Skip to content

Add in-docs web parser page powered by browser WASM#697

Open
1technophile wants to merge 2 commits into
developmentfrom
add-web-parser-page
Open

Add in-docs web parser page powered by browser WASM#697
1technophile wants to merge 2 commits into
developmentfrom
add-web-parser-page

Conversation

@1technophile
Copy link
Copy Markdown
Member

Description:

Adds a /parser page on the VitePress site that decodes BLE advertisements locally in the browser via a new BUILD_WASM_WEB Emscripten target (ENVIRONMENT=web,worker, EXPORT_ES6, SINGLE_FILE), built fresh by the docs publish workflow on each release. The Node.js WASM build shipped to npm is untouched.

Checklist:

  • The pull request is done against the latest development branch
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • I accept the DCO.

Adds a /parser page on the VitePress site that decodes BLE
advertisements locally in the browser via a new BUILD_WASM_WEB
Emscripten target (ENVIRONMENT=web,worker, EXPORT_ES6, SINGLE_FILE),
built fresh by the docs publish workflow on each release. The Node.js
WASM build shipped to npm is untouched.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@1technophile
Copy link
Copy Markdown
Member Author

@mhaberler feel free to share your comments

@mhaberler
Copy link
Copy Markdown
Contributor

mhaberler commented May 17, 2026

how can I preview this?
lost in build land :-/

ping @1technophile

@1technophile
Copy link
Copy Markdown
Member Author

Try this @mhaberler :

  1. Get Emscripten on your PATH (CI uses 3.1.61, any recent emsdk works):
    git clone https://github.com/emscripten-core/emsdk.git
    cd emsdk && ./emsdk install 3.1.61 && ./emsdk activate 3.1.61
    source ./emsdk_env.sh # puts emcmake/emmake on PATH

  2. Build the browser WASM (from the repo root):
    cd nodejs/theengs-decoder
    npm install
    npm run build:web
    That runs emcmake cmake -DBUILD_WASM_WEB=ON + emmake make, then copies the single-file ES6 module into
    docs/.vitepress/public/wasm/theengs_decoder_web.js.

  3. Run the docs site (from the repo root):
    npm install
    npm run docs:dev
    Then open the /parser page — it should load the decoder and decode the sample payload.

@mhaberler
Copy link
Copy Markdown
Contributor

LGTM - got it to work as outlined

if you merge this just close my PR

do you see any downside in one module for both use cases?

@1technophile
Copy link
Copy Markdown
Member Author

1technophile commented May 30, 2026

Going to update this PR to have one unified esm module

@1technophile 1technophile force-pushed the add-web-parser-page branch from 529e4af to 738c119 Compare May 30, 2026 19:25
Replace the separate BUILD_WASM (node, UMD) and BUILD_WASM_WEB (browser,
ES6) Emscripten targets with a single BUILD_WASM target that emits one ES
module running in the browser, web workers and Node.js
(ENVIRONMENT=web,worker,node, EXPORT_ES6, SINGLE_FILE).

The output is now theengs_decoder_wasm.mjs so Node loads it as an ES
module even though the npm package stays CommonJS; index.js loads it via
dynamic import() internally, leaving the public API unchanged. The same
artifact is shipped to npm (dist/) and to the docs site (public/wasm/),
so there is a single build to maintain and one tested binary everywhere.
@1technophile 1technophile force-pushed the add-web-parser-page branch from 738c119 to fdfff6c Compare May 30, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants