@swiftbrowser/web 0.1.0

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.
Files changed (84) hide show
  1. package/README.md +600 -0
  2. package/app/index.html +125 -0
  3. package/index.html +56 -0
  4. package/node/dist/node/apps.d.ts +58 -0
  5. package/node/dist/node/apps.d.ts.map +1 -0
  6. package/node/dist/node/apps.js +60 -0
  7. package/node/dist/node/apps.js.map +1 -0
  8. package/node/dist/node/config.d.ts +42 -0
  9. package/node/dist/node/config.d.ts.map +1 -0
  10. package/node/dist/node/config.js +99 -0
  11. package/node/dist/node/config.js.map +1 -0
  12. package/node/dist/node/examples.d.ts +39 -0
  13. package/node/dist/node/examples.d.ts.map +1 -0
  14. package/node/dist/node/examples.js +116 -0
  15. package/node/dist/node/examples.js.map +1 -0
  16. package/node/dist/node/index.d.ts +47 -0
  17. package/node/dist/node/index.d.ts.map +1 -0
  18. package/node/dist/node/index.js +52 -0
  19. package/node/dist/node/index.js.map +1 -0
  20. package/node/dist/plugins/app-manifests.d.ts +61 -0
  21. package/node/dist/plugins/app-manifests.d.ts.map +1 -0
  22. package/node/dist/plugins/app-manifests.js +168 -0
  23. package/node/dist/plugins/app-manifests.js.map +1 -0
  24. package/node/dist/plugins/asset-catalogs.d.ts +119 -0
  25. package/node/dist/plugins/asset-catalogs.d.ts.map +1 -0
  26. package/node/dist/plugins/asset-catalogs.js +488 -0
  27. package/node/dist/plugins/asset-catalogs.js.map +1 -0
  28. package/node/dist/plugins/bundle-resources.d.ts +49 -0
  29. package/node/dist/plugins/bundle-resources.d.ts.map +1 -0
  30. package/node/dist/plugins/bundle-resources.js +172 -0
  31. package/node/dist/plugins/bundle-resources.js.map +1 -0
  32. package/node/dist/plugins/swift-wasm.d.ts +33 -0
  33. package/node/dist/plugins/swift-wasm.d.ts.map +1 -0
  34. package/node/dist/plugins/swift-wasm.js +241 -0
  35. package/node/dist/plugins/swift-wasm.js.map +1 -0
  36. package/node/dist/src/assets.d.ts +60 -0
  37. package/node/dist/src/assets.d.ts.map +1 -0
  38. package/node/dist/src/assets.js +54 -0
  39. package/node/dist/src/assets.js.map +1 -0
  40. package/node/dist/src/devEvents.d.ts +31 -0
  41. package/node/dist/src/devEvents.d.ts.map +1 -0
  42. package/node/dist/src/devEvents.js +9 -0
  43. package/node/dist/src/devEvents.js.map +1 -0
  44. package/package.json +56 -0
  45. package/plugins/app-manifests.ts +192 -0
  46. package/plugins/asset-catalogs.ts +558 -0
  47. package/plugins/bundle-resources.ts +195 -0
  48. package/plugins/swift-wasm.ts +259 -0
  49. package/public/_headers +23 -0
  50. package/public/apple-touch-icon.png +0 -0
  51. package/public/icon.svg +14 -0
  52. package/public/manifest.webmanifest +14 -0
  53. package/src/animation.ts +521 -0
  54. package/src/assets.ts +86 -0
  55. package/src/chartDom.ts +481 -0
  56. package/src/devEvents.ts +35 -0
  57. package/src/deviceMode.ts +80 -0
  58. package/src/ghost.ts +25 -0
  59. package/src/interaction.ts +1113 -0
  60. package/src/landing.css +261 -0
  61. package/src/landing.ts +141 -0
  62. package/src/layout/chart.ts +477 -0
  63. package/src/layout/controls.ts +116 -0
  64. package/src/layout/engine.ts +3581 -0
  65. package/src/layout/index.ts +91 -0
  66. package/src/layout/measure.ts +86 -0
  67. package/src/layout/text.ts +124 -0
  68. package/src/layout/types.ts +153 -0
  69. package/src/layout/typography.ts +188 -0
  70. package/src/layoutDom.ts +549 -0
  71. package/src/layoutEvents.ts +110 -0
  72. package/src/locale.ts +64 -0
  73. package/src/main.ts +554 -0
  74. package/src/mock.ts +752 -0
  75. package/src/nodeQueries.ts +60 -0
  76. package/src/protocol.ts +1421 -0
  77. package/src/renderer.ts +2882 -0
  78. package/src/styles.css +2834 -0
  79. package/src/styles.ts +373 -0
  80. package/src/swipe.ts +110 -0
  81. package/src/symbols.ts +595 -0
  82. package/src/typography.ts +76 -0
  83. package/src/vite-env.d.ts +26 -0
  84. package/src/wasm.ts +400 -0
@@ -0,0 +1,488 @@
1
+ /**
2
+ * Serves every registered app's Xcode asset catalogs (the `*.xcassets`
3
+ * directories of its `AppSpec`) as one JSON manifest at `/catalog/<App>.json`
4
+ * plus the image files at `/catalog/<App>/<name>.<ext>` (dev server and
5
+ * `vite build`).
6
+ *
7
+ * The Swift side refers to catalog images and colors by name only
8
+ * (`Image("dough/plain-full")`, `Color("dough/plain-bg")`). The page fetches
9
+ * the manifest before loading the app (src/main.ts) so the layout engine
10
+ * knows every image's intrinsic size and the renderer can resolve the URL and
11
+ * the light/dark color values. See `AssetCatalog` in src/assets.ts.
12
+ *
13
+ * Catalog rules implemented here:
14
+ * - a folder whose `Contents.json` has `properties.provides-namespace: true`
15
+ * prefixes everything inside with `<folder>/` (nested folders chain);
16
+ * - `<name>.imageset`: the `2x` entry is preferred (then `1x`, `3x`, then the
17
+ * first entry with a file); points = pixels ÷ scale;
18
+ * - `<name>.symbolset`: an SVG drawn as a template (`kind: "symbol"`);
19
+ * - `<name>.colorset`: the entry without appearances is `light`, the one with
20
+ * `luminosity: dark` is `dark`; idiom and contrast variants are ignored.
21
+ */
22
+ import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
23
+ import path from 'node:path';
24
+ import { APP_NAME } from '../node/apps.js';
25
+ import { CATALOG_DIR, assetFileName, assetFilePath, } from '../src/assets.js';
26
+ export { CATALOG_DIR, catalogPath, assetFilePath } from '../src/assets.js';
27
+ const CONTENT_TYPES = {
28
+ png: 'image/png',
29
+ jpg: 'image/jpeg',
30
+ jpeg: 'image/jpeg',
31
+ webp: 'image/webp',
32
+ svg: 'image/svg+xml',
33
+ };
34
+ function readJson(file) {
35
+ try {
36
+ return JSON.parse(readFileSync(file, 'utf8'));
37
+ }
38
+ catch {
39
+ return null;
40
+ }
41
+ }
42
+ // ---------------------------------------------------------------------------
43
+ // Color components
44
+ // ---------------------------------------------------------------------------
45
+ /**
46
+ * One colorset component as a 0...1 value. Xcode writes hex (`"0xC2"`),
47
+ * floats (`"0.439"`, `"1.000"`) or 0...255 integers (`"255"`). A bare `"0"`
48
+ * or `"1"` has no decimal point but is taken as 0 / 1 (full), as Xcode never
49
+ * writes 1/255 that way.
50
+ */
51
+ export function parseComponent(value, fallback = 1) {
52
+ if (typeof value !== 'string')
53
+ return fallback;
54
+ const text = value.trim();
55
+ if (/^0x[0-9a-f]+$/i.test(text))
56
+ return clamp01(parseInt(text.slice(2), 16) / 255);
57
+ if (/^-?\d+$/.test(text)) {
58
+ const n = parseInt(text, 10);
59
+ return clamp01(n > 1 ? n / 255 : n);
60
+ }
61
+ const n = Number(text);
62
+ return Number.isFinite(n) ? clamp01(n) : fallback;
63
+ }
64
+ function clamp01(v) {
65
+ return Math.min(1, Math.max(0, v));
66
+ }
67
+ /** CSS `rgba(r, g, b, a)` for colorset components (r/g/b 0...255, a 0...1). */
68
+ export function componentsToCSS(components) {
69
+ const channel = (v) => Math.round(parseComponent(v, 0) * 255);
70
+ const alpha = Math.round(parseComponent(components.alpha, 1) * 1000) / 1000;
71
+ return `rgba(${channel(components.red)}, ${channel(components.green)}, ${channel(components.blue)}, ${alpha})`;
72
+ }
73
+ /** The `light` / `dark` CSS colors of a colorset, or null when it has no usable entry. */
74
+ export function parseColorSet(contents) {
75
+ let light;
76
+ let dark;
77
+ for (const entry of contents.colors ?? []) {
78
+ const components = entry.color?.components;
79
+ if (!components)
80
+ continue;
81
+ const appearances = entry.appearances ?? [];
82
+ // Contrast ("high") variants are not rendered; skip entries that carry one.
83
+ if (appearances.some((a) => a.appearance === 'contrast'))
84
+ continue;
85
+ const luminosity = appearances.find((a) => a.appearance === 'luminosity')?.value;
86
+ const css = componentsToCSS(components);
87
+ if (luminosity === 'dark')
88
+ dark ??= css;
89
+ else if (luminosity === undefined)
90
+ light ??= css;
91
+ }
92
+ if (light === undefined) {
93
+ if (dark === undefined)
94
+ return null;
95
+ light = dark;
96
+ }
97
+ return dark === undefined ? { light } : { light, dark };
98
+ }
99
+ /**
100
+ * Pixel size of a PNG (IHDR), JPEG (the first SOF segment), WebP (VP8,
101
+ * VP8L or VP8X chunk) or SVG (`width`/`height` attributes, else `viewBox`);
102
+ * null for anything else.
103
+ */
104
+ export function readImageSize(data, ext) {
105
+ switch (ext.toLowerCase()) {
106
+ case 'png':
107
+ return pngSize(data);
108
+ case 'jpg':
109
+ case 'jpeg':
110
+ return jpegSize(data);
111
+ case 'webp':
112
+ return webpSize(data);
113
+ case 'svg':
114
+ return svgSize(data.toString('utf8'));
115
+ default:
116
+ return null;
117
+ }
118
+ }
119
+ const PNG_SIGNATURE = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
120
+ function pngSize(data) {
121
+ if (data.length < 24 || !data.subarray(0, 8).equals(PNG_SIGNATURE))
122
+ return null;
123
+ if (data.toString('latin1', 12, 16) !== 'IHDR')
124
+ return null;
125
+ return { width: data.readUInt32BE(16), height: data.readUInt32BE(20) };
126
+ }
127
+ /** RIFF/WEBP: the first chunk is VP8 (lossy), VP8L (lossless) or VP8X (extended). */
128
+ function webpSize(data) {
129
+ if (data.length < 30 || data.toString('latin1', 0, 4) !== 'RIFF' || data.toString('latin1', 8, 12) !== 'WEBP')
130
+ return null;
131
+ const chunk = data.toString('latin1', 12, 16);
132
+ if (chunk === 'VP8X') {
133
+ // 24-bit little-endian canvas width/height minus one at bytes 24 and 27.
134
+ const width = 1 + (data[24] | (data[25] << 8) | (data[26] << 16));
135
+ const height = 1 + (data[27] | (data[28] << 8) | (data[29] << 16));
136
+ return { width, height };
137
+ }
138
+ if (chunk === 'VP8L') {
139
+ if (data[20] !== 0x2f)
140
+ return null;
141
+ const bits = data.readUInt32LE(21);
142
+ return { width: 1 + (bits & 0x3fff), height: 1 + ((bits >>> 14) & 0x3fff) };
143
+ }
144
+ if (chunk === 'VP8 ') {
145
+ // Key frame: 3-byte frame tag, start code 9d 01 2a, then 14-bit width and height.
146
+ if (data[23] !== 0x9d || data[24] !== 0x01 || data[25] !== 0x2a)
147
+ return null;
148
+ return { width: data.readUInt16LE(26) & 0x3fff, height: data.readUInt16LE(28) & 0x3fff };
149
+ }
150
+ return null;
151
+ }
152
+ function jpegSize(data) {
153
+ if (data.length < 4 || data[0] !== 0xff || data[1] !== 0xd8)
154
+ return null;
155
+ let offset = 2;
156
+ while (offset + 9 <= data.length) {
157
+ if (data[offset] !== 0xff)
158
+ return null;
159
+ const marker = data[offset + 1];
160
+ if (marker === 0xff) {
161
+ offset += 1; // padding
162
+ continue;
163
+ }
164
+ if (marker === 0xd8 || (marker >= 0xd0 && marker <= 0xd7) || marker === 0x01) {
165
+ offset += 2; // standalone markers without a length
166
+ continue;
167
+ }
168
+ const length = data.readUInt16BE(offset + 2);
169
+ // SOF0...SOF15 except DHT (C4), JPG (C8) and DAC (CC) hold the frame size.
170
+ const isSOF = marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc;
171
+ if (isSOF) {
172
+ return { height: data.readUInt16BE(offset + 5), width: data.readUInt16BE(offset + 7) };
173
+ }
174
+ if (marker === 0xda || marker === 0xd9)
175
+ return null; // scan data / end: no SOF found
176
+ offset += 2 + length;
177
+ }
178
+ return null;
179
+ }
180
+ /** A CSS length from an SVG attribute, in px (pt is 4/3 px; other units are taken as px). */
181
+ function svgLength(value) {
182
+ if (!value)
183
+ return null;
184
+ const match = /^\s*([0-9]*\.?[0-9]+)\s*([a-z%]*)\s*$/i.exec(value);
185
+ if (!match)
186
+ return null;
187
+ const n = Number(match[1]);
188
+ if (!Number.isFinite(n) || n <= 0)
189
+ return null;
190
+ if (match[2] === '%')
191
+ return null;
192
+ return match[2]?.toLowerCase() === 'pt' ? (n * 4) / 3 : n;
193
+ }
194
+ function svgSize(text) {
195
+ const open = /<svg\b[^>]*>/i.exec(text);
196
+ if (!open)
197
+ return null;
198
+ const tag = open[0];
199
+ const attr = (name) => new RegExp(`\\s${name}\\s*=\\s*["']([^"']*)["']`, 'i').exec(tag)?.[1];
200
+ const width = svgLength(attr('width'));
201
+ const height = svgLength(attr('height'));
202
+ if (width !== null && height !== null)
203
+ return { width, height };
204
+ const viewBox = attr('viewBox');
205
+ if (viewBox) {
206
+ const parts = viewBox.trim().split(/[\s,]+/).map(Number);
207
+ const vw = parts[2];
208
+ const vh = parts[3];
209
+ if (parts.length === 4 && vw !== undefined && vh !== undefined && vw > 0 && vh > 0) {
210
+ // One explicit dimension with a viewBox: derive the other from the aspect ratio.
211
+ if (width !== null)
212
+ return { width, height: (width * vh) / vw };
213
+ if (height !== null)
214
+ return { width: (height * vw) / vh, height };
215
+ return { width: vw, height: vh };
216
+ }
217
+ }
218
+ return null;
219
+ }
220
+ // ---------------------------------------------------------------------------
221
+ // Catalog scanning
222
+ // ---------------------------------------------------------------------------
223
+ const SCALE_PREFERENCE = ['2x', '1x', '3x'];
224
+ /** The image entry to publish for an imageset, with its numeric scale. */
225
+ export function pickImage(contents) {
226
+ const images = (contents.images ?? []).filter((image) => typeof image.filename === 'string');
227
+ for (const scale of SCALE_PREFERENCE) {
228
+ const match = images.find((image) => image.scale === scale);
229
+ if (match)
230
+ return { filename: match.filename, scale: parseInt(scale, 10) };
231
+ }
232
+ const first = images[0];
233
+ if (!first)
234
+ return null;
235
+ const scale = first.scale ? parseInt(first.scale, 10) : 1;
236
+ return { filename: first.filename, scale: Number.isFinite(scale) && scale > 0 ? scale : 1 };
237
+ }
238
+ function extensionOf(file) {
239
+ return path.extname(file).slice(1).toLowerCase();
240
+ }
241
+ function addFile(scan, name, source, relativeToCatalog) {
242
+ const ext = extensionOf(source);
243
+ const contentType = CONTENT_TYPES[ext];
244
+ if (!contentType) {
245
+ scan.warnings.push(`${relativeToCatalog}: unsupported image type .${ext}, skipped`);
246
+ return null;
247
+ }
248
+ const fileName = `${CATALOG_DIR}/${scan.app}/${assetFileName(name, ext)}`;
249
+ scan.files.set(fileName, { fileName, source, contentType });
250
+ return { src: assetFilePath(scan.app, name, ext), width: 0, height: 0, scale: 1, kind: 'image' };
251
+ }
252
+ function scanImageSet(scan, dir, name, label) {
253
+ const contents = readJson(path.join(dir, 'Contents.json'));
254
+ const picked = contents ? pickImage(contents) : null;
255
+ if (!picked) {
256
+ scan.warnings.push(`${label}: no image file listed in Contents.json, skipped`);
257
+ return;
258
+ }
259
+ const source = path.join(dir, picked.filename);
260
+ if (!existsSync(source)) {
261
+ scan.warnings.push(`${label}: ${picked.filename} is missing, skipped`);
262
+ return;
263
+ }
264
+ const entry = addFile(scan, name, source, label);
265
+ if (!entry)
266
+ return;
267
+ const size = readImageSize(readFileSync(source), extensionOf(source));
268
+ if (!size) {
269
+ scan.warnings.push(`${label}: could not read the size of ${picked.filename}, skipped`);
270
+ scan.files.delete(`${CATALOG_DIR}/${scan.app}/${assetFileName(name, extensionOf(source))}`);
271
+ return;
272
+ }
273
+ entry.width = size.width / picked.scale;
274
+ entry.height = size.height / picked.scale;
275
+ entry.scale = picked.scale;
276
+ scan.manifest.images[name] = entry;
277
+ }
278
+ function scanSymbolSet(scan, dir, name, label) {
279
+ const contents = readJson(path.join(dir, 'Contents.json'));
280
+ const filename = contents?.symbols?.find((s) => typeof s.filename === 'string')?.filename;
281
+ if (!filename) {
282
+ scan.warnings.push(`${label}: no symbol file listed in Contents.json, skipped`);
283
+ return;
284
+ }
285
+ const source = path.join(dir, filename);
286
+ if (!existsSync(source)) {
287
+ scan.warnings.push(`${label}: ${filename} is missing, skipped`);
288
+ return;
289
+ }
290
+ if (extensionOf(source) !== 'svg') {
291
+ scan.warnings.push(`${label}: a symbolset must hold an SVG, skipped`);
292
+ return;
293
+ }
294
+ const entry = addFile(scan, name, source, label);
295
+ if (!entry)
296
+ return;
297
+ entry.kind = 'symbol';
298
+ // The layout engine sizes symbols from the font, so the size is informative only.
299
+ const size = readImageSize(readFileSync(source), 'svg');
300
+ if (size) {
301
+ entry.width = size.width;
302
+ entry.height = size.height;
303
+ }
304
+ scan.manifest.images[name] = entry;
305
+ }
306
+ function scanColorSet(scan, dir, name, label) {
307
+ const contents = readJson(path.join(dir, 'Contents.json'));
308
+ const color = contents ? parseColorSet(contents) : null;
309
+ if (!color) {
310
+ scan.warnings.push(`${label}: no color components in Contents.json, skipped`);
311
+ return;
312
+ }
313
+ scan.manifest.colors[name] = color;
314
+ }
315
+ /** Walk one directory of a catalog; `prefix` is the namespace so far (`dough/`). */
316
+ function scanDirectory(scan, dir, prefix, label) {
317
+ const entries = readdirSync(dir, { withFileTypes: true })
318
+ .filter((entry) => entry.isDirectory() && !entry.name.startsWith('.'))
319
+ .sort((a, b) => a.name.localeCompare(b.name));
320
+ for (const entry of entries) {
321
+ const full = path.join(dir, entry.name);
322
+ const ext = path.extname(entry.name);
323
+ const base = path.basename(entry.name, ext);
324
+ const name = prefix + base;
325
+ const entryLabel = `${label}/${entry.name}`;
326
+ switch (ext) {
327
+ case '.imageset':
328
+ scanImageSet(scan, full, name, entryLabel);
329
+ break;
330
+ case '.symbolset':
331
+ scanSymbolSet(scan, full, name, entryLabel);
332
+ break;
333
+ case '.colorset':
334
+ scanColorSet(scan, full, name, entryLabel);
335
+ break;
336
+ case '':
337
+ case undefined: {
338
+ // A plain folder: a namespace when its Contents.json says so.
339
+ const contents = readJson(path.join(full, 'Contents.json'));
340
+ const namespaced = contents?.properties?.['provides-namespace'] === true;
341
+ scanDirectory(scan, full, namespaced ? `${name}/` : prefix, entryLabel);
342
+ break;
343
+ }
344
+ default:
345
+ // App icons, launch images, data sets, ...: not addressable from SwiftUI views.
346
+ break;
347
+ }
348
+ }
349
+ }
350
+ /** Every `*.xcassets` directory under `dir` (recursive, skipping hidden directories). */
351
+ export function findAssetCatalogs(dir) {
352
+ if (!existsSync(dir) || !statSync(dir).isDirectory())
353
+ return [];
354
+ const found = [];
355
+ const walk = (current) => {
356
+ for (const entry of readdirSync(current, { withFileTypes: true })) {
357
+ if (!entry.isDirectory() || entry.name.startsWith('.'))
358
+ continue;
359
+ const full = path.join(current, entry.name);
360
+ if (entry.name.endsWith('.xcassets'))
361
+ found.push(full);
362
+ else if (entry.name !== 'node_modules')
363
+ walk(full);
364
+ }
365
+ };
366
+ walk(dir);
367
+ return found.sort();
368
+ }
369
+ /**
370
+ * Build the manifest of `app` from the given `.xcassets` directories (later
371
+ * catalogs do not override earlier names: the first definition wins, with a
372
+ * warning for the duplicate).
373
+ */
374
+ export function buildCatalog(app, catalogDirs) {
375
+ if (!APP_NAME.test(app))
376
+ throw new Error(`Invalid app name: ${JSON.stringify(app)}`);
377
+ const scan = { app, manifest: { images: {}, colors: {} }, files: new Map(), warnings: [] };
378
+ for (const dir of catalogDirs) {
379
+ const partial = { app, manifest: { images: {}, colors: {} }, files: new Map(), warnings: scan.warnings };
380
+ scanDirectory(partial, dir, '', path.basename(dir));
381
+ for (const [name, image] of Object.entries(partial.manifest.images)) {
382
+ if (name in scan.manifest.images) {
383
+ scan.warnings.push(`${path.basename(dir)}: image "${name}" is already defined by another catalog, skipped`);
384
+ continue;
385
+ }
386
+ scan.manifest.images[name] = image;
387
+ }
388
+ for (const [name, color] of Object.entries(partial.manifest.colors)) {
389
+ if (name in scan.manifest.colors) {
390
+ scan.warnings.push(`${path.basename(dir)}: color "${name}" is already defined by another catalog, skipped`);
391
+ continue;
392
+ }
393
+ scan.manifest.colors[name] = color;
394
+ }
395
+ for (const [fileName, file] of partial.files) {
396
+ if (!scan.files.has(fileName))
397
+ scan.files.set(fileName, file);
398
+ }
399
+ }
400
+ // Drop files whose image was skipped or shadowed.
401
+ const referenced = new Set(Object.values(scan.manifest.images).map((image) => image.src.slice(1)));
402
+ for (const fileName of Array.from(scan.files.keys())) {
403
+ if (!referenced.has(fileName))
404
+ scan.files.delete(fileName);
405
+ }
406
+ return { manifest: scan.manifest, files: scan.files, warnings: scan.warnings };
407
+ }
408
+ /** The manifest of the app at `<examplesDir>/<App>` (all catalogs under it). */
409
+ export function buildAppCatalog(examplesDir, app) {
410
+ return buildCatalog(app, findAssetCatalogs(path.join(examplesDir, app)));
411
+ }
412
+ export function catalogJson(catalog) {
413
+ return JSON.stringify(catalog, null, 2) + '\n';
414
+ }
415
+ /** The app named by a manifest request URL (`/catalog/<App>.json`), or null. */
416
+ export function catalogRequestApp(url) {
417
+ const match = new RegExp(`^/${CATALOG_DIR}/([A-Za-z0-9_-]+)\\.json(?:\\?|$)`).exec(url);
418
+ return match?.[1] ?? null;
419
+ }
420
+ /** The app and published file name of an asset file request, or null. */
421
+ export function catalogRequestFile(url) {
422
+ const match = new RegExp(`^/${CATALOG_DIR}/([A-Za-z0-9_-]+)/([A-Za-z0-9_.-]+)(?:\\?|$)`).exec(url);
423
+ if (!match?.[1] || !match[2] || match[2].startsWith('.'))
424
+ return null;
425
+ return { app: match[1], fileName: `${CATALOG_DIR}/${match[1]}/${match[2]}` };
426
+ }
427
+ export function assetCatalogs(specs) {
428
+ const byName = new Map(specs.map((spec) => [spec.name, spec]));
429
+ return {
430
+ name: 'swiftbrowser:asset-catalogs',
431
+ configureServer(server) {
432
+ const warned = new Set();
433
+ // Rebuilt on every manifest request so edits to a catalog show up on
434
+ // reload; scanning a few directories is cheap.
435
+ const build = (spec) => {
436
+ const built = buildCatalog(spec.name, spec.catalogs);
437
+ for (const warning of built.warnings) {
438
+ if (warned.has(warning))
439
+ continue;
440
+ warned.add(warning);
441
+ server.config.logger.warn(`[asset-catalogs] ${spec.name}: ${warning}`, { timestamp: true });
442
+ }
443
+ return built;
444
+ };
445
+ server.middlewares.use((req, res, next) => {
446
+ const url = req.url ?? '';
447
+ const app = catalogRequestApp(url);
448
+ if (app !== null) {
449
+ const spec = byName.get(app);
450
+ if (!spec) {
451
+ res.statusCode = 404;
452
+ res.end();
453
+ return;
454
+ }
455
+ res.setHeader('Content-Type', 'application/json');
456
+ res.setHeader('Cache-Control', 'no-cache');
457
+ res.end(catalogJson(build(spec).manifest));
458
+ return;
459
+ }
460
+ const file = catalogRequestFile(url);
461
+ if (file === null)
462
+ return next();
463
+ const spec = byName.get(file.app);
464
+ const entry = spec ? build(spec).files.get(file.fileName) : undefined;
465
+ if (!entry) {
466
+ res.statusCode = 404;
467
+ res.end();
468
+ return;
469
+ }
470
+ res.setHeader('Content-Type', entry.contentType);
471
+ res.setHeader('Cache-Control', 'no-cache');
472
+ res.end(readFileSync(entry.source));
473
+ });
474
+ },
475
+ generateBundle() {
476
+ for (const spec of specs) {
477
+ const built = buildCatalog(spec.name, spec.catalogs);
478
+ for (const warning of built.warnings)
479
+ this.warn(`${spec.name}: ${warning}`);
480
+ this.emitFile({ type: 'asset', fileName: `${CATALOG_DIR}/${spec.name}.json`, source: catalogJson(built.manifest) });
481
+ for (const file of built.files.values()) {
482
+ this.emitFile({ type: 'asset', fileName: file.fileName, source: readFileSync(file.source) });
483
+ }
484
+ }
485
+ },
486
+ };
487
+ }
488
+ //# sourceMappingURL=asset-catalogs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-catalogs.js","sourceRoot":"","sources":["../../../plugins/asset-catalogs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAgB,MAAM,iBAAiB,CAAC;AACzD,OAAO,EACL,WAAW,EACX,aAAa,EACb,aAAa,GAId,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAoB3E,MAAM,aAAa,GAA2B;IAC5C,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,eAAe;CACrB,CAAC;AA0BF,SAAS,QAAQ,CAAI,IAAY;IAC/B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAM,CAAC;IACrD,CAAC;IAAC,MAAM,CAAC;QACP,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
+ * or `resources` in swiftbrowser.json) as one manifest at `/bundle/<App>.json`
4
+ * (`{ files: [{ path, size }] }`) plus the files at `/bundle/<App>/<path>`,
5
+ * dev server and `vite build` alike. The page fetches them before loading the
6
+ * module and mounts them at `/bundle` in the WASI filesystem, where the shim's
7
+ * `Bundle.main` finds them (docs/ops-protocol.md, "Phase 11").
8
+ *
9
+ * A resource entry that is a file is published under its base name, like
10
+ * Xcode copies it; a directory keeps its name and structure (a folder
11
+ * reference). Asset catalogs are not resources here: plugins/asset-catalogs.ts
12
+ * turns them into the catalog manifest.
13
+ */
14
+ import type { Plugin } from 'vite';
15
+ import type { AppSpec } from '../node/apps.js';
16
+ export declare const BUNDLE_DIR = "bundle";
17
+ export interface BundleFile {
18
+ /** Path inside the bundle, `/`-separated (`missions.json`, `Data/notes.txt`). */
19
+ path: string;
20
+ size: number;
21
+ }
22
+ export interface BundleManifest {
23
+ files: BundleFile[];
24
+ }
25
+ /** The fields of an {@link AppSpec} this plugin reads. */
26
+ export type BundleSpec = Pick<AppSpec, 'name' | 'resources'>;
27
+ export interface BuiltBundle {
28
+ manifest: BundleManifest;
29
+ /** Published path (`bundle/App/missions.json`) → source file on disk. */
30
+ files: Map<string, string>;
31
+ warnings: string[];
32
+ }
33
+ /** URL path of an app's bundle manifest. */
34
+ export declare function bundleManifestPath(app: string): string;
35
+ /** URL path of a file inside an app's bundle. */
36
+ export declare function bundleFilePath(app: string, file: string): string;
37
+ /** Lists the resources of a spec as published paths and sources. */
38
+ export declare function buildBundle(app: string, resources: readonly string[] | undefined): BuiltBundle;
39
+ export declare function bundleManifestJson(manifest: BundleManifest): string;
40
+ /** The app named by a manifest request URL (`/bundle/<App>.json`), or null. */
41
+ export declare function bundleRequestApp(url: string): string | null;
42
+ /** The app and published path of a resource request (`/bundle/<App>/<path>`), or null. */
43
+ export declare function bundleRequestFile(url: string): {
44
+ app: string;
45
+ fileName: string;
46
+ } | null;
47
+ export declare function bundleContentType(file: string): string;
48
+ export declare function bundleResources(specs: readonly BundleSpec[]): Plugin;
49
+ //# sourceMappingURL=bundle-resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle-resources.d.ts","sourceRoot":"","sources":["../../../plugins/bundle-resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,eAAO,MAAM,UAAU,WAAW,CAAC;AAEnC,MAAM,WAAW,UAAU;IACzB,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,cAAc,CAAC;IACzB,yEAAyE;IACzE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAID,4CAA4C;AAC5C,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,iDAAiD;AACjD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhE;AAYD,oEAAoE;AACpE,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,WAAW,CAyB9F;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAEnE;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG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