@astryxdesign/cli 0.6.3-canary.2c831e4 → 0.6.3-canary.3ee796c
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/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/docs.type.d.mts +4 -4
- package/api/docs/docs.type.mjs +10 -10
- package/api/hook/hook.type.d.mts +3 -3
- package/api/hook/hook.type.mjs +11 -11
- package/api/integration/add-contribution.mjs +3 -5
- package/api/integration/add-contribution.test.mjs +4 -4
- package/api/integration/pack-check.mjs +7 -49
- package/api/integration/pack-check.test.mjs +0 -249
- package/api/search/search.type.d.mts +1 -1
- 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.type.d.mts +5 -5
- package/api/template/template.type.mjs +12 -12
- package/api/theme/build/build.mjs +6 -20
- package/api/theme/build/build.test.mjs +0 -127
- package/api/theme/palette/generate/generate.mjs +1 -1
- package/api/theme/palette/generate/generator.d.mts +13 -10
- package/api/theme/palette/generate/generator.mjs +3 -7
- package/api/theme/theme.type.d.mts +11 -170
- package/api/theme/theme.type.mjs +27 -94
- package/api/upgrade/upgrade.type.d.mts +4 -4
- package/api/upgrade/upgrade.type.mjs +10 -10
- package/assets/codemods/integration-discovery.mjs +2 -40
- package/assets/codemods/integration-discovery.test.mjs +0 -58
- package/assets/docs/cli-integrations.doc.mjs +0 -9
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +1 -1
- package/clients/cli/commands/integration-authoring.test.mjs +9 -13
- package/package.json +11 -9
|
@@ -567,252 +567,3 @@ describe('pack-check mutation tests', () => {
|
|
|
567
567
|
}
|
|
568
568
|
});
|
|
569
569
|
});
|
|
570
|
-
|
|
571
|
-
describe('extensionless subpath resolution', () => {
|
|
572
|
-
it('rejects .tsx public specifiers before publishing', async () => {
|
|
573
|
-
// Manually construct a package with OLD-style .tsx exports keys
|
|
574
|
-
writePackage({
|
|
575
|
-
manifest: "export default {components: './components'};\n",
|
|
576
|
-
files: ['astryx.integration.mjs', 'components', 'index.mjs'],
|
|
577
|
-
themes: false,
|
|
578
|
-
});
|
|
579
|
-
const pkgFile = path.join(tmpDir, 'package.json');
|
|
580
|
-
const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
|
|
581
|
-
pkg.exports = {
|
|
582
|
-
'.': './index.mjs',
|
|
583
|
-
'./components/AcmeWidget.tsx': './components/AcmeWidget.tsx',
|
|
584
|
-
};
|
|
585
|
-
fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
586
|
-
fs.writeFileSync(
|
|
587
|
-
path.join(tmpDir, 'index.mjs'),
|
|
588
|
-
'export const existing = 1;\n',
|
|
589
|
-
);
|
|
590
|
-
fs.mkdirSync(path.join(tmpDir, 'components'));
|
|
591
|
-
fs.writeFileSync(
|
|
592
|
-
path.join(tmpDir, 'components', 'AcmeWidget.doc.mjs'),
|
|
593
|
-
`export default {type: 'component', name: 'AcmeWidget', import: '@acme/widgets/components/AcmeWidget.tsx', description: 'Widget.', props: []};\n`,
|
|
594
|
-
);
|
|
595
|
-
fs.writeFileSync(
|
|
596
|
-
path.join(tmpDir, 'components', 'AcmeWidget.tsx'),
|
|
597
|
-
'export function AcmeWidget() { return null; }\n',
|
|
598
|
-
);
|
|
599
|
-
|
|
600
|
-
const result = await integrationPackCheck({cwd: tmpDir});
|
|
601
|
-
|
|
602
|
-
// The .tsx extension in the specifier must be caught
|
|
603
|
-
expect(result.data.packable).toBe(false);
|
|
604
|
-
expect(result.data.issues).toContainEqual(
|
|
605
|
-
expect.objectContaining({
|
|
606
|
-
code: 'typescript_extension_in_specifier',
|
|
607
|
-
message: expect.stringContaining('.tsx'),
|
|
608
|
-
}),
|
|
609
|
-
);
|
|
610
|
-
});
|
|
611
|
-
|
|
612
|
-
it('generated extensionless component specifier resolves through exports map', async () => {
|
|
613
|
-
fs.writeFileSync(
|
|
614
|
-
path.join(tmpDir, 'package.json'),
|
|
615
|
-
`${JSON.stringify({
|
|
616
|
-
name: '@acme/widgets',
|
|
617
|
-
version: '1.0.0',
|
|
618
|
-
files: ['index.mjs'],
|
|
619
|
-
exports: {'.': './index.mjs'},
|
|
620
|
-
})}\n`,
|
|
621
|
-
);
|
|
622
|
-
fs.writeFileSync(
|
|
623
|
-
path.join(tmpDir, 'index.mjs'),
|
|
624
|
-
'export const existing = 1;\n',
|
|
625
|
-
);
|
|
626
|
-
await integrationAddComponent('AcmeWidget', {cwd: tmpDir});
|
|
627
|
-
|
|
628
|
-
// Verify the exports map has extensionless key → .tsx target
|
|
629
|
-
const pkg = JSON.parse(
|
|
630
|
-
fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'),
|
|
631
|
-
);
|
|
632
|
-
expect(pkg.exports['./components/AcmeWidget']).toBe(
|
|
633
|
-
'./components/AcmeWidget.tsx',
|
|
634
|
-
);
|
|
635
|
-
expect(pkg.exports['./components/AcmeWidget.tsx']).toBeUndefined();
|
|
636
|
-
|
|
637
|
-
const result = await integrationPackCheck({cwd: tmpDir});
|
|
638
|
-
|
|
639
|
-
expect(result.data.packable).toBe(true);
|
|
640
|
-
expect(result.data.issues).not.toContainEqual(
|
|
641
|
-
expect.objectContaining({code: 'typescript_extension_in_specifier'}),
|
|
642
|
-
);
|
|
643
|
-
expect(result.data.issues).not.toContainEqual(
|
|
644
|
-
expect.objectContaining({code: 'component_import_unresolvable'}),
|
|
645
|
-
);
|
|
646
|
-
});
|
|
647
|
-
|
|
648
|
-
it('validates generated imports without project-local TypeScript', async () => {
|
|
649
|
-
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
650
|
-
tmpDir = fs.mkdtempSync(
|
|
651
|
-
path.join(os.tmpdir(), 'astryx-pack-check-no-typescript-'),
|
|
652
|
-
);
|
|
653
|
-
fs.writeFileSync(
|
|
654
|
-
path.join(tmpDir, 'package.json'),
|
|
655
|
-
`${JSON.stringify({
|
|
656
|
-
name: '@acme/widgets',
|
|
657
|
-
version: '1.0.0',
|
|
658
|
-
files: ['index.mjs'],
|
|
659
|
-
exports: {'.': './index.mjs'},
|
|
660
|
-
})}\n`,
|
|
661
|
-
);
|
|
662
|
-
fs.writeFileSync(
|
|
663
|
-
path.join(tmpDir, 'index.mjs'),
|
|
664
|
-
'export const existing = 1;\n',
|
|
665
|
-
);
|
|
666
|
-
await integrationAddComponent('AcmeWidget', {cwd: tmpDir});
|
|
667
|
-
|
|
668
|
-
const result = await integrationPackCheck({cwd: tmpDir});
|
|
669
|
-
|
|
670
|
-
expect(result.data.packable).toBe(true);
|
|
671
|
-
expect(result.data.issues).not.toContainEqual(
|
|
672
|
-
expect.objectContaining({code: 'component_import_unresolvable'}),
|
|
673
|
-
);
|
|
674
|
-
});
|
|
675
|
-
|
|
676
|
-
it('generated extensionless template specifiers resolve for page and block types', async () => {
|
|
677
|
-
fs.writeFileSync(
|
|
678
|
-
path.join(tmpDir, 'package.json'),
|
|
679
|
-
`${JSON.stringify({
|
|
680
|
-
name: '@acme/widgets',
|
|
681
|
-
version: '1.0.0',
|
|
682
|
-
files: ['index.mjs'],
|
|
683
|
-
exports: {'.': './index.mjs'},
|
|
684
|
-
})}\n`,
|
|
685
|
-
);
|
|
686
|
-
fs.writeFileSync(
|
|
687
|
-
path.join(tmpDir, 'index.mjs'),
|
|
688
|
-
'export const existing = 1;\n',
|
|
689
|
-
);
|
|
690
|
-
await integrationAddTemplate('account-page', {cwd: tmpDir, type: 'page'});
|
|
691
|
-
await integrationAddTemplate('info-card', {cwd: tmpDir, type: 'block'});
|
|
692
|
-
|
|
693
|
-
const pkg = JSON.parse(
|
|
694
|
-
fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'),
|
|
695
|
-
);
|
|
696
|
-
expect(pkg.exports['./templates/account-page']).toBe(
|
|
697
|
-
'./templates/account-page.tsx',
|
|
698
|
-
);
|
|
699
|
-
expect(pkg.exports['./templates/info-card']).toBe(
|
|
700
|
-
'./templates/info-card.tsx',
|
|
701
|
-
);
|
|
702
|
-
|
|
703
|
-
const result = await integrationPackCheck({cwd: tmpDir});
|
|
704
|
-
|
|
705
|
-
expect(result.data.packable).toBe(true);
|
|
706
|
-
expect(result.data.issues).not.toContainEqual(
|
|
707
|
-
expect.objectContaining({code: 'template_import_unresolvable'}),
|
|
708
|
-
);
|
|
709
|
-
expect(result.data.issues).not.toContainEqual(
|
|
710
|
-
expect.objectContaining({code: 'typescript_extension_in_specifier'}),
|
|
711
|
-
);
|
|
712
|
-
});
|
|
713
|
-
|
|
714
|
-
it('preserves condition-style exports sugar without creating a map', async () => {
|
|
715
|
-
// Package with condition-only exports (sugar, no subpaths)
|
|
716
|
-
fs.writeFileSync(
|
|
717
|
-
path.join(tmpDir, 'package.json'),
|
|
718
|
-
`${JSON.stringify({
|
|
719
|
-
name: '@acme/widgets',
|
|
720
|
-
version: '1.0.0',
|
|
721
|
-
files: ['index.mjs'],
|
|
722
|
-
exports: {import: './index.mjs', require: './index.cjs'},
|
|
723
|
-
})}\n`,
|
|
724
|
-
);
|
|
725
|
-
fs.writeFileSync(
|
|
726
|
-
path.join(tmpDir, 'index.mjs'),
|
|
727
|
-
'export const existing = 1;\n',
|
|
728
|
-
);
|
|
729
|
-
fs.writeFileSync(path.join(tmpDir, 'index.cjs'), 'exports.existing = 1;\n');
|
|
730
|
-
fs.writeFileSync(
|
|
731
|
-
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
732
|
-
'export default {};\n',
|
|
733
|
-
);
|
|
734
|
-
|
|
735
|
-
await integrationAddComponent('AcmeWidget', {cwd: tmpDir});
|
|
736
|
-
|
|
737
|
-
const pkg = JSON.parse(
|
|
738
|
-
fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'),
|
|
739
|
-
);
|
|
740
|
-
// Condition sugar wrapped into subpath map with the component added
|
|
741
|
-
expect(pkg.exports['.']).toEqual({
|
|
742
|
-
import: './index.mjs',
|
|
743
|
-
require: './index.cjs',
|
|
744
|
-
});
|
|
745
|
-
expect(pkg.exports['./components/AcmeWidget']).toBe(
|
|
746
|
-
'./components/AcmeWidget.tsx',
|
|
747
|
-
);
|
|
748
|
-
});
|
|
749
|
-
|
|
750
|
-
it('no-map: pack-check fails when generated component has no exports map', async () => {
|
|
751
|
-
fs.writeFileSync(
|
|
752
|
-
path.join(tmpDir, 'package.json'),
|
|
753
|
-
`${JSON.stringify({
|
|
754
|
-
name: '@acme/widgets',
|
|
755
|
-
version: '1.0.0',
|
|
756
|
-
files: ['dist'],
|
|
757
|
-
})}\n`,
|
|
758
|
-
);
|
|
759
|
-
fs.writeFileSync(
|
|
760
|
-
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
761
|
-
'export default {};\n',
|
|
762
|
-
);
|
|
763
|
-
|
|
764
|
-
await integrationAddComponent('AcmeWidget', {cwd: tmpDir});
|
|
765
|
-
await integrationAddTemplate('hero-page', {cwd: tmpDir, type: 'page'});
|
|
766
|
-
|
|
767
|
-
const pkg = JSON.parse(
|
|
768
|
-
fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'),
|
|
769
|
-
);
|
|
770
|
-
// No exports map created
|
|
771
|
-
expect(pkg.exports).toBeUndefined();
|
|
772
|
-
|
|
773
|
-
const result = await integrationPackCheck({cwd: tmpDir});
|
|
774
|
-
|
|
775
|
-
// The extensionless import cannot resolve without an exports map —
|
|
776
|
-
// pack-check must fail closed, not false-green.
|
|
777
|
-
expect(result.data.packable).toBe(false);
|
|
778
|
-
expect(result.data.issues).toContainEqual(
|
|
779
|
-
expect.objectContaining({
|
|
780
|
-
severity: 'error',
|
|
781
|
-
message: expect.stringContaining('AcmeWidget'),
|
|
782
|
-
}),
|
|
783
|
-
);
|
|
784
|
-
});
|
|
785
|
-
|
|
786
|
-
it('idempotent when extensionless export already exists', async () => {
|
|
787
|
-
fs.writeFileSync(
|
|
788
|
-
path.join(tmpDir, 'package.json'),
|
|
789
|
-
`${JSON.stringify({
|
|
790
|
-
name: '@acme/widgets',
|
|
791
|
-
version: '1.0.0',
|
|
792
|
-
files: ['index.mjs'],
|
|
793
|
-
exports: {
|
|
794
|
-
'.': './index.mjs',
|
|
795
|
-
'./components/AcmeWidget': './components/AcmeWidget.tsx',
|
|
796
|
-
},
|
|
797
|
-
})}\n`,
|
|
798
|
-
);
|
|
799
|
-
fs.writeFileSync(
|
|
800
|
-
path.join(tmpDir, 'index.mjs'),
|
|
801
|
-
'export const existing = 1;\n',
|
|
802
|
-
);
|
|
803
|
-
fs.writeFileSync(
|
|
804
|
-
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
805
|
-
'export default {};\n',
|
|
806
|
-
);
|
|
807
|
-
|
|
808
|
-
await integrationAddComponent('AcmeWidget', {cwd: tmpDir});
|
|
809
|
-
|
|
810
|
-
const pkg = JSON.parse(
|
|
811
|
-
fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'),
|
|
812
|
-
);
|
|
813
|
-
// Export preserved, no duplicate
|
|
814
|
-
expect(
|
|
815
|
-
Object.keys(pkg.exports).filter(k => k.includes('AcmeWidget')),
|
|
816
|
-
).toEqual(['./components/AcmeWidget']);
|
|
817
|
-
});
|
|
818
|
-
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* xds --json swizzle [--list]
|
|
6
6
|
*/
|
|
7
7
|
export type SwizzleListResponse = {
|
|
8
8
|
type: "swizzle.list";
|
|
@@ -22,7 +22,7 @@ export type SwizzleFeedback = {
|
|
|
22
22
|
ghCommand?: string | undefined;
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* xds --json swizzle <component>
|
|
26
26
|
*/
|
|
27
27
|
export type SwizzleCopyResponse = {
|
|
28
28
|
type: "swizzle.copy";
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* xds --json swizzle [--list]
|
|
11
11
|
*
|
|
12
12
|
* @typedef {object} SwizzleListResponse
|
|
13
13
|
* @property {'swizzle.list'} type
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* xds --json swizzle <component>
|
|
27
27
|
*
|
|
28
28
|
* @typedef {object} SwizzleCopyResponse
|
|
29
29
|
* @property {'swizzle.copy'} type
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* xds --json template [--list]
|
|
6
6
|
*/
|
|
7
7
|
export type TemplateListResponse = {
|
|
8
8
|
type: "template.list";
|
|
@@ -53,7 +53,7 @@ export type TemplateListEntry = {
|
|
|
53
53
|
scaffold?: boolean | undefined;
|
|
54
54
|
};
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* xds --json template <name>
|
|
57
57
|
*/
|
|
58
58
|
export type TemplateShowResponse = {
|
|
59
59
|
type: "template.show";
|
|
@@ -66,7 +66,7 @@ export type TemplateShowResponse = {
|
|
|
66
66
|
};
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
69
|
+
* xds --json template <name> --skeleton
|
|
70
70
|
*/
|
|
71
71
|
export type TemplateSkeletonResponse = {
|
|
72
72
|
type: "template.skeleton";
|
|
@@ -78,7 +78,7 @@ export type TemplateSkeletonResponse = {
|
|
|
78
78
|
};
|
|
79
79
|
};
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
81
|
+
* xds --json template <name> [path]
|
|
82
82
|
*/
|
|
83
83
|
export type TemplateCopyResponse = {
|
|
84
84
|
type: "template.copy";
|
|
@@ -90,7 +90,7 @@ export type TemplateCopyResponse = {
|
|
|
90
90
|
};
|
|
91
91
|
};
|
|
92
92
|
/**
|
|
93
|
-
*
|
|
93
|
+
* xds --json template --cdn [path]
|
|
94
94
|
* `written: false` with `reason: 'exists'` is a success: the command is safe to
|
|
95
95
|
* re-run, and an edited page is the consumer's file to keep. `version` is the
|
|
96
96
|
* Astryx version every CDN URL in the file was pinned to.
|
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Each template is exactly two files: page.tsx (code) + template.doc.mjs (metadata).
|
|
8
8
|
*
|
|
9
|
-
* Invocation
|
|
9
|
+
* Invocation -> type discriminator
|
|
10
10
|
* ------------------------------------------------------------------
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* (unknown template)
|
|
11
|
+
* xds --json template [--list] -> template.list
|
|
12
|
+
* xds --json template <name> -> template.show
|
|
13
|
+
* xds --json template <name> --skeleton -> template.skeleton
|
|
14
|
+
* xds --json template <name> [path] -> template.copy
|
|
15
|
+
* xds --json template --cdn [path] -> template.cdn
|
|
16
|
+
* (unknown template) -> CLIError
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* xds --json template [--list]
|
|
21
21
|
* @typedef {object} TemplateListResponse
|
|
22
22
|
* @property {'template.list'} type
|
|
23
23
|
* @property {TemplateListEntry[]} data
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* xds --json template <name>
|
|
47
47
|
* @typedef {object} TemplateShowResponse
|
|
48
48
|
* @property {'template.show'} type
|
|
49
49
|
* @property {object} data
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
*/
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
58
|
+
* xds --json template <name> --skeleton
|
|
59
59
|
* @typedef {object} TemplateSkeletonResponse
|
|
60
60
|
* @property {'template.skeleton'} type
|
|
61
61
|
* @property {object} data
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
*/
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
69
|
+
* xds --json template <name> [path]
|
|
70
70
|
* @typedef {object} TemplateCopyResponse
|
|
71
71
|
* @property {'template.copy'} type
|
|
72
72
|
* @property {object} data
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
*/
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
80
|
+
* xds --json template --cdn [path]
|
|
81
81
|
* `written: false` with `reason: 'exists'` is a success: the command is safe to
|
|
82
82
|
* re-run, and an edited page is the consumer's file to keep. `version` is the
|
|
83
83
|
* Astryx version every CDN URL in the file was pinned to.
|
|
@@ -12,10 +12,9 @@
|
|
|
12
12
|
* - A .d.ts (plus an optional .variants.d.ts for custom prop values)
|
|
13
13
|
*
|
|
14
14
|
* It performs the writes and returns a `theme.build` receipt — its `warnings`
|
|
15
|
-
* carry override problems
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* CSS (nothing to build). Errors throw AstryxError (with
|
|
15
|
+
* carry override problems and any fonts the theme names but does not load
|
|
16
|
+
* (font-warning.mjs) — or `null` when the theme produced no CSS (nothing to
|
|
17
|
+
* build). Errors throw AstryxError (with
|
|
19
18
|
* a stable code). Human progress is emitted through the shared `logger`
|
|
20
19
|
* (silent by default), so the CLI keeps its exact output while a programmatic
|
|
21
20
|
* caller stays quiet.
|
|
@@ -2304,15 +2303,7 @@ async function themeBuildInternal(
|
|
|
2304
2303
|
const scopeSelector = themeScopeStart(themeDef.name);
|
|
2305
2304
|
const scopeTo = THEME_SCOPE_TO;
|
|
2306
2305
|
|
|
2307
|
-
|
|
2308
|
-
// warning text here that runtime callers receive on the console.
|
|
2309
|
-
/** @type {string[]} */
|
|
2310
|
-
const droppedDeclarations = [];
|
|
2311
|
-
|
|
2312
|
-
const {component, prose} = _generateThemeRulesSplit(
|
|
2313
|
-
resolvedTheme,
|
|
2314
|
-
droppedDeclarations,
|
|
2315
|
-
);
|
|
2306
|
+
const {component, prose} = _generateThemeRulesSplit(resolvedTheme);
|
|
2316
2307
|
const cssParts = [];
|
|
2317
2308
|
// Prose element defaults always ship — the `<Theme>` runtime
|
|
2318
2309
|
// (generateThemeCSS) always emits them, so the build must too, or the
|
|
@@ -2331,7 +2322,7 @@ async function themeBuildInternal(
|
|
|
2331
2322
|
let adaptationCss;
|
|
2332
2323
|
try {
|
|
2333
2324
|
adaptationCss = _generateAdaptationCSS
|
|
2334
|
-
? _generateAdaptationCSS(resolvedTheme
|
|
2325
|
+
? _generateAdaptationCSS(resolvedTheme)
|
|
2335
2326
|
: {component: '', prose: ''};
|
|
2336
2327
|
} catch (error) {
|
|
2337
2328
|
const message =
|
|
@@ -2377,16 +2368,11 @@ async function themeBuildInternal(
|
|
|
2377
2368
|
// adaptations on the same resolved leaf.
|
|
2378
2369
|
let onMediaCss = '';
|
|
2379
2370
|
if (_generateOnMediaCSS) {
|
|
2380
|
-
onMediaCss = _generateOnMediaCSS(resolvedTheme
|
|
2371
|
+
onMediaCss = _generateOnMediaCSS(resolvedTheme);
|
|
2381
2372
|
if (onMediaCss) {
|
|
2382
2373
|
cssParts.push(`@layer astryx-theme {\n${onMediaCss}\n}`);
|
|
2383
2374
|
}
|
|
2384
2375
|
}
|
|
2385
|
-
for (const message of droppedDeclarations) {
|
|
2386
|
-
const w = `Declaration ${message}. The generated CSS omits it; fix the value in the theme source.`;
|
|
2387
|
-
warningMessages.push(w);
|
|
2388
|
-
logger.warn(` ⚠ ${w}`);
|
|
2389
|
-
}
|
|
2390
2376
|
if (cssParts.length === 0) {
|
|
2391
2377
|
logger.log('No overrides found — nothing to build.');
|
|
2392
2378
|
return null;
|
|
@@ -206,133 +206,6 @@ 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
|
-
|
|
336
209
|
describe('themeBuild() — nothing to build', () => {
|
|
337
210
|
it('returns null and writes nothing when the generator yields no CSS', async () => {
|
|
338
211
|
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] */
|
|
104
104
|
function receiptFor(result, candidateText, previewText = null) {
|
|
105
105
|
return {
|
|
106
106
|
schemaVersion: 1,
|
|
@@ -22,17 +22,15 @@ 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 */
|
|
28
25
|
/** @typedef {[number, number, number]} ColorTriple */
|
|
29
26
|
/** @typedef {'light' | 'dark'} PaletteMode */
|
|
30
27
|
/** @typedef {{lightness: number, chroma: number, hue: number}} PolarColor */
|
|
31
28
|
/** @typedef {TonalPaletteAnchor & {color: string, generatedColor: string, deltaE: number}} AnchorResult */
|
|
32
|
-
/** @typedef {{colors: Record<number, string>, diagnostics:
|
|
29
|
+
/** @typedef {{colors: Record<number, string>, diagnostics: Record<string, unknown>}} GeneratedRamp */
|
|
33
30
|
/** @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 */
|
|
34
32
|
/** @typedef {{id: string, name: string, seed: string, light?: GeneratedRamp, dark?: GeneratedRamp}} GeneratedFamily */
|
|
35
|
-
/** @typedef {{recipe: typeof PALETTE_RECIPE, status: 'candidate', request: NormalizedRequest, families: GeneratedFamily[], coordination:
|
|
33
|
+
/** @typedef {{recipe: typeof PALETTE_RECIPE, status: 'candidate', request: NormalizedRequest, families: GeneratedFamily[], coordination: Record<string, unknown>[], errors: {familyId: string, message: string}[]}} PaletteGenerationResult */
|
|
36
34
|
export const PALETTE_RECIPE: "astryx-oklch-v1";
|
|
37
35
|
export const PALETTE_BLACK: "#000000";
|
|
38
36
|
export const PALETTE_WHITE: "#ffffff";
|
|
@@ -40,9 +38,6 @@ export const DEFAULT_21_STOPS: readonly number[];
|
|
|
40
38
|
export const COMPACT_11_STOPS: readonly number[];
|
|
41
39
|
export type TonalPaletteAnchor = import("../../theme.type.mjs").TonalPaletteAnchor;
|
|
42
40
|
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;
|
|
46
41
|
export type ColorTriple = [number, number, number];
|
|
47
42
|
export type PaletteMode = "light" | "dark";
|
|
48
43
|
export type PolarColor = {
|
|
@@ -57,7 +52,7 @@ export type AnchorResult = TonalPaletteAnchor & {
|
|
|
57
52
|
};
|
|
58
53
|
export type GeneratedRamp = {
|
|
59
54
|
colors: Record<number, string>;
|
|
60
|
-
diagnostics:
|
|
55
|
+
diagnostics: Record<string, unknown>;
|
|
61
56
|
};
|
|
62
57
|
export type NormalizedFamily = {
|
|
63
58
|
id: string;
|
|
@@ -66,6 +61,14 @@ export type NormalizedFamily = {
|
|
|
66
61
|
kind: "chromatic" | "neutral";
|
|
67
62
|
anchors: TonalPaletteAnchor[];
|
|
68
63
|
};
|
|
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
|
+
};
|
|
69
72
|
export type GeneratedFamily = {
|
|
70
73
|
id: string;
|
|
71
74
|
name: string;
|
|
@@ -78,7 +81,7 @@ export type PaletteGenerationResult = {
|
|
|
78
81
|
status: "candidate";
|
|
79
82
|
request: NormalizedRequest;
|
|
80
83
|
families: GeneratedFamily[];
|
|
81
|
-
coordination:
|
|
84
|
+
coordination: Record<string, unknown>[];
|
|
82
85
|
errors: {
|
|
83
86
|
familyId: string;
|
|
84
87
|
message: string;
|