@swiftbrowser/web 0.9.0 → 0.9.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/node/dist/plugins/playground.d.ts +5 -2
- package/node/dist/plugins/playground.d.ts.map +1 -1
- package/node/dist/plugins/playground.js +29 -11
- package/node/dist/plugins/playground.js.map +1 -1
- package/node/dist/src/playground/files.d.ts +6 -0
- package/node/dist/src/playground/files.d.ts.map +1 -1
- package/node/dist/src/playground/files.js.map +1 -1
- package/node/dist/src/playground/sections.d.ts +5 -0
- package/node/dist/src/playground/sections.d.ts.map +1 -0
- package/node/dist/src/playground/sections.js +88 -0
- package/node/dist/src/playground/sections.js.map +1 -0
- package/package.json +1 -1
- package/plugins/playground.ts +27 -11
- package/src/playground/assets.ts +53 -134
- package/src/playground/build.ts +30 -19
- package/src/playground/download.ts +125 -0
- package/src/playground/files.ts +6 -0
- package/src/playground/freeze.ts +105 -0
- package/src/playground/main.ts +28 -2
- package/src/playground/read-once.ts +75 -0
- package/src/playground/sections.ts +77 -0
- package/src/playground/tool-host.ts +163 -0
- package/src/playground/tool-worker.ts +67 -0
- package/src/playground/worker.ts +41 -17
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* version, except those the site serves itself (`localPackages`): the kit
|
|
9
9
|
* and @swiftbrowser/playground made from the same commit as the site's
|
|
10
10
|
* renderer, so the two cannot drift, and any package the CDN does not have
|
|
11
|
-
* at that version. The dev server serves this repository's packages at
|
|
11
|
+
* at that version, the compiler's included. The dev server serves this repository's packages at
|
|
12
12
|
* /npm/, laid out as the CDN serves them, and a built site carries the
|
|
13
13
|
* files the page reads of its local packages there.
|
|
14
14
|
*/
|
|
@@ -49,7 +49,10 @@ export declare function localPackages(repoRoot: string, others?: readonly string
|
|
|
49
49
|
* Writes the files the page reads of each local package under `outDir`, at
|
|
50
50
|
* the paths `packages` names: brotli-compressed as `<file>.brotli` from
|
|
51
51
|
* SITE_COMPRESS_FROM (and always over the size limit), and playground.json
|
|
52
|
-
* naming those (`brotli`).
|
|
52
|
+
* naming those (`brotli`). A tool or plugin goes without its custom
|
|
53
|
+
* sections, which the page drops anyway (sections.ts), as
|
|
54
|
+
* `<module>.brotli`: so the compiler fits the size limit, compressed harder
|
|
55
|
+
* when it must, and the site can serve it when npm has not got this one.
|
|
53
56
|
*/
|
|
54
57
|
export declare function writeLocalPackages(repoRoot: string, packages: Record<string, string>, outDir: string, limit?: number, compressFrom?: number): {
|
|
55
58
|
files: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../../plugins/playground.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAQL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACtB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../../plugins/playground.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAQL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACtB,MAAM,4BAA4B,CAAC;AAGpC,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAEjD,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAC3C,qEAAqE;AACrE,eAAO,MAAM,WAAW,sBAAsB,CAAC;AAC/C;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAmB,CAAC;AAIhD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,QAAY,CAAC;AAE5C,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAK1E;AAED,2DAA2D;AAC3D,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAQvE;AAED,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAGxE;AAED,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,QAAQ,EAAE,kBAAkB,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAQjF;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAE,SAAS,MAAM,EAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CActG;AAMD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,SAAkB,EAAE,YAAY,SAAqB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CA0DnM;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CA0BvF"}
|
|
@@ -8,15 +8,16 @@
|
|
|
8
8
|
* version, except those the site serves itself (`localPackages`): the kit
|
|
9
9
|
* and @swiftbrowser/playground made from the same commit as the site's
|
|
10
10
|
* renderer, so the two cannot drift, and any package the CDN does not have
|
|
11
|
-
* at that version. The dev server serves this repository's packages at
|
|
11
|
+
* at that version, the compiler's included. The dev server serves this repository's packages at
|
|
12
12
|
* /npm/, laid out as the CDN serves them, and a built site carries the
|
|
13
13
|
* files the page reads of its local packages there.
|
|
14
14
|
*/
|
|
15
15
|
import { createHash } from 'node:crypto';
|
|
16
16
|
import { createReadStream, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from 'node:fs';
|
|
17
17
|
import path from 'node:path';
|
|
18
|
-
import { brotliCompressSync, constants } from 'node:zlib';
|
|
18
|
+
import { brotliCompressSync, brotliDecompressSync, constants } from 'node:zlib';
|
|
19
19
|
import { PLAYGROUND_ICU, PLAYGROUND_MANIFEST, PLAYGROUND_MODULE_CACHE, PLAYGROUND_PACKAGE, SITE_BROTLI, isBrotli, } from '../src/playground/files.js';
|
|
20
|
+
import { stripCustomSections } from '../src/playground/sections.js';
|
|
20
21
|
/** Where the dev server serves the workspaces' packages, and a built site its local ones. */
|
|
21
22
|
export const PLAYGROUND_NPM_PATH = '/npm/';
|
|
22
23
|
/** The kit, which must come from the same commit as the renderer. */
|
|
@@ -27,7 +28,7 @@ export const KIT_PACKAGE = '@swiftbrowser/kit';
|
|
|
27
28
|
*/
|
|
28
29
|
export const SITE_FILE_LIMIT = 24 * 1024 * 1024;
|
|
29
30
|
/** Bumped whenever writeLocalPackages writes other files for the same packages. */
|
|
30
|
-
const SITE_LAYOUT =
|
|
31
|
+
const SITE_LAYOUT = 3;
|
|
31
32
|
/**
|
|
32
33
|
* Files a site stores brotli-compressed from this size, when compressing
|
|
33
34
|
* saves a tenth: a static host may not compress what it serves in transit
|
|
@@ -96,17 +97,25 @@ export function localPackages(repoRoot, others = []) {
|
|
|
96
97
|
const version = `site-${hash.digest('hex').slice(0, 12)}`;
|
|
97
98
|
return Object.fromEntries(names.map((name) => [name, `${PLAYGROUND_NPM_PATH}${name}@${version}/`]));
|
|
98
99
|
}
|
|
100
|
+
/** `data` brotli-compressed at `quality`, with the window the tools are published with. */
|
|
101
|
+
const brotli = (data, quality) => brotliCompressSync(data, { params: { [constants.BROTLI_PARAM_QUALITY]: quality, [constants.BROTLI_PARAM_LGWIN]: 24, [constants.BROTLI_PARAM_SIZE_HINT]: data.length } });
|
|
99
102
|
/**
|
|
100
103
|
* Writes the files the page reads of each local package under `outDir`, at
|
|
101
104
|
* the paths `packages` names: brotli-compressed as `<file>.brotli` from
|
|
102
105
|
* SITE_COMPRESS_FROM (and always over the size limit), and playground.json
|
|
103
|
-
* naming those (`brotli`).
|
|
106
|
+
* naming those (`brotli`). A tool or plugin goes without its custom
|
|
107
|
+
* sections, which the page drops anyway (sections.ts), as
|
|
108
|
+
* `<module>.brotli`: so the compiler fits the size limit, compressed harder
|
|
109
|
+
* when it must, and the site can serve it when npm has not got this one.
|
|
104
110
|
*/
|
|
105
111
|
export function writeLocalPackages(repoRoot, packages, outDir, limit = SITE_FILE_LIMIT, compressFrom = SITE_COMPRESS_FROM) {
|
|
106
112
|
const dirs = workspacePackages(repoRoot);
|
|
107
113
|
const manifest = JSON.parse(readFileSync(path.join(dirs.get(PLAYGROUND_PACKAGE), PLAYGROUND_MANIFEST), 'utf8'));
|
|
108
|
-
const
|
|
109
|
-
const
|
|
114
|
+
const key = (file) => `${file.package}/${file.file}`;
|
|
115
|
+
const modules = new Set([manifest.frontend, manifest.linker, ...Object.values(manifest.plugins)].map(key));
|
|
116
|
+
/** Files stored under another name: brotli-compressed by the site. */
|
|
117
|
+
const renamed = new Map();
|
|
118
|
+
const rename = (file) => ({ ...file, file: renamed.get(key(file)) ?? file.file });
|
|
110
119
|
const written = { files: 0, bytes: 0 };
|
|
111
120
|
for (const [name, files] of manifestFiles(manifest)) {
|
|
112
121
|
const base = packages[name];
|
|
@@ -120,20 +129,30 @@ export function writeLocalPackages(repoRoot, packages, outDir, limit = SITE_FILE
|
|
|
120
129
|
continue;
|
|
121
130
|
let data = readFileSync(path.join(dir, file));
|
|
122
131
|
let target = file;
|
|
123
|
-
if (
|
|
132
|
+
if (modules.has(`${name}/${file}`)) {
|
|
133
|
+
const module = stripCustomSections(isBrotli(file) ? brotliDecompressSync(data) : data);
|
|
134
|
+
data = brotli(module, 5);
|
|
135
|
+
if (data.length > limit)
|
|
136
|
+
data = brotli(module, 11);
|
|
137
|
+
if (data.length > limit)
|
|
138
|
+
throw new Error(`${name}/${file} is over ${limit} bytes even compressed, without its custom sections`);
|
|
139
|
+
target = `${file.replace(/\.br$/, '')}${SITE_BROTLI}`;
|
|
140
|
+
}
|
|
141
|
+
else if (isBrotli(file)) {
|
|
124
142
|
if (data.length > limit)
|
|
125
143
|
throw new Error(`${name}/${file} is over ${limit} bytes compressed: the site cannot serve it`);
|
|
126
144
|
}
|
|
127
145
|
else if (data.length >= compressFrom || data.length > limit) {
|
|
128
|
-
const compressed =
|
|
146
|
+
const compressed = brotli(data, 5);
|
|
129
147
|
if (compressed.length > limit)
|
|
130
148
|
throw new Error(`${name}/${file} is over ${limit} bytes even compressed`);
|
|
131
149
|
if (data.length > limit || compressed.length < data.length * 0.9) {
|
|
132
150
|
data = compressed;
|
|
133
|
-
brotli.add(`${name}/${file}`);
|
|
134
151
|
target = `${file}${SITE_BROTLI}`;
|
|
135
152
|
}
|
|
136
153
|
}
|
|
154
|
+
if (target !== file)
|
|
155
|
+
renamed.set(`${name}/${file}`, target);
|
|
137
156
|
const out = path.join(outDir, base, target);
|
|
138
157
|
mkdirSync(path.dirname(out), { recursive: true });
|
|
139
158
|
writeFileSync(out, data);
|
|
@@ -143,8 +162,7 @@ export function writeLocalPackages(repoRoot, packages, outDir, limit = SITE_FILE
|
|
|
143
162
|
}
|
|
144
163
|
if (packages[PLAYGROUND_PACKAGE]) {
|
|
145
164
|
// A tool or plugin is named by its compressed file; the rest by the list.
|
|
146
|
-
const
|
|
147
|
-
const listed = [...brotli].filter((entry) => !tools.has(entry)).sort();
|
|
165
|
+
const listed = [...renamed.keys()].filter((entry) => !modules.has(entry)).sort();
|
|
148
166
|
const site = {
|
|
149
167
|
...manifest,
|
|
150
168
|
frontend: rename(manifest.frontend),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.js","sourceRoot":"","sources":["../../../plugins/playground.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAA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AC,gBAAgB,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;gBACrD,gBAAgB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;QACL,CAAC;QACD,WAAW;YACT,IAAI,CAAC,OAAO,CAAC,QAAQ;gBAAE,OAAO;YAC9B,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAChF,IAAI,CAAC,IAAI,CAAC,oCAAoC,KAAK,WAAW,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC/F,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -30,6 +30,12 @@ export interface PlaygroundManifest {
|
|
|
30
30
|
sdk: Record<string, string[]>;
|
|
31
31
|
/** The kit's files a compile reads, relative to @swiftbrowser/kit (`wasm32-unknown-wasip1/...`). */
|
|
32
32
|
kit: string[];
|
|
33
|
+
/**
|
|
34
|
+
* SDK files (paths as in `sdk`) the manifest carries itself, as text: a
|
|
35
|
+
* CDN refuses some names (jsDelivr a `.lnk`, as the SDK names its
|
|
36
|
+
* static-executable flags).
|
|
37
|
+
*/
|
|
38
|
+
inline?: Record<string, string>;
|
|
33
39
|
/**
|
|
34
40
|
* The SwiftBrowser sources the kit was built from (@swiftbrowser/swift's
|
|
35
41
|
* `sourcesHash`), when build-assets.ts could tell: the page compares it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../src/playground/files.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,kBAAkB,6BAA6B,CAAC;AAC7D,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AACrD,yDAAyD;AACzD,eAAO,MAAM,cAAc,YAAY,CAAC;AACxC,uEAAuE;AACvE,eA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vE,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,mFAAmF;IACnF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,mCAAmC;AACnC,wBAAgB,UAAU,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAGvF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../../src/playground/files.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,8EAA8E;AAC9E,8EAA8E;AAC9E,gEAAgE;AAChE,8EAA8E;AAC9E,wEAAwE;AACxE,4EAA4E;AAC5E,mEAAmE;AAEnE,MAAM,CAAC,MAAM,kBAAkB,GAAG,0BAA0B,CAAC;AAC7D,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AACrD,yDAAyD;AACzD,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC;AACxC,uEAAuE;AACvE,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAC3D,0DAA0D;AAC1D,MAAM,CAAC,MAAM,QAAQ,GAAG,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../../src/playground/files.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,8EAA8E;AAC9E,8EAA8E;AAC9E,gEAAgE;AAChE,8EAA8E;AAC9E,wEAAwE;AACxE,4EAA4E;AAC5E,mEAAmE;AAEnE,MAAM,CAAC,MAAM,kBAAkB,GAAG,0BAA0B,CAAC;AAC7D,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AACrD,yDAAyD;AACzD,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC;AACxC,uEAAuE;AACvE,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAC3D,0DAA0D;AAC1D,MAAM,CAAC,MAAM,QAAQ,GAAG,+BAA+B,CAAC;AAgDxD;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AAErC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAgBtG,mCAAmC;AACnC,MAAM,UAAU,UAAU,CAAC,MAAwB,EAAE,IAAY,EAAE,IAAY;IAC7E,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC,OAAO,IAAI,IAAI,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;AACzG,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Passes a module through, dropping each custom section (id 0). */
|
|
2
|
+
export declare function withoutCustomSections(): TransformStream<Uint8Array, Uint8Array>;
|
|
3
|
+
/** `module` without its custom sections, at once: what `withoutCustomSections` streams. */
|
|
4
|
+
export declare function stripCustomSections(module: Uint8Array): Uint8Array;
|
|
5
|
+
//# sourceMappingURL=sections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sections.d.ts","sourceRoot":"","sources":["../../../../src/playground/sections.ts"],"names":[],"mappings":"AAKA,oEAAoE;AACpE,wBAAgB,qBAAqB,IAAI,eAAe,CAAC,UAAU,EAAE,UAAU,CAAC,CA2C/E;AAED,2FAA2F;AAC3F,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAwBlE"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// A WebAssembly module without its custom sections, as it streams in. A
|
|
2
|
+
// tool's or plugin's run reads none of them, but a browser keeps them beside
|
|
3
|
+
// the compiled code: the function names are a quarter of the compiler and of
|
|
4
|
+
// the linker, and a macro plugin carries its DWARF.
|
|
5
|
+
/** Passes a module through, dropping each custom section (id 0). */
|
|
6
|
+
export function withoutCustomSections() {
|
|
7
|
+
// The preamble's bytes still to pass, then a section header's bytes so far
|
|
8
|
+
// (its id and LEB128 size), then the section's bytes to pass or to drop.
|
|
9
|
+
let preamble = 8;
|
|
10
|
+
let header = [];
|
|
11
|
+
let pass = 0;
|
|
12
|
+
let drop = 0;
|
|
13
|
+
return new TransformStream({
|
|
14
|
+
transform(chunk, controller) {
|
|
15
|
+
let at = 0;
|
|
16
|
+
while (at < chunk.length) {
|
|
17
|
+
if (preamble > 0 || pass > 0) {
|
|
18
|
+
const count = Math.min(preamble > 0 ? preamble : pass, chunk.length - at);
|
|
19
|
+
controller.enqueue(chunk.subarray(at, at + count));
|
|
20
|
+
if (preamble > 0)
|
|
21
|
+
preamble -= count;
|
|
22
|
+
else
|
|
23
|
+
pass -= count;
|
|
24
|
+
at += count;
|
|
25
|
+
}
|
|
26
|
+
else if (drop > 0) {
|
|
27
|
+
const count = Math.min(drop, chunk.length - at);
|
|
28
|
+
drop -= count;
|
|
29
|
+
at += count;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const byte = chunk[at++];
|
|
33
|
+
header.push(byte);
|
|
34
|
+
if (header.length === 1 || byte & 0x80) {
|
|
35
|
+
if (header.length > 6)
|
|
36
|
+
throw new Error('a WebAssembly section size is longer than five bytes');
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
let size = 0;
|
|
40
|
+
for (let i = header.length - 1; i >= 1; i--)
|
|
41
|
+
size = size * 128 + (header[i] & 0x7f);
|
|
42
|
+
if (header[0] === 0)
|
|
43
|
+
drop = size;
|
|
44
|
+
else {
|
|
45
|
+
controller.enqueue(new Uint8Array(header));
|
|
46
|
+
pass = size;
|
|
47
|
+
}
|
|
48
|
+
header = [];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
flush() {
|
|
53
|
+
if (preamble > 0 || pass > 0 || drop > 0 || header.length > 0)
|
|
54
|
+
throw new Error('a WebAssembly module ended early');
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/** `module` without its custom sections, at once: what `withoutCustomSections` streams. */
|
|
59
|
+
export function stripCustomSections(module) {
|
|
60
|
+
const kept = [module.subarray(0, 8)];
|
|
61
|
+
let at = 8;
|
|
62
|
+
while (at < module.length) {
|
|
63
|
+
const start = at;
|
|
64
|
+
const id = module[at++];
|
|
65
|
+
let size = 0;
|
|
66
|
+
for (let shift = 0;; shift += 7) {
|
|
67
|
+
if (at >= module.length)
|
|
68
|
+
throw new Error('a WebAssembly module ended early');
|
|
69
|
+
const byte = module[at++];
|
|
70
|
+
size += (byte & 0x7f) * 2 ** shift;
|
|
71
|
+
if (!(byte & 0x80))
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
if (at + size > module.length)
|
|
75
|
+
throw new Error('a WebAssembly module ended early');
|
|
76
|
+
if (id !== 0)
|
|
77
|
+
kept.push(module.subarray(start, at + size));
|
|
78
|
+
at += size;
|
|
79
|
+
}
|
|
80
|
+
const out = new Uint8Array(kept.reduce((total, part) => total + part.length, 0));
|
|
81
|
+
let offset = 0;
|
|
82
|
+
for (const part of kept) {
|
|
83
|
+
out.set(part, offset);
|
|
84
|
+
offset += part.length;
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=sections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sections.js","sourceRoot":"","sources":["../../../../src/playground/sections.ts"],"names":[],"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
|
* version, except those the site serves itself (`localPackages`): the kit
|
|
9
9
|
* and @swiftbrowser/playground made from the same commit as the site's
|
|
10
10
|
* renderer, so the two cannot drift, and any package the CDN does not have
|
|
11
|
-
* at that version. The dev server serves this repository's packages at
|
|
11
|
+
* at that version, the compiler's included. The dev server serves this repository's packages at
|
|
12
12
|
* /npm/, laid out as the CDN serves them, and a built site carries the
|
|
13
13
|
* files the page reads of its local packages there.
|
|
14
14
|
*/
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { createHash } from 'node:crypto';
|
|
17
17
|
import { createReadStream, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from 'node:fs';
|
|
18
18
|
import path from 'node:path';
|
|
19
|
-
import { brotliCompressSync, constants } from 'node:zlib';
|
|
19
|
+
import { brotliCompressSync, brotliDecompressSync, constants } from 'node:zlib';
|
|
20
20
|
import type { Plugin } from 'vite';
|
|
21
21
|
import {
|
|
22
22
|
PLAYGROUND_ICU,
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
type PlaygroundManifest,
|
|
30
30
|
type PlaygroundSource,
|
|
31
31
|
} from '../src/playground/files.js';
|
|
32
|
+
import { stripCustomSections } from '../src/playground/sections.js';
|
|
32
33
|
|
|
33
34
|
export type PlaygroundOptions = PlaygroundSource;
|
|
34
35
|
|
|
@@ -42,7 +43,7 @@ export const KIT_PACKAGE = '@swiftbrowser/kit';
|
|
|
42
43
|
*/
|
|
43
44
|
export const SITE_FILE_LIMIT = 24 * 1024 * 1024;
|
|
44
45
|
/** Bumped whenever writeLocalPackages writes other files for the same packages. */
|
|
45
|
-
const SITE_LAYOUT =
|
|
46
|
+
const SITE_LAYOUT = 3;
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
49
|
* Files a site stores brotli-compressed from this size, when compressing
|
|
@@ -109,17 +110,27 @@ export function localPackages(repoRoot: string, others: readonly string[] = []):
|
|
|
109
110
|
return Object.fromEntries(names.map((name) => [name, `${PLAYGROUND_NPM_PATH}${name}@${version}/`]));
|
|
110
111
|
}
|
|
111
112
|
|
|
113
|
+
/** `data` brotli-compressed at `quality`, with the window the tools are published with. */
|
|
114
|
+
const brotli = (data: Uint8Array, quality: number): Uint8Array =>
|
|
115
|
+
brotliCompressSync(data, { params: { [constants.BROTLI_PARAM_QUALITY]: quality, [constants.BROTLI_PARAM_LGWIN]: 24, [constants.BROTLI_PARAM_SIZE_HINT]: data.length } });
|
|
116
|
+
|
|
112
117
|
/**
|
|
113
118
|
* Writes the files the page reads of each local package under `outDir`, at
|
|
114
119
|
* the paths `packages` names: brotli-compressed as `<file>.brotli` from
|
|
115
120
|
* SITE_COMPRESS_FROM (and always over the size limit), and playground.json
|
|
116
|
-
* naming those (`brotli`).
|
|
121
|
+
* naming those (`brotli`). A tool or plugin goes without its custom
|
|
122
|
+
* sections, which the page drops anyway (sections.ts), as
|
|
123
|
+
* `<module>.brotli`: so the compiler fits the size limit, compressed harder
|
|
124
|
+
* when it must, and the site can serve it when npm has not got this one.
|
|
117
125
|
*/
|
|
118
126
|
export function writeLocalPackages(repoRoot: string, packages: Record<string, string>, outDir: string, limit = SITE_FILE_LIMIT, compressFrom = SITE_COMPRESS_FROM): { files: number; bytes: number } {
|
|
119
127
|
const dirs = workspacePackages(repoRoot);
|
|
120
128
|
const manifest = JSON.parse(readFileSync(path.join(dirs.get(PLAYGROUND_PACKAGE)!, PLAYGROUND_MANIFEST), 'utf8')) as PlaygroundManifest;
|
|
121
|
-
const
|
|
122
|
-
const
|
|
129
|
+
const key = (file: PackageFile): string => `${file.package}/${file.file}`;
|
|
130
|
+
const modules = new Set([manifest.frontend, manifest.linker, ...Object.values(manifest.plugins)].map(key));
|
|
131
|
+
/** Files stored under another name: brotli-compressed by the site. */
|
|
132
|
+
const renamed = new Map<string, string>();
|
|
133
|
+
const rename = (file: PackageFile): PackageFile => ({ ...file, file: renamed.get(key(file)) ?? file.file });
|
|
123
134
|
const written = { files: 0, bytes: 0 };
|
|
124
135
|
for (const [name, files] of manifestFiles(manifest)) {
|
|
125
136
|
const base = packages[name];
|
|
@@ -130,17 +141,23 @@ export function writeLocalPackages(repoRoot: string, packages: Record<string, st
|
|
|
130
141
|
if (name === PLAYGROUND_PACKAGE && file === PLAYGROUND_MANIFEST) continue;
|
|
131
142
|
let data: Uint8Array = readFileSync(path.join(dir, file));
|
|
132
143
|
let target = file;
|
|
133
|
-
if (
|
|
144
|
+
if (modules.has(`${name}/${file}`)) {
|
|
145
|
+
const module = stripCustomSections(isBrotli(file) ? brotliDecompressSync(data) : data);
|
|
146
|
+
data = brotli(module, 5);
|
|
147
|
+
if (data.length > limit) data = brotli(module, 11);
|
|
148
|
+
if (data.length > limit) throw new Error(`${name}/${file} is over ${limit} bytes even compressed, without its custom sections`);
|
|
149
|
+
target = `${file.replace(/\.br$/, '')}${SITE_BROTLI}`;
|
|
150
|
+
} else if (isBrotli(file)) {
|
|
134
151
|
if (data.length > limit) throw new Error(`${name}/${file} is over ${limit} bytes compressed: the site cannot serve it`);
|
|
135
152
|
} else if (data.length >= compressFrom || data.length > limit) {
|
|
136
|
-
const compressed =
|
|
153
|
+
const compressed = brotli(data, 5);
|
|
137
154
|
if (compressed.length > limit) throw new Error(`${name}/${file} is over ${limit} bytes even compressed`);
|
|
138
155
|
if (data.length > limit || compressed.length < data.length * 0.9) {
|
|
139
156
|
data = compressed;
|
|
140
|
-
brotli.add(`${name}/${file}`);
|
|
141
157
|
target = `${file}${SITE_BROTLI}`;
|
|
142
158
|
}
|
|
143
159
|
}
|
|
160
|
+
if (target !== file) renamed.set(`${name}/${file}`, target);
|
|
144
161
|
const out = path.join(outDir, base, target);
|
|
145
162
|
mkdirSync(path.dirname(out), { recursive: true });
|
|
146
163
|
writeFileSync(out, data);
|
|
@@ -150,8 +167,7 @@ export function writeLocalPackages(repoRoot: string, packages: Record<string, st
|
|
|
150
167
|
}
|
|
151
168
|
if (packages[PLAYGROUND_PACKAGE]) {
|
|
152
169
|
// A tool or plugin is named by its compressed file; the rest by the list.
|
|
153
|
-
const
|
|
154
|
-
const listed = [...brotli].filter((entry) => !tools.has(entry)).sort();
|
|
170
|
+
const listed = [...renamed.keys()].filter((entry) => !modules.has(entry)).sort();
|
|
155
171
|
const site: PlaygroundManifest = {
|
|
156
172
|
...manifest,
|
|
157
173
|
frontend: rename(manifest.frontend),
|