@g9tm/lynxcontrols-foundation 0.0.0-stage → 1.4.2

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.
Files changed (164) hide show
  1. package/README.md +4 -2
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/collections.d.ts +16 -0
  4. package/dist/collections.d.ts.map +1 -0
  5. package/dist/collections.js +40 -0
  6. package/dist/collections.js.map +1 -0
  7. package/dist/culture/calendar.d.ts +122 -0
  8. package/dist/culture/calendar.d.ts.map +1 -0
  9. package/dist/culture/calendar.js +379 -0
  10. package/dist/culture/calendar.js.map +1 -0
  11. package/dist/culture/culture.d.ts +91 -0
  12. package/dist/culture/culture.d.ts.map +1 -0
  13. package/dist/culture/culture.js +173 -0
  14. package/dist/culture/culture.js.map +1 -0
  15. package/dist/culture/date-format.d.ts +19 -0
  16. package/dist/culture/date-format.d.ts.map +1 -0
  17. package/dist/culture/date-format.js +101 -0
  18. package/dist/culture/date-format.js.map +1 -0
  19. package/dist/culture/digits.d.ts +29 -0
  20. package/dist/culture/digits.d.ts.map +1 -0
  21. package/dist/culture/digits.js +43 -0
  22. package/dist/culture/digits.js.map +1 -0
  23. package/dist/culture/duration.d.ts +38 -0
  24. package/dist/culture/duration.d.ts.map +1 -0
  25. package/dist/culture/duration.js +41 -0
  26. package/dist/culture/duration.js.map +1 -0
  27. package/dist/culture/index.d.ts +9 -0
  28. package/dist/culture/index.d.ts.map +1 -0
  29. package/dist/culture/index.js +8 -0
  30. package/dist/culture/numbers.d.ts +38 -0
  31. package/dist/culture/numbers.d.ts.map +1 -0
  32. package/dist/culture/numbers.js +64 -0
  33. package/dist/culture/numbers.js.map +1 -0
  34. package/dist/culture/relative-time.d.ts +50 -0
  35. package/dist/culture/relative-time.d.ts.map +1 -0
  36. package/dist/culture/relative-time.js +63 -0
  37. package/dist/culture/relative-time.js.map +1 -0
  38. package/dist/culture/strings.d.ts +145 -0
  39. package/dist/culture/strings.d.ts.map +1 -0
  40. package/dist/culture/strings.js +345 -0
  41. package/dist/culture/strings.js.map +1 -0
  42. package/dist/enums/index.d.ts +195 -0
  43. package/dist/enums/index.d.ts.map +1 -0
  44. package/dist/enums/index.js +130 -0
  45. package/dist/enums/index.js.map +1 -0
  46. package/dist/errors.d.ts +10 -0
  47. package/dist/errors.d.ts.map +1 -0
  48. package/dist/errors.js +21 -0
  49. package/dist/errors.js.map +1 -0
  50. package/dist/exec/diagnostics.d.ts +74 -0
  51. package/dist/exec/diagnostics.d.ts.map +1 -0
  52. package/dist/exec/diagnostics.js +73 -0
  53. package/dist/exec/diagnostics.js.map +1 -0
  54. package/dist/exec/index.d.ts +5 -0
  55. package/dist/exec/index.d.ts.map +1 -0
  56. package/dist/exec/index.js +4 -0
  57. package/dist/exec/options.d.ts +75 -0
  58. package/dist/exec/options.d.ts.map +1 -0
  59. package/dist/exec/options.js +107 -0
  60. package/dist/exec/options.js.map +1 -0
  61. package/dist/exec/safe-executor.d.ts +138 -0
  62. package/dist/exec/safe-executor.d.ts.map +1 -0
  63. package/dist/exec/safe-executor.js +401 -0
  64. package/dist/exec/safe-executor.js.map +1 -0
  65. package/dist/exec/trace.d.ts +59 -0
  66. package/dist/exec/trace.d.ts.map +1 -0
  67. package/dist/exec/trace.js +108 -0
  68. package/dist/exec/trace.js.map +1 -0
  69. package/dist/icons/generated/glyph-svg.d.ts +37 -0
  70. package/dist/icons/generated/glyph-svg.d.ts.map +1 -0
  71. package/dist/icons/generated/glyph-svg.js +33 -0
  72. package/dist/icons/generated/glyph-svg.js.map +1 -0
  73. package/dist/icons/glyph-slots.d.ts +79 -0
  74. package/dist/icons/glyph-slots.d.ts.map +1 -0
  75. package/dist/icons/glyph-slots.js +50 -0
  76. package/dist/icons/glyph-slots.js.map +1 -0
  77. package/dist/icons/glyph.d.ts +76 -0
  78. package/dist/icons/glyph.d.ts.map +1 -0
  79. package/dist/icons/glyph.js +42 -0
  80. package/dist/icons/glyph.js.map +1 -0
  81. package/dist/icons/icon-fonts.d.ts +55 -0
  82. package/dist/icons/icon-fonts.d.ts.map +1 -0
  83. package/dist/icons/icon-fonts.js +74 -0
  84. package/dist/icons/icon-fonts.js.map +1 -0
  85. package/dist/icons/icon.d.ts +102 -0
  86. package/dist/icons/icon.d.ts.map +1 -0
  87. package/dist/icons/icon.js +132 -0
  88. package/dist/icons/icon.js.map +1 -0
  89. package/dist/icons/index.d.ts +7 -0
  90. package/dist/icons/index.d.ts.map +1 -0
  91. package/dist/icons/index.js +6 -0
  92. package/dist/icons/svg.d.ts +28 -0
  93. package/dist/icons/svg.d.ts.map +1 -0
  94. package/dist/icons/svg.js +59 -0
  95. package/dist/icons/svg.js.map +1 -0
  96. package/dist/index.d.ts +10 -0
  97. package/dist/index.d.ts.map +1 -0
  98. package/dist/index.js +9 -0
  99. package/dist/services/abort.d.ts +31 -0
  100. package/dist/services/abort.d.ts.map +1 -0
  101. package/dist/services/abort.js +47 -0
  102. package/dist/services/abort.js.map +1 -0
  103. package/dist/services/clock.d.ts +35 -0
  104. package/dist/services/clock.d.ts.map +1 -0
  105. package/dist/services/clock.js +37 -0
  106. package/dist/services/clock.js.map +1 -0
  107. package/dist/services/contracts.d.ts +200 -0
  108. package/dist/services/contracts.d.ts.map +1 -0
  109. package/dist/services/contracts.js +37 -0
  110. package/dist/services/contracts.js.map +1 -0
  111. package/dist/services/index.d.ts +5 -0
  112. package/dist/services/index.d.ts.map +1 -0
  113. package/dist/services/index.js +4 -0
  114. package/dist/services/preferences.d.ts +105 -0
  115. package/dist/services/preferences.d.ts.map +1 -0
  116. package/dist/services/preferences.js +253 -0
  117. package/dist/services/preferences.js.map +1 -0
  118. package/dist/theme/color.d.ts +94 -0
  119. package/dist/theme/color.d.ts.map +1 -0
  120. package/dist/theme/color.js +150 -0
  121. package/dist/theme/color.js.map +1 -0
  122. package/dist/theme/control-colors.d.ts +46 -0
  123. package/dist/theme/control-colors.d.ts.map +1 -0
  124. package/dist/theme/control-colors.js +46 -0
  125. package/dist/theme/control-colors.js.map +1 -0
  126. package/dist/theme/index.d.ts +5 -0
  127. package/dist/theme/index.d.ts.map +1 -0
  128. package/dist/theme/index.js +4 -0
  129. package/dist/theme/theme.d.ts +88 -0
  130. package/dist/theme/theme.d.ts.map +1 -0
  131. package/dist/theme/theme.js +190 -0
  132. package/dist/theme/theme.js.map +1 -0
  133. package/dist/theme/variants.d.ts +33 -0
  134. package/dist/theme/variants.d.ts.map +1 -0
  135. package/dist/theme/variants.js +53 -0
  136. package/dist/theme/variants.js.map +1 -0
  137. package/dist/tokens/css-vars.d.ts +41 -0
  138. package/dist/tokens/css-vars.d.ts.map +1 -0
  139. package/dist/tokens/css-vars.js +55 -0
  140. package/dist/tokens/css-vars.js.map +1 -0
  141. package/dist/tokens/generated/metrics.d.ts +184 -0
  142. package/dist/tokens/generated/metrics.d.ts.map +1 -0
  143. package/dist/tokens/generated/metrics.js +349 -0
  144. package/dist/tokens/generated/metrics.js.map +1 -0
  145. package/dist/tokens/generated/palettes.d.ts +113 -0
  146. package/dist/tokens/generated/palettes.d.ts.map +1 -0
  147. package/dist/tokens/generated/palettes.js +391 -0
  148. package/dist/tokens/generated/palettes.js.map +1 -0
  149. package/dist/tokens/index.d.ts +5 -0
  150. package/dist/tokens/index.d.ts.map +1 -0
  151. package/dist/tokens/index.js +4 -0
  152. package/dist/tokens/layout-metrics.d.ts +120 -0
  153. package/dist/tokens/layout-metrics.d.ts.map +1 -0
  154. package/dist/tokens/layout-metrics.js +111 -0
  155. package/dist/tokens/layout-metrics.js.map +1 -0
  156. package/docs/api.md +369 -0
  157. package/docs/foundation.md +370 -0
  158. package/docs/migration/Core.Controls.Shared.md +475 -0
  159. package/docs/migration/Core.Helpers.md +132 -0
  160. package/docs/migration/Core.Icons.md +135 -0
  161. package/docs/migration/Core.Localization.md +118 -0
  162. package/docs/migration/Core.Storage.md +54 -0
  163. package/docs/migration/Core.Theming.md +328 -0
  164. package/package.json +59 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../../src/icons/svg.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;AAEtD,uFAAuF;AACvF,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,2EAA2E;AAC3E,MAAM,WAAW,eAAe;IAC9B,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAClE,2FAA2F;IAC3F,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACnE,mCAAmC;IACnC,KAAK,IAAI,IAAI,CAAC;CACf;AA0BD,0GAA0G;AAC1G,wBAAgB,mBAAmB,CAAC,UAAU,GAAE,MAAmC,GAAG,eAAe,CAmCpG;AAID;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAiB,EAAE,WAAW,SAAI,GAAG,MAAM,CAE3F"}
@@ -0,0 +1,59 @@
1
+ import { G9Error } from "../errors.js";
2
+ import { formatColor, parseColor } from "../theme/color.js";
3
+ import { g9GlyphStrokeUnits, g9GlyphSvg } from "./generated/glyph-svg.js";
4
+ import { assertG9Glyph } from "./glyph.js";
5
+ const g9GlyphSvgCacheDefaultSize = 256;
6
+ function formatWidth(value) {
7
+ return String(Math.round(10000 * value) / 10000);
8
+ }
9
+ function requireWeight(weightScale) {
10
+ if ('number' != typeof weightScale || !Number.isFinite(weightScale) || weightScale <= 0) throw new G9Error('icon-weight', `weightScale must be a finite number above 0 (got ${String(weightScale)}).`);
11
+ return weightScale;
12
+ }
13
+ function canonicalColor(color) {
14
+ return 'currentColor' === color ? color : formatColor(parseColor(color));
15
+ }
16
+ function render(glyph, color, weightScale) {
17
+ if ('none' === glyph) return '';
18
+ return g9GlyphSvg[glyph].replace(`stroke-width="${g9GlyphStrokeUnits}"`, `stroke-width="${formatWidth(g9GlyphStrokeUnits * weightScale)}"`).replace(/currentColor/g, color);
19
+ }
20
+ function createGlyphSvgCache(maxEntries = g9GlyphSvgCacheDefaultSize) {
21
+ if (!Number.isInteger(maxEntries) || maxEntries < 1) throw new G9Error('icon-cache', `maxEntries must be a positive integer (got ${String(maxEntries)}).`);
22
+ const entries = new Map();
23
+ const keyOf = (glyph, color, weightScale)=>{
24
+ assertG9Glyph(glyph);
25
+ return `${glyph}|${canonicalColor(color)}|${requireWeight(weightScale)}`;
26
+ };
27
+ return {
28
+ maxEntries,
29
+ get size () {
30
+ return entries.size;
31
+ },
32
+ svg (glyph, color = 'currentColor', weightScale = 1) {
33
+ const key = keyOf(glyph, color, weightScale);
34
+ const hit = entries.get(key);
35
+ if (void 0 !== hit) {
36
+ entries.delete(key);
37
+ entries.set(key, hit);
38
+ return hit;
39
+ }
40
+ const svg = render(glyph, canonicalColor(color), weightScale);
41
+ entries.set(key, svg);
42
+ if (entries.size > maxEntries) entries.delete(entries.keys().next().value);
43
+ return svg;
44
+ },
45
+ has (glyph, color = 'currentColor', weightScale = 1) {
46
+ return entries.has(keyOf(glyph, color, weightScale));
47
+ },
48
+ clear () {
49
+ entries.clear();
50
+ }
51
+ };
52
+ }
53
+ const sharedCache = createGlyphSvgCache();
54
+ function svgForGlyph(glyph, color = 'currentColor', weightScale = 1) {
55
+ return sharedCache.svg(glyph, color, weightScale);
56
+ }
57
+ export { createGlyphSvgCache, g9GlyphSvgCacheDefaultSize, svgForGlyph };
58
+
59
+ //# sourceMappingURL=svg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icons/svg.js","sources":["../../src/icons/svg.ts"],"sourcesContent":["import { G9Error } from '../errors';\nimport { formatColor, parseColor } from '../theme/color';\nimport { g9GlyphStrokeUnits, g9GlyphSvg } from './generated/glyph-svg';\nimport { assertG9Glyph, type G9Glyph } from './glyph';\n\n/** Default capacity of a glyph SVG cache: every glyph in a few colours and weights. */\nexport const g9GlyphSvgCacheDefaultSize = 256;\n\n/** A bounded least-recently-used cache of rendered glyph SVG documents. */\nexport interface G9GlyphSvgCache {\n /** The capacity; inserting beyond it evicts the least recently used entry. */\n readonly maxEntries: number;\n /** How many documents are cached now (never more than `maxEntries`). */\n readonly size: number;\n /** Renders (or returns the cached) SVG document; same contract as `svgForGlyph`. */\n svg(glyph: G9Glyph, color?: string, weightScale?: number): string;\n /** True when the document for these arguments is cached (does not refresh its recency). */\n has(glyph: G9Glyph, color?: string, weightScale?: number): boolean;\n /** Drops every cached document. */\n clear(): void;\n}\n\n/** Shortest decimal for a stroke width, rounded to 4 places so `2 * 1.1` prints `2.2`; no locale (no Intl). */\nfunction formatWidth(value: number): string {\n return String(Math.round(value * 10_000) / 10_000);\n}\n\nfunction requireWeight(weightScale: number): number {\n if (typeof weightScale !== 'number' || !Number.isFinite(weightScale) || weightScale <= 0) {\n throw new G9Error('icon-weight', `weightScale must be a finite number above 0 (got ${String(weightScale)}).`);\n }\n return weightScale;\n}\n\n/** The canonical colour string written into the SVG: `currentColor` stays, any other CSS colour is normalised. */\nfunction canonicalColor(color: string): string {\n return color === 'currentColor' ? color : formatColor(parseColor(color));\n}\n\nfunction render(glyph: G9Glyph, color: string, weightScale: number): string {\n if (glyph === 'none') return '';\n return g9GlyphSvg[glyph]\n .replace(`stroke-width=\"${g9GlyphStrokeUnits}\"`, `stroke-width=\"${formatWidth(g9GlyphStrokeUnits * weightScale)}\"`)\n .replace(/currentColor/g, color);\n}\n\n/** Creates a bounded LRU cache of glyph SVG documents (default capacity `g9GlyphSvgCacheDefaultSize`). */\nexport function createGlyphSvgCache(maxEntries: number = g9GlyphSvgCacheDefaultSize): G9GlyphSvgCache {\n if (!Number.isInteger(maxEntries) || maxEntries < 1) {\n throw new G9Error('icon-cache', `maxEntries must be a positive integer (got ${String(maxEntries)}).`);\n }\n // Map iteration order is insertion order: re-inserting on a hit makes the first key the least recently used.\n const entries = new Map<string, string>();\n const keyOf = (glyph: G9Glyph, color: string, weightScale: number) => {\n assertG9Glyph(glyph);\n return `${glyph}|${canonicalColor(color)}|${requireWeight(weightScale)}`;\n };\n return {\n maxEntries,\n get size() {\n return entries.size;\n },\n svg(glyph, color = 'currentColor', weightScale = 1) {\n const key = keyOf(glyph, color, weightScale);\n const hit = entries.get(key);\n if (hit !== undefined) {\n entries.delete(key);\n entries.set(key, hit);\n return hit;\n }\n const svg = render(glyph, canonicalColor(color), weightScale);\n entries.set(key, svg);\n if (entries.size > maxEntries) entries.delete(entries.keys().next().value as string);\n return svg;\n },\n has(glyph, color = 'currentColor', weightScale = 1) {\n return entries.has(keyOf(glyph, color, weightScale));\n },\n clear() {\n entries.clear();\n },\n };\n}\n\nconst sharedCache = createGlyphSvgCache();\n\n/**\n * The SVG document of a built-in glyph for Lynx `<svg content>` (WP02 renders it): the golden MAUI drawing with every\n * `currentColor` replaced by `color` and the stroke width scaled by `weightScale` (MAUI `G9GlyphDrawable.Color`,\n * `WeightScale`; stroke = 2 design units × weight; filled dots keep their recorded radius). `'none'` returns `''`\n * (renders nothing). `color` defaults to `currentColor`; any other value must be a CSS colour `parseColor` reads and\n * is written normalised (`formatColor`). Invalid glyph, colour or weight (finite, above 0) throws a `G9Error`.\n * Results come from a shared bounded LRU cache (`createGlyphSvgCache` for a private one).\n */\nexport function svgForGlyph(glyph: G9Glyph, color = 'currentColor', weightScale = 1): string {\n return sharedCache.svg(glyph, color, weightScale);\n}\n"],"names":["g9GlyphSvgCacheDefaultSize","formatWidth","value","String","Math","requireWeight","weightScale","Number","G9Error","canonicalColor","color","formatColor","parseColor","render","glyph","g9GlyphSvg","g9GlyphStrokeUnits","createGlyphSvgCache","maxEntries","entries","Map","keyOf","assertG9Glyph","key","hit","undefined","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YAChC,MAAMkB,MAAML,QAAQ,GAAG,CAACI;YACxB,IAAIC,AAAQC,WAARD,KAAmB;gBACrBL,QAAQ,MAAM,CAACI;gBACfJ,QAAQ,GAAG,CAACI,KAAKC;gBACjB,OAAOA;YACT;YACA,MAAME,MAAMb,OAAOC,OAAOL,eAAeC,QAAQJ;YACjDa,QAAQ,GAAG,CAACI,KAAKG;YACjB,IAAIP,QAAQ,IAAI,GAAGD,YAAYC,QAAQ,MAAM,CAACA,QAAQ,IAAI,GAAG,IAAI,GAAG,KAAK;YACzE,OAAOO;QACT;QACA,KAAIZ,KAAK,EAAEJ,QAAQ,cAAc,EAAEJ,cAAc,CAAC;YAChD,OAAOa,QAAQ,GAAG,CAACE,MAAMP,OAAOJ,OAAOJ;QACzC;QACA;YACEa,QAAQ,KAAK;QACf;IACF;AACF;AAEA,MAAMQ,cAAcV;AAUb,SAASW,YAAYd,KAAc,EAAEJ,QAAQ,cAAc,EAAEJ,cAAc,CAAC;IACjF,OAAOqB,YAAY,GAAG,CAACb,OAAOJ,OAAOJ;AACvC"}
@@ -0,0 +1,10 @@
1
+ export { addRange, removeRange, replaceRange, replaceWith } from './collections.js';
2
+ export * from './culture/index.js';
3
+ export * from './enums/index.js';
4
+ export { G9Error } from './errors.js';
5
+ export * from './exec/index.js';
6
+ export * from './icons/index.js';
7
+ export * from './services/index.js';
8
+ export * from './theme/index.js';
9
+ export * from './tokens/index.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjF,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export * from "./culture/index.js";
2
+ export * from "./enums/index.js";
3
+ export * from "./exec/index.js";
4
+ export * from "./icons/index.js";
5
+ export * from "./services/index.js";
6
+ export * from "./theme/index.js";
7
+ export * from "./tokens/index.js";
8
+ export { addRange, removeRange, replaceRange, replaceWith } from "./collections.js";
9
+ export { G9Error } from "./errors.js";
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The cancellation signal G9 passes to async work (MAUI `CancellationToken`, plan/specs/03-API-Conventions.md §2).
3
+ * A web `AbortSignal` satisfies it, so app code can hand it to `fetch`. The Lynx typings do not declare
4
+ * `AbortController`, and its presence on PrimJS is not verified, so {@link createAbortController} falls back to a
5
+ * small portable implementation when the runtime has none.
6
+ */
7
+ export interface G9AbortSignal {
8
+ /** `true` once aborted; never goes back. */
9
+ readonly aborted: boolean;
10
+ /** Why it was aborted (`undefined` until then). */
11
+ readonly reason: unknown;
12
+ addEventListener(type: 'abort', listener: () => void, options?: {
13
+ once?: boolean;
14
+ }): void;
15
+ removeEventListener(type: 'abort', listener: () => void): void;
16
+ }
17
+ /** Owner side of a {@link G9AbortSignal}. */
18
+ export interface G9AbortController {
19
+ readonly signal: G9AbortSignal;
20
+ /** Aborts once; later calls are ignored. Without a reason, an `Error` named `'AbortError'` is used. */
21
+ abort(reason?: unknown): void;
22
+ }
23
+ /** An `Error` named `'AbortError'`, the shape web APIs and {@link isAbortError} agree on. */
24
+ export declare function createAbortError(message?: string): Error;
25
+ /** `true` for an error named `'AbortError'` (web `DOMException`, our {@link createAbortError}, most libraries). */
26
+ export declare function isAbortError(error: unknown): boolean;
27
+ /** The portable controller used when the runtime has no `AbortController`. Listeners run once, in order, guarded. */
28
+ export declare function createPortableAbortController(): G9AbortController;
29
+ /** A runtime `AbortController` when there is one, otherwise {@link createPortableAbortController}. */
30
+ export declare function createAbortController(): G9AbortController;
31
+ //# sourceMappingURL=abort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../../src/services/abort.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,EAAE,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC1F,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CAChE;AAED,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,uGAAuG;IACvG,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/B;AAED,6FAA6F;AAC7F,wBAAgB,gBAAgB,CAAC,OAAO,SAA+B,GAAG,KAAK,CAI9E;AAED,mHAAmH;AACnH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEpD;AAED,qHAAqH;AACrH,wBAAgB,6BAA6B,IAAI,iBAAiB,CAmCjE;AAMD,sGAAsG;AACtG,wBAAgB,qBAAqB,IAAI,iBAAiB,CAGzD"}
@@ -0,0 +1,47 @@
1
+ function createAbortError(message = 'The operation was aborted.') {
2
+ const error = new Error(message);
3
+ error.name = 'AbortError';
4
+ return error;
5
+ }
6
+ function isAbortError(error) {
7
+ return 'object' == typeof error && null !== error && 'AbortError' === error.name;
8
+ }
9
+ function createPortableAbortController() {
10
+ let aborted = false;
11
+ let reason;
12
+ let listeners = [];
13
+ const signal = {
14
+ get aborted () {
15
+ return aborted;
16
+ },
17
+ get reason () {
18
+ return reason;
19
+ },
20
+ addEventListener (type, listener) {
21
+ if ('abort' === type && !aborted && !listeners.includes(listener)) listeners.push(listener);
22
+ },
23
+ removeEventListener (type, listener) {
24
+ if ('abort' === type) listeners = listeners.filter((l)=>l !== listener);
25
+ }
26
+ };
27
+ return {
28
+ signal,
29
+ abort (why) {
30
+ if (aborted) return;
31
+ aborted = true;
32
+ reason = void 0 === why ? createAbortError() : why;
33
+ const run = listeners;
34
+ listeners = [];
35
+ for (const listener of run)try {
36
+ listener();
37
+ } catch {}
38
+ }
39
+ };
40
+ }
41
+ function createAbortController() {
42
+ const Native = globalThis.AbortController;
43
+ return 'function' == typeof Native ? new Native() : createPortableAbortController();
44
+ }
45
+ export { createAbortController, createAbortError, createPortableAbortController, isAbortError };
46
+
47
+ //# sourceMappingURL=abort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services/abort.js","sources":["../../src/services/abort.ts"],"sourcesContent":["/**\n * The cancellation signal G9 passes to async work (MAUI `CancellationToken`, plan/specs/03-API-Conventions.md §2).\n * A web `AbortSignal` satisfies it, so app code can hand it to `fetch`. The Lynx typings do not declare\n * `AbortController`, and its presence on PrimJS is not verified, so {@link createAbortController} falls back to a\n * small portable implementation when the runtime has none.\n */\nexport interface G9AbortSignal {\n /** `true` once aborted; never goes back. */\n readonly aborted: boolean;\n /** Why it was aborted (`undefined` until then). */\n readonly reason: unknown;\n addEventListener(type: 'abort', listener: () => void, options?: { once?: boolean }): void;\n removeEventListener(type: 'abort', listener: () => void): void;\n}\n\n/** Owner side of a {@link G9AbortSignal}. */\nexport interface G9AbortController {\n readonly signal: G9AbortSignal;\n /** Aborts once; later calls are ignored. Without a reason, an `Error` named `'AbortError'` is used. */\n abort(reason?: unknown): void;\n}\n\n/** An `Error` named `'AbortError'`, the shape web APIs and {@link isAbortError} agree on. */\nexport function createAbortError(message = 'The operation was aborted.'): Error {\n const error = new Error(message);\n error.name = 'AbortError';\n return error;\n}\n\n/** `true` for an error named `'AbortError'` (web `DOMException`, our {@link createAbortError}, most libraries). */\nexport function isAbortError(error: unknown): boolean {\n return typeof error === 'object' && error !== null && (error as { name?: unknown }).name === 'AbortError';\n}\n\n/** The portable controller used when the runtime has no `AbortController`. Listeners run once, in order, guarded. */\nexport function createPortableAbortController(): G9AbortController {\n let aborted = false;\n let reason: unknown;\n let listeners: Array<() => void> = [];\n const signal: G9AbortSignal = {\n get aborted() {\n return aborted;\n },\n get reason() {\n return reason;\n },\n addEventListener(type, listener) {\n if (type === 'abort' && !aborted && !listeners.includes(listener)) listeners.push(listener);\n },\n removeEventListener(type, listener) {\n if (type === 'abort') listeners = listeners.filter((l) => l !== listener);\n },\n };\n return {\n signal,\n abort(why) {\n if (aborted) return;\n aborted = true;\n reason = why === undefined ? createAbortError() : why;\n const run = listeners;\n listeners = [];\n for (const listener of run) {\n try {\n listener();\n } catch {\n // A listener must not stop the others (web AbortSignal reports and continues the same way).\n }\n }\n },\n };\n}\n\ninterface MaybeAbortControllerGlobal {\n readonly AbortController?: new () => G9AbortController;\n}\n\n/** A runtime `AbortController` when there is one, otherwise {@link createPortableAbortController}. */\nexport function createAbortController(): G9AbortController {\n const Native = (globalThis as MaybeAbortControllerGlobal).AbortController;\n return typeof Native === 'function' ? new Native() : createPortableAbortController();\n}\n"],"names":["createAbortError","message","error","Error","isAbortError","createPortableAbortController","aborted","reason","listeners","signal","type","listener","l","why","undefined","run","createAbortController","Native","globalThis"],"mappings":"AAuBO,SAASA,iBAAiBC,UAAU,4BAA4B;IACrE,MAAMC,QAAQ,IAAIC,MAAMF;IACxBC,MAAM,IAAI,GAAG;IACb,OAAOA;AACT;AAGO,SAASE,aAAaF,KAAc;IACzC,OAAO,AAAiB,YAAjB,OAAOA,SAAsBA,AAAU,SAAVA,SAAmBA,AAAsC,iBAAtCA,MAA6B,IAAI;AAC1F;AAGO,SAASG;IACd,IAAIC,UAAU;IACd,IAAIC;IACJ,IAAIC,YAA+B,EAAE;IACrC,MAAMC,SAAwB;QAC5B,IAAI;YACF,OAAOH;QACT;QACA,IAAI;YACF,OAAOC;QACT;QACA,kBAAiBG,IAAI,EAAEC,QAAQ;YAC7B,IAAID,AAAS,YAATA,QAAoB,CAACJ,WAAW,CAACE,UAAU,QAAQ,CAACG,WAAWH,UAAU,IAAI,CAACG;QACpF;QACA,qBAAoBD,IAAI,EAAEC,QAAQ;YAChC,IAAID,AAAS,YAATA,MAAkBF,YAAYA,UAAU,MAAM,CAAC,CAACI,IAAMA,MAAMD;QAClE;IACF;IACA,OAAO;QACLF;QACA,OAAMI,GAAG;YACP,IAAIP,SAAS;YACbA,UAAU;YACVC,SAASM,AAAQC,WAARD,MAAoBb,qBAAqBa;YAClD,MAAME,MAAMP;YACZA,YAAY,EAAE;YACd,KAAK,MAAMG,YAAYI,IACrB,IAAI;gBACFJ;YACF,EAAE,OAAM,CAER;QAEJ;IACF;AACF;AAOO,SAASK;IACd,MAAMC,SAAUC,WAA0C,eAAe;IACzE,OAAO,AAAkB,cAAlB,OAAOD,SAAwB,IAAIA,WAAWZ;AACvD"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Time source of everything in G9 that needs "now" (plan/specs/01-Architecture.md §8). Supplied by the app through the
3
+ * provider; tests pass a manual clock.
4
+ *
5
+ * - `now()` is wall time in epoch milliseconds: what relative time, calendars and trace timestamps show.
6
+ * - `monotonicNow()` never runs backwards and is only meaningful as a difference: what throttles, timeouts and
7
+ * elapsed times measure. MAUI used `Environment.TickCount64` for exactly this, because a device clock that is
8
+ * corrected backwards made every stored wall-clock throttle stamp lie in the future and killed every button.
9
+ */
10
+ export interface G9Clock {
11
+ /** Wall-clock time, epoch milliseconds. */
12
+ now(): number;
13
+ /** A non-decreasing millisecond counter with an arbitrary origin. */
14
+ monotonicNow(): number;
15
+ }
16
+ /**
17
+ * A monotonic counter built from a wall clock: it advances by every positive step of `wallNow` and ignores backward
18
+ * steps, so a clock corrected backwards pauses nothing and a forward jump only makes time pass faster once.
19
+ */
20
+ export declare function createMonotonicFromWall(wallNow: () => number): () => number;
21
+ /**
22
+ * The system clock: `Date.now()` for wall time; `performance.now()` for monotonic time where the runtime has it (the
23
+ * Lynx typings do not promise it), otherwise {@link createMonotonicFromWall} over `Date.now()`.
24
+ */
25
+ export declare function createSystemClock(): G9Clock;
26
+ /** A clock you move by hand (tests, previews). Both readings start at the given values and advance together. */
27
+ export interface G9ManualClock extends G9Clock {
28
+ /** Moves both readings forward. @throws {RangeError} for a negative or non-finite step. */
29
+ advance(ms: number): void;
30
+ /** Sets wall time only (simulates a device-clock correction); monotonic time is unaffected. */
31
+ setWallTime(epochMs: number): void;
32
+ }
33
+ /** Creates a {@link G9ManualClock}. */
34
+ export declare function createManualClock(startEpochMs?: number, startMonotonic?: number): G9ManualClock;
35
+ //# sourceMappingURL=clock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../../src/services/clock.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,OAAO;IACtB,2CAA2C;IAC3C,GAAG,IAAI,MAAM,CAAC;IACd,qEAAqE;IACrE,YAAY,IAAI,MAAM,CAAC;CACxB;AAMD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,MAAM,GAAG,MAAM,MAAM,CAS3E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAO3C;AAED,gHAAgH;AAChH,MAAM,WAAW,aAAc,SAAQ,OAAO;IAC5C,2FAA2F;IAC3F,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,+FAA+F;IAC/F,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,uCAAuC;AACvC,wBAAgB,iBAAiB,CAAC,YAAY,SAAI,EAAE,cAAc,SAAI,GAAG,aAAa,CAerF"}
@@ -0,0 +1,37 @@
1
+ function createMonotonicFromWall(wallNow) {
2
+ let last = wallNow();
3
+ let elapsed = 0;
4
+ return ()=>{
5
+ const wall = wallNow();
6
+ if (wall > last) elapsed += wall - last;
7
+ last = wall;
8
+ return elapsed;
9
+ };
10
+ }
11
+ function createSystemClock() {
12
+ const perf = globalThis.performance;
13
+ const perfNow = perf && 'function' == typeof perf.now ? perf.now.bind(perf) : null;
14
+ return Object.freeze({
15
+ now: ()=>Date.now(),
16
+ monotonicNow: null != perfNow ? perfNow : createMonotonicFromWall(()=>Date.now())
17
+ });
18
+ }
19
+ function createManualClock(startEpochMs = 0, startMonotonic = 0) {
20
+ let wall = startEpochMs;
21
+ let mono = startMonotonic;
22
+ return {
23
+ now: ()=>wall,
24
+ monotonicNow: ()=>mono,
25
+ advance (ms) {
26
+ if (!Number.isFinite(ms) || ms < 0) throw new RangeError(`advance(ms) needs a finite ms >= 0, got ${ms}.`);
27
+ wall += ms;
28
+ mono += ms;
29
+ },
30
+ setWallTime (epochMs) {
31
+ wall = epochMs;
32
+ }
33
+ };
34
+ }
35
+ export { createManualClock, createMonotonicFromWall, createSystemClock };
36
+
37
+ //# sourceMappingURL=clock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services/clock.js","sources":["../../src/services/clock.ts"],"sourcesContent":["/**\n * Time source of everything in G9 that needs \"now\" (plan/specs/01-Architecture.md §8). Supplied by the app through the\n * provider; tests pass a manual clock.\n *\n * - `now()` is wall time in epoch milliseconds: what relative time, calendars and trace timestamps show.\n * - `monotonicNow()` never runs backwards and is only meaningful as a difference: what throttles, timeouts and\n * elapsed times measure. MAUI used `Environment.TickCount64` for exactly this, because a device clock that is\n * corrected backwards made every stored wall-clock throttle stamp lie in the future and killed every button.\n */\nexport interface G9Clock {\n /** Wall-clock time, epoch milliseconds. */\n now(): number;\n /** A non-decreasing millisecond counter with an arbitrary origin. */\n monotonicNow(): number;\n}\n\ninterface MaybePerformance {\n readonly performance?: { now?: () => number };\n}\n\n/**\n * A monotonic counter built from a wall clock: it advances by every positive step of `wallNow` and ignores backward\n * steps, so a clock corrected backwards pauses nothing and a forward jump only makes time pass faster once.\n */\nexport function createMonotonicFromWall(wallNow: () => number): () => number {\n let last = wallNow();\n let elapsed = 0;\n return () => {\n const wall = wallNow();\n if (wall > last) elapsed += wall - last;\n last = wall;\n return elapsed;\n };\n}\n\n/**\n * The system clock: `Date.now()` for wall time; `performance.now()` for monotonic time where the runtime has it (the\n * Lynx typings do not promise it), otherwise {@link createMonotonicFromWall} over `Date.now()`.\n */\nexport function createSystemClock(): G9Clock {\n const perf = (globalThis as MaybePerformance).performance;\n const perfNow = perf && typeof perf.now === 'function' ? perf.now.bind(perf) : null;\n return Object.freeze({\n now: () => Date.now(),\n monotonicNow: perfNow ?? createMonotonicFromWall(() => Date.now()),\n });\n}\n\n/** A clock you move by hand (tests, previews). Both readings start at the given values and advance together. */\nexport interface G9ManualClock extends G9Clock {\n /** Moves both readings forward. @throws {RangeError} for a negative or non-finite step. */\n advance(ms: number): void;\n /** Sets wall time only (simulates a device-clock correction); monotonic time is unaffected. */\n setWallTime(epochMs: number): void;\n}\n\n/** Creates a {@link G9ManualClock}. */\nexport function createManualClock(startEpochMs = 0, startMonotonic = 0): G9ManualClock {\n let wall = startEpochMs;\n let mono = startMonotonic;\n return {\n now: () => wall,\n monotonicNow: () => mono,\n advance(ms) {\n if (!Number.isFinite(ms) || ms < 0) throw new RangeError(`advance(ms) needs a finite ms >= 0, got ${ms}.`);\n wall += ms;\n mono += ms;\n },\n setWallTime(epochMs) {\n wall = epochMs;\n },\n };\n}\n"],"names":["createMonotonicFromWall","wallNow","last","elapsed","wall","createSystemClock","perf","globalThis","perfNow","Object","Date","createManualClock","startEpochMs","startMonotonic","mono","ms","Number","RangeError","epochMs"],"mappings":"AAwBO,SAASA,wBAAwBC,OAAqB;IAC3D,IAAIC,OAAOD;IACX,IAAIE,UAAU;IACd,OAAO;QACL,MAAMC,OAAOH;QACb,IAAIG,OAAOF,MAAMC,WAAWC,OAAOF;QACnCA,OAAOE;QACP,OAAOD;IACT;AACF;AAMO,SAASE;IACd,MAAMC,OAAQC,WAAgC,WAAW;IACzD,MAAMC,UAAUF,QAAQ,AAAoB,cAApB,OAAOA,KAAK,GAAG,GAAkBA,KAAK,GAAG,CAAC,IAAI,CAACA,QAAQ;IAC/E,OAAOG,OAAO,MAAM,CAAC;QACnB,KAAK,IAAMC,KAAK,GAAG;QACnB,cAAcF,QAAAA,UAAAA,UAAWR,wBAAwB,IAAMU,KAAK,GAAG;IACjE;AACF;AAWO,SAASC,kBAAkBC,eAAe,CAAC,EAAEC,iBAAiB,CAAC;IACpE,IAAIT,OAAOQ;IACX,IAAIE,OAAOD;IACX,OAAO;QACL,KAAK,IAAMT;QACX,cAAc,IAAMU;QACpB,SAAQC,EAAE;YACR,IAAI,CAACC,OAAO,QAAQ,CAACD,OAAOA,KAAK,GAAG,MAAM,IAAIE,WAAW,CAAC,wCAAwC,EAAEF,GAAG,CAAC,CAAC;YACzGX,QAAQW;YACRD,QAAQC;QACV;QACA,aAAYG,OAAO;YACjBd,OAAOc;QACT;IACF;AACF"}
@@ -0,0 +1,200 @@
1
+ import { G9Error } from '../errors.js';
2
+ import type { G9AbortSignal } from './abort.js';
3
+ import type { G9Clock } from './clock.js';
4
+ import type { G9PreferenceStore } from './preferences.js';
5
+ /** Result of asking for a runtime permission. `'restricted'`: blocked by policy, the user cannot grant it. */
6
+ export type G9PermissionStatus = 'granted' | 'denied' | 'restricted';
7
+ /** Options of one dictation session. */
8
+ export interface G9SpeechToTextOptions {
9
+ /** BCP 47 locale the recogniser listens for (from the culture, e.g. `'fa-IR'`). */
10
+ readonly locale: string;
11
+ /** Aborting stops listening; the session then settles with `{ status: 'cancelled' }`. */
12
+ readonly signal?: G9AbortSignal;
13
+ /** Interim hypotheses while the user speaks, when the platform reports them. */
14
+ readonly onPartialResult?: (text: string) => void;
15
+ }
16
+ /** How a dictation session ended. Expected outcomes are results, not errors (specs/03 §7). */
17
+ export type G9SpeechToTextResult = {
18
+ readonly status: 'recognized';
19
+ readonly text: string;
20
+ } | {
21
+ readonly status: 'cancelled';
22
+ } | {
23
+ readonly status: 'no-match';
24
+ } | {
25
+ readonly status: 'denied';
26
+ };
27
+ /**
28
+ * Speech recognition for dictation into fields (MAUI `IG9SpeechToText`). Optional: without it the microphone
29
+ * affordance is hidden. A platform fault rejects with a `G9Error`.
30
+ */
31
+ export interface G9SpeechToText {
32
+ /** Whether a recogniser exists for this locale on this device (no permission prompt). */
33
+ isAvailable(locale: string): Promise<boolean>;
34
+ /** Asks for microphone and speech permission (only ever from a user action). */
35
+ requestPermission(): Promise<G9PermissionStatus>;
36
+ /** Listens once and settles exactly once. */
37
+ listen(options: G9SpeechToTextOptions): Promise<G9SpeechToTextResult>;
38
+ }
39
+ /** Options of one scan. */
40
+ export interface G9ScanOptions {
41
+ /** Symbologies to accept (e.g. `'qr'`, `'ean13'`, `'code128'`); empty or absent means every one the scanner has. */
42
+ readonly formats?: ReadonlyArray<string>;
43
+ /** Aborting closes the scanner; the scan then settles with `{ status: 'cancelled' }`. */
44
+ readonly signal?: G9AbortSignal;
45
+ }
46
+ /** How a scan ended. */
47
+ export type G9ScanResult = {
48
+ readonly status: 'scanned';
49
+ readonly text: string;
50
+ readonly format: string;
51
+ } | {
52
+ readonly status: 'cancelled';
53
+ } | {
54
+ readonly status: 'denied';
55
+ };
56
+ /** Barcode/QR scanning supplied by the app (WP09 barcode package). Optional: without it the scan action is hidden. */
57
+ export interface G9Scanner {
58
+ /** Whether a camera scanner is usable on this device (no permission prompt). */
59
+ isAvailable(): Promise<boolean>;
60
+ /** Opens the scanner and settles exactly once. */
61
+ scan(options?: G9ScanOptions): Promise<G9ScanResult>;
62
+ }
63
+ /** A media reference as the app describes it (an asset name, a file or a remote URI). */
64
+ export type G9MediaSource = {
65
+ readonly kind: 'image';
66
+ readonly uri: string;
67
+ } | {
68
+ readonly kind: 'image';
69
+ readonly asset: string;
70
+ } | {
71
+ readonly kind: 'video';
72
+ readonly uri: string;
73
+ } | {
74
+ readonly kind: 'video';
75
+ readonly asset: string;
76
+ };
77
+ /** A source resolved to something the platform can display; `uri` is what `<image>`/the video XElement load. */
78
+ export interface G9ResolvedMedia {
79
+ readonly kind: 'image' | 'video';
80
+ readonly uri: string;
81
+ /** Intrinsic size when known, so layout can reserve space before the first frame. */
82
+ readonly width?: number;
83
+ readonly height?: number;
84
+ }
85
+ /** What a {@link G9MediaPlayer} tells its owner. */
86
+ export type G9MediaPlayerEvent =
87
+ /** The first frame is ready to show. */
88
+ {
89
+ readonly type: 'ready';
90
+ }
91
+ /** A looping video is about to end (`seconds` left); the owner may fade out. */
92
+ | {
93
+ readonly type: 'nearEnd';
94
+ readonly seconds: number;
95
+ }
96
+ /** A looping video restarted from the beginning; the owner may fade back in. */
97
+ | {
98
+ readonly type: 'looped';
99
+ }
100
+ /** Playback failed; the owner falls back to the slide image. */
101
+ | {
102
+ readonly type: 'error';
103
+ readonly error: unknown;
104
+ };
105
+ /** Options of {@link G9MediaProvider.createPlayer}. */
106
+ export interface G9MediaPlayerOptions {
107
+ readonly loop?: boolean;
108
+ readonly muted?: boolean;
109
+ /** Best-effort seek applied once after the media opened (MAUI `InitialVideoStartSeconds`). */
110
+ readonly startSeconds?: number;
111
+ /** How early `nearEnd` fires, in seconds. */
112
+ readonly nearEndSeconds?: number;
113
+ }
114
+ /**
115
+ * One video player created by the app's media provider. `view` is what the control renders (the platform video
116
+ * XElement the host registered, built by the app); the control never names a video tag itself.
117
+ */
118
+ export interface G9MediaPlayer {
119
+ /** The element to render (a ReactNode built by the app's provider; foundation keeps it opaque). */
120
+ readonly view: unknown;
121
+ play(): void;
122
+ pause(): void;
123
+ /** Releases the native player; idempotent. */
124
+ dispose(): void;
125
+ /** Subscribes to player events; returns the unsubscribe function. */
126
+ subscribe(listener: (event: G9MediaPlayerEvent) => void): () => void;
127
+ }
128
+ /**
129
+ * Resolves image and video sources for IntroCarousel and other media controls (WP09). Video is part of the contract on
130
+ * every target, desktop included (decision D14 is open; no scope reduction is accepted). A provider that cannot play
131
+ * video yet omits `createPlayer` or returns `false` from `supportsVideo`; controls then show the slide image and say
132
+ * why (`'video-unsupported'`).
133
+ */
134
+ export interface G9MediaProvider {
135
+ resolve(source: G9MediaSource, options?: {
136
+ readonly signal?: G9AbortSignal;
137
+ }): Promise<G9ResolvedMedia>;
138
+ /** Whether this target can play video now (no permission prompt). Absent = `createPlayer` decides. */
139
+ supportsVideo?(): boolean;
140
+ /** Creates a player for a resolved video. The control disposes it on slide change, deactivation and unmount. */
141
+ createPlayer?(media: G9ResolvedMedia, options?: G9MediaPlayerOptions): G9MediaPlayer;
142
+ }
143
+ /** Safe-area insets in logical pixels. */
144
+ export interface G9SafeInsets {
145
+ readonly top: number;
146
+ readonly end: number;
147
+ readonly bottom: number;
148
+ readonly start: number;
149
+ }
150
+ /** Android soft-input policy while a flow needs it (MAUI `G9KeyboardHelper.UseAndroidPanSoftInputMode`). */
151
+ export type G9SoftInputMode = 'pan' | 'resize';
152
+ /**
153
+ * Host integration the provider and overlays need (MAUI page/window plumbing), supplied by the native host. Required.
154
+ * The system back press does not go through this object: the host sends a global event (default `g9:back`, specs/02
155
+ * §4) and the provider dispatches it to the active `G9Host`; `exit` is what happens when nothing handled it.
156
+ */
157
+ export interface G9HostServices {
158
+ /** Leaves the app the platform way (Android moves the task to the back; desktop closes the window). */
159
+ exit(): void;
160
+ /** Hides the soft keyboard and clears focus (MAUI `G9KeyboardHelper.HideKeyboardAndClearFocus`). */
161
+ hideKeyboard(): void;
162
+ /** Current safe-area insets. */
163
+ getSafeInsets(): G9SafeInsets;
164
+ /** Called when the insets change (rotation, window resize). Returns an unsubscribe function. */
165
+ subscribeSafeInsets(listener: (insets: G9SafeInsets) => void): () => void;
166
+ /**
167
+ * Switches the window's soft-input mode (Android only; `'resize'` is the app default). Hosts on platforms without
168
+ * soft-input modes (iOS, desktop) omit it, which is where MAUI's helper was a no-op too.
169
+ */
170
+ setSoftInputMode?(mode: G9SoftInputMode): void;
171
+ }
172
+ /** Every service the app can supply. Required ones are listed in {@link g9RequiredCapabilities}. */
173
+ export interface G9Capabilities {
174
+ readonly clock: G9Clock;
175
+ readonly preferences: G9PreferenceStore;
176
+ readonly host: G9HostServices;
177
+ readonly speech?: G9SpeechToText;
178
+ readonly scanner?: G9Scanner;
179
+ readonly media?: G9MediaProvider;
180
+ }
181
+ /** The name of a capability. */
182
+ export type G9CapabilityName = keyof G9Capabilities;
183
+ /** Capabilities without which the provider cannot mount. */
184
+ export declare const g9RequiredCapabilities: ReadonlyArray<G9CapabilityName>;
185
+ /** Thrown when code needs a capability the app did not supply (specs/03 §7: `G9CapabilityMissingError('speech')`). */
186
+ export declare class G9CapabilityMissingError extends G9Error {
187
+ /** The missing capability. */
188
+ readonly capability: string;
189
+ constructor(capability: string, message?: string);
190
+ }
191
+ /** `true` when the capability is present (optional features use this to hide themselves). */
192
+ export declare function hasCapability(services: Partial<G9Capabilities>, name: G9CapabilityName): boolean;
193
+ /** The capability, or throws {@link G9CapabilityMissingError} naming it. */
194
+ export declare function requireCapability<K extends G9CapabilityName>(services: Partial<G9Capabilities>, name: K): NonNullable<G9Capabilities[K]>;
195
+ /**
196
+ * Checks every required capability at once (the provider calls this at mount).
197
+ * @throws {G9CapabilityMissingError} for the first missing one, in {@link g9RequiredCapabilities} order.
198
+ */
199
+ export declare function assertRequiredCapabilities(services: Partial<G9Capabilities>): asserts services is G9Capabilities;
200
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +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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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"}
@@ -0,0 +1,37 @@
1
+ import { G9Error } from "../errors.js";
2
+ function _define_property(obj, key, value) {
3
+ if (key in obj) Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ else obj[key] = value;
10
+ return obj;
11
+ }
12
+ const g9RequiredCapabilities = Object.freeze([
13
+ 'clock',
14
+ 'preferences',
15
+ 'host'
16
+ ]);
17
+ class G9CapabilityMissingError extends G9Error {
18
+ constructor(capability, message){
19
+ super('capability-missing', null != message ? message : `The '${capability}' service is not available; supply it to G9Provider.`), _define_property(this, "capability", void 0);
20
+ this.name = 'G9CapabilityMissingError';
21
+ this.capability = capability;
22
+ }
23
+ }
24
+ function hasCapability(services, name) {
25
+ return null != services[name];
26
+ }
27
+ function requireCapability(services, name) {
28
+ const service = services[name];
29
+ if (null == service) throw new G9CapabilityMissingError(name);
30
+ return service;
31
+ }
32
+ function assertRequiredCapabilities(services) {
33
+ for (const name of g9RequiredCapabilities)requireCapability(services, name);
34
+ }
35
+ export { G9CapabilityMissingError, assertRequiredCapabilities, g9RequiredCapabilities, hasCapability, requireCapability };
36
+
37
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +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"}
@@ -0,0 +1,5 @@
1
+ export { createAbortController, createAbortError, createPortableAbortController, type G9AbortController, type G9AbortSignal, isAbortError, } from './abort.js';
2
+ export { createManualClock, createMonotonicFromWall, createSystemClock, type G9Clock, type G9ManualClock, } from './clock.js';
3
+ export { assertRequiredCapabilities, type G9Capabilities, G9CapabilityMissingError, type G9CapabilityName, type G9HostServices, type G9MediaPlayer, type G9MediaPlayerEvent, type G9MediaPlayerOptions, type G9MediaProvider, type G9MediaSource, type G9PermissionStatus, type G9ResolvedMedia, type G9SafeInsets, type G9Scanner, type G9ScanOptions, type G9ScanResult, type G9SoftInputMode, type G9SpeechToText, type G9SpeechToTextOptions, type G9SpeechToTextResult, g9RequiredCapabilities, hasCapability, requireCapability, } from './contracts.js';
4
+ export { createMemoryPreferenceStore, createPreferences, type G9MaybePromise, type G9PreferenceKey, type G9PreferenceStore, type G9PreferenceStoreFailure, type G9Preferences, type G9PreferencesOptions, type G9PreferencesSnapshot, type G9PreferenceValue, g9PreferenceKeyPrefix, } from './preferences.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,6BAA6B,EAC7B,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,KAAK,OAAO,EACZ,KAAK,aAAa,GACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,0BAA0B,EAC1B,KAAK,cAAc,EACnB,wBAAwB,EACxB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,sBAAsB,EACtB,aAAa,EACb,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,2BAA2B,EAC3B,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,qBAAqB,GACtB,MAAM,eAAe,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { createAbortController, createAbortError, createPortableAbortController, isAbortError } from "./abort.js";
2
+ export { createManualClock, createMonotonicFromWall, createSystemClock } from "./clock.js";
3
+ export { G9CapabilityMissingError, assertRequiredCapabilities, g9RequiredCapabilities, hasCapability, requireCapability } from "./contracts.js";
4
+ export { createMemoryPreferenceStore, createPreferences, g9PreferenceKeyPrefix } from "./preferences.js";