@astryxdesign/cli 0.7.14 → 0.7.15-canary.g061b2fa
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 +63 -63
- package/api/build/_adapter.d.mts +4 -0
- package/api/build/_adapter.mjs +28 -2
- package/api/build/blocks/blocks.d.mts +10 -1
- package/api/build/blocks/blocks.mjs +84 -7
- package/api/build/build.mjs +6 -1
- package/api/build/tree.d.mts +4 -0
- package/api/build/tree.mjs +9 -2
- package/api/doctor/_adapter.d.mts +3 -1
- package/api/doctor/_adapter.mjs +14 -1
- package/api/doctor/_authoring-audit.d.mts +42 -0
- package/api/doctor/_authoring-audit.mjs +106 -0
- package/api/doctor/doctor.d.mts +7 -0
- package/api/doctor/doctor.mjs +24 -39
- package/api/doctor/theme-checks.mjs +56 -21
- package/api/integration/validate-integration.mjs +17 -3
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_adapter.mjs +124 -3
- package/api/search/_candidate-score.mjs +63 -9
- package/api/search/_entries.d.mts +10 -0
- package/api/search/_entries.mjs +68 -1
- package/api/search/_gather-templates.d.mts +11 -0
- package/api/search/_gather-templates.mjs +22 -2
- package/api/search/_words.mjs +26 -6
- package/api/swizzle/copy/copy.mjs +1 -1
- package/api/theme/_adapter.d.mts +17 -1
- package/api/theme/_adapter.mjs +185 -40
- package/api/theme/build/build.d.mts +29 -1
- package/api/theme/build/build.mjs +426 -65
- package/api/theme/eject/eject.mjs +10 -6
- package/api/theme/targets/targets.d.mts +8 -0
- package/api/theme/targets/targets.mjs +24 -4
- package/api/theme/template/template.mjs +48 -2
- package/api/theme/theme.type.d.mts +8 -0
- package/api/theme/theme.type.mjs +5 -1
- package/api/theme/themeBuild.doc.mjs +7 -4
- package/api/theme/themeEject.doc.mjs +3 -3
- package/api/theme/themeRemove.doc.mjs +5 -2
- package/api/theme/themeTargets.doc.mjs +1 -1
- package/api/theme/themeTemplate.doc.mjs +2 -2
- package/api/theme/themeUse.doc.mjs +8 -2
- package/api/theme-edit/_adapter.d.mts +46 -3
- package/api/theme-edit/_adapter.mjs +372 -109
- package/api/theme-edit/_check.d.mts +6 -3
- package/api/theme-edit/_check.mjs +665 -87
- package/api/theme-edit/_color.mjs +4 -2
- package/api/theme-edit/_compiler.d.mts +2 -1
- package/api/theme-edit/_compiler.mjs +27 -13
- package/api/theme-edit/_context.d.mts +2 -1
- package/api/theme-edit/_context.mjs +47 -8
- package/api/theme-edit/_edit.d.mts +9 -3
- package/api/theme-edit/_edit.mjs +484 -66
- package/api/theme-edit/_how-commands.d.mts +33 -7
- package/api/theme-edit/_how-commands.mjs +57 -45
- package/api/theme-edit/_how-question.d.mts +4 -0
- package/api/theme-edit/_how-question.mjs +1004 -223
- package/api/theme-edit/_how.mjs +96 -9
- package/api/theme-edit/_palette.d.mts +38 -13
- package/api/theme-edit/_palette.mjs +620 -223
- package/api/theme-edit/_parts.mjs +63 -7
- package/api/theme-edit/_png.d.mts +4 -4
- package/api/theme-edit/_png.mjs +4 -2
- package/api/theme-edit/_preview-app.d.mts +6 -0
- package/api/theme-edit/_preview-app.mjs +1194 -207
- package/api/theme-edit/_preview.mjs +2 -2
- package/api/theme-edit/_project.d.mts +12 -1
- package/api/theme-edit/_project.mjs +37 -6
- package/api/theme-edit/_settings.d.mts +104 -33
- package/api/theme-edit/_settings.mjs +818 -118
- package/api/theme-edit/_tables.d.mts +7 -0
- package/api/theme-edit/_tables.mjs +61 -0
- package/api/theme-edit/theme-edit.type.d.mts +11 -1
- package/api/theme-edit/theme-edit.type.mjs +4 -3
- package/api/theme-edit/themeEditHow.doc.mjs +6 -0
- package/api/theme-edit/themeEditPreviewAdd.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewList.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +5 -1
- package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
- package/api/upgrade/_adapter.d.mts +1 -0
- package/assets/codemods/run-codemod.mjs +61 -0
- package/assets/codemods/runner.mjs +5 -4
- package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +3 -0
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +5 -1
- package/assets/codemods/transforms/v0.6.4/migrate-native-picker-to-presentation.mjs +3 -0
- package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +4 -0
- package/assets/codemods/transforms/v0.7.0/rename-empty-search-results-text.mjs +17 -12
- package/assets/codemods/transforms/v0.7.2/migrate-list-edge-compensation-to-edge.mjs +3 -0
- package/assets/codemods/transforms/v0.7.5/migrate-codeblock-tokenizer-to-language.mjs +3 -0
- package/assets/codemods/transforms/v0.7.8/promote-tokenizer-presentation.mjs +3 -0
- package/assets/docs/tree/calendars.doc.mjs +1 -3
- package/assets/docs/tree/checks.doc.mjs +22 -1
- package/assets/docs.generated.json +2 -1
- package/assets/self-audit.generated.json +1 -0
- package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.tsx +31 -0
- package/assets/templates/components.generated.json +1 -1
- package/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +8 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +9 -0
- package/clients/cli/bin/astryx.mjs +19 -15
- package/clients/cli/build-id.generated.json +1 -0
- package/clients/cli/commands/ensure-core-built.mjs +12 -5
- package/clients/cli/commands/experimental/theme.mjs +178 -78
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -2
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- 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 +3 -3
- 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-preview-list.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-template.doc.mjs +4 -3
- package/clients/cli/commands/manifest.mjs +5 -2
- package/clients/cli/commands/theme-build.doc.mjs +1 -1
- package/clients/cli/commands/theme-list.doc.mjs +1 -1
- package/clients/cli/commands/theme-template.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +374 -42
- package/clients/cli/index.mjs +9 -3
- package/clients/cli/lib/manifest.mjs +37 -0
- package/clients/cli/lib/resolve-theme.mjs +2 -1
- package/clients/cli/manifest.generated.json +1 -0
- package/foundation/config/theme-state.d.mts +16 -0
- package/foundation/config/theme-state.mjs +84 -13
- package/foundation/discovery/module-exports.mjs +16 -2
- package/foundation/discovery/stored-self-audit.d.mts +31 -0
- package/foundation/discovery/stored-self-audit.mjs +119 -0
- package/foundation/discovery/template-adapter.d.mts +48 -2
- package/foundation/discovery/template-adapter.mjs +51 -19
- package/foundation/discovery/template-needs.d.mts +19 -0
- package/foundation/discovery/template-needs.mjs +50 -16
- package/foundation/discovery/template-source-tree.d.mts +7 -0
- package/foundation/discovery/template-source-tree.mjs +15 -0
- package/foundation/discovery/theme-discovery.d.mts +2 -1
- package/foundation/discovery/theme-discovery.mjs +2 -8
- package/foundation/discovery/theme-module-extensions.d.mts +18 -0
- package/foundation/discovery/theme-module-extensions.mjs +30 -0
- package/foundation/doc-compiler/import.mjs +22 -15
- package/foundation/doc-compiler/stored-docs.d.mts +18 -12
- package/foundation/doc-compiler/stored-docs.mjs +52 -19
- package/foundation/env/private-dir.d.mts +17 -0
- package/foundation/env/private-dir.mjs +42 -0
- package/foundation/fs/gather-cache.d.mts +108 -0
- package/foundation/fs/gather-cache.mjs +741 -0
- package/foundation/fs/jiti-cache.d.mts +21 -0
- package/foundation/fs/jiti-cache.mjs +66 -0
- package/foundation/fs/module-loader.mjs +14 -3
- package/foundation/fs/read-record.d.mts +31 -1
- package/foundation/fs/read-record.mjs +100 -7
- package/foundation/integrations/integrations.d.mts +8 -0
- package/foundation/integrations/integrations.mjs +4 -0
- package/foundation/integrations/validate-contributions.d.mts +62 -1
- package/foundation/integrations/validate-contributions.mjs +476 -40
- package/foundation/release/cache.d.mts +11 -2
- package/foundation/release/cache.mjs +59 -10
- package/foundation/release/folder-lock.d.mts +21 -0
- package/foundation/release/folder-lock.mjs +171 -0
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +8 -6
|
@@ -17,10 +17,15 @@
|
|
|
17
17
|
|
|
18
18
|
import * as fs from 'node:fs';
|
|
19
19
|
import * as path from 'node:path';
|
|
20
|
+
import {isAlive} from '../../foundation/release/cache.mjs';
|
|
20
21
|
import {AstryxError} from '../error.mjs';
|
|
21
22
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
22
|
-
import {importPathOf} from './_project.mjs';
|
|
23
|
-
import {
|
|
23
|
+
import {importPathOf, installLine} from './_project.mjs';
|
|
24
|
+
import {
|
|
25
|
+
RENDER_TIMEOUT_MS,
|
|
26
|
+
renderPage,
|
|
27
|
+
RenderError,
|
|
28
|
+
} from '../../foundation/render/render-page.mjs';
|
|
24
29
|
import {
|
|
25
30
|
EXTRA,
|
|
26
31
|
OPEN_OVERLAYS,
|
|
@@ -83,6 +88,9 @@ export function catalogItems(project) {
|
|
|
83
88
|
return {items, imports};
|
|
84
89
|
}
|
|
85
90
|
|
|
91
|
+
/** How long the editor's own pages may take to render. */
|
|
92
|
+
const EDITOR_RENDER_MS = 3 * RENDER_TIMEOUT_MS;
|
|
93
|
+
|
|
86
94
|
/** One name per process, so two commands at once never share a folder. */
|
|
87
95
|
const RUN = `${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
|
|
88
96
|
|
|
@@ -96,6 +104,33 @@ const RUN = `${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
|
|
|
96
104
|
export const renderDir = project =>
|
|
97
105
|
path.join(project.cwd, 'themes', `.astryx-render-${RUN}`);
|
|
98
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Remove render folders a stopped command left (killed, out of memory):
|
|
109
|
+
* only `.astryx-render-<pid>-<random>` folders whose process is gone. Links
|
|
110
|
+
* are never followed.
|
|
111
|
+
* @param {string} themes
|
|
112
|
+
*/
|
|
113
|
+
function sweepRenders(themes) {
|
|
114
|
+
let names;
|
|
115
|
+
try {
|
|
116
|
+
names = fs.readdirSync(themes);
|
|
117
|
+
} catch {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
for (const n of names) {
|
|
121
|
+
const m = /^\.astryx-render-(\d+)-[a-z0-9]+$/.exec(n);
|
|
122
|
+
if (!m || Number(m[1]) === process.pid) continue;
|
|
123
|
+
if (isAlive(Number(m[1]))) continue;
|
|
124
|
+
const p = path.join(themes, n);
|
|
125
|
+
try {
|
|
126
|
+
if (fs.lstatSync(p).isDirectory())
|
|
127
|
+
fs.rmSync(p, {recursive: true, force: true});
|
|
128
|
+
} catch {
|
|
129
|
+
// Gone already.
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
99
134
|
/**
|
|
100
135
|
* Render a generated page module and give its HTML and markup (the body,
|
|
101
136
|
* without the embedded source block).
|
|
@@ -111,6 +146,7 @@ export async function renderGenerated(project, file, source, extra = []) {
|
|
|
111
146
|
const themes = path.dirname(dir);
|
|
112
147
|
// A themes/ folder that holds only other renders was made by another
|
|
113
148
|
// lookup running beside this one, so it is ours to remove too.
|
|
149
|
+
sweepRenders(themes);
|
|
114
150
|
const madeThemes =
|
|
115
151
|
!fs.existsSync(themes) ||
|
|
116
152
|
(() => {
|
|
@@ -135,16 +171,36 @@ export async function renderGenerated(project, file, source, extra = []) {
|
|
|
135
171
|
fs.copyFileSync(x.from, path.join(dir, x.name));
|
|
136
172
|
}
|
|
137
173
|
try {
|
|
138
|
-
|
|
139
|
-
|
|
174
|
+
// The editor's pages render every component, and a busy machine slows
|
|
175
|
+
// them down: they get three times the page limit.
|
|
176
|
+
const page = await renderPage(entry, {
|
|
177
|
+
title: file.replace(/\.[^.]+$/, ''),
|
|
178
|
+
timeoutMs: EDITOR_RENDER_MS,
|
|
179
|
+
});
|
|
180
|
+
// The page is the same whichever command rendered it: the folder's
|
|
181
|
+
// per-process name never reaches the file.
|
|
182
|
+
const html = page.html.split(path.basename(dir)).join('.astryx-render');
|
|
183
|
+
const body = html.slice(html.indexOf('<body>') + 6);
|
|
140
184
|
const end = body.indexOf('<script type=');
|
|
141
|
-
return {html
|
|
185
|
+
return {html, markup: end >= 0 ? body.slice(0, end) : body};
|
|
142
186
|
} catch (e) {
|
|
143
187
|
if (e instanceof RenderError) {
|
|
144
188
|
const missing = e.code === 'ERR_RENDER_MISSING_DEPENDENCY';
|
|
189
|
+
// A render stopped by its time limit on the editor's own page is the
|
|
190
|
+
// machine being busy, not a loop in the page.
|
|
191
|
+
const slow = e.code === 'ERR_RENDER_TIMEOUT';
|
|
145
192
|
throw new AstryxError(
|
|
146
|
-
|
|
147
|
-
|
|
193
|
+
slow
|
|
194
|
+
? `The components did not finish rendering within ${EDITOR_RENDER_MS / 1000} seconds, so the render was stopped. The machine may be busy: run the command again when it is less loaded.`
|
|
195
|
+
: `Could not render the components with this project's React: ${e.message}${missing ? ' The theme command renders components on the server, so react and react-dom must be installed.' : ''}`,
|
|
196
|
+
missing
|
|
197
|
+
? [
|
|
198
|
+
{
|
|
199
|
+
name: installLine(project.cwd, ['react', 'react-dom']),
|
|
200
|
+
reason: 'install them',
|
|
201
|
+
},
|
|
202
|
+
]
|
|
203
|
+
: [],
|
|
148
204
|
missing
|
|
149
205
|
? ERROR_CODES.ERR_RENDER_MISSING_DEPENDENCY
|
|
150
206
|
: ERROR_CODES.ERR_RENDER_FAILED,
|
|
@@ -11,18 +11,18 @@
|
|
|
11
11
|
export function decodePng(bytes: Buffer): Picture;
|
|
12
12
|
/**
|
|
13
13
|
* The exact color at each point, with its alpha (0 is fully see-through,
|
|
14
|
-
* 1 fully opaque).
|
|
14
|
+
* 1 fully opaque). A point outside the picture has no color.
|
|
15
15
|
* @param {Picture} pic
|
|
16
16
|
* @param {Array<{x: number, y: number}>} points
|
|
17
|
-
* @returns {Array<{at: string, color: string, alpha: number}>}
|
|
17
|
+
* @returns {Array<{at: string, color: string | null, alpha: number | null}>}
|
|
18
18
|
*/
|
|
19
19
|
export function colorsAt(pic: Picture, points: Array<{
|
|
20
20
|
x: number;
|
|
21
21
|
y: number;
|
|
22
22
|
}>): Array<{
|
|
23
23
|
at: string;
|
|
24
|
-
color: string;
|
|
25
|
-
alpha: number;
|
|
24
|
+
color: string | null;
|
|
25
|
+
alpha: number | null;
|
|
26
26
|
}>;
|
|
27
27
|
/**
|
|
28
28
|
* The main colors of a picture: every pixel (on a grid past 4 million)
|
package/api/theme-edit/_png.mjs
CHANGED
|
@@ -222,13 +222,15 @@ const hx = v => Math.round(v).toString(16).padStart(2, '0');
|
|
|
222
222
|
|
|
223
223
|
/**
|
|
224
224
|
* The exact color at each point, with its alpha (0 is fully see-through,
|
|
225
|
-
* 1 fully opaque).
|
|
225
|
+
* 1 fully opaque). A point outside the picture has no color.
|
|
226
226
|
* @param {Picture} pic
|
|
227
227
|
* @param {Array<{x: number, y: number}>} points
|
|
228
|
-
* @returns {Array<{at: string, color: string, alpha: number}>}
|
|
228
|
+
* @returns {Array<{at: string, color: string | null, alpha: number | null}>}
|
|
229
229
|
*/
|
|
230
230
|
export function colorsAt(pic, points) {
|
|
231
231
|
return points.map(({x, y}) => {
|
|
232
|
+
if (x < 0 || y < 0 || x >= pic.width || y >= pic.height)
|
|
233
|
+
return {at: `${x},${y}`, color: null, alpha: null};
|
|
232
234
|
const i = (y * pic.width + x) * 4;
|
|
233
235
|
return {
|
|
234
236
|
at: `${x},${y}`,
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* For tests: stop the next preview changes at the step where `when`
|
|
6
|
+
* returns true, as a kill would, with nothing put back. Null clears it.
|
|
7
|
+
* @param {((step: string) => boolean) | null} when
|
|
8
|
+
*/
|
|
9
|
+
export function stopPreviewCommitAt(when: ((step: string) => boolean) | null): void;
|
|
4
10
|
/**
|
|
5
11
|
* Rewrite the in-app preview routes of a theme when their imports changed, so
|
|
6
12
|
* a font package installed after `set` loads on the next change or `show`,
|