@fasl-work/caos-app-shell 0.11.2 → 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 +187 -3
- package/dist/index.js +1349 -43
- 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 -327
- package/gate/inpage.mjs +1270 -1142
- package/gate/run.mjs +780 -755
- package/gate/serve.mjs +101 -97
- package/package.json +4 -2
- package/reserved-classes.json +86 -0
- package/src/content/executive.schema.json +659 -0
- package/styles.css +769 -717
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",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"./styles.css": "./styles.css",
|
|
32
32
|
"./chart.css": "./chart.css",
|
|
33
33
|
"./reserved-classes.json": "./reserved-classes.json",
|
|
34
|
+
"./executive.schema.json": "./src/content/executive.schema.json",
|
|
34
35
|
"./serve": "./gate/serve.mjs",
|
|
35
36
|
"./gate": "./gate/run.mjs",
|
|
36
37
|
"./package.json": "./package.json"
|
|
@@ -41,7 +42,8 @@
|
|
|
41
42
|
"chart.css",
|
|
42
43
|
"bin",
|
|
43
44
|
"gate",
|
|
44
|
-
"reserved-classes.json"
|
|
45
|
+
"reserved-classes.json",
|
|
46
|
+
"src/content/executive.schema.json"
|
|
45
47
|
],
|
|
46
48
|
"scripts": {
|
|
47
49
|
"build": "tsup",
|
package/reserved-classes.json
CHANGED
|
@@ -38,6 +38,49 @@
|
|
|
38
38
|
"caos-doc-reference-list",
|
|
39
39
|
"caos-doc-references",
|
|
40
40
|
"caos-doc-section",
|
|
41
|
+
"caos-exec",
|
|
42
|
+
"caos-exec-actions",
|
|
43
|
+
"caos-exec-art",
|
|
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",
|
|
54
|
+
"caos-exec-cite",
|
|
55
|
+
"caos-exec-cs",
|
|
56
|
+
"caos-exec-error",
|
|
57
|
+
"caos-exec-evidence",
|
|
58
|
+
"caos-exec-fig",
|
|
59
|
+
"caos-exec-fig-error",
|
|
60
|
+
"caos-exec-figure",
|
|
61
|
+
"caos-exec-figures",
|
|
62
|
+
"caos-exec-handoff",
|
|
63
|
+
"caos-exec-headline",
|
|
64
|
+
"caos-exec-interaction",
|
|
65
|
+
"caos-exec-key",
|
|
66
|
+
"caos-exec-label",
|
|
67
|
+
"caos-exec-landing",
|
|
68
|
+
"caos-exec-link",
|
|
69
|
+
"caos-exec-links",
|
|
70
|
+
"caos-exec-list",
|
|
71
|
+
"caos-exec-notes",
|
|
72
|
+
"caos-exec-notes-title",
|
|
73
|
+
"caos-exec-notes-wrap",
|
|
74
|
+
"caos-exec-paragraph",
|
|
75
|
+
"caos-exec-section",
|
|
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",
|
|
83
|
+
"caos-exec-value",
|
|
41
84
|
"caos-field",
|
|
42
85
|
"caos-focus-actions",
|
|
43
86
|
"caos-focus-hud",
|
|
@@ -280,6 +323,49 @@
|
|
|
280
323
|
"caos-doc-reference-list",
|
|
281
324
|
"caos-doc-references",
|
|
282
325
|
"caos-doc-section",
|
|
326
|
+
"caos-exec",
|
|
327
|
+
"caos-exec-actions",
|
|
328
|
+
"caos-exec-art",
|
|
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",
|
|
339
|
+
"caos-exec-cite",
|
|
340
|
+
"caos-exec-cs",
|
|
341
|
+
"caos-exec-error",
|
|
342
|
+
"caos-exec-evidence",
|
|
343
|
+
"caos-exec-fig",
|
|
344
|
+
"caos-exec-fig-error",
|
|
345
|
+
"caos-exec-figure",
|
|
346
|
+
"caos-exec-figures",
|
|
347
|
+
"caos-exec-handoff",
|
|
348
|
+
"caos-exec-headline",
|
|
349
|
+
"caos-exec-interaction",
|
|
350
|
+
"caos-exec-key",
|
|
351
|
+
"caos-exec-label",
|
|
352
|
+
"caos-exec-landing",
|
|
353
|
+
"caos-exec-link",
|
|
354
|
+
"caos-exec-links",
|
|
355
|
+
"caos-exec-list",
|
|
356
|
+
"caos-exec-notes",
|
|
357
|
+
"caos-exec-notes-title",
|
|
358
|
+
"caos-exec-notes-wrap",
|
|
359
|
+
"caos-exec-paragraph",
|
|
360
|
+
"caos-exec-section",
|
|
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",
|
|
368
|
+
"caos-exec-value",
|
|
283
369
|
"caos-field",
|
|
284
370
|
"caos-focus-actions",
|
|
285
371
|
"caos-focus-hud",
|