@astryxdesign/cli 0.7.5-canary.d26cdf3 → 0.7.5-canary.d48bca5
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/CHANGELOG.md +3 -3
- package/api/hook/detail/detail.test.mjs +11 -0
- package/api/swizzle/copy/copy.mjs +1 -1
- 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 +371 -113
- 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/codemods/transforms/v0.1.2/rename-text-color-active-to-accent.mjs +1 -1
- package/assets/codemods/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +1 -1
- package/assets/codemods/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +1 -1
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +1 -1
- package/assets/codemods/transforms/v0.2.0/remove-tablist-orientation.mjs +1 -1
- package/assets/codemods/transforms/v0.2.1/migrate-dialog-position-to-logical.mjs +1 -1
- package/assets/docs/README.md +13 -13
- package/assets/docs/author-a-theme.doc.mjs +5 -1
- package/assets/docs/getting-started.doc.mjs +5 -5
- package/assets/docs/icons.doc.mjs +82 -1
- package/assets/docs/motion.doc.mjs +1 -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/docs/tree/i18n-library-integration.doc.mjs +1 -1
- package/assets/docs/tree/template-styles.doc.mjs +1 -1
- package/assets/docs/tree/tokens-color.doc.mjs +145 -1
- package/assets/docs/tree/tokens-ease.doc.mjs +4 -0
- package/assets/docs/tree/tokens.doc.mjs +1 -1
- 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/templates/pages/dashboard-alert-rail/page.tsx +3 -3
- package/assets/templates/pages/table-comparison/page.tsx +12 -3
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +3 -2
- package/assets/templates/themes/butter/butterTheme.ts +47 -44
- package/assets/templates/themes/chocolate/chocolateTheme.ts +15 -2
- package/assets/templates/themes/gothic/gothicTheme.ts +21 -16
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/matcha/matchaTheme.ts +15 -2
- package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +4 -4
- package/assets/templates/themes/neutral/neutralTheme.ts +24 -119
- package/assets/templates/themes/stone/stoneTheme.ts +46 -21
- package/assets/templates/themes/y2k/y2kTheme.ts +20 -16
- package/assets/theme.template.ts +19 -6
- package/authoring/config/config.doc.mjs +1 -1
- package/clients/cli/commands/build-theme.adaptations.test.mjs +110 -0
- package/clients/cli/commands/build-theme.outside-project.test.mjs +140 -0
- package/clients/cli/commands/swizzle.routing.test.mjs +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -0
- package/foundation/agent-docs/agent-docs.test.mjs +5 -0
- package/foundation/config/project.d.mts +1 -1
- package/foundation/config/project.mjs +1 -1
- package/foundation/debug/redact.test.mjs +1 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +2 -6
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -71,7 +71,7 @@ Thanks to everyone who contributed to this release:
|
|
|
71
71
|
#### New Features
|
|
72
72
|
|
|
73
73
|
- `astryx build` names the right block first far more often. It ranks every block in the catalog by what the request means, read from each block's own name, description, and component, so a block that word matching missed can still come first, with its own score and reason; and the block picker's fixed values are refitted on a larger, more varied set of written example requests, which helps most with requests worded in a product's own terms. A block the request names by its exact name, and a block from an integration, keep their place. The kit never lists more blocks than before, and its fields, page call, start template, and alternatives are unchanged.
|
|
74
|
-
- `astryx search` puts the entry you are after first more often: it orders the matches inside each score band, every result keeps its match score and reason, and a query that is an entry's exact name still answers with that entry first ([#7752](https://github.com/
|
|
74
|
+
- `astryx search` puts the entry you are after first more often: it orders the matches inside each score band, every result keeps its match score and reason, and a query that is an entry's exact name still answers with that entry first ([#7752](https://github.com/meta/astryx/pull/7752)).
|
|
75
75
|
- `astryx doctor integration validate` and `astryx integration check` check the component names a package's docs and blocks give, and list what they find as notes beside validate's issues, each with its fix. Nothing counts a note and `integration check --strict` does not fail on them; they become failing warnings in the next minor release:
|
|
76
76
|
- `doc_name_mismatch` lists a component doc whose `name` is not the name the component is listed under when the module its printed import names (the doc's `import`, the published subpath, or the package root) provably does not export that name, so `astryx component` would print a broken import. The `Fix:` proposes the file name when that module exports it, otherwise the component it exports. A name that module's exports cannot prove or rule out (a re-export from another package, `export =`, a destructured binding, a namespace, an import that resolves to no file, or, when no import can be resolved, a source that only exports a default) is listed as not checked, with the reason, in validate's new `docNames` report.
|
|
77
77
|
- `unknown_block_component` lists a name a template's `exampleFor` or `componentsUsed` gives that neither the package nor Core has (every doc `astryx component` resolves in Core counts) and the template does not import it. Imports the template's local helpers make count too, including through a barrel such as `parts/index.ts`. A name is judged only where the template reaches components solely through named imports and re-exports from Core, React, StyleX, local helpers read in full, or the package's own name (followed through its `exports` like a helper). Anything else is listed as not checked in validate's new `blockComponents` report: an import from another package, which may render other components; any `default` binding other than React's or StyleX's; a namespace import; an alias of or member read off an imported binding; a component held in a variable; `require()`; a dynamic `import()`; a file that does not parse cleanly; a local module this check cannot read; and, without Core installed, any name only Core could resolve.
|
|
@@ -141,7 +141,7 @@ Thanks to everyone who contributed to this release:
|
|
|
141
141
|
- Agents that follow the guide global mode writes to the home folder now know what to do when `astryx` is not found: run the command that installed the CLI for the computer first, with the same package manager and folder, such as `npm i -g @astryxdesign/cli` or `pnpm add -g @astryxdesign/cli`. On machines that keep the home folder but reset system folders on restart, the guide outlived the CLI installed for the computer and told agents to run a command that was gone. Outside a project, when the guide names `astryx` and no `astryx` command is on the search path, apart from a package runner's own copy, `astryx doctor` now says so and names the install step the guide records, or npm's when it records none. The global-mode guide for CI and containers explains how to keep the CLI across restarts. A guide written for a host's own command is unchanged. No JSON shape or exit code changes.
|
|
142
142
|
- The butter, stone, and y2k themes no longer show the secondary hover fill on a disabled `ComplexSelector` trigger, whether the trigger is natively disabled or exposes `aria-disabled="true"`, the focusable form every disabled control now uses. Before, the guard only recognized a natively disabled trigger. The themes `astryx theme eject` copies carry the same guard.
|
|
143
143
|
- Apps that use Core's prebuilt CSS without a StyleX build step now get the default data colors: the prebuilt CSS defines the canonical `dataVars` defaults, so compiled imports and raw CSS references paint correctly.
|
|
144
|
-
- `astryx init` writes the agent docs at the project root, in files the project commits, so Codex, Gemini CLI, Copilot CLI and Claude Code all read the block from the project root or any folder below it ([#7497](https://github.com/
|
|
144
|
+
- `astryx init` writes the agent docs at the project root, in files the project commits, so Codex, Gemini CLI, Copilot CLI and Claude Code all read the block from the project root or any folder below it ([#7497](https://github.com/meta/astryx/pull/7497)). It no longer writes agent docs into a project's subfolder, the home folder, or a settings folder in it such as `~/.gemini`.
|
|
145
145
|
- `AGENTS.md` holds the block, created when missing. Before, a project with only `CLAUDE.md` got the block only there, so Codex and Gemini CLI never saw it.
|
|
146
146
|
- Claude Code skips `AGENTS.md` in a folder that has a `CLAUDE.md` or `.claude/CLAUDE.md`, so the Claude Code file the project already has keeps a full copy: root `CLAUDE.md`, else `.claude/CLAUDE.md`. It keeps the copy even when it imports `AGENTS.md`, because Claude Code does not follow that import in a session started in a subfolder; started at the root, Claude Code then reads two. When both exist, the copy goes in root `CLAUDE.md`, which projects commit even when they ignore `.claude/`, and a block in `.claude/CLAUDE.md` is removed. Init creates no Claude file. `astryx upgrade` refreshes every copy, except in a project at the top of a home settings folder (see the next entry).
|
|
147
147
|
- Gemini CLI reads only `GEMINI.md`: init adds a one-line import, `@./AGENTS.md`, creating `GEMINI.md` when it is missing. It adds none when `GEMINI.md` already imports `AGENTS.md`, inline or on its own line. It adds the import even when the project's `.gemini/settings.json` has Gemini read `AGENTS.md` through `context.fileName`: Gemini loads those settings only when it starts at the project root, so a session started in a subfolder would otherwise get no copy. Started at the root, Gemini then reads two.
|
|
@@ -160,7 +160,7 @@ Thanks to everyone who contributed to this release:
|
|
|
160
160
|
- **Migration:** run `astryx init` from the project's own folder, or add the block to the file by hand. Move a project rooted at the home folder or a settings folder into a folder of its own, or update or remove its block by hand. To remove a block an earlier version wrote into `~/.claude/CLAUDE.md`, run `astryx init --remove-agents` in the home folder.
|
|
161
161
|
- Repeated searches in one process answer faster: `astryx search` reuses its entry index while the catalog is unchanged, and ties that reuse to one list of the fields the index reads, so the index is never reused after any of them changes. Every answer is unchanged.
|
|
162
162
|
- Tools that bundle the CLI into a server function no longer pack their whole project folder into it: one path in `integration check`'s import checks was built in a way file tracers cannot follow. The path and its results are unchanged.
|
|
163
|
-
- `search()` from `@astryxdesign/cli/api` answers faster when one process searches again: it reuses the components, docs, templates and themes it gathered for the same folder and `type` while no file it read, and no folder it listed, has changed since (a linked workspace package included). To see those reads, the first such search in a process wraps `node:fs`'s read functions for that process; outside a search they behave exactly as before. Results are unchanged. Short-lived runs are unaffected: each `astryx search` command gathers once, as before ([#7830](https://github.com/
|
|
163
|
+
- `search()` from `@astryxdesign/cli/api` answers faster when one process searches again: it reuses the components, docs, templates and themes it gathered for the same folder and `type` while no file it read, and no folder it listed, has changed since (a linked workspace package included). To see those reads, the first such search in a process wraps `node:fs`'s read functions for that process; outside a search they behave exactly as before. Results are unchanged. Short-lived runs are unaffected: each `astryx search` command gathers once, as before ([#7830](https://github.com/meta/astryx/pull/7830)).
|
|
164
164
|
- `astryx search` and `astryx build` find a block by its authored display name when that name has two words or more and holds every word of the component the block shows: a query naming it, such as "rich text editor" for an integration's Rich Text Editor block, ranks it first. A display name that labels only the variant, such as "Inside a card", is not read.
|
|
165
165
|
|
|
166
166
|
#### Documentation
|
|
@@ -27,6 +27,17 @@ describe('hook.detail leaf', () => {
|
|
|
27
27
|
expect(Array.isArray(res.data.returns)).toBe(true);
|
|
28
28
|
}, SLOW);
|
|
29
29
|
|
|
30
|
+
it('resolves useCombobox from the Selector entry point with its field props and the requirements it names', async () => {
|
|
31
|
+
const res = await detail('useCombobox', {cwd: REPO});
|
|
32
|
+
expect(res.data.importPath).toBe('@astryxdesign/core/Selector');
|
|
33
|
+
expect(res.data.returns.map(entry => entry.name)).toEqual(
|
|
34
|
+
expect.arrayContaining(['getFieldProps', 'getListboxProps', 'getOptionProps']),
|
|
35
|
+
);
|
|
36
|
+
expect(res.data.usage.accessibility?.map(entry => entry.requirement)).toEqual(
|
|
37
|
+
[1, 2, 3, 4, 5, 6, 7].map(n => `AST-075 FR${n}`),
|
|
38
|
+
);
|
|
39
|
+
}, SLOW);
|
|
40
|
+
|
|
30
41
|
it('throws ERR_UNKNOWN_HOOK with fuzzy suggestions for an unknown hook', async () => {
|
|
31
42
|
let err;
|
|
32
43
|
try {
|
|
@@ -30,7 +30,7 @@ import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
|
30
30
|
import {AstryxError, writeFailed} from '../../error.mjs';
|
|
31
31
|
|
|
32
32
|
/** Default issue tracker for maintainer feedback after swizzling. */
|
|
33
|
-
const DEFAULT_ISSUES_URL = 'https://github.com/
|
|
33
|
+
const DEFAULT_ISSUES_URL = 'https://github.com/meta/astryx/issues/new';
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Rewrite relative imports that point outside the component directory to use
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Contract test for the Tokenizer showcase block.
|
|
5
|
+
* @input The shipped TokenizerShowcase block source.
|
|
6
|
+
* @output Guards the block's search source: typing in the showcase must list
|
|
7
|
+
* matching tags rather than an empty menu.
|
|
8
|
+
* @position CLI template regression coverage; runs in the node test project.
|
|
9
|
+
* The block is the hero example of the Tokenizer docs page. Like the other
|
|
10
|
+
* template contract tests here it reads the block's source instead of
|
|
11
|
+
* importing it, so it needs no built `@astryxdesign/core`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import fs from 'node:fs';
|
|
15
|
+
import path from 'node:path';
|
|
16
|
+
import {fileURLToPath} from 'node:url';
|
|
17
|
+
import {describe, expect, it} from 'vitest';
|
|
18
|
+
|
|
19
|
+
const sourcePath = path.resolve(
|
|
20
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
21
|
+
'../../assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx',
|
|
22
|
+
);
|
|
23
|
+
const source = fs.readFileSync(sourcePath, 'utf8');
|
|
24
|
+
|
|
25
|
+
// Evaluate the block's tag list and search source on their own, with the
|
|
26
|
+
// type annotations removed, so the test exercises the shipped logic.
|
|
27
|
+
function loadSearchSource() {
|
|
28
|
+
const tags = source.match(/const tags[^=]*=\s*(\[[\s\S]*?\n\]);/)?.[1];
|
|
29
|
+
const searchSource = source.match(
|
|
30
|
+
/const source[^=]*=\s*(\{[\s\S]*?\n\});/,
|
|
31
|
+
)?.[1];
|
|
32
|
+
if (tags == null || searchSource == null) {
|
|
33
|
+
throw new Error('TokenizerShowcase no longer declares `tags` and `source`');
|
|
34
|
+
}
|
|
35
|
+
const untyped = searchSource.replace(/\((\w+):\s*string\)/g, '($1)');
|
|
36
|
+
return new Function(`const tags = ${tags}; return ${untyped};`)();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
describe('Tokenizer showcase block', () => {
|
|
40
|
+
it('lists the tags that match a typed query, ignoring case', async () => {
|
|
41
|
+
const {search, bootstrap} = loadSearchSource();
|
|
42
|
+
const labels = async query => (await search(query)).map(tag => tag.label);
|
|
43
|
+
expect(await labels('mar')).toEqual(['Marketing']);
|
|
44
|
+
expect(await labels('A')).toEqual(['Marketing', 'Research', 'Sales']);
|
|
45
|
+
expect((await bootstrap()).length).toBeGreaterThan(0);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -86,6 +86,10 @@ describe('values the root accepts without enrollment are accepted rule-only', ()
|
|
|
86
86
|
// case. It must NOT be an adaptation-specific exception; it is simply
|
|
87
87
|
// whatever root does.
|
|
88
88
|
['an unresolved domain', 'avatar-group', 'size:not-a-real-avatar-size'],
|
|
89
|
+
// `IconVariantMap` is public and augmentable, but `Icon.variant` selects
|
|
90
|
+
// artwork and has no component styling map (component-theming-surface
|
|
91
|
+
// INV14), so a styling key on it never enrolls a value.
|
|
92
|
+
['an artwork-request axis', 'icon', 'variant:filled'],
|
|
89
93
|
])('accepts %s on both surfaces', async (_label, component, key) => {
|
|
90
94
|
const rootReceipt = await buildWithRootValue('root-ok', component, key);
|
|
91
95
|
expect(rootReceipt?.type).toBe('theme.build');
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Built and runtime themes pass an inherited icon entry the same variants.
|
|
5
|
+
* @input Real themeBuild calls on a base theme with a function icon entry and a
|
|
6
|
+
* child that extends it with a wider `iconVariants` list.
|
|
7
|
+
* @output A native ESM load renders `<Icon variant>` under the built child and
|
|
8
|
+
* under the runtime child and compares the variant each entry received.
|
|
9
|
+
* @position `architecture:theme-compilation` INV15 for `spec:AST-087` FR4: an
|
|
10
|
+
* inherited entry keeps its defining theme's list, so a variant only the
|
|
11
|
+
* child lists never reaches it, built or runtime. The node project's global
|
|
12
|
+
* setup supplies the compiled core package.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import {expect, it} from 'vitest';
|
|
16
|
+
import {execFileSync} from 'node:child_process';
|
|
17
|
+
import * as fs from 'node:fs';
|
|
18
|
+
import * as path from 'node:path';
|
|
19
|
+
import {themeBuild} from './build.mjs';
|
|
20
|
+
|
|
21
|
+
it('passes an inherited entry only its defining theme variants in a built child, as at runtime', async () => {
|
|
22
|
+
const tmpDir = fs.mkdtempSync(
|
|
23
|
+
path.resolve(import.meta.dirname, '../../..', '.tmp-icon-entry-variants-'),
|
|
24
|
+
);
|
|
25
|
+
try {
|
|
26
|
+
for (const directory of ['base', 'child', 'unlisted']) {
|
|
27
|
+
fs.mkdirSync(path.join(tmpDir, directory));
|
|
28
|
+
}
|
|
29
|
+
const write = (file, source) =>
|
|
30
|
+
fs.writeFileSync(path.join(tmpDir, file), source);
|
|
31
|
+
|
|
32
|
+
write(
|
|
33
|
+
'base/icons.mjs',
|
|
34
|
+
`import {createElement} from 'react';
|
|
35
|
+
export const icons = {
|
|
36
|
+
info: ({variant}) => createElement('svg', {'data-variant': variant ?? 'normal'}),
|
|
37
|
+
};
|
|
38
|
+
`,
|
|
39
|
+
);
|
|
40
|
+
write(
|
|
41
|
+
'base/source.mjs',
|
|
42
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
43
|
+
import {icons} from './icons.mjs';
|
|
44
|
+
export const baseTheme = defineTheme({
|
|
45
|
+
name: 'entry-variants-base', tokens: {}, iconVariants: ['outline'], icons,
|
|
46
|
+
});
|
|
47
|
+
`,
|
|
48
|
+
);
|
|
49
|
+
write(
|
|
50
|
+
'child/source.mjs',
|
|
51
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
52
|
+
import {baseTheme} from '../base/source.mjs';
|
|
53
|
+
export default defineTheme({
|
|
54
|
+
name: 'entry-variants-child', extends: baseTheme, tokens: {},
|
|
55
|
+
iconVariants: ['outline', 'filled'],
|
|
56
|
+
});
|
|
57
|
+
`,
|
|
58
|
+
);
|
|
59
|
+
// A defining theme with no list: the built module writes it as `[]`.
|
|
60
|
+
write(
|
|
61
|
+
'unlisted/base.mjs',
|
|
62
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
63
|
+
import {icons} from '../base/icons.mjs';
|
|
64
|
+
export const unlistedBase = defineTheme({
|
|
65
|
+
name: 'entry-variants-unlisted-base', tokens: {}, icons,
|
|
66
|
+
});
|
|
67
|
+
`,
|
|
68
|
+
);
|
|
69
|
+
write(
|
|
70
|
+
'unlisted/source.mjs',
|
|
71
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
72
|
+
import {unlistedBase} from './base.mjs';
|
|
73
|
+
export default defineTheme({
|
|
74
|
+
name: 'entry-variants-unlisted-child', extends: unlistedBase, tokens: {},
|
|
75
|
+
iconVariants: ['filled'],
|
|
76
|
+
});
|
|
77
|
+
`,
|
|
78
|
+
);
|
|
79
|
+
for (const source of ['child/source.mjs', 'unlisted/source.mjs']) {
|
|
80
|
+
const receipt = await themeBuild(source, {}, {cwd: tmpDir});
|
|
81
|
+
expect(receipt?.type).toBe('theme.build');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const output = execFileSync(
|
|
85
|
+
process.execPath,
|
|
86
|
+
[
|
|
87
|
+
'--input-type=module',
|
|
88
|
+
'--eval',
|
|
89
|
+
`import {createElement} from 'react';
|
|
90
|
+
import {renderToStaticMarkup} from 'react-dom/server';
|
|
91
|
+
import {Icon} from '@astryxdesign/core/Icon';
|
|
92
|
+
import {Theme} from '@astryxdesign/core/theme';
|
|
93
|
+
import {entryVariantsChildTheme as built} from './child/entry-variants-child.js';
|
|
94
|
+
import runtime from './child/source.mjs';
|
|
95
|
+
import {entryVariantsUnlistedChildTheme as unlistedBuilt} from './unlisted/entry-variants-unlisted-child.js';
|
|
96
|
+
import unlistedRuntime from './unlisted/source.mjs';
|
|
97
|
+
const received = (theme, variant) => {
|
|
98
|
+
const html = renderToStaticMarkup(
|
|
99
|
+
createElement(Theme, {theme}, createElement(Icon, {icon: 'info', variant})),
|
|
100
|
+
);
|
|
101
|
+
return /data-variant="([^"]+)"/.exec(html)?.[1] ?? null;
|
|
102
|
+
};
|
|
103
|
+
const result = {};
|
|
104
|
+
for (const [label, theme] of [
|
|
105
|
+
['built', built],
|
|
106
|
+
['runtime', runtime],
|
|
107
|
+
['unlistedBuilt', unlistedBuilt],
|
|
108
|
+
['unlistedRuntime', unlistedRuntime],
|
|
109
|
+
]) {
|
|
110
|
+
result[label] = {
|
|
111
|
+
filled: received(theme, 'filled'),
|
|
112
|
+
outline: received(theme, 'outline'),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
process.stdout.write(JSON.stringify(result));`,
|
|
116
|
+
],
|
|
117
|
+
{cwd: tmpDir, stdio: ['ignore', 'pipe', 'pipe'], timeout: 20000},
|
|
118
|
+
);
|
|
119
|
+
const result = JSON.parse(String(output));
|
|
120
|
+
|
|
121
|
+
// The base never listed 'filled', so its entry draws normal artwork for
|
|
122
|
+
// it in the child; 'outline' is listed by both and reaches the entry.
|
|
123
|
+
expect(result.runtime).toEqual({filled: 'normal', outline: 'outline'});
|
|
124
|
+
expect(result.built).toEqual(result.runtime);
|
|
125
|
+
// A base with no list passes its entry no variant, even one its child lists.
|
|
126
|
+
expect(result.unlistedRuntime).toEqual({
|
|
127
|
+
filled: 'normal',
|
|
128
|
+
outline: 'normal',
|
|
129
|
+
});
|
|
130
|
+
expect(result.unlistedBuilt).toEqual(result.unlistedRuntime);
|
|
131
|
+
} finally {
|
|
132
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
133
|
+
}
|
|
134
|
+
});
|