@swiftbrowser/web 0.9.0 → 0.9.2
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/app/index.html +3 -0
- package/node/dist/plugins/playground.d.ts +6 -3
- package/node/dist/plugins/playground.d.ts.map +1 -1
- package/node/dist/plugins/playground.js +32 -12
- 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 +6 -1
- package/plugins/playground.ts +30 -12
- package/src/main.ts +6 -2
- package/src/page.css +16 -0
- package/src/playground/app.tsx +311 -0
- 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.tsx +45 -0
- package/src/playground/playground.css +192 -29
- package/src/playground/read-once.ts +75 -0
- package/src/playground/sections.ts +77 -0
- package/src/playground/session.ts +117 -0
- package/src/playground/tool-host.ts +163 -0
- package/src/playground/tool-worker.ts +67 -0
- package/src/playground/worker.ts +41 -17
- package/src/playground/main.ts +0 -107
package/app/index.html
CHANGED
|
@@ -40,6 +40,9 @@
|
|
|
40
40
|
var coarse = typeof matchMedia === 'function' && matchMedia('(pointer: coarse)').matches;
|
|
41
41
|
var device = mode === 'device' || (mode !== 'frame' && (coarse || site.pageMode === 'device'));
|
|
42
42
|
document.documentElement.setAttribute('data-sb-mode', device ? 'device' : 'frame');
|
|
43
|
+
// ?embed=1: the page is in another's frame (the playground's
|
|
44
|
+
// simulator), which has its own controls: the device alone.
|
|
45
|
+
if (new URLSearchParams(location.search).get('embed') === '1') document.documentElement.setAttribute('data-sb-embed', '');
|
|
43
46
|
})();
|
|
44
47
|
// Point the manifest, the home-screen icon and the titles at the app
|
|
45
48
|
// this page runs (?app=, else the site's default), so Share -> Add to
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* The playground page (playground/index.html): Swift compiled in the browser
|
|
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
|
-
* @swiftbrowser/wasm-compiler
|
|
5
|
+
* @swiftbrowser/wasm-compiler, the CLI's browser entry and @swiftbrowser/react from their sources
|
|
6
6
|
* (the aliases below). The page fetches the npm packages it reads
|
|
7
7
|
* (src/playground/files.ts) from a CDN that serves them file by file, at one
|
|
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,CAO1E;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"}
|
|
@@ -2,21 +2,22 @@
|
|
|
2
2
|
* The playground page (playground/index.html): Swift compiled in the browser
|
|
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
|
-
* @swiftbrowser/wasm-compiler
|
|
5
|
+
* @swiftbrowser/wasm-compiler, the CLI's browser entry and @swiftbrowser/react from their sources
|
|
6
6
|
* (the aliases below). The page fetches the npm packages it reads
|
|
7
7
|
* (src/playground/files.ts) from a CDN that serves them file by file, at one
|
|
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
|
|
@@ -40,6 +41,8 @@ export function playgroundAliases(repoRoot) {
|
|
|
40
41
|
return {
|
|
41
42
|
'@swiftbrowser/wasm-compiler': path.join(repoRoot, 'packages/wasm-compiler/src/index.ts'),
|
|
42
43
|
'@swiftbrowser/cli/browser': path.join(repoRoot, 'packages/cli/src/browser.ts'),
|
|
44
|
+
// The page's own UI is SwiftUI views from @swiftbrowser/react.
|
|
45
|
+
'@swiftbrowser/react': path.join(repoRoot, 'packages/react/src/index.ts'),
|
|
43
46
|
};
|
|
44
47
|
}
|
|
45
48
|
/** The workspaces' package directories by package name. */
|
|
@@ -96,17 +99,25 @@ export function localPackages(repoRoot, others = []) {
|
|
|
96
99
|
const version = `site-${hash.digest('hex').slice(0, 12)}`;
|
|
97
100
|
return Object.fromEntries(names.map((name) => [name, `${PLAYGROUND_NPM_PATH}${name}@${version}/`]));
|
|
98
101
|
}
|
|
102
|
+
/** `data` brotli-compressed at `quality`, with the window the tools are published with. */
|
|
103
|
+
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
104
|
/**
|
|
100
105
|
* Writes the files the page reads of each local package under `outDir`, at
|
|
101
106
|
* the paths `packages` names: brotli-compressed as `<file>.brotli` from
|
|
102
107
|
* SITE_COMPRESS_FROM (and always over the size limit), and playground.json
|
|
103
|
-
* naming those (`brotli`).
|
|
108
|
+
* naming those (`brotli`). A tool or plugin goes without its custom
|
|
109
|
+
* sections, which the page drops anyway (sections.ts), as
|
|
110
|
+
* `<module>.brotli`: so the compiler fits the size limit, compressed harder
|
|
111
|
+
* when it must, and the site can serve it when npm has not got this one.
|
|
104
112
|
*/
|
|
105
113
|
export function writeLocalPackages(repoRoot, packages, outDir, limit = SITE_FILE_LIMIT, compressFrom = SITE_COMPRESS_FROM) {
|
|
106
114
|
const dirs = workspacePackages(repoRoot);
|
|
107
115
|
const manifest = JSON.parse(readFileSync(path.join(dirs.get(PLAYGROUND_PACKAGE), PLAYGROUND_MANIFEST), 'utf8'));
|
|
108
|
-
const
|
|
109
|
-
const
|
|
116
|
+
const key = (file) => `${file.package}/${file.file}`;
|
|
117
|
+
const modules = new Set([manifest.frontend, manifest.linker, ...Object.values(manifest.plugins)].map(key));
|
|
118
|
+
/** Files stored under another name: brotli-compressed by the site. */
|
|
119
|
+
const renamed = new Map();
|
|
120
|
+
const rename = (file) => ({ ...file, file: renamed.get(key(file)) ?? file.file });
|
|
110
121
|
const written = { files: 0, bytes: 0 };
|
|
111
122
|
for (const [name, files] of manifestFiles(manifest)) {
|
|
112
123
|
const base = packages[name];
|
|
@@ -120,20 +131,30 @@ export function writeLocalPackages(repoRoot, packages, outDir, limit = SITE_FILE
|
|
|
120
131
|
continue;
|
|
121
132
|
let data = readFileSync(path.join(dir, file));
|
|
122
133
|
let target = file;
|
|
123
|
-
if (
|
|
134
|
+
if (modules.has(`${name}/${file}`)) {
|
|
135
|
+
const module = stripCustomSections(isBrotli(file) ? brotliDecompressSync(data) : data);
|
|
136
|
+
data = brotli(module, 5);
|
|
137
|
+
if (data.length > limit)
|
|
138
|
+
data = brotli(module, 11);
|
|
139
|
+
if (data.length > limit)
|
|
140
|
+
throw new Error(`${name}/${file} is over ${limit} bytes even compressed, without its custom sections`);
|
|
141
|
+
target = `${file.replace(/\.br$/, '')}${SITE_BROTLI}`;
|
|
142
|
+
}
|
|
143
|
+
else if (isBrotli(file)) {
|
|
124
144
|
if (data.length > limit)
|
|
125
145
|
throw new Error(`${name}/${file} is over ${limit} bytes compressed: the site cannot serve it`);
|
|
126
146
|
}
|
|
127
147
|
else if (data.length >= compressFrom || data.length > limit) {
|
|
128
|
-
const compressed =
|
|
148
|
+
const compressed = brotli(data, 5);
|
|
129
149
|
if (compressed.length > limit)
|
|
130
150
|
throw new Error(`${name}/${file} is over ${limit} bytes even compressed`);
|
|
131
151
|
if (data.length > limit || compressed.length < data.length * 0.9) {
|
|
132
152
|
data = compressed;
|
|
133
|
-
brotli.add(`${name}/${file}`);
|
|
134
153
|
target = `${file}${SITE_BROTLI}`;
|
|
135
154
|
}
|
|
136
155
|
}
|
|
156
|
+
if (target !== file)
|
|
157
|
+
renamed.set(`${name}/${file}`, target);
|
|
137
158
|
const out = path.join(outDir, base, target);
|
|
138
159
|
mkdirSync(path.dirname(out), { recursive: true });
|
|
139
160
|
writeFileSync(out, data);
|
|
@@ -143,8 +164,7 @@ export function writeLocalPackages(repoRoot, packages, outDir, limit = SITE_FILE
|
|
|
143
164
|
}
|
|
144
165
|
if (packages[PLAYGROUND_PACKAGE]) {
|
|
145
166
|
// 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();
|
|
167
|
+
const listed = [...renamed.keys()].filter((entry) => !modules.has(entry)).sort();
|
|
148
168
|
const site = {
|
|
149
169
|
...manifest,
|
|
150
170
|
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,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpI,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
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,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpI,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEhF,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,WAAW,EACX,QAAQ,GAIT,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAIpE,6FAA6F;AAC7F,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAC3C,qEAAqE;AACrE,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAAC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C,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;oBAAE,OAAO,IAAI,EAAE,CAAC;gBAC1H,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC;gBACtJ,GAAG,CAAC,SAAS,CAAC,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,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,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,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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":[],"mappings":"AAAA,wEAAwE;AACxE,6EAA6E;AAC7E,6EAA6E;AAC7E,oDAAoD;AAEpD,oEAAoE;AACpE,MAAM,UAAU,qBAAqB;IACnC,2EAA2E;IAC3E,yEAAyE;IACzE,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,MAAM,GAAa,EAAE,CAAC;IAC1B,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,OAAO,IAAI,eAAe,CAAC;QACzB,SAAS,CAAC,KAAK,EAAE,UAAU;YACzB,IAAI,EAAE,GAAG,CAAC,CAAC;YACX,OAAO,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;gBACzB,IAAI,QAAQ,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;oBAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;oBAC1E,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;oBACnD,IAAI,QA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CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IACjF,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACtB,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;IACxB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swiftbrowser/web",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "SwiftBrowser web renderer and dev server: applies render ops from a Swift/Wasm app to the DOM inside an iPhone frame.",
|
|
6
6
|
"repository": {
|
|
@@ -56,7 +56,12 @@
|
|
|
56
56
|
"@playwright/test": "^1.56.0",
|
|
57
57
|
"@types/node": "^26.6.4",
|
|
58
58
|
"@types/qrcode": "^1.5.6",
|
|
59
|
+
"@types/react": "^19.3.0",
|
|
60
|
+
"@types/react-dom": "^19.3.0",
|
|
59
61
|
"brotli-dec-wasm": "^2.3.2",
|
|
62
|
+
"react": "^19.3.1",
|
|
63
|
+
"react-dom": "^19.3.1",
|
|
64
|
+
"react-reconciler": "^0.34.0",
|
|
60
65
|
"typescript": "^5.9.2",
|
|
61
66
|
"vitest": "^5.0.3"
|
|
62
67
|
}
|
package/plugins/playground.ts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* The playground page (playground/index.html): Swift compiled in the browser
|
|
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
|
-
* @swiftbrowser/wasm-compiler
|
|
5
|
+
* @swiftbrowser/wasm-compiler, the CLI's browser entry and @swiftbrowser/react from their sources
|
|
6
6
|
* (the aliases below). The page fetches the npm packages it reads
|
|
7
7
|
* (src/playground/files.ts) from a CDN that serves them file by file, at one
|
|
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
|
*/
|
|
@@ -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
|
|
@@ -57,6 +58,8 @@ export function playgroundAliases(repoRoot: string): Record<string, string> {
|
|
|
57
58
|
return {
|
|
58
59
|
'@swiftbrowser/wasm-compiler': path.join(repoRoot, 'packages/wasm-compiler/src/index.ts'),
|
|
59
60
|
'@swiftbrowser/cli/browser': path.join(repoRoot, 'packages/cli/src/browser.ts'),
|
|
61
|
+
// The page's own UI is SwiftUI views from @swiftbrowser/react.
|
|
62
|
+
'@swiftbrowser/react': path.join(repoRoot, 'packages/react/src/index.ts'),
|
|
60
63
|
};
|
|
61
64
|
}
|
|
62
65
|
|
|
@@ -109,17 +112,27 @@ export function localPackages(repoRoot: string, others: readonly string[] = []):
|
|
|
109
112
|
return Object.fromEntries(names.map((name) => [name, `${PLAYGROUND_NPM_PATH}${name}@${version}/`]));
|
|
110
113
|
}
|
|
111
114
|
|
|
115
|
+
/** `data` brotli-compressed at `quality`, with the window the tools are published with. */
|
|
116
|
+
const brotli = (data: Uint8Array, quality: number): Uint8Array =>
|
|
117
|
+
brotliCompressSync(data, { params: { [constants.BROTLI_PARAM_QUALITY]: quality, [constants.BROTLI_PARAM_LGWIN]: 24, [constants.BROTLI_PARAM_SIZE_HINT]: data.length } });
|
|
118
|
+
|
|
112
119
|
/**
|
|
113
120
|
* Writes the files the page reads of each local package under `outDir`, at
|
|
114
121
|
* the paths `packages` names: brotli-compressed as `<file>.brotli` from
|
|
115
122
|
* SITE_COMPRESS_FROM (and always over the size limit), and playground.json
|
|
116
|
-
* naming those (`brotli`).
|
|
123
|
+
* naming those (`brotli`). A tool or plugin goes without its custom
|
|
124
|
+
* sections, which the page drops anyway (sections.ts), as
|
|
125
|
+
* `<module>.brotli`: so the compiler fits the size limit, compressed harder
|
|
126
|
+
* when it must, and the site can serve it when npm has not got this one.
|
|
117
127
|
*/
|
|
118
128
|
export function writeLocalPackages(repoRoot: string, packages: Record<string, string>, outDir: string, limit = SITE_FILE_LIMIT, compressFrom = SITE_COMPRESS_FROM): { files: number; bytes: number } {
|
|
119
129
|
const dirs = workspacePackages(repoRoot);
|
|
120
130
|
const manifest = JSON.parse(readFileSync(path.join(dirs.get(PLAYGROUND_PACKAGE)!, PLAYGROUND_MANIFEST), 'utf8')) as PlaygroundManifest;
|
|
121
|
-
const
|
|
122
|
-
const
|
|
131
|
+
const key = (file: PackageFile): string => `${file.package}/${file.file}`;
|
|
132
|
+
const modules = new Set([manifest.frontend, manifest.linker, ...Object.values(manifest.plugins)].map(key));
|
|
133
|
+
/** Files stored under another name: brotli-compressed by the site. */
|
|
134
|
+
const renamed = new Map<string, string>();
|
|
135
|
+
const rename = (file: PackageFile): PackageFile => ({ ...file, file: renamed.get(key(file)) ?? file.file });
|
|
123
136
|
const written = { files: 0, bytes: 0 };
|
|
124
137
|
for (const [name, files] of manifestFiles(manifest)) {
|
|
125
138
|
const base = packages[name];
|
|
@@ -130,17 +143,23 @@ export function writeLocalPackages(repoRoot: string, packages: Record<string, st
|
|
|
130
143
|
if (name === PLAYGROUND_PACKAGE && file === PLAYGROUND_MANIFEST) continue;
|
|
131
144
|
let data: Uint8Array = readFileSync(path.join(dir, file));
|
|
132
145
|
let target = file;
|
|
133
|
-
if (
|
|
146
|
+
if (modules.has(`${name}/${file}`)) {
|
|
147
|
+
const module = stripCustomSections(isBrotli(file) ? brotliDecompressSync(data) : data);
|
|
148
|
+
data = brotli(module, 5);
|
|
149
|
+
if (data.length > limit) data = brotli(module, 11);
|
|
150
|
+
if (data.length > limit) throw new Error(`${name}/${file} is over ${limit} bytes even compressed, without its custom sections`);
|
|
151
|
+
target = `${file.replace(/\.br$/, '')}${SITE_BROTLI}`;
|
|
152
|
+
} else if (isBrotli(file)) {
|
|
134
153
|
if (data.length > limit) throw new Error(`${name}/${file} is over ${limit} bytes compressed: the site cannot serve it`);
|
|
135
154
|
} else if (data.length >= compressFrom || data.length > limit) {
|
|
136
|
-
const compressed =
|
|
155
|
+
const compressed = brotli(data, 5);
|
|
137
156
|
if (compressed.length > limit) throw new Error(`${name}/${file} is over ${limit} bytes even compressed`);
|
|
138
157
|
if (data.length > limit || compressed.length < data.length * 0.9) {
|
|
139
158
|
data = compressed;
|
|
140
|
-
brotli.add(`${name}/${file}`);
|
|
141
159
|
target = `${file}${SITE_BROTLI}`;
|
|
142
160
|
}
|
|
143
161
|
}
|
|
162
|
+
if (target !== file) renamed.set(`${name}/${file}`, target);
|
|
144
163
|
const out = path.join(outDir, base, target);
|
|
145
164
|
mkdirSync(path.dirname(out), { recursive: true });
|
|
146
165
|
writeFileSync(out, data);
|
|
@@ -150,8 +169,7 @@ export function writeLocalPackages(repoRoot: string, packages: Record<string, st
|
|
|
150
169
|
}
|
|
151
170
|
if (packages[PLAYGROUND_PACKAGE]) {
|
|
152
171
|
// 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();
|
|
172
|
+
const listed = [...renamed.keys()].filter((entry) => !modules.has(entry)).sort();
|
|
155
173
|
const site: PlaygroundManifest = {
|
|
156
174
|
...manifest,
|
|
157
175
|
frontend: rename(manifest.frontend),
|
package/src/main.ts
CHANGED
|
@@ -147,11 +147,15 @@ function applyTheme(theme: Theme, persist: boolean): void {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
/**
|
|
150
|
+
/**
|
|
151
|
+
* The OS appearance: device mode follows it, and an embedded page
|
|
152
|
+
* (`?embed=1`, the playground's simulator) too; the toolbar toggle is
|
|
153
|
+
* hidden in both.
|
|
154
|
+
*/
|
|
151
155
|
const darkScheme = typeof matchMedia === 'function' ? matchMedia('(prefers-color-scheme: dark)') : null;
|
|
152
156
|
const systemTheme = (): Theme => (darkScheme?.matches ? 'dark' : 'light');
|
|
153
157
|
|
|
154
|
-
if (deviceMode) {
|
|
158
|
+
if (deviceMode || document.documentElement.hasAttribute('data-sb-embed')) {
|
|
155
159
|
applyTheme(systemTheme(), false);
|
|
156
160
|
darkScheme?.addEventListener('change', () => {
|
|
157
161
|
applyTheme(systemTheme(), false);
|
package/src/page.css
CHANGED
|
@@ -232,3 +232,19 @@ html[data-sb-mode="device"] .status {
|
|
|
232
232
|
max-height: 40dvh;
|
|
233
233
|
overflow: auto;
|
|
234
234
|
}
|
|
235
|
+
|
|
236
|
+
/* Embedded (?embed=1, app/index.html): in another page's frame, which has
|
|
237
|
+
its own controls and background. The device alone, at the top. */
|
|
238
|
+
html[data-sb-embed] .toolbar {
|
|
239
|
+
display: none;
|
|
240
|
+
}
|
|
241
|
+
html[data-sb-embed],
|
|
242
|
+
html[data-sb-embed] body {
|
|
243
|
+
min-height: 0;
|
|
244
|
+
background: transparent;
|
|
245
|
+
overflow: hidden;
|
|
246
|
+
}
|
|
247
|
+
/* Room for the device's rings and shadow, which the frame would clip. */
|
|
248
|
+
html[data-sb-embed] .stage {
|
|
249
|
+
padding: 16px;
|
|
250
|
+
}
|