@swiftbrowser/web 0.8.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/node/config.d.ts.map +1 -1
- package/node/dist/node/config.js +12 -5
- package/node/dist/node/config.js.map +1 -1
- package/node/dist/plugins/playground.d.ts +52 -16
- package/node/dist/plugins/playground.d.ts.map +1 -1
- package/node/dist/plugins/playground.js +186 -22
- package/node/dist/plugins/playground.js.map +1 -1
- package/node/dist/src/playground/files.d.ts +73 -9
- package/node/dist/src/playground/files.d.ts.map +1 -1
- package/node/dist/src/playground/files.js +29 -6
- 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 +2 -1
- package/plugins/playground.ts +183 -27
- package/src/playground/assets.ts +100 -80
- package/src/playground/build.ts +30 -19
- package/src/playground/download.ts +125 -0
- package/src/playground/files.ts +89 -14
- package/src/playground/freeze.ts +105 -0
- package/src/playground/main.ts +42 -4
- package/src/playground/playground.css +1 -0
- 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 +47 -21
- package/src/vite-env.d.ts +2 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAKvC,OAAO,EAAmD,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAChI,OAAO,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../config.ts"],"names":[],"mappings":"AAAA;;;;;;;;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AAOD;;;;;GAKG;AACH,wBAAgB,OAAO,IAAI,MAAM,CAoBhC;AAED,gDAAgD;AAChD,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,UAAU,EAAE,CAWnE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,CAmEjE"}
|
package/node/dist/node/config.js
CHANGED
|
@@ -20,7 +20,7 @@ import { assetCatalogs } from '../plugins/asset-catalogs.js';
|
|
|
20
20
|
import { bundleResources } from '../plugins/bundle-resources.js';
|
|
21
21
|
import { includedSites, readSiteApps } from '../plugins/included-sites.js';
|
|
22
22
|
import { ROOT_START_URL, siteLayoutPlugin } from '../plugins/site-layout.js';
|
|
23
|
-
import {
|
|
23
|
+
import { playgroundAliases, playgroundPackages } from '../plugins/playground.js';
|
|
24
24
|
import { swiftWasm } from '../plugins/swift-wasm.js';
|
|
25
25
|
import { displayNameOf, validateAppSpecs } from './apps.js';
|
|
26
26
|
/** The layout `options` resolve to (see `SiteOptions.layout`). */
|
|
@@ -122,9 +122,17 @@ export function createViteConfig(options) {
|
|
|
122
122
|
bundleResources(apps),
|
|
123
123
|
includedSites(landing, sites),
|
|
124
124
|
siteLayoutPlugin(site, main),
|
|
125
|
-
...(options.playground ? [
|
|
125
|
+
...(options.playground ? [playgroundPackages(path.resolve(root, '..'), options.playground)] : []),
|
|
126
126
|
],
|
|
127
|
-
...(options.playground
|
|
127
|
+
...(options.playground
|
|
128
|
+
? {
|
|
129
|
+
resolve: { alias: playgroundAliases(path.resolve(root, '..')) },
|
|
130
|
+
worker: { format: 'es' },
|
|
131
|
+
// Found only once the worker loads it, it would make the dev server
|
|
132
|
+
// reload the page mid-download.
|
|
133
|
+
optimizeDeps: { include: ['brotli-dec-wasm/web'] },
|
|
134
|
+
}
|
|
135
|
+
: {}),
|
|
128
136
|
// The landing page at `/` and the app at `/app/` (or the app alone). `mpa`
|
|
129
137
|
// keeps the dev server from answering unknown URLs with a page.
|
|
130
138
|
appType: 'mpa',
|
|
@@ -135,8 +143,7 @@ export function createViteConfig(options) {
|
|
|
135
143
|
__SB_COMMIT__: JSON.stringify(options.commit ?? 'dev'),
|
|
136
144
|
__SB_BRANCH__: JSON.stringify(options.branch ?? ''),
|
|
137
145
|
__SB_BUILT_AT__: JSON.stringify(new Date().toISOString()),
|
|
138
|
-
|
|
139
|
-
__SB_PLAYGROUND_FILES__: JSON.stringify(options.playground ? playgroundFiles(options.playground) : null),
|
|
146
|
+
__SB_PLAYGROUND__: JSON.stringify(options.playground ?? null),
|
|
140
147
|
},
|
|
141
148
|
server: {
|
|
142
149
|
port: 5173,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAqD,MAAM,2BAA2B,CAAC;AAChI,OAAO,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,YA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AQ;YAChB,SAAS,EAAE,IAAI;YACf,aAAa,EAAE;gBACb,KAAK,EAAE,KAAK;aACb;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -3,24 +3,60 @@
|
|
|
3
3
|
* by the WebAssembly compiler (docs/in-browser-compiler.md, Milestone 3).
|
|
4
4
|
* Only this repository's site has it: its code imports
|
|
5
5
|
* @swiftbrowser/wasm-compiler and the CLI's browser entry from their sources
|
|
6
|
-
* (the aliases below).
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* (the aliases below). The page fetches the npm packages it reads
|
|
7
|
+
* (src/playground/files.ts) from a CDN that serves them file by file, at one
|
|
8
|
+
* version, except those the site serves itself (`localPackages`): the kit
|
|
9
|
+
* and @swiftbrowser/playground made from the same commit as the site's
|
|
10
|
+
* renderer, so the two cannot drift, and any package the CDN does not have
|
|
11
|
+
* at that version, the compiler's included. The dev server serves this repository's packages at
|
|
12
|
+
* /npm/, laid out as the CDN serves them, and a built site carries the
|
|
13
|
+
* files the page reads of its local packages there.
|
|
11
14
|
*/
|
|
12
15
|
import type { Plugin } from 'vite';
|
|
13
|
-
import { type
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
import { type PlaygroundManifest, type PlaygroundSource } from '../src/playground/files.js';
|
|
17
|
+
export type PlaygroundOptions = PlaygroundSource;
|
|
18
|
+
/** Where the dev server serves the workspaces' packages, and a built site its local ones. */
|
|
19
|
+
export declare const PLAYGROUND_NPM_PATH = "/npm/";
|
|
20
|
+
/** The kit, which must come from the same commit as the renderer. */
|
|
21
|
+
export declare const KIT_PACKAGE = "@swiftbrowser/kit";
|
|
22
|
+
/**
|
|
23
|
+
* Files a site stores brotli-compressed past this size: Cloudflare Pages
|
|
24
|
+
* serves files of up to 25 MiB.
|
|
25
|
+
*/
|
|
26
|
+
export declare const SITE_FILE_LIMIT: number;
|
|
27
|
+
/**
|
|
28
|
+
* Files a site stores brotli-compressed from this size, when compressing
|
|
29
|
+
* saves a tenth: a static host may not compress what it serves in transit
|
|
30
|
+
* (Cloudflare Pages leaves application/octet-stream as it is), and the
|
|
31
|
+
* archives and modules compress to about a fifth.
|
|
32
|
+
*/
|
|
33
|
+
export declare const SITE_COMPRESS_FROM: number;
|
|
23
34
|
/** The source aliases of the playground's imports, from the repository root. */
|
|
24
35
|
export declare function playgroundAliases(repoRoot: string): Record<string, string>;
|
|
25
|
-
|
|
36
|
+
/** The workspaces' package directories by package name. */
|
|
37
|
+
export declare function workspacePackages(repoRoot: string): Map<string, string>;
|
|
38
|
+
/** `@scope/name@version/file` → [name, file], whatever the version. */
|
|
39
|
+
export declare function packageRequest(pathname: string): [string, string] | null;
|
|
40
|
+
/** Every file of `manifest` by package, as the package holds it. */
|
|
41
|
+
export declare function manifestFiles(manifest: PlaygroundManifest): Map<string, string[]>;
|
|
42
|
+
/**
|
|
43
|
+
* The packages the site serves itself: @swiftbrowser/playground and the kit
|
|
44
|
+
* always, and `others`, each at /npm/<name>@site-<hash>/, the hash naming
|
|
45
|
+
* what the workspaces hold so a browser's cache keeps no stale file.
|
|
46
|
+
*/
|
|
47
|
+
export declare function localPackages(repoRoot: string, others?: readonly string[]): Record<string, string>;
|
|
48
|
+
/**
|
|
49
|
+
* Writes the files the page reads of each local package under `outDir`, at
|
|
50
|
+
* the paths `packages` names: brotli-compressed as `<file>.brotli` from
|
|
51
|
+
* SITE_COMPRESS_FROM (and always over the size limit), and playground.json
|
|
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.
|
|
56
|
+
*/
|
|
57
|
+
export declare function writeLocalPackages(repoRoot: string, packages: Record<string, string>, outDir: string, limit?: number, compressFrom?: number): {
|
|
58
|
+
files: number;
|
|
59
|
+
bytes: number;
|
|
60
|
+
};
|
|
61
|
+
export declare function playgroundPackages(repoRoot: string, options: PlaygroundOptions): Plugin;
|
|
26
62
|
//# sourceMappingURL=playground.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../../plugins/playground.ts"],"names":[],"mappings":"AAAA
|
|
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"}
|
|
@@ -3,23 +3,39 @@
|
|
|
3
3
|
* by the WebAssembly compiler (docs/in-browser-compiler.md, Milestone 3).
|
|
4
4
|
* Only this repository's site has it: its code imports
|
|
5
5
|
* @swiftbrowser/wasm-compiler and the CLI's browser entry from their sources
|
|
6
|
-
* (the aliases below).
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* (the aliases below). The page fetches the npm packages it reads
|
|
7
|
+
* (src/playground/files.ts) from a CDN that serves them file by file, at one
|
|
8
|
+
* version, except those the site serves itself (`localPackages`): the kit
|
|
9
|
+
* and @swiftbrowser/playground made from the same commit as the site's
|
|
10
|
+
* renderer, so the two cannot drift, and any package the CDN does not have
|
|
11
|
+
* at that version, the compiler's included. The dev server serves this repository's packages at
|
|
12
|
+
* /npm/, laid out as the CDN serves them, and a built site carries the
|
|
13
|
+
* files the page reads of its local packages there.
|
|
11
14
|
*/
|
|
12
|
-
import {
|
|
15
|
+
import { createHash } from 'node:crypto';
|
|
16
|
+
import { createReadStream, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from 'node:fs';
|
|
13
17
|
import path from 'node:path';
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
import { brotliCompressSync, brotliDecompressSync, constants } from 'node:zlib';
|
|
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';
|
|
21
|
+
/** Where the dev server serves the workspaces' packages, and a built site its local ones. */
|
|
22
|
+
export const PLAYGROUND_NPM_PATH = '/npm/';
|
|
23
|
+
/** The kit, which must come from the same commit as the renderer. */
|
|
24
|
+
export const KIT_PACKAGE = '@swiftbrowser/kit';
|
|
25
|
+
/**
|
|
26
|
+
* Files a site stores brotli-compressed past this size: Cloudflare Pages
|
|
27
|
+
* serves files of up to 25 MiB.
|
|
28
|
+
*/
|
|
29
|
+
export const SITE_FILE_LIMIT = 24 * 1024 * 1024;
|
|
30
|
+
/** Bumped whenever writeLocalPackages writes other files for the same packages. */
|
|
31
|
+
const SITE_LAYOUT = 3;
|
|
32
|
+
/**
|
|
33
|
+
* Files a site stores brotli-compressed from this size, when compressing
|
|
34
|
+
* saves a tenth: a static host may not compress what it serves in transit
|
|
35
|
+
* (Cloudflare Pages leaves application/octet-stream as it is), and the
|
|
36
|
+
* archives and modules compress to about a fifth.
|
|
37
|
+
*/
|
|
38
|
+
export const SITE_COMPRESS_FROM = 64 * 1024;
|
|
23
39
|
/** The source aliases of the playground's imports, from the repository root. */
|
|
24
40
|
export function playgroundAliases(repoRoot) {
|
|
25
41
|
return {
|
|
@@ -27,20 +43,168 @@ export function playgroundAliases(repoRoot) {
|
|
|
27
43
|
'@swiftbrowser/cli/browser': path.join(repoRoot, 'packages/cli/src/browser.ts'),
|
|
28
44
|
};
|
|
29
45
|
}
|
|
30
|
-
|
|
46
|
+
/** The workspaces' package directories by package name. */
|
|
47
|
+
export function workspacePackages(repoRoot) {
|
|
48
|
+
const dirs = new Map();
|
|
49
|
+
const packagesDir = path.join(repoRoot, 'packages');
|
|
50
|
+
for (const name of readdirSync(packagesDir)) {
|
|
51
|
+
const manifest = path.join(packagesDir, name, 'package.json');
|
|
52
|
+
if (existsSync(manifest))
|
|
53
|
+
dirs.set(JSON.parse(readFileSync(manifest, 'utf8')).name, path.join(packagesDir, name));
|
|
54
|
+
}
|
|
55
|
+
return dirs;
|
|
56
|
+
}
|
|
57
|
+
/** `@scope/name@version/file` → [name, file], whatever the version. */
|
|
58
|
+
export function packageRequest(pathname) {
|
|
59
|
+
const match = /^(@[^/]+\/[^/@]+)@[^/]+\/(.+)$/.exec(pathname);
|
|
60
|
+
return match ? [match[1], match[2]] : null;
|
|
61
|
+
}
|
|
62
|
+
/** Every file of `manifest` by package, as the package holds it. */
|
|
63
|
+
export function manifestFiles(manifest) {
|
|
64
|
+
const files = new Map();
|
|
65
|
+
const add = ({ package: name, file }) => void (files.get(name) ?? files.set(name, []).get(name)).push(file);
|
|
66
|
+
for (const file of [manifest.frontend, manifest.linker, ...Object.values(manifest.plugins)])
|
|
67
|
+
add(file);
|
|
68
|
+
for (const [name, list] of Object.entries(manifest.sdk))
|
|
69
|
+
for (const file of list)
|
|
70
|
+
add({ package: name, file: `wasm32-unknown-wasip1/${file}` });
|
|
71
|
+
for (const file of [...manifest.kit, 'kit.json'])
|
|
72
|
+
add({ package: KIT_PACKAGE, file });
|
|
73
|
+
for (const file of [PLAYGROUND_MANIFEST, PLAYGROUND_ICU, PLAYGROUND_MODULE_CACHE])
|
|
74
|
+
add({ package: PLAYGROUND_PACKAGE, file });
|
|
75
|
+
return files;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The packages the site serves itself: @swiftbrowser/playground and the kit
|
|
79
|
+
* always, and `others`, each at /npm/<name>@site-<hash>/, the hash naming
|
|
80
|
+
* what the workspaces hold so a browser's cache keeps no stale file.
|
|
81
|
+
*/
|
|
82
|
+
export function localPackages(repoRoot, others = []) {
|
|
83
|
+
const dirs = workspacePackages(repoRoot);
|
|
84
|
+
const own = dirs.get(PLAYGROUND_PACKAGE);
|
|
85
|
+
const manifestFile = path.join(own, PLAYGROUND_MANIFEST);
|
|
86
|
+
if (!existsSync(manifestFile))
|
|
87
|
+
throw new Error(`${manifestFile} is missing: run \`npm run playground:assets --workspace @swiftbrowser/web\``);
|
|
88
|
+
const hash = createHash('sha256');
|
|
89
|
+
for (const file of [PLAYGROUND_MANIFEST, PLAYGROUND_ICU, PLAYGROUND_MODULE_CACHE])
|
|
90
|
+
hash.update(readFileSync(path.join(own, file)));
|
|
91
|
+
hash.update(readFileSync(path.join(dirs.get(KIT_PACKAGE), 'kit.json')));
|
|
92
|
+
const names = [...new Set([PLAYGROUND_PACKAGE, KIT_PACKAGE, ...others])].sort();
|
|
93
|
+
for (const name of names)
|
|
94
|
+
hash.update(`${name}\n`);
|
|
95
|
+
// And how writeLocalPackages lays them out: another layout is other files.
|
|
96
|
+
hash.update(`layout ${SITE_LAYOUT} ${SITE_FILE_LIMIT} ${SITE_COMPRESS_FROM}\n`);
|
|
97
|
+
const version = `site-${hash.digest('hex').slice(0, 12)}`;
|
|
98
|
+
return Object.fromEntries(names.map((name) => [name, `${PLAYGROUND_NPM_PATH}${name}@${version}/`]));
|
|
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 } });
|
|
102
|
+
/**
|
|
103
|
+
* Writes the files the page reads of each local package under `outDir`, at
|
|
104
|
+
* the paths `packages` names: brotli-compressed as `<file>.brotli` from
|
|
105
|
+
* SITE_COMPRESS_FROM (and always over the size limit), and playground.json
|
|
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.
|
|
110
|
+
*/
|
|
111
|
+
export function writeLocalPackages(repoRoot, packages, outDir, limit = SITE_FILE_LIMIT, compressFrom = SITE_COMPRESS_FROM) {
|
|
112
|
+
const dirs = workspacePackages(repoRoot);
|
|
113
|
+
const manifest = JSON.parse(readFileSync(path.join(dirs.get(PLAYGROUND_PACKAGE), PLAYGROUND_MANIFEST), 'utf8'));
|
|
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 });
|
|
119
|
+
const written = { files: 0, bytes: 0 };
|
|
120
|
+
for (const [name, files] of manifestFiles(manifest)) {
|
|
121
|
+
const base = packages[name];
|
|
122
|
+
if (!base)
|
|
123
|
+
continue;
|
|
124
|
+
const dir = dirs.get(name);
|
|
125
|
+
if (!dir)
|
|
126
|
+
throw new Error(`the site serves ${name}, which is not a package of this repository`);
|
|
127
|
+
for (const file of files) {
|
|
128
|
+
if (name === PLAYGROUND_PACKAGE && file === PLAYGROUND_MANIFEST)
|
|
129
|
+
continue;
|
|
130
|
+
let data = readFileSync(path.join(dir, file));
|
|
131
|
+
let target = file;
|
|
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)) {
|
|
142
|
+
if (data.length > limit)
|
|
143
|
+
throw new Error(`${name}/${file} is over ${limit} bytes compressed: the site cannot serve it`);
|
|
144
|
+
}
|
|
145
|
+
else if (data.length >= compressFrom || data.length > limit) {
|
|
146
|
+
const compressed = brotli(data, 5);
|
|
147
|
+
if (compressed.length > limit)
|
|
148
|
+
throw new Error(`${name}/${file} is over ${limit} bytes even compressed`);
|
|
149
|
+
if (data.length > limit || compressed.length < data.length * 0.9) {
|
|
150
|
+
data = compressed;
|
|
151
|
+
target = `${file}${SITE_BROTLI}`;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (target !== file)
|
|
155
|
+
renamed.set(`${name}/${file}`, target);
|
|
156
|
+
const out = path.join(outDir, base, target);
|
|
157
|
+
mkdirSync(path.dirname(out), { recursive: true });
|
|
158
|
+
writeFileSync(out, data);
|
|
159
|
+
written.files += 1;
|
|
160
|
+
written.bytes += data.length;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (packages[PLAYGROUND_PACKAGE]) {
|
|
164
|
+
// A tool or plugin is named by its compressed file; the rest by the list.
|
|
165
|
+
const listed = [...renamed.keys()].filter((entry) => !modules.has(entry)).sort();
|
|
166
|
+
const site = {
|
|
167
|
+
...manifest,
|
|
168
|
+
frontend: rename(manifest.frontend),
|
|
169
|
+
linker: rename(manifest.linker),
|
|
170
|
+
plugins: Object.fromEntries(Object.entries(manifest.plugins).map(([macro, file]) => [macro, rename(file)])),
|
|
171
|
+
...(listed.length > 0 ? { brotli: listed } : {}),
|
|
172
|
+
};
|
|
173
|
+
const out = path.join(outDir, packages[PLAYGROUND_PACKAGE], PLAYGROUND_MANIFEST);
|
|
174
|
+
mkdirSync(path.dirname(out), { recursive: true });
|
|
175
|
+
writeFileSync(out, `${JSON.stringify(site)}\n`);
|
|
176
|
+
written.files += 1;
|
|
177
|
+
}
|
|
178
|
+
return written;
|
|
179
|
+
}
|
|
180
|
+
export function playgroundPackages(repoRoot, options) {
|
|
181
|
+
let outDir = '';
|
|
31
182
|
return {
|
|
32
|
-
name: 'swiftbrowser-playground-
|
|
183
|
+
name: 'swiftbrowser-playground-packages',
|
|
184
|
+
configResolved(config) {
|
|
185
|
+
outDir = path.resolve(config.root, config.build.outDir);
|
|
186
|
+
},
|
|
33
187
|
configureServer(server) {
|
|
34
|
-
const
|
|
35
|
-
server.middlewares.use(
|
|
36
|
-
const
|
|
37
|
-
|
|
188
|
+
const packages = workspacePackages(repoRoot);
|
|
189
|
+
server.middlewares.use(PLAYGROUND_NPM_PATH, (req, res, next) => {
|
|
190
|
+
const request = packageRequest(decodeURIComponent(new URL(req.url ?? '/', 'http://x').pathname).replace(/^\//, ''));
|
|
191
|
+
const dir = request && packages.get(request[0]);
|
|
192
|
+
if (!request || !dir)
|
|
38
193
|
return next();
|
|
39
|
-
|
|
194
|
+
const file = path.join(dir, request[1]);
|
|
195
|
+
if (!existsSync(file) || statSync(file).isDirectory() || !realpathSync(file).startsWith(realpathSync(dir)))
|
|
196
|
+
return next();
|
|
197
|
+
res.setHeader('Content-Type', file.endsWith('.wasm') ? 'application/wasm' : file.endsWith('.json') ? 'application/json' : 'application/octet-stream');
|
|
40
198
|
res.setHeader('Content-Length', statSync(file).size);
|
|
41
199
|
createReadStream(file).pipe(res);
|
|
42
200
|
});
|
|
43
201
|
},
|
|
202
|
+
writeBundle() {
|
|
203
|
+
if (!options.packages)
|
|
204
|
+
return;
|
|
205
|
+
const { files, bytes } = writeLocalPackages(repoRoot, options.packages, outDir);
|
|
206
|
+
this.info(`the playground's local packages: ${files} files, ${(bytes / 1e6).toFixed(1)} MB`);
|
|
207
|
+
},
|
|
44
208
|
};
|
|
45
209
|
}
|
|
46
210
|
//# sourceMappingURL=playground.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.js","sourceRoot":"","sources":["../../../plugins/playground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AC;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"}
|
|
@@ -1,12 +1,76 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export declare const PLAYGROUND_PACKAGE = "@swiftbrowser/playground";
|
|
2
|
+
export declare const PLAYGROUND_MANIFEST = "playground.json";
|
|
3
|
+
/** The trimmed ICU data, in @swiftbrowser/playground. */
|
|
4
|
+
export declare const PLAYGROUND_ICU = "icu.dat";
|
|
5
|
+
/** The module cache, packed (pack.ts), in @swiftbrowser/playground. */
|
|
6
|
+
export declare const PLAYGROUND_MODULE_CACHE = "module-cache.pack";
|
|
7
|
+
/** Where the npm packages are fetched from by default. */
|
|
8
|
+
export declare const JSDELIVR = "https://cdn.jsdelivr.net/npm/";
|
|
9
|
+
/** A file of one of the packages. */
|
|
10
|
+
export interface PackageFile {
|
|
11
|
+
package: string;
|
|
12
|
+
/** The path in the package; `.br` files are brotli-compressed. */
|
|
13
|
+
file: string;
|
|
14
|
+
}
|
|
15
|
+
/** @swiftbrowser/playground's playground.json. */
|
|
16
|
+
export interface PlaygroundManifest {
|
|
17
|
+
/** The symbol Foundation's ICU reads its data through (`icudtNN_dat`). */
|
|
18
|
+
icuSymbol: string;
|
|
19
|
+
/** The apps whose compiles recorded the files. */
|
|
20
|
+
apps: string[];
|
|
21
|
+
frontend: PackageFile;
|
|
22
|
+
linker: PackageFile;
|
|
8
23
|
/** The macro plugins by the module whose macros they expand. */
|
|
9
|
-
plugins: Record<string,
|
|
24
|
+
plugins: Record<string, PackageFile>;
|
|
25
|
+
/**
|
|
26
|
+
* The Swift SDK's files a compile reads, by package, each relative to the
|
|
27
|
+
* SDK's `wasm32-unknown-wasip1` directory (the package's own
|
|
28
|
+
* `wasm32-unknown-wasip1/` holds it there).
|
|
29
|
+
*/
|
|
30
|
+
sdk: Record<string, string[]>;
|
|
31
|
+
/** The kit's files a compile reads, relative to @swiftbrowser/kit (`wasm32-unknown-wasip1/...`). */
|
|
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>;
|
|
39
|
+
/**
|
|
40
|
+
* The SwiftBrowser sources the kit was built from (@swiftbrowser/swift's
|
|
41
|
+
* `sourcesHash`), when build-assets.ts could tell: the page compares it
|
|
42
|
+
* with the sources its own renderer was built from.
|
|
43
|
+
*/
|
|
44
|
+
shimSources?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Files, as `<package>/<path>`, that the site serving them stores
|
|
47
|
+
* brotli-compressed (`<path>.brotli`, SITE_BROTLI): an SDK or kit file,
|
|
48
|
+
* the ICU data or the module cache (plugins/playground.ts). A tool or
|
|
49
|
+
* plugin is named by its compressed file instead.
|
|
50
|
+
*/
|
|
51
|
+
brotli?: string[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The suffix of a file a site stores brotli-compressed. Not `.br`: a static
|
|
55
|
+
* server may send a `.br` file as `Content-Encoding: br`, which the browser
|
|
56
|
+
* unpacks before the page could.
|
|
57
|
+
*/
|
|
58
|
+
export declare const SITE_BROTLI = ".brotli";
|
|
59
|
+
/** Whether a file is brotli-compressed by its name: an npm package's `.br`, or a site's. */
|
|
60
|
+
export declare const isBrotli: (file: string) => boolean;
|
|
61
|
+
/** Where the packages come from. */
|
|
62
|
+
export interface PlaygroundSource {
|
|
63
|
+
/** A CDN's npm base URL, which serves every package at `version`... */
|
|
64
|
+
npm: string;
|
|
65
|
+
version: string;
|
|
66
|
+
/**
|
|
67
|
+
* ...but those named here, each served from its own base URL: the site's
|
|
68
|
+
* copy, made from the same commit as its renderer (plugins/playground.ts).
|
|
69
|
+
*/
|
|
70
|
+
packages?: Record<string, string>;
|
|
71
|
+
/** The SwiftBrowser sources the site's renderer was built from (`sourcesHash`). */
|
|
72
|
+
shimSources?: string;
|
|
10
73
|
}
|
|
11
|
-
|
|
74
|
+
/** The URL of a package's file. */
|
|
75
|
+
export declare function packageUrl(source: PlaygroundSource, name: string, file: string): string;
|
|
12
76
|
//# sourceMappingURL=files.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../src/playground/files.ts"],"names":[],"mappings":"
|
|
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,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAC3D,0DAA0D;AAC1D,eAAO,MAAM,QAAQ,kCAAkC,CAAC;AAExD,qCAAqC;AACrC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;CACd;AAED,kDAAkD;AAClD,MAAM,WAAW,kBAAkB;IACjC,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,EAAE,WAAW,CAAC;IACtB,MAAM,EAAE,WAAW,CAAC;IACpB,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACrC;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9B,oGAAoG;IACpG,GAAG,EAAE,MAAM,EAAE,CAAC;IACd;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,YAAY,CAAC;AAErC,4FAA4F;AAC5F,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,KAAG,OAA6D,CAAC;AAEtG,oCAAoC;AACpC,MAAM,WAAW,gBAAgB;IAC/B,uEAAuE;IACvE,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,7 +1,30 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
|
|
1
|
+
// What the playground downloads, all from npm packages at one version (the
|
|
2
|
+
// release's lockstep version), through a CDN that serves npm packages file by
|
|
3
|
+
// file (jsDelivr): the compiler, the linker and the toolchain's macro plugins
|
|
4
|
+
// from @swiftbrowser/wasm-tools, the Swift SDK's files from the
|
|
5
|
+
// @swiftbrowser/wasm-sdk packages, the kit's from @swiftbrowser/kit, and what
|
|
6
|
+
// only the playground needs from @swiftbrowser/playground: its manifest
|
|
7
|
+
// (which files of those packages a compile reads), the trimmed ICU data and
|
|
8
|
+
// the module cache. playground/build-assets.ts makes that package.
|
|
9
|
+
export const PLAYGROUND_PACKAGE = '@swiftbrowser/playground';
|
|
10
|
+
export const PLAYGROUND_MANIFEST = 'playground.json';
|
|
11
|
+
/** The trimmed ICU data, in @swiftbrowser/playground. */
|
|
12
|
+
export const PLAYGROUND_ICU = 'icu.dat';
|
|
13
|
+
/** The module cache, packed (pack.ts), in @swiftbrowser/playground. */
|
|
14
|
+
export const PLAYGROUND_MODULE_CACHE = 'module-cache.pack';
|
|
15
|
+
/** Where the npm packages are fetched from by default. */
|
|
16
|
+
export const JSDELIVR = 'https://cdn.jsdelivr.net/npm/';
|
|
17
|
+
/**
|
|
18
|
+
* The suffix of a file a site stores brotli-compressed. Not `.br`: a static
|
|
19
|
+
* server may send a `.br` file as `Content-Encoding: br`, which the browser
|
|
20
|
+
* unpacks before the page could.
|
|
21
|
+
*/
|
|
22
|
+
export const SITE_BROTLI = '.brotli';
|
|
23
|
+
/** Whether a file is brotli-compressed by its name: an npm package's `.br`, or a site's. */
|
|
24
|
+
export const isBrotli = (file) => file.endsWith('.br') || file.endsWith(SITE_BROTLI);
|
|
25
|
+
/** The URL of a package's file. */
|
|
26
|
+
export function packageUrl(source, name, file) {
|
|
27
|
+
const base = source.packages?.[name];
|
|
28
|
+
return base ? new URL(file, base).href : new URL(`${name}@${source.version}/${file}`, source.npm).href;
|
|
29
|
+
}
|
|
7
30
|
//# sourceMappingURL=files.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../../src/playground/files.ts"],"names":[],"mappings":"AAAA,
|
|
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"}
|