@astryxdesign/cli 0.7.15-canary.gea16e8d → 0.7.15
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 +353 -3
- 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 +2 -1
- package/api/doctor/_adapter.mjs +6 -1
- package/api/doctor/doctor.mjs +2 -2
- package/api/doctor/theme-checks.mjs +56 -21
- package/api/integration/add-helpers.mjs +5 -0
- package/api/integration/add-theme.mjs +15 -110
- package/api/integration/validate-integration.mjs +17 -3
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/theme/_adapter.d.mts +37 -5
- package/api/theme/_adapter.mjs +363 -50
- package/api/theme/_fork.d.mts +90 -0
- package/api/theme/_fork.mjs +246 -0
- package/api/theme/build/build.d.mts +25 -1
- package/api/theme/build/build.mjs +352 -41
- package/api/theme/eject/eject.mjs +36 -15
- package/api/theme/list/list.mjs +3 -6
- package/api/theme/palette/generate/generator.d.mts +13 -0
- package/api/theme/palette/generate/generator.mjs +32 -2
- package/api/theme/targets/targets.mjs +10 -3
- 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 +2 -2
- package/api/theme/themeRemove.doc.mjs +5 -2
- package/api/theme/themeTemplate.doc.mjs +2 -2
- package/api/theme/themeUse.doc.mjs +8 -2
- package/api/theme-edit/_adapter.mjs +157 -36
- package/api/theme-edit/_catalog.d.mts +1 -6
- package/api/theme-edit/_catalog.mjs +5 -268
- package/api/theme-edit/_check.d.mts +3 -1
- package/api/theme-edit/_check.mjs +733 -308
- package/api/theme-edit/_color.d.mts +19 -0
- package/api/theme-edit/_color.mjs +277 -33
- package/api/theme-edit/_compiler.d.mts +1 -0
- package/api/theme-edit/_compiler.mjs +25 -0
- package/api/theme-edit/_context.d.mts +2 -0
- package/api/theme-edit/_context.mjs +83 -9
- package/api/theme-edit/_css.d.mts +84 -0
- package/api/theme-edit/_css.mjs +700 -0
- package/api/theme-edit/_edit.mjs +370 -85
- package/api/theme-edit/_how-commands.d.mts +5 -0
- package/api/theme-edit/_how-commands.mjs +20 -13
- package/api/theme-edit/_how-question.d.mts +29 -0
- package/api/theme-edit/_how-question.mjs +1573 -182
- package/api/theme-edit/_how.mjs +306 -22
- package/api/theme-edit/_overview.mjs +2 -7
- package/api/theme-edit/_palette.d.mts +27 -5
- package/api/theme-edit/_palette.mjs +231 -97
- package/api/theme-edit/_parts.d.mts +42 -10
- package/api/theme-edit/_parts.mjs +224 -69
- package/api/theme-edit/_preview-app.d.mts +8 -0
- package/api/theme-edit/_preview-app.mjs +549 -96
- package/api/theme-edit/_preview.d.mts +7 -16
- package/api/theme-edit/_preview.mjs +77 -84
- package/api/theme-edit/_project.d.mts +20 -1
- package/api/theme-edit/_project.mjs +43 -13
- package/api/theme-edit/_settings.d.mts +96 -20
- package/api/theme-edit/_settings.mjs +646 -141
- package/api/theme-edit/_tables.d.mts +18 -12
- package/api/theme-edit/_tables.mjs +144 -147
- package/api/theme-edit/theme-edit.type.d.mts +10 -1
- package/api/theme-edit/theme-edit.type.mjs +3 -1
- package/api/theme-edit/themeEditNew.doc.mjs +1 -1
- 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 +2 -2
- package/api/theme-edit/themeEditSet.doc.mjs +1 -1
- package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
- package/assets/docs/tree/checks.doc.mjs +22 -1
- package/assets/docs/tree/publishing.doc.mjs +1 -0
- package/assets/docs.generated.json +2 -2
- package/assets/self-audit.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/build-id.generated.json +1 -1
- package/clients/cli/commands/experimental/index.mjs +10 -10
- package/clients/cli/commands/experimental/theme.mjs +22 -3
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-new.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/integration.mjs +8 -0
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- 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 +325 -48
- package/clients/cli/index.mjs +18 -3
- package/clients/cli/lib/cli-error.mjs +118 -3
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/config/project.mjs +34 -8
- package/foundation/config/theme-state.d.mts +16 -0
- package/foundation/config/theme-state.mjs +84 -13
- package/foundation/discovery/template-needs.d.mts +13 -0
- package/foundation/discovery/template-needs.mjs +30 -15
- package/foundation/discovery/theme-discovery.mjs +14 -2
- package/foundation/discovery/theme-imports.d.mts +16 -0
- package/foundation/discovery/theme-imports.mjs +30 -2
- package/foundation/doc-compiler/import.mjs +10 -4
- package/foundation/fs/gather-cache.mjs +82 -23
- package/foundation/fs/jiti-cache.d.mts +21 -0
- package/foundation/fs/jiti-cache.mjs +66 -0
- package/foundation/fs/module-loader.mjs +7 -2
- package/foundation/integrations/autolink.d.mts +1 -24
- package/foundation/integrations/autolink.mjs +7 -60
- package/foundation/integrations/declared-dependencies.d.mts +27 -0
- package/foundation/integrations/declared-dependencies.mjs +73 -0
- package/foundation/integrations/integrations.d.mts +8 -0
- package/foundation/integrations/integrations.mjs +4 -0
- package/foundation/integrations/may-have-integrations.d.mts +8 -0
- package/foundation/integrations/may-have-integrations.mjs +47 -0
- package/foundation/integrations/validate-contributions.d.mts +62 -1
- package/foundation/integrations/validate-contributions.mjs +452 -29
- package/foundation/release/cache.d.mts +21 -2
- package/foundation/release/cache.mjs +48 -8
- package/foundation/release/folder-lock.d.mts +7 -0
- package/foundation/release/folder-lock.mjs +60 -26
- package/foundation/release/lock-lease.d.mts +2 -1
- package/foundation/release/lock-lease.mjs +7 -2
- package/foundation/response/error-codes.doc.mjs +1 -1
- package/foundation/response/response-types.doc.mjs +5 -5
- package/package.json +6 -6
- package/api/theme-edit/_css-properties.d.mts +0 -10
- package/api/theme-edit/_css-properties.mjs +0 -556
package/api/build/_adapter.d.mts
CHANGED
|
@@ -74,6 +74,10 @@ export function loadWeights(): import("./kit/weights.mjs").WeightsFile | null;
|
|
|
74
74
|
* @returns {import('../../foundation/route/route.mjs').ClassifierWeights}
|
|
75
75
|
*/
|
|
76
76
|
export function loadTreeWeights(): import("../../foundation/route/route.mjs").ClassifierWeights;
|
|
77
|
+
export function keptBlockCatalog<T>(key: unknown[], compute: () => T, codec: {
|
|
78
|
+
encode: (value: T) => any;
|
|
79
|
+
decode: (stored: any) => T;
|
|
80
|
+
}): T;
|
|
77
81
|
/**
|
|
78
82
|
* The block picker's weights (blocks/blocks.weights.json), read once; null
|
|
79
83
|
* when the file is absent, unreadable, or not the shape the picker reads, in
|
package/api/build/_adapter.mjs
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file The build subject's environment access: the page templates a project
|
|
5
|
-
* can scaffold, the components it can use,
|
|
5
|
+
* can scaffold, the components it can use, the checked-in matcher weights, and
|
|
6
|
+
* the block picker's per-block vectors kept between runs.
|
|
6
7
|
*
|
|
7
8
|
* @input Template and component discovery for `cwd` — the CLI's own templates
|
|
8
9
|
* and Core's components, plus any that the project's configured integrations
|
|
@@ -11,7 +12,8 @@
|
|
|
11
12
|
* keywords, command}`, where `command` is the `astryx template` command that
|
|
12
13
|
* selects exactly that template; blocks as search names them; components as
|
|
13
14
|
* `{name, keywords}`; the kit's matcher weights, the root's classifier
|
|
14
|
-
* weights, and the block picker's weights
|
|
15
|
+
* weights, and the block picker's weights; `keptBlockCatalog`, which keeps
|
|
16
|
+
* the picker's per-block vectors beside the kept search catalog.
|
|
15
17
|
* @position Beside build.mjs (api/build/). The kit leaf reads templates and
|
|
16
18
|
* components only through here, because a subject's `_adapter.mjs` is its
|
|
17
19
|
* only environment access. This adds no discovery of its own: templates come
|
|
@@ -19,10 +21,12 @@
|
|
|
19
21
|
*/
|
|
20
22
|
|
|
21
23
|
import fs from 'node:fs';
|
|
24
|
+
import {fileURLToPath} from 'node:url';
|
|
22
25
|
|
|
23
26
|
import {discoverTemplates} from '../template/template.mjs';
|
|
24
27
|
import {componentKeywords} from '../search/search.mjs';
|
|
25
28
|
import {findCoreDir, requireCoreDir} from '../../foundation/fs/paths.mjs';
|
|
29
|
+
import {persistedDerived} from '../../foundation/fs/gather-cache.mjs';
|
|
26
30
|
import {analyzeTemplateNeeds} from '../../foundation/discovery/template-needs.mjs';
|
|
27
31
|
|
|
28
32
|
/**
|
|
@@ -179,6 +183,28 @@ export function loadTreeWeights() {
|
|
|
179
183
|
/** @type {import('./blocks/blocks.mjs').BlockPickerWeights | null | undefined} */
|
|
180
184
|
let blockPicker;
|
|
181
185
|
|
|
186
|
+
/**
|
|
187
|
+
* The files the block picker's per-block vectors are worked out from, besides
|
|
188
|
+
* the catalog text: its module, its weights, and search's word rules (the
|
|
189
|
+
* stopwords).
|
|
190
|
+
*/
|
|
191
|
+
const BLOCK_CATALOG_INPUTS = [
|
|
192
|
+
fileURLToPath(new URL('./blocks/blocks.mjs', import.meta.url)),
|
|
193
|
+
fileURLToPath(new URL('./blocks/blocks.weights.json', import.meta.url)),
|
|
194
|
+
fileURLToPath(new URL('../search/_query.mjs', import.meta.url)),
|
|
195
|
+
];
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Keep the block picker's per-block vectors beside the kept search catalog
|
|
199
|
+
* (foundation/fs/gather-cache.mjs persistedDerived), keyed also by the files
|
|
200
|
+
* that work them out, so a later run with the same catalog text and code
|
|
201
|
+
* reads them back.
|
|
202
|
+
* @type {import('./blocks/blocks.mjs').KeepCatalog}
|
|
203
|
+
*/
|
|
204
|
+
export function keptBlockCatalog(key, compute, codec) {
|
|
205
|
+
return persistedDerived(key, compute, codec, BLOCK_CATALOG_INPUTS);
|
|
206
|
+
}
|
|
207
|
+
|
|
182
208
|
/**
|
|
183
209
|
* The block picker's weights (blocks/blocks.weights.json), read once; null
|
|
184
210
|
* when the file is absent, unreadable, or not the shape the picker reads, in
|
|
@@ -68,6 +68,7 @@ export function matchOf(request: {
|
|
|
68
68
|
* @param {string} request
|
|
69
69
|
* @param {{kitBlocks: string[], searched: BlockScore[], foreign: string[], catalog: CatalogBlock[], components: CatalogComponent[]}} signals
|
|
70
70
|
* @param {BlockPickerWeights} weights
|
|
71
|
+
* @param {KeepCatalog} [keep] keeps the per-block vectors between runs
|
|
71
72
|
* @returns {{names: string[], entries: Map<string, SearchResultEntry>}} as
|
|
72
73
|
* many names as build's own list, best first; an entry for each listed
|
|
73
74
|
* block search did not return
|
|
@@ -78,10 +79,18 @@ export function pickBlocks(request: string, signals: {
|
|
|
78
79
|
foreign: string[];
|
|
79
80
|
catalog: CatalogBlock[];
|
|
80
81
|
components: CatalogComponent[];
|
|
81
|
-
}, weights: BlockPickerWeights): {
|
|
82
|
+
}, weights: BlockPickerWeights, keep?: KeepCatalog): {
|
|
82
83
|
names: string[];
|
|
83
84
|
entries: Map<string, SearchResultEntry>;
|
|
84
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* Keeps a value derived from the catalog between runs (build's adapter does
|
|
88
|
+
* it beside the kept search catalog), or works it out.
|
|
89
|
+
*/
|
|
90
|
+
export type KeepCatalog = <T>(key: unknown[], compute: () => T, codec: {
|
|
91
|
+
encode: (value: T) => any;
|
|
92
|
+
decode: (stored: any) => T;
|
|
93
|
+
}) => T;
|
|
85
94
|
export type BlockPickerWeights = {
|
|
86
95
|
/**
|
|
87
96
|
* stemmed words and `a_b` word pairs
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* vocabulary of stemmed words and word pairs with their idf (x1024), two
|
|
12
12
|
* signed byte matrices that map request words and doc words into one space, the
|
|
13
13
|
* lexical weight, the blocks the matrices were fitted with, and the ranking
|
|
14
|
-
* coefficients.
|
|
14
|
+
* coefficients. Optionally, a keeper from build's adapter (`keep`) that
|
|
15
|
+
* reads back the per-block vectors kept for the same catalog.
|
|
15
16
|
* @output `pickBlocks(...)`: block names, best first, as many as build's own
|
|
16
17
|
* list, and an entry (real score and reason) for each listed block search
|
|
17
18
|
* did not return.
|
|
@@ -38,8 +39,15 @@
|
|
|
38
39
|
* slot build gave them; the best of the others fill the remaining slots.
|
|
39
40
|
*/
|
|
40
41
|
|
|
42
|
+
import {createHash} from 'node:crypto';
|
|
41
43
|
import {STOPWORDS} from '../../search/_query.mjs';
|
|
42
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Keeps a value derived from the catalog between runs (build's adapter does
|
|
47
|
+
* it beside the kept search catalog), or works it out.
|
|
48
|
+
* @typedef {<T>(key: unknown[], compute: () => T, codec: {encode: (value: T) => any, decode: (stored: any) => T}) => T} KeepCatalog
|
|
49
|
+
*/
|
|
50
|
+
|
|
43
51
|
/**
|
|
44
52
|
* @typedef {object} BlockPickerWeights
|
|
45
53
|
* @property {string[]} vocab stemmed words and `a_b` word pairs
|
|
@@ -325,14 +333,39 @@ const catalogs = new WeakMap();
|
|
|
325
333
|
* @param {CatalogBlock[]} catalog
|
|
326
334
|
* @param {CatalogComponent[]} components
|
|
327
335
|
* @param {BlockPickerWeights} weights
|
|
336
|
+
* @param {KeepCatalog} [keep] keeps the value between runs (build's adapter)
|
|
328
337
|
*/
|
|
329
|
-
function readCatalog(catalog, components, weights) {
|
|
338
|
+
function readCatalog(catalog, components, weights, keep) {
|
|
330
339
|
const key = JSON.stringify([
|
|
331
340
|
catalog.map(b => [b.name, b.displayName, b.description]),
|
|
332
341
|
components.map(c => [c.name, c.keywords]),
|
|
333
342
|
]);
|
|
334
343
|
const cached = catalogs.get(weights);
|
|
335
344
|
if (cached && cached.key === key) return cached;
|
|
345
|
+
const compute = () => computeCatalog(key, catalog, components, weights);
|
|
346
|
+
// A function of the catalog text and the shipped weights: where build's
|
|
347
|
+
// adapter keeps it between runs, a later run with the same text reads it
|
|
348
|
+
// back.
|
|
349
|
+
const read = keep
|
|
350
|
+
? keep(
|
|
351
|
+
['block-catalog', createHash('sha256').update(key).digest('hex')],
|
|
352
|
+
compute,
|
|
353
|
+
CATALOG_CODEC,
|
|
354
|
+
)
|
|
355
|
+
: compute();
|
|
356
|
+
catalogs.set(weights, read);
|
|
357
|
+
return read;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* readCatalog's value, worked out.
|
|
362
|
+
* @param {string} key
|
|
363
|
+
* @param {CatalogBlock[]} catalog
|
|
364
|
+
* @param {CatalogComponent[]} components
|
|
365
|
+
* @param {BlockPickerWeights} weights
|
|
366
|
+
* @returns {{key: string, blocks: Map<string, {component: string, vector: Map<number, number>, projected: Float64Array}>, phrases: Map<string, [string[], number][]>}}
|
|
367
|
+
*/
|
|
368
|
+
function computeCatalog(key, catalog, components, weights) {
|
|
336
369
|
const names = components.map(c => c.name).sort((a, b) => b.length - a.length);
|
|
337
370
|
const keywords = new Map(components.map(c => [c.name, c.keywords ?? []]));
|
|
338
371
|
/** @type {Map<string, {component: string, vector: Map<number, number>, projected: Float64Array}>} */
|
|
@@ -369,11 +402,54 @@ function readCatalog(catalog, components, weights) {
|
|
|
369
402
|
list.push([phrase(k), 1 / (shared.get(k) ?? 1)]);
|
|
370
403
|
phrases.set(c, list);
|
|
371
404
|
}
|
|
372
|
-
|
|
373
|
-
catalogs.set(weights, read);
|
|
374
|
-
return read;
|
|
405
|
+
return {key, blocks, phrases};
|
|
375
406
|
}
|
|
376
407
|
|
|
408
|
+
/**
|
|
409
|
+
* readCatalog's value as plain data and back: maps as entry lists, each
|
|
410
|
+
* projection as its numbers.
|
|
411
|
+
*/
|
|
412
|
+
const CATALOG_CODEC = {
|
|
413
|
+
/** @param {ReturnType<typeof computeCatalog>} read */
|
|
414
|
+
encode: read => ({
|
|
415
|
+
key: read.key,
|
|
416
|
+
blocks: [...read.blocks].map(([name, b]) => [
|
|
417
|
+
name,
|
|
418
|
+
b.component,
|
|
419
|
+
[...b.vector],
|
|
420
|
+
[...b.projected],
|
|
421
|
+
]),
|
|
422
|
+
phrases: [...read.phrases],
|
|
423
|
+
}),
|
|
424
|
+
/**
|
|
425
|
+
* @param {any} stored
|
|
426
|
+
* @returns {ReturnType<typeof computeCatalog>}
|
|
427
|
+
*/
|
|
428
|
+
decode: stored => ({
|
|
429
|
+
key: stored.key,
|
|
430
|
+
blocks: new Map(
|
|
431
|
+
stored.blocks.map(
|
|
432
|
+
(
|
|
433
|
+
/** @type {[string, string, [number, number][], number[]]} */ [
|
|
434
|
+
name,
|
|
435
|
+
component,
|
|
436
|
+
vector,
|
|
437
|
+
projected,
|
|
438
|
+
],
|
|
439
|
+
) => [
|
|
440
|
+
name,
|
|
441
|
+
{
|
|
442
|
+
component,
|
|
443
|
+
vector: new Map(vector),
|
|
444
|
+
projected: Float64Array.from(projected),
|
|
445
|
+
},
|
|
446
|
+
],
|
|
447
|
+
),
|
|
448
|
+
),
|
|
449
|
+
phrases: new Map(stored.phrases),
|
|
450
|
+
}),
|
|
451
|
+
};
|
|
452
|
+
|
|
377
453
|
/**
|
|
378
454
|
* How strongly the request names each component: its best phrase, longer
|
|
379
455
|
* phrases and earlier ones stronger, and half as strong once the request has
|
|
@@ -435,16 +511,17 @@ function writesName(words, block) {
|
|
|
435
511
|
* @param {string} request
|
|
436
512
|
* @param {{kitBlocks: string[], searched: BlockScore[], foreign: string[], catalog: CatalogBlock[], components: CatalogComponent[]}} signals
|
|
437
513
|
* @param {BlockPickerWeights} weights
|
|
514
|
+
* @param {KeepCatalog} [keep] keeps the per-block vectors between runs
|
|
438
515
|
* @returns {{names: string[], entries: Map<string, SearchResultEntry>}} as
|
|
439
516
|
* many names as build's own list, best first; an entry for each listed
|
|
440
517
|
* block search did not return
|
|
441
518
|
*/
|
|
442
|
-
export function pickBlocks(request, signals, weights) {
|
|
519
|
+
export function pickBlocks(request, signals, weights, keep) {
|
|
443
520
|
const own = signals.kitBlocks;
|
|
444
521
|
/** @type {Map<string, SearchResultEntry>} */
|
|
445
522
|
const entries = new Map();
|
|
446
523
|
if (own.length === 0) return {names: [], entries};
|
|
447
|
-
const cat = readCatalog(signals.catalog, signals.components, weights);
|
|
524
|
+
const cat = readCatalog(signals.catalog, signals.components, weights, keep);
|
|
448
525
|
const side = requestSideOf(request, weights);
|
|
449
526
|
/** @type {Map<string, {match: number, overlap: number}>} */
|
|
450
527
|
const scored = new Map();
|
package/api/build/build.mjs
CHANGED
|
@@ -20,6 +20,7 @@ import {buildHelp} from './help/help.mjs';
|
|
|
20
20
|
import {buildKit} from './kit/kit.mjs';
|
|
21
21
|
import {
|
|
22
22
|
loadBlockPicker,
|
|
23
|
+
keptBlockCatalog,
|
|
23
24
|
loadTreeWeights,
|
|
24
25
|
withListingCache,
|
|
25
26
|
} from './_adapter.mjs';
|
|
@@ -59,7 +60,11 @@ export async function build(query, options = {}) {
|
|
|
59
60
|
await runTree(
|
|
60
61
|
BUILD_TREE,
|
|
61
62
|
{query, options},
|
|
62
|
-
{
|
|
63
|
+
{
|
|
64
|
+
weights: loadTreeWeights(),
|
|
65
|
+
blocks: loadBlockPicker(),
|
|
66
|
+
keepBlocks: keptBlockCatalog,
|
|
67
|
+
},
|
|
63
68
|
)
|
|
64
69
|
),
|
|
65
70
|
);
|
package/api/build/tree.d.mts
CHANGED
|
@@ -15,6 +15,10 @@ export type BuildContext = {
|
|
|
15
15
|
* the block picker's weights; null: build names its own blocks
|
|
16
16
|
*/
|
|
17
17
|
blocks: import("./blocks/blocks.mjs").BlockPickerWeights | null;
|
|
18
|
+
/**
|
|
19
|
+
* keeps the picker's per-block vectors between runs
|
|
20
|
+
*/
|
|
21
|
+
keepBlocks?: import("./blocks/blocks.mjs").KeepCatalog | undefined;
|
|
18
22
|
};
|
|
19
23
|
export type BuildAnswer = import("./build.type.mjs").BuildKitResponse;
|
|
20
24
|
import { kitSignals } from './kit/signals.mjs';
|
package/api/build/tree.mjs
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* (kit/signals.mjs), the block picker's blocks (blocks/blocks.mjs), and the
|
|
8
8
|
* kit around them (kit/answer.mjs).
|
|
9
9
|
* @input {query, options} and the data build's adapter gathered: the root's
|
|
10
|
-
* weights and the block picker's
|
|
10
|
+
* weights and the block picker's, and the adapter's keeper for the picker's
|
|
11
|
+
* per-block vectors
|
|
11
12
|
* @output the build.kit response
|
|
12
13
|
* @position api/build; build.mjs runs it with the shared route helper
|
|
13
14
|
*/
|
|
@@ -22,6 +23,7 @@ import {pickBlocks} from './blocks/blocks.mjs';
|
|
|
22
23
|
* @typedef {object} BuildContext
|
|
23
24
|
* @property {import('../../foundation/route/route.mjs').ClassifierWeights} weights the root's weights
|
|
24
25
|
* @property {import('./blocks/blocks.mjs').BlockPickerWeights | null} blocks the block picker's weights; null: build names its own blocks
|
|
26
|
+
* @property {import('./blocks/blocks.mjs').KeepCatalog} [keepBlocks] keeps the picker's per-block vectors between runs
|
|
25
27
|
* @typedef {import('./build.type.mjs').BuildKitResponse} BuildAnswer
|
|
26
28
|
*/
|
|
27
29
|
|
|
@@ -35,7 +37,12 @@ const main = defineSearcher({
|
|
|
35
37
|
run: async (request, ctx) => {
|
|
36
38
|
const signals = await kitSignals(request.query, request.options);
|
|
37
39
|
if (!ctx.blocks) return kitAnswer(signals);
|
|
38
|
-
const picked = pickBlocks(
|
|
40
|
+
const picked = pickBlocks(
|
|
41
|
+
request.query,
|
|
42
|
+
signals,
|
|
43
|
+
ctx.blocks,
|
|
44
|
+
ctx.keepBlocks,
|
|
45
|
+
);
|
|
39
46
|
return kitAnswer(signals, picked.names, picked.entries);
|
|
40
47
|
},
|
|
41
48
|
});
|
|
@@ -248,6 +248,7 @@ export function readBuiltPath(target: string, { fileLimit }?: {
|
|
|
248
248
|
export function builtIntegrationPackages(target: string, cwd: string): string[];
|
|
249
249
|
export { placeholderFixes } from "../../foundation/discovery/template-icons.mjs";
|
|
250
250
|
export { unlistedIconSets } from "../../foundation/discovery/icon-set-discovery.mjs";
|
|
251
|
+
export { installCommandFor as packageInstallCommand } from "../../foundation/discovery/template-needs.mjs";
|
|
251
252
|
export { resolveRecordedTheme } from "../theme/theme.mjs";
|
|
252
253
|
export { collectUnloadedFonts } from "../theme/build/font-warning.mjs";
|
|
253
254
|
export const SOURCE_EXTENSIONS: Set<string>;
|
|
@@ -263,5 +264,5 @@ import { lastCheckFailure } from '../../foundation/release/global-state.mjs';
|
|
|
263
264
|
import { stateLockHolder } from '../../foundation/release/global-state.mjs';
|
|
264
265
|
import { displayHomePath } from '../../foundation/agent-docs/computer-agent-text.mjs';
|
|
265
266
|
export { isLocalThemeOwner, planThemeAppWrite, readThemeState, resolveThemeModule } from "../../foundation/config/theme-state.mjs";
|
|
266
|
-
export { themeBuild, validateThemePrivateInputs } from "../theme/build/build.mjs";
|
|
267
|
+
export { missingThemePackage, themeBuild, validateThemePrivateInputs } from "../theme/build/build.mjs";
|
|
267
268
|
export { AUTHORING_AUDIT, authoringAudit, authoringAuditData } from "./_authoring-audit.mjs";
|
package/api/doctor/_adapter.mjs
CHANGED
|
@@ -66,7 +66,12 @@ export {
|
|
|
66
66
|
readThemeState,
|
|
67
67
|
resolveThemeModule,
|
|
68
68
|
} from '../../foundation/config/theme-state.mjs';
|
|
69
|
-
export {
|
|
69
|
+
export {
|
|
70
|
+
missingThemePackage,
|
|
71
|
+
themeBuild,
|
|
72
|
+
validateThemePrivateInputs,
|
|
73
|
+
} from '../theme/build/build.mjs';
|
|
74
|
+
export {installCommandFor as packageInstallCommand} from '../../foundation/discovery/template-needs.mjs';
|
|
70
75
|
export {resolveRecordedTheme} from '../theme/theme.mjs';
|
|
71
76
|
export {collectUnloadedFonts} from '../theme/build/font-warning.mjs';
|
|
72
77
|
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -2190,9 +2190,9 @@ export function checkGatherCache() {
|
|
|
2190
2190
|
const size = `${(summary.bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
2191
2191
|
return {
|
|
2192
2192
|
id: 'gather-cache',
|
|
2193
|
-
label: '
|
|
2193
|
+
label: 'Kept catalog cache',
|
|
2194
2194
|
status: 'info',
|
|
2195
|
-
message: `search and
|
|
2195
|
+
message: `search, build, component, template, theme and discover keep what they gather (search's catalogs and each integration's check results) in ${summary.dir} (${summary.entries} ${summary.entries === 1 ? 'entry' : 'entries'}, ${size})${summary.pnp ? ", but not in a run under Yarn Plug'n'Play's loader, such as `yarn astryx`, which gathers every time" : ''}; each is used only while nothing it read has changed, and deleting the folder clears it.`,
|
|
2196
2196
|
};
|
|
2197
2197
|
}
|
|
2198
2198
|
|
|
@@ -31,6 +31,8 @@ import {
|
|
|
31
31
|
resolveRecordedTheme,
|
|
32
32
|
resolveThemeModule,
|
|
33
33
|
SOURCE_EXTENSIONS,
|
|
34
|
+
missingThemePackage,
|
|
35
|
+
packageInstallCommand,
|
|
34
36
|
themeBuild,
|
|
35
37
|
themeRecordOwner,
|
|
36
38
|
validateThemePrivateInputs,
|
|
@@ -1083,6 +1085,8 @@ export async function checkAppThemes(cwd) {
|
|
|
1083
1085
|
});
|
|
1084
1086
|
} else {
|
|
1085
1087
|
const stale = [];
|
|
1088
|
+
/** @type {Map<string, string[]>} theme slugs by the package they import and the app lacks */
|
|
1089
|
+
const missingPackages = new Map();
|
|
1086
1090
|
const previousSilent = logger.silent;
|
|
1087
1091
|
logger.setSilent(true);
|
|
1088
1092
|
try {
|
|
@@ -1106,38 +1110,69 @@ export async function checkAppThemes(cwd) {
|
|
|
1106
1110
|
) {
|
|
1107
1111
|
stale.push(theme.slug);
|
|
1108
1112
|
}
|
|
1109
|
-
} catch {
|
|
1110
|
-
|
|
1113
|
+
} catch (error) {
|
|
1114
|
+
const missing = missingThemePackage(error);
|
|
1115
|
+
if (missing) {
|
|
1116
|
+
missingPackages.set(missing, [
|
|
1117
|
+
...(missingPackages.get(missing) ?? []),
|
|
1118
|
+
theme.slug,
|
|
1119
|
+
]);
|
|
1120
|
+
} else {
|
|
1121
|
+
stale.push(theme.slug);
|
|
1122
|
+
}
|
|
1111
1123
|
}
|
|
1112
1124
|
}
|
|
1113
1125
|
} finally {
|
|
1114
1126
|
logger.setSilent(previousSilent);
|
|
1115
1127
|
}
|
|
1128
|
+
const packages = [...missingPackages.keys()];
|
|
1129
|
+
const install =
|
|
1130
|
+
packages.length > 0
|
|
1131
|
+
? packageInstallCommand(packages, state.projectDir)
|
|
1132
|
+
: null;
|
|
1133
|
+
const refresh = stale.map(slug =>
|
|
1134
|
+
refreshThemeCommand(
|
|
1135
|
+
state.projectDir,
|
|
1136
|
+
run,
|
|
1137
|
+
available,
|
|
1138
|
+
slug,
|
|
1139
|
+
state.themes[slug],
|
|
1140
|
+
),
|
|
1141
|
+
);
|
|
1116
1142
|
checks.push(
|
|
1117
|
-
|
|
1143
|
+
packages.length > 0
|
|
1118
1144
|
? {
|
|
1119
1145
|
id: 'theme-local-builds',
|
|
1120
1146
|
label: 'Local theme build freshness',
|
|
1121
1147
|
status: 'fail',
|
|
1122
|
-
message: `Local
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1148
|
+
message: `Local themes import packages the app does not have installed, so they cannot build: ${[
|
|
1149
|
+
...missingPackages,
|
|
1150
|
+
]
|
|
1151
|
+
.map(([pkg, slugs]) => `${pkg} (${slugs.join(', ')})`)
|
|
1152
|
+
.join(
|
|
1153
|
+
'; ',
|
|
1154
|
+
)}.${stale.length > 0 ? ` Local theme outputs are also missing or stale: ${stale.join(', ')}.` : ''}`,
|
|
1155
|
+
fix: [
|
|
1156
|
+
install?.installCommand ??
|
|
1157
|
+
install?.noCommandReason ??
|
|
1158
|
+
`Install ${packages.join(', ')}.`,
|
|
1159
|
+
...refresh,
|
|
1160
|
+
].join(' '),
|
|
1134
1161
|
}
|
|
1135
|
-
:
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1162
|
+
: stale.length > 0
|
|
1163
|
+
? {
|
|
1164
|
+
id: 'theme-local-builds',
|
|
1165
|
+
label: 'Local theme build freshness',
|
|
1166
|
+
status: 'fail',
|
|
1167
|
+
message: `Local theme outputs are missing or stale: ${stale.join(', ')}.`,
|
|
1168
|
+
fix: refresh.join(' '),
|
|
1169
|
+
}
|
|
1170
|
+
: {
|
|
1171
|
+
id: 'theme-local-builds',
|
|
1172
|
+
label: 'Local theme build freshness',
|
|
1173
|
+
status: 'pass',
|
|
1174
|
+
message: 'Every added local theme output matches its source.',
|
|
1175
|
+
},
|
|
1141
1176
|
);
|
|
1142
1177
|
}
|
|
1143
1178
|
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* same transaction. Side-effect-free outside of {@link applyWrites}.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import {stillHolds} from '../../foundation/release/folder-lock.mjs';
|
|
15
16
|
import * as fs from 'node:fs';
|
|
16
17
|
import * as path from 'node:path';
|
|
17
18
|
import {randomUUID} from 'node:crypto';
|
|
@@ -376,6 +377,10 @@ export function applyWrites(plans) {
|
|
|
376
377
|
staged.push({...plan, temporary, original, mode});
|
|
377
378
|
}
|
|
378
379
|
|
|
380
|
+
// Under a folder lock (the theme editor's), a run that lost the lock
|
|
381
|
+
// while it was stopped publishes nothing. Outside a lock this does
|
|
382
|
+
// nothing.
|
|
383
|
+
stillHolds();
|
|
379
384
|
for (const plan of staged) {
|
|
380
385
|
if (plan.original == null) {
|
|
381
386
|
publishNewFile(plan.temporary, plan.path);
|
|
@@ -18,7 +18,6 @@ import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
|
18
18
|
import {
|
|
19
19
|
assertWithin,
|
|
20
20
|
PathSafetyError,
|
|
21
|
-
sanitizeName,
|
|
22
21
|
} from '../../foundation/fs/path-safety.mjs';
|
|
23
22
|
import {
|
|
24
23
|
discoverBundledThemes,
|
|
@@ -46,47 +45,14 @@ import {
|
|
|
46
45
|
projectPath,
|
|
47
46
|
} from './add-helpers.mjs';
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
import {
|
|
49
|
+
renameDefinedTheme,
|
|
50
|
+
renameThemeFile,
|
|
51
|
+
rewriteThemeSource,
|
|
52
|
+
themeIdentity,
|
|
53
|
+
} from '../theme/_fork.mjs';
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
function themeIdentity(slug) {
|
|
53
|
-
try {
|
|
54
|
-
sanitizeName(slug, {label: 'theme name'});
|
|
55
|
-
} catch (error) {
|
|
56
|
-
if (error instanceof PathSafetyError) {
|
|
57
|
-
throw new AstryxError(
|
|
58
|
-
error.message,
|
|
59
|
-
undefined,
|
|
60
|
-
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
if (!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(slug)) {
|
|
66
|
-
throw new AstryxError(
|
|
67
|
-
`Invalid theme name "${slug}": use lowercase kebab-case starting with a letter.`,
|
|
68
|
-
undefined,
|
|
69
|
-
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
const identifier = slug.replace(/-([a-z0-9])/gu, (_, character) =>
|
|
73
|
-
character.toUpperCase(),
|
|
74
|
-
);
|
|
75
|
-
const displayName = slug
|
|
76
|
-
.split('-')
|
|
77
|
-
.map(part =>
|
|
78
|
-
part === 'y2k' ? 'Y2K' : part[0].toUpperCase() + part.slice(1),
|
|
79
|
-
)
|
|
80
|
-
.join(' ');
|
|
81
|
-
return {
|
|
82
|
-
slug,
|
|
83
|
-
identifier,
|
|
84
|
-
displayName,
|
|
85
|
-
exportName: `${identifier}Theme`,
|
|
86
|
-
entry: `${identifier}Theme.ts`,
|
|
87
|
-
descriptor: `${identifier}Theme.doc.mjs`,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
55
|
+
const DEFAULT_THEMES_ROOT = './themes';
|
|
90
56
|
|
|
91
57
|
/** @param {{slug: string, exportName: string}} identity */
|
|
92
58
|
function themeSource(identity) {
|
|
@@ -129,7 +95,10 @@ function resolveBaseTheme(slug, packageDir, owner, themesRoot) {
|
|
|
129
95
|
// Also check the package's own themes root.
|
|
130
96
|
if (themesRoot && fs.existsSync(themesRoot)) {
|
|
131
97
|
try {
|
|
132
|
-
candidates = [
|
|
98
|
+
candidates = [
|
|
99
|
+
...candidates,
|
|
100
|
+
...discoverThemeDirectory(themesRoot, owner),
|
|
101
|
+
];
|
|
133
102
|
} catch {
|
|
134
103
|
// A broken local root is not the caller's problem here.
|
|
135
104
|
}
|
|
@@ -149,74 +118,6 @@ function resolveBaseTheme(slug, packageDir, owner, themesRoot) {
|
|
|
149
118
|
return match;
|
|
150
119
|
}
|
|
151
120
|
|
|
152
|
-
/**
|
|
153
|
-
* Rename a file from the base theme's namespace to the new theme's namespace.
|
|
154
|
-
* Files whose name starts with the base identifier get the new identifier;
|
|
155
|
-
* others keep their name as-is.
|
|
156
|
-
* @param {string} file POSIX relative path inside the theme directory
|
|
157
|
-
* @param {string} baseIdentifier
|
|
158
|
-
* @param {string} newIdentifier
|
|
159
|
-
* @returns {string}
|
|
160
|
-
*/
|
|
161
|
-
function renameThemeFile(file, baseIdentifier, newIdentifier) {
|
|
162
|
-
const basename = path.posix.basename(file);
|
|
163
|
-
const dir = path.posix.dirname(file);
|
|
164
|
-
if (!basename.startsWith(baseIdentifier)) return file;
|
|
165
|
-
const renamed = newIdentifier + basename.slice(baseIdentifier.length);
|
|
166
|
-
return dir === '.' ? renamed : `${dir}/${renamed}`;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Rewrite a source file's contents from the base theme's names to the new
|
|
171
|
-
* theme's names. This replaces:
|
|
172
|
-
* 1. Identifier prefixes (camelCase variables, import paths): baseIdentifier
|
|
173
|
-
* followed by an uppercase letter.
|
|
174
|
-
* 2. The theme slug in string literals: 'baseSlug' → 'newSlug' and
|
|
175
|
-
* 'astryx-baseSlug' → 'astryx-newSlug'.
|
|
176
|
-
* 3. CSS custom properties scoped to the theme: --astryx-theme-baseSlug-.
|
|
177
|
-
* @param {string} source
|
|
178
|
-
* @param {string} baseSlug
|
|
179
|
-
* @param {string} baseIdentifier
|
|
180
|
-
* @param {string} newSlug
|
|
181
|
-
* @param {string} newIdentifier
|
|
182
|
-
* @returns {string}
|
|
183
|
-
*/
|
|
184
|
-
function rewriteThemeSource(
|
|
185
|
-
source,
|
|
186
|
-
baseSlug,
|
|
187
|
-
baseIdentifier,
|
|
188
|
-
newSlug,
|
|
189
|
-
newIdentifier,
|
|
190
|
-
) {
|
|
191
|
-
let result = source;
|
|
192
|
-
// 1. Identifier prefixes: neutralPalettes → oceanPalettes, neutralTheme → oceanTheme
|
|
193
|
-
const identRe = new RegExp(`${escapeRegExp(baseIdentifier)}(?=[A-Z])`, 'gu');
|
|
194
|
-
result = result.replace(identRe, newIdentifier);
|
|
195
|
-
// 2. String-literal theme names
|
|
196
|
-
result = result.replace(
|
|
197
|
-
new RegExp(`'astryx-${escapeRegExp(baseSlug)}'`, 'gu'),
|
|
198
|
-
`'astryx-${newSlug}'`,
|
|
199
|
-
);
|
|
200
|
-
result = result.replace(
|
|
201
|
-
new RegExp(`'${escapeRegExp(baseSlug)}'`, 'gu'),
|
|
202
|
-
`'${newSlug}'`,
|
|
203
|
-
);
|
|
204
|
-
// 3. CSS custom properties scoped to the base theme
|
|
205
|
-
result = result.replace(
|
|
206
|
-
new RegExp(
|
|
207
|
-
`--astryx-theme-${escapeRegExp(baseSlug)}-`,
|
|
208
|
-
'gu',
|
|
209
|
-
),
|
|
210
|
-
`--astryx-theme-${newSlug}-`,
|
|
211
|
-
);
|
|
212
|
-
return result;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/** @param {string} s */
|
|
216
|
-
function escapeRegExp(s) {
|
|
217
|
-
return s.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&');
|
|
218
|
-
}
|
|
219
|
-
|
|
220
121
|
/** What every app that uses Astryx already has: Core, and React through Core's peers. */
|
|
221
122
|
const APP_PROVIDED = new Set(['@astryxdesign/core', 'react', 'react-dom']);
|
|
222
123
|
|
|
@@ -332,6 +233,10 @@ function forkThemePlans(base, identity, themeDir) {
|
|
|
332
233
|
identity.slug,
|
|
333
234
|
identity.identifier,
|
|
334
235
|
);
|
|
236
|
+
// The entry's defineTheme name, wherever it sits (a double-quoted name,
|
|
237
|
+
// one after `extends`), is the fork's, as the build names its files.
|
|
238
|
+
if (file === base.files[0])
|
|
239
|
+
contents = renameDefinedTheme(contents, identity.slug) ?? contents;
|
|
335
240
|
} else {
|
|
336
241
|
contents = bytes;
|
|
337
242
|
}
|