wickra-compile 0.1.1 → 0.1.3

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.
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  <p align="center">
2
- <a href="https://wickra.org"><img src="https://raw.githubusercontent.com/wickra-lib/.github/main/profile/wickra-banner.webp?v=514" alt="Wickra Compile — compile a strategy spec into a standalone deployable" width="100%"></a>
2
+ <a href="https://wickra.org"><img src="https://raw.githubusercontent.com/wickra-lib/.github/main/profile/wickra-banner.webp?v=514-7" alt="Wickra Compile — compile a strategy spec into a standalone deployable" width="100%"></a>
3
3
  </p>
4
4
 
5
- [![Built on Wickra](https://img.shields.io/badge/built%20on-wickra-3b82f6)](https://github.com/wickra-lib/wickra)
6
- [![Status](https://img.shields.io/badge/status-pre--release-orange)](https://github.com/wickra-lib/wickra-compile)
5
+ [![Built on Wickra](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-compile/built-on.svg)](https://github.com/wickra-lib/wickra)
6
+ [![Status](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-compile/status.svg)](https://github.com/wickra-lib/wickra-compile)
7
7
  [![CI](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-compile/ci.svg)](https://github.com/wickra-lib/wickra-compile/actions/workflows/ci.yml)
8
8
  [![CodeQL](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-compile/codeql.svg)](https://github.com/wickra-lib/wickra-compile/actions/workflows/codeql.yml)
9
9
  [![codecov](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-compile/codecov.svg)](https://codecov.io/gh/wickra-lib/wickra-compile)
@@ -19,22 +19,24 @@
19
19
  [![OpenSSF Scorecard](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-compile/scorecard.svg)](https://scorecard.dev/viewer/?uri=github.com/wickra-lib/wickra-compile)
20
20
  [![OpenSSF Best Practices](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-compile/best-practices.svg)](https://www.bestpractices.dev)
21
21
  [![Build provenance](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-compile/provenance.svg)](https://github.com/wickra-lib/wickra-compile/attestations)
22
- [![Docs](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-compile/docs.svg)](https://wickra.org)
22
+ [![Docs](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-compile/docs.svg)](https://compile.wickra.org)
23
23
  [![Verified across 10 languages](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-compile/verified.svg)](golden/)
24
- [![Deterministic manifest](https://img.shields.io/badge/manifest-deterministic-3b82f6)](#determinism)
24
+ [![Deterministic manifest](https://raw.githubusercontent.com/wickra-lib/.github/main/profile/badges/wickra-compile/manifest.svg)](#determinism)
25
25
 
26
26
  ---
27
27
 
28
- # Wickra Compile
29
-
30
28
  **Compile a strategy spec into a standalone deployable: a WASM module, a
31
29
  self-contained binary, or a `no_std` artifact for microcontrollers. Write once
32
30
  as data, deploy anywhere.**
33
31
 
34
- > **Part of the [Wickra ecosystem](https://github.com/wickra-lib):** the same data-driven core and ten-language binding surface also power [wickra-exchange](https://github.com/wickra-lib/wickra-exchange), [wickra-backtest](https://github.com/wickra-lib/wickra-backtest), [wickra-terminal](https://github.com/wickra-lib/wickra-terminal) and 20 more — see [the full list](https://github.com/wickra-lib).
35
- > same [`StrategySpec`](https://github.com/wickra-lib/wickra-backtest) that
36
- > `wickra-backtest` runs and emits a self-contained project that embeds the spec
37
- > and calls the Wickra engine — no interpreter, no runtime spec parsing.
32
+ > **▶ Live demos:** the backtester compiled to WebAssembly, an equity curve building bar by bar — **[backtest-live.wickra.org](https://backtest-live.wickra.org)**;
33
+ > one StrategySpec side by side in Python, Rust, JS and Go — **[playground.wickra.org](https://playground.wickra.org)**;
34
+ > all 514 indicators of the core over a real Binance feed — **[live.wickra.org](https://live.wickra.org)**. Zero backend, all of them.
35
+
36
+ **Part of the [Wickra ecosystem](#ecosystem):** the same data-driven core and ten-language binding surface also power [wickra-exchange](https://github.com/wickra-lib/wickra-exchange), [wickra-backtest](https://github.com/wickra-lib/wickra-backtest), [wickra-terminal](https://github.com/wickra-lib/wickra-terminal) and 20 more — see [the full list](https://github.com/wickra-lib).
37
+ same [`StrategySpec`](https://github.com/wickra-lib/wickra-backtest) that
38
+ `wickra-backtest` runs and emits a self-contained project that embeds the spec
39
+ and calls the Wickra engine — no interpreter, no runtime spec parsing.
38
40
 
39
41
  Wickra Compile is the **output** side of strategy authoring: instead of wrestling
40
42
  a Pine-like input language, you write your strategy as a `StrategySpec` (data),
@@ -53,9 +55,18 @@ cargo run -p wickra-compile -- --spec golden/specs/sma_cross.json --dry-run --ou
53
55
 
54
56
  ## Status
55
57
 
56
- Early development (0.1.0). The codegen core, the reference CLI, the
58
+ **0.1.3 — the current release.** The codegen core, the reference CLI, the
57
59
  ten-language binding surface, the golden corpus and the full CI matrix are in
58
- place; 0.1.0 is the first published release.
60
+ place.
61
+
62
+ ## Documentation
63
+
64
+ - [ARCHITECTURE.md](docs/ARCHITECTURE.md) — the crates and the codegen pipeline.
65
+ - [COMPILESPEC.md](docs/COMPILESPEC.md) — the input schema.
66
+ - [TARGETS.md](docs/TARGETS.md) — WASM / binary / `no_std` and the MCU allowlist.
67
+ - [DETERMINISM.md](docs/DETERMINISM.md) — why the manifest is reproducible.
68
+ - [TEMPLATES.md](docs/TEMPLATES.md) — codegen and injection safety.
69
+ - [Cookbook.md](docs/Cookbook.md) — practical recipes.
59
70
 
60
71
  ## How it works
61
72
 
@@ -110,15 +121,6 @@ print(out["manifest"]["project_hash"]) # identical in every binding
110
121
 
111
122
  See [`examples/`](examples/) for the same program in all ten languages.
112
123
 
113
- ## Documentation
114
-
115
- - [ARCHITECTURE.md](docs/ARCHITECTURE.md) — the crates and the codegen pipeline.
116
- - [COMPILESPEC.md](docs/COMPILESPEC.md) — the input schema.
117
- - [TARGETS.md](docs/TARGETS.md) — WASM / binary / `no_std` and the MCU allowlist.
118
- - [DETERMINISM.md](docs/DETERMINISM.md) — why the manifest is reproducible.
119
- - [TEMPLATES.md](docs/TEMPLATES.md) — codegen and injection safety.
120
- - [Cookbook.md](docs/Cookbook.md) — practical recipes.
121
-
122
124
  ## Project layout
123
125
 
124
126
  ```
@@ -171,12 +173,6 @@ Run the suites with the commands in
171
173
  - **Fuzz** — `fuzz/` holds libFuzzer targets over spec and target parsing, the
172
174
  canonical hash and the codegen; CI runs each for a short smoke.
173
175
 
174
- ## Benchmarks
175
-
176
- Codegen is pure data templating and hashing — tens of microseconds, no
177
- compilation. See [BENCHMARKS.md](BENCHMARKS.md); reproduce with
178
- `cargo bench -p compile-bench`.
179
-
180
176
  ## Requirements
181
177
 
182
178
  - **Rust 1.86+** — the workspace MSRV; the Node binding needs **Rust 1.88**.
@@ -192,11 +188,11 @@ compilation. See [BENCHMARKS.md](BENCHMARKS.md); reproduce with
192
188
 
193
189
  See each `bindings/<lang>/README.md` for the per-language build and install.
194
190
 
195
- ## Security
191
+ ## Benchmarks
196
192
 
197
- See [SECURITY.md](SECURITY.md) and [THREAT_MODEL.md](THREAT_MODEL.md). The
198
- compiler generates code and can invoke `cargo` on it — run it only on trusted
199
- specs.
193
+ Codegen is pure data templating and hashing — tens of microseconds, no
194
+ compilation. See [BENCHMARKS.md](BENCHMARKS.md); reproduce with
195
+ `cargo bench -p compile-bench`.
200
196
 
201
197
  ## Ecosystem
202
198
 
@@ -235,17 +231,28 @@ in-browser demo at [wickra.org](https://wickra.org).
235
231
 
236
232
  See [CONTRIBUTING.md](CONTRIBUTING.md).
237
233
 
234
+ ## Security
235
+
236
+ See [SECURITY.md](SECURITY.md) and [THREAT_MODEL.md](THREAT_MODEL.md). The
237
+ compiler generates code and can invoke `cargo` on it — run it only on trusted
238
+ specs.
239
+
238
240
  ## License
239
241
 
240
- Dual-licensed under either of
242
+ Licensed under either of
243
+
244
+ - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
245
+ <http://www.apache.org/licenses/LICENSE-2.0>)
246
+ - MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
247
+
248
+ at your option. Use it, fork it, modify it, redistribute it — commercially or
249
+ not — file issues, send pull requests; all welcome.
241
250
 
242
- - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE))
243
- - MIT license ([LICENSE-MIT](LICENSE-MIT))
251
+ ### Contribution
244
252
 
245
- at your option. Unless you explicitly state otherwise, any contribution
246
- intentionally submitted for inclusion in this work, as defined in the Apache-2.0
247
- license, shall be dual-licensed as above, without any additional terms or
248
- conditions.
253
+ Unless you explicitly state otherwise, any contribution intentionally submitted
254
+ for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
255
+ dual licensed as above, without any additional terms or conditions.
249
256
 
250
257
  ## Disclaimer
251
258
 
package/index.d.ts CHANGED
@@ -1,6 +1,14 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
3
 
4
+ /**
5
+ * Which binding artifact the generated loader actually loaded: `'native'` for
6
+ * a native addon, otherwise the `platformArchABI` of the WASI flavor. Every
7
+ * flavor napi-rs can build is listed, because `NAPI_RS_NATIVE_LIBRARY_PATH`
8
+ * can point the loader at a WASI artifact this package does not build itself.
9
+ */
10
+ export declare const __napiBindingTarget: 'native' | 'wasm32-wasi' | 'wasm32-wasip1'
11
+
4
12
  /** A compiler driven by JSON commands. */
5
13
  export declare class Compiler {
6
14
  /** Construct a compiler handle. */
package/index.js CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  const { readFileSync } = require('fs')
6
6
  let nativeBinding = null
7
+ // Which artifact actually loaded. The WASI fallback chain overwrites it with
8
+ // the flavor it resolved; the late native retry below leaves it alone because
9
+ // it only runs while no WASI candidate has been loaded.
10
+ let __napiLoadedBindingTarget = 'native'
7
11
  const loadErrors = []
8
12
 
9
13
  const isMusl = () => {
@@ -62,7 +66,16 @@ const isMuslFromChildProcess = () => {
62
66
  function requireNative() {
63
67
  if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
64
68
  try {
65
- return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
69
+ const overrideBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
70
+ // The override may be a generated WASI loader, which already reports its
71
+ // own flavor. Adopt it: `module.exports` aliases this object, so claiming
72
+ // 'native' would both misreport the artifact and overwrite the loader's
73
+ // marker through the alias.
74
+ __napiLoadedBindingTarget =
75
+ overrideBinding && typeof overrideBinding.__napiBindingTarget === 'string'
76
+ ? overrideBinding.__napiBindingTarget
77
+ : 'native'
78
+ return overrideBinding
66
79
  } catch (err) {
67
80
  loadErrors.push(err)
68
81
  }
@@ -76,8 +89,8 @@ function requireNative() {
76
89
  try {
77
90
  const binding = require('wickra-compile-android-arm64')
78
91
  const bindingPackageVersion = require('wickra-compile-android-arm64/package.json').version
79
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
80
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
92
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
93
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
81
94
  }
82
95
  return binding
83
96
  } catch (e) {
@@ -92,8 +105,8 @@ function requireNative() {
92
105
  try {
93
106
  const binding = require('wickra-compile-android-arm-eabi')
94
107
  const bindingPackageVersion = require('wickra-compile-android-arm-eabi/package.json').version
95
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
96
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
108
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
109
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
97
110
  }
98
111
  return binding
99
112
  } catch (e) {
@@ -113,8 +126,8 @@ function requireNative() {
113
126
  try {
114
127
  const binding = require('wickra-compile-win32-x64-gnu')
115
128
  const bindingPackageVersion = require('wickra-compile-win32-x64-gnu/package.json').version
116
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
117
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
129
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
130
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
118
131
  }
119
132
  return binding
120
133
  } catch (e) {
@@ -129,8 +142,8 @@ function requireNative() {
129
142
  try {
130
143
  const binding = require('wickra-compile-win32-x64-msvc')
131
144
  const bindingPackageVersion = require('wickra-compile-win32-x64-msvc/package.json').version
132
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
133
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
145
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
146
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
134
147
  }
135
148
  return binding
136
149
  } catch (e) {
@@ -146,8 +159,8 @@ function requireNative() {
146
159
  try {
147
160
  const binding = require('wickra-compile-win32-ia32-msvc')
148
161
  const bindingPackageVersion = require('wickra-compile-win32-ia32-msvc/package.json').version
149
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
150
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
162
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
163
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
151
164
  }
152
165
  return binding
153
166
  } catch (e) {
@@ -162,8 +175,8 @@ function requireNative() {
162
175
  try {
163
176
  const binding = require('wickra-compile-win32-arm64-msvc')
164
177
  const bindingPackageVersion = require('wickra-compile-win32-arm64-msvc/package.json').version
165
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
166
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
178
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
179
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
167
180
  }
168
181
  return binding
169
182
  } catch (e) {
@@ -181,8 +194,8 @@ function requireNative() {
181
194
  try {
182
195
  const binding = require('wickra-compile-darwin-universal')
183
196
  const bindingPackageVersion = require('wickra-compile-darwin-universal/package.json').version
184
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
185
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
197
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
198
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
186
199
  }
187
200
  return binding
188
201
  } catch (e) {
@@ -197,8 +210,8 @@ function requireNative() {
197
210
  try {
198
211
  const binding = require('wickra-compile-darwin-x64')
199
212
  const bindingPackageVersion = require('wickra-compile-darwin-x64/package.json').version
200
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
201
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
213
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
214
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
202
215
  }
203
216
  return binding
204
217
  } catch (e) {
@@ -213,8 +226,8 @@ function requireNative() {
213
226
  try {
214
227
  const binding = require('wickra-compile-darwin-arm64')
215
228
  const bindingPackageVersion = require('wickra-compile-darwin-arm64/package.json').version
216
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
217
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
229
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
230
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
218
231
  }
219
232
  return binding
220
233
  } catch (e) {
@@ -233,8 +246,8 @@ function requireNative() {
233
246
  try {
234
247
  const binding = require('wickra-compile-freebsd-x64')
235
248
  const bindingPackageVersion = require('wickra-compile-freebsd-x64/package.json').version
236
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
237
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
249
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
250
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
238
251
  }
239
252
  return binding
240
253
  } catch (e) {
@@ -249,8 +262,8 @@ function requireNative() {
249
262
  try {
250
263
  const binding = require('wickra-compile-freebsd-arm64')
251
264
  const bindingPackageVersion = require('wickra-compile-freebsd-arm64/package.json').version
252
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
253
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
265
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
266
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
254
267
  }
255
268
  return binding
256
269
  } catch (e) {
@@ -270,8 +283,8 @@ function requireNative() {
270
283
  try {
271
284
  const binding = require('wickra-compile-linux-x64-musl')
272
285
  const bindingPackageVersion = require('wickra-compile-linux-x64-musl/package.json').version
273
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
274
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
286
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
287
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
275
288
  }
276
289
  return binding
277
290
  } catch (e) {
@@ -286,8 +299,8 @@ function requireNative() {
286
299
  try {
287
300
  const binding = require('wickra-compile-linux-x64-gnu')
288
301
  const bindingPackageVersion = require('wickra-compile-linux-x64-gnu/package.json').version
289
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
290
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
302
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
303
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
291
304
  }
292
305
  return binding
293
306
  } catch (e) {
@@ -304,8 +317,8 @@ function requireNative() {
304
317
  try {
305
318
  const binding = require('wickra-compile-linux-arm64-musl')
306
319
  const bindingPackageVersion = require('wickra-compile-linux-arm64-musl/package.json').version
307
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
308
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
320
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
321
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
309
322
  }
310
323
  return binding
311
324
  } catch (e) {
@@ -320,8 +333,8 @@ function requireNative() {
320
333
  try {
321
334
  const binding = require('wickra-compile-linux-arm64-gnu')
322
335
  const bindingPackageVersion = require('wickra-compile-linux-arm64-gnu/package.json').version
323
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
324
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
336
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
337
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
325
338
  }
326
339
  return binding
327
340
  } catch (e) {
@@ -338,8 +351,8 @@ function requireNative() {
338
351
  try {
339
352
  const binding = require('wickra-compile-linux-arm-musleabihf')
340
353
  const bindingPackageVersion = require('wickra-compile-linux-arm-musleabihf/package.json').version
341
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
342
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
354
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
355
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
343
356
  }
344
357
  return binding
345
358
  } catch (e) {
@@ -354,8 +367,8 @@ function requireNative() {
354
367
  try {
355
368
  const binding = require('wickra-compile-linux-arm-gnueabihf')
356
369
  const bindingPackageVersion = require('wickra-compile-linux-arm-gnueabihf/package.json').version
357
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
358
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
370
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
371
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
359
372
  }
360
373
  return binding
361
374
  } catch (e) {
@@ -372,8 +385,8 @@ function requireNative() {
372
385
  try {
373
386
  const binding = require('wickra-compile-linux-loong64-musl')
374
387
  const bindingPackageVersion = require('wickra-compile-linux-loong64-musl/package.json').version
375
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
376
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
388
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
389
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
377
390
  }
378
391
  return binding
379
392
  } catch (e) {
@@ -388,8 +401,8 @@ function requireNative() {
388
401
  try {
389
402
  const binding = require('wickra-compile-linux-loong64-gnu')
390
403
  const bindingPackageVersion = require('wickra-compile-linux-loong64-gnu/package.json').version
391
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
392
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
404
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
405
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
393
406
  }
394
407
  return binding
395
408
  } catch (e) {
@@ -406,8 +419,8 @@ function requireNative() {
406
419
  try {
407
420
  const binding = require('wickra-compile-linux-riscv64-musl')
408
421
  const bindingPackageVersion = require('wickra-compile-linux-riscv64-musl/package.json').version
409
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
410
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
422
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
423
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
411
424
  }
412
425
  return binding
413
426
  } catch (e) {
@@ -422,8 +435,8 @@ function requireNative() {
422
435
  try {
423
436
  const binding = require('wickra-compile-linux-riscv64-gnu')
424
437
  const bindingPackageVersion = require('wickra-compile-linux-riscv64-gnu/package.json').version
425
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
426
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
438
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
439
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
427
440
  }
428
441
  return binding
429
442
  } catch (e) {
@@ -439,8 +452,8 @@ function requireNative() {
439
452
  try {
440
453
  const binding = require('wickra-compile-linux-ppc64-gnu')
441
454
  const bindingPackageVersion = require('wickra-compile-linux-ppc64-gnu/package.json').version
442
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
443
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
455
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
456
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
444
457
  }
445
458
  return binding
446
459
  } catch (e) {
@@ -455,8 +468,8 @@ function requireNative() {
455
468
  try {
456
469
  const binding = require('wickra-compile-linux-s390x-gnu')
457
470
  const bindingPackageVersion = require('wickra-compile-linux-s390x-gnu/package.json').version
458
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
459
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
471
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
472
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
460
473
  }
461
474
  return binding
462
475
  } catch (e) {
@@ -475,8 +488,8 @@ function requireNative() {
475
488
  try {
476
489
  const binding = require('wickra-compile-openharmony-arm64')
477
490
  const bindingPackageVersion = require('wickra-compile-openharmony-arm64/package.json').version
478
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
479
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
491
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
492
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
480
493
  }
481
494
  return binding
482
495
  } catch (e) {
@@ -491,8 +504,8 @@ function requireNative() {
491
504
  try {
492
505
  const binding = require('wickra-compile-openharmony-x64')
493
506
  const bindingPackageVersion = require('wickra-compile-openharmony-x64/package.json').version
494
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
495
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
507
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
508
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
496
509
  }
497
510
  return binding
498
511
  } catch (e) {
@@ -507,8 +520,8 @@ function requireNative() {
507
520
  try {
508
521
  const binding = require('wickra-compile-openharmony-arm')
509
522
  const bindingPackageVersion = require('wickra-compile-openharmony-arm/package.json').version
510
- if (bindingPackageVersion !== '0.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
511
- throw new Error(`Native binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
523
+ if (bindingPackageVersion !== '0.1.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
524
+ throw new Error(`Native binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
512
525
  }
513
526
  return binding
514
527
  } catch (e) {
@@ -627,6 +640,7 @@ if (!nativeBinding || forceWasi) {
627
640
  if (!candidateFailed) {
628
641
  wasiBinding = require('./wickra-compile.wasi.cjs')
629
642
  nativeBinding = wasiBinding
643
+ __napiLoadedBindingTarget = 'wasm32-wasi'
630
644
  wasiBindingLoaded = true
631
645
  }
632
646
  } catch (err) {
@@ -647,12 +661,13 @@ if (!nativeBinding || forceWasi) {
647
661
  if (!candidateFailed) {
648
662
  if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
649
663
  const bindingPackageVersion = require('wickra-compile-wasm32-wasi/package.json').version
650
- if (bindingPackageVersion !== '0.1.1') {
651
- throw new Error(`WASI binding package version mismatch, expected 0.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
664
+ if (bindingPackageVersion !== '0.1.3') {
665
+ throw new Error(`WASI binding package version mismatch, expected 0.1.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
652
666
  }
653
667
  }
654
668
  wasiBinding = require('wickra-compile-wasm32-wasi')
655
669
  nativeBinding = wasiBinding
670
+ __napiLoadedBindingTarget = 'wasm32-wasi'
656
671
  wasiBindingLoaded = true
657
672
  }
658
673
  } catch (err) {
@@ -698,5 +713,69 @@ if (!nativeBinding) {
698
713
  throw new Error(`Failed to load native binding`)
699
714
  }
700
715
 
716
+ function __napiStampBindingTarget(exportsObject, target) {
717
+ if (
718
+ Object.prototype.hasOwnProperty.call(exportsObject, '__napiBindingTarget')
719
+ ) {
720
+ if (exportsObject.__napiBindingTarget === target) {
721
+ // Already ours: the root entry aliases the object it loaded, so a WASI
722
+ // fallback candidate — or a `NAPI_RS_NATIVE_LIBRARY_PATH` override that
723
+ // is a generated loader — arrives already stamped with this same value.
724
+ return target
725
+ }
726
+ const error = new Error(
727
+ '`__napiBindingTarget` is reserved by the generated binding loader, but the loaded binding already exports it. Rename the export, e.g. #[napi(js_name = "...")].',
728
+ )
729
+ error.code = 'ERR_NAPI_BINDING_TARGET_CONFLICT'
730
+ throw error
731
+ }
732
+ if (!Object.isExtensible(exportsObject)) {
733
+ // A `#[napi(module_exports)]` hook may seal or freeze this object
734
+ // (`Object::seal` / `Object::freeze`). Reporting the artifact is metadata,
735
+ // never a reason to fail an otherwise successful load, so the stamp is
736
+ // skipped. What a consumer still sees then follows the entry point: the
737
+ // browser and deferred loaders declare `__napiBindingTarget` at module
738
+ // level and go on reporting it, while the CommonJS entries hand back this
739
+ // very object as `module.exports`, so there the value is absent.
740
+ return target
741
+ }
742
+ try {
743
+ // [[Define]], not [[Set]]: an ordinary assignment walks the prototype
744
+ // chain, so an inherited accessor could swallow the value or throw and
745
+ // fail an otherwise successful load. The descriptor is what a successful
746
+ // assignment would have produced.
747
+ Object.defineProperty(exportsObject, '__napiBindingTarget', {
748
+ configurable: true,
749
+ enumerable: true,
750
+ value: target,
751
+ writable: true,
752
+ })
753
+ } catch {
754
+ // Same rule as the non-extensible skip above: reporting the artifact is
755
+ // metadata, never a reason to fail an otherwise successful load. An exotic
756
+ // object (a Proxy whose defineProperty trap refuses) is skipped, not
757
+ // thrown over.
758
+ }
759
+ // The CommonJS loaders assign this return value so `cjs-module-lexer` — and
760
+ // therefore Node's CJS -> ESM named export detection — can see
761
+ // `__napiBindingTarget` statically.
762
+ return target
763
+ }
764
+ // Stamp before the alias, not after. The guard only reads `nativeBinding`
765
+ // (`hasOwnProperty` plus a comparison), which is safe against any addon
766
+ // accessor; an assignment is not, because a `#[napi(module_exports)]` hook can
767
+ // expose a getter reporting this very value and a setter that throws. So the
768
+ // assignment lands on the loader's own `module.exports`, still the original
769
+ // object here, and the alias below replaces it.
770
+ //
771
+ // The assignment is what keeps the marker a statically visible CommonJS export:
772
+ // `cjs-module-lexer` is Node's CJS -> ESM named export detection, it cannot see
773
+ // a bare call, and the later `module.exports = nativeBinding` does not undo the
774
+ // detection. The assignment itself always succeeds — its target is this
775
+ // loader's own, still extensible `module.exports` — and the alias below then
776
+ // discards the value it wrote. What a consumer reads is whatever the guard put
777
+ // on `nativeBinding`, so on a frozen binding, where the guard skips, the
778
+ // linked import resolves to `undefined`.
779
+ module.exports.__napiBindingTarget = __napiStampBindingTarget(nativeBinding, __napiLoadedBindingTarget)
701
780
  module.exports = nativeBinding
702
781
  module.exports.Compiler = nativeBinding.Compiler
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wickra-compile",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Compile a Wickra strategy spec into a standalone deployable (WASM, binary, or no_std) with a deterministic manifest. Node bindings powered by Rust.",
5
5
  "author": "kingchenc <support@wickra.org>",
6
6
  "main": "index.js",
@@ -47,12 +47,12 @@
47
47
  "node": ">= 22"
48
48
  },
49
49
  "optionalDependencies": {
50
- "wickra-compile-linux-x64-gnu": "0.1.1",
51
- "wickra-compile-linux-arm64-gnu": "0.1.1",
52
- "wickra-compile-darwin-x64": "0.1.1",
53
- "wickra-compile-darwin-arm64": "0.1.1",
54
- "wickra-compile-win32-x64-msvc": "0.1.1",
55
- "wickra-compile-win32-arm64-msvc": "0.1.1"
50
+ "wickra-compile-darwin-arm64": "0.1.3",
51
+ "wickra-compile-darwin-x64": "0.1.3",
52
+ "wickra-compile-linux-arm64-gnu": "0.1.3",
53
+ "wickra-compile-linux-x64-gnu": "0.1.3",
54
+ "wickra-compile-win32-arm64-msvc": "0.1.3",
55
+ "wickra-compile-win32-x64-msvc": "0.1.3"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "napi build --platform --release",
@@ -62,6 +62,6 @@
62
62
  "test": "node --test"
63
63
  },
64
64
  "devDependencies": {
65
- "@napi-rs/cli": "^3.9.0"
65
+ "@napi-rs/cli": "^3.10.4"
66
66
  }
67
67
  }
Binary file
Binary file
Binary file
Binary file
Binary file