@wllzhang/afsim-compiler 0.5.3 → 0.5.6

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
@@ -55,14 +55,46 @@ end_platform_type
55
55
  ### `compile(data)`
56
56
 
57
57
  | Parameter | Type | Description |
58
- |-----------|------|-------------|
58
+ |-----------|------|--------------|
59
59
  | `data` | `object \| string` | Scenario definition as a JS object or JSON string |
60
60
  | **Returns** | `string` | Compiled AFSIM DSL text |
61
61
  | **Throws** | `Error` | On invalid input or compilation failure |
62
62
 
63
+ ## Environments
64
+
65
+ | Environment | Support |
66
+ |-------------|---------|
67
+ | **Browser** | Via Vite / webpack + wasm plugin (recommended) |
68
+ | **Node.js** | Via bundler (e.g. esbuild) — direct ESM import of `.wasm` is not supported |
69
+
70
+ ### Browser (Vite / webpack)
71
+
72
+ This package ships a **bundler**-targeted WebAssembly build. When using in a browser project, you need a WASM plugin to handle the `.wasm` import:
73
+
74
+ **Vite:**
75
+ ```bash
76
+ npm install vite-plugin-wasm
77
+ ```
78
+
79
+ ```js
80
+ // vite.config.js
81
+ import wasm from 'vite-plugin-wasm';
82
+
83
+ export default {
84
+ plugins: [wasm()],
85
+ build: { target: 'esnext' },
86
+ };
87
+ ```
88
+
89
+ **Webpack:** use `experiments.asyncWebAssembly: true` or a wasm loader.
90
+
91
+ ### Node.js
92
+
93
+ For Node.js scripts, bundle your code with a tool like [esbuild](https://esbuild.github.io/) that can resolve the `.wasm` import.
94
+
63
95
  ## Platforms
64
96
 
65
- Works everywhere: **browsers** (Chrome, Firefox, Safari, Edge), **Node.js** (v18+), and any bundler (Vite, webpack, etc.). No architecture-specific packages — one build fits all.
97
+ Works everywhere: **browsers** (Chrome, Firefox, Safari, Edge), **Node.js** (v18+). No architecture-specific packages — one build fits all.
66
98
 
67
99
  ## License
68
100
 
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { compile_json } from './pkg/afsim_compiler.js';
1
+ import { compile_json } from './pkg/afsim_compiler_lib.js';
2
2
 
3
3
  /**
4
4
  * Compile a JSON object into AFSIM DSL text.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wllzhang/afsim-compiler",
3
- "version": "0.5.3",
3
+ "version": "0.5.6",
4
4
  "description": "JSON to AFSIM DSL compiler — WebAssembly build for browsers and Node.js",
5
5
  "type": "module",
6
6
  "main": "index.mjs",
@@ -0,0 +1,9 @@
1
+ /* @ts-self-types="./afsim_compiler_lib.d.ts" */
2
+
3
+ import * as wasm from "./afsim_compiler_lib_bg.wasm";
4
+ import { __wbg_set_wasm } from "./afsim_compiler_lib_bg.js";
5
+ __wbg_set_wasm(wasm);
6
+
7
+ export {
8
+ compile_json
9
+ } from "./afsim_compiler_lib_bg.js";
@@ -21,6 +21,15 @@ export function compile_json(input) {
21
21
  wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
22
22
  }
23
23
  }
24
+ export function __wbg_error_7c5f5b5154c052d7(arg0, arg1) {
25
+ console.error(getStringFromWasm0(arg0, arg1));
26
+ }
27
+ export function __wbg_log_7d8110815355c340(arg0, arg1) {
28
+ console.log(getStringFromWasm0(arg0, arg1));
29
+ }
30
+ export function __wbg_warn_f2f01bad85a87234(arg0, arg1) {
31
+ console.warn(getStringFromWasm0(arg0, arg1));
32
+ }
24
33
  let cachedDataViewMemory0 = null;
25
34
  function getDataViewMemory0() {
26
35
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
Binary file
package/pkg/package.json CHANGED
@@ -4,15 +4,15 @@
4
4
  "description": "JSON to AFSIM DSL compiler",
5
5
  "version": "0.1.0",
6
6
  "files": [
7
- "afsim_compiler_bg.wasm",
8
- "afsim_compiler.js",
9
- "afsim_compiler_bg.js",
10
- "afsim_compiler.d.ts"
7
+ "afsim_compiler_lib_bg.wasm",
8
+ "afsim_compiler_lib.js",
9
+ "afsim_compiler_lib_bg.js",
10
+ "afsim_compiler_lib.d.ts"
11
11
  ],
12
- "main": "afsim_compiler.js",
13
- "types": "afsim_compiler.d.ts",
12
+ "main": "afsim_compiler_lib.js",
13
+ "types": "afsim_compiler_lib.d.ts",
14
14
  "sideEffects": [
15
- "./afsim_compiler.js",
15
+ "./afsim_compiler_lib.js",
16
16
  "./snippets/*"
17
17
  ]
18
18
  }
@@ -1,9 +0,0 @@
1
- /* @ts-self-types="./afsim_compiler.d.ts" */
2
-
3
- import * as wasm from "./afsim_compiler_bg.wasm";
4
- import { __wbg_set_wasm } from "./afsim_compiler_bg.js";
5
- __wbg_set_wasm(wasm);
6
-
7
- export {
8
- compile_json
9
- } from "./afsim_compiler_bg.js";
Binary file