@lynx-js/tasm 0.0.28 → 0.0.30
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/CHANGELOG.md +6 -0
- package/build/darwin/Release/lepus.node +0 -0
- package/build/linux/Release/lepus.node +0 -0
- package/cli.js +111 -0
- package/lepus.js +5843 -6233
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
# 0.0.30
|
|
4
|
+
* enlarge wasm MAXIMUM_MEMORY to 4G;
|
|
5
|
+
|
|
6
|
+
# 0.0.29
|
|
7
|
+
* Introducing cli command for `@lynx-js/tasm`;
|
|
8
|
+
|
|
3
9
|
# 0.0.28
|
|
4
10
|
* Support parsing comma-separated keyframe key lists in CSS keyframes (e.g., "0%,50%,100%" or "from, to"), which are flattened into multiple keyframe entries sharing the same style properties.
|
|
5
11
|
|
|
Binary file
|
|
Binary file
|
package/cli.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const { decode_napi, decode_wasm, encode, supportNapi } = require("./index");
|
|
7
|
+
|
|
8
|
+
function printHelp() {
|
|
9
|
+
console.log(
|
|
10
|
+
[
|
|
11
|
+
"Usage:",
|
|
12
|
+
" lynx-tasm encode -i <input.json> -o <output.tasm>",
|
|
13
|
+
" lynx-tasm decode -i <input.tasm> -o <output.json>",
|
|
14
|
+
"",
|
|
15
|
+
"Options:",
|
|
16
|
+
" -i, --input Input file path (required)",
|
|
17
|
+
" -o, --output Output file path (required)",
|
|
18
|
+
" -h, --help Show help",
|
|
19
|
+
"",
|
|
20
|
+
"Examples:",
|
|
21
|
+
" lynx-tasm encode -i ./template.json -o ./template.tasm",
|
|
22
|
+
" lynx-tasm decode -i ./template.tasm -o ./template.json",
|
|
23
|
+
].join("\n")
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function parseArgs(argv) {
|
|
28
|
+
let input = "";
|
|
29
|
+
let output = "";
|
|
30
|
+
let help = false;
|
|
31
|
+
const positional = [];
|
|
32
|
+
|
|
33
|
+
for (let i = 0; i < argv.length; i++) {
|
|
34
|
+
const arg = argv[i];
|
|
35
|
+
if (arg === "-i" || arg === "--input") {
|
|
36
|
+
input = argv[++i] || "";
|
|
37
|
+
} else if (arg === "-o" || arg === "--output") {
|
|
38
|
+
output = argv[++i] || "";
|
|
39
|
+
} else if (arg === "-h" || arg === "--help") {
|
|
40
|
+
help = true;
|
|
41
|
+
} else {
|
|
42
|
+
positional.push(arg);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return { input, output, help, positional };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function main() {
|
|
50
|
+
const { input, output, help, positional } = parseArgs(process.argv.slice(2));
|
|
51
|
+
|
|
52
|
+
if (help || positional.length === 0) {
|
|
53
|
+
printHelp();
|
|
54
|
+
process.exit(help ? 0 : 1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const command = positional[0];
|
|
58
|
+
if (command !== "decode" && command !== "encode") {
|
|
59
|
+
console.error(`Unknown command: ${command}`);
|
|
60
|
+
printHelp();
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!input) {
|
|
65
|
+
console.error("Missing required argument: --input");
|
|
66
|
+
printHelp();
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
if (!output) {
|
|
70
|
+
console.error("Missing required argument: --output");
|
|
71
|
+
printHelp();
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const inputPath = path.resolve(process.cwd(), input);
|
|
76
|
+
const outputPath = path.resolve(process.cwd(), output);
|
|
77
|
+
if (command === "decode") {
|
|
78
|
+
const inputBuffer = fs.readFileSync(inputPath);
|
|
79
|
+
let result;
|
|
80
|
+
if (supportNapi()) {
|
|
81
|
+
try {
|
|
82
|
+
result = await decode_napi(inputBuffer);
|
|
83
|
+
} catch (err) {
|
|
84
|
+
const isMissingNapiBinary =
|
|
85
|
+
err &&
|
|
86
|
+
err.code === "MODULE_NOT_FOUND" &&
|
|
87
|
+
String(err.message || "").includes("lepus.node");
|
|
88
|
+
if (!isMissingNapiBinary) {
|
|
89
|
+
throw err;
|
|
90
|
+
}
|
|
91
|
+
result = await decode_wasm(inputBuffer);
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
result = await decode_wasm(inputBuffer);
|
|
95
|
+
}
|
|
96
|
+
const content = JSON.stringify(result, null, 2);
|
|
97
|
+
fs.writeFileSync(outputPath, `${content}\n`, "utf8");
|
|
98
|
+
console.error(`Decode succeeded. Output written to: ${outputPath}`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const inputJson = JSON.parse(fs.readFileSync(inputPath, "utf8"));
|
|
103
|
+
const result = await encode(inputJson);
|
|
104
|
+
fs.writeFileSync(outputPath, result.buffer);
|
|
105
|
+
console.error(`Encode succeeded. Output written to: ${outputPath}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
main().catch((err) => {
|
|
109
|
+
console.error(err && err.message ? err.message : String(err));
|
|
110
|
+
process.exit(1);
|
|
111
|
+
});
|