@hpcc-js/esbuild-plugins 1.0.1
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 +45 -0
- package/dist/index.js +282 -0
- package/dist/index.js.map +7 -0
- package/dist/sfx-wrapper.js +100 -0
- package/dist/sfx-wrapper.js.map +7 -0
- package/package.json +60 -0
- package/types/build.d.ts +983 -0
- package/types/exclude-sourcemap.d.ts +5 -0
- package/types/index.d.ts +5 -0
- package/types/problem-matcher.d.ts +2 -0
- package/types/rebuild-logger.d.ts +5 -0
- package/types/sfx-wrapper.d.ts +3 -0
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# esbuild-plugin-sfx-wasm
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
With npm:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm i -D esbuild-plugin-sfx-wasm
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Use-cases
|
|
12
|
+
|
|
13
|
+
**The primary motivation for this plugin is to simplify the bundling and distribution of web assembly modules**
|
|
14
|
+
|
|
15
|
+
- Compresses the wasm module using Zstd
|
|
16
|
+
- Encodes the compressed wasm module as a base91 string
|
|
17
|
+
- Generates a standalone module that decodes and instantiates the wasm module on demand
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Build Config
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import esbuild from "esbuild";
|
|
25
|
+
import sfxWasm from "esbuild-plugin-sfx-wasm";
|
|
26
|
+
|
|
27
|
+
esbuild.build({
|
|
28
|
+
/* ... */
|
|
29
|
+
plugins: [
|
|
30
|
+
sfxWasm()
|
|
31
|
+
],
|
|
32
|
+
/* ... */
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Usage in your code
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
import loadCalculator from "../build/calculator.wasm";
|
|
40
|
+
|
|
41
|
+
async function add(a, b) {
|
|
42
|
+
const calc = await loadCalculator();
|
|
43
|
+
return calc.add(1, 2);
|
|
44
|
+
}
|
|
45
|
+
```
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
// src/build.ts
|
|
2
|
+
import * as process from "process";
|
|
3
|
+
import { readFileSync } from "fs";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
import * as esbuild from "esbuild";
|
|
6
|
+
import { umdWrapper } from "esbuild-plugin-umd-wrapper";
|
|
7
|
+
import yargs from "yargs";
|
|
8
|
+
import { hideBin } from "yargs/helpers";
|
|
9
|
+
import { rebuildLogger, sfxWasm } from "@hpcc-js/esbuild-plugins";
|
|
10
|
+
var pkg = JSON.parse(readFileSync(path.join(process.cwd(), "./package.json"), "utf8"));
|
|
11
|
+
var NODE_MJS = pkg.type === "module" ? "js" : "mjs";
|
|
12
|
+
var NODE_CJS = pkg.type === "module" ? "cjs" : "js";
|
|
13
|
+
var myYargs = yargs(hideBin(process.argv));
|
|
14
|
+
myYargs.usage("Usage: node esbuild.mjs [options]").demandCommand(0, 0).example("node esbuild.mjs --watch", "Bundle and watch for changes").option("mode", {
|
|
15
|
+
alias: "m",
|
|
16
|
+
describe: "Build mode",
|
|
17
|
+
choices: ["development", "production"],
|
|
18
|
+
default: "production"
|
|
19
|
+
}).option("w", {
|
|
20
|
+
alias: "watch",
|
|
21
|
+
describe: "Watch for changes",
|
|
22
|
+
type: "boolean"
|
|
23
|
+
}).help("h").alias("h", "help").epilog("https://github.com/hpcc-systems/hpcc-js-wasm");
|
|
24
|
+
var argv2 = await myYargs.argv;
|
|
25
|
+
var isDevelopment = argv2.mode === "development";
|
|
26
|
+
var isProduction = !isDevelopment;
|
|
27
|
+
var isWatch = argv2.watch;
|
|
28
|
+
function build2(config) {
|
|
29
|
+
if (isDevelopment && Array.isArray(config.entryPoints)) {
|
|
30
|
+
console.log("Start: ", config.entryPoints[0], config.outfile);
|
|
31
|
+
}
|
|
32
|
+
return esbuild.build({
|
|
33
|
+
...config,
|
|
34
|
+
sourcemap: "linked",
|
|
35
|
+
plugins: [
|
|
36
|
+
...config.plugins ?? [],
|
|
37
|
+
sfxWasm()
|
|
38
|
+
]
|
|
39
|
+
}).finally(() => {
|
|
40
|
+
if (isDevelopment && Array.isArray(config.entryPoints)) {
|
|
41
|
+
console.log("Stop: ", config.entryPoints[0], config.outfile);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async function watch(config) {
|
|
46
|
+
await build2(config);
|
|
47
|
+
return esbuild.context({
|
|
48
|
+
...config,
|
|
49
|
+
sourcemap: "external",
|
|
50
|
+
plugins: [
|
|
51
|
+
...config.plugins ?? [],
|
|
52
|
+
rebuildLogger(config),
|
|
53
|
+
sfxWasm()
|
|
54
|
+
]
|
|
55
|
+
}).then((ctx) => {
|
|
56
|
+
return ctx.watch();
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function buildWatch(config) {
|
|
60
|
+
return isWatch ? watch(config) : build2(config);
|
|
61
|
+
}
|
|
62
|
+
function browserTpl(input, output, format = "esm", globalName, external = []) {
|
|
63
|
+
return buildWatch({
|
|
64
|
+
entryPoints: [input],
|
|
65
|
+
outfile: `${output}.${format === "esm" ? "js" : "umd.js"}`,
|
|
66
|
+
platform: "browser",
|
|
67
|
+
target: "es2022",
|
|
68
|
+
format,
|
|
69
|
+
globalName,
|
|
70
|
+
bundle: true,
|
|
71
|
+
minify: isProduction,
|
|
72
|
+
external,
|
|
73
|
+
plugins: format === "umd" ? [umdWrapper()] : []
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function browserBoth(input, output, globalName, external = []) {
|
|
77
|
+
return Promise.all([
|
|
78
|
+
browserTpl(input, output, "esm", globalName, external),
|
|
79
|
+
browserTpl(input, output, "umd", globalName, external)
|
|
80
|
+
]);
|
|
81
|
+
}
|
|
82
|
+
function nodeTpl(input, output, format = "esm", external = []) {
|
|
83
|
+
return buildWatch({
|
|
84
|
+
entryPoints: [input],
|
|
85
|
+
outfile: `${output}.${format === "esm" ? NODE_MJS : NODE_CJS}`,
|
|
86
|
+
platform: "node",
|
|
87
|
+
target: "node20",
|
|
88
|
+
format,
|
|
89
|
+
bundle: true,
|
|
90
|
+
minify: isProduction,
|
|
91
|
+
external
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function neutralTpl(input, output, format = "esm", globalName, external = []) {
|
|
95
|
+
return buildWatch({
|
|
96
|
+
entryPoints: [input],
|
|
97
|
+
outfile: `${output}.${format === "esm" ? "js" : "umd.js"}`,
|
|
98
|
+
platform: "neutral",
|
|
99
|
+
target: "es2022",
|
|
100
|
+
format,
|
|
101
|
+
globalName,
|
|
102
|
+
bundle: true,
|
|
103
|
+
minify: isProduction,
|
|
104
|
+
external,
|
|
105
|
+
plugins: format === "umd" ? [umdWrapper()] : []
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function nodeBoth(input, output, external = []) {
|
|
109
|
+
return Promise.all([
|
|
110
|
+
nodeTpl(input, output, "esm", external),
|
|
111
|
+
nodeTpl(input, output, "cjs", external)
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
function bothTpl(input, output, globalName, external = []) {
|
|
115
|
+
return Promise.all([
|
|
116
|
+
browserBoth(input, output, globalName, external),
|
|
117
|
+
nodeTpl(input, output, "cjs", external)
|
|
118
|
+
]);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/exclude-sourcemap.ts
|
|
122
|
+
import { readFile } from "fs/promises";
|
|
123
|
+
function excludeSourcemap(opts) {
|
|
124
|
+
return {
|
|
125
|
+
name: "exclude-sourcemap",
|
|
126
|
+
setup(build3) {
|
|
127
|
+
build3.onLoad({ filter: opts.filter }, async (args) => {
|
|
128
|
+
return {
|
|
129
|
+
contents: await readFile(args.path, "utf8") + "\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==",
|
|
130
|
+
loader: "default"
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// src/problem-matcher.ts
|
|
138
|
+
function problemMatcher() {
|
|
139
|
+
return {
|
|
140
|
+
name: "problem-matcher",
|
|
141
|
+
setup(build3) {
|
|
142
|
+
build3.onStart(() => {
|
|
143
|
+
console.log("[watch] build started");
|
|
144
|
+
});
|
|
145
|
+
build3.onEnd((result) => {
|
|
146
|
+
result.errors.forEach(({ text, location }) => {
|
|
147
|
+
console.error(`\u2718 [ERROR] ${text}`);
|
|
148
|
+
console.error(` ${location?.file}:${location?.line}:${location?.column}:`);
|
|
149
|
+
});
|
|
150
|
+
console.log("[watch] build finished");
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// src/rebuild-logger.ts
|
|
157
|
+
function rebuildLogger2(opts) {
|
|
158
|
+
return {
|
|
159
|
+
name: "rebuild-logger",
|
|
160
|
+
setup(build3) {
|
|
161
|
+
build3.onStart(() => {
|
|
162
|
+
console.log("[watch] build started");
|
|
163
|
+
});
|
|
164
|
+
build3.onEnd(() => {
|
|
165
|
+
console.log(`Rebuilt ${opts.outfile ?? "Unknown"}`);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// src/sfx-wrapper.ts
|
|
172
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
173
|
+
import { existsSync } from "fs";
|
|
174
|
+
import { Base91, Zstd } from "@hpcc-js/wasm";
|
|
175
|
+
function tpl(wasmJsPath, base91Wasm, base91CompressedWasm) {
|
|
176
|
+
const compressed = base91CompressedWasm.length + 8 * 1024 <= base91Wasm.length;
|
|
177
|
+
const wasmJsExists = existsSync(wasmJsPath);
|
|
178
|
+
return `${compressed ? 'import { decompress } from "fzstd";' : ""}
|
|
179
|
+
${wasmJsExists ? `import wrapper from "${wasmJsPath}";` : ""}
|
|
180
|
+
|
|
181
|
+
const table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_\`{|}~"';
|
|
182
|
+
|
|
183
|
+
function decode(raw: string): Uint8Array {
|
|
184
|
+
const len = raw.length;
|
|
185
|
+
const ret: number[] = [];
|
|
186
|
+
|
|
187
|
+
let b = 0;
|
|
188
|
+
let n = 0;
|
|
189
|
+
let v = -1;
|
|
190
|
+
|
|
191
|
+
for (let i = 0; i < len; i++) {
|
|
192
|
+
const p = table.indexOf(raw[i]);
|
|
193
|
+
/* istanbul ignore next */
|
|
194
|
+
if (p === -1) continue;
|
|
195
|
+
if (v < 0) {
|
|
196
|
+
v = p;
|
|
197
|
+
} else {
|
|
198
|
+
v += p * 91;
|
|
199
|
+
b |= v << n;
|
|
200
|
+
n += (v & 8191) > 88 ? 13 : 14;
|
|
201
|
+
do {
|
|
202
|
+
ret.push(b & 0xff);
|
|
203
|
+
b >>= 8;
|
|
204
|
+
n -= 8;
|
|
205
|
+
} while (n > 7);
|
|
206
|
+
v = -1;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (v > -1) {
|
|
211
|
+
ret.push((b | v << n) & 0xff);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return new Uint8Array(ret);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const blobStr = '${compressed ? base91CompressedWasm : base91Wasm}';
|
|
218
|
+
|
|
219
|
+
let g_module: Uint8Array | undefined;
|
|
220
|
+
let g_wasmBinary: Uint8Array | undefined;
|
|
221
|
+
export default function() {
|
|
222
|
+
if (!g_wasmBinary) {
|
|
223
|
+
g_wasmBinary = ${compressed ? "decompress(decode(blobStr))" : "decode(blobStr)"};
|
|
224
|
+
}
|
|
225
|
+
${!wasmJsExists ? ` return g_wasmBinary;
|
|
226
|
+
` : ` if (!g_module) {
|
|
227
|
+
g_module = wrapper({
|
|
228
|
+
wasmBinary: g_wasmBinary,
|
|
229
|
+
locateFile: undefined
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return g_module;
|
|
233
|
+
`}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export function reset() {
|
|
237
|
+
if (g_module) {
|
|
238
|
+
g_module = undefined;
|
|
239
|
+
}
|
|
240
|
+
} `.trim();
|
|
241
|
+
}
|
|
242
|
+
async function wrap(path2) {
|
|
243
|
+
const base91 = await Base91.load();
|
|
244
|
+
const zstd = await Zstd.load();
|
|
245
|
+
const wasm = await readFile2(path2);
|
|
246
|
+
path2 = path2.replace(/\.js$/, ".xxx");
|
|
247
|
+
const wasmJsPath = path2.replace(/\.wasm$/, ".js");
|
|
248
|
+
const base91Wasm = base91.encode(wasm);
|
|
249
|
+
const compressedWasm = zstd.compress(wasm);
|
|
250
|
+
const base91CompressedWasm = base91.encode(compressedWasm);
|
|
251
|
+
return tpl(wasmJsPath, base91Wasm, base91CompressedWasm);
|
|
252
|
+
}
|
|
253
|
+
function sfxWasm2() {
|
|
254
|
+
return {
|
|
255
|
+
name: "sfx-wasm",
|
|
256
|
+
setup(build3) {
|
|
257
|
+
build3.onLoad({ filter: /\.wasm$/ }, async (args) => {
|
|
258
|
+
return {
|
|
259
|
+
contents: await wrap(args.path),
|
|
260
|
+
loader: "ts"
|
|
261
|
+
};
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
export {
|
|
267
|
+
bothTpl,
|
|
268
|
+
browserBoth,
|
|
269
|
+
browserTpl,
|
|
270
|
+
build2 as build,
|
|
271
|
+
buildWatch,
|
|
272
|
+
excludeSourcemap,
|
|
273
|
+
neutralTpl,
|
|
274
|
+
nodeBoth,
|
|
275
|
+
nodeTpl,
|
|
276
|
+
problemMatcher,
|
|
277
|
+
rebuildLogger2 as rebuildLogger,
|
|
278
|
+
sfxWasm2 as sfxWasm,
|
|
279
|
+
watch,
|
|
280
|
+
wrap
|
|
281
|
+
};
|
|
282
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/build.ts", "../src/exclude-sourcemap.ts", "../src/problem-matcher.ts", "../src/rebuild-logger.ts", "../src/sfx-wrapper.ts"],
|
|
4
|
+
"sourcesContent": ["import * as process from \"process\";\nimport { readFileSync } from \"fs\";\nimport * as path from \"path\";\nimport * as esbuild from \"esbuild\";\nimport type { BuildOptions, Format } from \"esbuild\";\nimport { umdWrapper } from \"esbuild-plugin-umd-wrapper\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { rebuildLogger, sfxWasm } from \"@hpcc-js/esbuild-plugins\";\n\nconst pkg = JSON.parse(readFileSync(path.join(process.cwd(), \"./package.json\"), \"utf8\"));\nconst NODE_MJS = pkg.type === \"module\" ? \"js\" : \"mjs\";\nconst NODE_CJS = pkg.type === \"module\" ? \"cjs\" : \"js\";\n\nconst myYargs = yargs(hideBin(process.argv));\nmyYargs\n .usage(\"Usage: node esbuild.mjs [options]\")\n .demandCommand(0, 0)\n .example(\"node esbuild.mjs --watch\", \"Bundle and watch for changes\")\n .option(\"mode\", {\n alias: \"m\",\n describe: \"Build mode\",\n choices: [\"development\", \"production\"],\n default: \"production\"\n })\n .option(\"w\", {\n alias: \"watch\",\n describe: \"Watch for changes\",\n type: \"boolean\"\n })\n .help(\"h\")\n .alias(\"h\", \"help\")\n .epilog(\"https://github.com/hpcc-systems/hpcc-js-wasm\")\n ;\nconst argv = await myYargs.argv;\nconst isDevelopment = argv.mode === \"development\";\nconst isProduction = !isDevelopment;\nconst isWatch = argv.watch;\n\nexport function build(config: BuildOptions) {\n if (isDevelopment && Array.isArray(config.entryPoints)) {\n console.log(\"Start: \", config.entryPoints[0], config.outfile);\n }\n return esbuild.build({\n ...config,\n sourcemap: \"linked\",\n plugins: [\n ...(config.plugins ?? []),\n sfxWasm()\n ]\n }).finally(() => {\n if (isDevelopment && Array.isArray(config.entryPoints)) {\n console.log(\"Stop: \", config.entryPoints[0], config.outfile);\n }\n });\n}\n\nexport async function watch(config: BuildOptions) {\n await build(config);\n return esbuild.context({\n ...config,\n sourcemap: \"external\",\n plugins: [\n ...(config.plugins ?? []),\n rebuildLogger(config),\n sfxWasm()\n ]\n }).then(ctx => {\n return ctx.watch();\n });\n}\n\nexport function buildWatch(config: BuildOptions) {\n return isWatch ? watch(config) : build(config);\n}\n\nexport function browserTpl(input: string, output: string, format: Format | \"umd\" = \"esm\", globalName?: string, external: string[] = []) {\n return buildWatch({\n entryPoints: [input],\n outfile: `${output}.${format === \"esm\" ? \"js\" : \"umd.js\"}`,\n platform: \"browser\",\n target: \"es2022\",\n format: format as Format,\n globalName,\n bundle: true,\n minify: isProduction,\n external,\n plugins: format === \"umd\" ? [umdWrapper()] : []\n });\n}\n\nexport function browserBoth(input: string, output: string, globalName?: string, external: string[] = []) {\n return Promise.all([\n browserTpl(input, output, \"esm\", globalName, external),\n browserTpl(input, output, \"umd\", globalName, external)\n ]);\n}\n\nexport function nodeTpl(input: string, output: string, format: Format | \"umd\" = \"esm\", external: string[] = []) {\n return buildWatch({\n entryPoints: [input],\n outfile: `${output}.${format === \"esm\" ? NODE_MJS : NODE_CJS}`,\n platform: \"node\",\n target: \"node20\",\n format: format as Format,\n bundle: true,\n minify: isProduction,\n external\n });\n}\n\nexport function neutralTpl(input: string, output: string, format: Format | \"umd\" = \"esm\", globalName?: string, external: string[] = []) {\n return buildWatch({\n entryPoints: [input],\n outfile: `${output}.${format === \"esm\" ? \"js\" : \"umd.js\"}`,\n platform: \"neutral\",\n target: \"es2022\",\n format: format as Format,\n globalName,\n bundle: true,\n minify: isProduction,\n external,\n plugins: format === \"umd\" ? [umdWrapper()] : []\n });\n}\n\nexport function nodeBoth(input: string, output: string, external: string[] = []) {\n return Promise.all([\n nodeTpl(input, output, \"esm\", external),\n nodeTpl(input, output, \"cjs\", external)\n ]);\n}\n\nexport function bothTpl(input: string, output: string, globalName?: string, external: string[] = []) {\n return Promise.all([\n browserBoth(input, output, globalName, external),\n nodeTpl(input, output, \"cjs\", external)\n ]);\n}\n", "import { readFile } from \"fs/promises\";\nimport type { PluginBuild, Plugin } from \"esbuild\";\n\nexport interface ExcludeSourcemapOptions {\n filter: RegExp;\n}\nexport function excludeSourcemap(opts: ExcludeSourcemapOptions): Plugin {\n return {\n name: \"exclude-sourcemap\",\n\n setup(build: PluginBuild) {\n build.onLoad({ filter: opts.filter }, async args => {\n return {\n contents: await readFile(args.path, \"utf8\") + \"\\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==\",\n loader: \"default\",\n };\n });\n },\n };\n}\n", "import type { PluginBuild, Plugin } from \"esbuild\";\n\nexport function problemMatcher(): Plugin {\n return {\n name: \"problem-matcher\",\n\n setup(build: PluginBuild) {\n\n build.onStart(() => {\n console.log(\"[watch] build started\");\n });\n\n build.onEnd((result) => {\n result.errors.forEach(({ text, location }) => {\n console.error(`\u2718 [ERROR] ${text}`);\n console.error(` ${location?.file}:${location?.line}:${location?.column}:`);\n });\n console.log(\"[watch] build finished\");\n });\n }\n };\n}\n", "import type { PluginBuild, Plugin } from \"esbuild\";\n\nexport interface RebuildLoggerOptions {\n outfile?: string;\n}\n\nexport function rebuildLogger(opts: RebuildLoggerOptions): Plugin {\n return {\n name: \"rebuild-logger\",\n\n setup(build: PluginBuild) {\n\n build.onStart(() => {\n console.log(\"[watch] build started\");\n });\n\n build.onEnd(() => {\n console.log(`Rebuilt ${opts.outfile ?? \"Unknown\"}`);\n });\n }\n };\n}\n", "import { readFile } from \"fs/promises\";\nimport { existsSync } from \"fs\";\nimport { Base91, Zstd } from \"@hpcc-js/wasm\";\nimport type { Plugin, PluginBuild } from \"esbuild\";\n\nfunction tpl(wasmJsPath: string, base91Wasm: string, base91CompressedWasm: string) {\n\n const compressed = (base91CompressedWasm.length + 8 * 1024) <= base91Wasm.length;\n const wasmJsExists = existsSync(wasmJsPath);\n\n return `\\\n${compressed ? 'import { decompress } from \"fzstd\";' : ''}\n${wasmJsExists ? `import wrapper from \"${wasmJsPath}\";` : ''}\n\nconst table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_\\`{|}~\"';\n\nfunction decode(raw: string): Uint8Array {\n const len = raw.length;\n const ret: number[] = [];\n\n let b = 0;\n let n = 0;\n let v = -1;\n\n for (let i = 0; i < len; i++) {\n const p = table.indexOf(raw[i]);\n /* istanbul ignore next */\n if (p === -1) continue;\n if (v < 0) {\n v = p;\n } else {\n v += p * 91;\n b |= v << n;\n n += (v & 8191) > 88 ? 13 : 14;\n do {\n ret.push(b & 0xff);\n b >>= 8;\n n -= 8;\n } while (n > 7);\n v = -1;\n }\n }\n\n if (v > -1) {\n ret.push((b | v << n) & 0xff);\n }\n\n return new Uint8Array(ret);\n}\n\nconst blobStr = '${compressed ? base91CompressedWasm : base91Wasm}';\n\nlet g_module: Uint8Array | undefined;\nlet g_wasmBinary: Uint8Array | undefined;\nexport default function() {\n if (!g_wasmBinary) {\n g_wasmBinary = ${compressed ? \"decompress(decode(blobStr))\" : \"decode(blobStr)\"};\n }\n${!wasmJsExists ? `\\\n return g_wasmBinary;\n`: `\\\n if (!g_module) {\n g_module = wrapper({\n wasmBinary: g_wasmBinary,\n locateFile: undefined\n });\n }\n return g_module;\n`}\n}\n\nexport function reset() {\n if (g_module) {\n g_module = undefined;\n }\n} `.trim();\n}\n\nexport async function wrap(path: string) {\n const base91 = await Base91.load();\n const zstd = await Zstd.load();\n\n const wasm = await readFile(path);\n path = path.replace(/\\.js$/, \".xxx\");\n const wasmJsPath = path.replace(/\\.wasm$/, \".js\");\n const base91Wasm = base91.encode(wasm);\n const compressedWasm = zstd.compress(wasm);\n const base91CompressedWasm = base91.encode(compressedWasm);\n\n return tpl(wasmJsPath, base91Wasm, base91CompressedWasm);\n}\n\nexport function sfxWasm(): Plugin {\n return {\n name: \"sfx-wasm\",\n\n setup(build: PluginBuild) {\n\n build.onLoad({ filter: /\\.wasm$/ }, async args => {\n return {\n contents: await wrap(args.path),\n loader: \"ts\",\n };\n });\n }\n }\n};\n"],
|
|
5
|
+
"mappings": ";AAAA,YAAY,aAAa;AACzB,SAAS,oBAAoB;AAC7B,YAAY,UAAU;AACtB,YAAY,aAAa;AAEzB,SAAS,kBAAkB;AAC3B,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,SAAS,eAAe,eAAe;AAEvC,IAAM,MAAM,KAAK,MAAM,aAAkB,UAAa,YAAI,GAAG,gBAAgB,GAAG,MAAM,CAAC;AACvF,IAAM,WAAW,IAAI,SAAS,WAAW,OAAO;AAChD,IAAM,WAAW,IAAI,SAAS,WAAW,QAAQ;AAEjD,IAAM,UAAU,MAAM,QAAgB,YAAI,CAAC;AAC3C,QACK,MAAM,mCAAmC,EACzC,cAAc,GAAG,CAAC,EAClB,QAAQ,4BAA4B,8BAA8B,EAClE,OAAO,QAAQ;AAAA,EACZ,OAAO;AAAA,EACP,UAAU;AAAA,EACV,SAAS,CAAC,eAAe,YAAY;AAAA,EACrC,SAAS;AACb,CAAC,EACA,OAAO,KAAK;AAAA,EACT,OAAO;AAAA,EACP,UAAU;AAAA,EACV,MAAM;AACV,CAAC,EACA,KAAK,GAAG,EACR,MAAM,KAAK,MAAM,EACjB,OAAO,8CAA8C;AAE1D,IAAMA,QAAO,MAAM,QAAQ;AAC3B,IAAM,gBAAgBA,MAAK,SAAS;AACpC,IAAM,eAAe,CAAC;AACtB,IAAM,UAAUA,MAAK;AAEd,SAASC,OAAM,QAAsB;AACxC,MAAI,iBAAiB,MAAM,QAAQ,OAAO,WAAW,GAAG;AACpD,YAAQ,IAAI,YAAY,OAAO,YAAY,CAAC,GAA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
|
7
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// src/sfx-wrapper.ts
|
|
2
|
+
import { readFile } from "fs/promises";
|
|
3
|
+
import { existsSync } from "fs";
|
|
4
|
+
import { Base91, Zstd } from "@hpcc-js/wasm";
|
|
5
|
+
function tpl(wasmJsPath, base91Wasm, base91CompressedWasm) {
|
|
6
|
+
const compressed = base91CompressedWasm.length + 8 * 1024 <= base91Wasm.length;
|
|
7
|
+
const wasmJsExists = existsSync(wasmJsPath);
|
|
8
|
+
return `${compressed ? 'import { decompress } from "fzstd";' : ""}
|
|
9
|
+
${wasmJsExists ? `import wrapper from "${wasmJsPath}";` : ""}
|
|
10
|
+
|
|
11
|
+
const table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_\`{|}~"';
|
|
12
|
+
|
|
13
|
+
function decode(raw: string): Uint8Array {
|
|
14
|
+
const len = raw.length;
|
|
15
|
+
const ret: number[] = [];
|
|
16
|
+
|
|
17
|
+
let b = 0;
|
|
18
|
+
let n = 0;
|
|
19
|
+
let v = -1;
|
|
20
|
+
|
|
21
|
+
for (let i = 0; i < len; i++) {
|
|
22
|
+
const p = table.indexOf(raw[i]);
|
|
23
|
+
/* istanbul ignore next */
|
|
24
|
+
if (p === -1) continue;
|
|
25
|
+
if (v < 0) {
|
|
26
|
+
v = p;
|
|
27
|
+
} else {
|
|
28
|
+
v += p * 91;
|
|
29
|
+
b |= v << n;
|
|
30
|
+
n += (v & 8191) > 88 ? 13 : 14;
|
|
31
|
+
do {
|
|
32
|
+
ret.push(b & 0xff);
|
|
33
|
+
b >>= 8;
|
|
34
|
+
n -= 8;
|
|
35
|
+
} while (n > 7);
|
|
36
|
+
v = -1;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (v > -1) {
|
|
41
|
+
ret.push((b | v << n) & 0xff);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return new Uint8Array(ret);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const blobStr = '${compressed ? base91CompressedWasm : base91Wasm}';
|
|
48
|
+
|
|
49
|
+
let g_module: Uint8Array | undefined;
|
|
50
|
+
let g_wasmBinary: Uint8Array | undefined;
|
|
51
|
+
export default function() {
|
|
52
|
+
if (!g_wasmBinary) {
|
|
53
|
+
g_wasmBinary = ${compressed ? "decompress(decode(blobStr))" : "decode(blobStr)"};
|
|
54
|
+
}
|
|
55
|
+
${!wasmJsExists ? ` return g_wasmBinary;
|
|
56
|
+
` : ` if (!g_module) {
|
|
57
|
+
g_module = wrapper({
|
|
58
|
+
wasmBinary: g_wasmBinary,
|
|
59
|
+
locateFile: undefined
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return g_module;
|
|
63
|
+
`}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function reset() {
|
|
67
|
+
if (g_module) {
|
|
68
|
+
g_module = undefined;
|
|
69
|
+
}
|
|
70
|
+
} `.trim();
|
|
71
|
+
}
|
|
72
|
+
async function wrap(path) {
|
|
73
|
+
const base91 = await Base91.load();
|
|
74
|
+
const zstd = await Zstd.load();
|
|
75
|
+
const wasm = await readFile(path);
|
|
76
|
+
path = path.replace(/\.js$/, ".xxx");
|
|
77
|
+
const wasmJsPath = path.replace(/\.wasm$/, ".js");
|
|
78
|
+
const base91Wasm = base91.encode(wasm);
|
|
79
|
+
const compressedWasm = zstd.compress(wasm);
|
|
80
|
+
const base91CompressedWasm = base91.encode(compressedWasm);
|
|
81
|
+
return tpl(wasmJsPath, base91Wasm, base91CompressedWasm);
|
|
82
|
+
}
|
|
83
|
+
function sfxWasm() {
|
|
84
|
+
return {
|
|
85
|
+
name: "sfx-wasm",
|
|
86
|
+
setup(build) {
|
|
87
|
+
build.onLoad({ filter: /\.wasm$/ }, async (args) => {
|
|
88
|
+
return {
|
|
89
|
+
contents: await wrap(args.path),
|
|
90
|
+
loader: "ts"
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
sfxWasm,
|
|
98
|
+
wrap
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=sfx-wrapper.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/sfx-wrapper.ts"],
|
|
4
|
+
"sourcesContent": ["import { readFile } from \"fs/promises\";\nimport { existsSync } from \"fs\";\nimport { Base91, Zstd } from \"@hpcc-js/wasm\";\nimport type { Plugin, PluginBuild } from \"esbuild\";\n\nfunction tpl(wasmJsPath: string, base91Wasm: string, base91CompressedWasm: string) {\n\n const compressed = (base91CompressedWasm.length + 8 * 1024) <= base91Wasm.length;\n const wasmJsExists = existsSync(wasmJsPath);\n\n return `\\\n${compressed ? 'import { decompress } from \"fzstd\";' : ''}\n${wasmJsExists ? `import wrapper from \"${wasmJsPath}\";` : ''}\n\nconst table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_\\`{|}~\"';\n\nfunction decode(raw: string): Uint8Array {\n const len = raw.length;\n const ret: number[] = [];\n\n let b = 0;\n let n = 0;\n let v = -1;\n\n for (let i = 0; i < len; i++) {\n const p = table.indexOf(raw[i]);\n /* istanbul ignore next */\n if (p === -1) continue;\n if (v < 0) {\n v = p;\n } else {\n v += p * 91;\n b |= v << n;\n n += (v & 8191) > 88 ? 13 : 14;\n do {\n ret.push(b & 0xff);\n b >>= 8;\n n -= 8;\n } while (n > 7);\n v = -1;\n }\n }\n\n if (v > -1) {\n ret.push((b | v << n) & 0xff);\n }\n\n return new Uint8Array(ret);\n}\n\nconst blobStr = '${compressed ? base91CompressedWasm : base91Wasm}';\n\nlet g_module: Uint8Array | undefined;\nlet g_wasmBinary: Uint8Array | undefined;\nexport default function() {\n if (!g_wasmBinary) {\n g_wasmBinary = ${compressed ? \"decompress(decode(blobStr))\" : \"decode(blobStr)\"};\n }\n${!wasmJsExists ? `\\\n return g_wasmBinary;\n`: `\\\n if (!g_module) {\n g_module = wrapper({\n wasmBinary: g_wasmBinary,\n locateFile: undefined\n });\n }\n return g_module;\n`}\n}\n\nexport function reset() {\n if (g_module) {\n g_module = undefined;\n }\n} `.trim();\n}\n\nexport async function wrap(path: string) {\n const base91 = await Base91.load();\n const zstd = await Zstd.load();\n\n const wasm = await readFile(path);\n path = path.replace(/\\.js$/, \".xxx\");\n const wasmJsPath = path.replace(/\\.wasm$/, \".js\");\n const base91Wasm = base91.encode(wasm);\n const compressedWasm = zstd.compress(wasm);\n const base91CompressedWasm = base91.encode(compressedWasm);\n\n return tpl(wasmJsPath, base91Wasm, base91CompressedWasm);\n}\n\nexport function sfxWasm(): Plugin {\n return {\n name: \"sfx-wasm\",\n\n setup(build: PluginBuild) {\n\n build.onLoad({ filter: /\\.wasm$/ }, async args => {\n return {\n contents: await wrap(args.path),\n loader: \"ts\",\n };\n });\n }\n }\n};\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,QAAQ,YAAY;AAG7B,SAAS,IAAI,YAAoB,YAAoB,sBAA8B;AAE/E,QAAM,aAAc,qBAAqB,SAAS,IAAI,QAAS,WAAW;AAC1E,QAAM,eAAe,WAAW,UAAU;AAE1C,SAAO,GACT,aAAa,wCAAwC,EAAE;AAAA,EACvD,eAAe,wBAAwB,UAAU,OAAO,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAsCzC,aAAa,uBAAuB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAMxC,aAAa,gCAAgC,iBAAiB;AAAA;AAAA,EAErF,CAAC,eAAe;AAAA,IAEf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAQF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOG,KAAK;AACT;AAEA,eAAsB,KAAK,MAAc;AACrC,QAAM,SAAS,MAAM,OAAO,KAAK;AACjC,QAAM,OAAO,MAAM,KAAK,KAAK;AAE7B,QAAM,OAAO,MAAM,SAAS,IAAI;AAChC,SAAO,KAAK,QAAQ,SAAS,MAAM;AACnC,QAAM,aAAa,KAAK,QAAQ,WAAW,KAAK;AAChD,QAAM,aAAa,OAAO,OAAO,IAAI;AACrC,QAAM,iBAAiB,KAAK,SAAS,IAAI;AACzC,QAAM,uBAAuB,OAAO,OAAO,cAAc;AAEzD,SAAO,IAAI,YAAY,YAAY,oBAAoB;AAC3D;AAEO,SAAS,UAAkB;AAC9B,SAAO;AAAA,IACH,MAAM;AAAA,IAEN,MAAM,OAAoB;AAEtB,YAAM,OAAO,EAAE,QAAQ,UAAU,GAAG,OAAM,SAAQ;AAC9C,eAAO;AAAA,UACH,UAAU,MAAM,KAAK,KAAK,IAAI;AAAA,UAC9B,QAAQ;AAAA,QACZ;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,EACJ;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hpcc-js/esbuild-plugins",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Various esbuild plugins",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./sfx-wrapper": {
|
|
12
|
+
"types": "./types/sfx-wrapper.d.ts",
|
|
13
|
+
"import": "./dist/sfx-wrapper.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"types": "./types/index.d.ts",
|
|
17
|
+
"files": [
|
|
18
|
+
"dist/**/*",
|
|
19
|
+
"types/**/*"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"clean": "rimraf ./dist ./types",
|
|
23
|
+
"build-types": "tsc --project tsconfig.json --emitDeclarationOnly",
|
|
24
|
+
"build-types-watch": "npm run build-types -- --watch",
|
|
25
|
+
"build-ts-dev": "esbuild ./src/index.ts --platform=node --format=esm --bundle --packages=external --sourcemap --outfile=./dist/index.js",
|
|
26
|
+
"build-ts": "npm run build-ts-dev --minify",
|
|
27
|
+
"build-ts-watch": "npm run build-ts-dev -- --watch",
|
|
28
|
+
"build-dev": "run-p build-types build-ts-dev",
|
|
29
|
+
"build-sfx-wrapper": "esbuild ./src/sfx-wrapper.ts --platform=node --format=esm --bundle --packages=external --sourcemap --outfile=./dist/sfx-wrapper.js",
|
|
30
|
+
"build": "run-p build-types build-ts build-sfx-wrapper",
|
|
31
|
+
"lint-skypack": "npx -y @skypack/package-check",
|
|
32
|
+
"lint-eslint": "eslint src/**/*.ts",
|
|
33
|
+
"lint": "run-p lint-eslint lint-skypack",
|
|
34
|
+
"test-cli": "npx . -v",
|
|
35
|
+
"test-cli-help": "npx .",
|
|
36
|
+
"test-node": "npx . -v",
|
|
37
|
+
"update": "npx --yes npm-check-updates -u -t minor"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@hpcc-js/wasm-base91": "1.0.1",
|
|
41
|
+
"@hpcc-js/wasm-zstd": "1.0.1",
|
|
42
|
+
"yargs": "17.7.2",
|
|
43
|
+
"fzstd": "0.1.1"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"esbuild",
|
|
48
|
+
"plugins",
|
|
49
|
+
"WebAssembly",
|
|
50
|
+
"wasm",
|
|
51
|
+
"sfx"
|
|
52
|
+
],
|
|
53
|
+
"author": "hpcc-systems",
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "git+https://github.com/hpcc-systems/hpcc-js-wasm.git"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://hpcc-systems.github.io/hpcc-js-wasm/",
|
|
59
|
+
"license": "Apache-2.0"
|
|
60
|
+
}
|