@astryxdesign/cli 0.7.15-canary.gf890983 → 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/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/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/publishing.doc.mjs +1 -0
- package/assets/docs.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/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/may-have-integrations.d.mts +8 -0
- package/foundation/integrations/may-have-integrations.mjs +47 -0
- 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 +4 -4
- package/package.json +6 -6
- package/api/theme-edit/_css-properties.d.mts +0 -10
- package/api/theme-edit/_css-properties.mjs +0 -556
|
@@ -16,6 +16,25 @@ export function alphaOf(value: unknown): number;
|
|
|
16
16
|
* @returns {Rgb}
|
|
17
17
|
*/
|
|
18
18
|
export function compositeOver(over: Rgb, alpha: number, under: Rgb): Rgb;
|
|
19
|
+
/**
|
|
20
|
+
* A value split at `sep` outside brackets: `a(b, c), d` by `,` is
|
|
21
|
+
* [`a(b, c)`, ` d`]. A space separator also splits runs of spaces.
|
|
22
|
+
* @param {string} v
|
|
23
|
+
* @param {',' | ' '} sep
|
|
24
|
+
* @returns {string[]}
|
|
25
|
+
*/
|
|
26
|
+
export function splitTop(v: string, sep: "," | " "): string[];
|
|
27
|
+
/**
|
|
28
|
+
* One side of a color-mix(): the color, and the share written before or
|
|
29
|
+
* after it at the top level (null when none). A percentage inside the
|
|
30
|
+
* color (`hsl(0 100% 50%) 30%`) is the color's own.
|
|
31
|
+
* @param {string} side
|
|
32
|
+
* @returns {{color: string, pct: number | null}}
|
|
33
|
+
*/
|
|
34
|
+
export function mixSide(side: string): {
|
|
35
|
+
color: string;
|
|
36
|
+
pct: number | null;
|
|
37
|
+
};
|
|
19
38
|
/**
|
|
20
39
|
* The RGB of a fixed CSS color: a hex, a named color, or rgb(), hsl(),
|
|
21
40
|
* hwb(), lab(), lch(), oklab(), oklch() or color() in srgb, srgb-linear or
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* @position api/theme-edit — pure helpers
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import {CSS_WIDE} from './_tables.mjs';
|
|
12
|
+
import {MATH_FUNCTION, matchType} from './_css.mjs';
|
|
11
13
|
import {luminance, oklabToLinearRgb} from '../theme/palette/generate/color.mjs';
|
|
12
14
|
|
|
13
15
|
/** @typedef {[number, number, number]} Rgb */
|
|
@@ -168,14 +170,7 @@ const NAMED = /** @type {Record<string, string>} */ ({
|
|
|
168
170
|
export const COLOR_NAMES = Object.keys(NAMED);
|
|
169
171
|
|
|
170
172
|
/** Color keywords that are valid colors but have no fixed value. */
|
|
171
|
-
const KEYWORDS = [
|
|
172
|
-
'transparent',
|
|
173
|
-
'currentcolor',
|
|
174
|
-
'inherit',
|
|
175
|
-
'initial',
|
|
176
|
-
'unset',
|
|
177
|
-
'revert',
|
|
178
|
-
];
|
|
173
|
+
const KEYWORDS = ['transparent', 'currentcolor', ...CSS_WIDE];
|
|
179
174
|
|
|
180
175
|
/** CSS system colors: valid, but they follow the user's device. */
|
|
181
176
|
const SYSTEM = [
|
|
@@ -208,7 +203,72 @@ const FUNCTIONS =
|
|
|
208
203
|
const FIXED = /^(rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)$/i;
|
|
209
204
|
|
|
210
205
|
/** The `color()` spaces this reader converts to sRGB. */
|
|
211
|
-
const COLOR_SPACES = [
|
|
206
|
+
const COLOR_SPACES = [
|
|
207
|
+
'srgb',
|
|
208
|
+
'srgb-linear',
|
|
209
|
+
'display-p3',
|
|
210
|
+
'a98-rgb',
|
|
211
|
+
'prophoto-rgb',
|
|
212
|
+
'rec2020',
|
|
213
|
+
'xyz',
|
|
214
|
+
'xyz-d50',
|
|
215
|
+
'xyz-d65',
|
|
216
|
+
];
|
|
217
|
+
|
|
218
|
+
/** Each RGB space's transfer to linear light, and its matrix to XYZ D65 (D50 for ProPhoto). */
|
|
219
|
+
const RGB_SPACES =
|
|
220
|
+
/** @type {Record<string, {lin: (v: number) => number, m: number[][], d50?: boolean}>} */ ({
|
|
221
|
+
'display-p3': {
|
|
222
|
+
lin: v =>
|
|
223
|
+
Math.abs(v) <= 0.04045
|
|
224
|
+
? v / 12.92
|
|
225
|
+
: Math.sign(v) * ((Math.abs(v) + 0.055) / 1.055) ** 2.4,
|
|
226
|
+
m: [
|
|
227
|
+
[0.4865709486482162, 0.26566769316909306, 0.1982172852343625],
|
|
228
|
+
[0.2289745640697488, 0.6917385218365064, 0.079286914093745],
|
|
229
|
+
[0, 0.04511338185890264, 1.043944368900976],
|
|
230
|
+
],
|
|
231
|
+
},
|
|
232
|
+
'a98-rgb': {
|
|
233
|
+
lin: v => Math.sign(v) * Math.abs(v) ** (563 / 256),
|
|
234
|
+
m: [
|
|
235
|
+
[0.5766690429101305, 0.1855582379065463, 0.1882286462349947],
|
|
236
|
+
[0.29734497525053605, 0.6273635662554661, 0.0752914584939979],
|
|
237
|
+
[0.02703136138641234, 0.07068885253582723, 0.9913375368376388],
|
|
238
|
+
],
|
|
239
|
+
},
|
|
240
|
+
rec2020: {
|
|
241
|
+
lin: v => {
|
|
242
|
+
const a = 1.09929682680944;
|
|
243
|
+
const b = 0.018053968510807;
|
|
244
|
+
return Math.abs(v) < b * 4.5
|
|
245
|
+
? v / 4.5
|
|
246
|
+
: Math.sign(v) * ((Math.abs(v) + a - 1) / a) ** (1 / 0.45);
|
|
247
|
+
},
|
|
248
|
+
m: [
|
|
249
|
+
[0.6369580483012914, 0.14461690358620832, 0.1688809751641721],
|
|
250
|
+
[0.2627002120112671, 0.6779980715188708, 0.05930171646986196],
|
|
251
|
+
[0, 0.028072693049087428, 1.060985057710791],
|
|
252
|
+
],
|
|
253
|
+
},
|
|
254
|
+
'prophoto-rgb': {
|
|
255
|
+
lin: v =>
|
|
256
|
+
Math.abs(v) <= 16 / 512 ? v / 16 : Math.sign(v) * Math.abs(v) ** 1.8,
|
|
257
|
+
m: [
|
|
258
|
+
[0.7977604896723027, 0.13518583717574031, 0.0313493495815248],
|
|
259
|
+
[0.2880711282292934, 0.7118432178101014, 0.00008565396060525902],
|
|
260
|
+
[0, 0, 0.8251046025104601],
|
|
261
|
+
],
|
|
262
|
+
d50: true,
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
/** XYZ D50 to XYZ D65 (Bradford). @param {number[]} c */
|
|
267
|
+
const d50ToD65 = ([x, y, z]) => [
|
|
268
|
+
0.955473421488075 * x - 0.02309845494876471 * y + 0.06325924320057072 * z,
|
|
269
|
+
-0.0283697093338637 * x + 1.0099953980813041 * y + 0.021041441191917323 * z,
|
|
270
|
+
0.012314014864481998 * x - 0.020507649298898964 * y + 1.330365926242124 * z,
|
|
271
|
+
];
|
|
212
272
|
|
|
213
273
|
/** @typedef {{n: number, unit: string}} Num */
|
|
214
274
|
|
|
@@ -338,8 +398,8 @@ function oklabToRgb(l, a, b) {
|
|
|
338
398
|
}
|
|
339
399
|
|
|
340
400
|
/**
|
|
341
|
-
* A `color()` value in sRGB: srgb as it is,
|
|
342
|
-
* through linear light, clipped to the sRGB gamut.
|
|
401
|
+
* A `color()` value in sRGB: srgb as it is, the other RGB spaces and
|
|
402
|
+
* XYZ through linear light and XYZ D65, clipped to the sRGB gamut.
|
|
343
403
|
* @param {string} space @param {number[]} c 0..1
|
|
344
404
|
* @returns {Rgb}
|
|
345
405
|
*/
|
|
@@ -347,20 +407,17 @@ function colorSpaceToRgb(space, c) {
|
|
|
347
407
|
if (space === 'srgb')
|
|
348
408
|
return /** @type {Rgb} */ (c.map(v => clamp(v, 0, 1) * 255));
|
|
349
409
|
if (space === 'srgb-linear') return fromLinear(c);
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
0.6917385218365064 * lin[1] +
|
|
362
|
-
0.079286914093745 * lin[2];
|
|
363
|
-
const z = 0.04511338185890264 * lin[1] + 1.043944368900976 * lin[2];
|
|
410
|
+
/** @type {number[]} */
|
|
411
|
+
let xyz;
|
|
412
|
+
if (space === 'xyz' || space === 'xyz-d65') xyz = c;
|
|
413
|
+
else if (space === 'xyz-d50') xyz = d50ToD65(c);
|
|
414
|
+
else {
|
|
415
|
+
const rgb = RGB_SPACES[space];
|
|
416
|
+
const lin = c.map(rgb.lin);
|
|
417
|
+
const t = rgb.m.map(r => r[0] * lin[0] + r[1] * lin[1] + r[2] * lin[2]);
|
|
418
|
+
xyz = rgb.d50 ? d50ToD65(t) : t;
|
|
419
|
+
}
|
|
420
|
+
const [x, y, z] = xyz;
|
|
364
421
|
return fromLinear([
|
|
365
422
|
3.2409699419045226 * x - 1.537383177570094 * y - 0.4986107602930034 * z,
|
|
366
423
|
-0.9692436362808796 * x + 1.8759675015077202 * y + 0.04155505740717559 * z,
|
|
@@ -411,6 +468,174 @@ export function compositeOver(over, alpha, under) {
|
|
|
411
468
|
);
|
|
412
469
|
}
|
|
413
470
|
|
|
471
|
+
/** The color-mix() spaces this reader mixes in. */
|
|
472
|
+
const MIX_SPACES = ['srgb', 'srgb-linear', 'xyz', 'xyz-d65', 'oklab', 'oklch'];
|
|
473
|
+
|
|
474
|
+
/** An sRGB channel (0..255) in linear light. @param {number} c */
|
|
475
|
+
const toLinear = c => {
|
|
476
|
+
const v = c / 255;
|
|
477
|
+
return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
/** Linear sRGB to OKLab. @param {number[]} lin @returns {number[]} */
|
|
481
|
+
function linearToOklab([r, g, b]) {
|
|
482
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
483
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
484
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
485
|
+
return [
|
|
486
|
+
0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
|
|
487
|
+
1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
|
|
488
|
+
0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,
|
|
489
|
+
];
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* A value split at `sep` outside brackets: `a(b, c), d` by `,` is
|
|
494
|
+
* [`a(b, c)`, ` d`]. A space separator also splits runs of spaces.
|
|
495
|
+
* @param {string} v
|
|
496
|
+
* @param {',' | ' '} sep
|
|
497
|
+
* @returns {string[]}
|
|
498
|
+
*/
|
|
499
|
+
export function splitTop(v, sep) {
|
|
500
|
+
/** @type {string[]} */
|
|
501
|
+
const out = [];
|
|
502
|
+
let depth = 0;
|
|
503
|
+
let cur = '';
|
|
504
|
+
for (const c of v) {
|
|
505
|
+
if (c === '(') depth++;
|
|
506
|
+
if (c === ')') depth--;
|
|
507
|
+
if (depth === 0 && (sep === ' ' ? /\s/.test(c) : c === sep)) {
|
|
508
|
+
if (cur.trim() || sep === ',') out.push(cur);
|
|
509
|
+
cur = '';
|
|
510
|
+
} else cur += c;
|
|
511
|
+
}
|
|
512
|
+
if (cur.trim() || sep === ',') out.push(cur);
|
|
513
|
+
return out.filter(x => sep === ',' || x.trim());
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* One side of a color-mix(): the color, and the share written before or
|
|
518
|
+
* after it at the top level (null when none). A percentage inside the
|
|
519
|
+
* color (`hsl(0 100% 50%) 30%`) is the color's own.
|
|
520
|
+
* @param {string} side
|
|
521
|
+
* @returns {{color: string, pct: number | null}}
|
|
522
|
+
*/
|
|
523
|
+
export function mixSide(side) {
|
|
524
|
+
const words = splitTop(side.trim(), ' ');
|
|
525
|
+
const share = (/** @type {string | undefined} */ w) =>
|
|
526
|
+
w != null && /^-?\d*\.?\d+%$/.test(w) ? Number.parseFloat(w) : null;
|
|
527
|
+
// A share outside 0-100% is invalid CSS: the side then names no color,
|
|
528
|
+
// so the mix is refused rather than extrapolated.
|
|
529
|
+
if (words.length < 2) return {color: side.trim(), pct: null};
|
|
530
|
+
const inRange = (/** @type {number} */ p) => p >= 0 && p <= 100;
|
|
531
|
+
const last = share(words.at(-1));
|
|
532
|
+
if (last != null)
|
|
533
|
+
return inRange(last)
|
|
534
|
+
? {color: words.slice(0, -1).join(' '), pct: last}
|
|
535
|
+
: {color: '', pct: null};
|
|
536
|
+
const first = share(words[0]);
|
|
537
|
+
if (first != null)
|
|
538
|
+
return inRange(first)
|
|
539
|
+
? {color: words.slice(1).join(' '), pct: first}
|
|
540
|
+
: {color: '', pct: null};
|
|
541
|
+
return {color: side.trim(), pct: null};
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* The fixed color a color-mix() of two fixed colors gives, as CSS Color 5
|
|
546
|
+
* mixes them (shares that do not add up to 100% are scaled, and a total
|
|
547
|
+
* under 100% makes the result see-through), or null when it is not one: a
|
|
548
|
+
* color with no fixed value, a space this reader does not mix in, or
|
|
549
|
+
* shares that add up to 0.
|
|
550
|
+
* @param {string} inner the arguments
|
|
551
|
+
* @returns {{rgb: Rgb, alpha: number} | null}
|
|
552
|
+
*/
|
|
553
|
+
function mixColor(inner) {
|
|
554
|
+
const args = splitTop(inner, ',').map(x => x.trim());
|
|
555
|
+
if (args.length !== 3) return null;
|
|
556
|
+
const sp =
|
|
557
|
+
/^in\s+([a-z0-9-]+)(?:\s+(shorter|longer|increasing|decreasing)\s+hue)?$/i.exec(
|
|
558
|
+
args[0],
|
|
559
|
+
);
|
|
560
|
+
const space = sp?.[1].toLowerCase() ?? '';
|
|
561
|
+
if (!MIX_SPACES.includes(space)) return null;
|
|
562
|
+
const hueWay = (sp?.[2] ?? 'shorter').toLowerCase();
|
|
563
|
+
const sides = args.slice(1).map(a => {
|
|
564
|
+
const {color, pct} = mixSide(a);
|
|
565
|
+
return {read: readColor(color), pct};
|
|
566
|
+
});
|
|
567
|
+
if (sides.some(x => !x.read)) return null;
|
|
568
|
+
let [p1, p2] = sides.map(x => x.pct);
|
|
569
|
+
if (p1 == null && p2 == null) [p1, p2] = [50, 50];
|
|
570
|
+
else if (p1 == null) p1 = 100 - /** @type {number} */ (p2);
|
|
571
|
+
else if (p2 == null) p2 = 100 - p1;
|
|
572
|
+
const total = /** @type {number} */ (p1) + /** @type {number} */ (p2);
|
|
573
|
+
if (!(total > 0)) return null;
|
|
574
|
+
const w2 = /** @type {number} */ (p2) / total;
|
|
575
|
+
const w1 = 1 - w2;
|
|
576
|
+
const [a, b] = sides.map(
|
|
577
|
+
x => /** @type {{rgb: Rgb, alpha: number}} */ (x.read),
|
|
578
|
+
);
|
|
579
|
+
/** @param {Rgb} rgb @returns {number[]} */
|
|
580
|
+
const into = rgb => {
|
|
581
|
+
if (space === 'srgb') return rgb.map(c => c / 255);
|
|
582
|
+
const lin = rgb.map(toLinear);
|
|
583
|
+
if (space === 'srgb-linear') return lin;
|
|
584
|
+
if (space === 'xyz' || space === 'xyz-d65')
|
|
585
|
+
return [
|
|
586
|
+
0.41239079926595934 * lin[0] +
|
|
587
|
+
0.357584339383878 * lin[1] +
|
|
588
|
+
0.1804807884018343 * lin[2],
|
|
589
|
+
0.21263900587151027 * lin[0] +
|
|
590
|
+
0.715168678767756 * lin[1] +
|
|
591
|
+
0.07219231536073371 * lin[2],
|
|
592
|
+
0.01933081871559182 * lin[0] +
|
|
593
|
+
0.11919477979462598 * lin[1] +
|
|
594
|
+
0.9505321522496607 * lin[2],
|
|
595
|
+
];
|
|
596
|
+
const lab = linearToOklab(lin);
|
|
597
|
+
if (space === 'oklab') return lab;
|
|
598
|
+
const c = Math.hypot(lab[1], lab[2]);
|
|
599
|
+
return [
|
|
600
|
+
lab[0],
|
|
601
|
+
c,
|
|
602
|
+
c < 1e-6 ? NaN : (Math.atan2(lab[2], lab[1]) * 180) / Math.PI,
|
|
603
|
+
];
|
|
604
|
+
};
|
|
605
|
+
/** @param {number[]} v @returns {Rgb} */
|
|
606
|
+
const back = v => {
|
|
607
|
+
if (space === 'srgb')
|
|
608
|
+
return /** @type {Rgb} */ (v.map(c => clamp(c, 0, 1) * 255));
|
|
609
|
+
if (space === 'srgb-linear') return fromLinear(v);
|
|
610
|
+
if (space === 'xyz' || space === 'xyz-d65')
|
|
611
|
+
return colorSpaceToRgb('xyz-d65', v);
|
|
612
|
+
if (space === 'oklab') return oklabToRgb(v[0], v[1], v[2]);
|
|
613
|
+
const h = (v[2] * Math.PI) / 180;
|
|
614
|
+
return oklabToRgb(v[0], v[1] * Math.cos(h), v[1] * Math.sin(h));
|
|
615
|
+
};
|
|
616
|
+
const x = into(a.rgb);
|
|
617
|
+
const y = into(b.rgb);
|
|
618
|
+
// Premultiplied by alpha, as CSS mixes; a missing hue takes the other's.
|
|
619
|
+
const alpha = a.alpha * w1 + b.alpha * w2;
|
|
620
|
+
const out = x.map((_, i) => {
|
|
621
|
+
if (space === 'oklch' && i === 2) {
|
|
622
|
+
let h1 = Number.isNaN(x[2]) ? y[2] : x[2];
|
|
623
|
+
let h2 = Number.isNaN(y[2]) ? x[2] : y[2];
|
|
624
|
+
if (Number.isNaN(h1)) return 0;
|
|
625
|
+
const d = h2 - h1;
|
|
626
|
+
if (hueWay === 'shorter' && Math.abs(d) > 180) h2 += d > 0 ? -360 : 360;
|
|
627
|
+
if (hueWay === 'longer' && Math.abs(d) < 180 && d !== 0)
|
|
628
|
+
h2 += d > 0 ? -360 : 360;
|
|
629
|
+
if (hueWay === 'increasing' && h2 < h1) h2 += 360;
|
|
630
|
+
if (hueWay === 'decreasing' && h2 > h1) h2 -= 360;
|
|
631
|
+
return h1 * w1 + h2 * w2;
|
|
632
|
+
}
|
|
633
|
+
const mixed = x[i] * a.alpha * w1 + y[i] * b.alpha * w2;
|
|
634
|
+
return alpha > 0 ? mixed / alpha : 0;
|
|
635
|
+
});
|
|
636
|
+
return {rgb: back(out), alpha: alpha * Math.min(1, total / 100)};
|
|
637
|
+
}
|
|
638
|
+
|
|
414
639
|
/**
|
|
415
640
|
* A fixed CSS color read as CSS Color 4 reads it: hues wrap, saturation,
|
|
416
641
|
* whiteness, blackness and lightness clamp to their range, and chroma
|
|
@@ -434,6 +659,7 @@ function readColor(s) {
|
|
|
434
659
|
const named = NAMED[s.toLowerCase()];
|
|
435
660
|
if (named) return readColor(named);
|
|
436
661
|
const fn = /^([a-z-]+)\((.*)\)$/i.exec(s);
|
|
662
|
+
if (fn && fn[1].toLowerCase() === 'color-mix') return mixColor(fn[2]);
|
|
437
663
|
if (!fn || !FIXED.test(fn[1])) return null;
|
|
438
664
|
const name = fn[1].toLowerCase();
|
|
439
665
|
if (name === 'color') {
|
|
@@ -572,6 +798,13 @@ export function colorProblem(value) {
|
|
|
572
798
|
}
|
|
573
799
|
if (fn && FIXED.test(fn[1]) && !/var\(|calc\(|env\(|\bfrom\b/i.test(fn[2]))
|
|
574
800
|
return {kind: 'malformed', message: 'is not a valid CSS color'};
|
|
801
|
+
// A mix this reader cannot work out (another space, a color with no
|
|
802
|
+
// fixed value) says so, rather than calling the mix unfixed.
|
|
803
|
+
if (fn && fn[1].toLowerCase() === 'color-mix' && !/var\(|env\(/i.test(fn[2]))
|
|
804
|
+
return {
|
|
805
|
+
kind: 'unfixed',
|
|
806
|
+
message: `is a color-mix() this editor cannot work out (it mixes in ${MIX_SPACES.join(', ')}, from colors with fixed values); give the mixed color itself`,
|
|
807
|
+
};
|
|
575
808
|
if (isColorValue(s))
|
|
576
809
|
return {
|
|
577
810
|
kind: 'unfixed',
|
|
@@ -607,6 +840,7 @@ export function ratio(a, b) {
|
|
|
607
840
|
* numbers must be well formed; one with `var()`, `calc()`, `env()` or a
|
|
608
841
|
* relative color is taken as written.
|
|
609
842
|
* @param {unknown} v
|
|
843
|
+
* @returns {boolean}
|
|
610
844
|
*/
|
|
611
845
|
export const isColorValue = v => {
|
|
612
846
|
const s = String(v).trim();
|
|
@@ -624,6 +858,9 @@ export const isColorValue = v => {
|
|
|
624
858
|
/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(s) ||
|
|
625
859
|
FUNCTIONS.test(s) ||
|
|
626
860
|
/^var\(--[a-z0-9-]+\)$/i.test(s) ||
|
|
861
|
+
// A variable with a color to fall back to.
|
|
862
|
+
(/^var\(--[a-z0-9-]+\s*,\s*(.+)\)$/i.test(s) &&
|
|
863
|
+
isColorValue(/^var\(--[a-z0-9-]+\s*,\s*(.+)\)$/i.exec(s)?.[1] ?? '')) ||
|
|
627
864
|
Object.hasOwn(NAMED, s.toLowerCase()) ||
|
|
628
865
|
KEYWORDS.includes(s.toLowerCase()) ||
|
|
629
866
|
SYSTEM.includes(s.toLowerCase())
|
|
@@ -650,13 +887,13 @@ export const isSize = (v, name = '') => {
|
|
|
650
887
|
);
|
|
651
888
|
if (/^var\(--[a-z0-9-]+\)$/i.test(s)) return true;
|
|
652
889
|
if (/^env\([a-z-]+(,.*)?\)$/i.test(s)) return true;
|
|
653
|
-
return
|
|
890
|
+
return MATH_FUNCTION.test(s) && matchType('length-percentage', s) != null;
|
|
654
891
|
};
|
|
655
892
|
|
|
656
893
|
/**
|
|
657
894
|
* Whether a value reads as a CSS number for the token: a weight is 1 to
|
|
658
|
-
* 1000 or a weight keyword; a line height is a
|
|
659
|
-
* percentage, or `normal`.
|
|
895
|
+
* 1000 or a weight keyword; a line height is a number, length or
|
|
896
|
+
* percentage of 0 or more, or `normal`.
|
|
660
897
|
* @param {unknown} v
|
|
661
898
|
* @param {string} [name]
|
|
662
899
|
*/
|
|
@@ -666,13 +903,15 @@ export const isNumber = (v, name = '') => {
|
|
|
666
903
|
if (/weight/.test(name))
|
|
667
904
|
return (
|
|
668
905
|
/^(normal|bold|bolder|lighter)$/.test(s) ||
|
|
669
|
-
(/^\d+(\.\d+)?$/.test(s) && Number(s) >= 1 && Number(s) <= 1000)
|
|
906
|
+
(/^\d+(\.\d+)?$/.test(s) && Number(s) >= 1 && Number(s) <= 1000) ||
|
|
907
|
+
(MATH_FUNCTION.test(s) && matchType('number', s) != null)
|
|
670
908
|
);
|
|
671
909
|
if (/leading|line-height/.test(name))
|
|
672
910
|
return (
|
|
673
911
|
s === 'normal' ||
|
|
674
|
-
(/^\d*\.?\d+(px|rem|em|%)?$/.test(s) && Number.parseFloat(s)
|
|
675
|
-
|
|
912
|
+
(/^\d*\.?\d+(px|rem|em|%)?$/.test(s) && Number.parseFloat(s) >= 0) ||
|
|
913
|
+
(MATH_FUNCTION.test(s) && matchType('length-percentage', s) != null) ||
|
|
914
|
+
(MATH_FUNCTION.test(s) && matchType('number', s) != null)
|
|
676
915
|
);
|
|
677
916
|
return /^-?\d*\.?\d+$/.test(s);
|
|
678
917
|
};
|
|
@@ -689,8 +928,13 @@ export function isSafeValue(v) {
|
|
|
689
928
|
// it, is a comment too.
|
|
690
929
|
// `</` (a closing tag), control characters, comments and !important are
|
|
691
930
|
// refused anywhere; < and > only outside a quoted string.
|
|
692
|
-
//
|
|
693
|
-
if (
|
|
931
|
+
// A tab is white space, as CSS reads it.
|
|
932
|
+
if (
|
|
933
|
+
// eslint-disable-next-line no-control-regex
|
|
934
|
+
/<\/|[\u0000-\u0008\u000a-\u001f\u007f]|\/\*|!important|(^|\s)#(\s|$)/i.test(
|
|
935
|
+
v,
|
|
936
|
+
)
|
|
937
|
+
)
|
|
694
938
|
return false;
|
|
695
939
|
const outside = v
|
|
696
940
|
.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g, '""')
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
export function makeCompiler(project: import("./_project.mjs").ThemeProject, parts: PartData): {
|
|
13
13
|
MAP: Record<string, import("./_parts.mjs").PartRecord>;
|
|
14
14
|
typeOf: (tok: string) => string;
|
|
15
|
+
propsReading: (tok: string) => string[];
|
|
15
16
|
feeds: (target: string, token: string) => Array<{
|
|
16
17
|
part: string;
|
|
17
18
|
prop: string;
|
|
@@ -512,9 +512,34 @@ export function makeCompiler(project, parts) {
|
|
|
512
512
|
return false;
|
|
513
513
|
}
|
|
514
514
|
|
|
515
|
+
/** @type {Map<string, string[]>} */
|
|
516
|
+
const propsCache = new Map();
|
|
517
|
+
/**
|
|
518
|
+
* The CSS properties anything in the catalog reads a token in.
|
|
519
|
+
* @param {string} tok
|
|
520
|
+
*/
|
|
521
|
+
const propsReading = tok => {
|
|
522
|
+
let r = propsCache.get(tok);
|
|
523
|
+
if (!r) {
|
|
524
|
+
/** @type {Set<string>} */
|
|
525
|
+
const out = new Set();
|
|
526
|
+
for (const t of Object.values(MAP)) {
|
|
527
|
+
for (const [prop, v] of Object.entries(t.own ?? {}))
|
|
528
|
+
if (tok in v.tokens) out.add(prop);
|
|
529
|
+
for (const [k, v] of Object.entries(t.inside ?? {}))
|
|
530
|
+
if (k === tok)
|
|
531
|
+
for (const p of /** @type {string[]} */ (v)) out.add(p);
|
|
532
|
+
}
|
|
533
|
+
r = [...out];
|
|
534
|
+
propsCache.set(tok, r);
|
|
535
|
+
}
|
|
536
|
+
return r;
|
|
537
|
+
};
|
|
538
|
+
|
|
515
539
|
return {
|
|
516
540
|
MAP,
|
|
517
541
|
typeOf,
|
|
542
|
+
propsReading,
|
|
518
543
|
feeds,
|
|
519
544
|
fmtFeeds,
|
|
520
545
|
showsCorners,
|
|
@@ -18,6 +18,7 @@ export function context(cwd: string): Promise<{
|
|
|
18
18
|
C: {
|
|
19
19
|
MAP: Record<string, import("./_parts.mjs").PartRecord>;
|
|
20
20
|
typeOf: (tok: string) => string;
|
|
21
|
+
propsReading: (tok: string) => string[];
|
|
21
22
|
feeds: (target: string, token: string) => Array<{
|
|
22
23
|
part: string;
|
|
23
24
|
prop: string;
|
|
@@ -101,6 +102,7 @@ export function styledChanges(before: any, after: any): string[];
|
|
|
101
102
|
* @param {boolean} png
|
|
102
103
|
*/
|
|
103
104
|
export function previewAfter(ctx: import("./_settings.mjs").Ctx, slug: string, data: import("./_settings.mjs").ThemeData, png: boolean): Promise<{
|
|
105
|
+
sheetStale?: string | undefined;
|
|
104
106
|
preview: string | null;
|
|
105
107
|
pictures: string[];
|
|
106
108
|
pictureProblem: string | null;
|
|
@@ -15,14 +15,17 @@ import {AstryxError} from '../error.mjs';
|
|
|
15
15
|
import {isOutsideProject} from '../../foundation/env/project-scope.mjs';
|
|
16
16
|
import {
|
|
17
17
|
CLOSEST_OPEN_FONT,
|
|
18
|
+
FONT_ROLES,
|
|
18
19
|
OPEN_FONTS,
|
|
20
|
+
isDesktopFamily,
|
|
21
|
+
oneSystemOf,
|
|
19
22
|
P,
|
|
20
|
-
SYSTEM_FAMILIES,
|
|
21
23
|
SYSTEM_FONTS,
|
|
22
24
|
} from './_tables.mjs';
|
|
23
25
|
import {makeCompiler} from './_compiler.mjs';
|
|
24
26
|
import {openProject, installLine} from './_project.mjs';
|
|
25
27
|
import {partData} from './_parts.mjs';
|
|
28
|
+
import {writeWhole} from './_palette.mjs';
|
|
26
29
|
import {
|
|
27
30
|
fontOf,
|
|
28
31
|
fontPackages,
|
|
@@ -48,7 +51,12 @@ export function requireProject(cwd) {
|
|
|
48
51
|
if (fs.existsSync(path.join(cwd, '.pnp.cjs')))
|
|
49
52
|
throw new AstryxError(
|
|
50
53
|
"This app uses Yarn Plug'n'Play, which astryx experimental theme does not support: it reads the installed Core from node_modules. Set `nodeLinker: node-modules` in .yarnrc.yml and run yarn install. Nothing was written.",
|
|
51
|
-
[
|
|
54
|
+
[
|
|
55
|
+
{
|
|
56
|
+
name: 'yarn config set nodeLinker node-modules',
|
|
57
|
+
reason: 'do this first, then yarn install',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
52
60
|
E.ERR_PROJECT_REQUIRED,
|
|
53
61
|
);
|
|
54
62
|
// A package.json with no Core: an app (or a workspace root) that needs it.
|
|
@@ -60,7 +68,12 @@ export function requireProject(cwd) {
|
|
|
60
68
|
);
|
|
61
69
|
throw new AstryxError(
|
|
62
70
|
'No package.json found. astryx experimental theme works inside an app project, which it writes the theme into and whose installed Core it checks every change against. Nothing was written.',
|
|
63
|
-
[
|
|
71
|
+
[
|
|
72
|
+
{
|
|
73
|
+
name: 'npm init -y',
|
|
74
|
+
reason: 'make a package.json here, then install @astryxdesign/core',
|
|
75
|
+
},
|
|
76
|
+
],
|
|
64
77
|
E.ERR_PROJECT_REQUIRED,
|
|
65
78
|
);
|
|
66
79
|
}
|
|
@@ -157,6 +170,8 @@ const notChecked = cause =>
|
|
|
157
170
|
export async function pictures(project, shots, modes) {
|
|
158
171
|
/** @type {string[]} */
|
|
159
172
|
const files = [];
|
|
173
|
+
/** @type {string[]} */
|
|
174
|
+
const cut = [];
|
|
160
175
|
for (const {html, png} of shots) {
|
|
161
176
|
for (const m of modes) {
|
|
162
177
|
const out =
|
|
@@ -166,9 +181,16 @@ export async function pictures(project, shots, modes) {
|
|
|
166
181
|
const r = await screenshot(project, html, out, m);
|
|
167
182
|
if (!r.ok) return {files, problem: r.reason};
|
|
168
183
|
files.push(r.file);
|
|
184
|
+
if (r.cut) cut.push(r.file);
|
|
169
185
|
}
|
|
170
186
|
}
|
|
171
|
-
return {
|
|
187
|
+
return {
|
|
188
|
+
files,
|
|
189
|
+
// A picture of the window shows the top of a longer page only.
|
|
190
|
+
problem: cut.length
|
|
191
|
+
? `${cut.join(', ')} show${cut.length === 1 ? 's' : ''} the top 2400 pixels of the page only (Chrome takes the window, not the whole page); open the .html beside ${cut.length === 1 ? 'it' : 'them'} to see all of it, or install Playwright (${installLine(project.cwd, ['playwright'])}) for whole-page pictures`
|
|
192
|
+
: null,
|
|
193
|
+
};
|
|
172
194
|
}
|
|
173
195
|
|
|
174
196
|
/**
|
|
@@ -182,7 +204,8 @@ export async function pictures(project, shots, modes) {
|
|
|
182
204
|
export function fontNotes(ctx, data) {
|
|
183
205
|
/** @type {string[]} */
|
|
184
206
|
const notes = [];
|
|
185
|
-
|
|
207
|
+
const packages = fontPackages(ctx, data);
|
|
208
|
+
for (const {pkg, family, installed} of packages) {
|
|
186
209
|
const fallbacks =
|
|
187
210
|
Object.values(OPEN_FONTS).find(f => f.pkg === pkg)?.fallbacks ?? '';
|
|
188
211
|
const near = /monospace/.test(fallbacks)
|
|
@@ -200,17 +223,30 @@ export function fontNotes(ctx, data) {
|
|
|
200
223
|
if (
|
|
201
224
|
s.thing !== 'font' ||
|
|
202
225
|
SYSTEM_FONTS.includes(s.value) ||
|
|
203
|
-
|
|
204
|
-
fontOf(s.value).family.replace(/["']/g, '').toLowerCase(),
|
|
205
|
-
) ||
|
|
226
|
+
isDesktopFamily(fontOf(s.value).family.replace(/["']/g, '')) ||
|
|
206
227
|
OPEN_FONTS[s.value] ||
|
|
207
228
|
fontOf(s.value).pkg ||
|
|
229
|
+
packages.some(x => x.of === s) ||
|
|
208
230
|
s.value === 'rounded' ||
|
|
209
231
|
s.value === 'comic'
|
|
210
232
|
)
|
|
211
233
|
continue;
|
|
212
234
|
const family = fontOf(s.value).family.replace(/["']/g, '').toLowerCase();
|
|
213
235
|
const near = CLOSEST_OPEN_FONT[family];
|
|
236
|
+
const named = fontOf(s.value).family.replace(/^["']|["']$/g, '');
|
|
237
|
+
const system = oneSystemOf(named);
|
|
238
|
+
const on = s.on ? ` --on ${s.on}` : '';
|
|
239
|
+
if (system) {
|
|
240
|
+
// A system font, on one system: the others show the next font.
|
|
241
|
+
const next =
|
|
242
|
+
fontOf(s.value).fallbacks.split(',')[0]?.trim() || 'system-ui';
|
|
243
|
+
notes.push(
|
|
244
|
+
/^(-apple-system|blinkmacsystemfont)$/.test(family)
|
|
245
|
+
? `"${named}" names the macOS interface font, which only macOS has: other systems show the next font in the stack (${next}). The system preset gives each system its own interface font: ${P} set ${data.name} font system${on}`
|
|
246
|
+
: `"${named}" ships only on ${system}: other systems show the next font in the stack (${next}).${near ? ` The closest open font, which loads everywhere, is ${near}: ${P} set ${data.name} font ${near}${on}` : ''}`,
|
|
247
|
+
);
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
214
250
|
notes.push(
|
|
215
251
|
`"${fontOf(s.value).family.replace(/^["']|["']$/g, '')}" is not a system font and no package loads it: the app must load it, or it falls back.${near ? ` The closest open font is ${near}: ${P} set ${data.name} font ${near}${s.on ? ` --on ${s.on}` : ''}` : ''}`,
|
|
216
252
|
);
|
|
@@ -268,7 +304,7 @@ export function styledChanges(before, after) {
|
|
|
268
304
|
const ta = JSON.stringify(before?.typography ?? {});
|
|
269
305
|
const tb = JSON.stringify(after?.typography ?? {});
|
|
270
306
|
if (ta !== tb) {
|
|
271
|
-
for (const role of
|
|
307
|
+
for (const role of FONT_ROLES) {
|
|
272
308
|
const x = after?.typography?.[role];
|
|
273
309
|
if (
|
|
274
310
|
JSON.stringify(before?.typography?.[role] ?? null) !==
|
|
@@ -318,6 +354,9 @@ export async function previewAfter(ctx, slug, data, png) {
|
|
|
318
354
|
: `checking it failed: ${e instanceof Error ? e.message : String(e)}`;
|
|
319
355
|
}
|
|
320
356
|
const f = themeFiles(ctx.project.cwd, slug);
|
|
357
|
+
// The sheet of every component is made by show only: after a change it
|
|
358
|
+
// says, at its top, that it shows the theme as it was.
|
|
359
|
+
const sheetStale = markSheetStale(f.sheet, slug);
|
|
321
360
|
const shots =
|
|
322
361
|
png && preview
|
|
323
362
|
? await pictures(
|
|
@@ -331,9 +370,44 @@ export async function previewAfter(ctx, slug, data, png) {
|
|
|
331
370
|
pictures: shots.files,
|
|
332
371
|
pictureProblem: shots.problem,
|
|
333
372
|
notChecked: notChecked(cause),
|
|
373
|
+
...(sheetStale
|
|
374
|
+
? {
|
|
375
|
+
sheetStale: `sheet.html shows ${slug} as it was before this change; ${P} show ${slug} makes it again`,
|
|
376
|
+
}
|
|
377
|
+
: {}),
|
|
334
378
|
};
|
|
335
379
|
}
|
|
336
380
|
|
|
381
|
+
const STALE_MARK = '<!-- astryx: sheet older than the theme -->';
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Put a notice at the top of a sheet the last change made out of date
|
|
385
|
+
* (once). Returns whether there is such a sheet.
|
|
386
|
+
* @param {string} file
|
|
387
|
+
* @param {string} slug
|
|
388
|
+
*/
|
|
389
|
+
function markSheetStale(file, slug) {
|
|
390
|
+
let html;
|
|
391
|
+
try {
|
|
392
|
+
html = fs.readFileSync(file, 'utf8');
|
|
393
|
+
} catch {
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
if (html.includes(STALE_MARK)) return true;
|
|
397
|
+
const banner = `${STALE_MARK}<div style="position:sticky;top:0;z-index:9999;padding:8px 12px;background:#fff3cd;color:#3d2c00;font:14px system-ui,sans-serif;border-bottom:1px solid #e0c870">This sheet shows ${slug} as it was before the last change. Run ${P} show ${slug} to make it again.</div>`;
|
|
398
|
+
const at = html.search(/<body[^>]*>/i);
|
|
399
|
+
const next =
|
|
400
|
+
at < 0 ? banner + html : html.replace(/<body[^>]*>/i, m => `${m}${banner}`);
|
|
401
|
+
try {
|
|
402
|
+
// Fenced like every editor write under the theme lock.
|
|
403
|
+
writeWhole(file, next);
|
|
404
|
+
} catch (e) {
|
|
405
|
+
if (/** @type {any} */ (e)?.lockLost) throw e;
|
|
406
|
+
// Read-only: the note in the result still says so.
|
|
407
|
+
}
|
|
408
|
+
return true;
|
|
409
|
+
}
|
|
410
|
+
|
|
337
411
|
/**
|
|
338
412
|
* The section of the sheet, in lower case, or undefined; a refusal for one
|
|
339
413
|
* that is not a section.
|