ttmg-wasm-tool 1.0.4 → 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/build/Release/wasm_tool_node.node +0 -0
- package/index.d.ts +6 -6
- package/index.js +11 -9
- package/package.json +1 -1
|
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
|
|
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?:
|
|
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
|
|
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?:
|
|
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
|
-
/**
|
|
357
|
-
funcIdList?:
|
|
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 {
|
|
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 &&
|
|
93
|
+
if (funcIdList !== undefined && !Array.isArray(funcIdList)) {
|
|
94
94
|
return {
|
|
95
95
|
success: false,
|
|
96
|
-
error: 'funcIdList must be
|
|
96
|
+
error: 'funcIdList must be an array of numbers if provided'
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
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 {
|
|
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 &&
|
|
153
|
+
if (funcIdList !== undefined && !Array.isArray(funcIdList)) {
|
|
153
154
|
return {
|
|
154
155
|
success: false,
|
|
155
|
-
error: 'funcIdList must be
|
|
156
|
+
error: 'funcIdList must be an array of numbers if provided'
|
|
156
157
|
};
|
|
157
158
|
}
|
|
158
159
|
|
|
159
|
-
|
|
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 {
|
|
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
|