@fasl-work/caos-app-shell 0.12.0 → 0.13.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.
- package/bin/caos-shell-gate.mjs +72 -72
- package/dist/chart.js +2 -2
- package/dist/{chunk-DX36XRD5.js → chunk-3QYQCWSZ.js} +1 -1
- package/dist/{chunk-X6Y5CDUD.js → chunk-YVVDBSAC.js} +5 -3
- package/dist/index.d.ts +149 -53
- package/dist/index.js +1030 -210
- package/dist/{keys-CnvqkckF.d.ts → keys-CTQZafOf.d.ts} +7 -3
- package/dist/keys.d.ts +1 -1
- package/dist/keys.js +1 -1
- package/gate/areas.mjs +631 -455
- package/gate/inpage.mjs +1270 -1228
- package/gate/run.mjs +780 -755
- package/gate/serve.mjs +101 -97
- package/package.json +1 -1
- package/reserved-classes.json +56 -18
- package/src/content/executive.schema.json +587 -69
- package/styles.css +769 -750
package/gate/serve.mjs
CHANGED
|
@@ -1,97 +1,101 @@
|
|
|
1
|
-
// A static server that answers the way GitHub Pages does, so a local gate run sees what the deployed site will:
|
|
2
|
-
// an existing file is 200; a directory without a trailing slash is a 301 to the slash; a directory with one serves its
|
|
3
|
-
// index.html; `/name` falls back to `name.html`; anything else is 404 with the site's 404.html. There is no SPA
|
|
4
|
-
// fallback, which is the point: a route that was not materialised, or an artifact missing from the build, fails here
|
|
5
|
-
// exactly as it would on Pages (failure classes 2 and 22: deep links that 404, artifacts answered with HTML).
|
|
6
|
-
|
|
7
|
-
import { createServer } from 'node:http';
|
|
8
|
-
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
9
|
-
import { extname, join, normalize, resolve, sep } from 'node:path';
|
|
10
|
-
|
|
11
|
-
const MIME = {
|
|
12
|
-
'.html': 'text/html; charset=utf-8',
|
|
13
|
-
'.js': 'text/javascript; charset=utf-8',
|
|
14
|
-
'.mjs': 'text/javascript; charset=utf-8',
|
|
15
|
-
'.css': 'text/css; charset=utf-8',
|
|
16
|
-
'.json': 'application/json; charset=utf-8',
|
|
17
|
-
'.geojson': 'application/geo+json',
|
|
18
|
-
'.svg': 'image/svg+xml',
|
|
19
|
-
'.png': 'image/png',
|
|
20
|
-
'.jpg': 'image/jpeg',
|
|
21
|
-
'.jpeg': 'image/jpeg',
|
|
22
|
-
'.webp': 'image/webp',
|
|
23
|
-
'.gif': 'image/gif',
|
|
24
|
-
'.ico': 'image/x-icon',
|
|
25
|
-
'.woff': 'font/woff',
|
|
26
|
-
'.woff2': 'font/woff2',
|
|
27
|
-
'.ttf': 'font/ttf',
|
|
28
|
-
'.txt': 'text/plain; charset=utf-8',
|
|
29
|
-
'.csv': 'text/csv; charset=utf-8',
|
|
30
|
-
'.map': 'application/json',
|
|
31
|
-
'.wasm': 'application/wasm',
|
|
32
|
-
'.webmanifest': 'application/manifest+json',
|
|
33
|
-
'.xml': 'application/xml',
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @param {string} dir the built site
|
|
38
|
-
* @param {string} basePath the site's base path ('/' for a custom domain, '/Repo/' for a project page)
|
|
39
|
-
* @param {number} port 0 for any free port (the gate), or a fixed one (a product's preview)
|
|
40
|
-
* @returns {Promise<{ url: string, close: () => Promise<void> }>}
|
|
41
|
-
*/
|
|
42
|
-
export function servePages(dir, basePath = '/', port = 0) {
|
|
43
|
-
const root = resolve(dir);
|
|
44
|
-
const base = basePath.endsWith('/') ? basePath : `${basePath}/`;
|
|
45
|
-
const notFound = join(root, '404.html');
|
|
46
|
-
const server = createServer((req, res) => {
|
|
47
|
-
const send = (status, file, headers = {}) => {
|
|
48
|
-
res.writeHead(status, { 'Content-Type': MIME[extname(file).toLowerCase()] ?? 'application/octet-stream', 'Cache-Control': 'no-store', ...headers });
|
|
49
|
-
res.end(req.method === 'HEAD' ? undefined : readFileSync(file));
|
|
50
|
-
};
|
|
51
|
-
const missing = () => {
|
|
52
|
-
if (existsSync(notFound)) send(404, notFound);
|
|
53
|
-
else {
|
|
54
|
-
res.writeHead(404, { 'Content-Type': 'text/plain' });
|
|
55
|
-
res.end('404');
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
let path;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
1
|
+
// A static server that answers the way GitHub Pages does, so a local gate run sees what the deployed site will:
|
|
2
|
+
// an existing file is 200; a directory without a trailing slash is a 301 to the slash; a directory with one serves its
|
|
3
|
+
// index.html; `/name` falls back to `name.html`; anything else is 404 with the site's 404.html. There is no SPA
|
|
4
|
+
// fallback, which is the point: a route that was not materialised, or an artifact missing from the build, fails here
|
|
5
|
+
// exactly as it would on Pages (failure classes 2 and 22: deep links that 404, artifacts answered with HTML).
|
|
6
|
+
|
|
7
|
+
import { createServer } from 'node:http';
|
|
8
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
9
|
+
import { extname, join, normalize, resolve, sep } from 'node:path';
|
|
10
|
+
|
|
11
|
+
const MIME = {
|
|
12
|
+
'.html': 'text/html; charset=utf-8',
|
|
13
|
+
'.js': 'text/javascript; charset=utf-8',
|
|
14
|
+
'.mjs': 'text/javascript; charset=utf-8',
|
|
15
|
+
'.css': 'text/css; charset=utf-8',
|
|
16
|
+
'.json': 'application/json; charset=utf-8',
|
|
17
|
+
'.geojson': 'application/geo+json',
|
|
18
|
+
'.svg': 'image/svg+xml',
|
|
19
|
+
'.png': 'image/png',
|
|
20
|
+
'.jpg': 'image/jpeg',
|
|
21
|
+
'.jpeg': 'image/jpeg',
|
|
22
|
+
'.webp': 'image/webp',
|
|
23
|
+
'.gif': 'image/gif',
|
|
24
|
+
'.ico': 'image/x-icon',
|
|
25
|
+
'.woff': 'font/woff',
|
|
26
|
+
'.woff2': 'font/woff2',
|
|
27
|
+
'.ttf': 'font/ttf',
|
|
28
|
+
'.txt': 'text/plain; charset=utf-8',
|
|
29
|
+
'.csv': 'text/csv; charset=utf-8',
|
|
30
|
+
'.map': 'application/json',
|
|
31
|
+
'.wasm': 'application/wasm',
|
|
32
|
+
'.webmanifest': 'application/manifest+json',
|
|
33
|
+
'.xml': 'application/xml',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param {string} dir the built site
|
|
38
|
+
* @param {string} basePath the site's base path ('/' for a custom domain, '/Repo/' for a project page)
|
|
39
|
+
* @param {number} port 0 for any free port (the gate), or a fixed one (a product's preview)
|
|
40
|
+
* @returns {Promise<{ url: string, close: () => Promise<void> }>}
|
|
41
|
+
*/
|
|
42
|
+
export function servePages(dir, basePath = '/', port = 0) {
|
|
43
|
+
const root = resolve(dir);
|
|
44
|
+
const base = basePath.endsWith('/') ? basePath : `${basePath}/`;
|
|
45
|
+
const notFound = join(root, '404.html');
|
|
46
|
+
const server = createServer((req, res) => {
|
|
47
|
+
const send = (status, file, headers = {}) => {
|
|
48
|
+
res.writeHead(status, { 'Content-Type': MIME[extname(file).toLowerCase()] ?? 'application/octet-stream', 'Cache-Control': 'no-store', ...headers });
|
|
49
|
+
res.end(req.method === 'HEAD' ? undefined : readFileSync(file));
|
|
50
|
+
};
|
|
51
|
+
const missing = () => {
|
|
52
|
+
if (existsSync(notFound)) send(404, notFound);
|
|
53
|
+
else {
|
|
54
|
+
res.writeHead(404, { 'Content-Type': 'text/plain' });
|
|
55
|
+
res.end('404');
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
let path;
|
|
59
|
+
let search = '';
|
|
60
|
+
try {
|
|
61
|
+
const u = new URL(req.url ?? '/', 'http://x');
|
|
62
|
+
path = decodeURIComponent(u.pathname);
|
|
63
|
+
search = u.search;
|
|
64
|
+
} catch {
|
|
65
|
+
return missing();
|
|
66
|
+
}
|
|
67
|
+
if (`${path}/` === base) {
|
|
68
|
+
res.writeHead(301, { Location: base });
|
|
69
|
+
return res.end();
|
|
70
|
+
}
|
|
71
|
+
if (!path.startsWith(base)) return missing();
|
|
72
|
+
const rel = path.slice(base.length);
|
|
73
|
+
const file = normalize(join(root, rel));
|
|
74
|
+
if (file !== root && !file.startsWith(root + sep)) return missing();
|
|
75
|
+
if (existsSync(file)) {
|
|
76
|
+
const st = statSync(file);
|
|
77
|
+
if (st.isFile()) return send(200, file);
|
|
78
|
+
if (st.isDirectory()) {
|
|
79
|
+
const index = join(file, 'index.html');
|
|
80
|
+
if (!existsSync(index)) return missing();
|
|
81
|
+
if (!path.endsWith('/')) {
|
|
82
|
+
// the query string survives the redirect, as a Pages host keeps it (an old link /app?case=B2 must reach its case)
|
|
83
|
+
res.writeHead(301, { Location: `${path}/${search}` });
|
|
84
|
+
return res.end();
|
|
85
|
+
}
|
|
86
|
+
return send(200, index);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (!path.endsWith('/') && existsSync(`${file}.html`)) return send(200, `${file}.html`);
|
|
90
|
+
return missing();
|
|
91
|
+
});
|
|
92
|
+
return new Promise((ok) => {
|
|
93
|
+
server.listen(port, '127.0.0.1', () => {
|
|
94
|
+
const { port } = server.address();
|
|
95
|
+
ok({
|
|
96
|
+
url: `http://127.0.0.1:${port}${base}`,
|
|
97
|
+
close: () => new Promise((done) => server.close(() => done())),
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fasl-work/caos-app-shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Shared web-app shell, workbench primitives, content primitives, design system and measured gate for the CAOS / Faena public apps (ADR-0016, ADR-0017, ADR-0071).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Felipe Santibáñez-Leal",
|
package/reserved-classes.json
CHANGED
|
@@ -39,29 +39,48 @@
|
|
|
39
39
|
"caos-doc-references",
|
|
40
40
|
"caos-doc-section",
|
|
41
41
|
"caos-exec",
|
|
42
|
+
"caos-exec-actions",
|
|
42
43
|
"caos-exec-art",
|
|
43
44
|
"caos-exec-art-wait",
|
|
45
|
+
"caos-exec-badge",
|
|
46
|
+
"caos-exec-badges",
|
|
47
|
+
"caos-exec-bar",
|
|
48
|
+
"caos-exec-card",
|
|
49
|
+
"caos-exec-cards",
|
|
50
|
+
"caos-exec-cause",
|
|
51
|
+
"caos-exec-cause-head",
|
|
52
|
+
"caos-exec-causes",
|
|
53
|
+
"caos-exec-cdef",
|
|
44
54
|
"caos-exec-cite",
|
|
45
55
|
"caos-exec-cs",
|
|
46
56
|
"caos-exec-error",
|
|
47
|
-
"caos-exec-
|
|
57
|
+
"caos-exec-evidence",
|
|
48
58
|
"caos-exec-fig",
|
|
49
59
|
"caos-exec-fig-error",
|
|
50
|
-
"caos-exec-
|
|
60
|
+
"caos-exec-figure",
|
|
61
|
+
"caos-exec-figures",
|
|
62
|
+
"caos-exec-handoff",
|
|
63
|
+
"caos-exec-headline",
|
|
64
|
+
"caos-exec-interaction",
|
|
65
|
+
"caos-exec-key",
|
|
51
66
|
"caos-exec-label",
|
|
67
|
+
"caos-exec-landing",
|
|
68
|
+
"caos-exec-link",
|
|
69
|
+
"caos-exec-links",
|
|
70
|
+
"caos-exec-list",
|
|
52
71
|
"caos-exec-notes",
|
|
53
72
|
"caos-exec-notes-title",
|
|
54
73
|
"caos-exec-notes-wrap",
|
|
55
|
-
"caos-exec-
|
|
56
|
-
"caos-exec-outcomes",
|
|
57
|
-
"caos-exec-pending",
|
|
58
|
-
"caos-exec-proof",
|
|
59
|
-
"caos-exec-question",
|
|
74
|
+
"caos-exec-paragraph",
|
|
60
75
|
"caos-exec-section",
|
|
61
76
|
"caos-exec-sep",
|
|
77
|
+
"caos-exec-setting",
|
|
78
|
+
"caos-exec-statement",
|
|
79
|
+
"caos-exec-status",
|
|
80
|
+
"caos-exec-sub",
|
|
81
|
+
"caos-exec-tabs",
|
|
82
|
+
"caos-exec-title",
|
|
62
83
|
"caos-exec-value",
|
|
63
|
-
"caos-exec-vision",
|
|
64
|
-
"caos-exec-whynow",
|
|
65
84
|
"caos-field",
|
|
66
85
|
"caos-focus-actions",
|
|
67
86
|
"caos-focus-hud",
|
|
@@ -305,29 +324,48 @@
|
|
|
305
324
|
"caos-doc-references",
|
|
306
325
|
"caos-doc-section",
|
|
307
326
|
"caos-exec",
|
|
327
|
+
"caos-exec-actions",
|
|
308
328
|
"caos-exec-art",
|
|
309
329
|
"caos-exec-art-wait",
|
|
330
|
+
"caos-exec-badge",
|
|
331
|
+
"caos-exec-badges",
|
|
332
|
+
"caos-exec-bar",
|
|
333
|
+
"caos-exec-card",
|
|
334
|
+
"caos-exec-cards",
|
|
335
|
+
"caos-exec-cause",
|
|
336
|
+
"caos-exec-cause-head",
|
|
337
|
+
"caos-exec-causes",
|
|
338
|
+
"caos-exec-cdef",
|
|
310
339
|
"caos-exec-cite",
|
|
311
340
|
"caos-exec-cs",
|
|
312
341
|
"caos-exec-error",
|
|
313
|
-
"caos-exec-
|
|
342
|
+
"caos-exec-evidence",
|
|
314
343
|
"caos-exec-fig",
|
|
315
344
|
"caos-exec-fig-error",
|
|
316
|
-
"caos-exec-
|
|
345
|
+
"caos-exec-figure",
|
|
346
|
+
"caos-exec-figures",
|
|
347
|
+
"caos-exec-handoff",
|
|
348
|
+
"caos-exec-headline",
|
|
349
|
+
"caos-exec-interaction",
|
|
350
|
+
"caos-exec-key",
|
|
317
351
|
"caos-exec-label",
|
|
352
|
+
"caos-exec-landing",
|
|
353
|
+
"caos-exec-link",
|
|
354
|
+
"caos-exec-links",
|
|
355
|
+
"caos-exec-list",
|
|
318
356
|
"caos-exec-notes",
|
|
319
357
|
"caos-exec-notes-title",
|
|
320
358
|
"caos-exec-notes-wrap",
|
|
321
|
-
"caos-exec-
|
|
322
|
-
"caos-exec-outcomes",
|
|
323
|
-
"caos-exec-pending",
|
|
324
|
-
"caos-exec-proof",
|
|
325
|
-
"caos-exec-question",
|
|
359
|
+
"caos-exec-paragraph",
|
|
326
360
|
"caos-exec-section",
|
|
327
361
|
"caos-exec-sep",
|
|
362
|
+
"caos-exec-setting",
|
|
363
|
+
"caos-exec-statement",
|
|
364
|
+
"caos-exec-status",
|
|
365
|
+
"caos-exec-sub",
|
|
366
|
+
"caos-exec-tabs",
|
|
367
|
+
"caos-exec-title",
|
|
328
368
|
"caos-exec-value",
|
|
329
|
-
"caos-exec-vision",
|
|
330
|
-
"caos-exec-whynow",
|
|
331
369
|
"caos-field",
|
|
332
370
|
"caos-focus-actions",
|
|
333
371
|
"caos-focus-hud",
|