@astryxdesign/cli 0.7.13 → 0.7.14-canary.d08ce65

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 (146) hide show
  1. package/README.md +18 -18
  2. package/api/component/__fixtures__/resolutions/modules.txt +1 -1
  3. package/api/doctor/doctor.mjs +3 -7
  4. package/api/experimental.d.mts +2 -0
  5. package/api/experimental.mjs +10 -0
  6. package/api/icon/_adapter.d.mts +10 -0
  7. package/api/icon/_adapter.mjs +31 -2
  8. package/api/icon/_authoring.d.mts +2 -1
  9. package/api/icon/_authoring.mjs +91 -6
  10. package/api/icon/_options.mjs +1 -0
  11. package/api/icon/_records.d.mts +18 -0
  12. package/api/icon/_records.mjs +26 -0
  13. package/api/icon/add/add.mjs +7 -1
  14. package/api/icon/definitions/definitions.d.mts +12 -0
  15. package/api/icon/definitions/definitions.mjs +83 -0
  16. package/api/icon/icon.doc.mjs +5 -4
  17. package/api/icon/icon.mjs +5 -16
  18. package/api/icon/icon.type.d.mts +29 -2
  19. package/api/icon/icon.type.mjs +17 -3
  20. package/api/icon/iconAdd.doc.mjs +1 -1
  21. package/api/icon/iconMap.doc.mjs +2 -2
  22. package/api/icon/iconNewSet.doc.mjs +8 -2
  23. package/api/icon/map/map.mjs +21 -2
  24. package/api/icon/new-set/new-set.mjs +14 -2
  25. package/api/icon/search/search.mjs +2 -15
  26. package/api/icon/use/use.mjs +4 -3
  27. package/api/integration/validate-integration.mjs +6 -1
  28. package/api/integration/validate-integration.type.d.mts +12 -0
  29. package/api/integration/validate-integration.type.mjs +5 -0
  30. package/api/theme-edit/_adapter.d.mts +96 -0
  31. package/api/theme-edit/_adapter.mjs +1039 -0
  32. package/api/theme-edit/_catalog.d.mts +59 -0
  33. package/api/theme-edit/_catalog.mjs +564 -0
  34. package/api/theme-edit/_check.d.mts +49 -0
  35. package/api/theme-edit/_check.mjs +842 -0
  36. package/api/theme-edit/_color.d.mts +35 -0
  37. package/api/theme-edit/_color.mjs +125 -0
  38. package/api/theme-edit/_compiler.d.mts +61 -0
  39. package/api/theme-edit/_compiler.mjs +522 -0
  40. package/api/theme-edit/_css-properties.d.mts +10 -0
  41. package/api/theme-edit/_css-properties.mjs +556 -0
  42. package/api/theme-edit/_parts.d.mts +111 -0
  43. package/api/theme-edit/_parts.mjs +409 -0
  44. package/api/theme-edit/_png.d.mts +40 -0
  45. package/api/theme-edit/_png.mjs +187 -0
  46. package/api/theme-edit/_preview.d.mts +86 -0
  47. package/api/theme-edit/_preview.mjs +564 -0
  48. package/api/theme-edit/_project.d.mts +83 -0
  49. package/api/theme-edit/_project.mjs +289 -0
  50. package/api/theme-edit/_settings.d.mts +222 -0
  51. package/api/theme-edit/_settings.mjs +848 -0
  52. package/api/theme-edit/_tables.d.mts +130 -0
  53. package/api/theme-edit/_tables.mjs +697 -0
  54. package/api/theme-edit/theme-edit.d.mts +89 -0
  55. package/api/theme-edit/theme-edit.mjs +119 -0
  56. package/api/theme-edit/theme-edit.type.d.mts +270 -0
  57. package/api/theme-edit/theme-edit.type.mjs +155 -0
  58. package/api/theme-edit/themeEditExplain.doc.d.mts +6 -0
  59. package/api/theme-edit/themeEditExplain.doc.mjs +88 -0
  60. package/api/theme-edit/themeEditNew.doc.d.mts +6 -0
  61. package/api/theme-edit/themeEditNew.doc.mjs +89 -0
  62. package/api/theme-edit/themeEditPreview.doc.d.mts +6 -0
  63. package/api/theme-edit/themeEditPreview.doc.mjs +96 -0
  64. package/api/theme-edit/themeEditReset.doc.d.mts +6 -0
  65. package/api/theme-edit/themeEditReset.doc.mjs +161 -0
  66. package/api/theme-edit/themeEditSet.doc.d.mts +6 -0
  67. package/api/theme-edit/themeEditSet.doc.mjs +165 -0
  68. package/api/theme-edit/themeEditShow.doc.d.mts +6 -0
  69. package/api/theme-edit/themeEditShow.doc.mjs +86 -0
  70. package/api/theme-edit/themeEditUndo.doc.d.mts +6 -0
  71. package/api/theme-edit/themeEditUndo.doc.mjs +80 -0
  72. package/assets/docs/color.doc.mjs +5 -5
  73. package/assets/docs/tree/icon-sets.doc.mjs +6 -2
  74. package/assets/docs/tree/tokens-border.doc.mjs +1 -1
  75. package/assets/docs/tree/tokens-color.doc.mjs +2 -2
  76. package/assets/docs/tree/tokens-data.doc.mjs +2 -2
  77. package/assets/docs/tree/tokens-duration.doc.mjs +1 -1
  78. package/assets/docs/tree/tokens-ease.doc.mjs +1 -1
  79. package/assets/docs/tree/tokens-focus.doc.mjs +1 -1
  80. package/assets/docs/tree/tokens-font-weight.doc.mjs +1 -1
  81. package/assets/docs/tree/tokens-radius.doc.mjs +1 -1
  82. package/assets/docs/tree/tokens-shadow.doc.mjs +1 -1
  83. package/assets/docs/tree/tokens-size.doc.mjs +1 -1
  84. package/assets/docs/tree/tokens-spacing.doc.mjs +1 -1
  85. package/assets/docs/tree/tokens-syntax.doc.mjs +1 -1
  86. package/assets/docs/tree/tokens-text-size.doc.mjs +1 -1
  87. package/assets/docs/tree/tokens-type-scale.doc.mjs +1 -1
  88. package/assets/docs/tree/tokens-typography.doc.mjs +1 -1
  89. package/assets/icons/definitions/bank.doc.mjs +1 -1
  90. package/assets/icons/definitions/save.doc.mjs +1 -1
  91. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.doc.mjs +2 -1
  92. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.doc.mjs +2 -1
  93. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider03RtlDirection.doc.mjs +2 -1
  94. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider04Calendar.doc.mjs +2 -1
  95. package/assets/templates/blocks/components/Text/useTruncationHookUsage.doc.mjs +14 -0
  96. package/assets/templates/blocks/components/Text/useTruncationHookUsage.tsx +112 -0
  97. package/authoring/doctypes/_schema.d.mts +1 -0
  98. package/authoring/doctypes/_schema.mjs +1 -0
  99. package/authoring/doctypes/command/command.doc.mjs +7 -0
  100. package/authoring/doctypes/command/type.ts +3 -0
  101. package/authoring/doctypes/icon-set/parse.d.mts +7 -0
  102. package/authoring/doctypes/icon-set/parse.mjs +18 -8
  103. package/clients/cli/commands/doctor.mjs +33 -3
  104. package/clients/cli/commands/experimental/icon.mjs +67 -14
  105. package/clients/cli/commands/experimental/index.mjs +2 -0
  106. package/clients/cli/commands/experimental/theme.mjs +542 -0
  107. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +7 -1
  108. package/clients/cli/commands/experimental-icon.doc.mjs +3 -2
  109. package/clients/cli/commands/experimental-theme-add.doc.mjs +78 -0
  110. package/clients/cli/commands/experimental-theme-compile.doc.mjs +97 -0
  111. package/clients/cli/commands/experimental-theme-eject.doc.mjs +71 -0
  112. package/clients/cli/commands/experimental-theme-explain.doc.mjs +84 -0
  113. package/clients/cli/commands/experimental-theme-list.doc.mjs +49 -0
  114. package/clients/cli/commands/experimental-theme-new.doc.mjs +66 -0
  115. package/clients/cli/commands/experimental-theme-palette-generate.doc.mjs +73 -0
  116. package/clients/cli/commands/experimental-theme-palette.doc.mjs +37 -0
  117. package/clients/cli/commands/experimental-theme-preview.doc.mjs +76 -0
  118. package/clients/cli/commands/experimental-theme-remove.doc.mjs +55 -0
  119. package/clients/cli/commands/experimental-theme-reset.doc.mjs +103 -0
  120. package/clients/cli/commands/experimental-theme-set.doc.mjs +121 -0
  121. package/clients/cli/commands/experimental-theme-show.doc.mjs +66 -0
  122. package/clients/cli/commands/experimental-theme-targets.doc.mjs +61 -0
  123. package/clients/cli/commands/experimental-theme-template.doc.mjs +61 -0
  124. package/clients/cli/commands/experimental-theme-undo.doc.mjs +55 -0
  125. package/clients/cli/commands/experimental-theme-use.doc.mjs +55 -0
  126. package/clients/cli/commands/experimental-theme.doc.mjs +66 -0
  127. package/clients/cli/commands/experimental.doc.mjs +10 -3
  128. package/clients/cli/commands/theme.mjs +101 -34
  129. package/clients/cli/index.mjs +16 -0
  130. package/clients/cli/lib/define-command.mjs +3 -0
  131. package/foundation/discovery/icon-set-checks.d.mts +16 -1
  132. package/foundation/discovery/icon-set-checks.mjs +68 -7
  133. package/foundation/discovery/icon-set-discovery.d.mts +21 -6
  134. package/foundation/discovery/icon-set-discovery.mjs +17 -8
  135. package/foundation/discovery/template-icon-meanings.d.mts +39 -0
  136. package/foundation/discovery/template-icon-meanings.mjs +95 -0
  137. package/foundation/discovery/theming-targets.d.mts +6 -0
  138. package/foundation/discovery/theming-targets.mjs +33 -0
  139. package/foundation/response/error-codes.d.mts +12 -1
  140. package/foundation/response/error-codes.doc.mjs +66 -0
  141. package/foundation/response/error-codes.mjs +55 -0
  142. package/foundation/response/response-types.doc.mjs +43 -0
  143. package/foundation/text/template-meanings-line.d.mts +16 -0
  144. package/foundation/text/template-meanings-line.mjs +37 -0
  145. package/foundation/xle/browser.d.mts +2 -2
  146. package/package.json +6 -6
@@ -0,0 +1,35 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * @file Color math for `astryx experimental theme`: parse a CSS color to RGB,
6
+ * contrast ratios, mixing, value type checks, and the accent derivation.
7
+ * @position api/theme-edit — pure helpers
8
+ */
9
+ /** @typedef {[number, number, number]} Rgb */
10
+ /**
11
+ * The RGB of a hex, rgb() or white/black color, or null for anything else.
12
+ * @param {unknown} value
13
+ * @returns {Rgb | null}
14
+ */
15
+ export function parseColor(value: unknown): Rgb | null;
16
+ /**
17
+ * The WCAG contrast ratio of two colors.
18
+ * @param {number[]} a
19
+ * @param {number[]} b
20
+ */
21
+ export function ratio(a: number[], b: number[]): number;
22
+ /**
23
+ * The tokens one accent color sets. The color itself stays exact; accent
24
+ * text is darkened (light) or lightened (dark) until it reads at 4.5:1.
25
+ * A pair is `[light, dark]`.
26
+ * @param {string} value
27
+ * @returns {Record<string, string | [string, string]>}
28
+ */
29
+ export function accentSet(value: string): Record<string, string | [string, string]>;
30
+ export function hex(rgb: number[]): string;
31
+ export function mix(a: number[], b: number[], t: number): Rgb;
32
+ export function isColorValue(v: unknown): boolean;
33
+ export function isSize(v: unknown): boolean;
34
+ export function isNumber(v: unknown): boolean;
35
+ export type Rgb = [number, number, number];
@@ -0,0 +1,125 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Color math for `astryx experimental theme`: parse a CSS color to RGB,
5
+ * contrast ratios, mixing, value type checks, and the accent derivation.
6
+ * @position api/theme-edit — pure helpers
7
+ */
8
+
9
+ /** @typedef {[number, number, number]} Rgb */
10
+
11
+ /**
12
+ * The RGB of a hex, rgb() or white/black color, or null for anything else.
13
+ * @param {unknown} value
14
+ * @returns {Rgb | null}
15
+ */
16
+ export function parseColor(value) {
17
+ const s = String(value ?? '').trim();
18
+ let m = /^#([0-9a-f]{3}|[0-9a-f]{6})([0-9a-f]{2})?$/i.exec(s);
19
+ if (m) {
20
+ let h = m[1];
21
+ if (h.length === 3) h = [...h].map(c => c + c).join('');
22
+ const n = parseInt(h, 16);
23
+ return [(n >> 16) & 255, (n >> 8) & 255, n & 255];
24
+ }
25
+ m = /^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/i.exec(s);
26
+ if (m) return [Number(m[1]), Number(m[2]), Number(m[3])];
27
+ if (/^white$/i.test(s)) return [255, 255, 255];
28
+ if (/^black$/i.test(s)) return [0, 0, 0];
29
+ return null;
30
+ }
31
+
32
+ /** @param {number[]} rgb */
33
+ export const hex = rgb =>
34
+ `#${rgb
35
+ .slice(0, 3)
36
+ .map(x =>
37
+ Math.round(Math.max(0, Math.min(255, x)))
38
+ .toString(16)
39
+ .padStart(2, '0'),
40
+ )
41
+ .join('')}`;
42
+
43
+ /** @param {number[]} rgb */
44
+ const luminance = ([r, g, b]) => {
45
+ /** @param {number} c */
46
+ const f = c => {
47
+ const v = c / 255;
48
+ return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
49
+ };
50
+ return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b);
51
+ };
52
+
53
+ /**
54
+ * The WCAG contrast ratio of two colors.
55
+ * @param {number[]} a
56
+ * @param {number[]} b
57
+ */
58
+ export function ratio(a, b) {
59
+ const [x, y] = [luminance(a), luminance(b)].sort((p, q) => q - p);
60
+ return (x + 0.05) / (y + 0.05);
61
+ }
62
+
63
+ /**
64
+ * @param {number[]} a
65
+ * @param {number[]} b
66
+ * @param {number} t 0 gives a, 1 gives b
67
+ * @returns {Rgb}
68
+ */
69
+ export const mix = (a, b, t) => [
70
+ a[0] + (b[0] - a[0]) * t,
71
+ a[1] + (b[1] - a[1]) * t,
72
+ a[2] + (b[2] - a[2]) * t,
73
+ ];
74
+
75
+ /** Whether a value reads as one CSS color. @param {unknown} v */
76
+ export const isColorValue = v =>
77
+ /^(#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|(rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix|light-dark)\(.+\)|var\(--[a-z0-9-]+\)|transparent|currentcolor|inherit|[a-z]+)$/i.test(
78
+ String(v).trim(),
79
+ );
80
+
81
+ /** Whether a value reads as one CSS size. @param {unknown} v */
82
+ export const isSize = v =>
83
+ /^(-?\d*\.?\d+(px|rem|em|%|vh|vw)?|0|var\(--[a-z0-9-]+\)|calc\(.+\))$/i.test(
84
+ String(v).trim(),
85
+ );
86
+
87
+ /** Whether a value reads as a number. @param {unknown} v */
88
+ export const isNumber = v => /^-?\d*\.?\d+$|^var\(/.test(String(v).trim());
89
+
90
+ /**
91
+ * The tokens one accent color sets. The color itself stays exact; accent
92
+ * text is darkened (light) or lightened (dark) until it reads at 4.5:1.
93
+ * A pair is `[light, dark]`.
94
+ * @param {string} value
95
+ * @returns {Record<string, string | [string, string]>}
96
+ */
97
+ export function accentSet(value) {
98
+ const c = parseColor(value);
99
+ if (!c)
100
+ return {
101
+ '--color-accent': value,
102
+ '--color-icon-accent': value,
103
+ '--color-text-accent': value,
104
+ };
105
+ /** @type {Rgb} */
106
+ const white = [255, 255, 255];
107
+ /** @type {Rgb} */
108
+ const black = [0, 0, 0];
109
+ /** @type {Rgb} */
110
+ const darkCard = [31, 31, 34];
111
+ let text = c;
112
+ for (let i = 0; i < 20 && ratio(text, white) < 4.5; i++)
113
+ text = mix(text, black, 0.08);
114
+ let darkText = c;
115
+ for (let i = 0; i < 20 && ratio(darkText, darkCard) < 4.5; i++)
116
+ darkText = mix(darkText, white, 0.08);
117
+ return {
118
+ '--color-accent': value,
119
+ '--color-text-accent': [hex(text), hex(darkText)],
120
+ '--color-icon-accent': [value, hex(darkText)],
121
+ '--color-accent-muted': [hex(mix(c, white, 0.85)), hex(mix(c, black, 0.7))],
122
+ '--color-on-accent':
123
+ ratio(c, white) >= ratio(c, [17, 17, 17]) ? '#ffffff' : '#111111',
124
+ };
125
+ }
@@ -0,0 +1,61 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /** @typedef {{token: string, props: string[], when: string[]}} Read */
5
+ /** @typedef {{message: string, run: string[], also: string[], soft?: boolean}} CheckFailure */
6
+ /**
7
+ * @param {import('./_project.mjs').ThemeProject} project
8
+ * @param {import('./_parts.mjs').PartData} parts
9
+ */
10
+ export function makeCompiler(project: import("./_project.mjs").ThemeProject, parts: import("./_parts.mjs").PartData): {
11
+ MAP: Record<string, import("./_parts.mjs").PartRecord>;
12
+ typeOf: (tok: string) => string;
13
+ feeds: (target: string, token: string) => Array<{
14
+ part: string;
15
+ prop: string;
16
+ when: string;
17
+ }>;
18
+ fmtFeeds: (list: ReturnType<(target: string, token: string) => Array<{
19
+ part: string;
20
+ prop: string;
21
+ when: string;
22
+ }>>) => string;
23
+ showsCorners: (target: string) => boolean;
24
+ groupOfToken: (t: string) => string | null;
25
+ groupOfProp: (p: string) => string | null;
26
+ partReads: (target: string, group: string | null) => Read[];
27
+ fmtWhen: (w: string[]) => string;
28
+ statusNote: (target: string, tok: string) => string;
29
+ allReads: (target: string) => Set<string>;
30
+ anyReader: (tok: string) => string[];
31
+ checkTokenOn: (theme: string, target: string, token: string, value: string, P: string) => CheckFailure | null;
32
+ checkTokenGlobal: (token: string, P: string) => CheckFailure | null;
33
+ variantValues: (target: string) => Record<string, string[]>;
34
+ explain: (target: string, P: string, theme?: string) => string[];
35
+ contrast: (value: (pair: import("./_parts.mjs").TextPair, side: "fg" | "bg", mode: string) => string | null | undefined, baseValue: (pair: import("./_parts.mjs").TextPair, side: "fg" | "bg", mode: string) => string | null | undefined, modes: string[], { parseColor, ratio }: {
36
+ parseColor: (v: unknown) => number[] | null;
37
+ ratio: (a: number[], b: number[]) => number;
38
+ }) => {
39
+ part: string;
40
+ mode: string;
41
+ ratio: number;
42
+ sample: string;
43
+ fg: string;
44
+ bgPart: string | null;
45
+ bg: string;
46
+ }[];
47
+ };
48
+ /** Only these token types may differ between light and dark. */
49
+ export const MODAL: Set<string>;
50
+ export type Read = {
51
+ token: string;
52
+ props: string[];
53
+ when: string[];
54
+ };
55
+ export type CheckFailure = {
56
+ message: string;
57
+ run: string[];
58
+ also: string[];
59
+ soft?: boolean;
60
+ };
61
+ export type Compiler = ReturnType<typeof makeCompiler>;