@astryxdesign/cli 0.7.15 → 0.7.16-canary.g9b5ad42
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/doctor/_adapter.d.mts +17 -0
- package/api/doctor/_adapter.mjs +35 -0
- package/api/doctor/doctor.mjs +18 -4
- package/api/integration/validate-integration.mjs +1 -1
- package/api/theme/_adapter.d.mts +5 -2
- package/api/theme/_adapter.mjs +43 -12
- package/api/theme/build/build.d.mts +1 -21
- package/api/theme/build/build.mjs +149 -37
- package/api/theme/eject/eject.mjs +22 -1
- package/api/theme/template/template.d.mts +2 -0
- package/api/theme/template/template.mjs +41 -12
- package/api/theme/theme.type.d.mts +4 -0
- 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 +10 -0
- package/api/theme-edit/_adapter.mjs +76 -5
- package/api/theme-edit/_check.mjs +181 -50
- package/api/theme-edit/_color.d.mts +2 -8
- package/api/theme-edit/_color.mjs +126 -55
- package/api/theme-edit/_compiler.d.mts +1 -0
- package/api/theme-edit/_compiler.mjs +3 -0
- package/api/theme-edit/_context.d.mts +7 -0
- package/api/theme-edit/_context.mjs +34 -1
- package/api/theme-edit/_css.d.mts +21 -1
- package/api/theme-edit/_css.mjs +172 -13
- package/api/theme-edit/_edit.d.mts +9 -0
- package/api/theme-edit/_edit.mjs +377 -48
- package/api/theme-edit/_how-commands.d.mts +7 -26
- package/api/theme-edit/_how-commands.mjs +27 -1
- package/api/theme-edit/_how-question.mjs +330 -12
- package/api/theme-edit/_how.mjs +68 -26
- package/api/theme-edit/_palette.mjs +10 -0
- package/api/theme-edit/_parts.d.mts +16 -0
- package/api/theme-edit/_parts.mjs +49 -1
- package/api/theme-edit/_preview-app.mjs +176 -9
- package/api/theme-edit/_preview.mjs +7 -3
- package/api/theme-edit/_project.d.mts +11 -0
- package/api/theme-edit/_project.mjs +35 -9
- package/api/theme-edit/_settings.d.mts +46 -5
- package/api/theme-edit/_settings.mjs +217 -25
- package/api/theme-edit/theme-edit.type.d.mts +2 -1
- package/api/theme-edit/theme-edit.type.mjs +1 -1
- package/api/theme-edit/themeEditNew.doc.mjs +1 -1
- package/api/theme-edit/themeEditShow.doc.mjs +1 -1
- 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/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/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/doctor.doc.mjs +2 -2
- package/clients/cli/commands/experimental/theme.mjs +113 -34
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- 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-template.doc.mjs +1 -1
- 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 +85 -5
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/config/project.mjs +50 -14
- package/foundation/fs/gather-cache.d.mts +9 -2
- package/foundation/fs/gather-cache.mjs +36 -10
- package/foundation/fs/paths.d.mts +16 -0
- package/foundation/fs/paths.mjs +25 -0
- 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/response-types.doc.mjs +1 -1
- package/package.json +7 -6
package/api/theme-edit/_edit.mjs
CHANGED
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
DIALS,
|
|
19
19
|
FAMILIES,
|
|
20
20
|
FONT_ROLES,
|
|
21
|
+
HEADING_TRACKING,
|
|
22
|
+
HEADING_WEIGHTS,
|
|
21
23
|
KEY_TOKENS,
|
|
22
24
|
LIKE,
|
|
23
25
|
P,
|
|
@@ -53,6 +55,7 @@ import {
|
|
|
53
55
|
staleBuild,
|
|
54
56
|
EDITOR_SUFFIXES,
|
|
55
57
|
madeByEditor,
|
|
58
|
+
camel,
|
|
56
59
|
NEW_MARKER,
|
|
57
60
|
clearNewMarker,
|
|
58
61
|
refuseThemeSource,
|
|
@@ -76,7 +79,7 @@ import {
|
|
|
76
79
|
} from './_palette.mjs';
|
|
77
80
|
import {renderPreview, renderSheet} from './_preview.mjs';
|
|
78
81
|
import {refreshPreviewRoute} from './_preview-app.mjs';
|
|
79
|
-
import {baseResolved, installLine} from './_project.mjs';
|
|
82
|
+
import {baseInstalled, baseResolved, installLine} from './_project.mjs';
|
|
80
83
|
import {reactMissing} from './_parts.mjs';
|
|
81
84
|
import {
|
|
82
85
|
requireProject,
|
|
@@ -88,7 +91,10 @@ import {
|
|
|
88
91
|
checkSection,
|
|
89
92
|
} from './_context.mjs';
|
|
90
93
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
91
|
-
import {
|
|
94
|
+
import {
|
|
95
|
+
getCliInvocation,
|
|
96
|
+
quoteCommandArgument,
|
|
97
|
+
} from '../../foundation/env/package-manager.mjs';
|
|
92
98
|
|
|
93
99
|
const E = ERROR_CODES;
|
|
94
100
|
|
|
@@ -191,6 +197,27 @@ export async function themeEditNew(name, options = {}) {
|
|
|
191
197
|
// `--like none` builds on no base, as `set <theme> base none` does.
|
|
192
198
|
const like = options.like === 'none' ? undefined : options.like;
|
|
193
199
|
requireProject(cwd);
|
|
200
|
+
// A corrected `new` keeps every option given, fixing only the bad one.
|
|
201
|
+
// A --like in another case is the built-in theme it names.
|
|
202
|
+
// A --like that names no built-in theme is the nearest one, or none: a
|
|
203
|
+
// corrected command never repeats a --like that is refused below.
|
|
204
|
+
// A guess (the nearest base to a word that names none) is only a base the
|
|
205
|
+
// project has installed: another would be refused in turn. A base named
|
|
206
|
+
// in other letters is the one meant, installed or not (its refusal then
|
|
207
|
+
// offers the install, or the same new on no base).
|
|
208
|
+
const have = LIKE.filter(b => baseInstalled(cwd, b));
|
|
209
|
+
const likeFixed =
|
|
210
|
+
like == null
|
|
211
|
+
? options.like === 'none'
|
|
212
|
+
? 'none'
|
|
213
|
+
: undefined
|
|
214
|
+
: LIKE.includes(String(like).toLowerCase())
|
|
215
|
+
? String(like).toLowerCase()
|
|
216
|
+
: (nearest(String(like).toLowerCase(), have)[0] ?? null);
|
|
217
|
+
const again = (
|
|
218
|
+
/** @type {string} */ newName,
|
|
219
|
+
/** @type {string | null | undefined} */ likeValue = likeFixed,
|
|
220
|
+
) => `${P} new ${newName}${newFlags(likeValue, settings, png)}`;
|
|
194
221
|
if (!slugOk(name)) {
|
|
195
222
|
const fixed = slugFor(name);
|
|
196
223
|
// The name as typed may be a theme that exists in another case.
|
|
@@ -198,7 +225,7 @@ export async function themeEditNew(name, options = {}) {
|
|
|
198
225
|
refuse(
|
|
199
226
|
E.ERR_INVALID_ARGUMENT,
|
|
200
227
|
`"${String(name ?? '').slice(0, 80)}" is not a theme name (${NAME_RULE})${exists ? `; ${fixed} is a theme here already` : ''}.`,
|
|
201
|
-
{run: exists ? [`${P} show ${fixed}`] : [
|
|
228
|
+
{run: exists ? [`${P} show ${fixed}`] : [again(fixed)]},
|
|
202
229
|
);
|
|
203
230
|
}
|
|
204
231
|
// A built-in theme's name would collide with the theme of that name the
|
|
@@ -207,7 +234,18 @@ export async function themeEditNew(name, options = {}) {
|
|
|
207
234
|
refuse(
|
|
208
235
|
E.ERR_FILE_EXISTS,
|
|
209
236
|
`${name} is a built-in theme; an editor theme needs a name of its own. To start from ${name}, build on it.`,
|
|
210
|
-
{
|
|
237
|
+
{
|
|
238
|
+
run: [
|
|
239
|
+
again(
|
|
240
|
+
fs.existsSync(themeFiles(cwd, `my-${name}`).dir)
|
|
241
|
+
? freeThemeName(cwd, `my-${name}`)
|
|
242
|
+
: `my-${name}`,
|
|
243
|
+
// Built on the theme named when it is installed, unless another
|
|
244
|
+
// base (or none) was given.
|
|
245
|
+
likeFixed ?? name,
|
|
246
|
+
),
|
|
247
|
+
],
|
|
248
|
+
},
|
|
211
249
|
);
|
|
212
250
|
const f = themeFiles(cwd, name);
|
|
213
251
|
// A link or a file where the theme goes is never written through or
|
|
@@ -218,15 +256,19 @@ export async function themeEditNew(name, options = {}) {
|
|
|
218
256
|
refuse(
|
|
219
257
|
E.ERR_FILE_EXISTS,
|
|
220
258
|
`themes in this app is ${rootSt.isSymbolicLink() ? `a link (to ${fs.readlinkSync(f.root)})` : 'a file'}, not a folder, so no editor theme can be made: every theme goes in themes/<name>/. Rename or move it, then run new again.`,
|
|
221
|
-
// A look that changes nothing:
|
|
222
|
-
{
|
|
259
|
+
// A look that changes nothing: what is in the way.
|
|
260
|
+
{
|
|
261
|
+
run: [
|
|
262
|
+
`ls -la ${quoteCommandArgument(path.relative(cwd, f.root) || 'themes')}`,
|
|
263
|
+
],
|
|
264
|
+
},
|
|
223
265
|
);
|
|
224
266
|
const dirSt = fs.lstatSync(f.dir, {throwIfNoEntry: false});
|
|
225
267
|
if (dirSt && (dirSt.isSymbolicLink() || !dirSt.isDirectory()))
|
|
226
268
|
refuse(
|
|
227
269
|
E.ERR_FILE_EXISTS,
|
|
228
270
|
`themes/${name} is ${dirSt.isSymbolicLink() ? 'a link' : 'a file'}, so a theme is not made there.`,
|
|
229
|
-
{run: [
|
|
271
|
+
{run: [again(freeThemeName(cwd, name))]},
|
|
230
272
|
);
|
|
231
273
|
// Settings that are not valid JSON are kept aside, and the theme is
|
|
232
274
|
// made again beside them.
|
|
@@ -250,28 +292,38 @@ export async function themeEditNew(name, options = {}) {
|
|
|
250
292
|
refuse(
|
|
251
293
|
E.ERR_FILE_EXISTS,
|
|
252
294
|
`themes/${name}/ already holds files this command did not make; choose another name.`,
|
|
253
|
-
{run: [
|
|
295
|
+
{run: [again(freeThemeName(cwd, name))]},
|
|
254
296
|
);
|
|
255
297
|
if (like != null && !LIKE.includes(like))
|
|
256
298
|
refuse(
|
|
257
299
|
E.ERR_THEME_BAD_VALUE,
|
|
258
300
|
`--like takes a built-in theme (${LIKE.join(', ')}), not "${like}"${fs.existsSync(themeFiles(cwd, String(like)).settings) ? `; ${like} is a theme made here, and a new theme builds only on a built-in one` : ''}.`,
|
|
259
301
|
{
|
|
260
|
-
|
|
261
|
-
|
|
302
|
+
// The built-in theme it names in another case, or the nearest
|
|
303
|
+
// installed one, else none: the did-you-mean and the run agree.
|
|
304
|
+
didYouMean: likeFixed ? [likeFixed] : [],
|
|
305
|
+
run: [again(name, likeFixed ?? null)],
|
|
262
306
|
},
|
|
263
307
|
);
|
|
264
308
|
const ctx = await context(cwd);
|
|
265
309
|
/** @type {import('./_settings.mjs').ThemeData} */
|
|
266
310
|
const data = {name, ...(like ? {like} : {}), mode: 'both', settings: []};
|
|
267
|
-
|
|
268
|
-
ctx.
|
|
269
|
-
|
|
270
|
-
)
|
|
311
|
+
try {
|
|
312
|
+
/** @type {import('./_settings.mjs').Ctx} */ (ctx).base =
|
|
313
|
+
await baseResolved(ctx.project, data.like);
|
|
314
|
+
} catch (e) {
|
|
315
|
+
// A base that is not installed: install it, or the same new on no base.
|
|
316
|
+
if (e instanceof AstryxError && e.code === E.ERR_UNKNOWN_THEME)
|
|
317
|
+
e.suggestions = [
|
|
318
|
+
...(e.suggestions ?? []),
|
|
319
|
+
{name: again(name, null), reason: 'build on no theme'},
|
|
320
|
+
];
|
|
321
|
+
throw e;
|
|
322
|
+
}
|
|
271
323
|
// Every check comes before the first change to the folder: the settings,
|
|
272
324
|
// and a source of the user's own kept from before (it must still extend
|
|
273
325
|
// the settings, or the build fails after the folder was cleared).
|
|
274
|
-
applyNewSettings(ctx, name, data, settings);
|
|
326
|
+
applyNewSettings(ctx, name, data, settings, png, likeFixed ?? undefined);
|
|
275
327
|
if (left?.keep.some(p => path.basename(p) === `${name}.theme.ts`))
|
|
276
328
|
refuseThemeSource(cwd, name);
|
|
277
329
|
/** @type {string[]} */
|
|
@@ -290,7 +342,7 @@ export async function themeEditNew(name, options = {}) {
|
|
|
290
342
|
);
|
|
291
343
|
if (left?.keep.some(p => path.basename(p) === `${name}.history.json`))
|
|
292
344
|
leftNotes.push(
|
|
293
|
-
`the
|
|
345
|
+
`the history is kept in ${name}.history.json: \`${P} undo ${name}\` steps back to the settings from before the last change, and the last change itself is not kept`,
|
|
294
346
|
);
|
|
295
347
|
// The marker goes first and comes off last: a `new` stopped between
|
|
296
348
|
// leaves a folder the next `new` can prove it made. The damaged settings
|
|
@@ -417,8 +469,17 @@ export async function themeEditNew(name, options = {}) {
|
|
|
417
469
|
* @param {string} slug
|
|
418
470
|
* @param {import('./_settings.mjs').ThemeData} data
|
|
419
471
|
* @param {Record<string, string | string[] | undefined>} settings
|
|
472
|
+
* @param {boolean} [png] kept in a corrected `new` a refusal suggests
|
|
473
|
+
* @param {string} [likeFlag] the --like a corrected `new` keeps (`none` too)
|
|
420
474
|
*/
|
|
421
|
-
function applyNewSettings(
|
|
475
|
+
function applyNewSettings(
|
|
476
|
+
ctx,
|
|
477
|
+
slug,
|
|
478
|
+
data,
|
|
479
|
+
settings,
|
|
480
|
+
png = false,
|
|
481
|
+
likeFlag = data.like,
|
|
482
|
+
) {
|
|
422
483
|
const given = Object.entries(settings).filter(([, v]) => v != null);
|
|
423
484
|
for (const [thing] of given)
|
|
424
485
|
if (!DIALS[thing] || thing === 'base')
|
|
@@ -441,13 +502,14 @@ function applyNewSettings(ctx, slug, data, settings) {
|
|
|
441
502
|
const given = settings[thing];
|
|
442
503
|
if (given == null) continue;
|
|
443
504
|
// `headings` takes a weight and a tracking: one value per axis.
|
|
444
|
-
|
|
505
|
+
const values = Array.isArray(given) ? given : [given];
|
|
506
|
+
for (const [index, value] of values.entries()) {
|
|
445
507
|
/** @type {import('./_settings.mjs').Setting} */
|
|
446
508
|
let s;
|
|
447
509
|
try {
|
|
448
510
|
s = checkSetting(ctx, slug, data, thing, String(value), {}, false);
|
|
449
511
|
} catch (e) {
|
|
450
|
-
throw asNewRefusal(e, slug, settings);
|
|
512
|
+
throw asNewRefusal(e, slug, settings, likeFlag, png, {thing, index});
|
|
451
513
|
}
|
|
452
514
|
if (thing === 'mode')
|
|
453
515
|
data.mode = /** @type {'both' | 'light-only' | 'dark-only'} */ (
|
|
@@ -460,8 +522,14 @@ function applyNewSettings(ctx, slug, data, settings) {
|
|
|
460
522
|
E.ERR_INVALID_ARGUMENT,
|
|
461
523
|
`--${thing} was given two values for the same thing (${data.settings[same].value}, ${s.value}); give one.`,
|
|
462
524
|
{
|
|
525
|
+
// Every other option given stays, and the first value on each
|
|
526
|
+
// axis: every later value for an axis already given goes.
|
|
463
527
|
run: [
|
|
464
|
-
`${P} new ${slug}
|
|
528
|
+
`${P} new ${slug}${newFlags(
|
|
529
|
+
likeFlag,
|
|
530
|
+
{...settings, [thing]: firstPerAxis(values)},
|
|
531
|
+
png,
|
|
532
|
+
)}`,
|
|
465
533
|
],
|
|
466
534
|
},
|
|
467
535
|
);
|
|
@@ -471,36 +539,117 @@ function applyNewSettings(ctx, slug, data, settings) {
|
|
|
471
539
|
}
|
|
472
540
|
}
|
|
473
541
|
|
|
542
|
+
/**
|
|
543
|
+
* The options of a `new` as flags, in the order given (`new --help`'s order
|
|
544
|
+
* for the command): `--like`, each dial setting, then `--png`.
|
|
545
|
+
* @param {string | null | undefined} like none when null or undefined
|
|
546
|
+
* @param {Record<string, string | string[] | undefined>} settings
|
|
547
|
+
* @param {boolean} [png]
|
|
548
|
+
* @returns {string[]}
|
|
549
|
+
*/
|
|
550
|
+
export function newFlagList(like, settings, png = false) {
|
|
551
|
+
return [
|
|
552
|
+
...(like ? [`--like ${quoteCommandArgument(like)}`] : []),
|
|
553
|
+
...Object.entries(settings)
|
|
554
|
+
.filter(([, v]) => v != null)
|
|
555
|
+
.flatMap(([k, v]) => (Array.isArray(v) ? v : [v]).map(x => [k, x]))
|
|
556
|
+
.map(([k, v]) => `--${k} ${quoteCommandArgument(String(v))}`),
|
|
557
|
+
...(png ? ['--png'] : []),
|
|
558
|
+
];
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* The options of a `new` as one flag line, with its leading space.
|
|
563
|
+
* @param {string | null | undefined} like
|
|
564
|
+
* @param {Record<string, string | string[] | undefined>} settings
|
|
565
|
+
* @param {boolean} png
|
|
566
|
+
*/
|
|
567
|
+
function newFlags(like, settings, png) {
|
|
568
|
+
const parts = newFlagList(like, settings, png);
|
|
569
|
+
return parts.length ? ` ${parts.join(' ')}` : '';
|
|
570
|
+
}
|
|
571
|
+
|
|
474
572
|
/**
|
|
475
573
|
* A refusal from a setting `new` was given, with its suggestions turned
|
|
476
574
|
* into `new` commands: the theme does not exist yet, so a `set` would fail.
|
|
477
575
|
* @param {unknown} e
|
|
478
576
|
* @param {string} slug
|
|
479
577
|
* @param {Record<string, string | string[] | undefined>} settings
|
|
578
|
+
* @param {string} [like] the --like given, kept in a corrected command
|
|
579
|
+
* @param {boolean} [png] --png, kept in a corrected command
|
|
580
|
+
* @param {{thing: string, index: number} | null} [at] the value refused
|
|
480
581
|
*/
|
|
481
|
-
function asNewRefusal(e, slug, settings) {
|
|
582
|
+
function asNewRefusal(e, slug, settings, like, png = false, at = null) {
|
|
482
583
|
if (!(e instanceof AstryxError)) return e;
|
|
483
|
-
const flags = Object.entries(settings)
|
|
484
|
-
.filter(([, v]) => v != null)
|
|
485
|
-
.flatMap(([k, v]) => (Array.isArray(v) ? v : [v]).map(x => [k, x]))
|
|
486
|
-
.map(([k, v]) => `--${k} ${quoteCommandArgument(String(v))}`);
|
|
487
584
|
const setPrefix = `${P} set ${slug} `;
|
|
488
585
|
e.suggestions = (e.suggestions ?? []).map(s => {
|
|
489
586
|
if (s.name === `${P} set --help`) return {...s, name: `${P} new --help`};
|
|
490
587
|
if (!s.name.startsWith(setPrefix)) return s;
|
|
491
588
|
const [thing, ...rest] = s.name.slice(setPrefix.length).split(' ');
|
|
492
589
|
if (thing.startsWith('--') || !DIALS[thing]) return s;
|
|
493
|
-
const
|
|
590
|
+
const fixed = unquoteWord(rest.join(' '));
|
|
591
|
+
// Only the refused value changes: a dial given several values
|
|
592
|
+
// (--headings tight --headings BOLD) keeps the others, in order.
|
|
593
|
+
const given = settings[thing];
|
|
594
|
+
const values = Array.isArray(given) ? [...given] : null;
|
|
595
|
+
const next =
|
|
596
|
+
values && at && at.thing === thing
|
|
597
|
+
? firstPerAxis(values.map((v, i) => (i === at.index ? fixed : v)))
|
|
598
|
+
: fixed;
|
|
494
599
|
return {
|
|
495
600
|
...s,
|
|
496
|
-
name:
|
|
497
|
-
' ',
|
|
498
|
-
),
|
|
601
|
+
name: `${P} new ${slug}${newFlags(like, {...settings, [thing]: next}, png)}`,
|
|
499
602
|
};
|
|
500
603
|
});
|
|
604
|
+
// A refused value with nothing to put in its place: the same new
|
|
605
|
+
// without it, every other option kept.
|
|
606
|
+
if (at && !e.suggestions.some(x => x.name.startsWith(`${P} new `))) {
|
|
607
|
+
const given = settings[at.thing];
|
|
608
|
+
const rest = Array.isArray(given)
|
|
609
|
+
? given.filter((_, i) => i !== at.index)
|
|
610
|
+
: undefined;
|
|
611
|
+
e.suggestions.push({
|
|
612
|
+
name: `${P} new ${slug}${newFlags(like, {...settings, [at.thing]: rest?.length ? rest : undefined}, png)}`,
|
|
613
|
+
reason: `without --${at.thing} ${quoteCommandArgument(String(Array.isArray(given) ? given[at.index] : given))}`,
|
|
614
|
+
});
|
|
615
|
+
}
|
|
501
616
|
return e;
|
|
502
617
|
}
|
|
503
618
|
|
|
619
|
+
/**
|
|
620
|
+
* Headings values with every later value for an axis already given left
|
|
621
|
+
* out (the first weight and the first tracking stay); a word of neither
|
|
622
|
+
* axis stays, for its own refusal.
|
|
623
|
+
* @param {string[]} values
|
|
624
|
+
* @returns {string[]}
|
|
625
|
+
*/
|
|
626
|
+
function firstPerAxis(values) {
|
|
627
|
+
const seen = new Set();
|
|
628
|
+
return values.filter(v => {
|
|
629
|
+
const w = String(v).trim().toLowerCase();
|
|
630
|
+
const axis =
|
|
631
|
+
HEADING_WEIGHTS[w] !== undefined
|
|
632
|
+
? 'weight'
|
|
633
|
+
: HEADING_TRACKING[w] !== undefined
|
|
634
|
+
? 'tracking'
|
|
635
|
+
: null;
|
|
636
|
+
if (!axis) return true;
|
|
637
|
+
if (seen.has(axis)) return false;
|
|
638
|
+
seen.add(axis);
|
|
639
|
+
return true;
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* A word as a suggested command writes it, without the quotes
|
|
645
|
+
* quoteCommandArgument adds.
|
|
646
|
+
* @param {string} word
|
|
647
|
+
*/
|
|
648
|
+
function unquoteWord(word) {
|
|
649
|
+
const m = /^'(.*)'$/s.exec(word);
|
|
650
|
+
return m ? m[1].replace(/'\\''/g, "'") : word;
|
|
651
|
+
}
|
|
652
|
+
|
|
504
653
|
/**
|
|
505
654
|
* The preview after a change, with the in-app preview route kept in step:
|
|
506
655
|
* its imports follow the theme, such as the stylesheet of a font package
|
|
@@ -571,7 +720,12 @@ function refuseStoredTokens(ctx, slug, data, skip) {
|
|
|
571
720
|
// setting is never refused for another.
|
|
572
721
|
run: [
|
|
573
722
|
...bad.slice(0, 5).map(b => `${P} undo ${slug} ${undoArgs(b.setting)}`),
|
|
574
|
-
|
|
723
|
+
// A value to set only for a token whose stored value has the wrong
|
|
724
|
+
// type; any other thing `set` would refuse, or read as a dial.
|
|
725
|
+
...(one &&
|
|
726
|
+
!one.scope &&
|
|
727
|
+
one.setting.source === 'token' &&
|
|
728
|
+
ctx.C.isToken(one.setting.thing)
|
|
575
729
|
? [
|
|
576
730
|
`${P} set ${slug} ${one.setting.thing} ${quoteCommandArgument(exampleOf(ctx.C.typeOf(one.setting.thing), one.setting.thing))}`,
|
|
577
731
|
]
|
|
@@ -581,6 +735,22 @@ function refuseStoredTokens(ctx, slug, data, skip) {
|
|
|
581
735
|
);
|
|
582
736
|
}
|
|
583
737
|
|
|
738
|
+
/**
|
|
739
|
+
* A theme name near `name` that is valid and whose folder is free: `name-2`,
|
|
740
|
+
* `name-3`, …, shortened to fit the name's length limit.
|
|
741
|
+
* @param {string} cwd
|
|
742
|
+
* @param {string} name
|
|
743
|
+
*/
|
|
744
|
+
function freeThemeName(cwd, name) {
|
|
745
|
+
for (let n = 2; n < 1000; n += 1) {
|
|
746
|
+
const suffix = `-${n}`;
|
|
747
|
+
const candidate = `${name.slice(0, 64 - suffix.length).replace(/-+$/, '')}${suffix}`;
|
|
748
|
+
if (slugOk(candidate) && !fs.existsSync(themeFiles(cwd, candidate).dir))
|
|
749
|
+
return candidate;
|
|
750
|
+
}
|
|
751
|
+
return '<another name>';
|
|
752
|
+
}
|
|
753
|
+
|
|
584
754
|
/**
|
|
585
755
|
* A note for type scale steps that land outside 9 to 200 pixels.
|
|
586
756
|
* @param {Record<string, string>} res resolved light tokens
|
|
@@ -675,7 +845,7 @@ async function change(sub, slug, thing, value, options) {
|
|
|
675
845
|
sub === 'undo'
|
|
676
846
|
? data.settings.find(
|
|
677
847
|
x =>
|
|
678
|
-
x.thing === thing &&
|
|
848
|
+
x.thing.toLowerCase() === String(thing).toLowerCase() &&
|
|
679
849
|
(x.on ?? null) === (flags.on ?? null) &&
|
|
680
850
|
(x.when ?? null) === (flags.when ?? null) &&
|
|
681
851
|
(x.state ?? null) === (flags.state ?? null) &&
|
|
@@ -687,13 +857,36 @@ async function change(sub, slug, thing, value, options) {
|
|
|
687
857
|
// what it named (or of the dial its refusal names), else the last
|
|
688
858
|
// step.
|
|
689
859
|
if (sub === 'undo' && e instanceof AstryxError) {
|
|
860
|
+
// Setting names are matched in any case, and a near name of a
|
|
861
|
+
// setting the theme has counts: `undo t Corners`, `undo t corner`.
|
|
862
|
+
const typed = String(thing).toLowerCase();
|
|
690
863
|
const named = new Set([
|
|
691
|
-
|
|
864
|
+
typed,
|
|
865
|
+
...(e.suggestions ?? [])
|
|
866
|
+
.filter(x => x.reason === 'did you mean')
|
|
867
|
+
.map(x => x.name.toLowerCase()),
|
|
692
868
|
...(e.suggestions ?? [])
|
|
693
|
-
.map(
|
|
869
|
+
.map(
|
|
870
|
+
x => new RegExp(` (?:set|undo) ${slug} (\\S+)`).exec(x.name)?.[1],
|
|
871
|
+
)
|
|
694
872
|
.filter(Boolean),
|
|
873
|
+
...nearest(
|
|
874
|
+
typed,
|
|
875
|
+
data.settings.map(x => x.thing.toLowerCase()),
|
|
876
|
+
),
|
|
695
877
|
]);
|
|
696
|
-
const matches = data.settings.filter(x =>
|
|
878
|
+
const matches = data.settings.filter(x =>
|
|
879
|
+
named.has(x.thing.toLowerCase()),
|
|
880
|
+
);
|
|
881
|
+
// A word that is near a setting name (a typo, another case) is never
|
|
882
|
+
// answered with a bare step back, which would undo another change;
|
|
883
|
+
// any other word (`all`) may mean the last step.
|
|
884
|
+
const nearSetting =
|
|
885
|
+
named.size > 1 ||
|
|
886
|
+
nearest(typed, [
|
|
887
|
+
...Object.keys(DIALS),
|
|
888
|
+
...data.settings.map(x => x.thing.toLowerCase()),
|
|
889
|
+
]).length > 0;
|
|
697
890
|
const steps = readHistory(themeFiles(cwd, slug).history).steps.length;
|
|
698
891
|
throw new AstryxError(
|
|
699
892
|
e.message,
|
|
@@ -703,7 +896,7 @@ async function change(sub, slug, thing, value, options) {
|
|
|
703
896
|
reason: 'do this instead',
|
|
704
897
|
}))
|
|
705
898
|
: [
|
|
706
|
-
steps
|
|
899
|
+
steps && !nearSetting
|
|
707
900
|
? {name: `${P} undo ${slug}`, reason: 'step back one change'}
|
|
708
901
|
: {name: `${P} show ${slug}`, reason: 'see what it sets'},
|
|
709
902
|
],
|
|
@@ -956,6 +1149,13 @@ async function change(sub, slug, thing, value, options) {
|
|
|
956
1149
|
...exactWins,
|
|
957
1150
|
].map(describe)
|
|
958
1151
|
: [];
|
|
1152
|
+
// The role fonts a whole-theme font sits under.
|
|
1153
|
+
const roleOver =
|
|
1154
|
+
sub === 'set' && s.thing === 'font' && !s.on
|
|
1155
|
+
? data.settings.filter(
|
|
1156
|
+
x => x.thing === 'font' && x.on && ['body', 'heading'].includes(x.on),
|
|
1157
|
+
)
|
|
1158
|
+
: [];
|
|
959
1159
|
// The exact property a dial on a part competes with there.
|
|
960
1160
|
const DIAL_PROPERTY = /** @type {Record<string, RegExp>} */ ({
|
|
961
1161
|
corners: /radius$/,
|
|
@@ -986,6 +1186,29 @@ async function change(sub, slug, thing, value, options) {
|
|
|
986
1186
|
`comes after ${covers.map(describe).join(', ')}, so ${covers.length > 1 ? 'those parts show' : `${covers[0].on} shows`} this value now; set ${covers.length > 1 ? 'one' : 'it'} again to make it win`,
|
|
987
1187
|
]
|
|
988
1188
|
: []),
|
|
1189
|
+
// Core writes a part's derived variables (a button's or card's radius
|
|
1190
|
+
// variable, read by what is drawn inside it) from plain declarations
|
|
1191
|
+
// only: in a state they keep the plain value, and the result says so.
|
|
1192
|
+
...(sub === 'set' && s.state && s.on
|
|
1193
|
+
? (() => {
|
|
1194
|
+
const prop =
|
|
1195
|
+
s.thing === 'corners' || /radius$/.test(s.thing)
|
|
1196
|
+
? 'borderRadius'
|
|
1197
|
+
: s.thing === 'padding' || s.thing === 'spacing'
|
|
1198
|
+
? 'padding'
|
|
1199
|
+
: s.thing.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
1200
|
+
const vars = parts.flatMap(t =>
|
|
1201
|
+
(ctx.derived?.[t] ?? [])
|
|
1202
|
+
.filter(d => d.property === prop)
|
|
1203
|
+
.flatMap(d => d.vars ?? []),
|
|
1204
|
+
);
|
|
1205
|
+
return vars.length
|
|
1206
|
+
? [
|
|
1207
|
+
`in the ${s.state} state, ${[...new Set(vars)].join(', ')} (which Core sets from the plain value, for what is drawn inside the part) keeps the plain value`,
|
|
1208
|
+
]
|
|
1209
|
+
: [];
|
|
1210
|
+
})()
|
|
1211
|
+
: []),
|
|
989
1212
|
// Phones keep the base theme's reading sizes (a coarse pointer below
|
|
990
1213
|
// the lg width), so a size change says where it applies.
|
|
991
1214
|
...(sub === 'set' &&
|
|
@@ -1006,9 +1229,17 @@ async function change(sub, slug, thing, value, options) {
|
|
|
1006
1229
|
`${describe(exactOver)} is an exact property and wins over ${s.thing} there, so this shows only after \`${P} undo ${slug} ${undoArgs(exactOver)}\``,
|
|
1007
1230
|
]
|
|
1008
1231
|
: []),
|
|
1232
|
+
// A whole-theme font under fonts set for each role shows only where no
|
|
1233
|
+
// role font is set.
|
|
1234
|
+
...(roleOver.length
|
|
1235
|
+
? [
|
|
1236
|
+
`keeps your ${roleOver.map(describe).join(', ')}: a font for one role wins over the whole-theme font, so ${s.value} shows there only after ${roleOver.map(x => `\`${P} undo ${slug} ${undoArgs(x)}\``).join(' and ')}`,
|
|
1237
|
+
]
|
|
1238
|
+
: []),
|
|
1009
1239
|
// An accepted change that the theme already showed says so.
|
|
1010
1240
|
...(sub === 'set' &&
|
|
1011
1241
|
!exactOver &&
|
|
1242
|
+
!roleOver.length &&
|
|
1012
1243
|
// With the last build unreadable, nothing was compared.
|
|
1013
1244
|
!r.notes.some(n => n.includes('could not be read')) &&
|
|
1014
1245
|
!r.unchanged &&
|
|
@@ -1104,8 +1335,13 @@ async function change(sub, slug, thing, value, options) {
|
|
|
1104
1335
|
if (s.thing === 'font' && sub === 'set')
|
|
1105
1336
|
notes.unshift(...fontNotes(ctx, {...data, settings: [s]}));
|
|
1106
1337
|
if (s.thing === 'type' || s.thing === 'headings')
|
|
1107
|
-
for (const [m, why] of maskedSettings(data))
|
|
1338
|
+
for (const [m, why] of maskedSettings(data, ctx))
|
|
1108
1339
|
notes.push(`${describe(m)}: ${why}`);
|
|
1340
|
+
// An earlier setting this one now covers (through a spread too) is named.
|
|
1341
|
+
else if (sub === 'set')
|
|
1342
|
+
for (const [m, why] of maskedSettings(data, ctx))
|
|
1343
|
+
if (m !== s && why.startsWith(describe(s)))
|
|
1344
|
+
notes.push(`${describe(m)} no longer shows: ${why}`);
|
|
1109
1345
|
if (s.thing === 'type' && sub === 'set' && TYPE_STYLES[s.value].ratio > 1.2)
|
|
1110
1346
|
notes.push(
|
|
1111
1347
|
'text below the base size keeps its standard sizes, so small text stays readable',
|
|
@@ -1235,7 +1471,7 @@ export async function themeEditShow(theme, options = {}) {
|
|
|
1235
1471
|
? [installLine(cwd, ['react', 'react-dom'])]
|
|
1236
1472
|
: // Two copies of React and other install problems are named by
|
|
1237
1473
|
// doctor; the same show would fail the same way.
|
|
1238
|
-
[
|
|
1474
|
+
[`${getCliInvocation(cwd)} doctor`],
|
|
1239
1475
|
},
|
|
1240
1476
|
);
|
|
1241
1477
|
const f = themeFiles(cwd, theme);
|
|
@@ -1243,7 +1479,42 @@ export async function themeEditShow(theme, options = {}) {
|
|
|
1243
1479
|
// a hand edit, another CLI) is made again from the settings, and said.
|
|
1244
1480
|
const stale = staleBuild(cwd, theme, data);
|
|
1245
1481
|
const brokenSource = themeSourceProblem(cwd, theme);
|
|
1246
|
-
if (stale && !brokenSource && !readOnly)
|
|
1482
|
+
if (stale && !brokenSource && !readOnly) {
|
|
1483
|
+
// Every file the build may rewrite or remove (the settings module, the
|
|
1484
|
+
// variants types, section sheets, pictures), so a theme source that
|
|
1485
|
+
// does not build leaves the folder exactly as it was.
|
|
1486
|
+
const kept = new Map(
|
|
1487
|
+
fs
|
|
1488
|
+
.readdirSync(f.dir)
|
|
1489
|
+
.filter(
|
|
1490
|
+
n =>
|
|
1491
|
+
n === path.basename(f.settingsTs) ||
|
|
1492
|
+
n === `${theme}.variants.d.ts` ||
|
|
1493
|
+
/^(sheet-[a-z-]+\.html|(sheet|preview)(-[a-z-]+)?\.png)$/.test(n),
|
|
1494
|
+
)
|
|
1495
|
+
.map(n => [path.join(f.dir, n), fs.readFileSync(path.join(f.dir, n))]),
|
|
1496
|
+
);
|
|
1497
|
+
try {
|
|
1498
|
+
await buildTheme(ctx, theme, data);
|
|
1499
|
+
} catch (e) {
|
|
1500
|
+
for (const [file, bytes] of kept) writeWhole(file, bytes);
|
|
1501
|
+
if (e instanceof AstryxError && e.code !== E.ERR_THEME_LOAD) throw e;
|
|
1502
|
+
// An own theme source that no longer builds is named, as `set` names
|
|
1503
|
+
// it; the old build is never shown as current.
|
|
1504
|
+
const why = (e instanceof Error ? e.message : String(e))
|
|
1505
|
+
.split(`${cwd}${path.sep}`)
|
|
1506
|
+
.join('')
|
|
1507
|
+
.replace(/\s*Make sure all imports[^|]*$/s, '')
|
|
1508
|
+
.split('\n')
|
|
1509
|
+
.slice(0, 3)
|
|
1510
|
+
.join(' | ');
|
|
1511
|
+
refuse(
|
|
1512
|
+
E.ERR_THEME_INVALID,
|
|
1513
|
+
`${theme} did not build: ${why}${why.includes(path.basename(f.ts)) ? ` (${shown(cwd, f.ts)} is your own file: fix it, then run show again)` : ''}`,
|
|
1514
|
+
{run: [`${P} how --list dials`]},
|
|
1515
|
+
);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1247
1518
|
// The settings loaded whole: a `new` marker beside them is stale.
|
|
1248
1519
|
if (!readOnly) clearNewMarker(f.dir);
|
|
1249
1520
|
// A built module that cannot be read (damaged by hand) is built again.
|
|
@@ -1251,6 +1522,17 @@ export async function themeEditShow(theme, options = {}) {
|
|
|
1251
1522
|
let unreadable = null;
|
|
1252
1523
|
const res = await resolvedTokens(ctx, theme).catch(async e => {
|
|
1253
1524
|
if (e instanceof AstryxError || readOnly) throw e;
|
|
1525
|
+
// The source lines the settings need are missing too: the build cannot
|
|
1526
|
+
// be made again until they are back, and show says so (never a run of
|
|
1527
|
+
// show itself).
|
|
1528
|
+
if (brokenSource)
|
|
1529
|
+
refuse(
|
|
1530
|
+
E.ERR_THEME_INVALID,
|
|
1531
|
+
`${theme}.js could not be read, and it cannot be built again: ${brokenSource}. Put back the import of ${camel(theme)}Settings from './${theme}.settings', extends: ${camel(theme)}Settings and name: '${theme}' in ${shown(cwd, f.ts)}, then run show again.`,
|
|
1532
|
+
{
|
|
1533
|
+
run: [`cat ${quoteCommandArgument(shown(cwd, f.ts))}`],
|
|
1534
|
+
},
|
|
1535
|
+
);
|
|
1254
1536
|
unreadable = `${theme}.js could not be read (${e instanceof Error ? e.message.split('\n')[0] : String(e)}), so it was built again from the settings`;
|
|
1255
1537
|
await buildTheme(ctx, theme, data);
|
|
1256
1538
|
return resolvedTokens(ctx, theme);
|
|
@@ -1297,7 +1579,7 @@ export async function themeEditShow(theme, options = {}) {
|
|
|
1297
1579
|
like: data.like ?? null,
|
|
1298
1580
|
mode: data.mode,
|
|
1299
1581
|
settings: data.settings.map(s => {
|
|
1300
|
-
const masked = maskedSettings(data).get(s);
|
|
1582
|
+
const masked = maskedSettings(data, ctx).get(s);
|
|
1301
1583
|
return {...s, parts: partsOf(ctx, s), ...(masked ? {masked} : {})};
|
|
1302
1584
|
}),
|
|
1303
1585
|
notes: [
|
|
@@ -1312,7 +1594,7 @@ export async function themeEditShow(theme, options = {}) {
|
|
|
1312
1594
|
]
|
|
1313
1595
|
: stale
|
|
1314
1596
|
? [
|
|
1315
|
-
`the build
|
|
1597
|
+
`the build was not current (${stale}), so it was built again from the settings`,
|
|
1316
1598
|
]
|
|
1317
1599
|
: []),
|
|
1318
1600
|
...(unreadable ? [unreadable] : []),
|
|
@@ -1339,7 +1621,7 @@ export async function themeEditShow(theme, options = {}) {
|
|
|
1339
1621
|
res,
|
|
1340
1622
|
modes[0],
|
|
1341
1623
|
),
|
|
1342
|
-
...colorsReport(pal, data),
|
|
1624
|
+
...colorsReport(pal, data, res, theme),
|
|
1343
1625
|
problems,
|
|
1344
1626
|
preview,
|
|
1345
1627
|
previewStale,
|
|
@@ -1481,7 +1763,7 @@ function otherModeNotes(data) {
|
|
|
1481
1763
|
* @returns {string[]}
|
|
1482
1764
|
*/
|
|
1483
1765
|
function partValues(ctx, data, res, mode) {
|
|
1484
|
-
const masked = maskedSettings(data);
|
|
1766
|
+
const masked = maskedSettings(data, ctx);
|
|
1485
1767
|
return data.settings
|
|
1486
1768
|
.filter(
|
|
1487
1769
|
s =>
|
|
@@ -1554,9 +1836,13 @@ function partValues(ctx, data, res, mode) {
|
|
|
1554
1836
|
* says so), and the contrast moves behind the shade choices.
|
|
1555
1837
|
* @param {import('./_palette.mjs').PaletteMapping | null} pal
|
|
1556
1838
|
* @param {import('./_settings.mjs').ThemeData} data
|
|
1839
|
+
* @param {Record<'light' | 'dark', Record<string, string>>} [built] the
|
|
1840
|
+
* built theme's resolved values: where one differs from the generated
|
|
1841
|
+
* shade with no exact setting, the theme's own source changed it
|
|
1842
|
+
* @param {string} [slug]
|
|
1557
1843
|
* @returns {{vibrancy: number | null, colors: import('./theme-edit.type.mjs').ThemeEditColor[], colorNotes: string[]}}
|
|
1558
1844
|
*/
|
|
1559
|
-
function colorsReport(pal, data) {
|
|
1845
|
+
function colorsReport(pal, data, built, slug = '') {
|
|
1560
1846
|
if (!pal) return {vibrancy: null, colors: [], colorNotes: []};
|
|
1561
1847
|
/** What the user set for each token exactly, in each mode. */
|
|
1562
1848
|
const exactBy =
|
|
@@ -1566,6 +1852,19 @@ function colorsReport(pal, data) {
|
|
|
1566
1852
|
for (const m of s.mode ? [s.mode] : ['light', 'dark'])
|
|
1567
1853
|
(exactBy[s.thing] ??= {})[/** @type {'light' | 'dark'} */ (m)] =
|
|
1568
1854
|
s.value;
|
|
1855
|
+
/** Tokens the theme's own source sets to another value than generated. */
|
|
1856
|
+
const ownBy =
|
|
1857
|
+
/** @type {Record<string, {light?: string, dark?: string}>} */ ({});
|
|
1858
|
+
for (const [k, v] of Object.entries(pal.tokens))
|
|
1859
|
+
for (const m of /** @type {const} */ (['light', 'dark'])) {
|
|
1860
|
+
const now = built?.[m]?.[k];
|
|
1861
|
+
if (
|
|
1862
|
+
now &&
|
|
1863
|
+
!exactBy[k]?.[m] &&
|
|
1864
|
+
now.trim().toLowerCase() !== String(v[m].color).trim().toLowerCase()
|
|
1865
|
+
)
|
|
1866
|
+
(ownBy[k] ??= {})[m] = now;
|
|
1867
|
+
}
|
|
1569
1868
|
/** @param {import('./_palette.mjs').StopRef} r */
|
|
1570
1869
|
const shade = r =>
|
|
1571
1870
|
r.family === 'black' || r.family === 'white'
|
|
@@ -1587,12 +1886,14 @@ function colorsReport(pal, data) {
|
|
|
1587
1886
|
k,
|
|
1588
1887
|
// Each mode says what it shows: the exact setting where one is
|
|
1589
1888
|
// made for it, else the generated shade.
|
|
1590
|
-
exactBy[k]
|
|
1889
|
+
exactBy[k] || ownBy[k]
|
|
1591
1890
|
? modes
|
|
1592
1891
|
.map(m =>
|
|
1593
|
-
exactBy[k][m] != null
|
|
1892
|
+
exactBy[k]?.[m] != null
|
|
1594
1893
|
? `${m} ${exactBy[k][m]} (your exact setting wins over the generated ${shade(v[m])})`
|
|
1595
|
-
:
|
|
1894
|
+
: ownBy[k]?.[m] != null
|
|
1895
|
+
? `${m} ${ownBy[k][m]} (your change in ${slug}.theme.ts wins over the generated ${shade(v[m])})`
|
|
1896
|
+
: `${m} ${shade(v[m])}`,
|
|
1596
1897
|
)
|
|
1597
1898
|
.join(', ')
|
|
1598
1899
|
: shades(v),
|
|
@@ -1600,9 +1901,22 @@ function colorsReport(pal, data) {
|
|
|
1600
1901
|
),
|
|
1601
1902
|
})),
|
|
1602
1903
|
colorNotes: [
|
|
1603
|
-
|
|
1904
|
+
// A note about a token the theme's own source changed is dropped:
|
|
1905
|
+
// what it says no longer holds.
|
|
1906
|
+
...pal.notes.filter(
|
|
1907
|
+
n =>
|
|
1908
|
+
!Object.keys(ownBy).some(k =>
|
|
1909
|
+
new RegExp(`${k.replace(/[-]/g, '\\-')}(?![\\w-])`).test(n),
|
|
1910
|
+
),
|
|
1911
|
+
),
|
|
1604
1912
|
...pal.contrast
|
|
1605
1913
|
.filter(c => modes.includes(c.mode))
|
|
1914
|
+
// A pairing the theme's own source changed no longer holds.
|
|
1915
|
+
.filter(
|
|
1916
|
+
c =>
|
|
1917
|
+
!ownBy[c.token]?.[/** @type {'light' | 'dark'} */ (c.mode)] &&
|
|
1918
|
+
!ownBy[c.against]?.[/** @type {'light' | 'dark'} */ (c.mode)],
|
|
1919
|
+
)
|
|
1606
1920
|
.filter(c => c.note || !c.pass || c.stop !== c.preferred)
|
|
1607
1921
|
.map(c =>
|
|
1608
1922
|
c.note
|
|
@@ -1611,7 +1925,12 @@ function colorsReport(pal, data) {
|
|
|
1611
1925
|
? `${c.token} ${c.mode}: shade ${c.stop}, not ${c.preferred}, so it reads at ${c.ratio}:1 on ${c.against}`
|
|
1612
1926
|
: `${c.token} ${c.mode}: only ${c.ratio}:1 on ${c.against} at shade ${c.stop} (needs ${c.needs}:1)`,
|
|
1613
1927
|
),
|
|
1614
|
-
]
|
|
1928
|
+
].filter(
|
|
1929
|
+
n =>
|
|
1930
|
+
!Object.keys(ownBy).some(k =>
|
|
1931
|
+
new RegExp(`${k.replace(/[-]/g, '\\-')}(?![\\w-])`).test(n),
|
|
1932
|
+
),
|
|
1933
|
+
),
|
|
1615
1934
|
};
|
|
1616
1935
|
}
|
|
1617
1936
|
|
|
@@ -1790,6 +2109,16 @@ export async function themeEditUndo(theme, options = {}) {
|
|
|
1790
2109
|
prev = repaired.data;
|
|
1791
2110
|
leftOut = repaired.dropped;
|
|
1792
2111
|
}
|
|
2112
|
+
// The checks that need this Core too (a token's type, a part, a state,
|
|
2113
|
+
// a name that is no token or property): what they refuse is left out of
|
|
2114
|
+
// the step, with the same note, so the build stays valid.
|
|
2115
|
+
{
|
|
2116
|
+
const bad = new Set(storedProblems(ctx, theme, prev).map(p => p.setting));
|
|
2117
|
+
if (bad.size) {
|
|
2118
|
+
leftOut = [...leftOut, ...prev.settings.filter(s => bad.has(s))];
|
|
2119
|
+
prev = {...prev, settings: prev.settings.filter(s => !bad.has(s))};
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
1793
2122
|
// The popped history is written with the change, inside its rollback.
|
|
1794
2123
|
const committed = await commitTheme(ctx, theme, prev, {
|
|
1795
2124
|
history: false,
|