@g9tm/lynxcontrols-foundation 1.4.11 → 1.6.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.
@@ -0,0 +1,116 @@
1
+ import { sameSegment } from "./address.js";
2
+ import { g9PlaceLayers } from "./sink.js";
3
+ const MAX_STEPS = 64;
4
+ function rank(p) {
5
+ return g9PlaceLayers.indexOf(p.layer);
6
+ }
7
+ function compareLivePlaces(a, b) {
8
+ return rank(a) - rank(b) || a.order - b.order || a.token - b.token;
9
+ }
10
+ function resolvePath(live, catalogue) {
11
+ if (0 === live.length) return {
12
+ segments: [],
13
+ tokens: [],
14
+ incomplete: false,
15
+ others: []
16
+ };
17
+ const sorted = live.slice().sort(compareLivePlaces);
18
+ let floor = sorted.length - 1;
19
+ const top = sorted[floor];
20
+ const segments = [
21
+ top.segment
22
+ ];
23
+ const tokens = [
24
+ top.token
25
+ ];
26
+ let kind = top.segment.kind;
27
+ let pending = top.under.slice();
28
+ let incomplete = false;
29
+ const below = (predicate)=>{
30
+ for(let i = floor - 1; i >= 0; i--)if (predicate(sorted[i])) return i;
31
+ return -1;
32
+ };
33
+ for(let step = 0; step < MAX_STEPS; step++){
34
+ if (pending.length > 0) {
35
+ const u = pending[pending.length - 1];
36
+ if (!catalogue.allowsParent(kind, u.kind)) {
37
+ pending = [];
38
+ continue;
39
+ }
40
+ pending = pending.slice(0, -1);
41
+ const same = below((p)=>sameSegment(p.segment, u));
42
+ if (same >= 0) {
43
+ const p = sorted[same];
44
+ segments.unshift(p.segment);
45
+ tokens.unshift(p.token);
46
+ floor = same;
47
+ pending = [
48
+ ...p.under,
49
+ ...pending
50
+ ];
51
+ } else {
52
+ segments.unshift(u);
53
+ tokens.unshift(null);
54
+ }
55
+ kind = u.kind;
56
+ continue;
57
+ }
58
+ const parentAt = below((p)=>catalogue.allowsParent(kind, p.segment.kind));
59
+ if (parentAt >= 0) {
60
+ const p = sorted[parentAt];
61
+ segments.unshift(p.segment);
62
+ tokens.unshift(p.token);
63
+ floor = parentAt;
64
+ kind = p.segment.kind;
65
+ pending = p.under.slice();
66
+ continue;
67
+ }
68
+ if (catalogue.allowsParent(kind, '')) break;
69
+ const made = catalogue.defaultAncestors(kind);
70
+ if (made) {
71
+ segments.unshift(...made);
72
+ tokens.unshift(...made.map(()=>null));
73
+ } else incomplete = true;
74
+ break;
75
+ }
76
+ const onPath = new Set(tokens.filter((t)=>null !== t));
77
+ const others = sorted.filter((p)=>!onPath.has(p.token)).map((p)=>p.token);
78
+ return {
79
+ segments,
80
+ tokens,
81
+ incomplete,
82
+ others
83
+ };
84
+ }
85
+ function planNavigation(target, current, live) {
86
+ let keep = 0;
87
+ const max = Math.min(target.length, current.segments.length);
88
+ while(keep < max && sameSegment(target[keep], current.segments[keep]))keep++;
89
+ while(keep > 0 && null === current.tokens[keep - 1])keep--;
90
+ const byToken = new Map(live.map((p)=>[
91
+ p.token,
92
+ p
93
+ ]));
94
+ const keptTop = keep > 0 ? byToken.get(current.tokens[keep - 1]) : void 0;
95
+ const closing = new Set();
96
+ for(let i = keep; i < current.tokens.length; i++){
97
+ var _byToken_get;
98
+ const t = current.tokens[i];
99
+ if (null != t && (null == (_byToken_get = byToken.get(t)) ? void 0 : _byToken_get.layer) !== 'root') closing.add(t);
100
+ }
101
+ for (const t of current.others){
102
+ const p = byToken.get(t);
103
+ if (p && ('sheet' === p.layer || 'popup' === p.layer)) {
104
+ if (!keptTop || compareLivePlaces(p, keptTop) > 0) closing.add(t);
105
+ }
106
+ }
107
+ const close = Array.from(closing).map((t)=>byToken.get(t)).sort((a, b)=>compareLivePlaces(b, a)).map((p)=>p.token);
108
+ return {
109
+ keep,
110
+ close,
111
+ open: target.slice(keep)
112
+ };
113
+ }
114
+ export { compareLivePlaces, planNavigation, resolvePath };
115
+
116
+ //# sourceMappingURL=resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route/resolve.js","sources":["../../src/route/resolve.ts"],"sourcesContent":["import { type G9Segment, sameSegment } from './address';\nimport type { G9Catalogue } from './catalogue';\nimport { type G9PlaceLayer, g9PlaceLayers } from './sink';\n\n// From the places that are open to the LOGICAL path (pure). The top place (highest layer, then order, then the latest\n// declaration) is the leaf; each step up takes, in this order: the declared `under` ancestors (explicit beats inferred;\n// a live place equal to one is used instead of a made-up one), the nearest open place below that the catalogue allows\n// as a parent, the root when the kind may sit there, the kind's default ancestors, or — none of these — the path ends\n// `incomplete`. Same input, same output.\n\n/** One open place as the resolver sees it. */\nexport interface G9LivePlace {\n readonly token: number;\n readonly segment: G9Segment;\n readonly layer: G9PlaceLayer;\n readonly order: number;\n readonly under: readonly G9Segment[];\n}\n\n/** The logical path and how each step is held. */\nexport interface G9ResolvedPath {\n readonly segments: readonly G9Segment[];\n /** Per segment: the open place holding it, or null when it was made up (`under`, default ancestors). */\n readonly tokens: ReadonlyArray<number | null>;\n /** The path does not reach the root: a parent was missing. */\n readonly incomplete: boolean;\n /** Open places that are not on the path. */\n readonly others: readonly number[];\n}\n\nconst MAX_STEPS = 64;\n\nfunction rank(p: G9LivePlace): number {\n return g9PlaceLayers.indexOf(p.layer);\n}\n\n/** Bottom-to-top order of open places. */\nexport function compareLivePlaces(a: G9LivePlace, b: G9LivePlace): number {\n return rank(a) - rank(b) || a.order - b.order || a.token - b.token;\n}\n\n/** The logical path of what is open. */\nexport function resolvePath(live: readonly G9LivePlace[], catalogue: G9Catalogue<unknown>): G9ResolvedPath {\n if (live.length === 0) return { segments: [], tokens: [], incomplete: false, others: [] };\n const sorted = live.slice().sort(compareLivePlaces);\n let floor = sorted.length - 1;\n const top = sorted[floor] as G9LivePlace;\n const segments: G9Segment[] = [top.segment];\n const tokens: Array<number | null> = [top.token];\n let kind = top.segment.kind;\n let pending: G9Segment[] = top.under.slice();\n let incomplete = false;\n\n const below = (predicate: (p: G9LivePlace) => boolean): number => {\n for (let i = floor - 1; i >= 0; i--) if (predicate(sorted[i] as G9LivePlace)) return i;\n return -1;\n };\n\n for (let step = 0; step < MAX_STEPS; step++) {\n if (pending.length > 0) {\n const u = pending[pending.length - 1] as G9Segment;\n if (!catalogue.allowsParent(kind, u.kind)) {\n pending = [];\n continue;\n }\n pending = pending.slice(0, -1);\n const same = below((p) => sameSegment(p.segment, u));\n if (same >= 0) {\n const p = sorted[same] as G9LivePlace;\n segments.unshift(p.segment);\n tokens.unshift(p.token);\n floor = same;\n pending = [...p.under, ...pending];\n } else {\n segments.unshift(u);\n tokens.unshift(null);\n }\n kind = u.kind;\n continue;\n }\n const parentAt = below((p) => catalogue.allowsParent(kind, p.segment.kind));\n if (parentAt >= 0) {\n const p = sorted[parentAt] as G9LivePlace;\n segments.unshift(p.segment);\n tokens.unshift(p.token);\n floor = parentAt;\n kind = p.segment.kind;\n pending = p.under.slice();\n continue;\n }\n if (catalogue.allowsParent(kind, '')) break;\n const made = catalogue.defaultAncestors(kind);\n if (made) {\n segments.unshift(...made);\n tokens.unshift(...made.map(() => null));\n } else incomplete = true;\n break;\n }\n\n const onPath = new Set(tokens.filter((t): t is number => t !== null));\n const others = sorted.filter((p) => !onPath.has(p.token)).map((p) => p.token);\n return { segments, tokens, incomplete, others };\n}\n\n/** What going to a target path changes. */\nexport interface G9NavigationPlan {\n /** How many leading segments of the target are already open (and kept). */\n readonly keep: number;\n /** Open places to close, top first. */\n readonly close: readonly number[];\n /** Segments to open, in order (the target from `keep` on). */\n readonly open: readonly G9Segment[];\n}\n\n/**\n * The plan from what is open to a target path (pure). The kept prefix must END on an open place (a made-up ancestor\n * is kept only when an open place below the divergence holds it): leaving the sampling map for its own task overview\n * closes the map mode and opens the overview, it does not keep a task that was never open. Closed: every open place of\n * the current path past the kept prefix, and every overlay (sheet, popup) above it; never a root place (opening a\n * sibling root replaces it).\n */\nexport function planNavigation(\n target: readonly G9Segment[],\n current: G9ResolvedPath,\n live: readonly G9LivePlace[],\n): G9NavigationPlan {\n let keep = 0;\n const max = Math.min(target.length, current.segments.length);\n while (keep < max && sameSegment(target[keep] as G9Segment, current.segments[keep] as G9Segment)) keep++;\n while (keep > 0 && current.tokens[keep - 1] === null) keep--;\n\n const byToken = new Map(live.map((p) => [p.token, p] as const));\n const keptTop = keep > 0 ? byToken.get(current.tokens[keep - 1] as number) : undefined;\n const closing = new Set<number>();\n for (let i = keep; i < current.tokens.length; i++) {\n const t = current.tokens[i];\n if (t !== null && t !== undefined && byToken.get(t)?.layer !== 'root') closing.add(t);\n }\n for (const t of current.others) {\n const p = byToken.get(t);\n if (!p || (p.layer !== 'sheet' && p.layer !== 'popup')) continue;\n if (!keptTop || compareLivePlaces(p, keptTop) > 0) closing.add(t);\n }\n const close = Array.from(closing)\n .map((t) => byToken.get(t) as G9LivePlace)\n .sort((a, b) => compareLivePlaces(b, a))\n .map((p) => p.token);\n return { keep, close, open: target.slice(keep) };\n}\n"],"names":["MAX_STEPS","rank","p","g9PlaceLayers","compareLivePlaces","a","b","resolvePath","live","catalogue","sorted","floor","top","segments","tokens","kind","pending","incomplete","below","predicate","i","step","u","same","sameSegment","parentAt","made","onPath","Set","t","others","planNavigation","target","current","keep","max","Math","byToken","Map","keptTop","undefined","closing","_byToken_get","close","Array"],"mappings":";;AA8BA,MAAMA,YAAY;AAElB,SAASC,KAAKC,CAAc;IAC1B,OAAOC,cAAc,OAAO,CAACD,EAAE,KAAK;AACtC;AAGO,SAASE,kBAAkBC,CAAc,EAAEC,CAAc;IAC9D,OAAOL,KAAKI,KAAKJ,KAAKK,MAAMD,EAAE,KAAK,GAAGC,EAAE,KAAK,IAAID,EAAE,KAAK,GAAGC,EAAE,KAAK;AACpE;AAGO,SAASC,YAAYC,IAA4B,EAAEC,SAA+B;IACvF,IAAID,AAAgB,MAAhBA,KAAK,MAAM,EAAQ,OAAO;QAAE,UAAU,EAAE;QAAE,QAAQ,EAAE;QAAE,YAAY;QAAO,QAAQ,EAAE;IAAC;IACxF,MAAME,SAASF,KAAK,KAAK,GAAG,IAAI,CAACJ;IACjC,IAAIO,QAAQD,OAAO,MAAM,GAAG;IAC5B,M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a,QAAQ,MAAM,CAAC,MAAM,EAAEb,IAAK;YAEZsB;QADrC,MAAMb,IAAII,QAAQ,MAAM,CAACb,EAAE;QAC3B,IAAIS,QAAAA,KAAiCa,AAAAA,SAAAA,CAAAA,eAAAA,QAAQ,GAAG,CAACb,EAAC,IAAba,KAAAA,IAAAA,aAAgB,KAAK,AAAD,MAAM,QAAQD,QAAQ,GAAG,CAACZ;IACrF;IACA,KAAK,MAAMA,KAAKI,QAAQ,MAAM,CAAE;QAC9B,MAAM/B,IAAImC,QAAQ,GAAG,CAACR;QACtB,IAAI,AAAC3B,KAAMA,CAAAA,AAAY,YAAZA,EAAE,KAAK,IAAgBA,AAAY,YAAZA,EAAE,KAAK,AAAW,GACpD;YAAA,IAAI,CAACqC,WAAWnC,kBAAkBF,GAAGqC,WAAW,GAAGE,QAAQ,GAAG,CAACZ;QAAE;IACnE;IACA,MAAMc,QAAQC,MAAM,IAAI,CAACH,SACtB,GAAG,CAAC,CAACZ,IAAMQ,QAAQ,GAAG,CAACR,IACvB,IAAI,CAAC,CAACxB,GAAGC,IAAMF,kBAAkBE,GAAGD,IACpC,GAAG,CAAC,CAACH,IAAMA,EAAE,KAAK;IACrB,OAAO;QAAEgC;QAAMS;QAAO,MAAMX,OAAO,KAAK,CAACE;IAAM;AACjD"}
@@ -0,0 +1,62 @@
1
+ import type { G9Segment } from './address.js';
2
+ /** Where a place is drawn: decides which open place is on top. Bottom to top. */
3
+ export type G9PlaceLayer = 'root' | 'page' | 'mode' | 'inner' | 'sheet' | 'popup';
4
+ /** Every layer, bottom to top. */
5
+ export declare const g9PlaceLayers: readonly G9PlaceLayer[];
6
+ /** One change a write would make, as a person reads it (the confirmation before a guided save lists these). */
7
+ export interface G9ChangeLine {
8
+ readonly action: 'create' | 'update' | 'delete' | 'send' | 'other';
9
+ /** What it is about: «گزارش مشاهده»، «بستهٔ PK-12». */
10
+ readonly subject: string;
11
+ /** For an update: which field. */
12
+ readonly field?: string;
13
+ readonly from?: string | null;
14
+ readonly to?: string | null;
15
+ /** A consequence the person must know («۱۲ نمونهٔ این بسته هم حذف می‌شود»). */
16
+ readonly note?: string;
17
+ }
18
+ /** A place that is open right now, as it declares itself. */
19
+ export interface G9PlaceDeclaration {
20
+ /** Read again on every `touch()`: a segment may carry live view parameters (search, sort). */
21
+ readonly segment: G9Segment | (() => G9Segment);
22
+ readonly layer: G9PlaceLayer;
23
+ /** Order inside the layer (the sheet stack index). Default 0. */
24
+ readonly order?: number;
25
+ /** Logical ancestors that are not open themselves, root first (a mode drawn on the map tab but living under a task). */
26
+ readonly under?: readonly G9Segment[];
27
+ /** The breadcrumb of the live place (its real title). Default: the catalogue's title. */
28
+ title?(): string | null | undefined;
29
+ /** Extra view state of this place (scroll marks are collected by the router). */
30
+ view?(): Readonly<Record<string, string>> | undefined;
31
+ applyView?(view: Readonly<Record<string, string>>): void | Promise<void>;
32
+ /** How the router leaves this place. Absent = the router cannot close it. */
33
+ close?(): void | Promise<void>;
34
+ /** Unsaved work: the router asks before closing it. */
35
+ canLeave?(): true | {
36
+ readonly dirty: true;
37
+ readonly message?: string;
38
+ };
39
+ /** What saving this place would change (the guided-save confirmation). */
40
+ describeChanges?(): readonly G9ChangeLine[];
41
+ /** Physical facts for snapshots and reports, never part of the address (the surface it is drawn on, the open site). */
42
+ facts?(): Readonly<Record<string, string | number | boolean | null>>;
43
+ /**
44
+ * False while the place is open but not on screen — the content of a background tab (a site left open on the map
45
+ * while the person is on another tab). A hidden place is not part of the location; going to it opens it again (its
46
+ * `open` brings it forward). Read on every recompute: call `touch()` when it changes. Absent = always shown.
47
+ */
48
+ shown?(): boolean;
49
+ }
50
+ /** The handle of one declaration. */
51
+ export interface G9PlaceHandle {
52
+ readonly token: number;
53
+ /** The place's own state changed (view parameters, title): the router re-reads it. */
54
+ touch(): void;
55
+ /** The place closed. Idempotent. */
56
+ remove(): void;
57
+ }
58
+ /** The router as places see it (`G9Capabilities.route`). */
59
+ export interface G9RouteSink {
60
+ declare(declaration: G9Pl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version":3,"file":"route/sink.js","sources":["../../src/route/sink.ts"],"sourcesContent":["import type { G9Segment } from './address';\n\n// What a place that is OPEN tells the router (the route sink). The sheet service, the tab view, the host and the app's\n// own places declare themselves through this small contract (`G9Capabilities.route`), so the controls depend on the\n// contract, never on the router.\n\n/** Where a place is drawn: decides which open place is on top. Bottom to top. */\nexport type G9PlaceLayer = 'root' | 'page' | 'mode' | 'inner' | 'sheet' | 'popup';\n\n/** Every layer, bottom to top. */\nexport const g9PlaceLayers: readonly G9PlaceLayer[] = Object.freeze([\n 'root',\n 'page',\n 'mode',\n 'inner',\n 'sheet',\n 'popup',\n]);\n\n/** One change a write would make, as a person reads it (the confirmation before a guided save lists these). */\nexport interface G9ChangeLine {\n readonly action: 'create' | 'update' | 'delete' | 'send' | 'other';\n /** What it is about: «گزارش مشاهده»، «بستهٔ PK-12». */\n readonly subject: string;\n /** For an update: which field. */\n readonly field?: string;\n readonly from?: string | null;\n readonly to?: string | null;\n /** A consequence the person must know («۱۲ نمونهٔ این بسته هم حذف می‌شود»). */\n readonly note?: string;\n}\n\n/** A place that is open right now, as it declares itself. */\nexport interface G9PlaceDeclaration {\n /** Read again on every `touch()`: a segment may carry live view parameters (search, sort). */\n readonly segment: G9Segment | (() => G9Segment);\n readonly layer: G9PlaceLayer;\n /** Order inside the layer (the sheet stack index). Default 0. */\n readonly order?: number;\n /** Logical ancestors that are not open themselves, root first (a mode drawn on the map tab but living under a task). */\n readonly under?: readonly G9Segment[];\n /** The breadcrumb of the live place (its real title). Default: the catalogue's title. */\n title?(): string | null | undefined;\n /** Extra view state of this place (scroll marks are collected by the router). */\n view?(): Readonly<Record<string, string>> | undefined;\n applyView?(view: Readonly<Record<string, string>>): void | Promise<void>;\n /** How the router leaves this place. Absent = the router cannot close it. */\n close?(): void | Promise<void>;\n /** Unsaved work: the router asks before closing it. */\n canLeave?(): true | { readonly dirty: true; readonly message?: string };\n /** What saving this place would change (the guided-save confirmation). */\n describeChanges?(): readonly G9ChangeLine[];\n /** Physical facts for snapshots and reports, never part of the address (the surface it is drawn on, the open site). */\n facts?(): Readonly<Record<string, string | number | boolean | null>>;\n /**\n * False while the place is open but not on screen — the content of a background tab (a site left open on the map\n * while the person is on another tab). A hidden place is not part of the location; going to it opens it again (its\n * `open` brings it forward). Read on every recompute: call `touch()` when it changes. Absent = always shown.\n */\n shown?(): boolean;\n}\n\n/** The handle of one declaration. */\nexport interface G9PlaceHandle {\n readonly token: number;\n /** The place's own state changed (view parameters, title): the router re-reads it. */\n touch(): void;\n /** The place closed. Idempotent. */\n remove(): void;\n}\n\n/** The router as places see it (`G9Capabilities.route`). */\nexport interface G9RouteSink {\n declare(declaration: G9PlaceDeclaration): G9PlaceHandle;\n}\n"],"names":["g9PlaceLayers","Object"],"mappings":"AAUO,MAAMA,gBAAyCC,OAAO,MAAM,CAAC;IAClE;IACA;IACA;IACA;IACA;IACA;CACD"}
@@ -0,0 +1,60 @@
1
+ /** What is first in view in one scroller. */
2
+ export type G9ScrollMark =
3
+ /** A list: the first visible row's item key; `offset` = share (0..1) of that row's height already scrolled past. */
4
+ {
5
+ readonly by: 'item';
6
+ readonly key: string;
7
+ readonly offset: number;
8
+ }
9
+ /** A scroll view: the first visible registered anchor; `offset` as above. */
10
+ | {
11
+ readonly by: 'anchor';
12
+ readonly id: string;
13
+ readonly offset: number;
14
+ }
15
+ /** Last resort: share (0..1) of the scrollable range. */
16
+ | {
17
+ readonly by: 'ratio';
18
+ readonly ratio: number;
19
+ }
20
+ /** At the top, or nothing to scroll on this screen. */
21
+ | {
22
+ readonly by: 'start';
23
+ };
24
+ /** How exactly a view was put back. */
25
+ export type G9ViewApplied = 'exact' | 'degraded' | 'skipped';
26
+ /** The view state of one segment of a snapshot. */
27
+ export interface G9SegmentView {
28
+ readonly view?: Readonly<Record<string, string>>;
29
+ /** Scroll marks by scroller id. */
30
+ readonly scroll?: Readonly<Record<string, G9ScrollMark>>;
31
+ }
32
+ /** Everything open, as data (JSON). */
33
+ export interface G9Snapshot {
34
+ readonly v: 1;
35
+ /** The unique address, canonical. */
36
+ readonly address: string;
37
+ readonly general: string;
38
+ /** The focused anchor. */
39
+ readonly target?: string;
40
+ /** Per segment of the address. */
41
+ readonly views: readonly G9SegmentView[];
42
+ readonly facts: Readonly<Record<string, string | number | boolean | null>>;
43
+ /** When it was taken (ms since the epoch). */
44
+ readonly at: number;
45
+ /** The app version that took it. */
46
+ readonly app: string;
47
+ /** The catalogue hash: a snapshot is not applied across another catalogue. */
48
+ readonly catalogue: string;
49
+ }
50
+ /** A scroll mark from untrusted data, clamped; null when it is not one. */
51
+ export declare function toScrollMark(x: unknown): G9ScrollMark | null;
52
+ /** The snapshot in untrusted data (stored preferences, a QA command), or null when it is not a valid one. */
53
+ export declare function parseSnapshot(x: unknown): G9Snapshot | null;
54
+ /** Why a snapshot may not be applied now, or null when it may. */
55
+ export declare function snapshotRefusal(snapshot: G9Snapshot, now: {
56
+ readonly at: number;
57
+ readonly catalogue: string;
58
+ readonly maxAgeMs: number;
59
+ }): 'catalogue' | 'stale' | 'future' | null;
60
+ //# sourceMappingURL=view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/route/view.ts"],"names":[],"mappings":"AAOA,6CAA6C;AAC7C,MAAM,MAAM,YAAY;AACtB,oHAAoH;AAClH;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACxE,6EAA6E;GAC3E;IAAE,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACzE,yDAAyD;GACvD;IAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CA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D;AAED,kEAAkE;AAClE,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,UAAU,EACpB,GAAG,EAAE;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAClF,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,IAAI,CAKzC"}
@@ -0,0 +1,104 @@
1
+ import { tryParseAddress } from "./address.js";
2
+ const clamp01 = (n)=>n < 0 ? 0 : n > 1 ? 1 : n;
3
+ const TOKEN = /^[A-Za-z0-9._:\-~]{1,128}$/;
4
+ function toScrollMark(x) {
5
+ if (!x || 'object' != typeof x) return null;
6
+ const m = x;
7
+ const offset = 'number' == typeof m.offset && Number.isFinite(m.offset) ? clamp01(m.offset) : 0;
8
+ switch(m.by){
9
+ case 'item':
10
+ return 'string' == typeof m.key && m.key.length > 0 && m.key.length <= 128 ? {
11
+ by: 'item',
12
+ key: m.key,
13
+ offset
14
+ } : null;
15
+ case 'anchor':
16
+ return 'string' == typeof m.id && TOKEN.test(m.id) ? {
17
+ by: 'anchor',
18
+ id: m.id,
19
+ offset
20
+ } : null;
21
+ case 'ratio':
22
+ return 'number' == typeof m.ratio && Number.isFinite(m.ratio) ? {
23
+ by: 'ratio',
24
+ ratio: clamp01(m.ratio)
25
+ } : null;
26
+ case 'start':
27
+ return {
28
+ by: 'start'
29
+ };
30
+ default:
31
+ return null;
32
+ }
33
+ }
34
+ function stringRecord(x, maxKeys, maxValue) {
35
+ if (!x || 'object' != typeof x || Array.isArray(x)) return null;
36
+ const out = {};
37
+ const keys = Object.keys(x);
38
+ if (keys.length > maxKeys) return null;
39
+ for (const k of keys){
40
+ const v = x[k];
41
+ if (!TOKEN.test(k) || 'string' != typeof v || v.length > maxValue) return null;
42
+ out[k] = v;
43
+ }
44
+ return out;
45
+ }
46
+ function parseSnapshot(x) {
47
+ if (!x || 'object' != typeof x) return null;
48
+ const s = x;
49
+ if (1 !== s.v || 'string' != typeof s.address || 'number' != typeof s.at || 'string' != typeof s.catalogue || 'string' != typeof s.app) return null;
50
+ const parsed = tryParseAddress(s.address);
51
+ if (!parsed.ok) return null;
52
+ if (!Array.isArray(s.views) || s.views.length > parsed.address.segments.length) return null;
53
+ const views = [];
54
+ for (const raw of s.views){
55
+ if (!raw || 'object' != typeof raw) return null;
56
+ const r = raw;
57
+ const out = {};
58
+ if (void 0 !== r.view) {
59
+ const view = stringRecord(r.view, 16, 512);
60
+ if (!view) return null;
61
+ out.view = view;
62
+ }
63
+ if (void 0 !== r.scroll) {
64
+ if (!r.scroll || 'object' != typeof r.scroll) return null;
65
+ const scroll = {};
66
+ const keys = Object.keys(r.scroll);
67
+ if (keys.length > 16) return null;
68
+ for (const k of keys){
69
+ const mark = toScrollMark(r.scroll[k]);
70
+ if (!TOKEN.test(k) || !mark) return null;
71
+ scroll[k] = mark;
72
+ }
73
+ out.scroll = scroll;
74
+ }
75
+ views.push(out);
76
+ }
77
+ const facts = {};
78
+ if (s.facts && 'object' == typeof s.facts) {
79
+ for (const [k, v] of Object.entries(s.facts))if (null === v || 'string' == typeof v || 'number' == typeof v || 'boolean' == typeof v) facts[k] = v;
80
+ }
81
+ const snapshot = {
82
+ v: 1,
83
+ address: s.address,
84
+ general: 'string' == typeof s.general ? s.general : '',
85
+ ...'string' == typeof s.target && TOKEN.test(s.target) ? {
86
+ target: s.target
87
+ } : {},
88
+ views,
89
+ facts,
90
+ at: s.at,
91
+ app: s.app,
92
+ catalogue: s.catalogue
93
+ };
94
+ return snapshot;
95
+ }
96
+ function snapshotRefusal(snapshot, now) {
97
+ if (snapshot.catalogue !== now.catalogue) return 'catalogue';
98
+ if (snapshot.at > now.at + 60000) return 'future';
99
+ if (now.at - snapshot.at > now.maxAgeMs) return 'stale';
100
+ return null;
101
+ }
102
+ export { parseSnapshot, snapshotRefusal, toScrollMark };
103
+
104
+ //# sourceMappingURL=view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route/view.js","sources":["../../src/route/view.ts"],"sourcesContent":["import { tryParseAddress } from './address';\n\n// The view state of a place, and the snapshot of everything open (pure). A scroll position is never a pixel offset:\n// pixels mean something else on another screen size, a virtual list may not have laid the row out, and a screen that\n// is tall enough may not scroll at all. A mark names WHAT is first in view — a list row by its item key, a registered\n// control by its anchor id — and how much of it is already scrolled past, as a share of its own height.\n\n/** What is first in view in one scroller. */\nexport type G9ScrollMark =\n /** A list: the first visible row's item key; `offset` = share (0..1) of that row's height already scrolled past. */\n | { readonly by: 'item'; readonly key: string; readonly offset: number }\n /** A scroll view: the first visible registered anchor; `offset` as above. */\n | { readonly by: 'anchor'; readonly id: string; readonly offset: number }\n /** Last resort: share (0..1) of the scrollable range. */\n | { readonly by: 'ratio'; readonly ratio: number }\n /** At the top, or nothing to scroll on this screen. */\n | { readonly by: 'start' };\n\n/** How exactly a view was put back. */\nexport type G9ViewApplied = 'exact' | 'degraded' | 'skipped';\n\n/** The view state of one segment of a snapshot. */\nexport interface G9SegmentView {\n readonly view?: Readonly<Record<string, string>>;\n /** Scroll marks by scroller id. */\n readonly scroll?: Readonly<Record<string, G9ScrollMark>>;\n}\n\n/** Everything open, as data (JSON). */\nexport interface G9Snapshot {\n readonly v: 1;\n /** The unique address, canonical. */\n readonly address: string;\n readonly general: string;\n /** The focused anchor. */\n readonly target?: string;\n /** Per segment of the address. */\n readonly views: readonly G9SegmentView[];\n readonly facts: Readonly<Record<string, string | number | boolean | null>>;\n /** When it was taken (ms since the epoch). */\n readonly at: number;\n /** The app version that took it. */\n readonly app: string;\n /** The catalogue hash: a snapshot is not applied across another catalogue. */\n readonly catalogue: string;\n}\n\nconst clamp01 = (n: number) => (n < 0 ? 0 : n > 1 ? 1 : n);\nconst TOKEN = /^[A-Za-z0-9._:\\-~]{1,128}$/;\n\n/** A scroll mark from untrusted data, clamped; null when it is not one. */\nexport function toScrollMark(x: unknown): G9ScrollMark | null {\n if (!x || typeof x !== 'object') return null;\n const m = x as Record<string, unknown>;\n const offset = typeof m.offset === 'number' && Number.isFinite(m.offset) ? clamp01(m.offset) : 0;\n switch (m.by) {\n case 'item':\n return typeof m.key === 'string' && m.key.length > 0 && m.key.length <= 128\n ? { by: 'item', key: m.key, offset }\n : null;\n case 'anchor':\n return typeof m.id === 'string' && TOKEN.test(m.id) ? { by: 'anchor', id: m.id, offset } : null;\n case 'ratio':\n return typeof m.ratio === 'number' && Number.isFinite(m.ratio) ? { by: 'ratio', ratio: clamp01(m.ratio) } : null;\n case 'start':\n return { by: 'start' };\n default:\n return null;\n }\n}\n\nfunction stringRecord(x: unknown, maxKeys: number, maxValue: number): Record<string, string> | null {\n if (!x || typeof x !== 'object' || Array.isArray(x)) return null;\n const out: Record<string, string> = {};\n const keys = Object.keys(x);\n if (keys.length > maxKeys) return null;\n for (const k of keys) {\n const v = (x as Record<string, unknown>)[k];\n if (!TOKEN.test(k) || typeof v !== 'string' || v.length > maxValue) return null;\n out[k] = v;\n }\n return out;\n}\n\n/** The snapshot in untrusted data (stored preferences, a QA command), or null when it is not a valid one. */\nexport function parseSnapshot(x: unknown): G9Snapshot | null {\n if (!x || typeof x !== 'object') return null;\n const s = x as Record<string, unknown>;\n if (\n s.v !== 1 ||\n typeof s.address !== 'string' ||\n typeof s.at !== 'number' ||\n typeof s.catalogue !== 'string' ||\n typeof s.app !== 'string'\n )\n return null;\n const parsed = tryParseAddress(s.address);\n if (!parsed.ok) return null;\n if (!Array.isArray(s.views) || s.views.length > parsed.address.segments.length) return null;\n const views: G9SegmentView[] = [];\n for (const raw of s.views) {\n if (!raw || typeof raw !== 'object') return null;\n const r = raw as Record<string, unknown>;\n const out: { view?: Record<string, string>; scroll?: Record<string, G9ScrollMark> } = {};\n if (r.view !== undefined) {\n const view = stringRecord(r.view, 16, 512);\n if (!view) return null;\n out.view = view;\n }\n if (r.scroll !== undefined) {\n if (!r.scroll || typeof r.scroll !== 'object') return null;\n const scroll: Record<string, G9ScrollMark> = {};\n const keys = Object.keys(r.scroll);\n if (keys.length > 16) return null;\n for (const k of keys) {\n const mark = toScrollMark((r.scroll as Record<string, unknown>)[k]);\n if (!TOKEN.test(k) || !mark) return null;\n scroll[k] = mark;\n }\n out.scroll = scroll;\n }\n views.push(out);\n }\n const facts: Record<string, string | number | boolean | null> = {};\n if (s.facts && typeof s.facts === 'object') {\n for (const [k, v] of Object.entries(s.facts as Record<string, unknown>)) {\n if (v === null || typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean') facts[k] = v;\n }\n }\n const snapshot: G9Snapshot = {\n v: 1,\n address: s.address,\n general: typeof s.general === 'string' ? s.general : '',\n ...(typeof s.target === 'string' && TOKEN.test(s.target) ? { target: s.target } : {}),\n views,\n facts,\n at: s.at,\n app: s.app,\n catalogue: s.catalogue,\n };\n return snapshot;\n}\n\n/** Why a snapshot may not be applied now, or null when it may. */\nexport function snapshotRefusal(\n snapshot: G9Snapshot,\n now: { readonly at: number; readonly catalogue: string; readonly maxAgeMs: number },\n): 'catalogue' | 'stale' | 'future' | null {\n if (snapshot.catalogue !== now.catalogue) return 'catalogue';\n if (snapshot.at > now.at + 60000) return 'future';\n if (now.at - snapshot.at > now.maxAgeMs) return 'stale';\n return null;\n}\n"],"names":["clamp01","n","TOKEN","toScrollMark","x","m","offset","Number","stringRecord","maxKeys","maxValue","Array","out","keys","Object","k","v","parseSnapshot","s","parsed","tryParseAddress","views","raw","r","undefined","view","scroll","mark","facts","snapshot","snapshotRefusal","now"],"mappings":";AA+CA,MAAMA,UAAU,CAACC,IAAeA,IAAI,IAAI,IAAIA,IAAI,IAAI,IAAIA;AACxD,MAAMC,QAAQ;AAGP,SAASC,aAAaC,CAAU;IACrC,IAAI,CAACA,KAAK,AAAa,YAAb,OAAOA,GAAgB,OAAO;IACxC,MAAMC,IAAID;IACV,MAAME,SAAS,AAAoB,YAApB,OAAOD,EAAE,MAAM,IAAiBE,OAAO,QAAQ,CAACF,EAAE,MAAM,IAAIL,QAAQK,EAAE,M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ACA,MAAMgB,QAA0D,CAAC;IACjE,IAAIV,EAAE,KAAK,IAAI,AAAmB,YAAnB,OAAOA,EAAE,KAAK,EAC3B;QAAA,KAAK,MAAM,CAACH,GAAGC,EAAE,IAAIF,OAAO,OAAO,CAACI,EAAE,KAAK,EACzC,IAAIF,AAAM,SAANA,KAAc,AAAa,YAAb,OAAOA,KAAkB,AAAa,YAAb,OAAOA,KAAkB,AAAa,aAAb,OAAOA,GAAiBY,KAAK,CAACb,EAAE,GAAGC;IACzG;IAEF,MAAMa,WAAuB;QAC3B,GAAG;QACH,SAASX,EAAE,OAAO;QAClB,SAAS,AAAqB,YAArB,OAAOA,EAAE,OAAO,GAAgBA,EAAE,OAAO,GAAG;QACrD,GAAI,AAAoB,YAApB,OAAOA,EAAE,MAAM,IAAiBhB,MAAM,IAAI,CAACgB,EAAE,MAAM,IAAI;YAAE,QAAQA,EAAE,MAAM;QAAC,IAAI,CAAC,CAAC;QACpFG;QACAO;QACA,IAAIV,EAAE,EAAE;QACR,KAAKA,EAAE,GAAG;QACV,WAAWA,EAAE,SAAS;IACxB;IACA,OAAOW;AACT;AAGO,SAASC,gBACdD,QAAoB,EACpBE,GAAmF;IAEnF,IAAIF,SAAS,SAAS,KAAKE,IAAI,SAAS,EAAE,OAAO;IACjD,IAAIF,SAAS,EAAE,GAAGE,IAAI,EAAE,GAAG,OAAO,OAAO;IACzC,IAAIA,IAAI,EAAE,GAAGF,SAAS,EAAE,GAAGE,IAAI,QAAQ,EAAE,OAAO;IAChD,OAAO;AACT"}
@@ -1,4 +1,5 @@
1
1
  import { G9Error } from '../errors.js';
2
+ import type { G9RouteSink } from '../route/sink.js';
2
3
  import type { G9AbortSignal } from './abort.js';
3
4
  import type { G9Clock } from './clock.js';
4
5
  import type { G9PreferenceStore } from './preferences.js';
@@ -177,6 +178,11 @@ export interface G9Capabilities {
177
178
  readonly speech?: G9SpeechToText;
178
179
  readonly scanner?: G9Scanner;
179
180
  readonly media?: G9MediaProvider;
181
+ /**
182
+ * The router places declare themselves to (`@g9tm/lynxcontrols/route` makes one). Optional: without it sheets, tab views
183
+ * and hosts work as before and a `route` option only reports a one-time diagnostics warning.
184
+ */
185
+ readonly route?: G9RouteSink;
180
186
  }
181
187
  /** The name of a capability. */
182
188
  export type G9CapabilityName = keyof G9Capabilities;
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/services/contracts.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,8GAA8G;AAC9G,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,CAAC;AAErE,wCAAwC;AACxC,MAAM,WAAW,qBAAqB;IACpC,mFAAmF;IACnF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,yFAAyF;IACzF,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;IAChC,gFAAgF;IAChF,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACnD;AAED,8FAA8F;AAC9F,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;CAAE,GAChC;IAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAAE,GAC/B;IAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAA;CAAE,CAAC;AAElC;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,yFAAyF;IACzF,WAAW,CAAC,MA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,cAAc,CAAC;AAEpD,4DAA4D;AAC5D,eAAO,MAAM,sBAAsB,EAAE,aAAa,CAAC,gBAAgB,CAAmD,CAAC;AAEvH,sHAAsH;AACtH,qBAAa,wBAAyB,SAAQ,OAAO;IACnD,8BAA8B;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAKjD;AAED,6FAA6F;AAC7F,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAEhG;AAED,4EAA4E;AAC5E,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,gBAAgB,EAC1D,QAAQ,EAAE,OAAO,CAAC,cAAc,CAAC,EACjC,IAAI,EAAE,CAAC,GACN,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAIhC;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,QAAQ,IAAI,cAAc,CAEhH"}
@@ -1 +1 @@
1
- {"version":3,"file":"services/contracts.js","sources":["../../src/services/contracts.ts"],"sourcesContent":["// Platform capability contracts (plan/specs/01-Architecture.md §8). Foundation defines the shapes only; the app\n// supplies implementations through the WP02 provider (`<G9Provider services={…}>`), platform adapters live in the\n// native and Lynxtron packages (WP12–WP14), and the features that use them (fields' dictation WP03, barcode WP09,\n// IntroCarousel WP09) own the behaviour. Nothing here requests a permission or touches a native module.\nimport { G9Error } from '../errors';\nimport type { G9AbortSignal } from './abort';\nimport type { G9Clock } from './clock';\nimport type { G9PreferenceStore } from './preferences';\n\n/** Result of asking for a runtime permission. `'restricted'`: blocked by policy, the user cannot grant it. */\nexport type G9PermissionStatus = 'granted' | 'denied' | 'restricted';\n\n/** Options of one dictation session. */\nexport interface G9SpeechToTextOptions {\n /** BCP 47 locale the recogniser listens for (from the culture, e.g. `'fa-IR'`). */\n readonly locale: string;\n /** Aborting stops listening; the session then settles with `{ status: 'cancelled' }`. */\n readonly signal?: G9AbortSignal;\n /** Interim hypotheses while the user speaks, when the platform reports them. */\n readonly onPartialResult?: (text: string) => void;\n}\n\n/** How a dictation session ended. Expected outcomes are results, not errors (specs/03 §7). */\nexport type G9SpeechToTextResult =\n | { readonly status: 'recognized'; readonly text: string }\n | { readonly status: 'cancelled' }\n | { readonly status: 'no-match' }\n | { readonly status: 'denied' };\n\n/**\n * Speech recognition for dictation into fields (MAUI `IG9SpeechToText`). Optional: without it the microphone\n * affordance is hidden. A platform fault rejects with a `G9Error`.\n */\nexport interface G9SpeechToText {\n /** Whether a recogniser exists for this locale on this device (no permission prompt). */\n isAvailable(locale: string): Promise<boolean>;\n /** Asks for microphone and speech permission (only ever from a user action). */\n requestPermission(): Promise<G9PermissionStatus>;\n /** Listens once and settles exactly once. */\n listen(options: G9SpeechToTextOptions): Promise<G9SpeechToTextResult>;\n}\n\n/** Options of one scan. */\nexport interface G9ScanOptions {\n /** Symbologies to accept (e.g. `'qr'`, `'ean13'`, `'code128'`); empty or absent means every one the scanner has. */\n readonly formats?: ReadonlyArray<string>;\n /** Aborting closes the scanner; the scan then settles with `{ status: 'cancelled' }`. */\n readonly signal?: G9AbortSignal;\n}\n\n/** How a scan ended. */\nexport type G9ScanResult =\n | { readonly status: 'scanned'; readonly text: string; readonly format: string }\n | { readonly status: 'cancelled' }\n | { readonly status: 'denied' };\n\n/** Barcode/QR scanning supplied by the app (WP09 barcode package). Optional: without it the scan action is hidden. */\nexport interface G9Scanner {\n /** Whether a camera scanner is usable on this device (no permission prompt). */\n isAvailable(): Promise<boolean>;\n /** Opens the scanner and settles exactly once. */\n scan(options?: G9ScanOptions): Promise<G9ScanResult>;\n}\n\n/** A media reference as the app describes it (an asset name, a file or a remote URI). */\nexport type G9MediaSource =\n | { readonly kind: 'image'; readonly uri: string }\n | { readonly kind: 'image'; readonly asset: string }\n | { readonly kind: 'video'; readonly uri: string }\n | { readonly kind: 'video'; readonly asset: string };\n\n/** A source resolved to something the platform can display; `uri` is what `<image>`/the video XElement load. */\nexport interface G9ResolvedMedia {\n readonly kind: 'image' | 'video';\n readonly uri: string;\n /** Intrinsic size when known, so layout can reserve space before the first frame. */\n readonly width?: number;\n readonly height?: number;\n}\n\n/** What a {@link G9MediaPlayer} tells its owner. */\nexport type G9MediaPlayerEvent =\n /** The first frame is ready to show. */\n | { readonly type: 'ready' }\n /** A looping video is about to end (`seconds` left); the owner may fade out. */\n | { readonly type: 'nearEnd'; readonly seconds: number }\n /** A looping video restarted from the beginning; the owner may fade back in. */\n | { readonly type: 'looped' }\n /** Playback failed; the owner falls back to the slide image. */\n | { readonly type: 'error'; readonly error: unknown };\n\n/** Options of {@link G9MediaProvider.createPlayer}. */\nexport interface G9MediaPlayerOptions {\n readonly loop?: boolean;\n readonly muted?: boolean;\n /** Best-effort seek applied once after the media opened (MAUI `InitialVideoStartSeconds`). */\n readonly startSeconds?: number;\n /** How early `nearEnd` fires, in seconds. */\n readonly nearEndSeconds?: number;\n}\n\n/**\n * One video player created by the app's media provider. `view` is what the control renders (the platform video\n * XElement the host registered, built by the app); the control never names a video tag itself.\n */\nexport interface G9MediaPlayer {\n /** The element to render (a ReactNode built by the app's provider; foundation keeps it opaque). */\n readonly view: unknown;\n play(): void;\n pause(): void;\n /** Releases the native player; idempotent. */\n dispose(): void;\n /** Subscribes to player events; returns the unsubscribe function. */\n subscribe(listener: (event: G9MediaPlayerEvent) => void): () => void;\n}\n\n/**\n * Resolves image and video sources for IntroCarousel and other media controls (WP09). Video is part of the contract on\n * every target, desktop included (decision D14 is open; no scope reduction is accepted). A provider that cannot play\n * video yet omits `createPlayer` or returns `false` from `supportsVideo`; controls then show the slide image and say\n * why (`'video-unsupported'`).\n */\nexport interface G9MediaProvider {\n resolve(source: G9MediaSource, options?: { readonly signal?: G9AbortSignal }): Promise<G9ResolvedMedia>;\n /** Whether this target can play video now (no permission prompt). Absent = `createPlayer` decides. */\n supportsVideo?(): boolean;\n /** Creates a player for a resolved video. The control disposes it on slide change, deactivation and unmount. */\n createPlayer?(media: G9ResolvedMedia, options?: G9MediaPlayerOptions): G9MediaPlayer;\n}\n\n/** Safe-area insets in logical pixels. */\nexport interface G9SafeInsets {\n readonly top: number;\n readonly end: number;\n readonly bottom: number;\n readonly start: number;\n}\n\n/** Android soft-input policy while a flow needs it (MAUI `G9KeyboardHelper.UseAndroidPanSoftInputMode`). */\nexport type G9SoftInputMode = 'pan' | 'resize';\n\n/**\n * Host integration the provider and overlays need (MAUI page/window plumbing), supplied by the native host. Required.\n * The system back press does not go through this object: the host sends a global event (default `g9:back`, specs/02\n * §4) and the provider dispatches it to the active `G9Host`; `exit` is what happens when nothing handled it.\n */\nexport interface G9HostServices {\n /** Leaves the app the platform way (Android moves the task to the back; desktop closes the window). */\n exit(): void;\n /** Hides the soft keyboard and clears focus (MAUI `G9KeyboardHelper.HideKeyboardAndClearFocus`). */\n hideKeyboard(): void;\n /** Current safe-area insets. */\n getSafeInsets(): G9SafeInsets;\n /** Called when the insets change (rotation, window resize). Returns an unsubscribe function. */\n subscribeSafeInsets(listener: (insets: G9SafeInsets) => void): () => void;\n /**\n * Switches the window's soft-input mode (Android only; `'resize'` is the app default). Hosts on platforms without\n * soft-input modes (iOS, desktop) omit it, which is where MAUI's helper was a no-op too.\n */\n setSoftInputMode?(mode: G9SoftInputMode): void;\n}\n\n/** Every service the app can supply. Required ones are listed in {@link g9RequiredCapabilities}. */\nexport interface G9Capabilities {\n readonly clock: G9Clock;\n readonly preferences: G9PreferenceStore;\n readonly host: G9HostServices;\n readonly speech?: G9SpeechToText;\n readonly scanner?: G9Scanner;\n readonly media?: G9MediaProvider;\n}\n\n/** The name of a capability. */\nexport type G9CapabilityName = keyof G9Capabilities;\n\n/** Capabilities without which the provider cannot mount. */\nexport const g9RequiredCapabilities: ReadonlyArray<G9CapabilityName> = Object.freeze(['clock', 'preferences', 'host']);\n\n/** Thrown when code needs a capability the app did not supply (specs/03 §7: `G9CapabilityMissingError('speech')`). */\nexport class G9CapabilityMissingError extends G9Error {\n /** The missing capability. */\n readonly capability: string;\n\n constructor(capability: string, message?: string) {\n super('capability-missing', message ?? `The '${capability}' service is not available; supply it to G9Provider.`);\n this.name = 'G9CapabilityMissingError';\n this.capability = capability;\n }\n}\n\n/** `true` when the capability is present (optional features use this to hide themselves). */\nexport function hasCapability(services: Partial<G9Capabilities>, name: G9CapabilityName): boolean {\n return services[name] != null;\n}\n\n/** The capability, or throws {@link G9CapabilityMissingError} naming it. */\nexport function requireCapability<K extends G9CapabilityName>(\n services: Partial<G9Capabilities>,\n name: K,\n): NonNullable<G9Capabilities[K]> {\n const service = services[name];\n if (service == null) throw new G9CapabilityMissingError(name);\n return service as NonNullable<G9Capabilities[K]>;\n}\n\n/**\n * Checks every required capability at once (the provider calls this at mount).\n * @throws {G9CapabilityMissingError} for the first missing one, in {@link g9RequiredCapabilities} order.\n */\nexport function assertRequiredCapabilities(services: Partial<G9Capabilities>): asserts services is G9Capabilities {\n for (const name of g9RequiredCapabilities) requireCapability(services, name);\n}\n"],"names":["g9RequiredCapabilities","Object","G9CapabilityMissingError","G9Error","capability","message","hasCapability","services","name","requireCapability","service","assertRequiredCapabilities"],"mappings":";;;;;;;;;;;AAgLO,MAAMA,yBAA0DC,OAAO,MAAM,CAAC;IAAC;IAAS;IAAe;CAAO;AAG9G,MAAMC,iCAAiCC;IAI5C,YAAYC,UAAkB,EAAEC,OAAgB,CAAE;QAChD,KAAK,CAAC,sBAAsBA,QAAAA,UAAAA,UAAW,CAAC,KAAK,EAAED,WAAW,oDAAoD,CAAC,GAHjH,uBAAS,cAAT;QAIE,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,UAAU,GAAGA;IACpB;AACF;AAGO,SAASE,cAAcC,QAAiC,EAAEC,IAAsB;IACrF,OAAOD,AAAkB,QAAlBA,QAAQ,CAACC,KAAK;AACvB;AAGO,SAASC,kBACdF,QAAiC,EACjCC,IAAO;IAEP,MAAME,UAAUH,QAAQ,CAACC,KAAK;IAC9B,IAAIE,AAAW,QAAXA,SAAiB,MAAM,IAAIR,yBAAyBM;IACxD,OAAOE;AACT;AAMO,SAASC,2BAA2BJ,QAAiC;IAC1E,KAAK,MAAMC,QAAQR,uBAAwBS,kBAAkBF,UAAUC;AACzE"}
1
+ {"version":3,"file":"services/contracts.js","sources":["../../src/services/contracts.ts"],"sourcesContent":["// Platform capability contracts (plan/specs/01-Architecture.md §8). Foundation defines the shapes only; the app\n// supplies implementations through the WP02 provider (`<G9Provider services={…}>`), platform adapters live in the\n// native and Lynxtron packages (WP12–WP14), and the features that use them (fields' dictation WP03, barcode WP09,\n// IntroCarousel WP09) own the behaviour. Nothing here requests a permission or touches a native module.\nimport { G9Error } from '../errors';\nimport type { G9RouteSink } from '../route/sink';\nimport type { G9AbortSignal } from './abort';\nimport type { G9Clock } from './clock';\nimport type { G9PreferenceStore } from './preferences';\n\n/** Result of asking for a runtime permission. `'restricted'`: blocked by policy, the user cannot grant it. */\nexport type G9PermissionStatus = 'granted' | 'denied' | 'restricted';\n\n/** Options of one dictation session. */\nexport interface G9SpeechToTextOptions {\n /** BCP 47 locale the recogniser listens for (from the culture, e.g. `'fa-IR'`). */\n readonly locale: string;\n /** Aborting stops listening; the session then settles with `{ status: 'cancelled' }`. */\n readonly signal?: G9AbortSignal;\n /** Interim hypotheses while the user speaks, when the platform reports them. */\n readonly onPartialResult?: (text: string) => void;\n}\n\n/** How a dictation session ended. Expected outcomes are results, not errors (specs/03 §7). */\nexport type G9SpeechToTextResult =\n | { readonly status: 'recognized'; readonly text: string }\n | { readonly status: 'cancelled' }\n | { readonly status: 'no-match' }\n | { readonly status: 'denied' };\n\n/**\n * Speech recognition for dictation into fields (MAUI `IG9SpeechToText`). Optional: without it the microphone\n * affordance is hidden. A platform fault rejects with a `G9Error`.\n */\nexport interface G9SpeechToText {\n /** Whether a recogniser exists for this locale on this device (no permission prompt). */\n isAvailable(locale: string): Promise<boolean>;\n /** Asks for microphone and speech permission (only ever from a user action). */\n requestPermission(): Promise<G9PermissionStatus>;\n /** Listens once and settles exactly once. */\n listen(options: G9SpeechToTextOptions): Promise<G9SpeechToTextResult>;\n}\n\n/** Options of one scan. */\nexport interface G9ScanOptions {\n /** Symbologies to accept (e.g. `'qr'`, `'ean13'`, `'code128'`); empty or absent means every one the scanner has. */\n readonly formats?: ReadonlyArray<string>;\n /** Aborting closes the scanner; the scan then settles with `{ status: 'cancelled' }`. */\n readonly signal?: G9AbortSignal;\n}\n\n/** How a scan ended. */\nexport type G9ScanResult =\n | { readonly status: 'scanned'; readonly text: string; readonly format: string }\n | { readonly status: 'cancelled' }\n | { readonly status: 'denied' };\n\n/** Barcode/QR scanning supplied by the app (WP09 barcode package). Optional: without it the scan action is hidden. */\nexport interface G9Scanner {\n /** Whether a camera scanner is usable on this device (no permission prompt). */\n isAvailable(): Promise<boolean>;\n /** Opens the scanner and settles exactly once. */\n scan(options?: G9ScanOptions): Promise<G9ScanResult>;\n}\n\n/** A media reference as the app describes it (an asset name, a file or a remote URI). */\nexport type G9MediaSource =\n | { readonly kind: 'image'; readonly uri: string }\n | { readonly kind: 'image'; readonly asset: string }\n | { readonly kind: 'video'; readonly uri: string }\n | { readonly kind: 'video'; readonly asset: string };\n\n/** A source resolved to something the platform can display; `uri` is what `<image>`/the video XElement load. */\nexport interface G9ResolvedMedia {\n readonly kind: 'image' | 'video';\n readonly uri: string;\n /** Intrinsic size when known, so layout can reserve space before the first frame. */\n readonly width?: number;\n readonly height?: number;\n}\n\n/** What a {@link G9MediaPlayer} tells its owner. */\nexport type G9MediaPlayerEvent =\n /** The first frame is ready to show. */\n | { readonly type: 'ready' }\n /** A looping video is about to end (`seconds` left); the owner may fade out. */\n | { readonly type: 'nearEnd'; readonly seconds: number }\n /** A looping video restarted from the beginning; the owner may fade back in. */\n | { readonly type: 'looped' }\n /** Playback failed; the owner falls back to the slide image. */\n | { readonly type: 'error'; readonly error: unknown };\n\n/** Options of {@link G9MediaProvider.createPlayer}. */\nexport interface G9MediaPlayerOptions {\n readonly loop?: boolean;\n readonly muted?: boolean;\n /** Best-effort seek applied once after the media opened (MAUI `InitialVideoStartSeconds`). */\n readonly startSeconds?: number;\n /** How early `nearEnd` fires, in seconds. */\n readonly nearEndSeconds?: number;\n}\n\n/**\n * One video player created by the app's media provider. `view` is what the control renders (the platform video\n * XElement the host registered, built by the app); the control never names a video tag itself.\n */\nexport interface G9MediaPlayer {\n /** The element to render (a ReactNode built by the app's provider; foundation keeps it opaque). */\n readonly view: unknown;\n play(): void;\n pause(): void;\n /** Releases the native player; idempotent. */\n dispose(): void;\n /** Subscribes to player events; returns the unsubscribe function. */\n subscribe(listener: (event: G9MediaPlayerEvent) => void): () => void;\n}\n\n/**\n * Resolves image and video sources for IntroCarousel and other media controls (WP09). Video is part of the contract on\n * every target, desktop included (decision D14 is open; no scope reduction is accepted). A provider that cannot play\n * video yet omits `createPlayer` or returns `false` from `supportsVideo`; controls then show the slide image and say\n * why (`'video-unsupported'`).\n */\nexport interface G9MediaProvider {\n resolve(source: G9MediaSource, options?: { readonly signal?: G9AbortSignal }): Promise<G9ResolvedMedia>;\n /** Whether this target can play video now (no permission prompt). Absent = `createPlayer` decides. */\n supportsVideo?(): boolean;\n /** Creates a player for a resolved video. The control disposes it on slide change, deactivation and unmount. */\n createPlayer?(media: G9ResolvedMedia, options?: G9MediaPlayerOptions): G9MediaPlayer;\n}\n\n/** Safe-area insets in logical pixels. */\nexport interface G9SafeInsets {\n readonly top: number;\n readonly end: number;\n readonly bottom: number;\n readonly start: number;\n}\n\n/** Android soft-input policy while a flow needs it (MAUI `G9KeyboardHelper.UseAndroidPanSoftInputMode`). */\nexport type G9SoftInputMode = 'pan' | 'resize';\n\n/**\n * Host integration the provider and overlays need (MAUI page/window plumbing), supplied by the native host. Required.\n * The system back press does not go through this object: the host sends a global event (default `g9:back`, specs/02\n * §4) and the provider dispatches it to the active `G9Host`; `exit` is what happens when nothing handled it.\n */\nexport interface G9HostServices {\n /** Leaves the app the platform way (Android moves the task to the back; desktop closes the window). */\n exit(): void;\n /** Hides the soft keyboard and clears focus (MAUI `G9KeyboardHelper.HideKeyboardAndClearFocus`). */\n hideKeyboard(): void;\n /** Current safe-area insets. */\n getSafeInsets(): G9SafeInsets;\n /** Called when the insets change (rotation, window resize). Returns an unsubscribe function. */\n subscribeSafeInsets(listener: (insets: G9SafeInsets) => void): () => void;\n /**\n * Switches the window's soft-input mode (Android only; `'resize'` is the app default). Hosts on platforms without\n * soft-input modes (iOS, desktop) omit it, which is where MAUI's helper was a no-op too.\n */\n setSoftInputMode?(mode: G9SoftInputMode): void;\n}\n\n/** Every service the app can supply. Required ones are listed in {@link g9RequiredCapabilities}. */\nexport interface G9Capabilities {\n readonly clock: G9Clock;\n readonly preferences: G9PreferenceStore;\n readonly host: G9HostServices;\n readonly speech?: G9SpeechToText;\n readonly scanner?: G9Scanner;\n readonly media?: G9MediaProvider;\n /**\n * The router places declare themselves to (`@g9tm/lynxcontrols/route` makes one). Optional: without it sheets, tab views\n * and hosts work as before and a `route` option only reports a one-time diagnostics warning.\n */\n readonly route?: G9RouteSink;\n}\n\n/** The name of a capability. */\nexport type G9CapabilityName = keyof G9Capabilities;\n\n/** Capabilities without which the provider cannot mount. */\nexport const g9RequiredCapabilities: ReadonlyArray<G9CapabilityName> = Object.freeze(['clock', 'preferences', 'host']);\n\n/** Thrown when code needs a capability the app did not supply (specs/03 §7: `G9CapabilityMissingError('speech')`). */\nexport class G9CapabilityMissingError extends G9Error {\n /** The missing capability. */\n readonly capability: string;\n\n constructor(capability: string, message?: string) {\n super('capability-missing', message ?? `The '${capability}' service is not available; supply it to G9Provider.`);\n this.name = 'G9CapabilityMissingError';\n this.capability = capability;\n }\n}\n\n/** `true` when the capability is present (optional features use this to hide themselves). */\nexport function hasCapability(services: Partial<G9Capabilities>, name: G9CapabilityName): boolean {\n return services[name] != null;\n}\n\n/** The capability, or throws {@link G9CapabilityMissingError} naming it. */\nexport function requireCapability<K extends G9CapabilityName>(\n services: Partial<G9Capabilities>,\n name: K,\n): NonNullable<G9Capabilities[K]> {\n const service = services[name];\n if (service == null) throw new G9CapabilityMissingError(name);\n return service as NonNullable<G9Capabilities[K]>;\n}\n\n/**\n * Checks every required capability at once (the provider calls this at mount).\n * @throws {G9CapabilityMissingError} for the first missing one, in {@link g9RequiredCapabilities} order.\n */\nexport function assertRequiredCapabilities(services: Partial<G9Capabilities>): asserts services is G9Capabilities {\n for (const name of g9RequiredCapabilities) requireCapability(services, name);\n}\n"],"names":["g9RequiredCapabilities","Object","G9CapabilityMissingError","G9Error","capability","message","hasCapability","services","name","requireCapability","service","assertRequiredCapabilities"],"mappings":";;;;;;;;;;;AAsLO,MAAMA,yBAA0DC,OAAO,MAAM,CAAC;IAAC;IAAS;IAAe;CAAO;AAG9G,MAAMC,iCAAiCC;IAI5C,YAAYC,UAAkB,EAAEC,OAAgB,CAAE;QAChD,KAAK,CAAC,sBAAsBA,QAAAA,UAAAA,UAAW,CAAC,KAAK,EAAED,WAAW,oDAAoD,CAAC,GAHjH,uBAAS,cAAT;QAIE,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,UAAU,GAAGA;IACpB;AACF;AAGO,SAASE,cAAcC,QAAiC,EAAEC,IAAsB;IACrF,OAAOD,AAAkB,QAAlBA,QAAQ,CAACC,KAAK;AACvB;AAGO,SAASC,kBACdF,QAAiC,EACjCC,IAAO;IAEP,MAAME,UAAUH,QAAQ,CAACC,KAAK;IAC9B,IAAIE,AAAW,QAAXA,SAAiB,MAAM,IAAIR,yBAAyBM;IACxD,OAAOE;AACT;AAMO,SAASC,2BAA2BJ,QAAiC;IAC1E,KAAK,MAAMC,QAAQR,uBAAwBS,kBAAkBF,UAAUC;AACzE"}
package/docs/api.md CHANGED
@@ -362,6 +362,77 @@ folder) explain how the pieces fit; the migration tables map every MAUI member.
362
362
  | `G9SoftInputMode` | type | Android soft-input policy while a flow needs it (MAUI `G9KeyboardHelper.UseAndroidPanSoftInputMode`). |
363
363
  | `G9SpeechToTextResult` | type | How a dictation session ended. Expected outcomes are results, not errors (specs/03 §7). |
364
364
 
365
+ ## `@g9tm/lynxcontrols-foundation/route`
366
+
367
+ | Export | Kind | Summary |
368
+ | --- | --- | --- |
369
+ | `catalogueManifest` | function | The catalogue as data (JSON-safe), in one language. |
370
+ | `compareLivePlaces` | function | Bottom-to-top order of open places. |
371
+ | `confirmSeconds` | function | The countdown of one confirmation (whole seconds, ≥ 1). |
372
+ | `createCatalogue` | function | Builds a catalogue and validates it: unique kinds, names in the grammar, known parents, a `defaultParent` that is a parent and leads to the root through singletons, no cycles. The generic kinds are added. |
373
+ | `formatAddress` | function | The canonical text of an address: parameters sorted by name, hex escapes upper case, no trailing "/". Two addresses are the same address when their canonical texts are equal (ids are normalised by the catalogue, not here). |
374
+ | `g9PatternCodec` | function | A codec from a pattern (and an optional normaliser; default: the id as it is). |
375
+ | `generalOf` | function | The general form: kinds and variants only (no ids, parameters or target). |
376
+ | `journeyAuthority` | function | The source policy (plan §11.3). `navigate` covers go / show / say / wait; `fill` covers fill and select (a form value, never a save); `press` reads the anchor's risk. An app may only make it stricter. |
377
+ | `matchesAddress` | function | Whether an address matches a pattern of kinds: `/tasks/task.sampling/**​/package`. A token is `kind`, `kind.variant`, either with `:*` (an id is required), `*` (exactly one segment) or `**` (any number, also none). |
378
+ | `parseAddress` | function | Parses an address strictly. |
379
+ | `parseSnapshot` | function | The snapshot in untrusted data (stored preferences, a QA command), or null when it is not a valid one. |
380
+ | `planNavigation` | function | The plan from what is open to a target path (pure). The kept prefix must END on an open place (a made-up ancestor is kept only when an open place below the divergence holds it): leaving the sampling map for its own task overview closes the map mode and opens the overview, it does not keep a task that was never open. Closed: every open place of the current path past the kept prefix, and every overlay (sheet, popup) above it; never a root place (opening a sibling root replaces it). |
381
+ | `resolvePath` | function | The logical path of what is open. |
382
+ | `sameSegment` | function | Same kind, variant and id (parameters are view state, not identity). |
383
+ | `sameSegmentState` | function | Same kind, variant, id AND parameters. |
384
+ | `seg` | function | Builds a segment, leaving out what is null or empty. |
385
+ | `snapshotRefusal` | function | Why a snapshot may not be applied now, or null when it may. |
386
+ | `textIn` | function | A text in the person's language. |
387
+ | `toScrollMark` | function | A scroll mark from untrusted data, clamped; null when it is not one. |
388
+ | `toSegment` | function | A `G9SegmentInput` as a segment. |
389
+ | `tryParseAddress` | function | `parseAddress` without throwing. |
390
+ | `validateJourney` | function | Validates untrusted JSON as a journey: unknown keys, bad texts, addresses or ids are refused. |
391
+ | `g9AddressLimits` | constant | The bounds of an address (each one a refusal past it). |
392
+ | `g9ConfirmTimingDefaults` | constant | The default countdowns: 5 s for a save, 10 s for a delete, +3 s from a link, ×2 when undescribed. |
393
+ | `g9GenericKinds` | constant | The kinds the library adds to every catalogue: an undeclared sheet, map mode or page stays visible in the address. |
394
+ | `g9GuidCodec` | constant | A GUID, canonical in lower case. |
395
+ | `g9JourneyLimits` | constant | The bounds of a journey. |
396
+ | `g9PlaceLayers` | constant | Every layer, bottom to top. |
397
+ | `G9AddressError` | class | A refused address. `code` is stable; `message` is for developers (not shown to users). |
398
+ | `G9CatalogueError` | class | A catalogue that cannot work (a developer error: raised at start-up, never at run time). |
399
+ | `G9Address` | interface | A parsed address: the path of places (root first) and an optional focused anchor. |
400
+ | `G9BilingualText` | interface | Text in both languages (the catalogue's descriptions, journeys). |
401
+ | `G9Catalogue` | interface | The places of an app, validated: definitions, parents, made-up ancestors, structural checks of an address. |
402
+ | `G9CatalogueManifestEntry` | interface | One kind as a manifest lists it (an assistant's or a QA tool's view of the catalogue). |
403
+ | `G9ChangeLine` | interface | One change a write would make, as a person reads it (the confirmation before a guided save lists these). |
404
+ | `G9ConfirmTiming` | interface | Countdown lengths of the confirmation (seconds). |
405
+ | `G9Entry` | interface | How a PERSON reaches a place from its parent: the control to tap there. |
406
+ | `G9IdCodec` | interface | How the ids of one kind look. |
407
+ | `G9Journey` | interface | A journey: validated JSON steps a guide runs on screen. |
408
+ | `G9LivePlace` | interface | One open place as the resolver sees it. |
409
+ | `G9NavigationPlan` | interface | What going to a target path changes. |
410
+ | `G9ParamDef` | interface | One view parameter of a place (`;q=…`, `;sort=due.desc`). |
411
+ | `G9PlaceDeclaration` | interface | A place that is open right now, as it declares itself. |
412
+ | `G9PlaceDef` | interface | One kind of place. `Ctx` is what the app hands every callback (its session, services…). |
413
+ | `G9PlaceHandle` | interface | The handle of one declaration. |
414
+ | `G9ResolvedPath` | interface | The logical path and how each step is held. |
415
+ | `G9RouteSink` | interface | The router as places see it (`G9Capabilities.route`). |
416
+ | `G9Segment` | interface | One place in an address. Values are DECODED text; `formatAddress` encodes them. |
417
+ | `G9SegmentView` | interface | The view state of one segment of a snapshot. |
418
+ | `G9Snapshot` | interface | Everything open, as data (JSON). |
419
+ | `G9WaitFor` | interface | What a wait step waits for (any one of them). |
420
+ | `G9AddressCheck` | type | A structural check of one address against the catalogue. |
421
+ | `G9AddressErrorCode` | type | Why an address was refused. |
422
+ | `G9AnchorRisk` | type | What pressing a control does to data. |
423
+ | `G9GoFailure` | type | Why going to an address failed (or why a check refused it). |
424
+ | `G9GuardResult` | type | What a place's guard answers. `message` is shown to the person (their language). |
425
+ | `G9GuideEffectSpec` | type | One visual effect of a journey step (JSON-safe; the guide draws it). |
426
+ | `G9JourneySource` | type | Who authored a journey. The runner uses the CALLER's source, never the journey's own claim. |
427
+ | `G9JourneyStep` | type | One step of a journey. |
428
+ | `G9PlaceLayer` | type | Where a place is drawn: decides which open place is on top. Bottom to top. |
429
+ | `G9ScrollMark` | type | What is first in view in one scroller. |
430
+ | `G9SegmentInput` | type | A segment, or just its kind. |
431
+ | `G9StepAuthority` | type | Who carries a step out: the engine, the engine after the person's countdown confirmation, or the person. |
432
+ | `G9Text` | type | Text in one language or both. |
433
+ | `G9Until` | type | When a show / say step moves on. |
434
+ | `G9ViewApplied` | type | How exactly a view was put back. |
435
+
365
436
  ## `@g9tm/lynxcontrols-foundation`
366
437
 
367
438
  | Export | Kind | Summary |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@g9tm/lynxcontrols-foundation",
3
- "version": "1.4.11",
3
+ "version": "1.6.0",
4
4
  "description": "Pure TypeScript core: design tokens, theme model, culture (strings, digits, calendars, relative time, durations), icon model, safe execution, diagnostics, preference and capability contracts. No React, no UI.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -45,6 +45,11 @@
45
45
  "source": "./src/services/index.ts",
46
46
  "types": "./dist/services/index.d.ts",
47
47
  "default": "./dist/services/index.js"
48
+ },
49
+ "./route": {
50
+ "source": "./src/route/index.ts",
51
+ "types": "./dist/route/index.d.ts",
52
+ "default": "./dist/route/index.js"
48
53
  }
49
54
  },
50
55
  "files": [