@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.
- package/README.md +4 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/collections.d.ts +16 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +40 -0
- package/dist/collections.js.map +1 -0
- package/dist/culture/calendar.d.ts +122 -0
- package/dist/culture/calendar.d.ts.map +1 -0
- package/dist/culture/calendar.js +379 -0
- package/dist/culture/calendar.js.map +1 -0
- package/dist/culture/culture.d.ts +91 -0
- package/dist/culture/culture.d.ts.map +1 -0
- package/dist/culture/culture.js +173 -0
- package/dist/culture/culture.js.map +1 -0
- package/dist/culture/date-format.d.ts +19 -0
- package/dist/culture/date-format.d.ts.map +1 -0
- package/dist/culture/date-format.js +101 -0
- package/dist/culture/date-format.js.map +1 -0
- package/dist/culture/digits.d.ts +29 -0
- package/dist/culture/digits.d.ts.map +1 -0
- package/dist/culture/digits.js +43 -0
- package/dist/culture/digits.js.map +1 -0
- package/dist/culture/duration.d.ts +38 -0
- package/dist/culture/duration.d.ts.map +1 -0
- package/dist/culture/duration.js +41 -0
- package/dist/culture/duration.js.map +1 -0
- package/dist/culture/index.d.ts +9 -0
- package/dist/culture/index.d.ts.map +1 -0
- package/dist/culture/index.js +8 -0
- package/dist/culture/numbers.d.ts +38 -0
- package/dist/culture/numbers.d.ts.map +1 -0
- package/dist/culture/numbers.js +64 -0
- package/dist/culture/numbers.js.map +1 -0
- package/dist/culture/relative-time.d.ts +50 -0
- package/dist/culture/relative-time.d.ts.map +1 -0
- package/dist/culture/relative-time.js +63 -0
- package/dist/culture/relative-time.js.map +1 -0
- package/dist/culture/strings.d.ts +145 -0
- package/dist/culture/strings.d.ts.map +1 -0
- package/dist/culture/strings.js +345 -0
- package/dist/culture/strings.js.map +1 -0
- package/dist/enums/index.d.ts +195 -0
- package/dist/enums/index.d.ts.map +1 -0
- package/dist/enums/index.js +130 -0
- package/dist/enums/index.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +21 -0
- package/dist/errors.js.map +1 -0
- package/dist/exec/diagnostics.d.ts +74 -0
- package/dist/exec/diagnostics.d.ts.map +1 -0
- package/dist/exec/diagnostics.js +73 -0
- package/dist/exec/diagnostics.js.map +1 -0
- package/dist/exec/index.d.ts +5 -0
- package/dist/exec/index.d.ts.map +1 -0
- package/dist/exec/index.js +4 -0
- package/dist/exec/options.d.ts +75 -0
- package/dist/exec/options.d.ts.map +1 -0
- package/dist/exec/options.js +107 -0
- package/dist/exec/options.js.map +1 -0
- package/dist/exec/safe-executor.d.ts +138 -0
- package/dist/exec/safe-executor.d.ts.map +1 -0
- package/dist/exec/safe-executor.js +401 -0
- package/dist/exec/safe-executor.js.map +1 -0
- package/dist/exec/trace.d.ts +59 -0
- package/dist/exec/trace.d.ts.map +1 -0
- package/dist/exec/trace.js +108 -0
- package/dist/exec/trace.js.map +1 -0
- package/dist/icons/generated/glyph-svg.d.ts +37 -0
- package/dist/icons/generated/glyph-svg.d.ts.map +1 -0
- package/dist/icons/generated/glyph-svg.js +33 -0
- package/dist/icons/generated/glyph-svg.js.map +1 -0
- package/dist/icons/glyph-slots.d.ts +79 -0
- package/dist/icons/glyph-slots.d.ts.map +1 -0
- package/dist/icons/glyph-slots.js +50 -0
- package/dist/icons/glyph-slots.js.map +1 -0
- package/dist/icons/glyph.d.ts +76 -0
- package/dist/icons/glyph.d.ts.map +1 -0
- package/dist/icons/glyph.js +42 -0
- package/dist/icons/glyph.js.map +1 -0
- package/dist/icons/icon-fonts.d.ts +55 -0
- package/dist/icons/icon-fonts.d.ts.map +1 -0
- package/dist/icons/icon-fonts.js +74 -0
- package/dist/icons/icon-fonts.js.map +1 -0
- package/dist/icons/icon.d.ts +102 -0
- package/dist/icons/icon.d.ts.map +1 -0
- package/dist/icons/icon.js +132 -0
- package/dist/icons/icon.js.map +1 -0
- package/dist/icons/index.d.ts +7 -0
- package/dist/icons/index.d.ts.map +1 -0
- package/dist/icons/index.js +6 -0
- package/dist/icons/svg.d.ts +28 -0
- package/dist/icons/svg.d.ts.map +1 -0
- package/dist/icons/svg.js +59 -0
- package/dist/icons/svg.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/services/abort.d.ts +31 -0
- package/dist/services/abort.d.ts.map +1 -0
- package/dist/services/abort.js +47 -0
- package/dist/services/abort.js.map +1 -0
- package/dist/services/clock.d.ts +35 -0
- package/dist/services/clock.d.ts.map +1 -0
- package/dist/services/clock.js +37 -0
- package/dist/services/clock.js.map +1 -0
- package/dist/services/contracts.d.ts +200 -0
- package/dist/services/contracts.d.ts.map +1 -0
- package/dist/services/contracts.js +37 -0
- package/dist/services/contracts.js.map +1 -0
- package/dist/services/index.d.ts +5 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +4 -0
- package/dist/services/preferences.d.ts +105 -0
- package/dist/services/preferences.d.ts.map +1 -0
- package/dist/services/preferences.js +253 -0
- package/dist/services/preferences.js.map +1 -0
- package/dist/theme/color.d.ts +94 -0
- package/dist/theme/color.d.ts.map +1 -0
- package/dist/theme/color.js +150 -0
- package/dist/theme/color.js.map +1 -0
- package/dist/theme/control-colors.d.ts +46 -0
- package/dist/theme/control-colors.d.ts.map +1 -0
- package/dist/theme/control-colors.js +46 -0
- package/dist/theme/control-colors.js.map +1 -0
- package/dist/theme/index.d.ts +5 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +4 -0
- package/dist/theme/theme.d.ts +88 -0
- package/dist/theme/theme.d.ts.map +1 -0
- package/dist/theme/theme.js +190 -0
- package/dist/theme/theme.js.map +1 -0
- package/dist/theme/variants.d.ts +33 -0
- package/dist/theme/variants.d.ts.map +1 -0
- package/dist/theme/variants.js +53 -0
- package/dist/theme/variants.js.map +1 -0
- package/dist/tokens/css-vars.d.ts +41 -0
- package/dist/tokens/css-vars.d.ts.map +1 -0
- package/dist/tokens/css-vars.js +55 -0
- package/dist/tokens/css-vars.js.map +1 -0
- package/dist/tokens/generated/metrics.d.ts +184 -0
- package/dist/tokens/generated/metrics.d.ts.map +1 -0
- package/dist/tokens/generated/metrics.js +349 -0
- package/dist/tokens/generated/metrics.js.map +1 -0
- package/dist/tokens/generated/palettes.d.ts +113 -0
- package/dist/tokens/generated/palettes.d.ts.map +1 -0
- package/dist/tokens/generated/palettes.js +391 -0
- package/dist/tokens/generated/palettes.js.map +1 -0
- package/dist/tokens/index.d.ts +5 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +4 -0
- package/dist/tokens/layout-metrics.d.ts +120 -0
- package/dist/tokens/layout-metrics.d.ts.map +1 -0
- package/dist/tokens/layout-metrics.js +111 -0
- package/dist/tokens/layout-metrics.js.map +1 -0
- package/docs/api.md +369 -0
- package/docs/foundation.md +370 -0
- package/docs/migration/Core.Controls.Shared.md +475 -0
- package/docs/migration/Core.Helpers.md +132 -0
- package/docs/migration/Core.Icons.md +135 -0
- package/docs/migration/Core.Localization.md +118 -0
- package/docs/migration/Core.Storage.md +54 -0
- package/docs/migration/Core.Theming.md +328 -0
- package/package.json +59 -4
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The library's own built-in glyph set (MAUI `G9Glyph`): the control-chrome affordances the controls need to look right
|
|
3
|
+
* with no icon font configured. They are vector paths (MAUI ADR-0003), rendered as SVG by `svgForGlyph`; for anything
|
|
4
|
+
* else register an icon font (`createIconFontRegistry`) and pass a font icon. Values are the camelCase member names.
|
|
5
|
+
*/
|
|
6
|
+
export declare const G9Glyph: {
|
|
7
|
+
/** No glyph. Renders nothing. */
|
|
8
|
+
readonly None: "none";
|
|
9
|
+
/** Downward chevron. The dropdown affordance on picker-like fields. */
|
|
10
|
+
readonly ChevronDown: "chevronDown";
|
|
11
|
+
/** Upward chevron. The collapse affordance on expanders. */
|
|
12
|
+
readonly ChevronUp: "chevronUp";
|
|
13
|
+
/** Leading-edge chevron (points physically left). */
|
|
14
|
+
readonly ChevronLeft: "chevronLeft";
|
|
15
|
+
/** Trailing-edge chevron (points physically right). Drill-down affordance. */
|
|
16
|
+
readonly ChevronRight: "chevronRight";
|
|
17
|
+
/**
|
|
18
|
+
* A back arrow WITH a shaft (←), not a bare chevron. Mirror by choosing `ArrowForward` in RTL, never by flipping the
|
|
19
|
+
* drawing (that reverses every other glyph too).
|
|
20
|
+
*/
|
|
21
|
+
readonly ArrowBack: "arrowBack";
|
|
22
|
+
/** A forward arrow WITH a shaft (→). The RTL counterpart of `ArrowBack`. */
|
|
23
|
+
readonly ArrowForward: "arrowForward";
|
|
24
|
+
/** A cross. Close / clear / dismiss. */
|
|
25
|
+
readonly Close: "close";
|
|
26
|
+
/** A magnifier. Search fields and the selection sheet's filter box. */
|
|
27
|
+
readonly Search: "search";
|
|
28
|
+
/** A globe. The language / locale switcher (deliberately not a status glyph). */
|
|
29
|
+
readonly Language: "language";
|
|
30
|
+
/** A cloud with a strike. "No connection" / offline, as distinct from a generic notice. */
|
|
31
|
+
readonly CloudOff: "cloudOff";
|
|
32
|
+
/** A QR / barcode scanner frame. The call-to-action on a scanner-aware entry; deliberately not a magnifier. */
|
|
33
|
+
readonly ScanCode: "scanCode";
|
|
34
|
+
/** An open eye. "Password is visible." */
|
|
35
|
+
readonly Eye: "eye";
|
|
36
|
+
/** A struck-through eye. "Password is hidden." */
|
|
37
|
+
readonly EyeOff: "eyeOff";
|
|
38
|
+
/** A tick. Selection confirmation and the picker sheet's Done action. */
|
|
39
|
+
readonly Check: "check";
|
|
40
|
+
/** A tick inside a circle. The Success popup / toast accent glyph. */
|
|
41
|
+
readonly CheckCircle: "checkCircle";
|
|
42
|
+
/** An exclamation mark inside a triangle. The Warning accent glyph. */
|
|
43
|
+
readonly Warning: "warning";
|
|
44
|
+
/** A cross inside a circle. The Error accent glyph. */
|
|
45
|
+
readonly ErrorCircle: "errorCircle";
|
|
46
|
+
/** An "i" inside a circle. The Information accent glyph. */
|
|
47
|
+
readonly Info: "info";
|
|
48
|
+
/** A calendar page. The date half of the date/time picker. */
|
|
49
|
+
readonly Calendar: "calendar";
|
|
50
|
+
/** A clock face. The time half of the date/time picker and duration pickers. */
|
|
51
|
+
readonly Clock: "clock";
|
|
52
|
+
/** A microphone. Voice input on the search entry. */
|
|
53
|
+
readonly Mic: "mic";
|
|
54
|
+
/** A struck-through microphone. Voice input unavailable or denied. */
|
|
55
|
+
readonly MicOff: "micOff";
|
|
56
|
+
/** A plus sign. The tab bar's centre action button. */
|
|
57
|
+
readonly Plus: "plus";
|
|
58
|
+
/** A minus sign. */
|
|
59
|
+
readonly Minus: "minus";
|
|
60
|
+
/** Three stacked bars. A menu / drawer affordance. */
|
|
61
|
+
readonly Menu: "menu";
|
|
62
|
+
/** A circular arrow. Refresh / retry. */
|
|
63
|
+
readonly Refresh: "refresh";
|
|
64
|
+
/** A trash can. Destructive swipe actions. */
|
|
65
|
+
readonly Delete: "delete";
|
|
66
|
+
};
|
|
67
|
+
export type G9Glyph = (typeof G9Glyph)[keyof typeof G9Glyph];
|
|
68
|
+
/** A glyph that draws something: every `G9Glyph` except `'none'`. */
|
|
69
|
+
export type G9DrawableGlyph = Exclude<G9Glyph, 'none'>;
|
|
70
|
+
/** Every glyph in MAUI declaration order; the index is the MAUI enum number (`'none'` is 0). */
|
|
71
|
+
export declare const g9Glyphs: readonly G9Glyph[];
|
|
72
|
+
/** True when `value` is one of the `G9Glyph` values (`'none'` included). */
|
|
73
|
+
export declare function isG9Glyph(value: unknown): value is G9Glyph;
|
|
74
|
+
/** Throws a `G9Error` with code `'icon-glyph'` unless `value` is a `G9Glyph` value. */
|
|
75
|
+
export declare function assertG9Glyph(value: unknown): asserts value is G9Glyph;
|
|
76
|
+
//# sourceMappingURL=glyph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glyph.d.ts","sourceRoot":"","sources":["../../src/icons/glyph.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,OAAO;IAClB,iCAAiC;;IAEjC,uEAAuE;;IAEvE,4DAA4D;;IAE5D,qDAAqD;;IAErD,8EAA8E;;IAE9E;;;OAGG;;IAEH,4EAA4E;;IAE5E,wCAAwC;;IAExC,uEAAuE;;IAEvE,iFAAiF;;IAEjF,2FAA2F;;IAE3F,+GAA+G;;IAE/G,0CAA0C;;IAE1C,kDAAkD;;IAElD,yEAAyE;;IAEzE,sEAAsE;;IAEtE,uEAAuE;;IAEvE,uDAAuD;;IAEvD,4DAA4D;;IAE5D,8DAA8D;;IAE9D,gFAAgF;;IAEhF,qDAAqD;;IAErD,sEAAsE;;IAEtE,uDAAuD;;IAEvD,oBAAoB;;IAEpB,sDAAsD;;IAEtD,yCAAyC;;IAEzC,8CAA8C;;CAEtC,CAAC;AACX,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;AAE7D,qEAAqE;AACrE,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAEvD,gGAAgG;AAChG,eAAO,MAAM,QAAQ,EAAE,SAAS,OAAO,EAEtC,CAAC;AAIF,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;AAED,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAOtE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { G9Error } from "../errors.js";
|
|
2
|
+
const G9Glyph = {
|
|
3
|
+
None: 'none',
|
|
4
|
+
ChevronDown: 'chevronDown',
|
|
5
|
+
ChevronUp: 'chevronUp',
|
|
6
|
+
ChevronLeft: 'chevronLeft',
|
|
7
|
+
ChevronRight: 'chevronRight',
|
|
8
|
+
ArrowBack: 'arrowBack',
|
|
9
|
+
ArrowForward: 'arrowForward',
|
|
10
|
+
Close: 'close',
|
|
11
|
+
Search: 'search',
|
|
12
|
+
Language: 'language',
|
|
13
|
+
CloudOff: 'cloudOff',
|
|
14
|
+
ScanCode: 'scanCode',
|
|
15
|
+
Eye: 'eye',
|
|
16
|
+
EyeOff: 'eyeOff',
|
|
17
|
+
Check: 'check',
|
|
18
|
+
CheckCircle: 'checkCircle',
|
|
19
|
+
Warning: 'warning',
|
|
20
|
+
ErrorCircle: 'errorCircle',
|
|
21
|
+
Info: 'info',
|
|
22
|
+
Calendar: 'calendar',
|
|
23
|
+
Clock: 'clock',
|
|
24
|
+
Mic: 'mic',
|
|
25
|
+
MicOff: 'micOff',
|
|
26
|
+
Plus: 'plus',
|
|
27
|
+
Minus: 'minus',
|
|
28
|
+
Menu: 'menu',
|
|
29
|
+
Refresh: 'refresh',
|
|
30
|
+
Delete: 'delete'
|
|
31
|
+
};
|
|
32
|
+
const g9Glyphs = Object.freeze(Object.keys(G9Glyph).map((k)=>G9Glyph[k]));
|
|
33
|
+
const glyphValues = new Set(g9Glyphs);
|
|
34
|
+
function isG9Glyph(value) {
|
|
35
|
+
return 'string' == typeof value && glyphValues.has(value);
|
|
36
|
+
}
|
|
37
|
+
function assertG9Glyph(value) {
|
|
38
|
+
if (!isG9Glyph(value)) throw new G9Error('icon-glyph', `${JSON.stringify(value)} is not a G9Glyph value (expected one of ${g9Glyphs.join(', ')}).`);
|
|
39
|
+
}
|
|
40
|
+
export { G9Glyph, assertG9Glyph, g9Glyphs, isG9Glyph };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=glyph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons/glyph.js","sources":["../../src/icons/glyph.ts"],"sourcesContent":["import { G9Error } from '../errors';\n\n/**\n * The library's own built-in glyph set (MAUI `G9Glyph`): the control-chrome affordances the controls need to look right\n * with no icon font configured. They are vector paths (MAUI ADR-0003), rendered as SVG by `svgForGlyph`; for anything\n * else register an icon font (`createIconFontRegistry`) and pass a font icon. Values are the camelCase member names.\n */\nexport const G9Glyph = {\n /** No glyph. Renders nothing. */\n None: 'none',\n /** Downward chevron. The dropdown affordance on picker-like fields. */\n ChevronDown: 'chevronDown',\n /** Upward chevron. The collapse affordance on expanders. */\n ChevronUp: 'chevronUp',\n /** Leading-edge chevron (points physically left). */\n ChevronLeft: 'chevronLeft',\n /** Trailing-edge chevron (points physically right). Drill-down affordance. */\n ChevronRight: 'chevronRight',\n /**\n * A back arrow WITH a shaft (←), not a bare chevron. Mirror by choosing `ArrowForward` in RTL, never by flipping the\n * drawing (that reverses every other glyph too).\n */\n ArrowBack: 'arrowBack',\n /** A forward arrow WITH a shaft (→). The RTL counterpart of `ArrowBack`. */\n ArrowForward: 'arrowForward',\n /** A cross. Close / clear / dismiss. */\n Close: 'close',\n /** A magnifier. Search fields and the selection sheet's filter box. */\n Search: 'search',\n /** A globe. The language / locale switcher (deliberately not a status glyph). */\n Language: 'language',\n /** A cloud with a strike. \"No connection\" / offline, as distinct from a generic notice. */\n CloudOff: 'cloudOff',\n /** A QR / barcode scanner frame. The call-to-action on a scanner-aware entry; deliberately not a magnifier. */\n ScanCode: 'scanCode',\n /** An open eye. \"Password is visible.\" */\n Eye: 'eye',\n /** A struck-through eye. \"Password is hidden.\" */\n EyeOff: 'eyeOff',\n /** A tick. Selection confirmation and the picker sheet's Done action. */\n Check: 'check',\n /** A tick inside a circle. The Success popup / toast accent glyph. */\n CheckCircle: 'checkCircle',\n /** An exclamation mark inside a triangle. The Warning accent glyph. */\n Warning: 'warning',\n /** A cross inside a circle. The Error accent glyph. */\n ErrorCircle: 'errorCircle',\n /** An \"i\" inside a circle. The Information accent glyph. */\n Info: 'info',\n /** A calendar page. The date half of the date/time picker. */\n Calendar: 'calendar',\n /** A clock face. The time half of the date/time picker and duration pickers. */\n Clock: 'clock',\n /** A microphone. Voice input on the search entry. */\n Mic: 'mic',\n /** A struck-through microphone. Voice input unavailable or denied. */\n MicOff: 'micOff',\n /** A plus sign. The tab bar's centre action button. */\n Plus: 'plus',\n /** A minus sign. */\n Minus: 'minus',\n /** Three stacked bars. A menu / drawer affordance. */\n Menu: 'menu',\n /** A circular arrow. Refresh / retry. */\n Refresh: 'refresh',\n /** A trash can. Destructive swipe actions. */\n Delete: 'delete',\n} as const;\nexport type G9Glyph = (typeof G9Glyph)[keyof typeof G9Glyph];\n\n/** A glyph that draws something: every `G9Glyph` except `'none'`. */\nexport type G9DrawableGlyph = Exclude<G9Glyph, 'none'>;\n\n/** Every glyph in MAUI declaration order; the index is the MAUI enum number (`'none'` is 0). */\nexport const g9Glyphs: readonly G9Glyph[] = Object.freeze(\n Object.keys(G9Glyph).map((k) => G9Glyph[k as keyof typeof G9Glyph]),\n);\n\nconst glyphValues = new Set<string>(g9Glyphs);\n\n/** True when `value` is one of the `G9Glyph` values (`'none'` included). */\nexport function isG9Glyph(value: unknown): value is G9Glyph {\n return typeof value === 'string' && glyphValues.has(value);\n}\n\n/** Throws a `G9Error` with code `'icon-glyph'` unless `value` is a `G9Glyph` value. */\nexport function assertG9Glyph(value: unknown): asserts value is G9Glyph {\n if (!isG9Glyph(value)) {\n throw new G9Error(\n 'icon-glyph',\n `${JSON.stringify(value)} is not a G9Glyph value (expected one of ${g9Glyphs.join(', ')}).`,\n );\n }\n}\n"],"names":["G9Glyph","g9Glyphs","Object","k","glyphValues","Set","isG9Glyph","value","assertG9Glyph","G9Error","JSON"],"mappings":";AAOO,MAAMA,UAAU;IAErB,MAAM;IAEN,aAAa;IAEb,WAAW;IAEX,aAAa;IAEb,cAAc;IAKd,WAAW;IAEX,cAAc;IAEd,OAAO;IAEP,QAAQ;IAER,UAAU;IAEV,UAAU;IAEV,UAAU;IAEV,KAAK;IAEL,QAAQ;IAER,OAAO;IAEP,aAAa;IAEb,SAAS;IAET,aAAa;IAEb,MAAM;IAEN,UAAU;IAEV,OAAO;IAEP,KAAK;IAEL,QAAQ;IAER,MAAM;IAEN,OAAO;IAEP,MAAM;IAEN,SAAS;IAET,QAAQ;AACV;AAOO,MAAMC,WAA+BC,OAAO,MAAM,CACvDA,OAAO,IAAI,CAACF,SAAS,GAAG,CAAC,CAACG,IAAMH,OAAO,CAACG,EAA0B;AAGpE,MAAMC,cAAc,IAAIC,IAAYJ;AAG7B,SAASK,UAAUC,KAAc;IACtC,OAAO,AAAiB,YAAjB,OAAOA,SAAsBH,YAAY,GAAG,CAACG;AACtD;AAGO,SAASC,cAAcD,KAAc;IAC1C,IAAI,CAACD,UAAUC,QACb,MAAM,IAAIE,QACR,cACA,GAAGC,KAAK,SAAS,CAACH,OAAO,yCAAyC,EAAEN,SAAS,IAAI,CAAC,MAAM,EAAE,CAAC;AAGjG"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type G9FontIcon, type G9Icon, type G9IconFontMemberValue } from './icon.js';
|
|
2
|
+
/**
|
|
3
|
+
* The registry of icon fonts and the by-name lookup that turns a name decided at runtime (an API response, a config
|
|
4
|
+
* row) into an icon (MAUI `G9IconFonts`). One registry per app; the WP02 provider owns it (no module-level state).
|
|
5
|
+
*
|
|
6
|
+
* Raw names, never a case-folded member parse: icon fonts contain names that collide once PascalCased (`hour-glass`
|
|
7
|
+
* and `hourglass` are different glyphs), so the registry keys on the raw name and only falls back to member names
|
|
8
|
+
* when the raw name has no entry. Keys compare ordinal-ignore-case, like the MAUI dictionaries.
|
|
9
|
+
*/
|
|
10
|
+
export interface G9IconFontRegistry {
|
|
11
|
+
/**
|
|
12
|
+
* The family registered with `register(…, { isDefault: true })` (the last such registration wins), or `undefined`.
|
|
13
|
+
* As in MAUI it never changes what `resolve` returns: unqualified member names are already first-come raw names.
|
|
14
|
+
*/
|
|
15
|
+
readonly defaultFontAlias: string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Registers an icon font's member table (MAUI `Register<TEnum>`; `font` plays the enum type name). Re-registering a
|
|
18
|
+
* family overwrites its `Font.Member` keys (members it no longer lists keep resolving, as in MAUI); an unqualified
|
|
19
|
+
* member name is first-come, so an earlier font is not shadowed by a later one, not even by the default font.
|
|
20
|
+
* Returns the font icons, as `defineIconFont` does.
|
|
21
|
+
*/
|
|
22
|
+
register<const TMembers extends Readonly<Record<string, G9IconFontMemberValue>>>(font: string, members: TMembers, options?: {
|
|
23
|
+
readonly isDefault?: boolean;
|
|
24
|
+
}): {
|
|
25
|
+
readonly [K in keyof TMembers]: G9FontIcon;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Maps one more raw name onto an icon (MAUI `RegisterName`): the font's own exported name when it differs from the
|
|
29
|
+
* member name. Overwrites an earlier mapping. A blank name throws.
|
|
30
|
+
*/
|
|
31
|
+
registerName(rawName: string, icon: G9Icon): void;
|
|
32
|
+
/**
|
|
33
|
+
* Resolves a name, or returns `fallback` (default `null`) when nothing matches (MAUI `Resolve(name)` and
|
|
34
|
+
* `Resolve(name, fallback)`). The name is trimmed; blank is no match. Tried in order: an exact registered raw name
|
|
35
|
+
* (`'hour-glass'`, `'MyIcons.Valve'`, and every registered member name, first font first); then a built-in `G9Glyph`
|
|
36
|
+
* (`'Search'`, `'chevronDown'`, or its MAUI number `'8'`).
|
|
37
|
+
*/
|
|
38
|
+
resolve(name: string | null | undefined): G9Icon | null;
|
|
39
|
+
resolve<TFallback extends G9Icon | null>(name: string | null | undefined, fallback: TFallback): G9Icon | TFallback;
|
|
40
|
+
/**
|
|
41
|
+
* Strict form for configuration text (MAUI implicit `string` conversion and `G9IconSourceTypeConverter`): blank →
|
|
42
|
+
* `null` (no icon); an unknown name throws a `G9Error` with code `'icon-unknown'` naming the value.
|
|
43
|
+
*/
|
|
44
|
+
parse(name: string | null | undefined): G9Icon | null;
|
|
45
|
+
/** Forgets every registration (MAUI `Reset`). */
|
|
46
|
+
reset(): void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The ordinal-ignore-case key of a name: each code point upper-cased when that maps to exactly one code point (a
|
|
50
|
+
* simple case mapping, like .NET `OrdinalIgnoreCase`; no Intl, no locale-specific rules).
|
|
51
|
+
*/
|
|
52
|
+
export declare function iconNameKey(name: string): string;
|
|
53
|
+
/** Creates an empty icon-font registry (MAUI `G9IconFonts`, without the process-wide static state). */
|
|
54
|
+
export declare function createIconFontRegistry(): G9IconFontRegistry;
|
|
55
|
+
//# sourceMappingURL=icon-fonts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-fonts.d.ts","sourceRoot":"","sources":["../../src/icons/icon-fonts.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,qBAAqB,EAE3B,MAAM,QAAQ,CAAC;AAEhB;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,QAAQ,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,EAC7E,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,QAAQ,EACjB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GACzC;QAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,QAAQ,GAAG,UAAU;KAAE,CAAC;IAClD;;;OAGG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAClD;;;;;OAKG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAAC;IACxD,OAAO,CAAC,SAAS,SAAS,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;IACnH;;;OAGG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAAC;IACtD,iDAAiD;IACjD,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOhD;AAoBD,uGAAuG;AACvG,wBAAgB,sBAAsB,IAAI,kBAAkB,CAsD3D"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { G9Error } from "../errors.js";
|
|
2
|
+
import { g9Glyphs } from "./glyph.js";
|
|
3
|
+
import { assertG9Icon, defineIconFont, glyphIcon } from "./icon.js";
|
|
4
|
+
function iconNameKey(name) {
|
|
5
|
+
let key = '';
|
|
6
|
+
for (const ch of name){
|
|
7
|
+
const upper = ch.toUpperCase();
|
|
8
|
+
key += 1 === [
|
|
9
|
+
...upper
|
|
10
|
+
].length ? upper : ch;
|
|
11
|
+
}
|
|
12
|
+
return key;
|
|
13
|
+
}
|
|
14
|
+
const isBlank = (value)=>/^\s*$/.test(value);
|
|
15
|
+
const glyphByKey = new Map(g9Glyphs.slice(1).map((glyph)=>[
|
|
16
|
+
iconNameKey(glyph),
|
|
17
|
+
glyphIcon(glyph)
|
|
18
|
+
]));
|
|
19
|
+
function resolveBuiltIn(name) {
|
|
20
|
+
const named = glyphByKey.get(iconNameKey(name));
|
|
21
|
+
if (named) return named;
|
|
22
|
+
if (/^[+-]?\d+$/.test(name)) {
|
|
23
|
+
const glyph = g9Glyphs[Number(name)];
|
|
24
|
+
if (void 0 !== glyph && 'none' !== glyph) return glyphIcon(glyph);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function createIconFontRegistry() {
|
|
28
|
+
const byName = new Map();
|
|
29
|
+
let defaultFontAlias;
|
|
30
|
+
function resolve(input) {
|
|
31
|
+
var _ref, _byName_get;
|
|
32
|
+
if ('string' != typeof input || isBlank(input)) return null;
|
|
33
|
+
const name = input.trim();
|
|
34
|
+
return null != (_ref = null != (_byName_get = byName.get(iconNameKey(name))) ? _byName_get : resolveBuiltIn(name)) ? _ref : null;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
get defaultFontAlias () {
|
|
38
|
+
return defaultFontAlias;
|
|
39
|
+
},
|
|
40
|
+
register (font, members, options) {
|
|
41
|
+
const icons = defineIconFont(font, members);
|
|
42
|
+
if ((null == options ? void 0 : options.isDefault) === true) defaultFontAlias = font;
|
|
43
|
+
for (const member of Object.keys(icons)){
|
|
44
|
+
const icon = icons[member];
|
|
45
|
+
byName.set(iconNameKey(`${font}.${member}`), icon);
|
|
46
|
+
const key = iconNameKey(member);
|
|
47
|
+
if (!byName.has(key)) byName.set(key, icon);
|
|
48
|
+
}
|
|
49
|
+
return icons;
|
|
50
|
+
},
|
|
51
|
+
registerName (rawName, icon) {
|
|
52
|
+
if ('string' != typeof rawName || isBlank(rawName)) throw new G9Error('icon-name', `An icon raw name must be a non-blank string (got ${JSON.stringify(rawName)}).`);
|
|
53
|
+
assertG9Icon(icon);
|
|
54
|
+
byName.set(iconNameKey(rawName), icon);
|
|
55
|
+
},
|
|
56
|
+
resolve (name, fallback = null) {
|
|
57
|
+
var _resolve;
|
|
58
|
+
return null != (_resolve = resolve(name)) ? _resolve : fallback;
|
|
59
|
+
},
|
|
60
|
+
parse (name) {
|
|
61
|
+
if ('string' != typeof name || isBlank(name)) return null;
|
|
62
|
+
const icon = resolve(name);
|
|
63
|
+
if (icon) return icon;
|
|
64
|
+
throw new G9Error('icon-unknown', `'${name}' is not a known icon. Use a G9Glyph (e.g. "Search"), a registered font member ("MyIcons.Valve"), or a name registered with registerName. Fonts are registered with register(font, members).`);
|
|
65
|
+
},
|
|
66
|
+
reset () {
|
|
67
|
+
byName.clear();
|
|
68
|
+
defaultFontAlias = void 0;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export { createIconFontRegistry, iconNameKey };
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=icon-fonts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons/icon-fonts.js","sources":["../../src/icons/icon-fonts.ts"],"sourcesContent":["import { G9Error } from '../errors';\nimport { g9Glyphs } from './glyph';\nimport {\n assertG9Icon,\n defineIconFont,\n type G9FontIcon,\n type G9Icon,\n type G9IconFontMemberValue,\n glyphIcon,\n} from './icon';\n\n/**\n * The registry of icon fonts and the by-name lookup that turns a name decided at runtime (an API response, a config\n * row) into an icon (MAUI `G9IconFonts`). One registry per app; the WP02 provider owns it (no module-level state).\n *\n * Raw names, never a case-folded member parse: icon fonts contain names that collide once PascalCased (`hour-glass`\n * and `hourglass` are different glyphs), so the registry keys on the raw name and only falls back to member names\n * when the raw name has no entry. Keys compare ordinal-ignore-case, like the MAUI dictionaries.\n */\nexport interface G9IconFontRegistry {\n /**\n * The family registered with `register(…, { isDefault: true })` (the last such registration wins), or `undefined`.\n * As in MAUI it never changes what `resolve` returns: unqualified member names are already first-come raw names.\n */\n readonly defaultFontAlias: string | undefined;\n /**\n * Registers an icon font's member table (MAUI `Register<TEnum>`; `font` plays the enum type name). Re-registering a\n * family overwrites its `Font.Member` keys (members it no longer lists keep resolving, as in MAUI); an unqualified\n * member name is first-come, so an earlier font is not shadowed by a later one, not even by the default font.\n * Returns the font icons, as `defineIconFont` does.\n */\n register<const TMembers extends Readonly<Record<string, G9IconFontMemberValue>>>(\n font: string,\n members: TMembers,\n options?: { readonly isDefault?: boolean },\n ): { readonly [K in keyof TMembers]: G9FontIcon };\n /**\n * Maps one more raw name onto an icon (MAUI `RegisterName`): the font's own exported name when it differs from the\n * member name. Overwrites an earlier mapping. A blank name throws.\n */\n registerName(rawName: string, icon: G9Icon): void;\n /**\n * Resolves a name, or returns `fallback` (default `null`) when nothing matches (MAUI `Resolve(name)` and\n * `Resolve(name, fallback)`). The name is trimmed; blank is no match. Tried in order: an exact registered raw name\n * (`'hour-glass'`, `'MyIcons.Valve'`, and every registered member name, first font first); then a built-in `G9Glyph`\n * (`'Search'`, `'chevronDown'`, or its MAUI number `'8'`).\n */\n resolve(name: string | null | undefined): G9Icon | null;\n resolve<TFallback extends G9Icon | null>(name: string | null | undefined, fallback: TFallback): G9Icon | TFallback;\n /**\n * Strict form for configuration text (MAUI implicit `string` conversion and `G9IconSourceTypeConverter`): blank →\n * `null` (no icon); an unknown name throws a `G9Error` with code `'icon-unknown'` naming the value.\n */\n parse(name: string | null | undefined): G9Icon | null;\n /** Forgets every registration (MAUI `Reset`). */\n reset(): void;\n}\n\n/**\n * The ordinal-ignore-case key of a name: each code point upper-cased when that maps to exactly one code point (a\n * simple case mapping, like .NET `OrdinalIgnoreCase`; no Intl, no locale-specific rules).\n */\nexport function iconNameKey(name: string): string {\n let key = '';\n for (const ch of name) {\n const upper = ch.toUpperCase();\n key += [...upper].length === 1 ? upper : ch;\n }\n return key;\n}\n\nconst isBlank = (value: string) => /^\\s*$/.test(value);\n\n// MAUI G9Glyph member names (PascalCase), by MAUI enum number; matched case-insensitively like Enum.TryParse(ignoreCase).\nconst glyphByKey = new Map<string, G9Icon>(\n g9Glyphs.slice(1).map((glyph) => [iconNameKey(glyph), glyphIcon(glyph)] as const),\n);\n\nfunction resolveBuiltIn(name: string): G9Icon | undefined {\n const named = glyphByKey.get(iconNameKey(name));\n if (named) return named;\n // Enum.TryParse also reads the member number (\"8\" → Search). Only defined, non-None numbers resolve here.\n if (/^[+-]?\\d+$/.test(name)) {\n const glyph = g9Glyphs[Number(name)];\n if (glyph !== undefined && glyph !== 'none') return glyphIcon(glyph);\n }\n return undefined;\n}\n\n/** Creates an empty icon-font registry (MAUI `G9IconFonts`, without the process-wide static state). */\nexport function createIconFontRegistry(): G9IconFontRegistry {\n const byName = new Map<string, G9Icon>();\n let defaultFontAlias: string | undefined;\n\n // MAUI Resolve also tries (3) `Font.Member` through the per-font member map and (4) an unqualified member of the\n // default font. Both are unreachable: Register writes `Font.Member` and (first-come) `Member` into the raw-name map\n // as well, so step 1 already answers every name steps 3 and 4 could. The port keeps the observable result (an\n // earlier font's member beats the default font's) without the dead lookups; `defaultFontAlias` is still reported.\n function resolve(input: string | null | undefined): G9Icon | null {\n if (typeof input !== 'string' || isBlank(input)) return null;\n const name = input.trim();\n return byName.get(iconNameKey(name)) ?? resolveBuiltIn(name) ?? null;\n }\n\n return {\n get defaultFontAlias() {\n return defaultFontAlias;\n },\n register(font, members, options) {\n const icons = defineIconFont(font, members);\n if (options?.isDefault === true) defaultFontAlias = font;\n for (const member of Object.keys(icons)) {\n const icon = icons[member] as G9FontIcon;\n byName.set(iconNameKey(`${font}.${member}`), icon);\n const key = iconNameKey(member);\n if (!byName.has(key)) byName.set(key, icon);\n }\n return icons;\n },\n registerName(rawName, icon) {\n if (typeof rawName !== 'string' || isBlank(rawName)) {\n throw new G9Error('icon-name', `An icon raw name must be a non-blank string (got ${JSON.stringify(rawName)}).`);\n }\n assertG9Icon(icon);\n byName.set(iconNameKey(rawName), icon);\n },\n resolve(name: string | null | undefined, fallback: G9Icon | null = null) {\n return resolve(name) ?? fallback;\n },\n parse(name) {\n if (typeof name !== 'string' || isBlank(name)) return null;\n const icon = resolve(name);\n if (icon) return icon;\n throw new G9Error(\n 'icon-unknown',\n `'${name}' is not a known icon. Use a G9Glyph (e.g. \"Search\"), a registered font member (\"MyIcons.Valve\"), ` +\n 'or a name registered with registerName. Fonts are registered with register(font, members).',\n );\n },\n reset() {\n byName.clear();\n defaultFontAlias = undefined;\n },\n } as G9IconFontRegistry;\n}\n"],"names":["iconNameKey","name","key","ch","upper","isBlank","value","glyphByKey","Map","g9Glyphs","glyph","glyphIcon","resolveBuiltIn","named","Number","undefined","createIconFontRegistry","byName","defaultFontAlias","resolve","input","_ref","font","members","options","icons","defineIconFont","member","Object","icon","rawName","G9Error","JSON","assertG9Icon","fallback","_resolve"],"mappings":";;;AA8DO,SAASA,YAAYC,IAAY;IACtC,IAAIC,MAA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AO;gBAC1BV,OAAO,GAAG,CAACjB,YAAY,GAAGsB,KAAK,CAAC,EAAEK,QAAQ,GAAGE;gBAC7C,MAAM3B,MAAMF,YAAY2B;gBACxB,IAAI,CAACV,OAAO,GAAG,CAACf,MAAMe,OAAO,GAAG,CAACf,KAAK2B;YACxC;YACA,OAAOJ;QACT;QACA,cAAaK,OAAO,EAAED,IAAI;YACxB,IAAI,AAAmB,YAAnB,OAAOC,WAAwBzB,QAAQyB,UACzC,MAAM,IAAIC,QAAQ,aAAa,CAAC,iDAAiD,EAAEC,KAAK,SAAS,CAACF,SAAS,EAAE,CAAC;YAEhHG,aAAaJ;YACbZ,OAAO,GAAG,CAACjB,YAAY8B,UAAUD;QACnC;QACA,SAAQ5B,IAA+B,EAAEiC,WAA0B,IAAI;gBAC9DC;YAAP,OAAO,QAAAA,CAAAA,WAAAA,QAAQlC,KAAI,IAAZkC,WAAiBD;QAC1B;QACA,OAAMjC,IAAI;YACR,IAAI,AAAgB,YAAhB,OAAOA,QAAqBI,QAAQJ,OAAO,OAAO;YACtD,MAAM4B,OAAOV,QAAQlB;YACrB,IAAI4B,MAAM,OAAOA;YACjB,MAAM,IAAIE,QACR,gBACA,CAAC,CAAC,EAAE9B,KAAK,4LAAkG,CAAC;QAGhH;QACA;YACEgB,OAAO,KAAK;YACZC,mBAAmBH;QACrB;IACF;AACF"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type G9Glyph } from './glyph.js';
|
|
2
|
+
/** A built-in vector glyph (MAUI `G9IconSource.FromGlyph`). `{ glyph: 'none' }` is an empty icon. */
|
|
3
|
+
export interface G9GlyphIcon {
|
|
4
|
+
readonly glyph: G9Glyph;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A glyph of an icon font, given as a code point (MAUI `G9IconSource.FromCodePoint`). `font` is the font family the
|
|
8
|
+
* renderer uses (MAUI: the enum type name / the `fonts.AddFont` alias).
|
|
9
|
+
*/
|
|
10
|
+
export interface G9FontCodePointIcon {
|
|
11
|
+
readonly font: string;
|
|
12
|
+
readonly codepoint: number;
|
|
13
|
+
}
|
|
14
|
+
/** A glyph of an icon font, given as its literal text (MAUI `G9IconSource.FromFont`), e.g. a surrogate pair or a ligature. */
|
|
15
|
+
export interface G9FontTextIcon {
|
|
16
|
+
readonly font: string;
|
|
17
|
+
readonly text: string;
|
|
18
|
+
}
|
|
19
|
+
/** A glyph of an icon font. Two font icons are equal when their family and glyph text are equal. */
|
|
20
|
+
export type G9FontIcon = G9FontCodePointIcon | G9FontTextIcon;
|
|
21
|
+
/** An icon given as an SVG document (rendered with Lynx `<svg content>` in WP02). */
|
|
22
|
+
export interface G9SvgIcon {
|
|
23
|
+
readonly svg: string;
|
|
24
|
+
}
|
|
25
|
+
/** A bitmap or vector image (plan/specs/03-API-Conventions.md §2); rendering needs the host image service (WP02). */
|
|
26
|
+
export type G9ImageSource = {
|
|
27
|
+
readonly uri: string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly asset: string;
|
|
30
|
+
} | {
|
|
31
|
+
readonly svg: string;
|
|
32
|
+
};
|
|
33
|
+
/** An icon given as an image. */
|
|
34
|
+
export interface G9ImageIcon {
|
|
35
|
+
readonly image: G9ImageSource;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* One icon from any source: the single type every icon slot accepts (MAUI `G9IconSource`, ADR-0002). A slot with no
|
|
39
|
+
* icon is `null`/`undefined` (MAUI `G9IconSource.Empty`); `{ glyph: 'none' }` is also empty.
|
|
40
|
+
*/
|
|
41
|
+
export type G9Icon = G9GlyphIcon | G9FontIcon | G9SvgIcon | G9ImageIcon;
|
|
42
|
+
/** A built-in glyph icon (MAUI `G9IconSource.FromGlyph` and the implicit `G9Glyph` conversion). Unknown glyphs throw. */
|
|
43
|
+
export declare function glyphIcon(glyph: G9Glyph): G9GlyphIcon;
|
|
44
|
+
/** A font glyph given as its literal text (MAUI `G9IconSource.FromFont`). Blank family or empty text throws. */
|
|
45
|
+
export declare function fontIcon(font: string, text: string): G9FontTextIcon;
|
|
46
|
+
/**
|
|
47
|
+
* A font glyph given as a code point, e.g. `0xE801` (MAUI `G9IconSource.FromCodePoint`). Above U+FFFF the glyph text is
|
|
48
|
+
* a surrogate pair. A blank family or a non-scalar code point throws.
|
|
49
|
+
*/
|
|
50
|
+
export declare function codePointIcon(font: string, codepoint: number): G9FontCodePointIcon;
|
|
51
|
+
/** True for a built-in glyph icon that draws something (MAUI `G9IconSource.IsBuiltIn`). */
|
|
52
|
+
export declare function isGlyphIcon(icon: G9Icon | null | undefined): icon is G9GlyphIcon;
|
|
53
|
+
/** True for a font icon (code point or text). */
|
|
54
|
+
export declare function isFontIcon(icon: G9Icon | null | undefined): icon is G9FontIcon;
|
|
55
|
+
/** True for an SVG icon. */
|
|
56
|
+
export declare function isSvgIcon(icon: G9Icon | null | undefined): icon is G9SvgIcon;
|
|
57
|
+
/** True for an image icon. */
|
|
58
|
+
export declare function isImageIcon(icon: G9Icon | null | undefined): icon is G9ImageIcon;
|
|
59
|
+
/** True when the value carries no icon: `null`, `undefined` or `{ glyph: 'none' }` (MAUI `G9IconSource.IsEmpty`). */
|
|
60
|
+
export declare function isIconEmpty(icon: G9Icon | null | undefined): icon is null | undefined | G9GlyphIcon;
|
|
61
|
+
/** The built-in glyph of an icon, or `'none'` for every other icon (MAUI `G9IconSource.BuiltIn`). */
|
|
62
|
+
export declare function builtInGlyph(icon: G9Icon | null | undefined): G9Glyph;
|
|
63
|
+
/**
|
|
64
|
+
* The glyph text of a font icon, a code point converted to its (possibly surrogate-pair) string, or `undefined` for
|
|
65
|
+
* every other icon (MAUI `G9IconSource.Glyph`).
|
|
66
|
+
*/
|
|
67
|
+
export declare function fontIconText(icon: G9Icon | null | undefined): string | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Throws a `G9Error` unless `value` is a well-formed `G9Icon` (exactly one of the four shapes, valid glyph, family,
|
|
70
|
+
* text, code point, SVG or image). Use at configuration boundaries; the constructors already validate.
|
|
71
|
+
*/
|
|
72
|
+
export declare function assertG9Icon(value: unknown): asserts value is G9Icon;
|
|
73
|
+
/**
|
|
74
|
+
* Value equality (MAUI `G9IconSource.Equals`, `==`, `!=`): same built-in glyph, or same family and glyph text (ordinal;
|
|
75
|
+
* a code point equals the text it converts to), or same SVG / image reference. All empty values are equal.
|
|
76
|
+
*/
|
|
77
|
+
export declare function iconEquals(a: G9Icon | null | undefined, b: G9Icon | null | undefined): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* A stable identity string that changes if and only if the icon changes (MAUI `G9IconSource.ToString`):
|
|
80
|
+
* `builtin:<glyph>`, `<font>:<text>`, `svg:<svg>`, `image:<kind>:<ref>`, or `''` when empty. Renderers compare it to
|
|
81
|
+
* decide whether an icon host needs rebuilding.
|
|
82
|
+
*/
|
|
83
|
+
export declare function iconSignature(icon: G9Icon | null | undefined): string;
|
|
84
|
+
/**
|
|
85
|
+
* Normalises a slot value (MAUI implicit `G9Glyph` conversion): a `G9Glyph` string becomes `glyphIcon(value)`, an icon
|
|
86
|
+
* is validated and returned, `null`/`undefined` become `null` (no icon). Anything malformed throws a `G9Error`.
|
|
87
|
+
*/
|
|
88
|
+
export declare function toIcon(value: G9Icon | G9Glyph | null | undefined): G9Icon | null;
|
|
89
|
+
/**
|
|
90
|
+
* The value of each member of an icon-font table: glyph text (MAUI `[Description]`) or a code point (MAUI
|
|
91
|
+
* `Valve = 0xE801` without a description).
|
|
92
|
+
*/
|
|
93
|
+
export type G9IconFontMemberValue = string | number;
|
|
94
|
+
/**
|
|
95
|
+
* Builds the frozen font icons of an icon-font table (MAUI `G9IconSource.FromEnum` and the implicit enum conversion):
|
|
96
|
+
* family = `font`, each member's glyph = its text, or its number read as a code point. An empty text throws (MAUI throws
|
|
97
|
+
* for an empty `[Description]`: a silently empty slot is harder to diagnose than a throw).
|
|
98
|
+
*/
|
|
99
|
+
export declare function defineIconFont<const TMembers extends Readonly<Record<string, G9IconFontMemberValue>>>(font: string, members: TMembers): {
|
|
100
|
+
readonly [K in keyof TMembers]: G9FontIcon;
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=icon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../src/icons/icon.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;AAEtD,qGAAqG;AACrG,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,8HAA8H;AAC9H,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,oGAAoG;AACpG,MAAM,MAAM,UAAU,GAAG,mBAAmB,GAAG,cAAc,CAAC;AAE9D,qFAAqF;AACrF,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,qHAAqH;AACrH,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7G,iCAAiC;AACjC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,CAAC;AA0CxE,yHAAyH;AACzH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAGrD;AAED,gHA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AG,OAAO,CAU9F;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAOrE;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAKhF;AAED;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,CAAC,QAAQ,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,EACnG,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,QAAQ,GAChB;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,QAAQ,GAAG,UAAU;CAAE,CAmBhD"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { G9Error } from "../errors.js";
|
|
2
|
+
import { assertG9Glyph } from "./glyph.js";
|
|
3
|
+
const isObject = (value)=>'object' == typeof value && null !== value;
|
|
4
|
+
const isBlank = (value)=>/^\s*$/.test(value);
|
|
5
|
+
function isScalarValue(codepoint) {
|
|
6
|
+
return Number.isInteger(codepoint) && codepoint >= 0 && codepoint <= 0x10ffff && !(codepoint >= 0xd800 && codepoint <= 0xdfff);
|
|
7
|
+
}
|
|
8
|
+
function requireFont(font) {
|
|
9
|
+
if ('string' != typeof font || isBlank(font)) throw new G9Error('icon-font', `An icon font family must be a non-blank string (got ${JSON.stringify(font)}).`);
|
|
10
|
+
return font;
|
|
11
|
+
}
|
|
12
|
+
function requireText(text) {
|
|
13
|
+
if ('string' != typeof text || 0 === text.length) throw new G9Error('icon-font', `A font icon's glyph text must be a non-empty string (got ${JSON.stringify(text)}).`);
|
|
14
|
+
return text;
|
|
15
|
+
}
|
|
16
|
+
function requireCodePoint(codepoint) {
|
|
17
|
+
if ('number' != typeof codepoint || !isScalarValue(codepoint)) throw new G9Error('icon-codepoint', `${String(codepoint)} is not a Unicode scalar value (0–0x10FFFF, no surrogates).`);
|
|
18
|
+
return codepoint;
|
|
19
|
+
}
|
|
20
|
+
function glyphIcon(glyph) {
|
|
21
|
+
assertG9Glyph(glyph);
|
|
22
|
+
return Object.freeze({
|
|
23
|
+
glyph
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function fontIcon(font, text) {
|
|
27
|
+
return Object.freeze({
|
|
28
|
+
font: requireFont(font),
|
|
29
|
+
text: requireText(text)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function codePointIcon(font, codepoint) {
|
|
33
|
+
return Object.freeze({
|
|
34
|
+
font: requireFont(font),
|
|
35
|
+
codepoint: requireCodePoint(codepoint)
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function isGlyphIcon(icon) {
|
|
39
|
+
return isObject(icon) && 'glyph' in icon && 'none' !== icon.glyph;
|
|
40
|
+
}
|
|
41
|
+
function isFontIcon(icon) {
|
|
42
|
+
return isObject(icon) && 'font' in icon;
|
|
43
|
+
}
|
|
44
|
+
function isSvgIcon(icon) {
|
|
45
|
+
return isObject(icon) && 'svg' in icon;
|
|
46
|
+
}
|
|
47
|
+
function isImageIcon(icon) {
|
|
48
|
+
return isObject(icon) && 'image' in icon;
|
|
49
|
+
}
|
|
50
|
+
function isIconEmpty(icon) {
|
|
51
|
+
return null == icon || 'glyph' in icon && 'none' === icon.glyph;
|
|
52
|
+
}
|
|
53
|
+
function builtInGlyph(icon) {
|
|
54
|
+
return null != icon && 'glyph' in icon ? icon.glyph : 'none';
|
|
55
|
+
}
|
|
56
|
+
function fontIconText(icon) {
|
|
57
|
+
if (!isFontIcon(icon)) return;
|
|
58
|
+
return 'text' in icon ? icon.text : String.fromCodePoint(icon.codepoint);
|
|
59
|
+
}
|
|
60
|
+
function assertG9Icon(value) {
|
|
61
|
+
if (!isObject(value)) throw new G9Error('icon-shape', `An icon must be an object (got ${JSON.stringify(value)}).`);
|
|
62
|
+
const kinds = [
|
|
63
|
+
'glyph',
|
|
64
|
+
'font',
|
|
65
|
+
'svg',
|
|
66
|
+
'image'
|
|
67
|
+
].filter((k)=>k in value);
|
|
68
|
+
if (1 !== kinds.length) throw new G9Error('icon-shape', `An icon has exactly one of glyph, font, svg or image (got ${kinds.join(', ') || 'none'}).`);
|
|
69
|
+
if ('glyph' in value) return assertG9Glyph(value.glyph);
|
|
70
|
+
if ('font' in value) {
|
|
71
|
+
requireFont(value.font);
|
|
72
|
+
const hasText = 'text' in value;
|
|
73
|
+
if (hasText === 'codepoint' in value) throw new G9Error('icon-shape', 'A font icon has exactly one of text or codepoint.');
|
|
74
|
+
if (hasText) requireText(value.text);
|
|
75
|
+
else requireCodePoint(value.codepoint);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if ('svg' in value) {
|
|
79
|
+
if ('string' != typeof value.svg || isBlank(value.svg)) throw new G9Error('icon-shape', 'An SVG icon needs a non-blank svg string.');
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const image = value.image;
|
|
83
|
+
const valid = isObject(image) && 1 === Object.keys(image).length && [
|
|
84
|
+
'uri',
|
|
85
|
+
'asset',
|
|
86
|
+
'svg'
|
|
87
|
+
].some((k)=>'string' == typeof image[k] && !isBlank(image[k]));
|
|
88
|
+
if (!valid) throw new G9Error('icon-shape', 'An image icon needs exactly one non-blank uri, asset or svg.');
|
|
89
|
+
}
|
|
90
|
+
function iconEquals(a, b) {
|
|
91
|
+
if (isIconEmpty(a) || isIconEmpty(b)) return isIconEmpty(a) && isIconEmpty(b);
|
|
92
|
+
if ('glyph' in a || 'glyph' in b) return 'glyph' in a && 'glyph' in b && a.glyph === b.glyph;
|
|
93
|
+
if (isFontIcon(a) || isFontIcon(b)) return isFontIcon(a) && isFontIcon(b) && a.font === b.font && fontIconText(a) === fontIconText(b);
|
|
94
|
+
if ('svg' in a || 'svg' in b) return 'svg' in a && 'svg' in b && a.svg === b.svg;
|
|
95
|
+
const x = a.image;
|
|
96
|
+
const y = b.image;
|
|
97
|
+
return [
|
|
98
|
+
'uri',
|
|
99
|
+
'asset',
|
|
100
|
+
'svg'
|
|
101
|
+
].some((k)=>k in x && k in y && x[k] === y[k]);
|
|
102
|
+
}
|
|
103
|
+
function iconSignature(icon) {
|
|
104
|
+
if (isIconEmpty(icon)) return '';
|
|
105
|
+
if ('glyph' in icon) return `builtin:${icon.glyph}`;
|
|
106
|
+
if (isFontIcon(icon)) return `${icon.font}:${fontIconText(icon)}`;
|
|
107
|
+
if ('svg' in icon) return `svg:${icon.svg}`;
|
|
108
|
+
const [kind, ref] = Object.entries(icon.image)[0];
|
|
109
|
+
return `image:${kind}:${ref}`;
|
|
110
|
+
}
|
|
111
|
+
function toIcon(value) {
|
|
112
|
+
if (null == value) return null;
|
|
113
|
+
if ('string' == typeof value) return glyphIcon(value);
|
|
114
|
+
assertG9Icon(value);
|
|
115
|
+
return value;
|
|
116
|
+
}
|
|
117
|
+
function defineIconFont(font, members) {
|
|
118
|
+
requireFont(font);
|
|
119
|
+
if (!isObject(members)) throw new G9Error('icon-font', 'An icon-font table must be an object of member → glyph.');
|
|
120
|
+
const out = {};
|
|
121
|
+
for (const name of Object.keys(members)){
|
|
122
|
+
const value = members[name];
|
|
123
|
+
if (isBlank(name)) throw new G9Error('icon-font', `Icon font '${font}' has a blank member name.`);
|
|
124
|
+
if ('number' == typeof value) out[name] = codePointIcon(font, value);
|
|
125
|
+
else if ('string' == typeof value && value.length > 0) out[name] = fontIcon(font, value);
|
|
126
|
+
else throw new G9Error('icon-font', `Icon font member '${font}.${name}' has no glyph (empty text); there is nothing to render.`);
|
|
127
|
+
}
|
|
128
|
+
return Object.freeze(out);
|
|
129
|
+
}
|
|
130
|
+
export { assertG9Icon, builtInGlyph, codePointIcon, defineIconFont, fontIcon, fontIconText, glyphIcon, iconEquals, iconSignature, isFontIcon, isGlyphIcon, isIconEmpty, isImageIcon, isSvgIcon, toIcon };
|
|
131
|
+
|
|
132
|
+
//# sourceMappingURL=icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons/icon.js","sources":["../../src/icons/icon.ts"],"sourcesContent":["import { G9Error } from '../errors';\nimport { assertG9Glyph, type G9Glyph } from './glyph';\n\n/** A built-in vector glyph (MAUI `G9IconSource.FromGlyph`). `{ glyph: 'none' }` is an empty icon. */\nexport interface G9GlyphIcon {\n readonly glyph: G9Glyph;\n}\n\n/**\n * A glyph of an icon font, given as a code point (MAUI `G9IconSource.FromCodePoint`). `font` is the font family the\n * renderer uses (MAUI: the enum type name / the `fonts.AddFont` alias).\n */\nexport interface G9FontCodePointIcon {\n readonly font: string;\n readonly codepoint: number;\n}\n\n/** A glyph of an icon font, given as its literal text (MAUI `G9IconSource.FromFont`), e.g. a surrogate pair or a ligature. */\nexport interface G9FontTextIcon {\n readonly font: string;\n readonly text: string;\n}\n\n/** A glyph of an icon font. Two font icons are equal when their family and glyph text are equal. */\nexport type G9FontIcon = G9FontCodePointIcon | G9FontTextIcon;\n\n/** An icon given as an SVG document (rendered with Lynx `<svg content>` in WP02). */\nexport interface G9SvgIcon {\n readonly svg: string;\n}\n\n/** A bitmap or vector image (plan/specs/03-API-Conventions.md §2); rendering needs the host image service (WP02). */\nexport type G9ImageSource = { readonly uri: string } | { readonly asset: string } | { readonly svg: string };\n\n/** An icon given as an image. */\nexport interface G9ImageIcon {\n readonly image: G9ImageSource;\n}\n\n/**\n * One icon from any source: the single type every icon slot accepts (MAUI `G9IconSource`, ADR-0002). A slot with no\n * icon is `null`/`undefined` (MAUI `G9IconSource.Empty`); `{ glyph: 'none' }` is also empty.\n */\nexport type G9Icon = G9GlyphIcon | G9FontIcon | G9SvgIcon | G9ImageIcon;\n\nconst isObject = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null;\nconst isBlank = (value: string) => /^\\s*$/.test(value);\n\n/** True for a valid Unicode scalar value: 0–0x10FFFF outside the surrogate range (.NET `char.ConvertFromUtf32`). */\nfunction isScalarValue(codepoint: number): boolean {\n return (\n Number.isInteger(codepoint) &&\n codepoint >= 0 &&\n codepoint <= 0x10ffff &&\n !(codepoint >= 0xd800 && codepoint <= 0xdfff)\n );\n}\n\nfunction requireFont(font: unknown): string {\n if (typeof font !== 'string' || isBlank(font)) {\n throw new G9Error('icon-font', `An icon font family must be a non-blank string (got ${JSON.stringify(font)}).`);\n }\n return font;\n}\n\nfunction requireText(text: unknown): string {\n if (typeof text !== 'string' || text.length === 0) {\n throw new G9Error(\n 'icon-font',\n `A font icon's glyph text must be a non-empty string (got ${JSON.stringify(text)}).`,\n );\n }\n return text;\n}\n\nfunction requireCodePoint(codepoint: unknown): number {\n if (typeof codepoint !== 'number' || !isScalarValue(codepoint)) {\n throw new G9Error(\n 'icon-codepoint',\n `${String(codepoint)} is not a Unicode scalar value (0–0x10FFFF, no surrogates).`,\n );\n }\n return codepoint;\n}\n\n/** A built-in glyph icon (MAUI `G9IconSource.FromGlyph` and the implicit `G9Glyph` conversion). Unknown glyphs throw. */\nexport function glyphIcon(glyph: G9Glyph): G9GlyphIcon {\n assertG9Glyph(glyph);\n return Object.freeze({ glyph });\n}\n\n/** A font glyph given as its literal text (MAUI `G9IconSource.FromFont`). Blank family or empty text throws. */\nexport function fontIcon(font: string, text: string): G9FontTextIcon {\n return Object.freeze({ font: requireFont(font), text: requireText(text) });\n}\n\n/**\n * A font glyph given as a code point, e.g. `0xE801` (MAUI `G9IconSource.FromCodePoint`). Above U+FFFF the glyph text is\n * a surrogate pair. A blank family or a non-scalar code point throws.\n */\nexport function codePointIcon(font: string, codepoint: number): G9FontCodePointIcon {\n return Object.freeze({ font: requireFont(font), codepoint: requireCodePoint(codepoint) });\n}\n\n/** True for a built-in glyph icon that draws something (MAUI `G9IconSource.IsBuiltIn`). */\nexport function isGlyphIcon(icon: G9Icon | null | undefined): icon is G9GlyphIcon {\n return isObject(icon) && 'glyph' in icon && icon.glyph !== 'none';\n}\n\n/** True for a font icon (code point or text). */\nexport function isFontIcon(icon: G9Icon | null | undefined): icon is G9FontIcon {\n return isObject(icon) && 'font' in icon;\n}\n\n/** True for an SVG icon. */\nexport function isSvgIcon(icon: G9Icon | null | undefined): icon is G9SvgIcon {\n return isObject(icon) && 'svg' in icon;\n}\n\n/** True for an image icon. */\nexport function isImageIcon(icon: G9Icon | null | undefined): icon is G9ImageIcon {\n return isObject(icon) && 'image' in icon;\n}\n\n/** True when the value carries no icon: `null`, `undefined` or `{ glyph: 'none' }` (MAUI `G9IconSource.IsEmpty`). */\nexport function isIconEmpty(icon: G9Icon | null | undefined): icon is null | undefined | G9GlyphIcon {\n return icon === null || icon === undefined || ('glyph' in icon && icon.glyph === 'none');\n}\n\n/** The built-in glyph of an icon, or `'none'` for every other icon (MAUI `G9IconSource.BuiltIn`). */\nexport function builtInGlyph(icon: G9Icon | null | undefined): G9Glyph {\n return icon !== null && icon !== undefined && 'glyph' in icon ? icon.glyph : 'none';\n}\n\n/**\n * The glyph text of a font icon, a code point converted to its (possibly surrogate-pair) string, or `undefined` for\n * every other icon (MAUI `G9IconSource.Glyph`).\n */\nexport function fontIconText(icon: G9Icon | null | undefined): string | undefined {\n if (!isFontIcon(icon)) return undefined;\n return 'text' in icon ? icon.text : String.fromCodePoint(icon.codepoint);\n}\n\n/**\n * Throws a `G9Error` unless `value` is a well-formed `G9Icon` (exactly one of the four shapes, valid glyph, family,\n * text, code point, SVG or image). Use at configuration boundaries; the constructors already validate.\n */\nexport function assertG9Icon(value: unknown): asserts value is G9Icon {\n if (!isObject(value)) throw new G9Error('icon-shape', `An icon must be an object (got ${JSON.stringify(value)}).`);\n const kinds = ['glyph', 'font', 'svg', 'image'].filter((k) => k in value);\n if (kinds.length !== 1) {\n throw new G9Error(\n 'icon-shape',\n `An icon has exactly one of glyph, font, svg or image (got ${kinds.join(', ') || 'none'}).`,\n );\n }\n if ('glyph' in value) return assertG9Glyph(value.glyph);\n if ('font' in value) {\n requireFont(value.font);\n const hasText = 'text' in value;\n if (hasText === 'codepoint' in value) {\n throw new G9Error('icon-shape', 'A font icon has exactly one of text or codepoint.');\n }\n if (hasText) requireText(value.text);\n else requireCodePoint(value.codepoint);\n return;\n }\n if ('svg' in value) {\n if (typeof value.svg !== 'string' || isBlank(value.svg)) {\n throw new G9Error('icon-shape', 'An SVG icon needs a non-blank svg string.');\n }\n return;\n }\n const image = value.image;\n const valid =\n isObject(image) &&\n Object.keys(image).length === 1 &&\n ['uri', 'asset', 'svg'].some((k) => typeof image[k] === 'string' && !isBlank(image[k] as string));\n if (!valid) throw new G9Error('icon-shape', 'An image icon needs exactly one non-blank uri, asset or svg.');\n}\n\n/**\n * Value equality (MAUI `G9IconSource.Equals`, `==`, `!=`): same built-in glyph, or same family and glyph text (ordinal;\n * a code point equals the text it converts to), or same SVG / image reference. All empty values are equal.\n */\nexport function iconEquals(a: G9Icon | null | undefined, b: G9Icon | null | undefined): boolean {\n if (isIconEmpty(a) || isIconEmpty(b)) return isIconEmpty(a) && isIconEmpty(b);\n if ('glyph' in a || 'glyph' in b) return 'glyph' in a && 'glyph' in b && a.glyph === b.glyph;\n if (isFontIcon(a) || isFontIcon(b)) {\n return isFontIcon(a) && isFontIcon(b) && a.font === b.font && fontIconText(a) === fontIconText(b);\n }\n if ('svg' in a || 'svg' in b) return 'svg' in a && 'svg' in b && a.svg === b.svg;\n const x = a.image as Record<string, unknown>;\n const y = (b as G9ImageIcon).image as Record<string, unknown>;\n return ['uri', 'asset', 'svg'].some((k) => k in x && k in y && x[k] === y[k]);\n}\n\n/**\n * A stable identity string that changes if and only if the icon changes (MAUI `G9IconSource.ToString`):\n * `builtin:<glyph>`, `<font>:<text>`, `svg:<svg>`, `image:<kind>:<ref>`, or `''` when empty. Renderers compare it to\n * decide whether an icon host needs rebuilding.\n */\nexport function iconSignature(icon: G9Icon | null | undefined): string {\n if (isIconEmpty(icon)) return '';\n if ('glyph' in icon) return `builtin:${icon.glyph}`;\n if (isFontIcon(icon)) return `${icon.font}:${fontIconText(icon)}`;\n if ('svg' in icon) return `svg:${icon.svg}`;\n const [kind, ref] = Object.entries(icon.image)[0] as [string, string];\n return `image:${kind}:${ref}`;\n}\n\n/**\n * Normalises a slot value (MAUI implicit `G9Glyph` conversion): a `G9Glyph` string becomes `glyphIcon(value)`, an icon\n * is validated and returned, `null`/`undefined` become `null` (no icon). Anything malformed throws a `G9Error`.\n */\nexport function toIcon(value: G9Icon | G9Glyph | null | undefined): G9Icon | null {\n if (value === null || value === undefined) return null;\n if (typeof value === 'string') return glyphIcon(value);\n assertG9Icon(value);\n return value;\n}\n\n/**\n * The value of each member of an icon-font table: glyph text (MAUI `[Description]`) or a code point (MAUI\n * `Valve = 0xE801` without a description).\n */\nexport type G9IconFontMemberValue = string | number;\n\n/**\n * Builds the frozen font icons of an icon-font table (MAUI `G9IconSource.FromEnum` and the implicit enum conversion):\n * family = `font`, each member's glyph = its text, or its number read as a code point. An empty text throws (MAUI throws\n * for an empty `[Description]`: a silently empty slot is harder to diagnose than a throw).\n */\nexport function defineIconFont<const TMembers extends Readonly<Record<string, G9IconFontMemberValue>>>(\n font: string,\n members: TMembers,\n): { readonly [K in keyof TMembers]: G9FontIcon } {\n requireFont(font);\n if (!isObject(members)) throw new G9Error('icon-font', 'An icon-font table must be an object of member → glyph.');\n const out: Record<string, G9FontIcon> = {};\n for (const name of Object.keys(members)) {\n const value: unknown = members[name];\n if (isBlank(name)) throw new G9Error('icon-font', `Icon font '${font}' has a blank member name.`);\n if (typeof value === 'number') {\n out[name] = codePointIcon(font, value);\n } else if (typeof value === 'string' && value.length > 0) {\n out[name] = fontIcon(font, value);\n } else {\n throw new G9Error(\n 'icon-font',\n `Icon font member '${font}.${name}' has no glyph (empty text); there is nothing to render.`,\n );\n }\n }\n return Object.freeze(out) as { readonly [K in keyof TMembers]: G9FontIcon };\n}\n"],"names":["isObject","value","isBlank","isScalarValue","codepoint","Number","requireFont","font","G9Error","JSON","requireText","text","requireCodePoint","String","glyphIcon","glyph","assertG9Glyph","Object","fontIcon","codePointIcon","isGlyphIcon","icon","isFontIcon","isSvgIcon","isImageIcon","isIconEmpty","builtInGlyph","fontIconText","assertG9Icon","kinds","k","hasText","image","valid","iconEquals","a","b","x","y","iconSignature","kind","ref","toIcon","defineIconFont","members","out","name"],"mappings":";;AA6CA,MAAMA,WAAW,CAACC,QAAqD,AAAiB,YAAjB,OAAOA,SAAsBA,AAAU,SAAVA;AACpG,MAAMC,UAAU,CAACD,QAAkB,QAAQ,IAAI,CAACA;AAGhD,SAASE,cAAcC,SAAiB;IACtC,OACEC,OAAO,SAAS,CAACD,cACjBA,aAAa,KACbA,aAAa,YACb,CAAEA,CAAAA,aAAa,UAAUA,aAAa,MAAK;AAE/C;AAEA,SAASE,YAAYC,IAAa;IAChC,IAAI,AAAgB,YAAhB,OAAOA,QAAqBL,QAAQK,OACtC,MAAM,IAAIC,QAAQ,aAAa,CAAC,oDAAoD,EAAEC,KAAK,SAAS,CAACF,MAAM,EAAE,CAAC;IAEhH,OAAOA;AACT;AAEA,SAASG,YAAYC,IAAa;IAChC,IAAI,AAAgB,YAAhB,OAAOA,QAAqBA,AAAgB,MAAhBA,KAAK,MAAM,EACzC,MAAM,IAAIH,QACR,aACA,CAAC,yDAAyD,EAAEC,KAAK,SAAS,CAACE,MAAM,EAAE,CAAC;IAGxF,OAAOA;AACT;AAEA,SAASC,iBAAiBR,SAAkB;IAC1C,IAAI,AAAqB,YAArB,OAAOA,aAA0B,CAACD,cAAcC,YAClD,MAAM,IAAII,QACR,kBACA,GAAGK,OAAOT,WAAW,2DAA2D,CAAC;IAGrF,OAAOA;AACT;AAGO,SAASU,UAAUC,KAAc;IACtCC,cAAcD;IACd,OAAOE,OAAO,MAAM,CAAC;QAAEF;IAAM;AAC/B;AAGO,SAASG,SAASX,IAAY,EAAEI,IAAY;IACjD,OAAOM,OAAO,MAAM,CAAC;QAAE,MAAMX,YAAYC;QAAO,MAAMG,YAAYC;IAAM;AAC1E;AAMO,SAASQ,cAAcZ,IA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,KAAK,CAAC,EAAEuC,KAAK,wDAAwD,CAAC;IAGjG;IACA,OAAO7B,OAAO,MAAM,CAAC4B;AACvB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { g9GlyphStrokeUnits, g9GlyphSvg } from './generated/glyph-svg.js';
|
|
2
|
+
export { assertG9Glyph, type G9DrawableGlyph, G9Glyph, g9Glyphs, isG9Glyph } from './glyph.js';
|
|
3
|
+
export { type G9GlyphSlot, type G9GlyphSlotOverrides, type G9GlyphSlots, g9DefaultGlyphSlots, g9GlyphSlotNames, resolveGlyphSlots, } from './glyph-slots.js';
|
|
4
|
+
export { assertG9Icon, builtInGlyph, codePointIcon, defineIconFont, fontIcon, fontIconText, type G9FontCodePointIcon, type G9FontIcon, type G9FontTextIcon, type G9GlyphIcon, type G9Icon, type G9IconFontMemberValue, type G9ImageIcon, type G9ImageSource, type G9SvgIcon, glyphIcon, iconEquals, iconSignature, isFontIcon, isGlyphIcon, isIconEmpty, isImageIcon, isSvgIcon, toIcon, } from './icon.js';
|
|
5
|
+
export { createIconFontRegistry, type G9IconFontRegistry, iconNameKey } from './icon-fonts.js';
|
|
6
|
+
export { createGlyphSvgCache, type G9GlyphSvgCache, g9GlyphSvgCacheDefaultSize, svgForGlyph, } from './svg.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/icons/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,KAAK,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,SAAS,EACT,UAAU,EACV,aAAa,EACb,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,SAAS,EACT,MAAM,GACP,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,sBAAsB,EAAE,KAAK,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EACL,mBAAmB,EACnB,KAAK,eAAe,EACpB,0BAA0B,EAC1B,WAAW,GACZ,MAAM,OAAO,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { g9GlyphStrokeUnits, g9GlyphSvg } from "./generated/glyph-svg.js";
|
|
2
|
+
export { G9Glyph, assertG9Glyph, g9Glyphs, isG9Glyph } from "./glyph.js";
|
|
3
|
+
export { g9DefaultGlyphSlots, g9GlyphSlotNames, resolveGlyphSlots } from "./glyph-slots.js";
|
|
4
|
+
export { assertG9Icon, builtInGlyph, codePointIcon, defineIconFont, fontIcon, fontIconText, glyphIcon, iconEquals, iconSignature, isFontIcon, isGlyphIcon, isIconEmpty, isImageIcon, isSvgIcon, toIcon } from "./icon.js";
|
|
5
|
+
export { createIconFontRegistry, iconNameKey } from "./icon-fonts.js";
|
|
6
|
+
export { createGlyphSvgCache, g9GlyphSvgCacheDefaultSize, svgForGlyph } from "./svg.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type G9Glyph } from './glyph.js';
|
|
2
|
+
/** Default capacity of a glyph SVG cache: every glyph in a few colours and weights. */
|
|
3
|
+
export declare const g9GlyphSvgCacheDefaultSize = 256;
|
|
4
|
+
/** A bounded least-recently-used cache of rendered glyph SVG documents. */
|
|
5
|
+
export interface G9GlyphSvgCache {
|
|
6
|
+
/** The capacity; inserting beyond it evicts the least recently used entry. */
|
|
7
|
+
readonly maxEntries: number;
|
|
8
|
+
/** How many documents are cached now (never more than `maxEntries`). */
|
|
9
|
+
readonly size: number;
|
|
10
|
+
/** Renders (or returns the cached) SVG document; same contract as `svgForGlyph`. */
|
|
11
|
+
svg(glyph: G9Glyph, color?: string, weightScale?: number): string;
|
|
12
|
+
/** True when the document for these arguments is cached (does not refresh its recency). */
|
|
13
|
+
has(glyph: G9Glyph, color?: string, weightScale?: number): boolean;
|
|
14
|
+
/** Drops every cached document. */
|
|
15
|
+
clear(): void;
|
|
16
|
+
}
|
|
17
|
+
/** Creates a bounded LRU cache of glyph SVG documents (default capacity `g9GlyphSvgCacheDefaultSize`). */
|
|
18
|
+
export declare function createGlyphSvgCache(maxEntries?: number): G9GlyphSvgCache;
|
|
19
|
+
/**
|
|
20
|
+
* The SVG document of a built-in glyph for Lynx `<svg content>` (WP02 renders it): the golden MAUI drawing with every
|
|
21
|
+
* `currentColor` replaced by `color` and the stroke width scaled by `weightScale` (MAUI `G9GlyphDrawable.Color`,
|
|
22
|
+
* `WeightScale`; stroke = 2 design units × weight; filled dots keep their recorded radius). `'none'` returns `''`
|
|
23
|
+
* (renders nothing). `color` defaults to `currentColor`; any other value must be a CSS colour `parseColor` reads and
|
|
24
|
+
* is written normalised (`formatColor`). Invalid glyph, colour or weight (finite, above 0) throws a `G9Error`.
|
|
25
|
+
* Results come from a shared bounded LRU cache (`createGlyphSvgCache` for a private one).
|
|
26
|
+
*/
|
|
27
|
+
export declare function svgForGlyph(glyph: G9Glyph, color?: string, weightScale?: number): string;
|
|
28
|
+
//# sourceMappingURL=svg.d.ts.map
|