@astryxdesign/cli 0.7.15 → 0.7.16-canary.g3aa244b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/api/build/_adapter.d.mts +1 -0
- package/api/build/blocks/blocks.d.mts +1 -0
- package/api/build/blocks/blocks.mjs +18 -1
- package/api/component/_adapter.d.mts +1 -1
- package/api/component/_adapter.mjs +28 -1
- package/api/doctor/_adapter.d.mts +35 -0
- package/api/doctor/_adapter.mjs +69 -0
- package/api/doctor/built-checks.mjs +1 -1
- package/api/doctor/doctor.d.mts +18 -0
- package/api/doctor/doctor.doc.mjs +1 -1
- package/api/doctor/doctor.mjs +104 -4
- package/api/doctor/theme-checks.mjs +6 -10
- package/api/integration/add-contribution.mjs +3 -3
- package/api/integration/pack-check.mjs +14 -8
- package/api/integration/validate-integration.mjs +1 -1
- package/api/search/_adapter.mjs +15 -16
- package/api/search/_entries.d.mts +2 -1
- package/api/search/_entries.mjs +28 -1
- package/api/swizzle/_moduleGraph.mjs +1 -1
- package/api/theme/_adapter.d.mts +5 -2
- package/api/theme/_adapter.mjs +43 -12
- package/api/theme/_fork.mjs +1 -1
- package/api/theme/build/build.d.mts +116 -32
- package/api/theme/build/build.mjs +449 -102
- package/api/theme/eject/eject.mjs +22 -1
- package/api/theme/template/template.d.mts +19 -0
- package/api/theme/template/template.mjs +102 -25
- package/api/theme/theme.type.d.mts +5 -1
- package/api/theme/theme.type.mjs +2 -1
- package/api/theme/themeBuild.doc.mjs +3 -3
- package/api/theme/themeEject.doc.mjs +1 -1
- package/api/theme/themeTemplate.doc.mjs +9 -3
- package/api/theme-edit/_adapter.d.mts +32 -2
- package/api/theme-edit/_adapter.mjs +264 -40
- package/api/theme-edit/_check.d.mts +93 -4
- package/api/theme-edit/_check.mjs +1727 -223
- package/api/theme-edit/_color.d.mts +2 -8
- package/api/theme-edit/_color.mjs +292 -219
- package/api/theme-edit/_compiler.d.mts +1 -0
- package/api/theme-edit/_compiler.mjs +20 -1
- package/api/theme-edit/_context.d.mts +31 -1
- package/api/theme-edit/_context.mjs +445 -41
- package/api/theme-edit/_css.d.mts +60 -1
- package/api/theme-edit/_css.mjs +404 -28
- package/api/theme-edit/_edit.d.mts +25 -0
- package/api/theme-edit/_edit.mjs +1532 -149
- package/api/theme-edit/_how-commands.d.mts +11 -26
- package/api/theme-edit/_how-commands.mjs +30 -2
- package/api/theme-edit/_how-question.d.mts +7 -0
- package/api/theme-edit/_how-question.mjs +1304 -176
- package/api/theme-edit/_how.mjs +144 -30
- package/api/theme-edit/_overview.mjs +2 -0
- package/api/theme-edit/_palette.d.mts +38 -0
- package/api/theme-edit/_palette.mjs +305 -71
- package/api/theme-edit/_parts.d.mts +33 -0
- package/api/theme-edit/_parts.mjs +138 -9
- package/api/theme-edit/_png.d.mts +18 -0
- package/api/theme-edit/_png.mjs +95 -14
- package/api/theme-edit/_preview-app.d.mts +36 -1
- package/api/theme-edit/_preview-app.mjs +1415 -96
- package/api/theme-edit/_preview.d.mts +64 -3
- package/api/theme-edit/_preview.mjs +514 -31
- package/api/theme-edit/_project.d.mts +11 -0
- package/api/theme-edit/_project.mjs +46 -12
- package/api/theme-edit/_settings.d.mts +278 -5
- package/api/theme-edit/_settings.mjs +2741 -195
- package/api/theme-edit/_tables.d.mts +24 -0
- package/api/theme-edit/_tables.mjs +211 -149
- package/api/theme-edit/_vet.d.mts +42 -0
- package/api/theme-edit/_vet.mjs +144 -0
- package/api/theme-edit/theme-edit.type.d.mts +20 -2
- package/api/theme-edit/theme-edit.type.mjs +6 -2
- package/api/theme-edit/themeEditNew.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
- package/api/theme-edit/themeEditShow.doc.mjs +11 -3
- package/api/upgrade/registry/registry.mjs +6 -1
- package/assets/codemods/parse.mjs +2 -2
- package/assets/docs/tree/single-component.doc.mjs +11 -2
- package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
- package/assets/docs.generated.json +2 -2
- package/assets/preview-app/next.config.mjs +7 -1
- package/assets/preview-app/package.json +1 -0
- package/assets/preview-app/src/app/globals.css +1 -0
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
- package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/dashboard/page.tsx +1 -1
- package/authoring/doctypes/_schema.d.mts +52 -5
- package/authoring/doctypes/_schema.mjs +62 -7
- package/authoring/doctypes/base/type.ts +10 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/function/function.doc.mjs +6 -0
- package/authoring/doctypes/function/type.ts +3 -0
- package/authoring/doctypes/legacy.mjs +5 -1
- package/authoring/index.d.ts +1 -0
- package/authoring/shadcn/source-variants.d.mts +1 -1
- package/authoring/shadcn/source-variants.mjs +32 -10
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/doctor.doc.mjs +2 -2
- package/clients/cli/commands/experimental/theme.mjs +239 -45
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/commands/theme-eject.doc.mjs +1 -1
- package/clients/cli/commands/theme-template.doc.mjs +3 -1
- package/clients/cli/commands/theme.mjs +190 -46
- package/clients/cli/formatters/index.mjs +7 -4
- package/clients/cli/lib/cli-error.mjs +9 -3
- package/clients/cli/lib/component-format.mjs +27 -9
- package/clients/cli/lib/json-shim.mjs +72 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +49 -0
- package/foundation/agent-docs/agent-docs-target.d.mts +2 -6
- package/foundation/agent-docs/agent-docs-target.mjs +9 -17
- package/foundation/agent-docs/agent-docs.mjs +3 -2
- package/foundation/config/config-writer.mjs +2 -2
- package/foundation/config/project.mjs +60 -14
- package/foundation/discovery/component-discovery.mjs +5 -17
- package/foundation/discovery/icon-set-writer.mjs +1 -1
- package/foundation/discovery/module-exports.mjs +1 -15
- package/foundation/discovery/template-adapter.mjs +44 -19
- package/foundation/discovery/template-source-tree.mjs +3 -16
- package/foundation/discovery/theme-discovery.d.mts +5 -1
- package/foundation/discovery/theme-discovery.mjs +61 -43
- package/foundation/fs/exact-codec.d.mts +35 -0
- package/foundation/fs/exact-codec.mjs +148 -0
- package/foundation/fs/gather-cache.d.mts +15 -5
- package/foundation/fs/gather-cache.mjs +129 -31
- package/foundation/fs/paths.d.mts +39 -0
- package/foundation/fs/paths.mjs +44 -11
- package/foundation/fs/read-record.mjs +11 -1
- package/foundation/integrations/contribution-fixes.mjs +1 -16
- package/foundation/integrations/may-have-integrations.mjs +3 -2
- package/foundation/integrations/public-imports.mjs +1 -1
- package/foundation/render/embedded-imports.mjs +1 -1
- package/foundation/render/host-exit.d.mts +8 -0
- package/foundation/render/host-exit.mjs +11 -0
- package/foundation/render/page-host.mjs +56 -10
- package/foundation/render/page-worker.mjs +14 -0
- package/foundation/render/render-page.mjs +37 -2
- package/foundation/response/error-codes.d.mts +2 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +5 -0
- package/foundation/response/error-codes.mjs +3 -0
- package/foundation/response/json.d.mts +15 -0
- package/foundation/response/json.mjs +52 -1
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/runtime/lazy-dependencies.d.mts +14 -0
- package/foundation/runtime/lazy-dependencies.mjs +82 -0
- package/foundation/xle/browser.d.mts +2 -2
- package/package.json +7 -6
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The one place every `set` command a refusal suggests is checked
|
|
5
|
+
* before it is shown: each runs through the same check `set` uses (in
|
|
6
|
+
* memory, nothing written, nothing built), and one `set` would refuse is
|
|
7
|
+
* dropped, so a "do this instead" never leads to a second refusal.
|
|
8
|
+
*
|
|
9
|
+
* @position api/theme-edit — imported by _edit.mjs
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {AstryxError} from '../error.mjs';
|
|
13
|
+
import {checkSetting} from './_check.mjs';
|
|
14
|
+
import {P} from './_tables.mjs';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Split a printed command into its arguments, as a POSIX shell reads them:
|
|
18
|
+
* single quotes (with `'\''` for a quote inside), double quotes and
|
|
19
|
+
* backslashes. `null` when the quotes do not close.
|
|
20
|
+
* @param {string} line
|
|
21
|
+
* @returns {string[] | null}
|
|
22
|
+
*/
|
|
23
|
+
export function splitCommand(line) {
|
|
24
|
+
/** @type {string[]} */
|
|
25
|
+
const out = [];
|
|
26
|
+
let cur = '';
|
|
27
|
+
let has = false;
|
|
28
|
+
for (let i = 0; i < line.length; i += 1) {
|
|
29
|
+
const c = line[i];
|
|
30
|
+
if (c === "'") {
|
|
31
|
+
const end = line.indexOf("'", i + 1);
|
|
32
|
+
if (end < 0) return null;
|
|
33
|
+
cur += line.slice(i + 1, end);
|
|
34
|
+
has = true;
|
|
35
|
+
i = end;
|
|
36
|
+
} else if (c === '"') {
|
|
37
|
+
let j = i + 1;
|
|
38
|
+
for (; j < line.length && line[j] !== '"'; j += 1) {
|
|
39
|
+
if (line[j] === '\\' && j + 1 < line.length) j += 1;
|
|
40
|
+
cur += line[j];
|
|
41
|
+
}
|
|
42
|
+
if (j >= line.length) return null;
|
|
43
|
+
has = true;
|
|
44
|
+
i = j;
|
|
45
|
+
} else if (c === '\\' && i + 1 < line.length) {
|
|
46
|
+
cur += line[i + 1];
|
|
47
|
+
has = true;
|
|
48
|
+
i += 1;
|
|
49
|
+
} else if (/\s/.test(c)) {
|
|
50
|
+
if (has) out.push(cur);
|
|
51
|
+
cur = '';
|
|
52
|
+
has = false;
|
|
53
|
+
} else {
|
|
54
|
+
cur += c;
|
|
55
|
+
has = true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (has) out.push(cur);
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const VALUE_FLAGS = new Set(['on', 'when', 'state', 'mode']);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Read a suggested `set <slug> <thing> <value> [flags]` line; `null` when it
|
|
66
|
+
* is not one this check can read (another command or theme, a placeholder,
|
|
67
|
+
* an unknown flag): such a line is kept as it is.
|
|
68
|
+
* @param {string} name
|
|
69
|
+
* @param {string} slug
|
|
70
|
+
*/
|
|
71
|
+
export function readSetLine(name, slug) {
|
|
72
|
+
const prefix = `${P} set ${slug} `;
|
|
73
|
+
if (!name.startsWith(prefix)) return null;
|
|
74
|
+
const rest = name.slice(prefix.length);
|
|
75
|
+
// A placeholder (`<a color>`, `…`) is a pattern, not a command to run.
|
|
76
|
+
if (/<[^>]*>|…/.test(rest)) return null;
|
|
77
|
+
const args = splitCommand(rest);
|
|
78
|
+
if (!args || !args.length) return null;
|
|
79
|
+
/** @type {string[]} */
|
|
80
|
+
const pos = [];
|
|
81
|
+
/** @type {{on?: string, when?: string, state?: string, mode?: string, only?: boolean}} */
|
|
82
|
+
const flags = {};
|
|
83
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
84
|
+
const a = args[i];
|
|
85
|
+
const m = /^--([a-z]+)(?:=(.*))?$/.exec(a);
|
|
86
|
+
// A token (`--color-accent`) is the thing, not a flag.
|
|
87
|
+
if (m && (VALUE_FLAGS.has(m[1]) || m[1] === 'only') && pos.length) {
|
|
88
|
+
if (m[1] === 'only') {
|
|
89
|
+
flags.only = true;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const v = m[2] ?? args[(i += 1)];
|
|
93
|
+
if (v == null) return null;
|
|
94
|
+
/** @type {any} */ (flags)[m[1]] = v;
|
|
95
|
+
} else if (m && pos.length) {
|
|
96
|
+
// Some other flag (`--png`): not part of the setting.
|
|
97
|
+
if (m[1] === 'png') continue;
|
|
98
|
+
return null;
|
|
99
|
+
} else pos.push(a);
|
|
100
|
+
}
|
|
101
|
+
if (pos.length > 2 || !pos.length) return null;
|
|
102
|
+
return {thing: pos[0], value: pos[1] ?? '', flags};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Drop each `set` suggestion of a refusal that `set` itself would refuse,
|
|
107
|
+
* checked against the theme as it is now (a copy: nothing is changed). Any
|
|
108
|
+
* other suggestion is kept. When every suggestion goes, the refusal points
|
|
109
|
+
* at `set --help`.
|
|
110
|
+
* @template T
|
|
111
|
+
* @param {T} e the error thrown
|
|
112
|
+
* @param {import('./_settings.mjs').Ctx | null | undefined} ctx
|
|
113
|
+
* @param {string} slug
|
|
114
|
+
* @param {import('./_settings.mjs').ThemeData | null | undefined} data
|
|
115
|
+
* @returns {T}
|
|
116
|
+
*/
|
|
117
|
+
export function vetSuggestions(e, ctx, slug, data) {
|
|
118
|
+
if (!(e instanceof AstryxError) || !ctx || !data) return e;
|
|
119
|
+
const list = e.suggestions ?? [];
|
|
120
|
+
if (!list.length) return e;
|
|
121
|
+
const kept = list.filter(s => {
|
|
122
|
+
const line = readSetLine(s.name, slug);
|
|
123
|
+
if (!line) return true;
|
|
124
|
+
try {
|
|
125
|
+
checkSetting(
|
|
126
|
+
ctx,
|
|
127
|
+
slug,
|
|
128
|
+
structuredClone(data),
|
|
129
|
+
line.thing,
|
|
130
|
+
line.value,
|
|
131
|
+
line.flags,
|
|
132
|
+
false,
|
|
133
|
+
);
|
|
134
|
+
return true;
|
|
135
|
+
} catch {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
if (kept.length === list.length) return e;
|
|
140
|
+
e.suggestions = kept.length
|
|
141
|
+
? kept
|
|
142
|
+
: [{name: `${P} set --help`, reason: 'see what set takes'}];
|
|
143
|
+
return e;
|
|
144
|
+
}
|
|
@@ -122,6 +122,12 @@ export type ThemeEditPreviewFields = {
|
|
|
122
122
|
* - Files of the in-app theme preview that were not written again and still show the theme as it was: changed by hand, or a preview folder where a stopped preview change waits for the next preview command.
|
|
123
123
|
*/
|
|
124
124
|
previewStale?: string[] | undefined;
|
|
125
|
+
/**
|
|
126
|
+
* - Only the first time the theme's app copy is written (src/themes/<theme>/, a standard local theme `astryx theme add <theme>` takes, written again after every build): the files written.
|
|
127
|
+
*/
|
|
128
|
+
appCopy?: {
|
|
129
|
+
wrote: string[];
|
|
130
|
+
} | undefined;
|
|
125
131
|
};
|
|
126
132
|
/**
|
|
127
133
|
* `astryx --json experimental theme editor new <theme>`.
|
|
@@ -129,7 +135,7 @@ export type ThemeEditPreviewFields = {
|
|
|
129
135
|
export type ThemeEditNewResponse = {
|
|
130
136
|
type: "themeEdit.new";
|
|
131
137
|
/**
|
|
132
|
-
* - `settings`: the dial settings it started with; `notes`: font loading.
|
|
138
|
+
* - `settings`: the dial settings it started with; `notes`: font loading; `wiring`: the steps that put the theme into this app (`theme add <theme>` for its app copy in src/themes/<theme>/, else the root file, its imports and the Theme around the app; what builds it).
|
|
133
139
|
*/
|
|
134
140
|
data: {
|
|
135
141
|
theme: string;
|
|
@@ -143,6 +149,7 @@ export type ThemeEditNewResponse = {
|
|
|
143
149
|
settings: string[];
|
|
144
150
|
notes: string[];
|
|
145
151
|
problems: string[];
|
|
152
|
+
wiring: string[];
|
|
146
153
|
} & ThemeEditPreviewFields;
|
|
147
154
|
};
|
|
148
155
|
/**
|
|
@@ -234,6 +241,12 @@ export type ThemeEditChangeData = {
|
|
|
234
241
|
* - Set when sheet.html shows the theme as it was before this change: see ThemeEditPreviewFields.
|
|
235
242
|
*/
|
|
236
243
|
sheetStale?: string | undefined;
|
|
244
|
+
/**
|
|
245
|
+
* - Only the first time the theme's app copy is written: see ThemeEditPreviewFields.
|
|
246
|
+
*/
|
|
247
|
+
appCopy?: {
|
|
248
|
+
wrote: string[];
|
|
249
|
+
} | undefined;
|
|
237
250
|
};
|
|
238
251
|
export type ThemeEditShowOptions = {
|
|
239
252
|
/**
|
|
@@ -281,6 +294,10 @@ export type ThemeEditShowResponse = {
|
|
|
281
294
|
module: string;
|
|
282
295
|
receipt: string;
|
|
283
296
|
} | null;
|
|
297
|
+
appCopy?: {
|
|
298
|
+
wrote: string[];
|
|
299
|
+
} | undefined;
|
|
300
|
+
wiring: string[];
|
|
284
301
|
};
|
|
285
302
|
};
|
|
286
303
|
/**
|
|
@@ -441,7 +458,7 @@ export type ThemeEditPreviewListOptions = {
|
|
|
441
458
|
export type ThemeEditPreviewListResponse = {
|
|
442
459
|
type: "themeEdit.previewList";
|
|
443
460
|
/**
|
|
444
|
-
* - `themeMissing`: the theme the preview wears is gone, so its route does not build; `notes`: what else to know, such as the command that
|
|
461
|
+
* - `themeMissing`: the theme the preview wears is gone, so its route does not build; a page's `missing`: its file is gone; `notes`: what else to know, such as the command that fixes it.
|
|
445
462
|
*/
|
|
446
463
|
data: {
|
|
447
464
|
folder: string | null;
|
|
@@ -450,6 +467,7 @@ export type ThemeEditPreviewListResponse = {
|
|
|
450
467
|
pages: Array<{
|
|
451
468
|
id: string;
|
|
452
469
|
label: string;
|
|
470
|
+
missing?: boolean;
|
|
453
471
|
}>;
|
|
454
472
|
notes: string[];
|
|
455
473
|
};
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
* @property {{code: string, cause: string} | null} notChecked - Set when the change is saved but the components could not be rendered, so it was not checked and has no preview: the cause, such as two copies of React.
|
|
54
54
|
* @property {string} [sheetStale] - Set when sheet.html (the sheet of every component, made by `show`) shows the theme as it was before this change: it says so at its top until `show` makes it again.
|
|
55
55
|
* @property {string[]} [previewStale] - Files of the in-app theme preview that were not written again and still show the theme as it was: changed by hand, or a preview folder where a stopped preview change waits for the next preview command.
|
|
56
|
+
* @property {{wrote: string[]}} [appCopy] - Only the first time the theme's app copy is written (src/themes/<theme>/, a standard local theme `astryx theme add <theme>` takes, written again after every build): the files written.
|
|
56
57
|
*/
|
|
57
58
|
|
|
58
59
|
/**
|
|
@@ -60,7 +61,7 @@
|
|
|
60
61
|
* @experimental May change or be removed in a patch release.
|
|
61
62
|
* @typedef {object} ThemeEditNewResponse
|
|
62
63
|
* @property {'themeEdit.new'} type
|
|
63
|
-
* @property {{theme: string, like: string | null, files: {settings: string, source: string, css: string, module: string}, settings: string[], notes: string[], problems: string[]} & ThemeEditPreviewFields} data - `settings`: the dial settings it started with; `notes`: font loading.
|
|
64
|
+
* @property {{theme: string, like: string | null, files: {settings: string, source: string, css: string, module: string}, settings: string[], notes: string[], problems: string[], wiring: string[]} & ThemeEditPreviewFields} data - `settings`: the dial settings it started with; `notes`: font loading; `wiring`: the steps that put the theme into this app (`theme add <theme>` for its app copy in src/themes/<theme>/, else the root file, its imports and the Theme around the app; what builds it).
|
|
64
65
|
*/
|
|
65
66
|
|
|
66
67
|
/**
|
|
@@ -97,6 +98,7 @@
|
|
|
97
98
|
* @property {{code: string, cause: string} | null} notChecked - Saved but not checked: see ThemeEditPreviewFields.
|
|
98
99
|
* @property {string[]} [previewStale] - In-app preview files changed by hand: see ThemeEditPreviewFields.
|
|
99
100
|
* @property {string} [sheetStale] - Set when sheet.html shows the theme as it was before this change: see ThemeEditPreviewFields.
|
|
101
|
+
* @property {{wrote: string[]}} [appCopy] - Only the first time the theme's app copy is written: see ThemeEditPreviewFields.
|
|
100
102
|
*/
|
|
101
103
|
|
|
102
104
|
/**
|
|
@@ -132,6 +134,8 @@
|
|
|
132
134
|
* @property {string[]} data.pictures
|
|
133
135
|
* @property {string | null} data.pictureProblem
|
|
134
136
|
* @property {{config: string, module: string, receipt: string} | null} data.colorFiles - The generated color files: the input (in the shape `theme palette generate` reads), the module the theme imports, and the receipt; null when the theme sets no color.
|
|
137
|
+
* @property {{wrote: string[]}} [data.appCopy] - Only the first time the theme's app copy is written: the files written in src/themes/<theme>/.
|
|
138
|
+
* @property {string[]} data.wiring - The steps that put the theme into this app: the root file, its imports, the Theme around the app, and what builds it (`theme add <theme>`, for the app copy the editor writes in src/themes/<theme>/; the imports by hand when a folder of yours is there).
|
|
135
139
|
*/
|
|
136
140
|
|
|
137
141
|
/**
|
|
@@ -227,7 +231,7 @@
|
|
|
227
231
|
* @experimental May change or be removed in a patch release.
|
|
228
232
|
* @typedef {object} ThemeEditPreviewListResponse
|
|
229
233
|
* @property {'themeEdit.previewList'} type
|
|
230
|
-
* @property {{folder: string | null, theme: string | null, themeMissing: boolean, pages: Array<{id: string, label: string}>, notes: string[]}} data - `themeMissing`: the theme the preview wears is gone, so its route does not build; `notes`: what else to know, such as the command that
|
|
234
|
+
* @property {{folder: string | null, theme: string | null, themeMissing: boolean, pages: Array<{id: string, label: string, missing?: boolean}>, notes: string[]}} data - `themeMissing`: the theme the preview wears is gone, so its route does not build; a page's `missing`: its file is gone; `notes`: what else to know, such as the command that fixes it.
|
|
231
235
|
*/
|
|
232
236
|
|
|
233
237
|
/**
|
|
@@ -12,7 +12,7 @@ export const doc = {
|
|
|
12
12
|
displayName: 'themeEditNew()',
|
|
13
13
|
summary: 'Start a theme in themes/<theme>/, optionally on a built-in theme.',
|
|
14
14
|
description:
|
|
15
|
-
'Makes themes/<theme>/ with <theme>.settings.json (the settings this command owns), the generated <theme>.settings.ts, <theme>.theme.ts (which extends it and is yours), and the built <theme>.css and <theme>.js (
|
|
15
|
+
'Makes themes/<theme>/ with <theme>.settings.json (the settings this command owns), the generated <theme>.settings.ts, <theme>.theme.ts (which extends it and is yours), and the built <theme>.css and <theme>.js (build them again with `astryx experimental theme compile themes/<theme>/<theme>.theme.ts`, which checks the editor settings first), then writes preview.html, the sample app page with the theme. --like builds on a built-in theme (neutral, stone, matcha, y2k, gothic, chocolate, butter; its package must be installed); without it the theme starts from Astryx defaults. `settings` takes any `set` dial by name ({accent: "#7c3aed", font: "inter", corners: "round", vibrancy: "60"}): the same names, values and checks as `set`, all applied in the one build, with one result that lists them. Change the base later with `astryx experimental theme editor set <theme> base <theme|none>`. Afterwards, <theme>.theme.ts is yours: it extends the generated <theme>.settings.ts, and every later change rewrites only the settings files, so your own edits in <theme>.theme.ts survive. A theme name is lowercase letters, digits and dashes. Experimental: it may change or be removed in a patch release.',
|
|
16
16
|
importPath: '@astryxdesign/cli/api/experimental',
|
|
17
17
|
signature: 'themeEditNew(theme: string, options?: object): Promise<object>',
|
|
18
18
|
keywords: [
|
|
@@ -12,7 +12,7 @@ export const doc = {
|
|
|
12
12
|
displayName: 'themeEditPreviewApp()',
|
|
13
13
|
summary: 'Make a new starter app with the theme preview inside.',
|
|
14
14
|
description:
|
|
15
|
-
"Writes a new starter app into `dir` (Next.js app router, Core and the neutral theme, with the Astryx packages pinned to this CLI's release), with the theme preview route and its default pages (the sample app page and every component grouped) in src/app/theme-preview/. With `theme`, the theme folder is copied into the app's themes/ and the pages wear it; a base theme or font package it needs is added to package.json. No install runs: the result says how to install, run and open it. `dir` must be new or empty, inside the current folder; a folder that is not empty is refused, with a free folder name to use instead. Every check runs before the first write, so a refusal changes nothing. Every open font the theme names is added to package.json, at the version this project has or a pinned range, and the route imports it; a theme with generated colors gets the Colors page too, and a one-mode theme starts the route in its mode. The app is written into a temp folder beside the folder and moved into place, so a failure leaves nothing behind. A folder holding only .git, .DS_Store or Thumbs.db counts as empty. The folder is refused when it is a file, a dangling link, inside this app's routes folder, themes/, node_modules/ or Next's build folder (.next/, out/ or the distDir next.config names), or written with Windows separators, white space at either end or a name too long. A theme whose build is missing or older than its settings is built first, with a note. The app's home page links to the preview, and its .gitignore leaves out node_modules, next-env.d.ts and *.tsbuildinfo. Inside a project with a tsconfig.json, a note says to exclude the new folder. With a theme, it holds that theme's lock while it builds and copies it, so an `editor set` on the same theme waits for it. A folder given from a subfolder of the project is taken from where it was given. An app is refused in public/ (served as files at the site root) and under a name Windows does not allow; a base theme passed to --theme is named as a package theme, installed or not, with the command that adds it. Experimental: it may change or be removed in a patch release.",
|
|
15
|
+
"Writes a new starter app into `dir` (Next.js app router, Core and the neutral theme, with the Astryx packages pinned to this CLI's release; with `theme`, Core and the base theme are pinned to the versions this project has, the ones the copied build was made on, with a note), with the theme preview route and its default pages (the sample app page and every component grouped) in src/app/theme-preview/. With `theme`, the theme folder is copied into the app's themes/ and the pages wear it; a base theme or font package it needs is added to package.json. No install runs: the result says how to install, run and open it. `dir` must be new or empty, inside the current folder; a folder that is not empty is refused, with a free folder name to use instead. Every check runs before the first write, so a refusal changes nothing. Every open font the theme names is added to package.json, at the version this project has or a pinned range, and the route imports it; a theme with generated colors gets the Colors page too, and a one-mode theme starts the route in its mode. The app is written into a temp folder beside the folder and moved into place, so a failure leaves nothing behind. A folder holding only .git, .DS_Store or Thumbs.db counts as empty. The folder is refused when it is a file, a dangling link, inside this app's routes folder, themes/, node_modules/ or Next's build folder (.next/, out/ or the distDir next.config names), or written with Windows separators, white space at either end or a name too long. A theme whose build is missing or older than its settings is built first, with a note. The app's home page links to the preview, and its .gitignore leaves out node_modules, next-env.d.ts and *.tsbuildinfo. Inside a project with a tsconfig.json, a note says to exclude the new folder. With a theme, it holds that theme's lock while it builds and copies it, so an `editor set` on the same theme waits for it. A folder given from a subfolder of the project is taken from where it was given. An app is refused in public/ (served as files at the site root) and under a name Windows does not allow; a base theme passed to --theme is named as a package theme, installed or not, with the command that adds it. Experimental: it may change or be removed in a patch release.",
|
|
16
16
|
importPath: '@astryxdesign/cli/api/experimental',
|
|
17
17
|
signature:
|
|
18
18
|
'themeEditPreviewApp(dir: string, options?: object): Promise<object>',
|
|
@@ -13,7 +13,7 @@ export const doc = {
|
|
|
13
13
|
summary:
|
|
14
14
|
'Every setting, key values, problems the theme caused, and the theme-building page with every component.',
|
|
15
15
|
description:
|
|
16
|
-
'Lists every setting with where it applies and its source (dial, token or property), the resolved value of key tokens in each mode, the colors (the vibrancy; each color with its seed and the shade each token uses in light and dark, marked when an exact token setting wins; any shade moved so text reads), contrast problems this theme caused versus its base, font notes, and last the generated color files. Writes two self-contained HTML files: preview.html (the sample app page) and sheet.html (the theme-building page: every component grouped, each variant side by side, overlays open, and real template pages, with an auto/light/dark switch). A theme with no build is built first, and an in-app preview (`preview add`) of the theme has its route and Colors page rewritten. --section limits the sheet to one section. Experimental: it may change or be removed in a patch release.',
|
|
16
|
+
'Lists every setting with where it applies and its source (dial, token or property), the resolved value of key tokens in each mode, the colors (the vibrancy; each color with its seed and the shade each token uses in light and dark, marked when an exact token setting wins; any shade moved so text reads), contrast problems this theme caused versus its base, font notes, and last the generated color files. Writes two self-contained HTML files: preview.html (the sample app page) and sheet.html (the theme-building page: every component grouped, each variant side by side, overlays open, and real template pages, with an auto/light/dark switch). A theme with no build is built first, and an in-app preview (`preview add`) of the theme has its route and Colors page rewritten. --section limits the sheet to one section. An own change to <theme>.theme.ts since the last build is built first, and the colors mark where it wins over a generated shade; a theme source that no longer builds, or a token in it that is not text, is refused (ERR_THEME_INVALID, exit 1) and the folder stays as it was. Experimental: it may change or be removed in a patch release.',
|
|
17
17
|
importPath: '@astryxdesign/cli/api/experimental',
|
|
18
18
|
signature: 'themeEditShow(theme: string, options?: object): Promise<object>',
|
|
19
19
|
keywords: [
|
|
@@ -61,7 +61,7 @@ export const doc = {
|
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
code: 'ERR_UNKNOWN_THEME',
|
|
64
|
-
when: 'the theme does not exist
|
|
64
|
+
when: 'the theme does not exist (the suggestion is the `new` command), or its base theme package is not installed (the suggestion installs it, such as `npm install @astryxdesign/theme-neutral`)',
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
code: 'ERR_PROJECT_REQUIRED',
|
|
@@ -73,7 +73,15 @@ export const doc = {
|
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
code: 'ERR_THEME_INVALID',
|
|
76
|
-
when: 'the theme does not build
|
|
76
|
+
when: 'the theme does not build, its own <theme>.theme.ts does not parse, or a token in it is not text; the folder stays as it was',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
code: 'ERR_FILE_EXISTS',
|
|
80
|
+
when: 'a folder sits where the build writes a file (such as themes/<theme>/<theme>.d.ts); the suggestion lists it',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
code: 'ERR_WRITE_FAILED',
|
|
84
|
+
when: 'a built file cannot be read or replaced (its permissions), or a file cannot be written; the suggestion shows its permissions',
|
|
77
85
|
},
|
|
78
86
|
{
|
|
79
87
|
code: 'ERR_RENDER_FAILED',
|
|
@@ -1120,8 +1120,13 @@ export function logRegistryCompositionSummary(summary) {
|
|
|
1120
1120
|
) {
|
|
1121
1121
|
continue;
|
|
1122
1122
|
}
|
|
1123
|
+
// Only an apply writes the conflict file; a dry run names where it
|
|
1124
|
+
// would go, so it does not send the reader to review a file that is
|
|
1125
|
+
// not there.
|
|
1123
1126
|
const detail = file.conflictFile
|
|
1124
|
-
?
|
|
1127
|
+
? summary.applied
|
|
1128
|
+
? ` Review ${file.conflictFile}.`
|
|
1129
|
+
: ` Re-run with --apply to write ${file.conflictFile} for review.`
|
|
1125
1130
|
: file.message
|
|
1126
1131
|
? ` ${file.message}.`
|
|
1127
1132
|
: '';
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import postcss from 'postcss';
|
|
16
|
-
import selectorParser from '
|
|
16
|
+
import {selectorParser as loadSelectorParser} from '../../foundation/runtime/lazy-dependencies.mjs';
|
|
17
17
|
|
|
18
18
|
export const CODEMOD_PARSE_ERROR = 'ERR_CODEMOD_PARSE';
|
|
19
19
|
|
|
@@ -65,7 +65,7 @@ export function parseCss(source, options) {
|
|
|
65
65
|
export function processSelector(selector, callback) {
|
|
66
66
|
let root;
|
|
67
67
|
try {
|
|
68
|
-
root =
|
|
68
|
+
root = loadSelectorParser()().astSync(selector, {lossless: true});
|
|
69
69
|
} catch (err) {
|
|
70
70
|
throw markParseError(err);
|
|
71
71
|
}
|
|
@@ -25,7 +25,7 @@ export const docs = {
|
|
|
25
25
|
content: [
|
|
26
26
|
{
|
|
27
27
|
type: 'prose',
|
|
28
|
-
text:
|
|
28
|
+
text: "`integration add component` creates the normal doc for one public component. Keep the generated identity and import, then replace its sample text and props with the component's real public contract.",
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
type: 'code',
|
|
@@ -149,10 +149,19 @@ export default {
|
|
|
149
149
|
code: `examples: [
|
|
150
150
|
{
|
|
151
151
|
label: 'Automatic rotation',
|
|
152
|
-
code: '<AcmeCarousel slides={
|
|
152
|
+
code: '<AcmeCarousel slides={["/one.jpg", "/two.jpg"]} interval={5000} />',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
label: 'Wrap the app',
|
|
156
|
+
kind: 'setup',
|
|
157
|
+
code: '<AcmeCarouselProvider locale={locale}>{children}</AcmeCarouselProvider>',
|
|
153
158
|
},
|
|
154
159
|
],`,
|
|
155
160
|
},
|
|
161
|
+
{
|
|
162
|
+
type: 'prose',
|
|
163
|
+
text: "An example's `kind` is `'demo'` by default: it runs on its own, so a docs site may show it as a live preview. Set `kind: 'setup'` for code that cannot run on its own, such as an app setup file, a server route, or a snippet that uses variables defined elsewhere; it is always shown as code only.",
|
|
164
|
+
},
|
|
156
165
|
],
|
|
157
166
|
},
|
|
158
167
|
{
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file `astryx docs styling/tokens-and-setup`: using design tokens in custom
|
|
5
|
-
* styles
|
|
5
|
+
* styles, configuring a StyleX compiler for swizzled components, and keeping
|
|
6
|
+
* Next.js webpack builds small.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
/** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
|
|
@@ -14,8 +15,16 @@ export const docs = {
|
|
|
14
15
|
placement: {parent: 'namespace:styling', slot: 'guides', order: 30},
|
|
15
16
|
category: 'guide',
|
|
16
17
|
description:
|
|
17
|
-
'Using design tokens in custom styles
|
|
18
|
-
keywords: [
|
|
18
|
+
'Using design tokens in custom styles, configuring a StyleX compiler for swizzled components, and keeping Next.js webpack builds small.',
|
|
19
|
+
keywords: [
|
|
20
|
+
'StyleX setup',
|
|
21
|
+
'swizzle',
|
|
22
|
+
'webpack',
|
|
23
|
+
'Vite',
|
|
24
|
+
'Next.js',
|
|
25
|
+
'optimizePackageImports',
|
|
26
|
+
'Server Components',
|
|
27
|
+
],
|
|
19
28
|
|
|
20
29
|
sections: [
|
|
21
30
|
{
|
|
@@ -129,5 +138,32 @@ export default stylexPlugin({
|
|
|
129
138
|
},
|
|
130
139
|
],
|
|
131
140
|
},
|
|
141
|
+
{
|
|
142
|
+
id: 'nextjs-webpack',
|
|
143
|
+
title: 'Next.js with webpack',
|
|
144
|
+
content: [
|
|
145
|
+
{
|
|
146
|
+
type: 'prose',
|
|
147
|
+
text: 'If your Next.js app builds with webpack (`next build --webpack`), add `@astryxdesign/core` to `experimental.optimizePackageImports`. With webpack, a Server Component that imports from the package root would otherwise ship every client component; this keeps first load to what the page uses. Turbopack, the default bundler in Next.js 16, needs no change, and the setting is safe to keep there.',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
type: 'code',
|
|
151
|
+
lang: 'js',
|
|
152
|
+
label: 'next.config.mjs',
|
|
153
|
+
code: `/** @type {import('next').NextConfig} */
|
|
154
|
+
const nextConfig = {
|
|
155
|
+
experimental: {
|
|
156
|
+
optimizePackageImports: ['@astryxdesign/core'],
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export default nextConfig;`,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
type: 'prose',
|
|
164
|
+
text: "In Server Components, also import each component from its own entry, for example `import {Button} from '@astryxdesign/core/Button'`. `{@command component <Name>}` prints that entry. Files that start with `'use client'` are not affected.",
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
},
|
|
132
168
|
],
|
|
133
169
|
};
|