Skip to content

Commit

Permalink
Test build for Emscripten PR 21701
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Apr 15, 2024
1 parent 9a0856d commit c1cadd3
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 26 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Uses libvips v8.15.2, compiled with Emscripten v3.1.57.

### Changed

- Inline worker scripts (`*.worker.js`) into the main output file.
[emscripten-core/emscripten#21701](https://github.com/emscripten-core/emscripten/pull/21701)

## [v0.0.8] - 2024-03-17

Uses libvips v8.15.2, compiled with Emscripten v3.1.56.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN \

# Emscripten patches
RUN \
curl -Ls https://github.com/emscripten-core/emscripten/compare/3.1.57...kleisauke:wasm-vips-3.1.57.patch | patch -p1 -d $EMSDK/upstream/emscripten && \
curl -Ls https://github.com/emscripten-core/emscripten/compare/3.1.57...kleisauke:wasm-vips-3.1.57-pthread_inline.patch | patch -p1 -d $EMSDK/upstream/emscripten && \
emcc --clear-cache && embuilder build sysroot --force

# Rust
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ yarn add wasm-vips

### Browser

Requires `vips.js`, `vips.wasm` and `vips.worker.js` to be served from
the same directory. Additionally, when using ES6 modules, it's necessary
to also serve the `vips-es6.js` and `vips-es6.worker.js` files.
Requires `vips.js` (or `vips-es6.js`) and `vips.wasm` to be served from
the same directory.

Since wasm-vips requires [the `SharedArrayBuffer` API](
https://caniuse.com/sharedarraybuffer), the website needs to opt-in to
a cross-origin isolated state, by serving the following HTTP headers on
both the main document and worker script (`*.worker.js`):
both the main document and `vips*.js` script:

```http
Cross-Origin-Embedder-Policy: require-corp
Expand Down
2 changes: 0 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,7 @@ node --version

# Omit -es6 suffix from Node.js files
mv $SOURCE_DIR/lib/vips-node-es6.mjs $SOURCE_DIR/lib/vips-node.mjs
mv $SOURCE_DIR/lib/vips-node-es6.worker.mjs $SOURCE_DIR/lib/vips-node.worker.mjs
sed -i 's/vips-node-es6/vips-node/g' $SOURCE_DIR/lib/vips-node.mjs
sed -i 's/vips-node-es6/vips-node/g' $SOURCE_DIR/lib/vips-node.worker.mjs

# Print the target features section
echo -n "Used Wasm features: "
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
"ignore": [
"src/closure-externs/wasm-vips.js",
"src/fixed-threadpool-web.js",
"src/locatefile-cors-pre.js",
"src/modules-pre.js"
"src/modules-pre.js",
"src/workaround-cors-pre.js"
],
"env": [
"browser",
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ endif()

if ("web" IN_LIST ENVIRONMENT)
set(WEB_CORS_WORKAROUND
--pre-js=${CMAKE_CURRENT_SOURCE_DIR}/locatefile-cors-pre.js
--pre-js=${CMAKE_CURRENT_SOURCE_DIR}/workaround-cors-pre.js
)
set(WEB_FIXED_THREADPOOL
--js-library=${CMAKE_CURRENT_SOURCE_DIR}/fixed-threadpool-web.js
Expand Down
16 changes: 0 additions & 16 deletions src/locatefile-cors-pre.js

This file was deleted.

7 changes: 7 additions & 0 deletions src/workaround-cors-pre.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// https://stackoverflow.com/q/25458104
if (Module['workaroundCors']) {
Module['mainScriptUrlOrBlob'] = Module['mainScriptUrlOrBlob'] ||
URL.createObjectURL(new Blob(
[`importScripts('${_scriptName}');`],
{'type': 'application/javascript'}));
}

0 comments on commit c1cadd3

Please sign in to comment.