@g9tm/lynxcontrols-foundation 1.4.11 → 1.5.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/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/route/address.d.ts +68 -0
- package/dist/route/address.d.ts.map +1 -0
- package/dist/route/address.js +282 -0
- package/dist/route/address.js.map +1 -0
- package/dist/route/catalogue.d.ts +131 -0
- package/dist/route/catalogue.d.ts.map +1 -0
- package/dist/route/catalogue.js +236 -0
- package/dist/route/catalogue.js.map +1 -0
- package/dist/route/index.d.ts +7 -0
- package/dist/route/index.d.ts.map +1 -0
- package/dist/route/index.js +6 -0
- package/dist/route/journey.d.ts +147 -0
- package/dist/route/journey.d.ts.map +1 -0
- package/dist/route/journey.js +345 -0
- package/dist/route/journey.js.map +1 -0
- package/dist/route/resolve.d.ts +43 -0
- package/dist/route/resolve.d.ts.map +1 -0
- package/dist/route/resolve.js +116 -0
- package/dist/route/resolve.js.map +1 -0
- package/dist/route/sink.d.ts +62 -0
- package/dist/route/sink.d.ts.map +1 -0
- package/dist/route/sink.js +11 -0
- package/dist/route/sink.js.map +1 -0
- package/dist/route/view.d.ts +60 -0
- package/dist/route/view.d.ts.map +1 -0
- package/dist/route/view.js +104 -0
- package/dist/route/view.js.map +1 -0
- package/dist/services/contracts.d.ts +6 -0
- package/dist/services/contracts.d.ts.map +1 -1
- package/dist/services/contracts.js.map +1 -1
- package/docs/api.md +71 -0
- package/package.json +6 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route/address.js","sources":["../../src/route/address.ts"],"sourcesContent":["import { G9Error } from '../errors';\n\n// The navigation address grammar (route): where a place of the app is, as text an automation, a tester report, a link\n// or an assistant can carry. Structure only — which kinds exist, their parents and ids belong to the catalogue.\n//\n// address = \"/\" [ segment *( \"/\" segment ) ] [ \"#\" target ]\n// segment = kind [ \".\" variant ] [ \":\" id ] *( \";\" name \"=\" value )\n//\n// A UNIQUE address names entities (`/tasks/task.sampling:9f3a…/sampling:71c2…/packages/package:9b10…`); its GENERAL\n// form keeps only the kinds (`/tasks/task.sampling/sampling/packages/package`). Parsing is strict and bounded: an\n// address may come from outside the app (a link), so anything outside the grammar is refused with a typed error.\n\n/** One place in an address. Values are DECODED text; `formatAddress` encodes them. */\nexport interface G9Segment {\n readonly kind: string;\n readonly variant?: string;\n readonly id?: string;\n readonly params?: Readonly<Record<string, string>>;\n}\n\n/** A parsed address: the path of places (root first) and an optional focused anchor. */\nexport interface G9Address {\n readonly segments: readonly G9Segment[];\n /** An anchor id to bring into view and focus (the `#…` part). */\n readonly target?: string;\n}\n\n/** A segment, or just its kind. */\nexport type G9SegmentInput = G9Segment | string;\n\n/** Why an address was refused. */\nexport type G9AddressErrorCode =\n | 'not-absolute'\n | 'too-long'\n | 'too-deep'\n | 'empty-segment'\n | 'bad-char'\n | 'bad-escape'\n | 'bad-name'\n | 'bad-param'\n | 'dup-param'\n | 'too-many-params';\n\n/** A refused address. `code` is stable; `message` is for developers (not shown to users). */\nexport class G9AddressError extends G9Error {\n override readonly code: G9AddressErrorCode;\n\n constructor(code: G9AddressErrorCode, message: string) {\n super(code, message);\n this.name = 'G9AddressError';\n this.code = code;\n }\n}\n\n/** The bounds of an address (each one a refusal past it). */\nexport const g9AddressLimits = Object.freeze({\n length: 2048,\n depth: 16,\n params: 8,\n kind: 32,\n id: 96,\n paramName: 24,\n paramValue: 256,\n target: 128,\n});\n\nconst NAME = /^[a-z][a-z0-9-]*$/;\nconst RAW_ID = /^[A-Za-z0-9\\-_~%]+$/;\nconst RAW_VALUE = /^[A-Za-z0-9\\-_~.,%]*$/;\nconst RAW_TARGET = /^[A-Za-z0-9._\\-%]+$/;\nconst SAFE_ID = /^[A-Za-z0-9\\-_~]$/;\nconst SAFE_VALUE = /^[A-Za-z0-9\\-_~.,]$/;\nconst SAFE_TARGET = /^[A-Za-z0-9._-]$/;\n// biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are what this refuses\nconst CONTROL = /[\\u0000-\\u001f\\u007f-\\u009f]/;\nconst ESCAPE = /%[0-9A-Fa-f]{2}/;\nconst BAD_ESCAPE = /%(?![0-9A-Fa-f]{2})/;\n\nfunction fail(code: G9AddressErrorCode, message: string): never {\n throw new G9AddressError(code, message);\n}\n\nfunction decode(raw: string, what: string): string {\n if (BAD_ESCAPE.test(raw)) fail('bad-escape', `${what}: a \"%\" must start a two-digit hex escape.`);\n let text: string;\n try {\n text = decodeURIComponent(raw);\n } catch {\n return fail('bad-escape', `${what}: the escapes are not UTF-8.`);\n }\n // Decoded exactly once: text that still holds an escape would mean something else to a second decoder.\n if (ESCAPE.test(text)) fail('bad-escape', `${what}: an escape decodes to another escape.`);\n if (CONTROL.test(text)) fail('bad-char', `${what}: control characters are not allowed.`);\n return text;\n}\n\nfunction hex2(code: number): string {\n const h = code.toString(16).toUpperCase();\n return h.length === 1 ? `0${h}` : h;\n}\n\nfunction encode(text: string, safe: RegExp): string {\n let out = '';\n for (const ch of text) {\n if (safe.test(ch)) {\n out += ch;\n continue;\n }\n let e: string;\n try {\n e = encodeURIComponent(ch);\n } catch {\n return fail('bad-char', 'A lone surrogate cannot be encoded.');\n }\n // encodeURIComponent leaves . ! * ' ( ) as they are; outside our safe set they are escaped too.\n out += e === ch ? `%${hex2(ch.charCodeAt(0))}` : e;\n }\n return out;\n}\n\nfunction checkName(name: string, what: string, max: number): void {\n if (name.length > max || !NAME.test(name))\n fail('bad-name', `${what} \"${name}\" must match [a-z][a-z0-9-]* (≤ ${max}).`);\n}\n\nfunction parseSegment(text: string, index: number): G9Segment {\n const parts = text.split(';');\n const head = parts[0] ?? '';\n if (head === '') fail('empty-segment', `Segment ${index} has no kind.`);\n const colon = head.indexOf(':');\n const name = colon < 0 ? head : head.slice(0, colon);\n const dot = name.indexOf('.');\n const kind = dot < 0 ? name : name.slice(0, dot);\n checkName(kind, 'A kind', g9AddressLimits.kind);\n let variant: string | undefined;\n if (dot >= 0) {\n variant = name.slice(dot + 1);\n checkName(variant, 'A variant', g9AddressLimits.kind);\n }\n let id: string | undefined;\n if (colon >= 0) {\n const raw = head.slice(colon + 1);\n if (raw === '' || raw.length > g9AddressLimits.id * 3 || !RAW_ID.test(raw))\n fail('bad-char', `Segment ${index}: the id has characters outside [A-Za-z0-9-_~] and escapes.`);\n id = decode(raw, `Segment ${index} id`);\n if (id.length > g9AddressLimits.id)\n fail('too-long', `Segment ${index}: the id is longer than ${g9AddressLimits.id}.`);\n }\n let params: Record<string, string> | undefined;\n if (parts.length > 1) {\n if (parts.length - 1 > g9AddressLimits.params)\n fail('too-many-params', `Segment ${index} has more than ${g9AddressLimits.params} parameters.`);\n params = {};\n const seen = new Set<string>();\n for (let i = 1; i < parts.length; i++) {\n const p = parts[i] ?? '';\n const eq = p.indexOf('=');\n if (eq <= 0) fail('bad-param', `Segment ${index}: \"${p}\" is not name=value.`);\n const pname = p.slice(0, eq);\n checkName(pname, 'A parameter name', g9AddressLimits.paramName);\n const raw = p.slice(eq + 1);\n if (raw === '' || !RAW_VALUE.test(raw))\n fail('bad-param', `Segment ${index}: parameter \"${pname}\" has an empty or invalid value.`);\n if (seen.has(pname)) fail('dup-param', `Segment ${index}: parameter \"${pname}\" twice.`);\n seen.add(pname);\n const value = decode(raw, `Parameter ${pname}`);\n if (value.length > g9AddressLimits.paramValue)\n fail('too-long', `Parameter ${pname} is longer than ${g9AddressLimits.paramValue}.`);\n params[pname] = value;\n }\n }\n return seg(kind, id, variant, params);\n}\n\n/** Builds a segment, leaving out what is null or empty. */\nexport function seg(\n kind: string,\n id?: string | null,\n variant?: string | null,\n params?: Readonly<Record<string, string | null | undefined>> | null,\n): G9Segment {\n const out: { kind: string; variant?: string; id?: string; params?: Record<string, string> } = { kind };\n if (variant) out.variant = variant;\n if (id) out.id = id;\n if (params) {\n const kept: Record<string, string> = {};\n let any = false;\n for (const key of Object.keys(params)) {\n const value = params[key];\n if (value === null || value === undefined || value === '') continue;\n kept[key] = value;\n any = true;\n }\n if (any) out.params = kept;\n }\n return out;\n}\n\n/** A {@link G9SegmentInput} as a segment. */\nexport function toSegment(input: G9SegmentInput): G9Segment {\n return typeof input === 'string' ? { kind: input } : input;\n}\n\n/**\n * Parses an address strictly.\n * @throws {G9AddressError} for anything outside the grammar or its bounds ({@link g9AddressLimits}).\n */\nexport function parseAddress(text: string): G9Address {\n if (typeof text !== 'string' || text.charAt(0) !== '/') fail('not-absolute', 'An address starts with \"/\".');\n if (text.length > g9AddressLimits.length)\n fail('too-long', `An address is at most ${g9AddressLimits.length} characters.`);\n const hash = text.indexOf('#');\n const path = hash < 0 ? text : text.slice(0, hash);\n let target: string | undefined;\n if (hash >= 0) {\n const raw = text.slice(hash + 1);\n if (raw === '' || !RAW_TARGET.test(raw))\n fail('bad-char', 'The target has characters outside [A-Za-z0-9._-] and escapes.');\n target = decode(raw, 'The target');\n if (target.length > g9AddressLimits.target)\n fail('too-long', `The target is longer than ${g9AddressLimits.target}.`);\n }\n const body = path.slice(1);\n const parts = body === '' ? [] : body.split('/');\n if (parts.length > g9AddressLimits.depth)\n fail('too-deep', `An address has at most ${g9AddressLimits.depth} segments.`);\n const segments = parts.map((p, i) => {\n if (p === '') fail('empty-segment', `Segment ${i} is empty (\"//\" or a trailing \"/\").`);\n return parseSegment(p, i);\n });\n return target === undefined ? { segments } : { segments, target };\n}\n\n/** {@link parseAddress} without throwing. */\nexport function tryParseAddress(\n text: string,\n): { readonly ok: true; readonly address: G9Address } | { readonly ok: false; readonly error: G9AddressError } {\n try {\n return { ok: true, address: parseAddress(text) };\n } catch (error) {\n if (error instanceof G9AddressError) return { ok: false, error };\n throw error;\n }\n}\n\nfunction formatSegment(s: G9Segment): string {\n let out = s.kind + (s.variant ? `.${s.variant}` : '');\n if (s.id) out += `:${encode(s.id, SAFE_ID)}`;\n if (s.params) {\n for (const name of Object.keys(s.params).sort()) {\n const value = s.params[name];\n if (value) out += `;${name}=${encode(value, SAFE_VALUE)}`;\n }\n }\n return out;\n}\n\n/**\n * The canonical text of an address: parameters sorted by name, hex escapes upper case, no trailing \"/\". Two addresses\n * are the same address when their canonical texts are equal (ids are normalised by the catalogue, not here).\n */\nexport function formatAddress(address: G9Address | readonly G9Segment[]): string {\n const a: G9Address = isAddress(address) ? address : { segments: address };\n const path = `/${a.segments.map(formatSegment).join('/')}`;\n return a.target ? `${path}#${encode(a.target, SAFE_TARGET)}` : path;\n}\n\nfunction isAddress(x: G9Address | readonly G9Segment[]): x is G9Address {\n return !Array.isArray(x);\n}\n\nfunction asAddress(address: G9Address | string): G9Address {\n return typeof address === 'string' ? parseAddress(address) : address;\n}\n\n/** The general form: kinds and variants only (no ids, parameters or target). */\nexport function generalOf(address: G9Address | string): string {\n return formatAddress(asAddress(address).segments.map((s) => seg(s.kind, null, s.variant ?? null)));\n}\n\n/** Same kind, variant and id (parameters are view state, not identity). */\nexport function sameSegment(a: G9Segment, b: G9Segment): boolean {\n return a.kind === b.kind && (a.variant ?? '') === (b.variant ?? '') && (a.id ?? '') === (b.id ?? '');\n}\n\n/** Same kind, variant, id AND parameters. */\nexport function sameSegmentState(a: G9Segment, b: G9Segment): boolean {\n if (!sameSegment(a, b)) return false;\n const pa = a.params ?? {};\n const pb = b.params ?? {};\n const ka = Object.keys(pa);\n if (ka.length !== Object.keys(pb).length) return false;\n return ka.every((k) => pa[k] === pb[k]);\n}\n\ninterface PatternToken {\n readonly any: 'one' | 'many' | null;\n readonly kind?: string;\n readonly variant?: string;\n readonly needsId: boolean;\n}\n\nfunction patternTokens(pattern: string): PatternToken[] {\n const body = pattern.charAt(0) === '/' ? pattern.slice(1) : pattern;\n if (body === '') return [];\n return body.split('/').map((t) => {\n if (t === '**') return { any: 'many', needsId: false };\n if (t === '*') return { any: 'one', needsId: false };\n const needsId = t.slice(-2) === ':*';\n const name = needsId ? t.slice(0, -2) : t;\n const dot = name.indexOf('.');\n const kind = dot < 0 ? name : name.slice(0, dot);\n checkName(kind, 'A pattern kind', g9AddressLimits.kind);\n if (dot < 0) return { any: null, kind, needsId };\n const variant = name.slice(dot + 1);\n checkName(variant, 'A pattern variant', g9AddressLimits.kind);\n return { any: null, kind, variant, needsId };\n });\n}\n\nfunction tokenMatches(t: PatternToken, s: G9Segment): boolean {\n if (t.any === 'one') return true;\n if (t.kind !== s.kind) return false;\n if (t.variant !== undefined && t.variant !== s.variant) return false;\n return !t.needsId || !!s.id;\n}\n\nfunction matchFrom(tokens: readonly PatternToken[], ti: number, segments: readonly G9Segment[], si: number): boolean {\n if (ti === tokens.length) return si === segments.length;\n const t = tokens[ti] as PatternToken;\n if (t.any === 'many') {\n for (let k = si; k <= segments.length; k++) if (matchFrom(tokens, ti + 1, segments, k)) return true;\n return false;\n }\n const s = segments[si];\n return !!s && tokenMatches(t, s) && matchFrom(tokens, ti + 1, segments, si + 1);\n}\n\n/**\n * Whether an address matches a pattern of kinds: `/tasks/task.sampling/**/package`. A token is `kind`,\n * `kind.variant`, either with `:*` (an id is required), `*` (exactly one segment) or `**` (any number, also none).\n */\nexport function matchesAddress(address: G9Address | string, pattern: string): boolean {\n return matchFrom(patternTokens(pattern), 0, asAddress(address).segments, 0);\n}\n"],"names":["G9AddressError","G9Error","code","message","g9AddressLimits","Object","NAME","RAW_ID","RAW_VALUE","RAW_TARGET","SAFE_ID","SAFE_VALUE","SAFE_TARGET","CONTROL","ESCAPE","BAD_ESCAPE","fail","decode","raw","what","text","decodeURIComponent","hex2","h","encode","safe","out","ch","e","encodeURIComponent","checkName","name","max","parseSegment","index","_parts_","parts","head","colon","dot","kind","variant","id","params","seen","Set","i","_parts_i","p","eq","pname","value","seg","kept","any","key","toSegment","input","parseAddress","hash","path","target","body","segments","undefined","tryParseAddress","error","formatSegment","s","formatAddress","address","a","isAddress","x","Array","asAddress","generalOf","_s_variant","sameSegment","b","_a_variant","_b_variant","_a_id","_b_id","sameSegmentState","_a_params","_b_params","pa","pb","ka","k","patternTokens","pattern","t","need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AQC,KAAK,GAAGnC,UAAUoC,KAAK;AAC/E;AAMO,SAASC,eAAe9B,OAA2B,EAAEsB,OAAe;IACzE,OAAOI,UAAUL,cAAcC,UAAU,GAAGjB,UAAUL,SAAS,QAAQ,EAAE;AAC3E"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { G9Error } from '../errors.js';
|
|
2
|
+
import { type G9Address, type G9Segment } from './address.js';
|
|
3
|
+
/** How the ids of one kind look. */
|
|
4
|
+
export interface G9IdCodec {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
test(id: string): boolean;
|
|
7
|
+
/** The canonical text of a valid id. */
|
|
8
|
+
normalize(id: string): string;
|
|
9
|
+
}
|
|
10
|
+
/** A GUID, canonical in lower case. */
|
|
11
|
+
export declare const g9GuidCodec: G9IdCodec;
|
|
12
|
+
/** A codec from a pattern (and an optional normaliser; default: the id as it is). */
|
|
13
|
+
export declare function g9PatternCodec(name: string, pattern: RegExp, normalize?: (id: string) => string): G9IdCodec;
|
|
14
|
+
/** One view parameter of a place (`;q=…`, `;sort=due.desc`). */
|
|
15
|
+
export interface G9ParamDef {
|
|
16
|
+
/** `text`: free text ≤ maxLength · `enum`: one of `values` · `list`: comma-separated, each in `values` when given · `flag`: `1`. */
|
|
17
|
+
readonly type: 'text' | 'enum' | 'list' | 'flag';
|
|
18
|
+
readonly values?: readonly string[];
|
|
19
|
+
/** For `text` (default 64) and each `list` item (default 96). */
|
|
20
|
+
readonly maxLength?: number;
|
|
21
|
+
}
|
|
22
|
+
/** Why going to an address failed (or why a check refused it). */
|
|
23
|
+
export type G9GoFailure = 'bad-address' | 'unknown-kind' | 'not-allowed-here' | 'not-addressable' | 'not-found' | 'no-permission' | 'not-synced' | 'offline' | 'dirty' | 'blocked' | 'busy' | 'timeout' | 'cancelled' | 'superseded' | 'session-ended' | 'failed';
|
|
24
|
+
/** What a place's guard answers. `message` is shown to the person (their language). */
|
|
25
|
+
export type G9GuardResult = {
|
|
26
|
+
readonly ok: true;
|
|
27
|
+
} | {
|
|
28
|
+
readonly ok: false;
|
|
29
|
+
readonly reason: G9GoFailure;
|
|
30
|
+
readonly message?: string;
|
|
31
|
+
};
|
|
32
|
+
/** How a PERSON reaches a place from its parent: the control to tap there. */
|
|
33
|
+
export interface G9Entry {
|
|
34
|
+
/** The control's anchor id, in the parent place. */
|
|
35
|
+
readonly anchor: string;
|
|
36
|
+
readonly gesture?: 'tap' | 'longPress';
|
|
37
|
+
/** Makes the anchor reachable first (a filter that hides the row, a collapsed section). */
|
|
38
|
+
readonly prepare?: () => void | Promise<void>;
|
|
39
|
+
/** What the preparation does, for the person, when it changes what they see. */
|
|
40
|
+
readonly prepareText?: string;
|
|
41
|
+
}
|
|
42
|
+
/** Text in both languages (the catalogue's descriptions, journeys). */
|
|
43
|
+
export interface G9BilingualText {
|
|
44
|
+
readonly fa: string;
|
|
45
|
+
readonly en: string;
|
|
46
|
+
}
|
|
47
|
+
/** One kind of place. `Ctx` is what the app hands every callback (its session, services…). */
|
|
48
|
+
export interface G9PlaceDef<Ctx = unknown> {
|
|
49
|
+
readonly kind: string;
|
|
50
|
+
/** The allowed variants (`task.sampling`, `task.transfer`), or `'*'` for any. Absent = no variant. */
|
|
51
|
+
readonly variants?: readonly string[] | '*';
|
|
52
|
+
/** How the id looks. Absent = a singleton place: it never has an id. */
|
|
53
|
+
readonly id?: G9IdCodec;
|
|
54
|
+
/** Logical parents: kinds, `''` for the root, or `'*'` = a floating place (it may sit on any place, also the root). */
|
|
55
|
+
readonly parents: readonly string[] | '*';
|
|
56
|
+
/** The parent put in when the ancestors must be made up (a singleton chain to the root). Default: none. */
|
|
57
|
+
readonly defaultParent?: string;
|
|
58
|
+
readonly params?: Readonly<Record<string, G9ParamDef>>;
|
|
59
|
+
/** What this KIND is, for the general address, manifests and reports. */
|
|
60
|
+
readonly describe: G9BilingualText;
|
|
61
|
+
/** Breadcrumb text in the current language; may read the entity's own name through ctx. Never empty. */
|
|
62
|
+
title?(segment: G9Segment, ctx: Ctx): string;
|
|
63
|
+
/** Checks before anything is opened or closed: permission, the entity is on this device. */
|
|
64
|
+
guard?(segment: G9Segment, path: readonly G9Segment[], ctx: Ctx): G9GuardResult | Promise<G9GuardResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Opens the place the way the UI does; the router waits for its declaration. `false` = it could not open and the app
|
|
67
|
+
* already told the person why (a missing permission, data that never arrived): the go stops there at once. The wait
|
|
68
|
+
* for `open` itself counts toward `openTimeoutMs` — an `open` that never settles cannot hold the router.
|
|
69
|
+
*/
|
|
70
|
+
open?(segment: G9Segment, path: readonly G9Segment[], ctx: Ctx): void | boolean | Promise<void | boolean>;
|
|
71
|
+
/** How a person gets here from the parent (walk / demo). null = no visible entry: the router opens it itself. */
|
|
72
|
+
entry?(segment: G9Segment, path: readonly G9Segment[], ctx: Ctx): G9Entry | null | Promise<G9Entry | null>;
|
|
73
|
+
/** How long the router waits, from calling `open`, for the declaration (ms). Default 8000. */
|
|
74
|
+
readonly openTimeoutMs?: number;
|
|
75
|
+
}
|
|
76
|
+
/** The kinds the library adds to every catalogue: an undeclared sheet, map mode or page stays visible in the address. */
|
|
77
|
+
export declare const g9GenericKinds: readonly string[];
|
|
78
|
+
/** A structural check of one address against the catalogue. */
|
|
79
|
+
export type G9AddressCheck = {
|
|
80
|
+
readonly ok: true;
|
|
81
|
+
readonly address: G9Address;
|
|
82
|
+
} | {
|
|
83
|
+
readonly ok: false;
|
|
84
|
+
readonly reason: G9GoFailure;
|
|
85
|
+
readonly at: number;
|
|
86
|
+
readonly message: string;
|
|
87
|
+
};
|
|
88
|
+
/** The places of an app, validated: definitions, parents, made-up ancestors, structural checks of an address. */
|
|
89
|
+
export interface G9Catalogue<Ctx = unknown> {
|
|
90
|
+
def(kind: string): G9PlaceDef<Ctx> | undefined;
|
|
91
|
+
kinds(): readonly string[];
|
|
92
|
+
/** A short hash of the structure (kinds, variants, ids, parents): a snapshot is refused across a different one. */
|
|
93
|
+
readonly hash: string;
|
|
94
|
+
/** Is `kind` allowed directly under `parentKind` (`''` = the root)? */
|
|
95
|
+
allowsParent(kind: string, parentKind: string): boolean;
|
|
96
|
+
/** The made-up ancestors of a kind (root first), through `defaultParent`; null when it does not reach the root. */
|
|
97
|
+
defaultAncestors(kind: string): readonly G9Segment[] | null;
|
|
98
|
+
/** Validates and canonicalises a UNIQUE address (ids through their codecs). */
|
|
99
|
+
check(address: G9Address): G9AddressCheck;
|
|
100
|
+
/** The breadcrumb of one segment: the def's title, else its description in `language`. */
|
|
101
|
+
title(segment: G9Segment, ctx: Ctx, language: 'fa' | 'en'): string;
|
|
102
|
+
}
|
|
103
|
+
/** A catalogue that cannot work (a developer error: raised at start-up, never at run time). */
|
|
104
|
+
export declare class G9CatalogueError extends G9Error {
|
|
105
|
+
constructor(message: string);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Builds a catalogue and validates it: unique kinds, names in the grammar, known parents, a `defaultParent` that is a
|
|
109
|
+
* parent and leads to the root through singletons, no cycles. The generic kinds are added.
|
|
110
|
+
* @throws {G9CatalogueError} on any inconsistency.
|
|
111
|
+
*/
|
|
112
|
+
export declare function createCatalogue<Ctx = unknown>(defs: ReadonlyArray<G9PlaceDef<Ctx>>): G9Catalogue<Ctx>;
|
|
113
|
+
/** One kind as a manifest lists it (an assistant's or a QA tool's view of the catalogue). */
|
|
114
|
+
export interface G9CatalogueManifestEntry {
|
|
115
|
+
readonly kind: string;
|
|
116
|
+
readonly variants: readonly string[] | '*' | null;
|
|
117
|
+
readonly id: string | null;
|
|
118
|
+
readonly parents: readonly string[] | '*';
|
|
119
|
+
readonly params: Readonly<Record<string, {
|
|
120
|
+
readonly type: G9ParamDef['type'];
|
|
121
|
+
readonly values?: readonly string[];
|
|
122
|
+
}>>;
|
|
123
|
+
readonly describe: string;
|
|
124
|
+
readonly opens: boolean;
|
|
125
|
+
readonly reachable: boolean;
|
|
126
|
+
/** An example general address of this kind (through its default ancestors), or null. */
|
|
127
|
+
readonly example: string | null;
|
|
128
|
+
}
|
|
129
|
+
/** The catalogue as data (JSON-safe), in one language. */
|
|
130
|
+
export declare function catalogueManifest<Ctx>(catalogue: G9Catalogue<Ctx>, language: 'fa' | 'en'): readonly G9CatalogueManifestEntry[];
|
|
131
|
+
//# sourceMappingURL=catalogue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogue.d.ts","sourceRoot":"","sources":["../../src/route/catalogue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAwB,MAAM,WAAW,CAAC;AAOjF,oCAAoC;AACpC,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,wCAAwC;IACxC,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;CAC/B;AAID,uCAAuC;AACvC,eAAO,MAAM,WAAW,EAAE,SAIxB,CAAC;AAEH,qFAAqF;AACrF,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAmB,GAC7C,SAAS,CAEX;AAED,gEAAgE;AAChE,MAAM,WAAW,UAAU;IACzB,oIAAoI;IACpI,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACjD,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,iEAAiE;IACjE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,kEAAkE;AAClE,MAAM,MAAM,WAAW,GACnB,aAAa,GACb,cAAc,GACd,kBAAkB,GAClB,iBAAiB,GACjB,WAAW,GACX,eAAe,GACf,YAAY,GACZ,S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,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC,CAAC;IACtH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,wFAAwF;IACxF,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED,0DAA0D;AAC1D,wBAAgB,iBAAiB,CAAC,GAAG,EACnC,SAAS,EAAE,WAAW,CAAC,GAAG,CAAC,EAC3B,QAAQ,EAAE,IAAI,GAAG,IAAI,GACpB,SAAS,wBAAwB,EAAE,CAoBrC"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { G9Error } from "../errors.js";
|
|
2
|
+
import { g9AddressLimits, seg } from "./address.js";
|
|
3
|
+
const GUID = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
4
|
+
const g9GuidCodec = Object.freeze({
|
|
5
|
+
name: 'guid',
|
|
6
|
+
test: (id)=>GUID.test(id),
|
|
7
|
+
normalize: (id)=>id.toLowerCase()
|
|
8
|
+
});
|
|
9
|
+
function g9PatternCodec(name, pattern, normalize = (id)=>id) {
|
|
10
|
+
return Object.freeze({
|
|
11
|
+
name,
|
|
12
|
+
test: (id)=>pattern.test(id),
|
|
13
|
+
normalize
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
const g9GenericKinds = Object.freeze([
|
|
17
|
+
'sheet',
|
|
18
|
+
'mode',
|
|
19
|
+
'page'
|
|
20
|
+
]);
|
|
21
|
+
class G9CatalogueError extends G9Error {
|
|
22
|
+
constructor(message){
|
|
23
|
+
super('route-catalogue', message);
|
|
24
|
+
this.name = 'G9CatalogueError';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const NAME = /^[a-z][a-z0-9-]*$/;
|
|
28
|
+
function genericDef(kind) {
|
|
29
|
+
const describe = {
|
|
30
|
+
sheet: {
|
|
31
|
+
fa: 'برگه',
|
|
32
|
+
en: 'Sheet'
|
|
33
|
+
},
|
|
34
|
+
mode: {
|
|
35
|
+
fa: 'حالت نقشه',
|
|
36
|
+
en: 'Map mode'
|
|
37
|
+
},
|
|
38
|
+
page: {
|
|
39
|
+
fa: 'صفحه',
|
|
40
|
+
en: 'Page'
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
kind,
|
|
45
|
+
variants: '*',
|
|
46
|
+
parents: '*',
|
|
47
|
+
describe: describe[kind]
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function fnv1a(text) {
|
|
51
|
+
let h = 0x811c9dc5;
|
|
52
|
+
for(let i = 0; i < text.length; i++){
|
|
53
|
+
h ^= text.charCodeAt(i);
|
|
54
|
+
h = Math.imul(h, 0x01000193) >>> 0;
|
|
55
|
+
}
|
|
56
|
+
return h.toString(16).padStart(8, '0');
|
|
57
|
+
}
|
|
58
|
+
function checkParam(def, value) {
|
|
59
|
+
switch(def.type){
|
|
60
|
+
case 'flag':
|
|
61
|
+
return '1' === value;
|
|
62
|
+
case 'enum':
|
|
63
|
+
return !!def.values && def.values.indexOf(value) >= 0;
|
|
64
|
+
case 'list':
|
|
65
|
+
return value.split(',').every((item)=>{
|
|
66
|
+
var _def_maxLength;
|
|
67
|
+
return '' !== item && item.length <= (null != (_def_maxLength = def.maxLength) ? _def_maxLength : 96) && (!def.values || def.values.indexOf(item) >= 0);
|
|
68
|
+
});
|
|
69
|
+
default:
|
|
70
|
+
var _def_maxLength;
|
|
71
|
+
return value.length <= (null != (_def_maxLength = def.maxLength) ? _def_maxLength : 64);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function createCatalogue(defs) {
|
|
75
|
+
const map = new Map();
|
|
76
|
+
for (const def of defs){
|
|
77
|
+
if (!NAME.test(def.kind) || def.kind.length > g9AddressLimits.kind) throw new G9CatalogueError(`Kind "${def.kind}" is not a valid name.`);
|
|
78
|
+
if (map.has(def.kind) || g9GenericKinds.indexOf(def.kind) >= 0) throw new G9CatalogueError(`Kind "${def.kind}" is defined twice (or is a generic kind).`);
|
|
79
|
+
if (Array.isArray(def.variants)) {
|
|
80
|
+
for (const v of def.variants)if (!NAME.test(v)) throw new G9CatalogueError(`Variant "${def.kind}.${v}" is not a valid name.`);
|
|
81
|
+
}
|
|
82
|
+
if (def.params) {
|
|
83
|
+
for (const p of Object.keys(def.params))if (!NAME.test(p)) throw new G9CatalogueError(`Parameter "${def.kind};${p}" is not a valid name.`);
|
|
84
|
+
}
|
|
85
|
+
map.set(def.kind, def);
|
|
86
|
+
}
|
|
87
|
+
for (const kind of g9GenericKinds)map.set(kind, genericDef(kind));
|
|
88
|
+
for (const def of map.values())if ('*' !== def.parents) {
|
|
89
|
+
for (const parent of def.parents)if ('' !== parent && !map.has(parent)) throw new G9CatalogueError(`Kind "${def.kind}" names an unknown parent "${parent}".`);
|
|
90
|
+
}
|
|
91
|
+
const ancestors = new Map();
|
|
92
|
+
function chain(kind, seen) {
|
|
93
|
+
const cached = ancestors.get(kind);
|
|
94
|
+
if (void 0 !== cached) return cached;
|
|
95
|
+
if (seen.indexOf(kind) >= 0) throw new G9CatalogueError(`defaultParent cycle: ${[
|
|
96
|
+
...seen,
|
|
97
|
+
kind
|
|
98
|
+
].join(' → ')}.`);
|
|
99
|
+
const def = map.get(kind);
|
|
100
|
+
let result = null;
|
|
101
|
+
if ('*' !== def.parents && def.parents.indexOf('') >= 0) result = [];
|
|
102
|
+
else if (void 0 !== def.defaultParent) {
|
|
103
|
+
const parent = map.get(def.defaultParent);
|
|
104
|
+
if (!parent) throw new G9CatalogueError(`Kind "${kind}" has an unknown defaultParent "${def.defaultParent}".`);
|
|
105
|
+
if ('*' !== def.parents && def.parents.indexOf(def.defaultParent) < 0) throw new G9CatalogueError(`Kind "${kind}": defaultParent "${def.defaultParent}" is not one of its parents.`);
|
|
106
|
+
if (parent.id) throw new G9CatalogueError(`Kind "${kind}": defaultParent "${def.defaultParent}" has an id, so it cannot be made up.`);
|
|
107
|
+
const up = chain(def.defaultParent, [
|
|
108
|
+
...seen,
|
|
109
|
+
kind
|
|
110
|
+
]);
|
|
111
|
+
result = up ? [
|
|
112
|
+
...up,
|
|
113
|
+
seg(def.defaultParent)
|
|
114
|
+
] : null;
|
|
115
|
+
if (!up) throw new G9CatalogueError(`Kind "${kind}": defaultParent "${def.defaultParent}" does not lead to the root.`);
|
|
116
|
+
}
|
|
117
|
+
ancestors.set(kind, result);
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
for (const kind of map.keys())chain(kind, []);
|
|
121
|
+
const kinds = Array.from(map.keys()).sort();
|
|
122
|
+
const hash = fnv1a(kinds.map((k)=>{
|
|
123
|
+
var _d_variants, _ref;
|
|
124
|
+
var _d_id;
|
|
125
|
+
const d = map.get(k);
|
|
126
|
+
const variants = '*' === d.variants ? '*' : (null != (_d_variants = d.variants) ? _d_variants : []).slice().sort().join(',');
|
|
127
|
+
const parents = '*' === d.parents ? '*' : d.parents.slice().sort().join(',');
|
|
128
|
+
return `${k}|${variants}|${null != (_ref = null == (_d_id = d.id) ? void 0 : _d_id.name) ? _ref : ''}|${parents}`;
|
|
129
|
+
}).join(';'));
|
|
130
|
+
const allowsParent = (kind, parentKind)=>{
|
|
131
|
+
const def = map.get(kind);
|
|
132
|
+
if (!def) return false;
|
|
133
|
+
if ('*' === def.parents) return true;
|
|
134
|
+
return def.parents.indexOf(parentKind) >= 0;
|
|
135
|
+
};
|
|
136
|
+
return {
|
|
137
|
+
def: (kind)=>map.get(kind),
|
|
138
|
+
kinds: ()=>kinds,
|
|
139
|
+
hash,
|
|
140
|
+
allowsParent,
|
|
141
|
+
defaultAncestors: (kind)=>{
|
|
142
|
+
var _ancestors_get;
|
|
143
|
+
return map.has(kind) ? null != (_ancestors_get = ancestors.get(kind)) ? _ancestors_get : null : null;
|
|
144
|
+
},
|
|
145
|
+
check (address) {
|
|
146
|
+
const out = [];
|
|
147
|
+
for(let i = 0; i < address.segments.length; i++){
|
|
148
|
+
var _s_variant, _s_params;
|
|
149
|
+
const s = address.segments[i];
|
|
150
|
+
const def = map.get(s.kind);
|
|
151
|
+
const refuse = (reason, message)=>({
|
|
152
|
+
ok: false,
|
|
153
|
+
reason,
|
|
154
|
+
at: i,
|
|
155
|
+
message
|
|
156
|
+
});
|
|
157
|
+
if (!def) return refuse('unknown-kind', `"${s.kind}" is not a place of this app.`);
|
|
158
|
+
if (void 0 !== s.variant) {
|
|
159
|
+
if (void 0 === def.variants) return refuse('bad-address', `"${s.kind}" takes no variant.`);
|
|
160
|
+
if ('*' !== def.variants && def.variants.indexOf(s.variant) < 0) return refuse('bad-address', `"${s.kind}.${s.variant}" is not a known variant.`);
|
|
161
|
+
}
|
|
162
|
+
let id = s.id;
|
|
163
|
+
if (def.id) {
|
|
164
|
+
if (!id) return refuse('bad-address', `"${s.kind}" needs an id.`);
|
|
165
|
+
if (!def.id.test(id)) return refuse('bad-address', `"${id}" is not a ${def.id.name} (${s.kind}).`);
|
|
166
|
+
id = def.id.normalize(id);
|
|
167
|
+
} else if (id) return refuse('bad-address', `"${s.kind}" takes no id.`);
|
|
168
|
+
if (s.params) for (const name of Object.keys(s.params)){
|
|
169
|
+
var _def_params;
|
|
170
|
+
const p = null == (_def_params = def.params) ? void 0 : _def_params[name];
|
|
171
|
+
if (!p) return refuse('bad-address', `"${s.kind}" has no parameter "${name}".`);
|
|
172
|
+
if (!checkParam(p, s.params[name])) return refuse('bad-address', `"${s.kind};${name}" has a value it does not take.`);
|
|
173
|
+
}
|
|
174
|
+
const parent = 0 === i ? '' : address.segments[i - 1].kind;
|
|
175
|
+
if (!allowsParent(s.kind, parent)) return refuse('not-allowed-here', `"${s.kind}" cannot sit ${0 === i ? 'at the root' : `under "${parent}"`}.`);
|
|
176
|
+
out.push(seg(s.kind, null != id ? id : null, null != (_s_variant = s.variant) ? _s_variant : null, null != (_s_params = s.params) ? _s_params : null));
|
|
177
|
+
}
|
|
178
|
+
const canonical = void 0 === address.target ? {
|
|
179
|
+
segments: out
|
|
180
|
+
} : {
|
|
181
|
+
segments: out,
|
|
182
|
+
target: address.target
|
|
183
|
+
};
|
|
184
|
+
return {
|
|
185
|
+
ok: true,
|
|
186
|
+
address: canonical
|
|
187
|
+
};
|
|
188
|
+
},
|
|
189
|
+
title (segment, ctx, language) {
|
|
190
|
+
const def = map.get(segment.kind);
|
|
191
|
+
if (!def) return segment.kind;
|
|
192
|
+
let text = '';
|
|
193
|
+
try {
|
|
194
|
+
var _ref;
|
|
195
|
+
var _def_title;
|
|
196
|
+
text = null != (_ref = null == (_def_title = def.title) ? void 0 : _def_title.call(def, segment, ctx)) ? _ref : '';
|
|
197
|
+
} catch {
|
|
198
|
+
text = '';
|
|
199
|
+
}
|
|
200
|
+
return text.trim() || def.describe[language];
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function catalogueManifest(catalogue, language) {
|
|
205
|
+
return catalogue.kinds().map((kind)=>{
|
|
206
|
+
var _def_params, _def_variants, _ref;
|
|
207
|
+
var _def_id;
|
|
208
|
+
const def = catalogue.def(kind);
|
|
209
|
+
const params = {};
|
|
210
|
+
for (const [name, p] of Object.entries(null != (_def_params = def.params) ? _def_params : {}))params[name] = p.values ? {
|
|
211
|
+
type: p.type,
|
|
212
|
+
values: p.values
|
|
213
|
+
} : {
|
|
214
|
+
type: p.type
|
|
215
|
+
};
|
|
216
|
+
const up = catalogue.defaultAncestors(kind);
|
|
217
|
+
const example = up ? `/${[
|
|
218
|
+
...up.map((s)=>s.kind),
|
|
219
|
+
kind
|
|
220
|
+
].join('/')}` : null;
|
|
221
|
+
return {
|
|
222
|
+
kind,
|
|
223
|
+
variants: null != (_def_variants = def.variants) ? _def_variants : null,
|
|
224
|
+
id: null != (_ref = null == (_def_id = def.id) ? void 0 : _def_id.name) ? _ref : null,
|
|
225
|
+
parents: def.parents,
|
|
226
|
+
params,
|
|
227
|
+
describe: def.describe[language],
|
|
228
|
+
opens: 'function' == typeof def.open,
|
|
229
|
+
reachable: 'function' == typeof def.entry,
|
|
230
|
+
example
|
|
231
|
+
};
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
export { G9CatalogueError, catalogueManifest, createCatalogue, g9GenericKinds, g9GuidCodec, g9PatternCodec };
|
|
235
|
+
|
|
236
|
+
//# sourceMappingURL=catalogue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route/catalogue.js","sources":["../../src/route/catalogue.ts"],"sourcesContent":["import { G9Error } from '../errors';\nimport { type G9Address, type G9Segment, g9AddressLimits, seg } from './address';\n\n// The catalogue of places: which kinds of place an app has, where each may sit (its logical parents), how its id looks,\n// which view parameters it takes, and — supplied by the app — how to check, open and reach one. The router and every\n// consumer (QA, tester reports, links, an assistant) read the same catalogue; the library itself knows no kind but the\n// three generic ones (`sheet`, `mode`, `page`) that keep an undeclared overlay visible in the address.\n\n/** How the ids of one kind look. */\nexport interface G9IdCodec {\n readonly name: string;\n test(id: string): boolean;\n /** The canonical text of a valid id. */\n normalize(id: string): string;\n}\n\nconst GUID = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;\n\n/** A GUID, canonical in lower case. */\nexport const g9GuidCodec: G9IdCodec = Object.freeze({\n name: 'guid',\n test: (id: string) => GUID.test(id),\n normalize: (id: string) => id.toLowerCase(),\n});\n\n/** A codec from a pattern (and an optional normaliser; default: the id as it is). */\nexport function g9PatternCodec(\n name: string,\n pattern: RegExp,\n normalize: (id: string) => string = (id) => id,\n): G9IdCodec {\n return Object.freeze({ name, test: (id: string) => pattern.test(id), normalize });\n}\n\n/** One view parameter of a place (`;q=…`, `;sort=due.desc`). */\nexport interface G9ParamDef {\n /** `text`: free text ≤ maxLength · `enum`: one of `values` · `list`: comma-separated, each in `values` when given · `flag`: `1`. */\n readonly type: 'text' | 'enum' | 'list' | 'flag';\n readonly values?: readonly string[];\n /** For `text` (default 64) and each `list` item (default 96). */\n readonly maxLength?: number;\n}\n\n/** Why going to an address failed (or why a check refused it). */\nexport type G9GoFailure =\n | 'bad-address'\n | 'unknown-kind'\n | 'not-allowed-here'\n | 'not-addressable'\n | 'not-found'\n | 'no-permission'\n | 'not-synced'\n | 'offline'\n | 'dirty'\n | 'blocked'\n | 'busy'\n | 'timeout'\n | 'cancelled'\n | 'superseded'\n | 'session-ended'\n | 'failed';\n\n/** What a place's guard answers. `message` is shown to the person (their language). */\nexport type G9GuardResult =\n | { readonly ok: true }\n | { readonly ok: false; readonly reason: G9GoFailure; readonly message?: string };\n\n/** How a PERSON reaches a place from its parent: the control to tap there. */\nexport interface G9Entry {\n /** The control's anchor id, in the parent place. */\n readonly anchor: string;\n readonly gesture?: 'tap' | 'longPress';\n /** Makes the anchor reachable first (a filter that hides the row, a collapsed section). */\n readonly prepare?: () => void | Promise<void>;\n /** What the preparation does, for the person, when it changes what they see. */\n readonly prepareText?: string;\n}\n\n/** Text in both languages (the catalogue's descriptions, journeys). */\nexport interface G9BilingualText {\n readonly fa: string;\n readonly en: string;\n}\n\n/** One kind of place. `Ctx` is what the app hands every callback (its session, services…). */\nexport interface G9PlaceDef<Ctx = unknown> {\n readonly kind: string;\n /** The allowed variants (`task.sampling`, `task.transfer`), or `'*'` for any. Absent = no variant. */\n readonly variants?: readonly string[] | '*';\n /** How the id looks. Absent = a singleton place: it never has an id. */\n readonly id?: G9IdCodec;\n /** Logical parents: kinds, `''` for the root, or `'*'` = a floating place (it may sit on any place, also the root). */\n readonly parents: readonly string[] | '*';\n /** The parent put in when the ancestors must be made up (a singleton chain to the root). Default: none. */\n readonly defaultParent?: string;\n readonly params?: Readonly<Record<string, G9ParamDef>>;\n /** What this KIND is, for the general address, manifests and reports. */\n readonly describe: G9BilingualText;\n /** Breadcrumb text in the current language; may read the entity's own name through ctx. Never empty. */\n title?(segment: G9Segment, ctx: Ctx): string;\n /** Checks before anything is opened or closed: permission, the entity is on this device. */\n guard?(segment: G9Segment, path: readonly G9Segment[], ctx: Ctx): G9GuardResult | Promise<G9GuardResult>;\n /**\n * Opens the place the way the UI does; the router waits for its declaration. `false` = it could not open and the app\n * already told the person why (a missing permission, data that never arrived): the go stops there at once. The wait\n * for `open` itself counts toward `openTimeoutMs` — an `open` that never settles cannot hold the router.\n */\n open?(segment: G9Segment, path: readonly G9Segment[], ctx: Ctx): void | boolean | Promise<void | boolean>;\n /** How a person gets here from the parent (walk / demo). null = no visible entry: the router opens it itself. */\n entry?(segment: G9Segment, path: readonly G9Segment[], ctx: Ctx): G9Entry | null | Promise<G9Entry | null>;\n /** How long the router waits, from calling `open`, for the declaration (ms). Default 8000. */\n readonly openTimeoutMs?: number;\n}\n\n/** The kinds the library adds to every catalogue: an undeclared sheet, map mode or page stays visible in the address. */\nexport const g9GenericKinds: readonly string[] = Object.freeze(['sheet', 'mode', 'page']);\n\n/** A structural check of one address against the catalogue. */\nexport type G9AddressCheck =\n | { readonly ok: true; readonly address: G9Address }\n | { readonly ok: false; readonly reason: G9GoFailure; readonly at: number; readonly message: string };\n\n/** The places of an app, validated: definitions, parents, made-up ancestors, structural checks of an address. */\nexport interface G9Catalogue<Ctx = unknown> {\n def(kind: string): G9PlaceDef<Ctx> | undefined;\n kinds(): readonly string[];\n /** A short hash of the structure (kinds, variants, ids, parents): a snapshot is refused across a different one. */\n readonly hash: string;\n /** Is `kind` allowed directly under `parentKind` (`''` = the root)? */\n allowsParent(kind: string, parentKind: string): boolean;\n /** The made-up ancestors of a kind (root first), through `defaultParent`; null when it does not reach the root. */\n defaultAncestors(kind: string): readonly G9Segment[] | null;\n /** Validates and canonicalises a UNIQUE address (ids through their codecs). */\n check(address: G9Address): G9AddressCheck;\n /** The breadcrumb of one segment: the def's title, else its description in `language`. */\n title(segment: G9Segment, ctx: Ctx, language: 'fa' | 'en'): string;\n}\n\n/** A catalogue that cannot work (a developer error: raised at start-up, never at run time). */\nexport class G9CatalogueError extends G9Error {\n constructor(message: string) {\n super('route-catalogue', message);\n this.name = 'G9CatalogueError';\n }\n}\n\nconst NAME = /^[a-z][a-z0-9-]*$/;\n\nfunction genericDef<Ctx>(kind: string): G9PlaceDef<Ctx> {\n const describe: Record<string, G9BilingualText> = {\n sheet: { fa: 'برگه', en: 'Sheet' },\n mode: { fa: 'حالت نقشه', en: 'Map mode' },\n page: { fa: 'صفحه', en: 'Page' },\n };\n return { kind, variants: '*', parents: '*', describe: describe[kind] as G9BilingualText };\n}\n\nfunction fnv1a(text: string): string {\n let h = 0x811c9dc5;\n for (let i = 0; i < text.length; i++) {\n h ^= text.charCodeAt(i);\n h = Math.imul(h, 0x01000193) >>> 0;\n }\n return h.toString(16).padStart(8, '0');\n}\n\nfunction checkParam(def: G9ParamDef, value: string): boolean {\n switch (def.type) {\n case 'flag':\n return value === '1';\n case 'enum':\n return !!def.values && def.values.indexOf(value) >= 0;\n case 'list':\n return value\n .split(',')\n .every(\n (item) =>\n item !== '' && item.length <= (def.maxLength ?? 96) && (!def.values || def.values.indexOf(item) >= 0),\n );\n default:\n return value.length <= (def.maxLength ?? 64);\n }\n}\n\n/**\n * Builds a catalogue and validates it: unique kinds, names in the grammar, known parents, a `defaultParent` that is a\n * parent and leads to the root through singletons, no cycles. The generic kinds are added.\n * @throws {G9CatalogueError} on any inconsistency.\n */\nexport function createCatalogue<Ctx = unknown>(defs: ReadonlyArray<G9PlaceDef<Ctx>>): G9Catalogue<Ctx> {\n const map = new Map<string, G9PlaceDef<Ctx>>();\n for (const def of defs) {\n if (!NAME.test(def.kind) || def.kind.length > g9AddressLimits.kind)\n throw new G9CatalogueError(`Kind \"${def.kind}\" is not a valid name.`);\n if (map.has(def.kind) || g9GenericKinds.indexOf(def.kind) >= 0)\n throw new G9CatalogueError(`Kind \"${def.kind}\" is defined twice (or is a generic kind).`);\n if (Array.isArray(def.variants))\n for (const v of def.variants)\n if (!NAME.test(v)) throw new G9CatalogueError(`Variant \"${def.kind}.${v}\" is not a valid name.`);\n if (def.params)\n for (const p of Object.keys(def.params))\n if (!NAME.test(p)) throw new G9CatalogueError(`Parameter \"${def.kind};${p}\" is not a valid name.`);\n map.set(def.kind, def);\n }\n for (const kind of g9GenericKinds) map.set(kind, genericDef<Ctx>(kind));\n\n for (const def of map.values()) {\n if (def.parents === '*') continue;\n for (const parent of def.parents) {\n if (parent !== '' && !map.has(parent))\n throw new G9CatalogueError(`Kind \"${def.kind}\" names an unknown parent \"${parent}\".`);\n }\n }\n\n const ancestors = new Map<string, readonly G9Segment[] | null>();\n function chain(kind: string, seen: readonly string[]): readonly G9Segment[] | null {\n const cached = ancestors.get(kind);\n if (cached !== undefined) return cached;\n if (seen.indexOf(kind) >= 0) throw new G9CatalogueError(`defaultParent cycle: ${[...seen, kind].join(' → ')}.`);\n const def = map.get(kind) as G9PlaceDef<Ctx>;\n let result: readonly G9Segment[] | null = null;\n if (def.parents !== '*' && def.parents.indexOf('') >= 0) result = [];\n else if (def.defaultParent !== undefined) {\n const parent = map.get(def.defaultParent);\n if (!parent) throw new G9CatalogueError(`Kind \"${kind}\" has an unknown defaultParent \"${def.defaultParent}\".`);\n if (def.parents !== '*' && def.parents.indexOf(def.defaultParent) < 0) {\n throw new G9CatalogueError(`Kind \"${kind}\": defaultParent \"${def.defaultParent}\" is not one of its parents.`);\n }\n if (parent.id)\n throw new G9CatalogueError(\n `Kind \"${kind}\": defaultParent \"${def.defaultParent}\" has an id, so it cannot be made up.`,\n );\n const up = chain(def.defaultParent, [...seen, kind]);\n result = up ? [...up, seg(def.defaultParent)] : null;\n if (!up)\n throw new G9CatalogueError(`Kind \"${kind}\": defaultParent \"${def.defaultParent}\" does not lead to the root.`);\n }\n ancestors.set(kind, result);\n return result;\n }\n for (const kind of map.keys()) chain(kind, []);\n\n const kinds = Array.from(map.keys()).sort();\n const hash = fnv1a(\n kinds\n .map((k) => {\n const d = map.get(k) as G9PlaceDef<Ctx>;\n const variants = d.variants === '*' ? '*' : (d.variants ?? []).slice().sort().join(',');\n const parents = d.parents === '*' ? '*' : d.parents.slice().sort().join(',');\n return `${k}|${variants}|${d.id?.name ?? ''}|${parents}`;\n })\n .join(';'),\n );\n\n const allowsParent = (kind: string, parentKind: string): boolean => {\n const def = map.get(kind);\n if (!def) return false;\n if (def.parents === '*') return true;\n return def.parents.indexOf(parentKind) >= 0;\n };\n\n return {\n def: (kind) => map.get(kind),\n kinds: () => kinds,\n hash,\n allowsParent,\n defaultAncestors: (kind) => (map.has(kind) ? (ancestors.get(kind) ?? null) : null),\n check(address) {\n const out: G9Segment[] = [];\n for (let i = 0; i < address.segments.length; i++) {\n const s = address.segments[i] as G9Segment;\n const def = map.get(s.kind);\n const refuse = (reason: G9GoFailure, message: string): G9AddressCheck => ({\n ok: false,\n reason,\n at: i,\n message,\n });\n if (!def) return refuse('unknown-kind', `\"${s.kind}\" is not a place of this app.`);\n if (s.variant !== undefined) {\n if (def.variants === undefined) return refuse('bad-address', `\"${s.kind}\" takes no variant.`);\n if (def.variants !== '*' && def.variants.indexOf(s.variant) < 0)\n return refuse('bad-address', `\"${s.kind}.${s.variant}\" is not a known variant.`);\n }\n let id = s.id;\n if (def.id) {\n if (!id) return refuse('bad-address', `\"${s.kind}\" needs an id.`);\n if (!def.id.test(id)) return refuse('bad-address', `\"${id}\" is not a ${def.id.name} (${s.kind}).`);\n id = def.id.normalize(id);\n } else if (id) return refuse('bad-address', `\"${s.kind}\" takes no id.`);\n if (s.params) {\n for (const name of Object.keys(s.params)) {\n const p = def.params?.[name];\n if (!p) return refuse('bad-address', `\"${s.kind}\" has no parameter \"${name}\".`);\n if (!checkParam(p, s.params[name] as string))\n return refuse('bad-address', `\"${s.kind};${name}\" has a value it does not take.`);\n }\n }\n const parent = i === 0 ? '' : (address.segments[i - 1] as G9Segment).kind;\n if (!allowsParent(s.kind, parent))\n return refuse('not-allowed-here', `\"${s.kind}\" cannot sit ${i === 0 ? 'at the root' : `under \"${parent}\"`}.`);\n out.push(seg(s.kind, id ?? null, s.variant ?? null, s.params ?? null));\n }\n const canonical: G9Address =\n address.target === undefined ? { segments: out } : { segments: out, target: address.target };\n return { ok: true, address: canonical };\n },\n title(segment, ctx, language) {\n const def = map.get(segment.kind);\n if (!def) return segment.kind;\n let text = '';\n try {\n text = def.title?.(segment, ctx) ?? '';\n } catch {\n text = '';\n }\n return text.trim() || def.describe[language];\n },\n };\n}\n\n/** One kind as a manifest lists it (an assistant's or a QA tool's view of the catalogue). */\nexport interface G9CatalogueManifestEntry {\n readonly kind: string;\n readonly variants: readonly string[] | '*' | null;\n readonly id: string | null;\n readonly parents: readonly string[] | '*';\n readonly params: Readonly<Record<string, { readonly type: G9ParamDef['type']; readonly values?: readonly string[] }>>;\n readonly describe: string;\n readonly opens: boolean;\n readonly reachable: boolean;\n /** An example general address of this kind (through its default ancestors), or null. */\n readonly example: string | null;\n}\n\n/** The catalogue as data (JSON-safe), in one language. */\nexport function catalogueManifest<Ctx>(\n catalogue: G9Catalogue<Ctx>,\n language: 'fa' | 'en',\n): readonly G9CatalogueManifestEntry[] {\n return catalogue.kinds().map((kind) => {\n const def = catalogue.def(kind) as G9PlaceDef<Ctx>;\n const params: Record<string, { type: G9ParamDef['type']; values?: readonly string[] }> = {};\n for (const [name, p] of Object.entries(def.params ?? {}))\n params[name] = p.values ? { type: p.type, values: p.values } : { type: p.type };\n const up = catalogue.defaultAncestors(kind);\n const example = up ? `/${[...up.map((s) => s.kind), kind].join('/')}` : null;\n return {\n kind,\n variants: def.variants ?? null,\n id: def.id?.name ?? null,\n parents: def.parents,\n params,\n describe: def.describe[language],\n opens: typeof def.open === 'function',\n reachable: typeof def.entry === 'function',\n example,\n };\n });\n}\n"],"names":["GUID","g9GuidCodec","Object","id","g9PatternCodec","name","pattern","normalize","g9GenericKinds","G9CatalogueError","G9Error","message","NAME","genericDef","kind","describe","fnv1a","text","h","i","Math","checkParam","def","value","item","_def_maxLength","createCatalogue","defs","map","Map","g9AddressLimits","Array","v","p","parent","ancestors","chain","seen","cached","undefined","result","up","seg","kinds","hash","k","_d_variants","_d_id","d","variants","parents","allowsParent","parentKind","_ancestors_get","address","out","_s_variant","_s_params","s","refuse","reason","_def_params","canonical","segment","ctx","language","catalogueManifest","catalogue","_def_variants","_def_id","params","example"],"mappings":";;AAgBA,MAAMA,OAAO;AAGN,MAAMC,cAAyBC,OAAO,MAAM,CAAC;IAClD,MAAM;IACN,MAAM,CAACC,KAAeH,KAAK,IAAI,CAACG;IAChC,WAAW,CAACA,KAAeA,GAAG,WAAW;AAC3C;AAGO,SAASC,eACdC,IAAY,EACZC,OAAe,EACfC,YAAoC,CAACJ,KAAOA,EAAE;IAE9C,OAAOD,OAAO,MAAM,CAAC;QAAEG;QAAM,MAAM,CAACF,KAAeG,QAAQ,IAAI,CAACH;QAAKI;IAAU;AACjF;AAmFO,MAAMC,iBAAoCN,OAAO,MAAM,CAAC;IAAC;IAAS;IAAQ;CAAO;AAwBjF,MAAMO,yBAAyBC;IACpC,YAAYC,OAAe,CAAE;QAC3B,KAAK,CAAC,mBAAmBA;QACzB,IAAI,CAAC,IAAI,GAAG;IACd;AACF;AAEA,MAAMC,OAAO;AAEb,SAASC,WAAgBC,IAAY;IACnC,MAAMC,WAA4C;QAChD,OAAO;YAAE,IAAI;YAAQ,IAAI;QAAQ;QACjC,MAAM;YAAE,IAAI;YAAa,IAAI;QAAW;QACxC,MAAM;YAAE,IAAI;YAAQ,IAAI;QAAO;IACjC;IACA,OAAO;QAAED;QAAM,UAAU;QAAK,SAAS;QAAK,UAAUC,QAAQ,CAACD,KAAK;IAAoB;AAC1F;AAEA,SAASE,MAAMC,IAAY;IACzB,IAAIC,IAAI;IACR,IAAK,IAAIC,IAAI,GAAGA,IAAIF,KAAK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|
|
1
|
+
export { formatAddress, type G9Address, G9AddressError, type G9AddressErrorCode, type G9Segment, type G9SegmentInput, g9AddressLimits, generalOf, matchesAddress, parseAddress, sameSegment, sameSegmentState, seg, toSegment, tryParseAddress, } from './address.js';
|
|
2
|
+
export { catalogueManifest, createCatalogue, type G9AddressCheck, type G9BilingualText, type G9Catalogue, G9CatalogueError, type G9CatalogueManifestEntry, type G9Entry, type G9GoFailure, type G9GuardResult, type G9IdCodec, type G9ParamDef, type G9PlaceDef, g9GenericKinds, g9GuidCodec, g9PatternCodec, } from './catalogue.js';
|
|
3
|
+
export { confirmSeconds, type G9AnchorRisk, type G9ConfirmTiming, type G9GuideEffectSpec, type G9Journey, type G9JourneySource, type G9JourneyStep, type G9StepAuthority, type G9Text, type G9Until, type G9WaitFor, g9ConfirmTimingDefaults, g9JourneyLimits, journeyAuthority, textIn, validateJourney, } from './journey.js';
|
|
4
|
+
export { compareLivePlaces, type G9LivePlace, type G9NavigationPlan, type G9ResolvedPath, planNavigation, resolvePath, } from './resolve.js';
|
|
5
|
+
export { type G9ChangeLine, type G9PlaceDeclaration, type G9PlaceHandle, type G9PlaceLayer, type G9RouteSink, g9PlaceLayers, } from './sink.js';
|
|
6
|
+
export { type G9ScrollMark, type G9SegmentView, type G9Snapshot, type G9ViewApplied, parseSnapshot, snapshotRefusal, toScrollMark, } from './view.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/route/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EACb,KAAK,SAAS,EACd,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,eAAe,EACf,SAAS,EACT,cAAc,EACd,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,GAAG,EACH,SAAS,EACT,eAAe,GAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,gBAAgB,EAChB,KAAK,wBAAwB,EAC7B,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,UAAU,EACf,cAAc,EACd,WAAW,EACX,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,MAAM,EACN,eAAe,GAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,cAAc,EACd,WAAW,GACZ,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,aAAa,GACd,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,aAAa,EACb,eAAe,EACf,YAAY,GACb,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { G9AddressError, formatAddress, g9AddressLimits, generalOf, matchesAddress, parseAddress, sameSegment, sameSegmentState, seg, toSegment, tryParseAddress } from "./address.js";
|
|
2
|
+
export { G9CatalogueError, catalogueManifest, createCatalogue, g9GenericKinds, g9GuidCodec, g9PatternCodec } from "./catalogue.js";
|
|
3
|
+
export { confirmSeconds, g9ConfirmTimingDefaults, g9JourneyLimits, journeyAuthority, textIn, validateJourney } from "./journey.js";
|
|
4
|
+
export { compareLivePlaces, planNavigation, resolvePath } from "./resolve.js";
|
|
5
|
+
export { g9PlaceLayers } from "./sink.js";
|
|
6
|
+
export { parseSnapshot, snapshotRefusal, toScrollMark } from "./view.js";
|