@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.
- package/README.md +18 -18
- package/api/component/__fixtures__/resolutions/modules.txt +1 -1
- package/api/doctor/doctor.mjs +3 -7
- package/api/experimental.d.mts +2 -0
- package/api/experimental.mjs +10 -0
- package/api/icon/_adapter.d.mts +10 -0
- package/api/icon/_adapter.mjs +31 -2
- package/api/icon/_authoring.d.mts +2 -1
- package/api/icon/_authoring.mjs +91 -6
- package/api/icon/_options.mjs +1 -0
- package/api/icon/_records.d.mts +18 -0
- package/api/icon/_records.mjs +26 -0
- package/api/icon/add/add.mjs +7 -1
- package/api/icon/definitions/definitions.d.mts +12 -0
- package/api/icon/definitions/definitions.mjs +83 -0
- package/api/icon/icon.doc.mjs +5 -4
- package/api/icon/icon.mjs +5 -16
- package/api/icon/icon.type.d.mts +29 -2
- package/api/icon/icon.type.mjs +17 -3
- package/api/icon/iconAdd.doc.mjs +1 -1
- package/api/icon/iconMap.doc.mjs +2 -2
- package/api/icon/iconNewSet.doc.mjs +8 -2
- package/api/icon/map/map.mjs +21 -2
- package/api/icon/new-set/new-set.mjs +14 -2
- package/api/icon/search/search.mjs +2 -15
- package/api/icon/use/use.mjs +4 -3
- package/api/integration/validate-integration.mjs +6 -1
- package/api/integration/validate-integration.type.d.mts +12 -0
- package/api/integration/validate-integration.type.mjs +5 -0
- package/api/theme-edit/_adapter.d.mts +96 -0
- package/api/theme-edit/_adapter.mjs +1039 -0
- package/api/theme-edit/_catalog.d.mts +59 -0
- package/api/theme-edit/_catalog.mjs +564 -0
- package/api/theme-edit/_check.d.mts +49 -0
- package/api/theme-edit/_check.mjs +842 -0
- package/api/theme-edit/_color.d.mts +35 -0
- package/api/theme-edit/_color.mjs +125 -0
- package/api/theme-edit/_compiler.d.mts +61 -0
- package/api/theme-edit/_compiler.mjs +522 -0
- package/api/theme-edit/_css-properties.d.mts +10 -0
- package/api/theme-edit/_css-properties.mjs +556 -0
- package/api/theme-edit/_parts.d.mts +111 -0
- package/api/theme-edit/_parts.mjs +409 -0
- package/api/theme-edit/_png.d.mts +40 -0
- package/api/theme-edit/_png.mjs +187 -0
- package/api/theme-edit/_preview.d.mts +86 -0
- package/api/theme-edit/_preview.mjs +564 -0
- package/api/theme-edit/_project.d.mts +83 -0
- package/api/theme-edit/_project.mjs +289 -0
- package/api/theme-edit/_settings.d.mts +222 -0
- package/api/theme-edit/_settings.mjs +848 -0
- package/api/theme-edit/_tables.d.mts +130 -0
- package/api/theme-edit/_tables.mjs +697 -0
- package/api/theme-edit/theme-edit.d.mts +89 -0
- package/api/theme-edit/theme-edit.mjs +119 -0
- package/api/theme-edit/theme-edit.type.d.mts +270 -0
- package/api/theme-edit/theme-edit.type.mjs +155 -0
- package/api/theme-edit/themeEditExplain.doc.d.mts +6 -0
- package/api/theme-edit/themeEditExplain.doc.mjs +88 -0
- package/api/theme-edit/themeEditNew.doc.d.mts +6 -0
- package/api/theme-edit/themeEditNew.doc.mjs +89 -0
- package/api/theme-edit/themeEditPreview.doc.d.mts +6 -0
- package/api/theme-edit/themeEditPreview.doc.mjs +96 -0
- package/api/theme-edit/themeEditReset.doc.d.mts +6 -0
- package/api/theme-edit/themeEditReset.doc.mjs +161 -0
- package/api/theme-edit/themeEditSet.doc.d.mts +6 -0
- package/api/theme-edit/themeEditSet.doc.mjs +165 -0
- package/api/theme-edit/themeEditShow.doc.d.mts +6 -0
- package/api/theme-edit/themeEditShow.doc.mjs +86 -0
- package/api/theme-edit/themeEditUndo.doc.d.mts +6 -0
- package/api/theme-edit/themeEditUndo.doc.mjs +80 -0
- package/assets/docs/color.doc.mjs +5 -5
- package/assets/docs/tree/icon-sets.doc.mjs +6 -2
- package/assets/docs/tree/tokens-border.doc.mjs +1 -1
- package/assets/docs/tree/tokens-color.doc.mjs +2 -2
- package/assets/docs/tree/tokens-data.doc.mjs +2 -2
- package/assets/docs/tree/tokens-duration.doc.mjs +1 -1
- package/assets/docs/tree/tokens-ease.doc.mjs +1 -1
- package/assets/docs/tree/tokens-focus.doc.mjs +1 -1
- package/assets/docs/tree/tokens-font-weight.doc.mjs +1 -1
- package/assets/docs/tree/tokens-radius.doc.mjs +1 -1
- package/assets/docs/tree/tokens-shadow.doc.mjs +1 -1
- package/assets/docs/tree/tokens-size.doc.mjs +1 -1
- package/assets/docs/tree/tokens-spacing.doc.mjs +1 -1
- package/assets/docs/tree/tokens-syntax.doc.mjs +1 -1
- package/assets/docs/tree/tokens-text-size.doc.mjs +1 -1
- package/assets/docs/tree/tokens-type-scale.doc.mjs +1 -1
- package/assets/docs/tree/tokens-typography.doc.mjs +1 -1
- package/assets/icons/definitions/bank.doc.mjs +1 -1
- package/assets/icons/definitions/save.doc.mjs +1 -1
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.doc.mjs +2 -1
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.doc.mjs +2 -1
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider03RtlDirection.doc.mjs +2 -1
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider04Calendar.doc.mjs +2 -1
- package/assets/templates/blocks/components/Text/useTruncationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Text/useTruncationHookUsage.tsx +112 -0
- package/authoring/doctypes/_schema.d.mts +1 -0
- package/authoring/doctypes/_schema.mjs +1 -0
- package/authoring/doctypes/command/command.doc.mjs +7 -0
- package/authoring/doctypes/command/type.ts +3 -0
- package/authoring/doctypes/icon-set/parse.d.mts +7 -0
- package/authoring/doctypes/icon-set/parse.mjs +18 -8
- package/clients/cli/commands/doctor.mjs +33 -3
- package/clients/cli/commands/experimental/icon.mjs +67 -14
- package/clients/cli/commands/experimental/index.mjs +2 -0
- package/clients/cli/commands/experimental/theme.mjs +542 -0
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +7 -1
- package/clients/cli/commands/experimental-icon.doc.mjs +3 -2
- package/clients/cli/commands/experimental-theme-add.doc.mjs +78 -0
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +97 -0
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +71 -0
- package/clients/cli/commands/experimental-theme-explain.doc.mjs +84 -0
- package/clients/cli/commands/experimental-theme-list.doc.mjs +49 -0
- package/clients/cli/commands/experimental-theme-new.doc.mjs +66 -0
- package/clients/cli/commands/experimental-theme-palette-generate.doc.mjs +73 -0
- package/clients/cli/commands/experimental-theme-palette.doc.mjs +37 -0
- package/clients/cli/commands/experimental-theme-preview.doc.mjs +76 -0
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +55 -0
- package/clients/cli/commands/experimental-theme-reset.doc.mjs +103 -0
- package/clients/cli/commands/experimental-theme-set.doc.mjs +121 -0
- package/clients/cli/commands/experimental-theme-show.doc.mjs +66 -0
- package/clients/cli/commands/experimental-theme-targets.doc.mjs +61 -0
- package/clients/cli/commands/experimental-theme-template.doc.mjs +61 -0
- package/clients/cli/commands/experimental-theme-undo.doc.mjs +55 -0
- package/clients/cli/commands/experimental-theme-use.doc.mjs +55 -0
- package/clients/cli/commands/experimental-theme.doc.mjs +66 -0
- package/clients/cli/commands/experimental.doc.mjs +10 -3
- package/clients/cli/commands/theme.mjs +101 -34
- package/clients/cli/index.mjs +16 -0
- package/clients/cli/lib/define-command.mjs +3 -0
- package/foundation/discovery/icon-set-checks.d.mts +16 -1
- package/foundation/discovery/icon-set-checks.mjs +68 -7
- package/foundation/discovery/icon-set-discovery.d.mts +21 -6
- package/foundation/discovery/icon-set-discovery.mjs +17 -8
- package/foundation/discovery/template-icon-meanings.d.mts +39 -0
- package/foundation/discovery/template-icon-meanings.mjs +95 -0
- package/foundation/discovery/theming-targets.d.mts +6 -0
- package/foundation/discovery/theming-targets.mjs +33 -0
- package/foundation/response/error-codes.d.mts +12 -1
- package/foundation/response/error-codes.doc.mjs +66 -0
- package/foundation/response/error-codes.mjs +55 -0
- package/foundation/response/response-types.doc.mjs +43 -0
- package/foundation/text/template-meanings-line.d.mts +16 -0
- package/foundation/text/template-meanings-line.mjs +37 -0
- package/foundation/xle/browser.d.mts +2 -2
- 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>;
|