@astryxdesign/cli 0.6.3-canary.bcf01fe → 0.6.3-canary.c13ef6b
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 +5 -3
- package/api/integration/add-contribution.test.mjs +4 -4
- package/api/integration/pack-check.mjs +49 -7
- package/api/integration/pack-check.test.mjs +249 -0
- 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 +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/upgrade.type.d.mts +4 -4
- package/api/upgrade/upgrade.type.mjs +10 -10
- 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 +4 -4
- package/authoring/debug/parse.mjs +3 -3
- package/authoring/doctypes/_schema.d.mts +121 -11
- package/authoring/doctypes/_schema.mjs +144 -13
- package/authoring/doctypes/base/graph-fields.doc.mjs +11 -4
- package/authoring/doctypes/base/type.ts +8 -4
- 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 +2 -2
- package/authoring/doctypes/component/component.doc.mjs +5 -2
- package/authoring/doctypes/component/parse.d.mts +2 -2
- package/authoring/doctypes/component/parse.mjs +1 -1
- package/authoring/doctypes/component/type.ts +1 -1
- package/authoring/doctypes/enum/parse.d.mts +2 -2
- package/authoring/doctypes/enum/parse.mjs +1 -1
- package/authoring/doctypes/enum/type.ts +1 -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 +1 -1
- 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 +1 -1
- package/authoring/doctypes/legacy.d.mts +6 -6
- package/authoring/doctypes/legacy.mjs +3 -3
- package/authoring/doctypes/load-contract.test.mjs +207 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +7 -3
- package/authoring/doctypes/namespace/parse.d.mts +2 -2
- package/authoring/doctypes/namespace/parse.mjs +1 -1
- package/authoring/doctypes/namespace/type.ts +2 -2
- package/authoring/doctypes/parse.d.mts +18 -18
- package/authoring/doctypes/parse.mjs +9 -9
- package/authoring/doctypes/reference/parse.d.mts +2 -2
- package/authoring/doctypes/reference/parse.mjs +1 -1
- package/authoring/doctypes/reference/reference.doc.mjs +6 -2
- package/authoring/doctypes/reference/type.ts +1 -1
- package/authoring/doctypes/schema/parse.d.mts +2 -2
- package/authoring/doctypes/schema/parse.mjs +1 -1
- package/authoring/doctypes/schema/type.ts +2 -2
- package/authoring/doctypes/template/parse.d.mts +92 -1
- package/authoring/doctypes/template/parse.mjs +33 -1
- package/authoring/doctypes/template/template.doc.mjs +4 -0
- package/authoring/doctypes/template/type.ts +4 -1
- package/authoring/doctypes/types.ts +10 -10
- package/authoring/gap-report/parse.d.mts +9 -9
- package/authoring/gap-report/parse.mjs +6 -6
- package/authoring/gap-report/type.ts +1 -1
- package/authoring/identity/identity.doc.mjs +3 -2
- package/authoring/identity/type.ts +10 -10
- package/authoring/index.d.ts +19 -19
- package/authoring/integration/parse.d.mts +2 -2
- package/authoring/integration/parse.mjs +1 -1
- package/authoring/integration/schema.d.mts +4 -4
- package/authoring/integration/schema.mjs +3 -3
- package/authoring/integration/type.ts +1 -1
- package/clients/cli/commands/integration-authoring.test.mjs +13 -9
- package/foundation/discovery/authoring-self-docs.test.mjs +71 -12
- package/foundation/discovery/docs-discovery.d.mts +4 -0
- package/foundation/discovery/docs-discovery.mjs +16 -2
- package/foundation/discovery/docs-discovery.test.mjs +47 -11
- package/package.json +9 -11
|
@@ -567,3 +567,252 @@ 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
|
+
* astryx --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
|
+
* astryx --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
|
+
* astryx --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
|
+
* astryx --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
|
+
* astryx --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
|
+
* astryx --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
|
+
* astryx --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
|
+
* astryx --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
|
+
* astryx --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
|
+
* astryx --json template [--list] -> template.list
|
|
12
|
+
* astryx --json template <name> -> template.show
|
|
13
|
+
* astryx --json template <name> --skeleton -> template.skeleton
|
|
14
|
+
* astryx --json template <name> [path] -> template.copy
|
|
15
|
+
* astryx --json template --cdn [path] -> template.cdn
|
|
16
|
+
* (unknown template) -> CLIError
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* astryx --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
|
+
* astryx --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
|
+
* astryx --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
|
+
* astryx --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
|
+
* astryx --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,9 +12,10 @@
|
|
|
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
|
-
*
|
|
15
|
+
* carry override problems, every declaration core's generator dropped because
|
|
16
|
+
* its value could not stay one CSS declaration, and any fonts the theme names
|
|
17
|
+
* but does not load (font-warning.mjs) — or `null` when the theme produced no
|
|
18
|
+
* CSS (nothing to build). Errors throw AstryxError (with
|
|
18
19
|
* a stable code). Human progress is emitted through the shared `logger`
|
|
19
20
|
* (silent by default), so the CLI keeps its exact output while a programmatic
|
|
20
21
|
* caller stays quiet.
|
|
@@ -2303,7 +2304,15 @@ async function themeBuildInternal(
|
|
|
2303
2304
|
const scopeSelector = themeScopeStart(themeDef.name);
|
|
2304
2305
|
const scopeTo = THEME_SCOPE_TO;
|
|
2305
2306
|
|
|
2306
|
-
|
|
2307
|
+
// Older cores ignore this optional collector. Current core writes the same
|
|
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
|
+
);
|
|
2307
2316
|
const cssParts = [];
|
|
2308
2317
|
// Prose element defaults always ship — the `<Theme>` runtime
|
|
2309
2318
|
// (generateThemeCSS) always emits them, so the build must too, or the
|
|
@@ -2322,7 +2331,7 @@ async function themeBuildInternal(
|
|
|
2322
2331
|
let adaptationCss;
|
|
2323
2332
|
try {
|
|
2324
2333
|
adaptationCss = _generateAdaptationCSS
|
|
2325
|
-
? _generateAdaptationCSS(resolvedTheme)
|
|
2334
|
+
? _generateAdaptationCSS(resolvedTheme, droppedDeclarations)
|
|
2326
2335
|
: {component: '', prose: ''};
|
|
2327
2336
|
} catch (error) {
|
|
2328
2337
|
const message =
|
|
@@ -2368,11 +2377,16 @@ async function themeBuildInternal(
|
|
|
2368
2377
|
// adaptations on the same resolved leaf.
|
|
2369
2378
|
let onMediaCss = '';
|
|
2370
2379
|
if (_generateOnMediaCSS) {
|
|
2371
|
-
onMediaCss = _generateOnMediaCSS(resolvedTheme);
|
|
2380
|
+
onMediaCss = _generateOnMediaCSS(resolvedTheme, droppedDeclarations);
|
|
2372
2381
|
if (onMediaCss) {
|
|
2373
2382
|
cssParts.push(`@layer astryx-theme {\n${onMediaCss}\n}`);
|
|
2374
2383
|
}
|
|
2375
2384
|
}
|
|
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
|
+
}
|
|
2376
2390
|
if (cssParts.length === 0) {
|
|
2377
2391
|
logger.log('No overrides found — nothing to build.');
|
|
2378
2392
|
return null;
|
|
@@ -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;
|