open-l2encdec 0.0.7 → 0.0.9
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 +6 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/package.json +6 -12
package/README.md
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
## Installation
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
+
# npm
|
|
6
7
|
$ npm install open-l2encdec
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
# yarn
|
|
8
10
|
$ yarn add open-l2encdec
|
|
9
|
-
|
|
11
|
+
|
|
12
|
+
# pnpm
|
|
10
13
|
$ pnpm add open-l2encdec
|
|
11
14
|
```
|
|
12
15
|
|
|
@@ -17,15 +20,12 @@ $ pnpm add open-l2encdec
|
|
|
17
20
|
```typescript
|
|
18
21
|
import { initL2EncDec, encode, decode, initParams } from 'open-l2encdec';
|
|
19
22
|
|
|
20
|
-
// Initialize the module
|
|
21
23
|
const module = await initL2EncDec();
|
|
22
24
|
|
|
23
|
-
// Encode data with protocol 111
|
|
24
25
|
const params = await initParams(111);
|
|
25
26
|
const input = new Uint8Array([1, 2, 3, 4, 5]);
|
|
26
27
|
const encoded = await encode(input, params, module);
|
|
27
28
|
|
|
28
|
-
// Decode data
|
|
29
29
|
const decoded = await decode(encoded, params, module);
|
|
30
30
|
```
|
|
31
31
|
|
|
@@ -97,14 +97,12 @@ Initializes default parameters for the specified protocol.
|
|
|
97
97
|
|
|
98
98
|
- [CMake](https://cmake.org/) >= 3.14
|
|
99
99
|
- [Emscripten](https://emscripten.org/) >= 4.0.21
|
|
100
|
-
- [Node.js](https://nodejs.org/) >=
|
|
100
|
+
- [Node.js](https://nodejs.org/) >= v22
|
|
101
101
|
- [npm](https://www.npmjs.com/), [yarn](https://yarnpkg.com/) or [pnpm](https://pnpm.io/)
|
|
102
102
|
|
|
103
103
|
### Building
|
|
104
104
|
|
|
105
105
|
```bash
|
|
106
|
-
$ yarn install
|
|
107
|
-
$ yarn wasm:build
|
|
108
106
|
$ yarn build
|
|
109
107
|
```
|
|
110
108
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TypeScript wrapper for l2encdec WASM module
|
|
3
3
|
*/
|
|
4
|
-
import type { MainModule, Params, Type, EncodeResult, DecodeResult } from "./l2encdec.js
|
|
4
|
+
import type { MainModule, Params, Type, EncodeResult, DecodeResult } from "./l2encdec.js";
|
|
5
5
|
export type { MainModule as L2EncDecModule, Params, Type, EncodeResult, DecodeResult };
|
|
6
6
|
/**
|
|
7
7
|
* Initialize and return the l2encdec WASM module
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,UAAU,EACV,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,YAAY,EACb,MAAM,eAAe,CAAC;AAGvB,YAAY,EACV,UAAU,IAAI,cAAc,EAC5B,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,YAAY,EACb,CAAC;AAqBF;;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
|
@@ -2,14 +2,20 @@
|
|
|
2
2
|
* TypeScript wrapper for l2encdec WASM module
|
|
3
3
|
*/
|
|
4
4
|
// ---- internal module cache ----
|
|
5
|
-
let cachedModule
|
|
5
|
+
let cachedModule;
|
|
6
6
|
// ---- internal loader ----
|
|
7
7
|
async function loadModule() {
|
|
8
8
|
if (cachedModule)
|
|
9
9
|
return cachedModule;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
// Try to load browser version in browser, node version in Node.js
|
|
11
|
+
if (typeof window !== 'undefined') {
|
|
12
|
+
const mod = await import("./dist/l2encdec.browser.js");
|
|
13
|
+
cachedModule = (await mod.default());
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const mod = await import("./dist/l2encdec.node.js");
|
|
17
|
+
cachedModule = (await mod.default());
|
|
18
|
+
}
|
|
13
19
|
return cachedModule;
|
|
14
20
|
}
|
|
15
21
|
/**
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAoBH,kCAAkC;AAClC,IAAI,YAAoC,CAAC;AAEzC,4BAA4B;AAC5B,KAAK,UAAU,UAAU;IACvB,IAAI,YAAY;QAAE,OAAO,YAAY,CAAC;IAEtC,kEAAkE;IAClE,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;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AAG,MAAM,IAAI,MAAM,UAAU,EAAE,CAAC;IACvC,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IAC9B,CAAC,CAAC,WAAW,CACX,MAAM,EACN,QAAQ,EACR,QAAQ,IAAI,EAAE,EACd,sBAAsB,IAAI,KAAK,CAChC,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "open-l2encdec",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "TypeScript/JavaScript bindings for open-l2encdec WASM module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -9,13 +9,8 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"default": "./dist/index.node.js"
|
|
15
|
-
},
|
|
16
|
-
"./wasm": {
|
|
17
|
-
"browser": "./dist/l2encdec.browser.js",
|
|
18
|
-
"import": "./dist/l2encdec.node.js"
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
19
14
|
}
|
|
20
15
|
},
|
|
21
16
|
"files": [
|
|
@@ -41,10 +36,9 @@
|
|
|
41
36
|
},
|
|
42
37
|
"scripts": {
|
|
43
38
|
"wasm:build": "cd ../.. && cmake --preset emscripten && cmake --build --preset emscripten-build",
|
|
44
|
-
"
|
|
45
|
-
"build:
|
|
46
|
-
"build
|
|
47
|
-
"prepublishOnly": "npm run build",
|
|
39
|
+
"wasm:copy": "node scripts/copy-wasm.js",
|
|
40
|
+
"ts:build": "npm run wasm:copy && tsc -p tsconfig.json",
|
|
41
|
+
"build": "npm run wasm:build && npm run ts:build",
|
|
48
42
|
"dev": "vite"
|
|
49
43
|
},
|
|
50
44
|
"devDependencies": {
|