@astryxdesign/cli 0.7.15 → 0.7.16-canary.g22213fd
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 +6 -4
- package/api/build/_adapter.d.mts +10 -0
- package/api/build/_adapter.mjs +24 -0
- package/api/build/blocks/blocks.d.mts +1 -0
- package/api/build/blocks/blocks.mjs +18 -1
- package/api/build/kit/shell.weights.json +1 -0
- package/api/build/kit/shellcall.d.mts +26 -0
- package/api/build/kit/shellcall.mjs +87 -0
- package/api/build/kit/start.mjs +67 -4
- package/api/build/kit/weights.d.mts +15 -0
- package/api/build/kit/weights.mjs +27 -0
- package/api/component/__fixtures__/resolutions/modules.txt +1 -1
- package/api/component/_adapter.d.mts +1 -1
- package/api/component/_adapter.mjs +28 -1
- package/api/doctor/_adapter.d.mts +38 -2
- package/api/doctor/_adapter.mjs +76 -1
- package/api/doctor/built-checks.mjs +1 -1
- package/api/doctor/doctor.d.mts +26 -0
- package/api/doctor/doctor.doc.mjs +1 -1
- package/api/doctor/doctor.mjs +156 -11
- package/api/doctor/theme-checks.mjs +163 -18
- package/api/icon/_adapter.d.mts +7 -3
- package/api/icon/_adapter.mjs +12 -3
- package/api/icon/icon.type.d.mts +15 -0
- package/api/icon/icon.type.mjs +10 -3
- package/api/icon/iconUse.doc.mjs +19 -5
- package/api/icon/list/list.mjs +7 -1
- package/api/icon/use/use.d.mts +8 -5
- package/api/icon/use/use.mjs +95 -13
- package/api/init/run/run.mjs +1 -0
- package/api/integration/add-contribution.mjs +3 -3
- package/api/integration/pack-check.mjs +14 -8
- package/api/integration/validate-integration.mjs +1 -1
- package/api/search/_adapter.mjs +15 -16
- package/api/search/_entries.d.mts +2 -1
- package/api/search/_entries.mjs +28 -1
- package/api/swizzle/_moduleGraph.mjs +1 -1
- package/api/template/template.type.d.mts +6 -2
- package/api/template/template.type.mjs +2 -1
- package/api/theme/_adapter.d.mts +5 -2
- package/api/theme/_adapter.mjs +59 -14
- package/api/theme/_fork.mjs +1 -1
- package/api/theme/build/build.d.mts +120 -32
- package/api/theme/build/build.mjs +471 -111
- package/api/theme/eject/eject.mjs +22 -1
- package/api/theme/generateTonalPalette.doc.mjs +2 -2
- package/api/theme/palette/generate/generator.mjs +141 -2
- package/api/theme/template/template.d.mts +19 -0
- package/api/theme/template/template.mjs +102 -25
- package/api/theme/theme.type.d.mts +44 -1
- package/api/theme/theme.type.mjs +23 -1
- package/api/theme/themeBuild.doc.mjs +4 -4
- package/api/theme/themeEject.doc.mjs +1 -1
- package/api/theme/themePaletteGenerate.doc.mjs +1 -1
- package/api/theme/themeTemplate.doc.mjs +9 -3
- package/api/theme-edit/_adapter.d.mts +33 -2
- package/api/theme-edit/_adapter.mjs +276 -41
- package/api/theme-edit/_check.d.mts +93 -4
- package/api/theme-edit/_check.mjs +1712 -223
- package/api/theme-edit/_color.d.mts +2 -8
- package/api/theme-edit/_color.mjs +292 -219
- package/api/theme-edit/_compiler.d.mts +1 -0
- package/api/theme-edit/_compiler.mjs +20 -1
- package/api/theme-edit/_context.d.mts +31 -1
- package/api/theme-edit/_context.mjs +445 -41
- package/api/theme-edit/_css.d.mts +60 -1
- package/api/theme-edit/_css.mjs +404 -28
- package/api/theme-edit/_edit.d.mts +25 -0
- package/api/theme-edit/_edit.mjs +1620 -154
- package/api/theme-edit/_how-commands.d.mts +11 -26
- package/api/theme-edit/_how-commands.mjs +30 -2
- package/api/theme-edit/_how-question.d.mts +15 -0
- package/api/theme-edit/_how-question.mjs +1469 -194
- package/api/theme-edit/_how.mjs +144 -30
- package/api/theme-edit/_marks.d.mts +13 -0
- package/api/theme-edit/_marks.mjs +15 -0
- package/api/theme-edit/_overview.mjs +2 -0
- package/api/theme-edit/_palette.d.mts +38 -0
- package/api/theme-edit/_palette.mjs +306 -73
- package/api/theme-edit/_parts.d.mts +33 -0
- package/api/theme-edit/_parts.mjs +138 -9
- package/api/theme-edit/_png.d.mts +18 -0
- package/api/theme-edit/_png.mjs +95 -14
- package/api/theme-edit/_preview-app.d.mts +55 -1
- package/api/theme-edit/_preview-app.mjs +1552 -101
- package/api/theme-edit/_preview.d.mts +71 -3
- package/api/theme-edit/_preview.mjs +565 -35
- package/api/theme-edit/_project.d.mts +15 -0
- package/api/theme-edit/_project.mjs +68 -13
- package/api/theme-edit/_settings.d.mts +299 -5
- package/api/theme-edit/_settings.mjs +2806 -158
- package/api/theme-edit/_tables.d.mts +24 -0
- package/api/theme-edit/_tables.mjs +212 -150
- package/api/theme-edit/_vet.d.mts +42 -0
- package/api/theme-edit/_vet.mjs +144 -0
- package/api/theme-edit/theme-edit.type.d.mts +31 -2
- package/api/theme-edit/theme-edit.type.mjs +10 -2
- package/api/theme-edit/themeEditNew.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
- package/api/theme-edit/themeEditShow.doc.mjs +11 -3
- package/api/upgrade/registry/registry.mjs +6 -1
- package/assets/codemods/parse.mjs +2 -2
- package/assets/docs/author-a-theme.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/theme.doc.zh.mjs +4 -3
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +63 -8
- package/assets/docs/tree/single-component.doc.mjs +11 -2
- 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/preview-app/package.json +1 -0
- package/assets/preview-app/src/app/globals.css +1 -0
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.doc.mjs +21 -0
- package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.tsx +62 -0
- 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/assets/templates/pages/ai-chat/page.tsx +20 -2
- package/assets/templates/pages/dashboard/page.tsx +1 -1
- package/assets/templates/themes/neutral/neutralPalettes.generated.receipt.json +2 -0
- package/authoring/config/config.doc.mjs +8 -0
- package/authoring/config/parse.d.mts +1 -0
- package/authoring/config/parse.mjs +12 -0
- package/authoring/config/type.ts +8 -0
- package/authoring/doctypes/_schema.d.mts +52 -5
- package/authoring/doctypes/_schema.mjs +62 -7
- package/authoring/doctypes/base/type.ts +10 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/function/function.doc.mjs +6 -0
- package/authoring/doctypes/function/type.ts +3 -0
- package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +3 -3
- package/authoring/doctypes/legacy.mjs +5 -1
- package/authoring/index.d.ts +1 -0
- package/authoring/shadcn/source-variants.d.mts +1 -1
- package/authoring/shadcn/source-variants.mjs +32 -10
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/doctor.doc.mjs +2 -2
- package/clients/cli/commands/experimental/icon.mjs +61 -6
- package/clients/cli/commands/experimental/theme.mjs +244 -45
- package/clients/cli/commands/experimental-icon-use.doc.mjs +12 -5
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
- 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.doc.mjs +7 -2
- package/clients/cli/commands/theme.mjs +222 -55
- package/clients/cli/commands.generated.json +1 -1
- package/clients/cli/formatters/index.mjs +7 -4
- package/clients/cli/index.mjs +25 -5
- package/clients/cli/lib/cli-error.mjs +9 -3
- package/clients/cli/lib/component-format.mjs +27 -9
- package/clients/cli/lib/json-shim.mjs +72 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +49 -0
- package/foundation/agent-docs/agent-docs-target.d.mts +2 -6
- package/foundation/agent-docs/agent-docs-target.mjs +9 -17
- package/foundation/agent-docs/agent-docs.mjs +4 -3
- package/foundation/config/config-writer.d.mts +23 -0
- package/foundation/config/config-writer.mjs +152 -58
- package/foundation/config/project.mjs +103 -16
- package/foundation/discovery/component-discovery.mjs +11 -22
- package/foundation/discovery/icon-set-checks.mjs +164 -48
- package/foundation/discovery/icon-set-discovery.d.mts +38 -5
- package/foundation/discovery/icon-set-discovery.mjs +50 -6
- package/foundation/discovery/icon-set-theme-maps.d.mts +59 -0
- package/foundation/discovery/icon-set-theme-maps.mjs +95 -0
- package/foundation/discovery/icon-set-writer.d.mts +2 -3
- package/foundation/discovery/icon-set-writer.mjs +58 -17
- package/foundation/discovery/module-exports.mjs +1 -15
- package/foundation/discovery/template-adapter.mjs +44 -19
- package/foundation/discovery/template-icons.d.mts +27 -10
- package/foundation/discovery/template-icons.mjs +142 -26
- package/foundation/discovery/template-source-tree.mjs +3 -16
- package/foundation/discovery/theme-discovery.d.mts +30 -1
- package/foundation/discovery/theme-discovery.mjs +109 -50
- package/foundation/fs/exact-codec.d.mts +35 -0
- package/foundation/fs/exact-codec.mjs +148 -0
- package/foundation/fs/gather-cache.d.mts +15 -5
- package/foundation/fs/gather-cache.mjs +129 -31
- package/foundation/fs/paths.d.mts +39 -0
- package/foundation/fs/paths.mjs +44 -11
- package/foundation/fs/read-record.mjs +11 -1
- package/foundation/integrations/autolink.d.mts +4 -2
- package/foundation/integrations/autolink.mjs +4 -2
- package/foundation/integrations/cli-requirement.d.mts +16 -5
- package/foundation/integrations/cli-requirement.mjs +27 -6
- package/foundation/integrations/contribution-fixes.mjs +1 -16
- package/foundation/integrations/may-have-integrations.mjs +7 -3
- package/foundation/integrations/missing-dependency.d.mts +9 -0
- package/foundation/integrations/missing-dependency.mjs +100 -0
- package/foundation/integrations/public-imports.mjs +1 -1
- package/foundation/render/embedded-imports.mjs +1 -1
- package/foundation/render/host-exit.d.mts +8 -0
- package/foundation/render/host-exit.mjs +11 -0
- package/foundation/render/page-host.mjs +56 -10
- package/foundation/render/page-worker.mjs +14 -0
- package/foundation/render/render-page.mjs +37 -2
- 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/json.d.mts +15 -0
- package/foundation/response/json.mjs +52 -1
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/runtime/lazy-dependencies.d.mts +14 -0
- package/foundation/runtime/lazy-dependencies.mjs +82 -0
- package/foundation/xle/browser.d.mts +2 -2
- package/package.json +7 -6
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
import * as path from 'node:path';
|
|
9
9
|
import {AstryxError} from '../../error.mjs';
|
|
10
|
+
import {logger} from '../../logger.mjs';
|
|
10
11
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
12
|
+
import {
|
|
13
|
+
formatCliCommand,
|
|
14
|
+
quoteCommandArgument,
|
|
15
|
+
} from '../../../foundation/env/package-manager.mjs';
|
|
11
16
|
import {
|
|
12
17
|
ejectThemeFiles,
|
|
13
18
|
findTheme,
|
|
@@ -54,12 +59,28 @@ export async function themeEject(slug, options = {}) {
|
|
|
54
59
|
);
|
|
55
60
|
}
|
|
56
61
|
|
|
57
|
-
const {outputDir, files} = ejectThemeFiles(match, {
|
|
62
|
+
const {outputDir, files, editorFolder} = ejectThemeFiles(match, {
|
|
58
63
|
cwd,
|
|
59
64
|
targetPath,
|
|
60
65
|
overwrite,
|
|
61
66
|
takenSlugs: await availableSlugs(cwd),
|
|
62
67
|
});
|
|
68
|
+
// A folder the theme editor made holds that theme only, but a subfolder of
|
|
69
|
+
// it was always writable, so the fork is written there with one warning.
|
|
70
|
+
if (editorFolder != null) {
|
|
71
|
+
const fork = formatCliCommand(
|
|
72
|
+
[
|
|
73
|
+
'theme eject',
|
|
74
|
+
match.slug,
|
|
75
|
+
...(packageName
|
|
76
|
+
? ['--package', quoteCommandArgument(packageName)]
|
|
77
|
+
: []),
|
|
78
|
+
].join(' '),
|
|
79
|
+
cwd,
|
|
80
|
+
);
|
|
81
|
+
const warning = `Warning: ${editorFolder} is a folder the theme editor made, and the fork in ${outputDir} is inside it; eject writes there anyway. Fork into the project's local themes folder (${fork}), or pick a path outside ${editorFolder}, to keep the editor's folder to its own theme.`;
|
|
82
|
+
logger.warn(warning);
|
|
83
|
+
}
|
|
63
84
|
const {missingPackages, installCommand} = forkNeeds(outputDir, files, cwd);
|
|
64
85
|
return {
|
|
65
86
|
type: 'theme.eject',
|
|
@@ -29,7 +29,7 @@ export const doc = {
|
|
|
29
29
|
name: 'input',
|
|
30
30
|
type: 'TonalPaletteGenerationInput',
|
|
31
31
|
description:
|
|
32
|
-
'Families and seeds plus optional modes, shared stops, anchors, vibrancy from 0 to 100 (default 50), and
|
|
32
|
+
'Families and seeds plus optional modes, shared stops, anchors, vibrancy from 0 to 100 (default 50), neutral profile, and a dark chroma taper that mutes the dark edge of chromatic families.',
|
|
33
33
|
required: true,
|
|
34
34
|
},
|
|
35
35
|
],
|
|
@@ -43,7 +43,7 @@ export const doc = {
|
|
|
43
43
|
throws: [
|
|
44
44
|
{
|
|
45
45
|
code: 'Error',
|
|
46
|
-
when: 'the request, family, seed, stop layout, mode, or
|
|
46
|
+
when: 'the request, family, seed, stop layout, mode, anchor, or dark chroma taper is invalid',
|
|
47
47
|
},
|
|
48
48
|
],
|
|
49
49
|
examples: [
|
|
@@ -111,9 +111,16 @@ export const GENERATION_INPUT_KEYS = Object.freeze([
|
|
|
111
111
|
'vibrancy',
|
|
112
112
|
'neutralProfile',
|
|
113
113
|
'modeStrategy',
|
|
114
|
+
'darkChromaTaper',
|
|
114
115
|
'stops',
|
|
115
116
|
'families',
|
|
116
117
|
]);
|
|
118
|
+
const DARK_CHROMA_TAPER_KEYS = Object.freeze([
|
|
119
|
+
'edgeMultiplier',
|
|
120
|
+
'throughStop',
|
|
121
|
+
'recoverAtStop',
|
|
122
|
+
'familyMultipliers',
|
|
123
|
+
]);
|
|
117
124
|
export const FAMILY_INPUT_KEYS = Object.freeze([
|
|
118
125
|
'id',
|
|
119
126
|
'name',
|
|
@@ -235,6 +242,8 @@ function anchorPolarAtStop(seed, anchors, stop) {
|
|
|
235
242
|
* @param {PaletteMode} mode
|
|
236
243
|
* @param {number} vibrancy
|
|
237
244
|
* @param {boolean} coordinateWithOtherFamilies
|
|
245
|
+
* @param {number} [chromaMultiplier] Share of its in-gamut chroma the stop
|
|
246
|
+
* keeps (see darkChromaMultiplier).
|
|
238
247
|
*/
|
|
239
248
|
function generateCandidate(
|
|
240
249
|
source,
|
|
@@ -242,6 +251,7 @@ function generateCandidate(
|
|
|
242
251
|
mode,
|
|
243
252
|
vibrancy,
|
|
244
253
|
coordinateWithOtherFamilies,
|
|
254
|
+
chromaMultiplier = 1,
|
|
245
255
|
) {
|
|
246
256
|
const adjustedTone = tone;
|
|
247
257
|
const adjustedHue = toneAdjustedHue(source.hue, adjustedTone);
|
|
@@ -256,9 +266,16 @@ function generateCandidate(
|
|
|
256
266
|
toneChromaEnvelope(adjustedTone) *
|
|
257
267
|
(mode === 'dark' ? DARK_CHROMA_FACTOR : 1);
|
|
258
268
|
const lightness = toneToOklabLightness(adjustedTone);
|
|
269
|
+
const maxChroma = maxOklchChroma(adjustedHue, lightness);
|
|
270
|
+
// A taper scales the chroma the stop shows after gamut mapping, so a stop
|
|
271
|
+
// the gamut already limits loses the same share as any other stop.
|
|
272
|
+
const shownChroma =
|
|
273
|
+
chromaMultiplier === 1
|
|
274
|
+
? chroma
|
|
275
|
+
: Math.min(chroma, maxChroma) * chromaMultiplier;
|
|
259
276
|
return {
|
|
260
|
-
hex: oklchClampedHex(lightness,
|
|
261
|
-
gamutMapped: chroma >
|
|
277
|
+
hex: oklchClampedHex(lightness, shownChroma, adjustedHue),
|
|
278
|
+
gamutMapped: chroma > maxChroma + 0.000001,
|
|
262
279
|
};
|
|
263
280
|
}
|
|
264
281
|
|
|
@@ -490,6 +507,31 @@ function buildDiagnostics(colors, stops, sourceHue, gamutMappedStops, anchors) {
|
|
|
490
507
|
};
|
|
491
508
|
}
|
|
492
509
|
|
|
510
|
+
/**
|
|
511
|
+
* The share of its chroma a stop keeps under the request's
|
|
512
|
+
* `darkChromaTaper`: the edge multiplier through `throughStop`, a smoothstep
|
|
513
|
+
* back to 1 at `recoverAtStop`, and 1 from there on. Light ramps, neutral
|
|
514
|
+
* families, and the black and white endpoints keep all of it.
|
|
515
|
+
* @param {NormalizedRequest['darkChromaTaper']} taper
|
|
516
|
+
* @param {NormalizedFamily} family
|
|
517
|
+
* @param {PaletteMode} mode
|
|
518
|
+
* @param {number} stop
|
|
519
|
+
*/
|
|
520
|
+
function darkChromaMultiplier(taper, family, mode, stop) {
|
|
521
|
+
if (!taper || mode !== 'dark' || family.kind === 'neutral') return 1;
|
|
522
|
+
if (stop <= 0 || stop >= 100 || stop >= taper.recoverAtStop) return 1;
|
|
523
|
+
// Read own keys only. A family id such as `constructor` must not get a
|
|
524
|
+
// multiplier from the object prototype.
|
|
525
|
+
const edge = Object.hasOwn(taper.familyMultipliers, family.id)
|
|
526
|
+
? taper.familyMultipliers[family.id]
|
|
527
|
+
: taper.edgeMultiplier;
|
|
528
|
+
if (stop <= taper.throughStop) return edge;
|
|
529
|
+
const recovery = smoothstep(
|
|
530
|
+
(stop - taper.throughStop) / (taper.recoverAtStop - taper.throughStop),
|
|
531
|
+
);
|
|
532
|
+
return edge + (1 - edge) * recovery;
|
|
533
|
+
}
|
|
534
|
+
|
|
493
535
|
/** @param {NormalizedRequest} request @param {NormalizedFamily} family @param {PaletteMode} mode @returns {GeneratedRamp} */
|
|
494
536
|
function generateRamp(request, family, mode) {
|
|
495
537
|
const seedHex = normalizeColor(family.seed);
|
|
@@ -508,6 +550,7 @@ function generateRamp(request, family, mode) {
|
|
|
508
550
|
mode,
|
|
509
551
|
request.vibrancy,
|
|
510
552
|
family.kind !== 'neutral',
|
|
553
|
+
darkChromaMultiplier(request.darkChromaTaper, family, mode, 50),
|
|
511
554
|
).hex;
|
|
512
555
|
for (const stop of request.stops) {
|
|
513
556
|
const source = anchorPolarAtStop(seed, anchors, stop);
|
|
@@ -517,6 +560,7 @@ function generateRamp(request, family, mode) {
|
|
|
517
560
|
mode,
|
|
518
561
|
request.vibrancy,
|
|
519
562
|
family.kind !== 'neutral',
|
|
563
|
+
darkChromaMultiplier(request.darkChromaTaper, family, mode, stop),
|
|
520
564
|
);
|
|
521
565
|
colors[stop] = generated.hex;
|
|
522
566
|
if (generated.gamutMapped) gamutMappedStops.push(stop);
|
|
@@ -602,6 +646,95 @@ function buildCoordinationDiagnostics(request, families) {
|
|
|
602
646
|
});
|
|
603
647
|
}
|
|
604
648
|
|
|
649
|
+
/** @param {unknown} value @param {string} label */
|
|
650
|
+
function assertMultiplier(value, label) {
|
|
651
|
+
if (
|
|
652
|
+
typeof value !== 'number' ||
|
|
653
|
+
!Number.isFinite(value) ||
|
|
654
|
+
value < 0 ||
|
|
655
|
+
value > 1
|
|
656
|
+
) {
|
|
657
|
+
throw new Error(`${label} must be a number from 0 to 1.`);
|
|
658
|
+
}
|
|
659
|
+
return value;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* The request's dark chroma taper, checked against its stops and families,
|
|
664
|
+
* or undefined when the request has none. The receipt records the taper, so
|
|
665
|
+
* a field the taper does not read fails instead of changing nothing.
|
|
666
|
+
* @param {unknown} taper
|
|
667
|
+
* @param {number[]} stops
|
|
668
|
+
* @param {NormalizedFamily[]} families
|
|
669
|
+
* @returns {NormalizedRequest['darkChromaTaper']}
|
|
670
|
+
*/
|
|
671
|
+
function normalizeDarkChromaTaper(taper, stops, families) {
|
|
672
|
+
if (taper == null) return undefined;
|
|
673
|
+
if (typeof taper !== 'object' || Array.isArray(taper)) {
|
|
674
|
+
throw new Error('darkChromaTaper must be an object.');
|
|
675
|
+
}
|
|
676
|
+
const fields = /** @type {Record<string, unknown>} */ (taper);
|
|
677
|
+
const unread = Object.keys(fields).filter(
|
|
678
|
+
key => !DARK_CHROMA_TAPER_KEYS.includes(key),
|
|
679
|
+
);
|
|
680
|
+
if (unread.length > 0) {
|
|
681
|
+
throw new Error(
|
|
682
|
+
`darkChromaTaper does not read ${unread.join(', ')}; it reads ${DARK_CHROMA_TAPER_KEYS.join(', ')}.`,
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
const {edgeMultiplier, throughStop, recoverAtStop, familyMultipliers} =
|
|
686
|
+
fields;
|
|
687
|
+
const edge = assertMultiplier(
|
|
688
|
+
edgeMultiplier,
|
|
689
|
+
'darkChromaTaper.edgeMultiplier',
|
|
690
|
+
);
|
|
691
|
+
if (typeof throughStop !== 'number' || !stops.includes(throughStop)) {
|
|
692
|
+
throw new Error(
|
|
693
|
+
'darkChromaTaper.throughStop must be a stop in the requested stop layout.',
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
if (
|
|
697
|
+
typeof recoverAtStop !== 'number' ||
|
|
698
|
+
!stops.includes(recoverAtStop) ||
|
|
699
|
+
recoverAtStop <= throughStop
|
|
700
|
+
) {
|
|
701
|
+
throw new Error(
|
|
702
|
+
'darkChromaTaper.recoverAtStop must be a stop in the requested stop layout after throughStop.',
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
if (
|
|
706
|
+
familyMultipliers != null &&
|
|
707
|
+
(typeof familyMultipliers !== 'object' || Array.isArray(familyMultipliers))
|
|
708
|
+
) {
|
|
709
|
+
throw new Error('darkChromaTaper.familyMultipliers must be an object.');
|
|
710
|
+
}
|
|
711
|
+
/** @type {Record<string, number>} */
|
|
712
|
+
const multipliers = {};
|
|
713
|
+
for (const [id, value] of Object.entries(familyMultipliers ?? {})) {
|
|
714
|
+
const family = families.find(candidate => candidate.id === id);
|
|
715
|
+
if (!family) {
|
|
716
|
+
throw new Error(
|
|
717
|
+
`darkChromaTaper.familyMultipliers names unknown family ${id}.`,
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
if (family.kind === 'neutral') {
|
|
721
|
+
throw new Error(
|
|
722
|
+
`darkChromaTaper.familyMultipliers names neutral family ${id}; the taper changes only chromatic families.`,
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
multipliers[id] = assertMultiplier(
|
|
726
|
+
value,
|
|
727
|
+
`darkChromaTaper.familyMultipliers.${id}`,
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
return {
|
|
731
|
+
edgeMultiplier: edge,
|
|
732
|
+
throughStop,
|
|
733
|
+
recoverAtStop,
|
|
734
|
+
familyMultipliers: multipliers,
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
|
|
605
738
|
/** @param {TonalPaletteGenerationInput} input @returns {NormalizedRequest} */
|
|
606
739
|
export function normalizeGenerationRequest(input) {
|
|
607
740
|
if (!input || typeof input !== 'object' || Array.isArray(input)) {
|
|
@@ -708,12 +841,18 @@ export function normalizeGenerationRequest(input) {
|
|
|
708
841
|
if (!NEUTRAL_PROFILES.includes(neutralProfile)) {
|
|
709
842
|
throw new Error(`Unknown neutral profile: ${String(neutralProfile)}`);
|
|
710
843
|
}
|
|
844
|
+
const darkChromaTaper = normalizeDarkChromaTaper(
|
|
845
|
+
input.darkChromaTaper,
|
|
846
|
+
stops,
|
|
847
|
+
normalizedFamilies,
|
|
848
|
+
);
|
|
711
849
|
/** @type {NormalizedRequest} */
|
|
712
850
|
const request = {
|
|
713
851
|
recipe: PALETTE_RECIPE,
|
|
714
852
|
vibrancy: input.vibrancy ?? 50,
|
|
715
853
|
neutralProfile,
|
|
716
854
|
modeStrategy,
|
|
855
|
+
...(darkChromaTaper ? {darkChromaTaper} : {}),
|
|
717
856
|
stops,
|
|
718
857
|
families: normalizedFamilies,
|
|
719
858
|
};
|
|
@@ -15,7 +15,26 @@ export function themeTemplate(options?: {
|
|
|
15
15
|
overwrite?: boolean;
|
|
16
16
|
cwd?: string;
|
|
17
17
|
}): import("../theme.type.mjs").ThemeTemplateResponse;
|
|
18
|
+
/**
|
|
19
|
+
* The template write behind `themeTemplate`, with the experimental editor's
|
|
20
|
+
* one difference: with `editorFilesOnly`, in a folder the theme editor made
|
|
21
|
+
* only the editor's own files (`<folder>.*`) are protected, so an earlier
|
|
22
|
+
* template there is the person's. Internal: the experimental `template`
|
|
23
|
+
* command reaches it through `editorThemeTemplate` (api/theme-edit), and it
|
|
24
|
+
* is not part of the public API.
|
|
25
|
+
* @internal
|
|
26
|
+
* @param {{targetPath?: string, overwrite?: boolean, cwd?: string}} options
|
|
27
|
+
* @param {boolean} editorFilesOnly
|
|
28
|
+
* @returns {import('../theme.type.mjs').ThemeTemplateResponse}
|
|
29
|
+
*/
|
|
30
|
+
export function writeThemeTemplate(options: {
|
|
31
|
+
targetPath?: string;
|
|
32
|
+
overwrite?: boolean;
|
|
33
|
+
cwd?: string;
|
|
34
|
+
}, editorFilesOnly: boolean): import("../theme.type.mjs").ThemeTemplateResponse;
|
|
18
35
|
/** The annotated `defineTheme` reference that ships with the CLI. */
|
|
19
36
|
export const THEME_TEMPLATE_SRC: string;
|
|
37
|
+
/** The warning the CLI prints when it writes the template outside a project. */
|
|
38
|
+
export const OUTSIDE_PROJECT_WARNING: "Warning: no package.json is in this folder or above it, so the template is written here. Run it inside a project, or run `npm init -y` here first, to write it at a project root.";
|
|
20
39
|
/** Where it lands when the caller does not say. */
|
|
21
40
|
export const THEME_TEMPLATE_DEFAULT_PATH: "theme.template.ts";
|
|
@@ -15,8 +15,11 @@
|
|
|
15
15
|
|
|
16
16
|
import * as fs from 'node:fs';
|
|
17
17
|
import * as path from 'node:path';
|
|
18
|
-
import {CLI_ROOT} from '../../../foundation/fs/paths.mjs';
|
|
19
|
-
import {
|
|
18
|
+
import {CLI_ROOT, projectWritePath} from '../../../foundation/fs/paths.mjs';
|
|
19
|
+
import {
|
|
20
|
+
assertWithin,
|
|
21
|
+
PathSafetyError,
|
|
22
|
+
} from '../../../foundation/fs/path-safety.mjs';
|
|
20
23
|
import {stripCopyrightHeader} from '../../../foundation/text/copyright-header.mjs';
|
|
21
24
|
import {formatCliCommand} from '../../../foundation/env/package-manager.mjs';
|
|
22
25
|
import {fsErrorMessage} from '../../../foundation/fs/fs-error.mjs';
|
|
@@ -25,7 +28,15 @@ import {AstryxError} from '../../error.mjs';
|
|
|
25
28
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
26
29
|
|
|
27
30
|
/** The annotated `defineTheme` reference that ships with the CLI. */
|
|
28
|
-
export const THEME_TEMPLATE_SRC = path.join(
|
|
31
|
+
export const THEME_TEMPLATE_SRC = path.join(
|
|
32
|
+
CLI_ROOT,
|
|
33
|
+
'assets',
|
|
34
|
+
'theme.template.ts',
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
/** The warning the CLI prints when it writes the template outside a project. */
|
|
38
|
+
export const OUTSIDE_PROJECT_WARNING =
|
|
39
|
+
'Warning: no package.json is in this folder or above it, so the template is written here. Run it inside a project, or run `npm init -y` here first, to write it at a project root.';
|
|
29
40
|
|
|
30
41
|
/** Where it lands when the caller does not say. */
|
|
31
42
|
export const THEME_TEMPLATE_DEFAULT_PATH = 'theme.template.ts';
|
|
@@ -72,6 +83,22 @@ function isReplaceableThemeFile(file) {
|
|
|
72
83
|
* @returns {import('../theme.type.mjs').ThemeTemplateResponse}
|
|
73
84
|
*/
|
|
74
85
|
export function themeTemplate(options = {}) {
|
|
86
|
+
return writeThemeTemplate(options, false);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The template write behind `themeTemplate`, with the experimental editor's
|
|
91
|
+
* one difference: with `editorFilesOnly`, in a folder the theme editor made
|
|
92
|
+
* only the editor's own files (`<folder>.*`) are protected, so an earlier
|
|
93
|
+
* template there is the person's. Internal: the experimental `template`
|
|
94
|
+
* command reaches it through `editorThemeTemplate` (api/theme-edit), and it
|
|
95
|
+
* is not part of the public API.
|
|
96
|
+
* @internal
|
|
97
|
+
* @param {{targetPath?: string, overwrite?: boolean, cwd?: string}} options
|
|
98
|
+
* @param {boolean} editorFilesOnly
|
|
99
|
+
* @returns {import('../theme.type.mjs').ThemeTemplateResponse}
|
|
100
|
+
*/
|
|
101
|
+
export function writeThemeTemplate(options, editorFilesOnly) {
|
|
75
102
|
const {
|
|
76
103
|
targetPath = THEME_TEMPLATE_DEFAULT_PATH,
|
|
77
104
|
overwrite = false,
|
|
@@ -86,34 +113,52 @@ export function themeTemplate(options = {}) {
|
|
|
86
113
|
);
|
|
87
114
|
if (String(targetPath).trim() === '') {
|
|
88
115
|
throw new AstryxError(
|
|
89
|
-
'The theme template path is blank. Give a file path, or leave it out for theme.template.ts.',
|
|
116
|
+
'The theme template path is blank. Give a file path, or leave it out for theme.template.ts at the project root.',
|
|
90
117
|
[
|
|
91
118
|
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
),
|
|
96
|
-
reason: 'the default path',
|
|
119
|
+
// No path: the template at the project root, from any folder.
|
|
120
|
+
name: formatCliCommand('theme template', cwd),
|
|
121
|
+
reason: 'write the template at the project root',
|
|
97
122
|
},
|
|
98
123
|
],
|
|
99
124
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
100
125
|
);
|
|
101
126
|
}
|
|
102
127
|
|
|
128
|
+
// The project the folder belongs to bounds the path, as for other theme
|
|
129
|
+
// commands: a path given is read from the current folder, and no path
|
|
130
|
+
// means the project root.
|
|
131
|
+
// With no package.json at or above the folder it writes here, and the CLI
|
|
132
|
+
// prints OUTSIDE_PROJECT_WARNING.
|
|
133
|
+
// Read as every theme command reads a path it writes; a backslash
|
|
134
|
+
// separates folders on every platform.
|
|
135
|
+
const {projectDir, relative: fromRoot} = projectWritePath(
|
|
136
|
+
cwd,
|
|
137
|
+
options.targetPath == null ? undefined : String(targetPath),
|
|
138
|
+
THEME_TEMPLATE_DEFAULT_PATH,
|
|
139
|
+
);
|
|
103
140
|
let resolved;
|
|
104
141
|
try {
|
|
105
|
-
resolved = assertWithin(
|
|
142
|
+
resolved = assertWithin(fromRoot, projectDir, {
|
|
143
|
+
label: 'theme template path',
|
|
144
|
+
});
|
|
106
145
|
} catch (err) {
|
|
107
146
|
if (err instanceof PathSafetyError) {
|
|
108
147
|
throw new AstryxError(
|
|
109
|
-
|
|
148
|
+
// The path as typed, not as read from the project root.
|
|
149
|
+
// A typed path is read from the current folder, so the advice says
|
|
150
|
+
// so (the safety check reads it from the project root).
|
|
151
|
+
err.message
|
|
152
|
+
.replace(`"${fromRoot}"`, `"${targetPath}"`)
|
|
153
|
+
.replace(
|
|
154
|
+
/relative to the project root/g,
|
|
155
|
+
'relative to the current folder, inside the project',
|
|
156
|
+
),
|
|
110
157
|
[
|
|
111
158
|
{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
),
|
|
116
|
-
reason: 'write the template in this project',
|
|
159
|
+
// No path: the template at the project root.
|
|
160
|
+
name: formatCliCommand('theme template', cwd),
|
|
161
|
+
reason: 'write the template at the project root',
|
|
117
162
|
},
|
|
118
163
|
],
|
|
119
164
|
ERROR_CODES.ERR_PATH_TRAVERSAL,
|
|
@@ -153,10 +198,39 @@ export function themeTemplate(options = {}) {
|
|
|
153
198
|
);
|
|
154
199
|
}
|
|
155
200
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
201
|
+
// The folder as it is on disk (`themes/T` is `themes/t` on a
|
|
202
|
+
// case-insensitive disk, or through a link).
|
|
203
|
+
const realDir = fs.existsSync(resolved)
|
|
204
|
+
? fs.realpathSync(path.dirname(resolved))
|
|
205
|
+
: path.dirname(resolved);
|
|
206
|
+
const record = fs.existsSync(resolved) ? editorThemeRecord(realDir) : null;
|
|
207
|
+
// The editor's own files are `<folder>.*` beside its settings; with
|
|
208
|
+
// editorFilesOnly any other file there (an earlier template) is the
|
|
209
|
+
// person's.
|
|
210
|
+
// On a case-insensitive disk `T.theme.ts` is `t.theme.ts`: names are
|
|
211
|
+
// compared in any case, and an existing file by what it is on disk.
|
|
212
|
+
const folder = path.basename(realDir).toLowerCase();
|
|
213
|
+
const sameFile = (/** @type {string} */ other) => {
|
|
214
|
+
try {
|
|
215
|
+
const a = fs.statSync(resolved);
|
|
216
|
+
const b = fs.statSync(other);
|
|
217
|
+
return a.ino === b.ino && a.dev === b.dev;
|
|
218
|
+
} catch {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
const editorFile =
|
|
223
|
+
record != null &&
|
|
224
|
+
(!editorFilesOnly ||
|
|
225
|
+
path.basename(resolved).toLowerCase().startsWith(`${folder}.`) ||
|
|
226
|
+
fs
|
|
227
|
+
.readdirSync(realDir)
|
|
228
|
+
.some(
|
|
229
|
+
f =>
|
|
230
|
+
f.toLowerCase().startsWith(`${folder}.`) &&
|
|
231
|
+
sameFile(path.join(realDir, f)),
|
|
232
|
+
));
|
|
233
|
+
const editorRecord = overwrite && editorFile ? record : null;
|
|
160
234
|
if (editorRecord) {
|
|
161
235
|
throw new AstryxError(
|
|
162
236
|
`${relative} belongs to a theme the theme editor made (${editorRecord} is beside it). Replacing it would cut the theme off from its settings, so --overwrite does not replace it.`,
|
|
@@ -196,9 +270,7 @@ export function themeTemplate(options = {}) {
|
|
|
196
270
|
if (fs.existsSync(resolved) && !overwrite) {
|
|
197
271
|
// Whether --overwrite would replace this file, and if not, a path that
|
|
198
272
|
// takes the template, so the hint never names a command that refuses.
|
|
199
|
-
const overwritable =
|
|
200
|
-
!editorThemeRecord(path.dirname(resolved)) &&
|
|
201
|
-
isReplaceableThemeFile(resolved);
|
|
273
|
+
const overwritable = !editorFile && isReplaceableThemeFile(resolved);
|
|
202
274
|
return {
|
|
203
275
|
type: 'theme.template',
|
|
204
276
|
data: {
|
|
@@ -212,7 +284,9 @@ export function themeTemplate(options = {}) {
|
|
|
212
284
|
}
|
|
213
285
|
|
|
214
286
|
// Our repo header has no business in someone else's source tree.
|
|
215
|
-
const contents = stripCopyrightHeader(
|
|
287
|
+
const contents = stripCopyrightHeader(
|
|
288
|
+
fs.readFileSync(THEME_TEMPLATE_SRC, 'utf-8'),
|
|
289
|
+
);
|
|
216
290
|
try {
|
|
217
291
|
fs.mkdirSync(path.dirname(resolved), {recursive: true});
|
|
218
292
|
fs.writeFileSync(resolved, contents);
|
|
@@ -223,7 +297,10 @@ export function themeTemplate(options = {}) {
|
|
|
223
297
|
throw new AstryxError(message, undefined, ERROR_CODES.ERR_WRITE_FAILED);
|
|
224
298
|
}
|
|
225
299
|
|
|
226
|
-
return {
|
|
300
|
+
return {
|
|
301
|
+
type: 'theme.template',
|
|
302
|
+
data: {path: relative, written: true, reason: null},
|
|
303
|
+
};
|
|
227
304
|
}
|
|
228
305
|
|
|
229
306
|
/** @param {string} file */
|
|
@@ -32,6 +32,9 @@ export type ThemeBuildResponse = {
|
|
|
32
32
|
*/
|
|
33
33
|
export type ThemeBuildCheckResponse = {
|
|
34
34
|
type: "theme.build.check";
|
|
35
|
+
/**
|
|
36
|
+
* `code` is set when the outputs are stale or missing (exit 1).
|
|
37
|
+
*/
|
|
35
38
|
data: {
|
|
36
39
|
name: string;
|
|
37
40
|
upToDate: boolean;
|
|
@@ -40,6 +43,7 @@ export type ThemeBuildCheckResponse = {
|
|
|
40
43
|
reason: "missing" | "outdated";
|
|
41
44
|
}>;
|
|
42
45
|
checked: string[];
|
|
46
|
+
code?: "ERR_THEME_STALE";
|
|
43
47
|
};
|
|
44
48
|
};
|
|
45
49
|
/**
|
|
@@ -281,12 +285,40 @@ export type TonalPaletteFamilyInput = {
|
|
|
281
285
|
* `neutral` derives the ramp from
|
|
282
286
|
* `neutralProfile` instead of the seed hue; defaults to `chromatic`.
|
|
283
287
|
*/
|
|
284
|
-
kind?: "
|
|
288
|
+
kind?: "chromatic" | "neutral" | undefined;
|
|
285
289
|
/**
|
|
286
290
|
* Colors pinned at specific stops.
|
|
287
291
|
*/
|
|
288
292
|
anchors?: TonalPaletteAnchor[] | undefined;
|
|
289
293
|
};
|
|
294
|
+
/**
|
|
295
|
+
* Mutes the dark edge of every chromatic family. Their dark ramps keep
|
|
296
|
+
* `edgeMultiplier` of their in-gamut chroma through `throughStop`, then
|
|
297
|
+
* recover along a smoothstep to the standard recipe at `recoverAtStop`. Light
|
|
298
|
+
* ramps, neutral families, and the black and white endpoints do not change.
|
|
299
|
+
*/
|
|
300
|
+
export type TonalPaletteDarkChromaTaper = {
|
|
301
|
+
/**
|
|
302
|
+
* Share of chroma, from 0 to 1, that the
|
|
303
|
+
* dark edge keeps.
|
|
304
|
+
*/
|
|
305
|
+
edgeMultiplier: number;
|
|
306
|
+
/**
|
|
307
|
+
* Last stop that takes the full edge
|
|
308
|
+
* multiplier; must be a requested stop.
|
|
309
|
+
*/
|
|
310
|
+
throughStop: number;
|
|
311
|
+
/**
|
|
312
|
+
* First stop back on the standard recipe;
|
|
313
|
+
* must be a requested stop after `throughStop`.
|
|
314
|
+
*/
|
|
315
|
+
recoverAtStop: number;
|
|
316
|
+
/**
|
|
317
|
+
* Edge multipliers,
|
|
318
|
+
* from 0 to 1, by chromatic family id, in place of `edgeMultiplier`.
|
|
319
|
+
*/
|
|
320
|
+
familyMultipliers?: Record<string, number> | undefined;
|
|
321
|
+
};
|
|
290
322
|
export type TonalPaletteGenerationInput = {
|
|
291
323
|
families: TonalPaletteFamilyInput[];
|
|
292
324
|
/**
|
|
@@ -301,6 +333,11 @@ export type TonalPaletteGenerationInput = {
|
|
|
301
333
|
*/
|
|
302
334
|
neutralProfile?: "custom" | "neutral-v1" | "warm-v1" | "cool-v1" | undefined;
|
|
303
335
|
modeStrategy?: "light-only" | "dark-only" | "light-and-dark" | undefined;
|
|
336
|
+
/**
|
|
337
|
+
* Mutes the dark
|
|
338
|
+
* edge of the chromatic families.
|
|
339
|
+
*/
|
|
340
|
+
darkChromaTaper?: TonalPaletteDarkChromaTaper | undefined;
|
|
304
341
|
/**
|
|
305
342
|
* Ordered stops shared by every requested family;
|
|
306
343
|
* defaults to 0 through 100 in increments of 5. Decimal stops are supported,
|
|
@@ -418,6 +455,12 @@ export type TonalPaletteNormalizedRequest = {
|
|
|
418
455
|
vibrancy: number;
|
|
419
456
|
neutralProfile: "neutral-v1" | "warm-v1" | "cool-v1" | "custom";
|
|
420
457
|
modeStrategy: "light-only" | "dark-only" | "light-and-dark";
|
|
458
|
+
/**
|
|
459
|
+
* The
|
|
460
|
+
* requested taper, with `familyMultipliers` filled in; present only when the
|
|
461
|
+
* request has a taper.
|
|
462
|
+
*/
|
|
463
|
+
darkChromaTaper?: Required<TonalPaletteDarkChromaTaper> | undefined;
|
|
421
464
|
stops: number[];
|
|
422
465
|
families: Array<{
|
|
423
466
|
id: string;
|
package/api/theme/theme.type.mjs
CHANGED
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
* astryx --json theme build <file> --check
|
|
39
39
|
* @typedef {object} ThemeBuildCheckResponse
|
|
40
40
|
* @property {'theme.build.check'} type
|
|
41
|
-
* @property {{name: string, upToDate: boolean, stale: Array<{path: string, reason: 'missing' | 'outdated'}>, checked: string[]}} data
|
|
41
|
+
* @property {{name: string, upToDate: boolean, stale: Array<{path: string, reason: 'missing' | 'outdated'}>, checked: string[], code?: 'ERR_THEME_STALE'}} data
|
|
42
|
+
* `code` is set when the outputs are stale or missing (exit 1).
|
|
42
43
|
*/
|
|
43
44
|
|
|
44
45
|
/**
|
|
@@ -177,6 +178,22 @@
|
|
|
177
178
|
* @property {TonalPaletteAnchor[]} [anchors] Colors pinned at specific stops.
|
|
178
179
|
*/
|
|
179
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Mutes the dark edge of every chromatic family. Their dark ramps keep
|
|
183
|
+
* `edgeMultiplier` of their in-gamut chroma through `throughStop`, then
|
|
184
|
+
* recover along a smoothstep to the standard recipe at `recoverAtStop`. Light
|
|
185
|
+
* ramps, neutral families, and the black and white endpoints do not change.
|
|
186
|
+
* @typedef {object} TonalPaletteDarkChromaTaper
|
|
187
|
+
* @property {number} edgeMultiplier Share of chroma, from 0 to 1, that the
|
|
188
|
+
* dark edge keeps.
|
|
189
|
+
* @property {number} throughStop Last stop that takes the full edge
|
|
190
|
+
* multiplier; must be a requested stop.
|
|
191
|
+
* @property {number} recoverAtStop First stop back on the standard recipe;
|
|
192
|
+
* must be a requested stop after `throughStop`.
|
|
193
|
+
* @property {Record<string, number>} [familyMultipliers] Edge multipliers,
|
|
194
|
+
* from 0 to 1, by chromatic family id, in place of `edgeMultiplier`.
|
|
195
|
+
*/
|
|
196
|
+
|
|
180
197
|
/**
|
|
181
198
|
* @typedef {object} TonalPaletteGenerationInput
|
|
182
199
|
* @property {TonalPaletteFamilyInput[]} families
|
|
@@ -187,6 +204,8 @@
|
|
|
187
204
|
* `warm-v1` and `cool-v1` add a slight tint, and `custom` derives the hue from
|
|
188
205
|
* the family's own seed. Defaults to `neutral-v1`.
|
|
189
206
|
* @property {'light-only' | 'dark-only' | 'light-and-dark'} [modeStrategy]
|
|
207
|
+
* @property {TonalPaletteDarkChromaTaper} [darkChromaTaper] Mutes the dark
|
|
208
|
+
* edge of the chromatic families.
|
|
190
209
|
* @property {number[]} [stops] Ordered stops shared by every requested family;
|
|
191
210
|
* defaults to 0 through 100 in increments of 5. Decimal stops are supported,
|
|
192
211
|
* and authors may omit the repeated black and white endpoints.
|
|
@@ -244,6 +263,9 @@
|
|
|
244
263
|
* @property {number} vibrancy
|
|
245
264
|
* @property {'neutral-v1' | 'warm-v1' | 'cool-v1' | 'custom'} neutralProfile
|
|
246
265
|
* @property {'light-only' | 'dark-only' | 'light-and-dark'} modeStrategy
|
|
266
|
+
* @property {Required<TonalPaletteDarkChromaTaper>} [darkChromaTaper] The
|
|
267
|
+
* requested taper, with `familyMultipliers` filled in; present only when the
|
|
268
|
+
* request has a taper.
|
|
247
269
|
* @property {number[]} stops
|
|
248
270
|
* @property {Array<{id: string, name: string, seed: string, kind: 'chromatic' | 'neutral', anchors: TonalPaletteAnchor[]}>} families
|
|
249
271
|
*/
|
|
@@ -58,7 +58,7 @@ export const doc = {
|
|
|
58
58
|
name: 'options.out',
|
|
59
59
|
type: 'string',
|
|
60
60
|
description:
|
|
61
|
-
'Override the output CSS path, relative or absolute; a build refuses a path outside cwd, and check mode refuses only a relative path that escapes cwd. The .js, .d.ts and any .variants.d.ts are written in the same directory, named after the theme (<name>.js), not after the CSS file. An existing folder, or a path that ends in a separator, names the folder: the CSS is written there as <name>.css. A file path should end in .css; another name still builds, with a warning, and the import line it prints names the file as written.',
|
|
61
|
+
'Override the output CSS path, relative or absolute; a build refuses a path outside cwd, and check mode refuses only a relative path that escapes cwd. The .js, .d.ts and any .variants.d.ts are written in the same directory, named after the theme (<name>.js), not after the CSS file. An existing folder, or a path that ends in a separator, names the folder: the CSS is written there as <name>.css. A file path should end in .css; another name still builds, with a warning, and the import line it prints names the file as written. A path in a folder the theme editor made (folder <slug>/ holds <slug>.settings.json) takes the outputs of a source outside that folder too, and the CLI warns; to keep the editor folder to its own theme, build beside the source, or pick an out path outside it.',
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
64
|
name: 'options.check',
|
|
@@ -90,7 +90,7 @@ export const doc = {
|
|
|
90
90
|
{
|
|
91
91
|
type: 'theme.build.check',
|
|
92
92
|
description:
|
|
93
|
-
'The {check: true} receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: "missing" | "outdated"}),
|
|
93
|
+
'The {check: true} receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: "missing" | "outdated"}), the full list of checked paths, and, when stale, code ERR_THEME_STALE. Writes nothing. Resolves to null, like a normal build, when the theme produces no CSS.',
|
|
94
94
|
},
|
|
95
95
|
],
|
|
96
96
|
throws: [
|
|
@@ -104,11 +104,11 @@ export const doc = {
|
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
106
|
code: 'ERR_THEME_INVALID',
|
|
107
|
-
when: 'the resolved theme is invalid, for example it has no name, a custom Heading type has no standalone rule with a declaration the compiler can emit, or its icon registry cannot be preserved through an import (also rejected in check mode); or an output would replace the theme source, two outputs share one path, or the file is itself an output of a build, whatever its extension (refused before loading, naming the source it was built from); in a batch, two themes that build the same outputs are refused before either writes',
|
|
107
|
+
when: 'the resolved theme is invalid, for example it has no name, it sets a private `--_*` variable (refused before anything is written, also in check mode; each one is named), a custom Heading type has no standalone rule with a declaration the compiler can emit, or its icon registry cannot be preserved through an import (also rejected in check mode); or an output would replace the theme source, two outputs share one path, or the file is itself an output of a build, whatever its extension (refused before loading, naming the source it was built from); in a batch, two themes that build the same outputs are refused before either writes',
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
code: 'ERR_FILE_EXISTS',
|
|
111
|
-
when: 'a path that out names holds a non-empty file without the generated header, such as package.json, app source, or an output from a CLI before 0.6.7; nothing is written.
|
|
111
|
+
when: 'a path that out names holds a non-empty file without the generated header, such as package.json, app source, or an output from a CLI before 0.6.7; nothing is written. The suggestions name a free out path beside it and the build beside the source; the file is left as it is. At the default paths beside the source, and at family output paths, a header-less file is an output of a CLI before 0.6.7 and is replaced',
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
114
|
code: 'ERR_INVALID_ARGUMENT',
|