@glandais/vcyclist-elevation-wasm 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +34 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -112,16 +112,42 @@ suspend fun virtualize(xml: String): String {
112
112
  `generateTypeScriptDefinitions()` is enabled on both `js(IR)` and `wasmJs`, so you get a
113
113
  `.d.ts` next to the bundle in `build/dist/{js,wasmJs}/productionExecutable/vcyclist-engine.d.{ts,mts}`.
114
114
 
115
+ The Kotlin/JS variant (`@glandais/vcyclist-engine`, `@glandais/vcyclist-elevation`) runs
116
+ **in both browser and Node.js / Bun**. The Wasm variants (`*-wasm`) are browser-only.
117
+
118
+ #### Browser
119
+
115
120
  ```js
116
- import { parseGpx, enhance, writeGpx, pathSize, pathTotalDistance } from './vcyclist-engine.mjs';
121
+ import { parseGpx, enhance, writeGpx, pathSize, pathTotalDistance } from '@glandais/vcyclist-engine';
117
122
 
118
123
  const handle = parseGpx(gpxXml);
119
124
  console.log('input points:', pathSize(handle));
120
- const out = await enhance(handle, null);
125
+ const out = await enhance(handle, null); // physics only, no HTTP
121
126
  console.log('output:', pathSize(out), pathTotalDistance(out), 'm');
122
127
  const xml = writeGpx(out);
123
128
  ```
124
129
 
130
+ #### Node.js / Bun (with elevation correction)
131
+
132
+ ```js
133
+ import { parseGpx, enhance, writeGpx } from '@glandais/vcyclist-engine';
134
+
135
+ const handle = parseGpx(gpxXml);
136
+ const out = await enhance(handle, { fixElevation: true }); // fetches DEM tiles, decodes WebP
137
+ const xml = writeGpx(out);
138
+ ```
139
+
140
+ `enhance(..., { fixElevation: true })` auto-instantiates a default `ElevationProvider`
141
+ (mapterhorn Terrarium tiles) and runs the full pipeline (densify → fix elevation → smooth →
142
+ max speeds → virtualize → resample → simplify).
143
+
144
+ On Node.js / Bun, tile decoding uses [`@jsquash/webp`](https://www.npmjs.com/package/@jsquash/webp)
145
+ (a pure-WASM WebP decoder, ~50 KB, listed as a runtime `dependency` of
146
+ `@glandais/vcyclist-engine` and `@glandais/vcyclist-elevation`). It is loaded lazily via
147
+ `eval('require')`, so browser bundlers do not pull it into the browser build. Requires
148
+ Node ≥ 18 (`globalThis.fetch` is built-in since Node 18 / Bun) ; Node 22+ recommended for
149
+ ESM `require()` support.
150
+
125
151
  ## Build & test
126
152
 
127
153
  ```bash
@@ -158,6 +184,12 @@ vcyclist/
158
184
  GPX I/O, full physics, simulation, post-processing, `Enhancer`, CLI, `@JsExport` façades.
159
185
  - ✅ **Phase 2bis** — pipeline fidelity fixes (tasks 29-31) : `VirtualizeService` last-point
160
186
  timestamp, `PointPerDistance` port, integration into `Enhancer`.
187
+ - ✅ **Phase 3** — Node.js / Bun support (tasks 32-33) : runtime-detection in
188
+ `TileFetcher.js.kt` (browser path unchanged, Node path uses `globalThis.fetch` +
189
+ `@jsquash/webp` WASM decoder loaded via lazy `eval('require')`), webpack externals to keep
190
+ the browser bundle free of `@jsquash/webp`, `ElevationProvider` auto-instantiation in
191
+ `EngineJsApi.enhance` when `opts.fixElevation` is true (JS + Wasm façades), 6 jsTest classes
192
+ gated by `INTEGRATION=1`.
161
193
 
162
194
  Total `:engine` test coverage : 32 test classes / ~326 commonTest cases / 4 targets =
163
195
  ~1300 green executions, plus JVM-only smoke tests for the CLI and the full pipeline.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glandais/vcyclist-elevation-wasm",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "main": "vcyclist-elevation.mjs",
5
5
  "types": "vcyclist-elevation.d.mts",
6
6
  "devDependencies": {},