@fasl-work/caos-app-shell 0.6.13 → 0.7.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/README.md +71 -32
- package/bin/caos-shell-gate.mjs +67 -0
- package/chart.css +19 -0
- package/dist/chart.d.ts +58 -0
- package/dist/chart.js +153 -0
- package/dist/chunk-LOSSTLPP.js +174 -0
- package/dist/chunk-X6Y5CDUD.js +16 -0
- package/dist/index.d.ts +398 -119
- package/dist/index.js +708 -184
- package/dist/keys-CnvqkckF.d.ts +135 -0
- package/dist/keys.d.ts +4 -0
- package/dist/keys.js +1 -0
- package/dist/text-BlY47nIt.d.ts +21 -0
- package/dist/tokens-CSV0MOgR.d.ts +41 -0
- package/gate/inpage.mjs +494 -0
- package/gate/png.mjs +149 -0
- package/gate/run.mjs +595 -0
- package/gate/serve.mjs +97 -0
- package/package.json +40 -7
- package/reserved-classes.json +224 -0
- package/styles.css +225 -9
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { B as BiText } from './text-BlY47nIt.js';
|
|
4
|
+
|
|
5
|
+
interface ArchTab {
|
|
6
|
+
id: string;
|
|
7
|
+
/** tab label. */
|
|
8
|
+
en: string;
|
|
9
|
+
es: string;
|
|
10
|
+
/** the explanation body (paragraphs separated by a blank line). */
|
|
11
|
+
body_en: string;
|
|
12
|
+
body_es: string;
|
|
13
|
+
/**
|
|
14
|
+
* an inline '<svg…>…</svg>' string (import it with `?raw`); a URL is refused, because an `<img>` or a fetched
|
|
15
|
+
* file cannot read the page's theme tokens and a path goes stale (S11).
|
|
16
|
+
*
|
|
17
|
+
* ONE file carries BOTH languages (ADR-0058). Tag each translatable `<text>` twice at the same
|
|
18
|
+
* coordinates, `class="… l-en"` and `class="… l-es"`; the modal wrapper sets `data-arch-lang`
|
|
19
|
+
* and the shell stylesheet shows exactly one. Two files would be two things to keep in step, and
|
|
20
|
+
* the one that is not on screen is the one that goes stale. Anything language-neutral (a number,
|
|
21
|
+
* a file name, an identifier) needs no pair.
|
|
22
|
+
*/
|
|
23
|
+
svg: string;
|
|
24
|
+
}
|
|
25
|
+
interface ArchitectureConfig {
|
|
26
|
+
/** modal title override (defaults to "Architecture / How it works"). */
|
|
27
|
+
title_en?: string;
|
|
28
|
+
title_es?: string;
|
|
29
|
+
tabs: ArchTab[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Problems with an architecture configuration, one string each (ADR-0058, ADR-0078). The diagram must be an INLINE
|
|
33
|
+
* SVG string (a fetched or `<img>` file cannot be checked against the theme tokens before it is shown, failure class
|
|
34
|
+
* 14); every `var(--x)` it names must be a shell token (an undefined token renders as nothing, silently, failure
|
|
35
|
+
* class 25); a hex colour does not follow the theme; both languages are required; at least five tabs.
|
|
36
|
+
*/
|
|
37
|
+
declare function validateArchitectureConfig(config: ArchitectureConfig): string[];
|
|
38
|
+
declare function ArchitectureModal({ config, onClose }: {
|
|
39
|
+
config: ArchitectureConfig;
|
|
40
|
+
onClose: () => void;
|
|
41
|
+
}): react.JSX.Element | null;
|
|
42
|
+
|
|
43
|
+
interface ShellRoute {
|
|
44
|
+
path: string;
|
|
45
|
+
en: string;
|
|
46
|
+
es: string;
|
|
47
|
+
}
|
|
48
|
+
interface ShellConfig {
|
|
49
|
+
/** Brand: product name + optional lucide icon element (defaults to a generic mark). */
|
|
50
|
+
product: {
|
|
51
|
+
name: string;
|
|
52
|
+
mark?: ReactNode;
|
|
53
|
+
};
|
|
54
|
+
/** Top-level routes for the header nav (use `STANDARD_ROUTES`). 0 or 1 entries hide the nav (a hub). */
|
|
55
|
+
routes?: ShellRoute[];
|
|
56
|
+
/** External links. personal/portfolio default to Felipe's canonical URLs (kept identical app-to-app). */
|
|
57
|
+
links: {
|
|
58
|
+
github: string;
|
|
59
|
+
personal?: string;
|
|
60
|
+
portfolio?: string;
|
|
61
|
+
};
|
|
62
|
+
/** Display version `X.XX.XXX`, read from the repo's VERSION (ADR-0068); a semver form is reported. */
|
|
63
|
+
version: string;
|
|
64
|
+
/** Short commit SHA of the build, printed after the version so the deployed build is identifiable. */
|
|
65
|
+
build?: string;
|
|
66
|
+
/** The product's licence as the footer shows it. Required: the shell's own licence is not inherited, and a
|
|
67
|
+
* default "MIT · open source" once appeared on private products (failure class 16). */
|
|
68
|
+
license: BiText;
|
|
69
|
+
/** Repository visibility. A private product shows no source link in the header or the footer. */
|
|
70
|
+
visibility: 'public' | 'private';
|
|
71
|
+
/** In-app Architecture / "How it works" modal (ADR-0058). When present, an info button appears in the header. */
|
|
72
|
+
architecture?: ArchitectureConfig;
|
|
73
|
+
/** Footer provenance + honesty (ADR-0016 s2): the real data/engine source with citation + licence, and the
|
|
74
|
+
* one-line honest disclaimer of how the app runs. */
|
|
75
|
+
footer?: {
|
|
76
|
+
/** Explicit product attribution, or false when the product excludes personal attribution. */
|
|
77
|
+
attribution?: {
|
|
78
|
+
en: string;
|
|
79
|
+
es: string;
|
|
80
|
+
} | false;
|
|
81
|
+
/** @deprecated use `ShellConfig.license`. */
|
|
82
|
+
license?: {
|
|
83
|
+
en: string;
|
|
84
|
+
es: string;
|
|
85
|
+
};
|
|
86
|
+
provenance?: {
|
|
87
|
+
en: string;
|
|
88
|
+
es: string;
|
|
89
|
+
};
|
|
90
|
+
disclaimer?: {
|
|
91
|
+
en: string;
|
|
92
|
+
es: string;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
/** Routes whose surface IS the viewport (ADR-0071 rule 1), matched exactly or by prefix for a non-root path. */
|
|
96
|
+
fixedRoutes?: string[];
|
|
97
|
+
/** Every route fixed: a single-surface app (a hub, a one-page tool). */
|
|
98
|
+
fixed?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Every route is the viewport (ADR-0071 rule 1, as amended 2026-10-04): the workbench (`WorkbenchLayout`) fills
|
|
101
|
+
* it, and a documentation route scrolls INSIDE the main container, so the header and footer stay in view and the
|
|
102
|
+
* document itself never scrolls. The configuration the product template uses.
|
|
103
|
+
*/
|
|
104
|
+
contain?: boolean;
|
|
105
|
+
}
|
|
106
|
+
/** The shared CAOS/Faena app shell: sticky header (brand + nav + icon-links + lang/theme) + footer.
|
|
107
|
+
* Wrap your <Routes> (or single landing) in it, inside a Router. */
|
|
108
|
+
declare function AppShell({ config, children }: {
|
|
109
|
+
config: ShellConfig;
|
|
110
|
+
children: ReactNode;
|
|
111
|
+
}): react.JSX.Element;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The six routes every CAOS product carries, in this order (ADR-0016 s3, ADR-0069 s7, the product quality bar):
|
|
115
|
+
* the App (the tool, landing) and the five documentation routes. One definition, so the header, the router and the
|
|
116
|
+
* gate read the same list and no product retypes it.
|
|
117
|
+
*/
|
|
118
|
+
declare const STANDARD_ROUTES: ShellRoute[];
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The storage keys the shell reads and writes. Exported (and built as their own entry, `dist/keys.js`) so the
|
|
122
|
+
* measured gate sets the theme and the language exactly the way the shell reads them, instead of guessing the
|
|
123
|
+
* key names (failure class 10 of the 2026-10-04 history: gates that measured the wrong mode).
|
|
124
|
+
*/
|
|
125
|
+
declare const THEME_STORAGE_KEY = "caos.theme";
|
|
126
|
+
declare const LANG_STORAGE_KEY = "caos.lang";
|
|
127
|
+
/**
|
|
128
|
+
* The pre-paint script for index.html (inline, before the bundle): applies the stored or preferred theme and the
|
|
129
|
+
* stored language before the first frame, so a light-theme user never sees a dark flash and the document language
|
|
130
|
+
* is right from the start (ADR-0011, ADR-0012). Built from the keys above, so the two cannot drift; exported from
|
|
131
|
+
* this React-free entry so a build config can inline it.
|
|
132
|
+
*/
|
|
133
|
+
declare const THEME_BOOT_SCRIPT: string;
|
|
134
|
+
|
|
135
|
+
export { AppShell as A, LANG_STORAGE_KEY as L, STANDARD_ROUTES as S, THEME_BOOT_SCRIPT as T, type ArchTab as a, type ArchitectureConfig as b, ArchitectureModal as c, type ShellConfig as d, type ShellRoute as e, THEME_STORAGE_KEY as f, validateArchitectureConfig as v };
|
package/dist/keys.d.ts
ADDED
package/dist/keys.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LANG_STORAGE_KEY, STANDARD_ROUTES, THEME_BOOT_SCRIPT, THEME_STORAGE_KEY } from './chunk-X6Y5CDUD.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as zustand from 'zustand';
|
|
2
|
+
|
|
3
|
+
type Lang = 'en' | 'es';
|
|
4
|
+
interface LangState {
|
|
5
|
+
lang: Lang;
|
|
6
|
+
setLang: (l: Lang) => void;
|
|
7
|
+
toggle: () => void;
|
|
8
|
+
}
|
|
9
|
+
declare const useLangStore: zustand.UseBoundStore<zustand.StoreApi<LangState>>;
|
|
10
|
+
/** Current language, for app pages that render language-branched long-form content. */
|
|
11
|
+
declare const useShellLang: () => Lang;
|
|
12
|
+
|
|
13
|
+
/** A string shown to users: one language-neutral string (a number, a code, a name) or both languages. */
|
|
14
|
+
type BiText = string | {
|
|
15
|
+
en: string;
|
|
16
|
+
es: string;
|
|
17
|
+
};
|
|
18
|
+
/** The text for the current language. English is the canonical fallback (ADR-0011). */
|
|
19
|
+
declare function pick(text: BiText | undefined, lang: Lang): string;
|
|
20
|
+
|
|
21
|
+
export { type BiText as B, type Lang as L, useShellLang as a, pick as p, useLangStore as u };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { L as Lang } from './text-BlY47nIt.js';
|
|
2
|
+
|
|
3
|
+
interface FormatOptions {
|
|
4
|
+
/** Significant digits for a value below 10^(digits-1) (default 4); a larger value shows every integer digit, so a
|
|
5
|
+
* count is never rounded (27345 people, not 27,350). A magnitude below 1e-4 is written in scientific notation with
|
|
6
|
+
* these significant digits (6.53E-13). Ignored when `decimals` is set. */
|
|
7
|
+
digits?: number;
|
|
8
|
+
/** Fixed number of decimals. The caller's explicit choice: a value below the last decimal reads as zero. */
|
|
9
|
+
decimals?: number;
|
|
10
|
+
/** Render a fraction as a percentage (0.123 -> 12.3 %). */
|
|
11
|
+
percent?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** "Not available" in the interface language: what an absent or non-finite value renders as. */
|
|
14
|
+
declare const NOT_AVAILABLE: Record<Lang, string>;
|
|
15
|
+
/**
|
|
16
|
+
* A number in the interface language: a decimal point in English and a decimal comma in Spanish
|
|
17
|
+
* (`conventions/languages.md`), significant digits by default, scientific notation below 1e-4. `null`, `undefined` and non-finite values render as
|
|
18
|
+
* "not available", never as `NaN` (failure classes 5 and 23 of the 2026-10-04 history).
|
|
19
|
+
*/
|
|
20
|
+
declare function formatNumber(value: number | null | undefined, lang: Lang, opts?: FormatOptions): string;
|
|
21
|
+
/** `formatNumber` bound to the current shell language. */
|
|
22
|
+
declare function useFormat(): (value: number | null | undefined, opts?: FormatOptions) => string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The colour and font tokens `styles.css` defines for both themes. The architecture-modal validation and the
|
|
26
|
+
* template's web-baseline guard check every `var(--x)` a product names against this list; a token that is not
|
|
27
|
+
* defined renders as nothing, silently (failure class 25 of the 2026-10-04 history). A unit test keeps this list
|
|
28
|
+
* equal to the stylesheet.
|
|
29
|
+
*/
|
|
30
|
+
declare const SHELL_TOKENS: readonly ["--color-bg", "--color-surface", "--color-surface-2", "--color-border", "--color-fg", "--color-fg-subtle", "--color-fg-faint", "--color-accent", "--color-accent-fg", "--color-accent-soft", "--color-accent-2", "--color-magenta", "--color-good", "--color-warn", "--color-bad", "--color-shadow", "--font-sans", "--font-mono", "--maxw", "--maxw-wide"];
|
|
31
|
+
type ShellToken = (typeof SHELL_TOKENS)[number];
|
|
32
|
+
/** The computed value of a token on the document, or `fallback` outside a browser. */
|
|
33
|
+
declare function resolveToken(token: string, fallback?: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* The colour tokens resolved to concrete values for the active theme, recomputed when the theme changes. Canvas
|
|
36
|
+
* and WebGL renderers cannot read CSS variables, so they take these (failure classes 7 and 18: charts drawn in
|
|
37
|
+
* dark-theme colours on a light page).
|
|
38
|
+
*/
|
|
39
|
+
declare function useThemeTokens(): Record<ShellToken, string>;
|
|
40
|
+
|
|
41
|
+
export { type FormatOptions as F, NOT_AVAILABLE as N, type ShellToken as S, SHELL_TOKENS as a, useThemeTokens as b, formatNumber as f, resolveToken as r, useFormat as u };
|