open-l2encdec 0.0.5 → 0.0.7

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/dist/index.d.ts CHANGED
@@ -1,35 +1,22 @@
1
1
  /**
2
2
  * TypeScript wrapper for l2encdec WASM module
3
3
  */
4
- import type { MainModule, Params, Type, EncodeResult, DecodeResult } from './interface.d.ts';
4
+ import type { MainModule, Params, Type, EncodeResult, DecodeResult } from "./l2encdec.js.d.ts";
5
5
  export type { MainModule as L2EncDecModule, Params, Type, EncodeResult, DecodeResult };
6
6
  /**
7
7
  * Initialize and return the l2encdec WASM module
8
8
  */
9
9
  export declare function initL2EncDec(): Promise<MainModule>;
10
10
  /**
11
- * Type-safe wrapper for encoding data
12
- * @param input - Input data as Uint8Array or number array
13
- * @param params - Encoding parameters
14
- * @param module - Optional pre-initialized module (for performance)
15
- * @returns Encoded data as Uint8Array
11
+ * Encode data
16
12
  */
17
13
  export declare function encode(input: Uint8Array | number[], params: Params, module?: MainModule): Promise<Uint8Array>;
18
14
  /**
19
- * Type-safe wrapper for decoding data
20
- * @param input - Input data as Uint8Array or number array
21
- * @param params - Decoding parameters
22
- * @param module - Optional pre-initialized module (for performance)
23
- * @returns Decoded data as Uint8Array
15
+ * Decode data
24
16
  */
25
17
  export declare function decode(input: Uint8Array | number[], params: Params, module?: MainModule): Promise<Uint8Array>;
26
18
  /**
27
- * Helper function to initialize params with protocol
28
- * @param protocol - Protocol number (last three digits of file header)
29
- * @param filename - Filename used for protocol 121 (XOR_FILENAME)
30
- * @param use_legacy_decrypt_rsa - Use legacy RSA decryption for protocols 411-414
31
- * @param module - Optional pre-initialized module (for performance)
32
- * @returns Initialized Params instance
19
+ * Initialize params
33
20
  */
34
21
  export declare function initParams(protocol: number, filename?: string, use_legacy_decrypt_rsa?: boolean, module?: MainModule): Promise<Params>;
35
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACR,UAAU,EACV,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,YAAY,EACf,MAAM,kBAAkB,CAAC;AAS1B,YAAY,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;AAEvF;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,UAAU,CAAC,CAExD;AAED;;;;;;GAMG;AACH,wBAAsB,MAAM,CACxB,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE,EAC5B,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,UAAU,GACpB,OAAO,CAAC,UAAU,CAAC,CAIrB;AAED;;;;;;GAMG;AACH,wBAAsB,MAAM,CACxB,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE,EAC5B,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,UAAU,GACpB,OAAO,CAAC,UAAU,CAAC,CAIrB;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC5B,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,EACjB,sBAAsB,CAAC,EAAE,OAAO,EAChC,MAAM,CAAC,EAAE,UAAU,GACpB,OAAO,CAAC,MAAM,CAAC,CAKjB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACR,UAAU,EACV,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,YAAY,EACb,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,UAAU,IAAI,cAAc,EAC5B,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,YAAY,EACb,CAAC;AAgBF;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,UAAU,CAAC,CAExD;AAED;;GAEG;AACH,wBAAsB,MAAM,CAC1B,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE,EAC5B,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,UAAU,GAClB,OAAO,CAAC,UAAU,CAAC,CAIrB;AAED;;GAEG;AACH,wBAAsB,MAAM,CAC1B,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE,EAC5B,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,UAAU,GAClB,OAAO,CAAC,UAAU,CAAC,CAIrB;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,EACjB,sBAAsB,CAAC,EAAE,OAAO,EAChC,MAAM,CAAC,EAAE,UAAU,GAClB,OAAO,CAAC,MAAM,CAAC,CAUjB"}
package/dist/index.js CHANGED
@@ -1,53 +1,46 @@
1
1
  /**
2
2
  * TypeScript wrapper for l2encdec WASM module
3
3
  */
4
- // Import WASM module factory
5
- // In development, Vite aliases this to build_wasm output
6
- // In production, this resolves to ./l2encdec.js in dist/
7
- // @ts-expect-error - Module resolution handled at runtime/build time
8
- import createModule from './l2encdec.js';
4
+ // ---- internal module cache ----
5
+ let cachedModule = null;
6
+ // ---- internal loader ----
7
+ async function loadModule() {
8
+ if (cachedModule)
9
+ return cachedModule;
10
+ const mod = await import("./l2encdec.js");
11
+ const createModule = mod.default;
12
+ cachedModule = await createModule();
13
+ return cachedModule;
14
+ }
9
15
  /**
10
16
  * Initialize and return the l2encdec WASM module
11
17
  */
12
18
  export async function initL2EncDec() {
13
- return await createModule();
19
+ return loadModule();
14
20
  }
15
21
  /**
16
- * Type-safe wrapper for encoding data
17
- * @param input - Input data as Uint8Array or number array
18
- * @param params - Encoding parameters
19
- * @param module - Optional pre-initialized module (for performance)
20
- * @returns Encoded data as Uint8Array
22
+ * Encode data
21
23
  */
22
24
  export async function encode(input, params, module) {
23
- const m = module || await initL2EncDec();
25
+ const m = module ?? await loadModule();
24
26
  const result = m.encode(input, params);
25
27
  return result instanceof Uint8Array ? result : new Uint8Array(result);
26
28
  }
27
29
  /**
28
- * Type-safe wrapper for decoding data
29
- * @param input - Input data as Uint8Array or number array
30
- * @param params - Decoding parameters
31
- * @param module - Optional pre-initialized module (for performance)
32
- * @returns Decoded data as Uint8Array
30
+ * Decode data
33
31
  */
34
32
  export async function decode(input, params, module) {
35
- const m = module || await initL2EncDec();
33
+ const m = module ?? await loadModule();
36
34
  const result = m.decode(input, params);
37
35
  return result instanceof Uint8Array ? result : new Uint8Array(result);
38
36
  }
39
37
  /**
40
- * Helper function to initialize params with protocol
41
- * @param protocol - Protocol number (last three digits of file header)
42
- * @param filename - Filename used for protocol 121 (XOR_FILENAME)
43
- * @param use_legacy_decrypt_rsa - Use legacy RSA decryption for protocols 411-414
44
- * @param module - Optional pre-initialized module (for performance)
45
- * @returns Initialized Params instance
38
+ * Initialize params
46
39
  */
47
40
  export async function initParams(protocol, filename, use_legacy_decrypt_rsa, module) {
48
- const m = module || await initL2EncDec();
41
+ const m = module ?? await loadModule();
49
42
  const params = new m.Params();
50
- m.init_params(params, protocol, filename || '', use_legacy_decrypt_rsa || false);
43
+ m.init_params(params, protocol, filename ?? "", use_legacy_decrypt_rsa ?? false);
51
44
  return params;
52
45
  }
53
46
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,6BAA6B;AAC7B,yDAAyD;AACzD,yDAAyD;AACzD,qEAAqE;AACrE,OAAO,YAAY,MAAM,eAAe,CAAC;AAKzC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAC9B,OAAO,MAAM,YAAY,EAAE,CAAC;AAChC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CACxB,KAA4B,EAC5B,MAAc,EACd,MAAmB;IAEnB,MAAM,CAAC,GAAG,MAAM,IAAI,MAAM,YAAY,EAAE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,MAAM,CAAC;AAChB,CAAC"}
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-l2encdec",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "TypeScript/JavaScript bindings for open-l2encdec WASM module",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -9,15 +9,14 @@
9
9
  "exports": {
10
10
  ".": {
11
11
  "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js",
13
- "default": "./dist/index.js"
12
+ "browser": "./dist/index.browser.js",
13
+ "import": "./dist/index.node.js",
14
+ "default": "./dist/index.node.js"
14
15
  },
15
16
  "./wasm": {
16
- "types": "./dist/interface.d.ts",
17
- "import": "./dist/l2encdec.js",
18
- "default": "./dist/l2encdec.js"
19
- },
20
- "./package.json": "./package.json"
17
+ "browser": "./dist/l2encdec.browser.js",
18
+ "import": "./dist/l2encdec.node.js"
19
+ }
21
20
  },
22
21
  "files": [
23
22
  "dist",
@@ -53,4 +52,4 @@
53
52
  "typescript": "^5.3.0",
54
53
  "vite": "^7.3.0"
55
54
  }
56
- }
55
+ }
package/dist/l2encdec.js DELETED
Binary file
File without changes