diff --git a/.github/workflows/publish_docs.yml b/.github/workflows/publish_docs.yml index 54171575..80bb6c23 100644 --- a/.github/workflows/publish_docs.yml +++ b/.github/workflows/publish_docs.yml @@ -22,6 +22,14 @@ jobs: python -m pip install --upgrade pip pip install requests pandas markdown pytablereader tabulate npm install + - name: Set up Emscripten + uses: mymindstorm/setup-emsdk@v14 + with: + version: 3.1.61 + actions-cache-folder: emsdk-cache + - name: Build browser WebAssembly decoder + run: npm run build:web + working-directory: nodejs/theengs-decoder - name: Build documentation run: | npm run docs:build diff --git a/.gitignore b/.gitignore index e5db5b23..e1bec7ce 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,8 @@ docs/.vitepress/dist/ docs/.vitepress/cache/ docs/.vitepress/public/commonConfig.js docs/.vitepress/public/img/ +docs/.vitepress/public/wasm/ docs/.vitepress/data/devices.json +nodejs/theengs-decoder/build-web/ docs/devices/_app_devices.md generated/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dca9968..a54289ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,9 +36,13 @@ elseif(BUILD_WASM) target_compile_features(theengs_decoder_wasm PRIVATE cxx_std_17) + # Single ES6 module that runs in the browser, web workers and Node.js. + # The .mjs suffix lets Node load it as an ES module even though the npm + # package itself is CommonJS. SINGLE_FILE inlines the wasm so the same + # artifact is shipped to npm (dist/) and to the docs site (public/wasm/). set_target_properties(theengs_decoder_wasm PROPERTIES - SUFFIX ".js" - LINK_FLAGS "-lembind -sMODULARIZE=1 -sEXPORT_NAME=createTheengsDecoderModule -sENVIRONMENT=node -sALLOW_MEMORY_GROWTH=1 -sSINGLE_FILE=1 -sNODEJS_CATCH_EXIT=0 -sNODEJS_CATCH_REJECTION=0" + SUFFIX ".mjs" + LINK_FLAGS "-lembind -sMODULARIZE=1 -sEXPORT_ES6=1 -sEXPORT_NAME=createTheengsDecoderModule -sENVIRONMENT=web,worker,node -sALLOW_MEMORY_GROWTH=1 -sSINGLE_FILE=1 -sNODEJS_CATCH_EXIT=0 -sNODEJS_CATCH_REJECTION=0" ) else() diff --git a/docs/.vitepress/components/WebParser.vue b/docs/.vitepress/components/WebParser.vue new file mode 100644 index 00000000..135a2e50 --- /dev/null +++ b/docs/.vitepress/components/WebParser.vue @@ -0,0 +1,311 @@ + + +