@astryxdesign/cli 0.6.3-canary.ea2f048 → 0.6.3-canary.ebaebc4
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 +2 -1
- package/api/build/build.type.d.mts +2 -2
- package/api/build/build.type.mjs +2 -2
- package/api/component/component.type.d.mts +6 -6
- package/api/component/component.type.mjs +19 -19
- package/api/discover/discover.type.d.mts +4 -4
- package/api/discover/discover.type.mjs +10 -10
- package/api/docs/_adapter.d.mts +37 -24
- package/api/docs/_adapter.mjs +169 -83
- package/api/docs/compiled-topics.test.mjs +78 -0
- package/api/docs/detail/detail.mjs +14 -63
- package/api/docs/detail/section/section.d.mts +1 -1
- package/api/docs/detail/section/section.mjs +44 -20
- package/api/docs/detail/section/section.test.mjs +41 -0
- package/api/docs/docs.d.mts +7 -2
- package/api/docs/docs.doc.mjs +27 -10
- package/api/docs/docs.mjs +16 -9
- package/api/docs/docs.test.mjs +6 -0
- package/api/docs/docs.type.d.mts +40 -3
- package/api/docs/docs.type.mjs +36 -8
- package/api/docs/index/index.d.mts +18 -0
- package/api/docs/index/index.mjs +32 -0
- package/api/docs/index/index.test.mjs +62 -0
- package/api/docs/integrationDocs.test.mjs +106 -0
- package/api/doctor/doctor.d.mts +48 -0
- package/api/doctor/doctor.mjs +232 -0
- package/api/doctor/doctor.test.mjs +196 -0
- package/api/hook/hook.type.d.mts +3 -3
- package/api/hook/hook.type.mjs +11 -11
- package/api/hook/list/list.d.mts +1 -1
- package/api/integration/add-contribution.mjs +5 -3
- package/api/integration/add-contribution.test.mjs +4 -4
- package/api/integration/integration-authoring.type.d.mts +1 -1
- package/api/integration/pack-check.mjs +49 -7
- package/api/integration/pack-check.test.mjs +249 -0
- package/api/search/search.d.mts +1 -1
- package/api/search/search.mjs +5 -5
- package/api/search/search.type.d.mts +2 -2
- package/api/search/search.type.mjs +1 -1
- package/api/swizzle/swizzle.type.d.mts +2 -2
- package/api/swizzle/swizzle.type.mjs +2 -2
- package/api/template/template.d.mts +1 -1
- package/api/template/template.type.d.mts +6 -6
- package/api/template/template.type.mjs +12 -12
- package/api/theme/build/build.mjs +20 -6
- package/api/theme/build/build.test.mjs +127 -0
- package/api/theme/palette/generate/generate.mjs +1 -1
- package/api/theme/palette/generate/generator.d.mts +10 -13
- package/api/theme/palette/generate/generator.mjs +7 -3
- package/api/theme/theme.type.d.mts +170 -11
- package/api/theme/theme.type.mjs +94 -27
- package/api/upgrade/_adapter.mjs +71 -5
- package/api/upgrade/project-context.test.mjs +272 -0
- package/api/upgrade/upgrade.doc.mjs +4 -3
- package/api/upgrade/upgrade.type.d.mts +5 -5
- package/api/upgrade/upgrade.type.mjs +11 -11
- package/assets/codemods/integration-discovery.mjs +40 -2
- package/assets/codemods/integration-discovery.test.mjs +58 -0
- package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +27 -5
- package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +20 -5
- package/assets/docs/README.md +9 -0
- package/assets/docs/authoring.doc.mjs +14 -0
- package/assets/docs/cli-integrations.doc.mjs +86 -15
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +1 -1
- package/authoring/_shared/contract.ts +22 -0
- package/authoring/codemod/codemod.doc.mjs +6 -1
- package/authoring/codemod/parse.d.mts +8 -8
- package/authoring/codemod/parse.mjs +8 -6
- package/authoring/config/parse.d.mts +13 -13
- package/authoring/config/parse.mjs +8 -8
- package/authoring/config/type.ts +3 -3
- package/authoring/debug/parse.d.mts +5 -5
- package/authoring/debug/parse.mjs +3 -3
- package/authoring/doctypes/_schema.d.mts +788 -23
- package/authoring/doctypes/_schema.mjs +492 -39
- package/authoring/doctypes/base/graph-fields.doc.d.mts +9 -0
- package/authoring/doctypes/base/graph-fields.doc.mjs +62 -0
- package/authoring/doctypes/base/type.ts +40 -0
- package/authoring/doctypes/command/command.doc.mjs +3 -2
- package/authoring/doctypes/command/parse.d.mts +2 -2
- package/authoring/doctypes/command/parse.mjs +1 -1
- package/authoring/doctypes/command/type.ts +3 -2
- package/authoring/doctypes/component/component.doc.mjs +6 -3
- package/authoring/doctypes/component/parse.d.mts +2 -2
- package/authoring/doctypes/component/parse.mjs +1 -1
- package/authoring/doctypes/component/type.ts +4 -3
- package/authoring/doctypes/enum/parse.d.mts +2 -2
- package/authoring/doctypes/enum/parse.mjs +1 -1
- package/authoring/doctypes/enum/type.ts +3 -1
- package/authoring/doctypes/function/function.doc.mjs +4 -0
- package/authoring/doctypes/function/parse.d.mts +2 -2
- package/authoring/doctypes/function/parse.mjs +1 -1
- package/authoring/doctypes/function/type.ts +6 -2
- package/authoring/doctypes/hook/hook.doc.mjs +4 -0
- package/authoring/doctypes/hook/parse.d.mts +2 -2
- package/authoring/doctypes/hook/parse.mjs +1 -1
- package/authoring/doctypes/hook/type.ts +3 -2
- package/authoring/doctypes/legacy.d.mts +8 -6
- package/authoring/doctypes/legacy.mjs +5 -4
- package/authoring/doctypes/load-contract.test.mjs +207 -0
- package/authoring/doctypes/namespace/namespace.doc.d.mts +9 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +132 -0
- package/authoring/doctypes/namespace/parse.d.mts +12 -0
- package/authoring/doctypes/namespace/parse.mjs +25 -0
- package/authoring/doctypes/namespace/parse.test.mjs +165 -0
- package/authoring/doctypes/namespace/type.ts +71 -0
- package/authoring/doctypes/parse.d.mts +20 -18
- package/authoring/doctypes/parse.mjs +16 -10
- package/authoring/doctypes/parse.test.mjs +77 -3
- package/authoring/doctypes/reference/parse.d.mts +2 -2
- package/authoring/doctypes/reference/parse.mjs +8 -5
- package/authoring/doctypes/reference/reference.doc.mjs +17 -4
- package/authoring/doctypes/reference/type.ts +51 -5
- package/authoring/doctypes/schema/parse.d.mts +2 -2
- package/authoring/doctypes/schema/parse.mjs +1 -1
- package/authoring/doctypes/schema/type.ts +3 -2
- package/authoring/doctypes/template/parse.d.mts +92 -1
- package/authoring/doctypes/template/parse.mjs +36 -2
- package/authoring/doctypes/template/parse.test.mjs +8 -2
- package/authoring/doctypes/template/template.doc.mjs +4 -0
- package/authoring/doctypes/template/type.ts +5 -2
- package/authoring/doctypes/types.ts +10 -9
- package/authoring/gap-report/parse.d.mts +10 -10
- package/authoring/gap-report/parse.mjs +6 -6
- package/authoring/gap-report/type.ts +1 -1
- package/authoring/identity/identity.doc.d.mts +9 -0
- package/authoring/identity/identity.doc.mjs +61 -0
- package/authoring/identity/type.ts +132 -0
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +49 -17
- package/authoring/index.mjs +1 -0
- package/authoring/integration/integration.doc.mjs +13 -6
- package/authoring/integration/parse.d.mts +2 -2
- package/authoring/integration/parse.mjs +1 -1
- package/authoring/integration/parse.test.mjs +10 -1
- package/authoring/integration/schema.d.mts +6 -4
- package/authoring/integration/schema.mjs +9 -3
- package/authoring/integration/type.ts +23 -6
- package/authoring/shadcn/receipt.d.mts +6 -6
- package/clients/cli/commands/docs.doc.mjs +13 -3
- package/clients/cli/commands/docs.mjs +121 -21
- package/clients/cli/commands/docs.test.mjs +88 -0
- package/clients/cli/commands/integration-authoring.test.mjs +13 -9
- package/clients/cli/commands/theme-palette-generate.doc.mjs +8 -4
- package/clients/cli/commands/upgrade.doc.mjs +2 -2
- package/clients/cli/formatters/index.mjs +162 -1
- package/clients/cli/formatters/index.test.mjs +91 -0
- package/clients/cli/lib/manifest.mjs +7 -2
- package/foundation/config/project.mjs +21 -6
- package/foundation/discovery/authoring-self-docs.d.mts +69 -0
- package/foundation/discovery/authoring-self-docs.mjs +214 -0
- package/foundation/discovery/authoring-self-docs.test.mjs +154 -0
- package/foundation/discovery/component-discovery.d.mts +1 -1
- package/foundation/discovery/component-discovery.mjs +2 -1
- package/foundation/discovery/docs-discovery.d.mts +11 -4
- package/foundation/discovery/docs-discovery.mjs +208 -88
- package/foundation/discovery/docs-discovery.test.mjs +279 -13
- package/foundation/discovery/docs-output-budget.d.mts +28 -0
- package/foundation/discovery/docs-output-budget.mjs +50 -0
- package/foundation/discovery/docs-section-key.d.mts +98 -0
- package/foundation/discovery/docs-section-key.mjs +221 -0
- package/foundation/discovery/docs-section-key.test.mjs +224 -0
- package/foundation/discovery/template-adapter.mjs +2 -1
- package/foundation/discovery/theming-targets.test.mjs +4 -0
- package/foundation/doc-compiler/compile.d.mts +162 -0
- package/foundation/doc-compiler/compile.mjs +262 -0
- package/foundation/doc-compiler/doc-compiler.test.mjs +687 -0
- package/foundation/doc-compiler/ir.d.mts +9 -0
- package/foundation/doc-compiler/ir.mjs +287 -0
- package/foundation/doc-compiler/lenses.d.mts +33 -0
- package/foundation/doc-compiler/lenses.mjs +127 -0
- package/foundation/identity/provider-identity.d.mts +90 -0
- package/foundation/identity/provider-identity.mjs +320 -0
- package/foundation/identity/provider-identity.test.mjs +254 -0
- package/foundation/identity/providers.d.mts +7 -0
- package/foundation/identity/providers.mjs +16 -0
- package/foundation/integrations/autolink.mjs +12 -5
- package/foundation/integrations/integration-warnings.mjs +6 -0
- package/foundation/integrations/integrations.d.mts +46 -2
- package/foundation/integrations/integrations.mjs +167 -8
- package/foundation/integrations/integrations.test.mjs +384 -1
- package/foundation/integrations/provider-conflicts.test.mjs +125 -0
- package/foundation/integrations/validate-contributions.d.mts +2 -0
- package/foundation/integrations/validate-contributions.mjs +10 -0
- package/foundation/response/json-contract.test.mjs +46 -17
- package/foundation/response/response-types.doc.mjs +6 -1
- package/package.json +9 -11
|
@@ -206,6 +206,133 @@ describe('themeBuild() — receipt', () => {
|
|
|
206
206
|
});
|
|
207
207
|
});
|
|
208
208
|
|
|
209
|
+
describe('themeBuild() — dropped declarations reach the receipt', () => {
|
|
210
|
+
// Core's generator refuses a declaration whose value would end it early
|
|
211
|
+
// (an unquoted `;` or brace, an unclosed string/comment/url). The runtime
|
|
212
|
+
// says so on the console; a build has a receipt, so every drop must land in
|
|
213
|
+
// `warnings` — a programmatic caller otherwise sees `warnings: []` while the
|
|
214
|
+
// CSS silently omits a value the generated JS still carries.
|
|
215
|
+
it('reports every dropped declaration, from every generator path, in warnings', async () => {
|
|
216
|
+
const themeFile = path.join(tmpDir, 'dropped.mjs');
|
|
217
|
+
fs.writeFileSync(
|
|
218
|
+
themeFile,
|
|
219
|
+
`export default {
|
|
220
|
+
name: 'dropped',
|
|
221
|
+
tokens: {
|
|
222
|
+
'--color-bg': '#0a0a0a } body { background: url(https://example.com/token) ',
|
|
223
|
+
},
|
|
224
|
+
components: {
|
|
225
|
+
button: {
|
|
226
|
+
'variant:secondary': {
|
|
227
|
+
backgroundColor: 'red; background-image: url(https://example.com/component)',
|
|
228
|
+
':hover': {color: '"https://example.com/pseudo'},
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
onDark: {
|
|
233
|
+
tokens: {'--color-bg': 'url(https://example.com/dark'},
|
|
234
|
+
},
|
|
235
|
+
adaptations: {
|
|
236
|
+
rules: [
|
|
237
|
+
{
|
|
238
|
+
when: {pointer: 'coarse'},
|
|
239
|
+
value: {tokens: {'--color-bg': 'red /* https://example.com/adaptation'}},
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
};\n`,
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
247
|
+
let result;
|
|
248
|
+
try {
|
|
249
|
+
result = await themeBuild('dropped.mjs', {}, {cwd: tmpDir});
|
|
250
|
+
// Drops are collected, not printed: the programmatic API stays silent.
|
|
251
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
252
|
+
} finally {
|
|
253
|
+
warnSpy.mockRestore();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const css = fs.readFileSync(path.join(tmpDir, 'dropped.css'), 'utf8');
|
|
257
|
+
expect(css).not.toContain('example.com');
|
|
258
|
+
|
|
259
|
+
const warnings = result?.data.warnings ?? [];
|
|
260
|
+
expect(warnings).toHaveLength(5);
|
|
261
|
+
expect(warnings).toEqual(
|
|
262
|
+
expect.arrayContaining([
|
|
263
|
+
expect.stringMatching(
|
|
264
|
+
/^Declaration dropped "--color-bg" in tokens: an unquoted "}" would close the rule/,
|
|
265
|
+
),
|
|
266
|
+
expect.stringMatching(
|
|
267
|
+
/^Declaration dropped "background-color" in components\.button\["variant:secondary"\]: an unquoted ";" would end the declaration/,
|
|
268
|
+
),
|
|
269
|
+
expect.stringMatching(
|
|
270
|
+
/^Declaration dropped "color" in components\.button\["variant:secondary"\]\[":hover"\]: an unclosed " string/,
|
|
271
|
+
),
|
|
272
|
+
expect.stringMatching(
|
|
273
|
+
/^Declaration dropped "--color-bg" in onDark\.tokens: an unclosed url\(/,
|
|
274
|
+
),
|
|
275
|
+
expect.stringMatching(
|
|
276
|
+
/^Declaration dropped "--color-bg" in adaptations\[0\]\.tokens: an unclosed \/\* comment/,
|
|
277
|
+
),
|
|
278
|
+
]),
|
|
279
|
+
);
|
|
280
|
+
for (const w of warnings) {
|
|
281
|
+
expect(w).toContain('The generated CSS omits it');
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it('generates CSS for legacy null tokens without losing neighboring declarations', async () => {
|
|
286
|
+
fs.writeFileSync(
|
|
287
|
+
path.join(tmpDir, 'legacy.mjs'),
|
|
288
|
+
`export default {
|
|
289
|
+
name: 'legacy',
|
|
290
|
+
tokens: {'--color-background-body': null, '--spacing-4': 12},
|
|
291
|
+
onDark: {tokens: {'--color-background-body': null}},
|
|
292
|
+
components: {button: {base: {borderRadius: '4px'}}},
|
|
293
|
+
};\n`,
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
const result = await themeBuild('legacy.mjs', {}, {cwd: tmpDir});
|
|
297
|
+
const css = fs.readFileSync(path.join(tmpDir, 'legacy.css'), 'utf8');
|
|
298
|
+
expect(css).toContain('--color-background-body: null;');
|
|
299
|
+
expect(css).toContain('--spacing-4: 12;');
|
|
300
|
+
expect(css).toContain('border-radius: 4px;');
|
|
301
|
+
expect(result?.data.warnings).toEqual([]);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it('keeps valid CSS that carries semicolons, and reports nothing', async () => {
|
|
305
|
+
const themeFile = path.join(tmpDir, 'kept.mjs');
|
|
306
|
+
fs.writeFileSync(
|
|
307
|
+
themeFile,
|
|
308
|
+
`export default {
|
|
309
|
+
name: 'kept',
|
|
310
|
+
tokens: {'--font-family-body': 'Gill\\\\ Sans, "Segoe;UI", serif /* ; */'},
|
|
311
|
+
components: {
|
|
312
|
+
button: {
|
|
313
|
+
'variant:secondary': {
|
|
314
|
+
backgroundImage: 'URL(data:image/svg+xml;base64,PHN2Zz4=)',
|
|
315
|
+
WebkitLineClamp: '2',
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
};\n`,
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
const result = await themeBuild('kept.mjs', {}, {cwd: tmpDir});
|
|
323
|
+
const css = fs.readFileSync(path.join(tmpDir, 'kept.css'), 'utf8');
|
|
324
|
+
|
|
325
|
+
expect(css).toContain(
|
|
326
|
+
'--font-family-body: Gill\\ Sans, "Segoe;UI", serif /* ; */;',
|
|
327
|
+
);
|
|
328
|
+
expect(css).toContain(
|
|
329
|
+
'background-image: URL(data:image/svg+xml;base64,PHN2Zz4=);',
|
|
330
|
+
);
|
|
331
|
+
expect(css).toContain('-webkit-line-clamp: 2;');
|
|
332
|
+
expect(result?.data.warnings).toEqual([]);
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
|
|
209
336
|
describe('themeBuild() — nothing to build', () => {
|
|
210
337
|
it('returns null and writes nothing when the generator yields no CSS', async () => {
|
|
211
338
|
const themeFile = path.join(tmpDir, 'empty.mjs');
|
|
@@ -100,7 +100,7 @@ function serializeCandidate(candidate, outputPath) {
|
|
|
100
100
|
);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
/** @param {PaletteGenerationResult} result @param {string} candidateText @param {string | null} [previewText] */
|
|
103
|
+
/** @param {PaletteGenerationResult} result @param {string} candidateText @param {string | null} [previewText] @returns {import('../../theme.type.mjs').TonalPaletteGenerationReceipt} */
|
|
104
104
|
function receiptFor(result, candidateText, previewText = null) {
|
|
105
105
|
return {
|
|
106
106
|
schemaVersion: 1,
|
|
@@ -22,15 +22,17 @@ export function generateTonalPalette(input: import("../../theme.type.mjs").Tonal
|
|
|
22
22
|
export function serializeGenerationResult(result: unknown): string;
|
|
23
23
|
/** @typedef {import('../../theme.type.mjs').TonalPaletteAnchor} TonalPaletteAnchor */
|
|
24
24
|
/** @typedef {import('../../theme.type.mjs').TonalPaletteGenerationInput} TonalPaletteGenerationInput */
|
|
25
|
+
/** @typedef {import('../../theme.type.mjs').TonalPaletteRampDiagnostics} TonalPaletteRampDiagnostics */
|
|
26
|
+
/** @typedef {import('../../theme.type.mjs').TonalPaletteCoordinationDiagnostics} TonalPaletteCoordinationDiagnostics */
|
|
27
|
+
/** @typedef {import('../../theme.type.mjs').TonalPaletteNormalizedRequest} NormalizedRequest */
|
|
25
28
|
/** @typedef {[number, number, number]} ColorTriple */
|
|
26
29
|
/** @typedef {'light' | 'dark'} PaletteMode */
|
|
27
30
|
/** @typedef {{lightness: number, chroma: number, hue: number}} PolarColor */
|
|
28
31
|
/** @typedef {TonalPaletteAnchor & {color: string, generatedColor: string, deltaE: number}} AnchorResult */
|
|
29
|
-
/** @typedef {{colors: Record<number, string>, diagnostics:
|
|
32
|
+
/** @typedef {{colors: Record<number, string>, diagnostics: TonalPaletteRampDiagnostics}} GeneratedRamp */
|
|
30
33
|
/** @typedef {{id: string, name: string, seed: string, kind: 'chromatic' | 'neutral', anchors: TonalPaletteAnchor[]}} NormalizedFamily */
|
|
31
|
-
/** @typedef {{recipe: typeof PALETTE_RECIPE, vibrancy: number, neutralProfile: string, modeStrategy: string, stops: number[], families: NormalizedFamily[]}} NormalizedRequest */
|
|
32
34
|
/** @typedef {{id: string, name: string, seed: string, light?: GeneratedRamp, dark?: GeneratedRamp}} GeneratedFamily */
|
|
33
|
-
/** @typedef {{recipe: typeof PALETTE_RECIPE, status: 'candidate', request: NormalizedRequest, families: GeneratedFamily[], coordination:
|
|
35
|
+
/** @typedef {{recipe: typeof PALETTE_RECIPE, status: 'candidate', request: NormalizedRequest, families: GeneratedFamily[], coordination: TonalPaletteCoordinationDiagnostics[], errors: {familyId: string, message: string}[]}} PaletteGenerationResult */
|
|
34
36
|
export const PALETTE_RECIPE: "astryx-oklch-v1";
|
|
35
37
|
export const PALETTE_BLACK: "#000000";
|
|
36
38
|
export const PALETTE_WHITE: "#ffffff";
|
|
@@ -38,6 +40,9 @@ export const DEFAULT_21_STOPS: readonly number[];
|
|
|
38
40
|
export const COMPACT_11_STOPS: readonly number[];
|
|
39
41
|
export type TonalPaletteAnchor = import("../../theme.type.mjs").TonalPaletteAnchor;
|
|
40
42
|
export type TonalPaletteGenerationInput = import("../../theme.type.mjs").TonalPaletteGenerationInput;
|
|
43
|
+
export type TonalPaletteRampDiagnostics = import("../../theme.type.mjs").TonalPaletteRampDiagnostics;
|
|
44
|
+
export type TonalPaletteCoordinationDiagnostics = import("../../theme.type.mjs").TonalPaletteCoordinationDiagnostics;
|
|
45
|
+
export type NormalizedRequest = import("../../theme.type.mjs").TonalPaletteNormalizedRequest;
|
|
41
46
|
export type ColorTriple = [number, number, number];
|
|
42
47
|
export type PaletteMode = "light" | "dark";
|
|
43
48
|
export type PolarColor = {
|
|
@@ -52,7 +57,7 @@ export type AnchorResult = TonalPaletteAnchor & {
|
|
|
52
57
|
};
|
|
53
58
|
export type GeneratedRamp = {
|
|
54
59
|
colors: Record<number, string>;
|
|
55
|
-
diagnostics:
|
|
60
|
+
diagnostics: TonalPaletteRampDiagnostics;
|
|
56
61
|
};
|
|
57
62
|
export type NormalizedFamily = {
|
|
58
63
|
id: string;
|
|
@@ -61,14 +66,6 @@ export type NormalizedFamily = {
|
|
|
61
66
|
kind: "chromatic" | "neutral";
|
|
62
67
|
anchors: TonalPaletteAnchor[];
|
|
63
68
|
};
|
|
64
|
-
export type NormalizedRequest = {
|
|
65
|
-
recipe: typeof PALETTE_RECIPE;
|
|
66
|
-
vibrancy: number;
|
|
67
|
-
neutralProfile: string;
|
|
68
|
-
modeStrategy: string;
|
|
69
|
-
stops: number[];
|
|
70
|
-
families: NormalizedFamily[];
|
|
71
|
-
};
|
|
72
69
|
export type GeneratedFamily = {
|
|
73
70
|
id: string;
|
|
74
71
|
name: string;
|
|
@@ -81,7 +78,7 @@ export type PaletteGenerationResult = {
|
|
|
81
78
|
status: "candidate";
|
|
82
79
|
request: NormalizedRequest;
|
|
83
80
|
families: GeneratedFamily[];
|
|
84
|
-
coordination:
|
|
81
|
+
coordination: TonalPaletteCoordinationDiagnostics[];
|
|
85
82
|
errors: {
|
|
86
83
|
familyId: string;
|
|
87
84
|
message: string;
|
|
@@ -12,15 +12,17 @@ import {
|
|
|
12
12
|
|
|
13
13
|
/** @typedef {import('../../theme.type.mjs').TonalPaletteAnchor} TonalPaletteAnchor */
|
|
14
14
|
/** @typedef {import('../../theme.type.mjs').TonalPaletteGenerationInput} TonalPaletteGenerationInput */
|
|
15
|
+
/** @typedef {import('../../theme.type.mjs').TonalPaletteRampDiagnostics} TonalPaletteRampDiagnostics */
|
|
16
|
+
/** @typedef {import('../../theme.type.mjs').TonalPaletteCoordinationDiagnostics} TonalPaletteCoordinationDiagnostics */
|
|
17
|
+
/** @typedef {import('../../theme.type.mjs').TonalPaletteNormalizedRequest} NormalizedRequest */
|
|
15
18
|
/** @typedef {[number, number, number]} ColorTriple */
|
|
16
19
|
/** @typedef {'light' | 'dark'} PaletteMode */
|
|
17
20
|
/** @typedef {{lightness: number, chroma: number, hue: number}} PolarColor */
|
|
18
21
|
/** @typedef {TonalPaletteAnchor & {color: string, generatedColor: string, deltaE: number}} AnchorResult */
|
|
19
|
-
/** @typedef {{colors: Record<number, string>, diagnostics:
|
|
22
|
+
/** @typedef {{colors: Record<number, string>, diagnostics: TonalPaletteRampDiagnostics}} GeneratedRamp */
|
|
20
23
|
/** @typedef {{id: string, name: string, seed: string, kind: 'chromatic' | 'neutral', anchors: TonalPaletteAnchor[]}} NormalizedFamily */
|
|
21
|
-
/** @typedef {{recipe: typeof PALETTE_RECIPE, vibrancy: number, neutralProfile: string, modeStrategy: string, stops: number[], families: NormalizedFamily[]}} NormalizedRequest */
|
|
22
24
|
/** @typedef {{id: string, name: string, seed: string, light?: GeneratedRamp, dark?: GeneratedRamp}} GeneratedFamily */
|
|
23
|
-
/** @typedef {{recipe: typeof PALETTE_RECIPE, status: 'candidate', request: NormalizedRequest, families: GeneratedFamily[], coordination:
|
|
25
|
+
/** @typedef {{recipe: typeof PALETTE_RECIPE, status: 'candidate', request: NormalizedRequest, families: GeneratedFamily[], coordination: TonalPaletteCoordinationDiagnostics[], errors: {familyId: string, message: string}[]}} PaletteGenerationResult */
|
|
24
26
|
|
|
25
27
|
export const PALETTE_RECIPE = 'astryx-oklch-v1';
|
|
26
28
|
export const PALETTE_BLACK = '#000000';
|
|
@@ -411,6 +413,7 @@ function buildDiagnostics(colors, stops, sourceHue, gamutMappedStops, anchors) {
|
|
|
411
413
|
let minimumAdjacentDeltaE = Number.POSITIVE_INFINITY;
|
|
412
414
|
let maximumAdjacentDeltaE = 0;
|
|
413
415
|
let maximumHueDrift = 0;
|
|
416
|
+
/** @type {TonalPaletteRampDiagnostics['hueIdentityRisk']} */
|
|
414
417
|
let hueIdentityRisk = null;
|
|
415
418
|
for (let index = 0; index < stops.length; index++) {
|
|
416
419
|
const stop = stops[index];
|
|
@@ -526,6 +529,7 @@ function buildCoordinationDiagnostics(request, families) {
|
|
|
526
529
|
chroma: hexToOklch(color).C,
|
|
527
530
|
};
|
|
528
531
|
});
|
|
532
|
+
/** @type {[string, string] | null} */
|
|
529
533
|
let closestFamilies = null;
|
|
530
534
|
let minimumFamilyDeltaE = Number.POSITIVE_INFINITY;
|
|
531
535
|
for (let index = 0; index < samples.length; index++) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* astryx --json theme build <file>
|
|
6
6
|
*/
|
|
7
7
|
export type ThemeBuildResponse = {
|
|
8
8
|
/**
|
|
@@ -27,7 +27,7 @@ export type ThemeBuildResponse = {
|
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* astryx --json theme build <file> --check
|
|
31
31
|
*/
|
|
32
32
|
export type ThemeBuildCheckResponse = {
|
|
33
33
|
type: "theme.build.check";
|
|
@@ -42,7 +42,7 @@ export type ThemeBuildCheckResponse = {
|
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* astryx --json theme build <a> <b> … — several themes in one invocation. Each
|
|
46
46
|
* result carries the file as it was passed and the receipt a single-file build
|
|
47
47
|
* would have returned (null when that theme produced no CSS). One file still
|
|
48
48
|
* returns the bare theme.build / theme.build.check envelope.
|
|
@@ -71,14 +71,14 @@ export type ThemeListEntry = {
|
|
|
71
71
|
package?: string | undefined;
|
|
72
72
|
};
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
74
|
+
* astryx --json theme list
|
|
75
75
|
*/
|
|
76
76
|
export type ThemeListResponse = {
|
|
77
77
|
type: "theme.list";
|
|
78
78
|
data: ThemeListEntry[];
|
|
79
79
|
};
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
81
|
+
* astryx --json theme add <slug>
|
|
82
82
|
*/
|
|
83
83
|
export type ThemeAddResponse = {
|
|
84
84
|
type: "theme.add";
|
|
@@ -94,7 +94,7 @@ export type ThemeAddResponse = {
|
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
96
|
/**
|
|
97
|
-
*
|
|
97
|
+
* astryx --json theme template
|
|
98
98
|
* `written: false` with `reason: 'exists'` is a success: the command is safe to
|
|
99
99
|
* re-run, and an edited template is the consumer's file to keep.
|
|
100
100
|
*/
|
|
@@ -123,7 +123,7 @@ export type ThemeTargetEntry = {
|
|
|
123
123
|
deprecatedFor?: string | undefined;
|
|
124
124
|
};
|
|
125
125
|
/**
|
|
126
|
-
*
|
|
126
|
+
* astryx --json theme targets [filter]
|
|
127
127
|
*/
|
|
128
128
|
export type ThemeTargetsResponse = {
|
|
129
129
|
type: "theme.targets";
|
|
@@ -134,8 +134,7 @@ export type ThemeTargetsResponse = {
|
|
|
134
134
|
};
|
|
135
135
|
};
|
|
136
136
|
/**
|
|
137
|
-
* A
|
|
138
|
-
* and is not connected to runtime theme values.
|
|
137
|
+
* A color an author pins at one stop of one mode, constraining generation.
|
|
139
138
|
*/
|
|
140
139
|
export type TonalPaletteAnchor = {
|
|
141
140
|
/**
|
|
@@ -146,6 +145,10 @@ export type TonalPaletteAnchor = {
|
|
|
146
145
|
* Existing requested stop where the anchor applies.
|
|
147
146
|
*/
|
|
148
147
|
stop: number;
|
|
148
|
+
/**
|
|
149
|
+
* sRGB hex the stop is pulled toward: three or six
|
|
150
|
+
* digits, with or without `#`; the generator normalizes it.
|
|
151
|
+
*/
|
|
149
152
|
color: string;
|
|
150
153
|
/**
|
|
151
154
|
* `exact` preserves the
|
|
@@ -159,11 +162,32 @@ export type TonalPaletteAnchor = {
|
|
|
159
162
|
*/
|
|
160
163
|
maxDeltaE?: number | undefined;
|
|
161
164
|
};
|
|
165
|
+
/**
|
|
166
|
+
* One requested family: a seed color and the constraints applied to its ramp.
|
|
167
|
+
*/
|
|
162
168
|
export type TonalPaletteFamilyInput = {
|
|
169
|
+
/**
|
|
170
|
+
* Lower-kebab-case key for the family in the generated
|
|
171
|
+
* palette. `black` and `white` are reserved for the standalone values.
|
|
172
|
+
*/
|
|
163
173
|
id: string;
|
|
174
|
+
/**
|
|
175
|
+
* sRGB hex the ramp is generated from: three or six
|
|
176
|
+
* digits, with or without `#`; the generator normalizes it.
|
|
177
|
+
*/
|
|
164
178
|
seed: string;
|
|
179
|
+
/**
|
|
180
|
+
* Display name for review artifacts; defaults to `id`.
|
|
181
|
+
*/
|
|
165
182
|
name?: string | undefined;
|
|
183
|
+
/**
|
|
184
|
+
* `neutral` derives the ramp from
|
|
185
|
+
* `neutralProfile` instead of the seed hue; defaults to `chromatic`.
|
|
186
|
+
*/
|
|
166
187
|
kind?: "neutral" | "chromatic" | undefined;
|
|
188
|
+
/**
|
|
189
|
+
* Colors pinned at specific stops.
|
|
190
|
+
*/
|
|
167
191
|
anchors?: TonalPaletteAnchor[] | undefined;
|
|
168
192
|
};
|
|
169
193
|
export type TonalPaletteGenerationInput = {
|
|
@@ -173,6 +197,11 @@ export type TonalPaletteGenerationInput = {
|
|
|
173
197
|
* (default) to 100 (most vivid).
|
|
174
198
|
*/
|
|
175
199
|
vibrancy?: number | undefined;
|
|
200
|
+
/**
|
|
201
|
+
* Hue treatment for `neutral` families: `neutral-v1` is fully achromatic,
|
|
202
|
+
* `warm-v1` and `cool-v1` add a slight tint, and `custom` derives the hue from
|
|
203
|
+
* the family's own seed. Defaults to `neutral-v1`.
|
|
204
|
+
*/
|
|
176
205
|
neutralProfile?: "custom" | "neutral-v1" | "warm-v1" | "cool-v1" | undefined;
|
|
177
206
|
modeStrategy?: "light-only" | "dark-only" | "light-and-dark" | undefined;
|
|
178
207
|
/**
|
|
@@ -182,6 +211,10 @@ export type TonalPaletteGenerationInput = {
|
|
|
182
211
|
*/
|
|
183
212
|
stops?: number[] | undefined;
|
|
184
213
|
};
|
|
214
|
+
/**
|
|
215
|
+
* A generated palette candidate. The palette is still subject to author review
|
|
216
|
+
* and is not connected to runtime theme values.
|
|
217
|
+
*/
|
|
185
218
|
export type TonalPaletteCandidate = {
|
|
186
219
|
schemaVersion: 1;
|
|
187
220
|
status: "candidate";
|
|
@@ -205,7 +238,133 @@ export type TonalPaletteCandidate = {
|
|
|
205
238
|
}>;
|
|
206
239
|
};
|
|
207
240
|
/**
|
|
208
|
-
*
|
|
241
|
+
* Per-ramp evidence recorded for one family in one mode.
|
|
242
|
+
*/
|
|
243
|
+
export type TonalPaletteRampDiagnostics = {
|
|
244
|
+
/**
|
|
245
|
+
* Whether luminance rises across every stop.
|
|
246
|
+
*/
|
|
247
|
+
monotonic: boolean;
|
|
248
|
+
/**
|
|
249
|
+
* Smallest perceptual gap between
|
|
250
|
+
* neighboring stops; a small value means two stops read as one color.
|
|
251
|
+
*/
|
|
252
|
+
minimumAdjacentDeltaE: number;
|
|
253
|
+
/**
|
|
254
|
+
* Largest gap between neighboring stops.
|
|
255
|
+
*/
|
|
256
|
+
maximumAdjacentDeltaE: number;
|
|
257
|
+
/**
|
|
258
|
+
* Largest hue distance, in degrees, between
|
|
259
|
+
* a stop and the family's reference hue.
|
|
260
|
+
*/
|
|
261
|
+
maximumHueDrift: number;
|
|
262
|
+
/**
|
|
263
|
+
* Named
|
|
264
|
+
* drift the ramp is at risk of, or `null`.
|
|
265
|
+
*/
|
|
266
|
+
hueIdentityRisk: "blue-to-purple" | "yellow-to-brown" | null;
|
|
267
|
+
/**
|
|
268
|
+
* Stops whose ideal color fell outside
|
|
269
|
+
* sRGB and was mapped back into it.
|
|
270
|
+
*/
|
|
271
|
+
gamutMappedStops: number[];
|
|
272
|
+
/**
|
|
273
|
+
* Each anchor with the color the stop received after its policy was applied
|
|
274
|
+
* and the perceptual distance that color still has from the requested target.
|
|
275
|
+
*/
|
|
276
|
+
anchors: Array<TonalPaletteAnchor & {
|
|
277
|
+
generatedColor: string;
|
|
278
|
+
deltaE: number;
|
|
279
|
+
}>;
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* Cross-family evidence for one mode, sampled at the stop nearest 50.
|
|
283
|
+
*/
|
|
284
|
+
export type TonalPaletteCoordinationDiagnostics = {
|
|
285
|
+
/**
|
|
286
|
+
* Mode these samples come from.
|
|
287
|
+
*/
|
|
288
|
+
mode: "light" | "dark";
|
|
289
|
+
/**
|
|
290
|
+
* Sampled stop.
|
|
291
|
+
*/
|
|
292
|
+
stop: number;
|
|
293
|
+
/**
|
|
294
|
+
* The two chromatic
|
|
295
|
+
* families hardest to tell apart, or `null` with fewer than two.
|
|
296
|
+
*/
|
|
297
|
+
closestFamilies: [string, string] | null;
|
|
298
|
+
/**
|
|
299
|
+
* Perceptual distance between them.
|
|
300
|
+
*/
|
|
301
|
+
minimumFamilyDeltaE: number | null;
|
|
302
|
+
/**
|
|
303
|
+
* Most saturated family at this stop.
|
|
304
|
+
*/
|
|
305
|
+
strongestFamily: string | null;
|
|
306
|
+
/**
|
|
307
|
+
* Least saturated family at this stop.
|
|
308
|
+
*/
|
|
309
|
+
weakestFamily: string | null;
|
|
310
|
+
/**
|
|
311
|
+
* Strongest chroma over weakest; a large
|
|
312
|
+
* ratio means the families are unbalanced.
|
|
313
|
+
*/
|
|
314
|
+
chromaRatio: number | null;
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* The request as the generator resolved it, with every default filled in.
|
|
318
|
+
*/
|
|
319
|
+
export type TonalPaletteNormalizedRequest = {
|
|
320
|
+
recipe: "astryx-oklch-v1";
|
|
321
|
+
vibrancy: number;
|
|
322
|
+
neutralProfile: "neutral-v1" | "warm-v1" | "cool-v1" | "custom";
|
|
323
|
+
modeStrategy: "light-only" | "dark-only" | "light-and-dark";
|
|
324
|
+
stops: number[];
|
|
325
|
+
families: Array<{
|
|
326
|
+
id: string;
|
|
327
|
+
name: string;
|
|
328
|
+
seed: string;
|
|
329
|
+
kind: "chromatic" | "neutral";
|
|
330
|
+
anchors: TonalPaletteAnchor[];
|
|
331
|
+
}>;
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* The detached receipt written beside a candidate. It records what was asked
|
|
335
|
+
* for and what the generator observed, so a candidate can be traced back to
|
|
336
|
+
* its request without rerunning generation.
|
|
337
|
+
*/
|
|
338
|
+
export type TonalPaletteGenerationReceipt = {
|
|
339
|
+
schemaVersion: 1;
|
|
340
|
+
/**
|
|
341
|
+
* Recipe that produced the candidate.
|
|
342
|
+
*/
|
|
343
|
+
recipe: "astryx-oklch-v1";
|
|
344
|
+
/**
|
|
345
|
+
* SHA-256 over the candidate bytes as written.
|
|
346
|
+
*/
|
|
347
|
+
candidateSha256: string;
|
|
348
|
+
/**
|
|
349
|
+
* Present when preview
|
|
350
|
+
* content was generated for the request, even if no file was written because
|
|
351
|
+
* the target already exists.
|
|
352
|
+
*/
|
|
353
|
+
preview?: {
|
|
354
|
+
version: string;
|
|
355
|
+
sha256: string;
|
|
356
|
+
} | undefined;
|
|
357
|
+
request: TonalPaletteNormalizedRequest;
|
|
358
|
+
diagnostics: {
|
|
359
|
+
families: Record<string, {
|
|
360
|
+
light?: TonalPaletteRampDiagnostics;
|
|
361
|
+
dark?: TonalPaletteRampDiagnostics;
|
|
362
|
+
}>;
|
|
363
|
+
coordination: TonalPaletteCoordinationDiagnostics[];
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* astryx --json theme palette generate <config>
|
|
209
368
|
*/
|
|
210
369
|
export type ThemePaletteGenerateResponse = {
|
|
211
370
|
type: "theme.palette.generate";
|
|
@@ -221,6 +380,6 @@ export type ThemePaletteGenerateResponse = {
|
|
|
221
380
|
written: boolean;
|
|
222
381
|
reason: "exists" | null;
|
|
223
382
|
candidate: TonalPaletteCandidate;
|
|
224
|
-
generationReceipt:
|
|
383
|
+
generationReceipt: TonalPaletteGenerationReceipt;
|
|
225
384
|
};
|
|
226
385
|
};
|