ttmg-wasm-tool 1.0.3 → 1.0.5

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,11 +1,11 @@
1
- # @aspect/wasm-tool-node
1
+ # ttmg-wasm-tool
2
2
 
3
3
  Native Node.js module for WASM preparation and splitting. Supports macOS and Windows.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @aspect/wasm-tool-node
8
+ npm install ttmg-wasm-tool
9
9
  ```
10
10
 
11
11
  This will automatically compile the native module during installation.
@@ -22,10 +22,8 @@ This will automatically compile the native module during installation.
22
22
 
23
23
  ### prepareWasm(wasmBuffer: Buffer): PrepareResult
24
24
 
25
- Prepare a WASM module by inserting `scwebgl.logCall` instrumentation at the beginning of each function.
26
-
27
25
  ```typescript
28
- import { prepareWasm } from '@aspect/wasm-tool-node';
26
+ import { prepareWasm } from 'ttmg-wasm-tool';
29
27
  import { readFileSync, writeFileSync } from 'fs';
30
28
 
31
29
  const wasm = readFileSync('input.wasm');
@@ -98,50 +96,3 @@ interface SplitResult {
98
96
  subWasmBuffer?: Buffer;
99
97
  }
100
98
  ```
101
-
102
- ## Split Rules
103
-
104
- The WASM splitting follows these rules:
105
-
106
- 1. All import functions and element segment functions go to the main package
107
- 2. Functions directly called from main package that don't exist create stub functions with `scwebgl.wait` calls
108
- 3. Sub package contains all functions not in the main package
109
- 4. Sub package functions get `scwebgl.logCall` instrumentation
110
- 5. Non-import global variables are converted to imports for sharing between packages
111
-
112
- ## Building from Source
113
-
114
- ```bash
115
- # Install dependencies
116
- npm install
117
-
118
- # Build (Release)
119
- npm run build
120
-
121
- # Build (Debug)
122
- npm run build:debug
123
-
124
- # Clean build artifacts
125
- npm run clean
126
-
127
- # Rebuild
128
- npm run rebuild
129
- ```
130
-
131
- ## Pre-built Binaries
132
-
133
- To create pre-built binaries for distribution:
134
-
135
- ```bash
136
- # Current platform
137
- npm run prebuild
138
-
139
- # Specific platforms
140
- npm run prebuild:win32
141
- npm run prebuild:darwin
142
- npm run prebuild:darwin-arm64
143
- ```
144
-
145
- ## License
146
-
147
- MIT
Binary file
package/index.d.ts CHANGED
@@ -114,7 +114,7 @@ export function prepareWasm(wasmBuffer: Buffer): PrepareResult;
114
114
  * 5. Global variables are converted to imports for sharing between packages
115
115
  *
116
116
  * @param wasmBuffer - The input WASM binary buffer
117
- * @param funcIdList - Optional newline-separated list of function IDs to include in main package
117
+ * @param funcIdList - Optional array of function IDs to include in main package
118
118
  * @returns SplitResult containing main and sub package WASM buffers
119
119
  *
120
120
  * @example
@@ -134,7 +134,7 @@ export function prepareWasm(wasmBuffer: Buffer): PrepareResult;
134
134
  * }
135
135
  * ```
136
136
  */
137
- export function splitWasm(wasmBuffer: Buffer, funcIdList?: string): SplitResult;
137
+ export function splitWasm(wasmBuffer: Buffer, funcIdList?: Array<number>): SplitResult;
138
138
 
139
139
  /**
140
140
  * Split a WASM module for H5/web platform
@@ -148,7 +148,7 @@ export function splitWasm(wasmBuffer: Buffer, funcIdList?: string): SplitResult;
148
148
  * to create the merged_js output.
149
149
  *
150
150
  * @param wasmBuffer - The input WASM binary buffer
151
- * @param funcIdList - Optional newline-separated list of function IDs to include in main package
151
+ * @param funcIdList - Optional array of function IDs to include in main package
152
152
  * @returns SplitH5Result containing main WASM, sub WASM, and sub_elem.json
153
153
  *
154
154
  * @example
@@ -177,7 +177,7 @@ export function splitWasm(wasmBuffer: Buffer, funcIdList?: string): SplitResult;
177
177
  * }
178
178
  * ```
179
179
  */
180
- export function splitWasmH5(wasmBuffer: Buffer, funcIdList?: string): SplitH5Result;
180
+ export function splitWasmH5(wasmBuffer: Buffer, funcIdList?: Array<number>): SplitH5Result;
181
181
 
182
182
  /**
183
183
  * Result of wasm2js operation
@@ -353,8 +353,8 @@ export interface SplitH5FullResult {
353
353
  * Options for splitWasmH5Full
354
354
  */
355
355
  export interface SplitH5FullOptions {
356
- /** Newline-separated list of function IDs for main package */
357
- funcIdList?: string;
356
+ /** Array of function IDs for main package */
357
+ funcIdList?: Array<number>;
358
358
  /** Path to wasm2js binary */
359
359
  wasm2jsPath?: string;
360
360
  /** Whether to optimize the JS output */
package/index.js CHANGED
@@ -72,7 +72,7 @@ function prepareWasm(wasmBuffer) {
72
72
  /**
73
73
  * Split a WASM module into main and sub packages
74
74
  * @param {Buffer} wasmBuffer - The input WASM binary buffer
75
- * @param {string} [funcIdList] - Optional newline-separated list of function IDs for main package
75
+ * @param {Array<number>} [funcIdList] - Optional array of function IDs for main package
76
76
  * @returns {import('./index').SplitResult} Result containing main and sub package WASM buffers
77
77
  */
78
78
  function splitWasm(wasmBuffer, funcIdList) {
@@ -90,14 +90,15 @@ function splitWasm(wasmBuffer, funcIdList) {
90
90
  };
91
91
  }
92
92
 
93
- if (funcIdList !== undefined && typeof funcIdList !== 'string') {
93
+ if (funcIdList !== undefined && !Array.isArray(funcIdList)) {
94
94
  return {
95
95
  success: false,
96
- error: 'funcIdList must be a string if provided'
96
+ error: 'funcIdList must be an array of numbers if provided'
97
97
  };
98
98
  }
99
99
 
100
- return binding.splitWasm(wasmBuffer, funcIdList || '');
100
+ // Pass array directly to native binding (or undefined if not provided)
101
+ return binding.splitWasm(wasmBuffer, funcIdList);
101
102
  }
102
103
 
103
104
  /**
@@ -115,7 +116,7 @@ function splitWasm(wasmBuffer, funcIdList) {
115
116
  * - subElemJsonBuffer: sub_elem_range.json ({"funcName":[start,end],...})
116
117
  *
117
118
  * @param {Buffer} wasmBuffer - The input WASM binary buffer
118
- * @param {string} [funcIdList] - Optional newline-separated list of function IDs for main package
119
+ * @param {Array<number>} [funcIdList] - Optional array of function IDs for main package
119
120
  * @returns {import('./index').SplitH5Result} Result containing H5-specific split outputs
120
121
  *
121
122
  * @example
@@ -149,14 +150,15 @@ function splitWasmH5(wasmBuffer, funcIdList) {
149
150
  };
150
151
  }
151
152
 
152
- if (funcIdList !== undefined && typeof funcIdList !== 'string') {
153
+ if (funcIdList !== undefined && !Array.isArray(funcIdList)) {
153
154
  return {
154
155
  success: false,
155
- error: 'funcIdList must be a string if provided'
156
+ error: 'funcIdList must be an array of numbers if provided'
156
157
  };
157
158
  }
158
159
 
159
- return binding.splitWasmH5(wasmBuffer, funcIdList || '');
160
+ // Pass array directly to native binding (or undefined if not provided)
161
+ return binding.splitWasmH5(wasmBuffer, funcIdList);
160
162
  }
161
163
 
162
164
  /**
@@ -317,7 +319,7 @@ function wasm2jsFunctions(wasmBuffer, options = {}) {
317
319
  *
318
320
  * @param {Buffer} wasmBuffer - The input WASM binary buffer
319
321
  * @param {Object} [options] - Options
320
- * @param {string} [options.funcIdList] - Newline-separated list of function IDs for main package
322
+ * @param {Array<number>} [options.funcIdList] - Array of function IDs for main package
321
323
  * @param {string} [options.wasm2jsPath] - Path to wasm2js binary (fallback if no native support)
322
324
  * @param {boolean} [options.optimize] - Whether to optimize the JS output
323
325
  * @returns {import('./index').SplitH5FullResult} Complete H5 split result
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ttmg-wasm-tool",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Native Node.js module for WASM preparation and splitting",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",