@astryxdesign/cli 0.7.5-canary.a17ee0a → 0.7.5-canary.a264f63
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/template/tokenizer-showcase.test.mjs +47 -0
- package/api/theme/build/build.adaptation-enrollment.test.mjs +4 -0
- package/api/theme/build/build.icon-entry-variants.test.mjs +134 -0
- package/api/theme/build/build.icon-function-entries.test.mjs +499 -0
- package/api/theme/build/build.icon-variants.test.mjs +105 -0
- package/api/theme/build/build.mjs +362 -109
- package/api/theme/build/build.project-core.test.mjs +63 -8
- package/api/theme/build/build.test.mjs +77 -0
- package/api/theme/build/icon-imports.d.mts +12 -2
- package/api/theme/build/icon-imports.mjs +36 -11
- package/assets/codemods/transforms/next/__tests__/migrate-codeblock-tokenizer-to-language.test.mjs +130 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-codeblock-tokenizer-to-language.mjs +315 -0
- package/assets/docs/author-a-theme.doc.mjs +5 -1
- package/assets/docs/icons.doc.mjs +82 -1
- package/assets/docs/theme.doc.dense.mjs +8 -0
- package/assets/docs/theme.doc.mjs +16 -0
- package/assets/docs/theme.doc.zh.mjs +11 -0
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +6 -4
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.tsx +61 -55
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.doc.mjs +6 -4
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.tsx +68 -37
- package/assets/templates/blocks/components/Thumbnail/ThumbnailDisabled.doc.mjs +1 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +13 -6
- package/assets/theme.template.ts +18 -5
- package/clients/cli/commands/build-theme.outside-project.test.mjs +140 -0
- package/foundation/agent-docs/agent-docs.mjs +1 -0
- package/foundation/agent-docs/agent-docs.test.mjs +5 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +2 -6
- package/package.json +9 -9
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file A built theme keeps its `iconVariants` list.
|
|
5
|
+
*
|
|
6
|
+
* `architecture:theme-compilation` (System model item 7): a built theme carries
|
|
7
|
+
* its `iconVariants` list in its JavaScript, so the built theme, and a theme
|
|
8
|
+
* that `extends` it, read the same list as the runtime theme
|
|
9
|
+
* (`spec:AST-087` FR2, FR18).
|
|
10
|
+
*
|
|
11
|
+
* `themeBuild` compiles via @astryxdesign/core, so it needs a built core — the
|
|
12
|
+
* `node` project's globalSetup builds it once before workers fork.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
|
16
|
+
import * as fs from 'node:fs';
|
|
17
|
+
import * as os from 'node:os';
|
|
18
|
+
import * as path from 'node:path';
|
|
19
|
+
import {pathToFileURL} from 'node:url';
|
|
20
|
+
import {defineTheme} from '@astryxdesign/core/theme';
|
|
21
|
+
import {themeBuild} from './build.mjs';
|
|
22
|
+
|
|
23
|
+
vi.setConfig({testTimeout: 30000});
|
|
24
|
+
|
|
25
|
+
let tmpDir;
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-icon-variants-'));
|
|
28
|
+
});
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Build a raw theme source and import the generated module's theme.
|
|
35
|
+
* @param {Record<string, unknown>} source
|
|
36
|
+
*/
|
|
37
|
+
async function buildAndImport(source) {
|
|
38
|
+
const name = String(source.name);
|
|
39
|
+
fs.writeFileSync(
|
|
40
|
+
path.join(tmpDir, `${name}.mjs`),
|
|
41
|
+
`export default ${JSON.stringify({tokens: {}, ...source})};\n`,
|
|
42
|
+
);
|
|
43
|
+
await themeBuild(`${name}.mjs`, {}, {cwd: tmpDir});
|
|
44
|
+
const mod = await import(pathToFileURL(path.join(tmpDir, `${name}.js`)).href);
|
|
45
|
+
const [theme] = Object.values(mod);
|
|
46
|
+
return /** @type {any} */ (theme);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
describe('theme build keeps the iconVariants list', () => {
|
|
50
|
+
it('writes the list a theme sets, as the runtime theme reads it', async () => {
|
|
51
|
+
const source = {name: 'listed-icons', iconVariants: ['outline', 'filled']};
|
|
52
|
+
const built = await buildAndImport(source);
|
|
53
|
+
|
|
54
|
+
expect(built.__built).toBe(true);
|
|
55
|
+
expect(built.iconVariants).toEqual(['outline', 'filled']);
|
|
56
|
+
expect(built.iconVariants).toEqual(defineTheme(source).iconVariants);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('lets a child of the built theme inherit or replace the list, as at runtime', async () => {
|
|
60
|
+
const source = {name: 'base-icons', iconVariants: ['outline', 'filled']};
|
|
61
|
+
const built = await buildAndImport(source);
|
|
62
|
+
const runtime = defineTheme(source);
|
|
63
|
+
|
|
64
|
+
const inherits = defineTheme({name: 'inherits', extends: built});
|
|
65
|
+
const replaces = defineTheme({
|
|
66
|
+
name: 'replaces',
|
|
67
|
+
extends: built,
|
|
68
|
+
iconVariants: ['bold'],
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
expect(inherits.iconVariants).toEqual(['outline', 'filled']);
|
|
72
|
+
expect(replaces.iconVariants).toEqual(['bold']);
|
|
73
|
+
expect(inherits.iconVariants).toEqual(
|
|
74
|
+
defineTheme({name: 'inherits-runtime', extends: runtime}).iconVariants,
|
|
75
|
+
);
|
|
76
|
+
expect(replaces.iconVariants).toEqual(
|
|
77
|
+
defineTheme({
|
|
78
|
+
name: 'replaces-runtime',
|
|
79
|
+
extends: runtime,
|
|
80
|
+
iconVariants: ['bold'],
|
|
81
|
+
}).iconVariants,
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('keeps an explicit empty list, which replaces an inherited one', async () => {
|
|
86
|
+
const built = await buildAndImport({
|
|
87
|
+
name: 'emptied-icons',
|
|
88
|
+
iconVariants: [],
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
expect(built.iconVariants).toEqual([]);
|
|
92
|
+
expect(
|
|
93
|
+
defineTheme({name: 'emptied-child', extends: built}).iconVariants,
|
|
94
|
+
).toEqual([]);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('writes no list for a theme without one', async () => {
|
|
98
|
+
const built = await buildAndImport({name: 'unlisted-icons'});
|
|
99
|
+
|
|
100
|
+
expect('iconVariants' in built).toBe(false);
|
|
101
|
+
expect(
|
|
102
|
+
defineTheme({name: 'unlisted-child', extends: built}).iconVariants,
|
|
103
|
+
).toBeUndefined();
|
|
104
|
+
});
|
|
105
|
+
});
|