@astryxdesign/cli 0.7.17-canary.g49a475f → 0.7.17-canary.g5e463b2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/theme/build/build.d.mts +40 -4
- package/api/theme/build/build.mjs +102 -21
- package/api/theme/build/core-interception.d.mts +10 -0
- package/api/theme/build/core-interception.mjs +10 -0
- package/api/theme/build/font-warning.d.mts +6 -2
- package/api/theme/build/font-warning.mjs +15 -4
- package/api/theme-edit/_adapter.d.mts +28 -0
- package/api/theme-edit/_adapter.mjs +139 -24
- package/api/theme-edit/_catalog.mjs +19 -4
- package/api/theme-edit/_check.d.mts +9 -2
- package/api/theme-edit/_check.mjs +433 -134
- package/api/theme-edit/_compiler.mjs +8 -0
- package/api/theme-edit/_context.mjs +18 -0
- package/api/theme-edit/_edit.d.mts +3 -1
- package/api/theme-edit/_edit.mjs +517 -178
- package/api/theme-edit/_how-commands.d.mts +7 -1
- package/api/theme-edit/_how-commands.mjs +65 -5
- package/api/theme-edit/_how-question.d.mts +0 -7
- package/api/theme-edit/_how-question.mjs +641 -268
- package/api/theme-edit/_how.d.mts +2 -1
- package/api/theme-edit/_how.mjs +93 -14
- package/api/theme-edit/_normal.d.mts +22 -9
- package/api/theme-edit/_normal.mjs +143 -50
- package/api/theme-edit/_part-words.d.mts +31 -0
- package/api/theme-edit/_part-words.mjs +126 -0
- package/api/theme-edit/_parts.d.mts +1 -1
- package/api/theme-edit/_parts.mjs +63 -22
- package/api/theme-edit/_preview-app.mjs +194 -38
- package/api/theme-edit/_preview.mjs +29 -0
- package/api/theme-edit/_settings.d.mts +87 -38
- package/api/theme-edit/_settings.mjs +464 -265
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/experimental/theme.mjs +88 -14
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +158 -57
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/discovery/theme-discovery.mjs +28 -2
- package/foundation/fs/gather-cache.d.mts +37 -0
- package/foundation/fs/gather-cache.mjs +324 -27
- package/foundation/fs/read-record.d.mts +9 -0
- package/foundation/fs/read-record.mjs +19 -11
- package/package.json +6 -6
|
@@ -181,18 +181,40 @@ export function importSpecifier(relDir: string, base: string): string;
|
|
|
181
181
|
/**
|
|
182
182
|
* Load a theme module as a standalone build of it loads it (the Core the
|
|
183
183
|
* build selects, the same loader and interception) and name the export the
|
|
184
|
-
* build reads
|
|
185
|
-
*
|
|
184
|
+
* build reads, with the theme its definition extends (`parent`, the exact
|
|
185
|
+
* authored `extends` value, after every spread and repeated key). Callers
|
|
186
|
+
* that must agree with the build on which theme a module defines read it
|
|
187
|
+
* here, never from the module's text.
|
|
186
188
|
* @param {string} file
|
|
187
189
|
* @param {{cwd?: string}} [ctx]
|
|
188
|
-
* @returns {Promise<{theme: any, exportName: string}>}
|
|
190
|
+
* @returns {Promise<{theme: any, exportName: string, parent: any}>}
|
|
189
191
|
*/
|
|
190
192
|
export function loadThemeExport(file: string, { cwd }?: {
|
|
191
193
|
cwd?: string;
|
|
192
194
|
}): Promise<{
|
|
193
195
|
theme: any;
|
|
194
196
|
exportName: string;
|
|
197
|
+
parent: any;
|
|
195
198
|
}>;
|
|
199
|
+
/**
|
|
200
|
+
* The input a theme module gives `defineTheme()` for the theme a build of
|
|
201
|
+
* it reads, evaluated as the build evaluates the module (an import, an
|
|
202
|
+
* expression, a spread or a computed key is its value), with the theme Core
|
|
203
|
+
* made of it. When Core refuses the input, the input the module gave for
|
|
204
|
+
* the named theme (else its last) and Core's error; null when the module
|
|
205
|
+
* does not load at all.
|
|
206
|
+
* @param {string} file
|
|
207
|
+
* @param {{cwd?: string, name?: string}} [ctx]
|
|
208
|
+
* @returns {Promise<{input: any, theme: any, error: Error | null} | null>}
|
|
209
|
+
*/
|
|
210
|
+
export function loadThemeInput(file: string, { cwd, name }?: {
|
|
211
|
+
cwd?: string;
|
|
212
|
+
name?: string;
|
|
213
|
+
}): Promise<{
|
|
214
|
+
input: any;
|
|
215
|
+
theme: any;
|
|
216
|
+
error: Error | null;
|
|
217
|
+
} | null>;
|
|
196
218
|
/**
|
|
197
219
|
* A one-mode `colorModes` value (`['light']` or `['dark']`), or null for
|
|
198
220
|
* anything else: a theme with both modes needs no export.
|
|
@@ -417,9 +439,13 @@ export type ThemeBuildTrailer = {
|
|
|
417
439
|
*/
|
|
418
440
|
unloadedFonts: string[];
|
|
419
441
|
/**
|
|
420
|
-
* One notice per unloaded font family.
|
|
442
|
+
* One notice per unloaded font family, as printed.
|
|
421
443
|
*/
|
|
422
444
|
fontNotices: string[];
|
|
445
|
+
/**
|
|
446
|
+
* How the caller loads fonts, when it does.
|
|
447
|
+
*/
|
|
448
|
+
fontHelp?: FontHelp | null | undefined;
|
|
423
449
|
};
|
|
424
450
|
/**
|
|
425
451
|
* What the CLI hands a build beyond themeBuild's options. CLI-internal, never
|
|
@@ -448,5 +474,15 @@ export type ThemeBuildHandOff = {
|
|
|
448
474
|
build: string;
|
|
449
475
|
};
|
|
450
476
|
colorModes?: ["light"] | ["dark"] | null;
|
|
477
|
+
fontHelp?: FontHelp | null;
|
|
478
|
+
};
|
|
479
|
+
/**
|
|
480
|
+
* How a caller that loads a theme's fonts itself (the editor's app copy)
|
|
481
|
+
* says to load a family: the notice per family and the recipe in place of
|
|
482
|
+
* the generic one.
|
|
483
|
+
*/
|
|
484
|
+
export type FontHelp = {
|
|
485
|
+
notice: (family: string) => string;
|
|
486
|
+
recipe: (families: string[]) => string;
|
|
451
487
|
};
|
|
452
488
|
import { AstryxError } from '../../error.mjs';
|
|
@@ -329,7 +329,9 @@ function importTarget(dir, subpath) {
|
|
|
329
329
|
/** @param {string} file @returns {string} its real path, or itself */
|
|
330
330
|
function realOrSelf(file) {
|
|
331
331
|
try {
|
|
332
|
-
|
|
332
|
+
// The native form spells a path as the disk does (its own case on a
|
|
333
|
+
// case-insensitive disk), so two spellings of one file compare equal.
|
|
334
|
+
return fs.realpathSync.native(file);
|
|
333
335
|
} catch {
|
|
334
336
|
return file;
|
|
335
337
|
}
|
|
@@ -1206,7 +1208,14 @@ function assertThemeSourceFile(filePath, cwd, mode = {}) {
|
|
|
1206
1208
|
* `familyInterception` make the build a family member's plan.
|
|
1207
1209
|
* `colorModes` is the one color mode a calling command knows the theme has
|
|
1208
1210
|
* (the theme editor, from its settings), written into the built module.
|
|
1209
|
-
* @typedef {{prepareFamily?: boolean, familyLoader?: any, familyInterception?: any, writeRoot?: string, claimedOutputs?: Map<string, string>, deferredWrites?: Array<Array<{dest: string, content: string}>>, commandWords?: {group: string, build: string}, colorModes?: ['light'] | ['dark'] | null}} ThemeBuildHandOff
|
|
1211
|
+
* @typedef {{prepareFamily?: boolean, familyLoader?: any, familyInterception?: any, writeRoot?: string, claimedOutputs?: Map<string, string>, deferredWrites?: Array<Array<{dest: string, content: string}>>, commandWords?: {group: string, build: string}, colorModes?: ['light'] | ['dark'] | null, fontHelp?: FontHelp | null}} ThemeBuildHandOff
|
|
1212
|
+
*/
|
|
1213
|
+
|
|
1214
|
+
/**
|
|
1215
|
+
* How a caller that loads a theme's fonts itself (the editor's app copy)
|
|
1216
|
+
* says to load a family: the notice per family and the recipe in place of
|
|
1217
|
+
* the generic one.
|
|
1218
|
+
* @typedef {{notice: (family: string) => string, recipe: (families: string[]) => string}} FontHelp
|
|
1210
1219
|
*/
|
|
1211
1220
|
|
|
1212
1221
|
/**
|
|
@@ -2763,7 +2772,7 @@ function isSyncLoaderLimitation(error) {
|
|
|
2763
2772
|
* @returns {Promise<{theme: any, exportName: string, degraded: {topLevelAwait: boolean, commonJs: boolean}, colorModes: ["light"] | ["dark"] | null}>}
|
|
2764
2773
|
*/
|
|
2765
2774
|
// prettier-ignore
|
|
2766
|
-
async function importThemeModule(filePath, interception, /** @type {any} */ loader = undefined) {
|
|
2775
|
+
async function importThemeModule(filePath, interception, /** @type {any} */ loader = undefined, /** @type {string | undefined} */ pick = undefined) {
|
|
2767
2776
|
const jiti =
|
|
2768
2777
|
loader ??
|
|
2769
2778
|
createJiti(import.meta.url, {
|
|
@@ -2830,6 +2839,12 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
2830
2839
|
);
|
|
2831
2840
|
const hasDefault = isModule && Object.hasOwn(mod, 'default');
|
|
2832
2841
|
const defaultExport = hasDefault ? mod.default : undefined;
|
|
2842
|
+
// A caller that already knows which export a build reads (from a load
|
|
2843
|
+
// as the build loads it) reads that one.
|
|
2844
|
+
if (pick !== undefined && isModule && Object.hasOwn(mod, pick)) {
|
|
2845
|
+
if (isThemeObject(mod[pick]))
|
|
2846
|
+
return {theme: mod[pick], exportName: pick, degraded, colorModes};
|
|
2847
|
+
}
|
|
2833
2848
|
if (isThemeObject(defaultExport)) {
|
|
2834
2849
|
return {theme: defaultExport, exportName: 'default', degraded, colorModes};
|
|
2835
2850
|
}
|
|
@@ -2940,9 +2955,9 @@ function isThemeObject(value) {
|
|
|
2940
2955
|
* @returns {Promise<{theme: any, exportName?: string, degraded: {topLevelAwait: boolean, commonJs: boolean}, colorModes?: ['light'] | ['dark'] | null}>}
|
|
2941
2956
|
*/
|
|
2942
2957
|
// prettier-ignore
|
|
2943
|
-
async function extractThemeDefinition(filePath, interception, /** @type {any} */ loader = undefined) {
|
|
2958
|
+
async function extractThemeDefinition(filePath, interception, /** @type {any} */ loader = undefined, /** @type {string | undefined} */ pick = undefined) {
|
|
2944
2959
|
try {
|
|
2945
|
-
return await importThemeModule(filePath, interception, loader);
|
|
2960
|
+
return await importThemeModule(filePath, interception, loader, pick);
|
|
2946
2961
|
} catch (jitiError) {
|
|
2947
2962
|
const je = /** @type {Error} */ (jitiError);
|
|
2948
2963
|
throw new Error(
|
|
@@ -2968,20 +2983,61 @@ function standaloneInterception(filePath) {
|
|
|
2968
2983
|
/**
|
|
2969
2984
|
* Load a theme module as a standalone build of it loads it (the Core the
|
|
2970
2985
|
* build selects, the same loader and interception) and name the export the
|
|
2971
|
-
* build reads
|
|
2972
|
-
*
|
|
2986
|
+
* build reads, with the theme its definition extends (`parent`, the exact
|
|
2987
|
+
* authored `extends` value, after every spread and repeated key). Callers
|
|
2988
|
+
* that must agree with the build on which theme a module defines read it
|
|
2989
|
+
* here, never from the module's text.
|
|
2973
2990
|
* @param {string} file
|
|
2974
2991
|
* @param {{cwd?: string}} [ctx]
|
|
2975
|
-
* @returns {Promise<{theme: any, exportName: string}>}
|
|
2992
|
+
* @returns {Promise<{theme: any, exportName: string, parent: any}>}
|
|
2976
2993
|
*/
|
|
2977
2994
|
export async function loadThemeExport(file, {cwd = process.cwd()} = {}) {
|
|
2978
2995
|
const filePath = path.resolve(cwd, file);
|
|
2979
2996
|
await selectCore(cwd, {projectOnly: false});
|
|
2980
|
-
const
|
|
2997
|
+
const interception = standaloneInterception(filePath);
|
|
2998
|
+
const {theme, exportName = 'default'} = await extractThemeDefinition(
|
|
2981
2999
|
filePath,
|
|
2982
|
-
|
|
3000
|
+
interception,
|
|
2983
3001
|
);
|
|
2984
|
-
|
|
3002
|
+
if (interception)
|
|
3003
|
+
return {theme, exportName, parent: interception.parentOf(theme)};
|
|
3004
|
+
// A build without interception records no parent: the same export is
|
|
3005
|
+
// read again through a recorder.
|
|
3006
|
+
const recorder = interceptCore(_coreThemeModule, _coreRootModule);
|
|
3007
|
+
const again = await extractThemeDefinition(
|
|
3008
|
+
filePath,
|
|
3009
|
+
recorder,
|
|
3010
|
+
undefined,
|
|
3011
|
+
exportName,
|
|
3012
|
+
);
|
|
3013
|
+
return {theme, exportName, parent: recorder.parentOf(again.theme)};
|
|
3014
|
+
}
|
|
3015
|
+
|
|
3016
|
+
/**
|
|
3017
|
+
* The input a theme module gives `defineTheme()` for the theme a build of
|
|
3018
|
+
* it reads, evaluated as the build evaluates the module (an import, an
|
|
3019
|
+
* expression, a spread or a computed key is its value), with the theme Core
|
|
3020
|
+
* made of it. When Core refuses the input, the input the module gave for
|
|
3021
|
+
* the named theme (else its last) and Core's error; null when the module
|
|
3022
|
+
* does not load at all.
|
|
3023
|
+
* @param {string} file
|
|
3024
|
+
* @param {{cwd?: string, name?: string}} [ctx]
|
|
3025
|
+
* @returns {Promise<{input: any, theme: any, error: Error | null} | null>}
|
|
3026
|
+
*/
|
|
3027
|
+
export async function loadThemeInput(file, {cwd = process.cwd(), name} = {}) {
|
|
3028
|
+
const filePath = path.resolve(cwd, file);
|
|
3029
|
+
await selectCore(cwd, {projectOnly: false});
|
|
3030
|
+
const interception = interceptCore(_coreThemeModule, _coreRootModule);
|
|
3031
|
+
try {
|
|
3032
|
+
const {theme} = await extractThemeDefinition(filePath, interception);
|
|
3033
|
+
return {input: interception.inputOf(theme) ?? null, theme, error: null};
|
|
3034
|
+
} catch (e) {
|
|
3035
|
+
const given = interception.inputs;
|
|
3036
|
+
const input =
|
|
3037
|
+
given.filter(x => x && typeof x === 'object' && x.name === name).at(-1) ??
|
|
3038
|
+
given.at(-1);
|
|
3039
|
+
return input ? {input, theme: null, error: /** @type {Error} */ (e)} : null;
|
|
3040
|
+
}
|
|
2985
3041
|
}
|
|
2986
3042
|
|
|
2987
3043
|
/**
|
|
@@ -4822,12 +4878,19 @@ async function themeBuildInternal(
|
|
|
4822
4878
|
// permanently in violation of its own "compiles with no warnings" guard).
|
|
4823
4879
|
// Adaptation rules are resolved theme writes in their own right, so a family
|
|
4824
4880
|
// named only inside one needs the same notice as one named at the root.
|
|
4881
|
+
// The result names the recipe's command bare, as every machine-read
|
|
4882
|
+
// command is; the printed note starts it the way this project runs the CLI.
|
|
4883
|
+
/** @param {string} family @param {string} recipe */
|
|
4884
|
+
const fontNotice = (family, recipe) =>
|
|
4885
|
+
handOff.fontHelp?.notice(family) ??
|
|
4886
|
+
`Font "${family}" is named by this theme but not loaded; add a <link> or @font-face in your app (recipe: ${recipe})`;
|
|
4825
4887
|
/** @type {string[]} */
|
|
4826
4888
|
const fontNotices = [];
|
|
4827
4889
|
for (const family of unloadedFonts) {
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4890
|
+
noticeMessages.push(fontNotice(family, 'astryx docs typography'));
|
|
4891
|
+
fontNotices.push(
|
|
4892
|
+
fontNotice(family, formatCliCommand('docs typography', cwd)),
|
|
4893
|
+
);
|
|
4831
4894
|
}
|
|
4832
4895
|
|
|
4833
4896
|
/** @type {ThemeBuildTrailer} */
|
|
@@ -4838,6 +4901,7 @@ async function themeBuildInternal(
|
|
|
4838
4901
|
cssImport,
|
|
4839
4902
|
unloadedFonts,
|
|
4840
4903
|
fontNotices,
|
|
4904
|
+
fontHelp: handOff.fontHelp ?? null,
|
|
4841
4905
|
};
|
|
4842
4906
|
// A batch or compact report prints this once for the whole run instead.
|
|
4843
4907
|
if (report.trailers) report.trailers.push(trailer);
|
|
@@ -4874,7 +4938,8 @@ async function themeBuildInternal(
|
|
|
4874
4938
|
* @property {string} jsImport Import specifier of the built JS module.
|
|
4875
4939
|
* @property {string} cssImport Import specifier of the built CSS.
|
|
4876
4940
|
* @property {string[]} unloadedFonts Font families the theme names but does not load.
|
|
4877
|
-
* @property {string[]} fontNotices One notice per unloaded font family.
|
|
4941
|
+
* @property {string[]} fontNotices One notice per unloaded font family, as printed.
|
|
4942
|
+
* @property {FontHelp | null} [fontHelp] How the caller loads fonts, when it does.
|
|
4878
4943
|
*/
|
|
4879
4944
|
|
|
4880
4945
|
/**
|
|
@@ -4905,7 +4970,13 @@ Or with a <link> tag:
|
|
|
4905
4970
|
`);
|
|
4906
4971
|
for (const msg of trailer.fontNotices) logger.log(` note: ${msg}`);
|
|
4907
4972
|
if (trailer.unloadedFonts.length > 0) {
|
|
4908
|
-
logger.log(
|
|
4973
|
+
logger.log(
|
|
4974
|
+
formatFontLoadingHelp(
|
|
4975
|
+
trailer.themeName,
|
|
4976
|
+
trailer.unloadedFonts,
|
|
4977
|
+
trailer.fontHelp?.recipe,
|
|
4978
|
+
),
|
|
4979
|
+
);
|
|
4909
4980
|
}
|
|
4910
4981
|
}
|
|
4911
4982
|
|
|
@@ -4948,7 +5019,10 @@ Or with a <link> tag:
|
|
|
4948
5019
|
}
|
|
4949
5020
|
}
|
|
4950
5021
|
const fonts = groupUnloadedFonts(trailers);
|
|
4951
|
-
|
|
5022
|
+
// One caller's recipe serves the batch only when every theme takes it.
|
|
5023
|
+
const help = trailers.every(t => t.fontHelp) ? trailers[0].fontHelp : null;
|
|
5024
|
+
if (fonts.length > 0)
|
|
5025
|
+
logger.log(formatBatchFontLoadingHelp(fonts, help?.recipe));
|
|
4952
5026
|
}
|
|
4953
5027
|
|
|
4954
5028
|
/**
|
|
@@ -5503,11 +5577,18 @@ Or load the same stylesheet natively:
|
|
|
5503
5577
|
const unloadedFonts = [
|
|
5504
5578
|
...new Set(members.flatMap(member => member.unloadedFonts)),
|
|
5505
5579
|
];
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5580
|
+
/** @param {string} family @param {string} recipe */
|
|
5581
|
+
const familyNotice = (family, recipe) =>
|
|
5582
|
+
`Font "${family}" is named by this theme family but not loaded; add a <link> or @font-face in your app (recipe: ${recipe})`;
|
|
5583
|
+
// The result names the command bare; the printed note as this project
|
|
5584
|
+
// runs the CLI.
|
|
5585
|
+
const notices = unloadedFonts.map(family =>
|
|
5586
|
+
familyNotice(family, 'astryx docs typography'),
|
|
5509
5587
|
);
|
|
5510
|
-
for (const
|
|
5588
|
+
for (const family of unloadedFonts)
|
|
5589
|
+
logger.log(
|
|
5590
|
+
` note: ${familyNotice(family, formatCliCommand('docs typography', cwd))}`,
|
|
5591
|
+
);
|
|
5511
5592
|
return {
|
|
5512
5593
|
type: 'theme.build',
|
|
5513
5594
|
data: {
|
|
@@ -57,6 +57,16 @@ export type CoreInterception = {
|
|
|
57
57
|
* - Exact authored `extends` value.
|
|
58
58
|
*/
|
|
59
59
|
parentOf: (theme: any) => any;
|
|
60
|
+
/**
|
|
61
|
+
* - The raw `defineTheme()` argument
|
|
62
|
+
* that produced a theme, or undefined.
|
|
63
|
+
*/
|
|
64
|
+
inputOf: (theme: any) => any;
|
|
65
|
+
/**
|
|
66
|
+
* - Every `defineTheme()` argument in call order,
|
|
67
|
+
* recorded before Core reads it, so an input Core refuses is seen too.
|
|
68
|
+
*/
|
|
69
|
+
inputs: any[];
|
|
60
70
|
/**
|
|
61
71
|
* - Every raw input that fed a
|
|
62
72
|
* theme, following its own `extends` chain and spread provenance.
|
|
@@ -95,6 +95,10 @@ const retainedLineageByReference = new WeakMap();
|
|
|
95
95
|
* @property {(theme: any) => boolean} observed - Whether authored input was captured.
|
|
96
96
|
* @property {(theme: any) => void} retain - Retain capture before stripping.
|
|
97
97
|
* @property {(theme: any) => any} parentOf - Exact authored `extends` value.
|
|
98
|
+
* @property {(theme: any) => any} inputOf - The raw `defineTheme()` argument
|
|
99
|
+
* that produced a theme, or undefined.
|
|
100
|
+
* @property {any[]} inputs - Every `defineTheme()` argument in call order,
|
|
101
|
+
* recorded before Core reads it, so an input Core refuses is seen too.
|
|
98
102
|
* @property {(theme: any) => any[]} lineageOf - Every raw input that fed a
|
|
99
103
|
* theme, following its own `extends` chain and spread provenance.
|
|
100
104
|
* @property {(theme: any) => any[]} unobservedIn - Lineage members this
|
|
@@ -243,6 +247,8 @@ function mergeGenerativeAxes(inherited, own) {
|
|
|
243
247
|
export function interceptCore(coreThemeModule, coreRootModule) {
|
|
244
248
|
/** @type {WeakMap<object, ThemeLineage>} */
|
|
245
249
|
const byReference = new WeakMap();
|
|
250
|
+
/** @type {any[]} */
|
|
251
|
+
const inputs = [];
|
|
246
252
|
|
|
247
253
|
/** @param {any} value @param {ThemeLineage} lineage */
|
|
248
254
|
const mark = (value, lineage) => {
|
|
@@ -281,6 +287,7 @@ export function interceptCore(coreThemeModule, coreRootModule) {
|
|
|
281
287
|
...namespace,
|
|
282
288
|
/** @param {any} input */
|
|
283
289
|
defineTheme(input) {
|
|
290
|
+
inputs.push(input);
|
|
284
291
|
const result = real.call(namespace, input);
|
|
285
292
|
mark(result, {input, result});
|
|
286
293
|
return result;
|
|
@@ -317,6 +324,9 @@ export function interceptCore(coreThemeModule, coreRootModule) {
|
|
|
317
324
|
|
|
318
325
|
return {
|
|
319
326
|
modules,
|
|
327
|
+
inputs,
|
|
328
|
+
// prettier-ignore
|
|
329
|
+
inputOf(theme) { return lineageFor(theme)?.input; },
|
|
320
330
|
|
|
321
331
|
// prettier-ignore
|
|
322
332
|
observed(theme) { return wasObserved(theme, byReference); },
|
|
@@ -42,17 +42,21 @@ export function collectUnloadedFonts(resolvedTheme: {
|
|
|
42
42
|
*
|
|
43
43
|
* @param {string} themeName
|
|
44
44
|
* @param {string[]} families
|
|
45
|
+
* @param {(families: string[]) => string} [recipe] the caller's own way to
|
|
46
|
+
* load them, in place of the generic recipe
|
|
45
47
|
* @returns {string}
|
|
46
48
|
*/
|
|
47
|
-
export function formatFontLoadingHelp(themeName: string, families: string[]): string;
|
|
49
|
+
export function formatFontLoadingHelp(themeName: string, families: string[], recipe?: (families: string[]) => string): string;
|
|
48
50
|
/**
|
|
49
51
|
* The same fix once for a batch build: each family the built themes name but
|
|
50
52
|
* do not load, with the themes that name it, then one recipe for all of them.
|
|
51
53
|
*
|
|
52
54
|
* @param {Array<{family: string, themes: string[]}>} entries
|
|
55
|
+
* @param {(families: string[]) => string} [recipe] the caller's own way to
|
|
56
|
+
* load them, in place of the generic recipe
|
|
53
57
|
* @returns {string}
|
|
54
58
|
*/
|
|
55
59
|
export function formatBatchFontLoadingHelp(entries: Array<{
|
|
56
60
|
family: string;
|
|
57
61
|
themes: string[];
|
|
58
|
-
}
|
|
62
|
+
}>, recipe?: (families: string[]) => string): string;
|
|
@@ -217,13 +217,19 @@ export function collectUnloadedFonts(resolvedTheme) {
|
|
|
217
217
|
*
|
|
218
218
|
* @param {string} themeName
|
|
219
219
|
* @param {string[]} families
|
|
220
|
+
* @param {(families: string[]) => string} [recipe] the caller's own way to
|
|
221
|
+
* load them, in place of the generic recipe
|
|
220
222
|
* @returns {string}
|
|
221
223
|
*/
|
|
222
|
-
export function formatFontLoadingHelp(
|
|
224
|
+
export function formatFontLoadingHelp(
|
|
225
|
+
themeName,
|
|
226
|
+
families,
|
|
227
|
+
recipe = fontLoadingRecipe,
|
|
228
|
+
) {
|
|
223
229
|
const named = families.map(f => `"${f}"`).join(', ');
|
|
224
230
|
return `
|
|
225
231
|
[note] Theme "${themeName}" names fonts it does not load: ${named}
|
|
226
|
-
${
|
|
232
|
+
${recipe(families)}`;
|
|
227
233
|
}
|
|
228
234
|
|
|
229
235
|
/**
|
|
@@ -231,16 +237,21 @@ ${fontLoadingRecipe(families)}`;
|
|
|
231
237
|
* do not load, with the themes that name it, then one recipe for all of them.
|
|
232
238
|
*
|
|
233
239
|
* @param {Array<{family: string, themes: string[]}>} entries
|
|
240
|
+
* @param {(families: string[]) => string} [recipe] the caller's own way to
|
|
241
|
+
* load them, in place of the generic recipe
|
|
234
242
|
* @returns {string}
|
|
235
243
|
*/
|
|
236
|
-
export function formatBatchFontLoadingHelp(
|
|
244
|
+
export function formatBatchFontLoadingHelp(
|
|
245
|
+
entries,
|
|
246
|
+
recipe = fontLoadingRecipe,
|
|
247
|
+
) {
|
|
237
248
|
const named = entries
|
|
238
249
|
.map(({family, themes}) => ` "${family}" (${themes.join(', ')})`)
|
|
239
250
|
.join('\n');
|
|
240
251
|
return `
|
|
241
252
|
[note] The built themes name fonts they do not load:
|
|
242
253
|
${named}
|
|
243
|
-
${
|
|
254
|
+
${recipe(entries.map(entry => entry.family))}`;
|
|
244
255
|
}
|
|
245
256
|
|
|
246
257
|
/**
|
|
@@ -67,6 +67,16 @@ export function editorCompileProblem(files: string[], { cwd, check, family, icon
|
|
|
67
67
|
iconsSpecifier?: string;
|
|
68
68
|
out?: string;
|
|
69
69
|
}): Promise<AstryxError | null>;
|
|
70
|
+
/**
|
|
71
|
+
* For `compile`, once its outputs are written: write each held editor
|
|
72
|
+
* theme's app copy now, and say per file what the write did (`appCopy` on
|
|
73
|
+
* a first write, `appCopyStale` when something keeps the copy behind), so
|
|
74
|
+
* the JSON result carries what the text says.
|
|
75
|
+
* @param {string[]} files
|
|
76
|
+
* @param {string} cwd
|
|
77
|
+
* @returns {Promise<Record<string, Record<string, unknown>>>}
|
|
78
|
+
*/
|
|
79
|
+
export function editorAfterBuild(files: string[], cwd: string): Promise<Record<string, Record<string, unknown>>>;
|
|
70
80
|
/**
|
|
71
81
|
* Hold the theme lock of every editor theme among the files while
|
|
72
82
|
* `compile` builds or checks them, so it never reads a change half
|
|
@@ -80,6 +90,24 @@ export function editorThemeHold(files: string[], { cwd, check, out }: {
|
|
|
80
90
|
check?: boolean;
|
|
81
91
|
out?: string;
|
|
82
92
|
}): Promise<() => Promise<void>>;
|
|
93
|
+
/**
|
|
94
|
+
* For `compile` of an editor theme's own source: how to load a family the
|
|
95
|
+
* build names, as the editor says it (the app copy imports a family's
|
|
96
|
+
* installed Fontsource package); null for any other file.
|
|
97
|
+
* @param {string} file the path as given
|
|
98
|
+
* @param {string} cwd
|
|
99
|
+
* @returns {import('../theme/build/build.mjs').FontHelp | null}
|
|
100
|
+
*/
|
|
101
|
+
export function editorFontHelp(file: string, cwd: string): import("../theme/build/build.mjs").FontHelp | null;
|
|
102
|
+
/**
|
|
103
|
+
* For `compile`: the path an editor theme's own file builds under when it
|
|
104
|
+
* was named through a link (its real path, which every output's header
|
|
105
|
+
* names and `--check` compares); null for any other file.
|
|
106
|
+
* @param {string} file the path as given
|
|
107
|
+
* @param {string} cwd
|
|
108
|
+
* @returns {string | null}
|
|
109
|
+
*/
|
|
110
|
+
export function editorSourcePath(file: string, cwd: string): string | null;
|
|
83
111
|
/**
|
|
84
112
|
* For `compile` of an editor theme: `appCopyStale` for its result data when
|
|
85
113
|
* the app copy is behind (the same line set and show give), or
|