@astryxdesign/cli 0.7.17 → 0.7.18-canary.g6dfc0b6
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 +1 -1
- package/api/discover/_adapter.d.mts +7 -5
- package/api/discover/_adapter.mjs +12 -11
- package/api/doctor/_adapter.d.mts +11 -62
- package/api/doctor/_adapter.mjs +242 -472
- package/api/doctor/doctor.d.mts +1 -1
- package/api/doctor/doctor.mjs +1 -1
- package/api/doctor/theme-checks.mjs +37 -45
- package/api/error.d.mts +21 -0
- package/api/error.mjs +89 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/icon/icon.doc.mjs +1 -1
- package/api/icon/icon.type.mjs +1 -1
- package/api/icon/search/search.d.mts +4 -1
- package/api/icon/search/search.mjs +41 -4
- package/api/render/_adapter.mjs +233 -40
- package/api/render/render.type.d.mts +1 -1
- package/api/render/render.type.mjs +1 -1
- package/api/search/ORDERING.md +2 -2
- package/api/search/_candidate-score.mjs +32 -8
- package/api/search/_cards.json +1 -1
- package/api/search/_compound.d.mts +0 -1
- package/api/search/_compound.mjs +93 -2
- package/api/search/_lexical.mjs +177 -17
- package/api/search/_order.d.mts +3 -1
- package/api/search/_order.mjs +16 -5
- package/api/search/_result.d.mts +9 -0
- package/api/search/_result.mjs +10 -0
- package/api/search/_score.mjs +21 -3
- package/api/swizzle/_moduleGraph.d.mts +8 -0
- package/api/swizzle/_moduleGraph.mjs +61 -3
- package/api/template/copy/copy.mjs +5 -3
- package/api/theme/_adapter.mjs +48 -12
- package/api/theme/build/build.d.mts +4 -0
- package/api/theme/build/build.mjs +69 -18
- package/api/theme/build/style-keys.mjs +4 -5
- package/api/theme/build/theme-object.mjs +5 -0
- package/api/theme/palette/generate/color.d.mts +47 -0
- package/api/theme/palette/generate/color.mjs +58 -1
- package/api/theme/palette/generate/derive-look.d.mts +293 -0
- package/api/theme/palette/generate/derive-look.mjs +1362 -0
- package/api/theme/palette/generate/editor-look.d.mts +62 -0
- package/api/theme/palette/generate/editor-look.mjs +550 -0
- package/api/theme/palette/generate/mapping.d.mts +94 -9
- package/api/theme/palette/generate/mapping.mjs +94 -22
- package/api/theme-edit/_adapter.mjs +10 -1
- package/api/theme-edit/_catalog.d.mts +13 -13
- package/api/theme-edit/_catalog.mjs +38 -16
- package/api/theme-edit/_check.d.mts +82 -6
- package/api/theme-edit/_check.mjs +1230 -223
- package/api/theme-edit/_color.d.mts +74 -0
- package/api/theme-edit/_color.mjs +168 -3
- package/api/theme-edit/_compiler.d.mts +3 -5
- package/api/theme-edit/_compiler.mjs +122 -23
- package/api/theme-edit/_context.d.mts +46 -5
- package/api/theme-edit/_context.mjs +97 -49
- package/api/theme-edit/_css.d.mts +11 -0
- package/api/theme-edit/_css.mjs +40 -0
- package/api/theme-edit/_edit.d.mts +13 -0
- package/api/theme-edit/_edit.mjs +1450 -128
- package/api/theme-edit/_how-commands.d.mts +12 -0
- package/api/theme-edit/_how-commands.mjs +96 -14
- package/api/theme-edit/_how-question.d.mts +73 -29
- package/api/theme-edit/_how-question.mjs +8131 -1209
- package/api/theme-edit/_how-sides.d.mts +22 -0
- package/api/theme-edit/_how-sides.mjs +173 -0
- package/api/theme-edit/_how-steps.d.mts +42 -0
- package/api/theme-edit/_how-steps.mjs +208 -0
- package/api/theme-edit/_how-values.d.mts +29 -0
- package/api/theme-edit/_how-values.mjs +111 -0
- package/api/theme-edit/_how-words.d.mts +15 -0
- package/api/theme-edit/_how-words.mjs +239 -0
- package/api/theme-edit/_how.d.mts +1 -1
- package/api/theme-edit/_how.mjs +412 -37
- package/api/theme-edit/_missed.d.mts +2 -1
- package/api/theme-edit/_missed.mjs +125 -13
- package/api/theme-edit/_normal.d.mts +5 -3
- package/api/theme-edit/_normal.mjs +54 -14
- package/api/theme-edit/_palette.d.mts +204 -4
- package/api/theme-edit/_palette.mjs +901 -25
- package/api/theme-edit/_part-pieces.d.mts +54 -0
- package/api/theme-edit/_part-pieces.mjs +179 -0
- package/api/theme-edit/_part-words.mjs +33 -5
- package/api/theme-edit/_parts.d.mts +133 -0
- package/api/theme-edit/_parts.mjs +599 -10
- package/api/theme-edit/_picture-traits.d.mts +259 -0
- package/api/theme-edit/_picture-traits.mjs +1030 -0
- package/api/theme-edit/_preview.d.mts +84 -4
- package/api/theme-edit/_preview.mjs +260 -24
- package/api/theme-edit/_project.d.mts +14 -4
- package/api/theme-edit/_project.mjs +95 -26
- package/api/theme-edit/_set-line.d.mts +29 -0
- package/api/theme-edit/_set-line.mjs +100 -0
- package/api/theme-edit/_settings.d.mts +625 -28
- package/api/theme-edit/_settings.mjs +4587 -880
- package/api/theme-edit/_tables.d.mts +25 -1
- package/api/theme-edit/_tables.mjs +115 -11
- package/api/theme-edit/_text-looks.d.mts +78 -0
- package/api/theme-edit/_text-looks.mjs +376 -0
- package/api/theme-edit/_vet.d.mts +3 -26
- package/api/theme-edit/_vet.mjs +5 -89
- package/api/theme-edit/how/how.d.mts +1 -1
- package/api/theme-edit/how/how.mjs +1 -1
- package/api/theme-edit/theme-edit.type.d.mts +54 -1
- package/api/theme-edit/theme-edit.type.mjs +17 -2
- package/api/theme-edit/themeEditHow.doc.mjs +3 -3
- package/api/theme-edit/themeEditNew.doc.mjs +4 -0
- package/api/theme-edit/themeEditSet.doc.mjs +6 -2
- package/api/theme-edit/themeEditShow.doc.mjs +4 -0
- package/api/theme-edit/themeEditUndo.doc.mjs +4 -0
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/author-a-theme.doc.mjs +7 -4
- package/assets/docs/tree/export-pages.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +89 -17
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/icons/definitions/article.doc.mjs +9 -0
- package/assets/icons/template-icons.json +5 -0
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Citation/CitationInlineText.doc.mjs +1 -1
- package/assets/templates/blocks/components/Citation/CitationInlineText.tsx +3 -1
- package/assets/templates/blocks/components/Citation/CitationShowcase.doc.mjs +1 -1
- package/assets/templates/blocks/components/Citation/CitationShowcase.tsx +3 -1
- package/assets/templates/blocks/components/Citation/CitationSourceList.doc.mjs +1 -1
- package/assets/templates/blocks/components/Citation/CitationSourceList.tsx +7 -3
- package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.doc.mjs +1 -1
- package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.tsx +5 -2
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ide/page.tsx +5 -10
- package/assets/templates/pages/payment-form/page.tsx +16 -60
- package/assets/templates/themes/neutral/neutralTheme.ts +4 -3
- package/authoring/debug/parse.d.mts +1 -1
- package/authoring/doctypes/_schema.d.mts +13 -13
- package/authoring/gap-report/parse.d.mts +1 -1
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/ensure-core-built.mjs +17 -10
- package/clients/cli/commands/experimental/theme.mjs +46 -6
- package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +11 -3
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/hook.mjs +7 -0
- package/clients/cli/commands/theme-build.doc.mjs +1 -1
- package/clients/cli/index.mjs +6 -2
- package/clients/cli/lib/hook-format.mjs +41 -1
- package/clients/cli/lib/json-shim.mjs +34 -14
- package/clients/cli/lib/other-cli-words.mjs +7 -0
- package/clients/cli/lib/unknown-command.mjs +345 -46
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.d.mts +11 -2
- package/foundation/agent-docs/agent-docs.mjs +51 -8
- package/foundation/config/project.d.mts +11 -1
- package/foundation/config/project.mjs +11 -2
- package/foundation/discovery/component-replacement.d.mts +5 -8
- package/foundation/discovery/component-replacement.mjs +12 -14
- package/foundation/discovery/core-augmentation-points.d.mts +35 -0
- package/foundation/discovery/core-augmentation-points.mjs +410 -9
- package/foundation/discovery/core-elements.d.mts +6 -0
- package/foundation/discovery/core-elements.mjs +10 -2
- package/foundation/discovery/core-prop-types.d.mts +5 -0
- package/foundation/discovery/core-prop-types.mjs +10 -3
- package/foundation/discovery/core-props.d.mts +8 -0
- package/foundation/discovery/core-props.mjs +29 -13
- package/foundation/discovery/official-list.d.mts +17 -0
- package/foundation/discovery/official-list.mjs +77 -0
- package/foundation/discovery/unknown-core-props.d.mts +130 -0
- package/foundation/discovery/unknown-core-props.mjs +601 -0
- package/foundation/discovery/written-prop-values.d.mts +35 -0
- package/foundation/discovery/written-prop-values.mjs +258 -0
- package/foundation/fonts/fontsource-families.generated.d.mts +5 -0
- package/foundation/fonts/fontsource-families.generated.mjs +2110 -0
- package/foundation/fs/package-name.d.mts +10 -0
- package/foundation/fs/package-name.mjs +37 -0
- package/foundation/fs/project-source-files.d.mts +27 -0
- package/foundation/fs/project-source-files.mjs +115 -0
- package/foundation/fs/project-sources.d.mts +25 -0
- package/foundation/fs/project-sources.mjs +83 -0
- package/foundation/fs/read-record.d.mts +18 -0
- package/foundation/fs/read-record.mjs +36 -2
- package/foundation/integrations/integration-warnings.d.mts +39 -7
- package/foundation/integrations/integration-warnings.mjs +141 -19
- package/foundation/integrations/missing-dependency.d.mts +11 -0
- package/foundation/integrations/missing-dependency.mjs +20 -5
- package/foundation/release/folder-lock.d.mts +5 -2
- package/foundation/release/folder-lock.mjs +9 -3
- package/foundation/release/notices.mjs +2 -8
- package/foundation/render/cut-short.d.mts +8 -2
- package/foundation/render/cut-short.mjs +50 -5
- package/foundation/render/drawn-contrast.d.mts +38 -0
- package/foundation/render/drawn-contrast.mjs +237 -0
- package/foundation/render/file-header.mjs +4 -0
- package/foundation/render/layers.d.mts +2 -1
- package/foundation/render/layers.mjs +22 -1
- package/foundation/render/page-worker.mjs +83 -18
- package/foundation/render/part-boxes.d.mts +27 -0
- package/foundation/render/part-boxes.mjs +45 -0
- package/foundation/render/picture-chrome.mjs +36 -4
- package/foundation/render/picture-playwright.mjs +26 -2
- package/foundation/render/picture-window.d.mts +29 -2
- package/foundation/render/picture-window.mjs +99 -1
- package/foundation/render/render-page.d.mts +39 -6
- package/foundation/render/render-page.mjs +26 -10
- package/foundation/render/ts-paths.mjs +2 -1
- package/foundation/response/error-codes.doc.mjs +1 -1
- package/foundation/response/error-codes.mjs +1 -1
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/text/written-string.d.mts +4 -1
- package/foundation/text/written-string.mjs +4 -1
- package/package.json +8 -7
|
@@ -566,8 +566,12 @@ export type ThemeBuildTrailer = {
|
|
|
566
566
|
* `ownsOutputs` says the caller made the folder the outputs go into and owns
|
|
567
567
|
* every file there named like one (the theme editor's theme folder), so a
|
|
568
568
|
* damaged or half-written output is replaced, never refused.
|
|
569
|
+
* `warnings` takes each warning message of the build, in check mode too,
|
|
570
|
+
* where the receipt carries none (the theme editor, recording a source as
|
|
571
|
+
* built without building it, keeps the warnings that build gives).
|
|
569
572
|
*/
|
|
570
573
|
export type ThemeBuildHandOff = {
|
|
574
|
+
warnings?: string[];
|
|
571
575
|
ownsOutputs?: boolean;
|
|
572
576
|
prepareFamily?: boolean;
|
|
573
577
|
familyLoader?: any;
|
|
@@ -67,6 +67,7 @@ import {createRequire, isBuiltin} from 'node:module';
|
|
|
67
67
|
import {moduleImports} from '../../../foundation/render/embedded-imports.mjs';
|
|
68
68
|
import {projectMapsImport} from '../../../foundation/render/ts-paths.mjs';
|
|
69
69
|
import {STYLESHEET_FILE} from '../../../foundation/fs/stylesheet-file.mjs';
|
|
70
|
+
import {packageNameAt} from '../../../foundation/fs/package-name.mjs';
|
|
70
71
|
import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
71
72
|
import {babelParse as parse} from '../../../foundation/runtime/lazy-dependencies.mjs';
|
|
72
73
|
import {jitiCacheOptions} from '../../../foundation/fs/jiti-cache.mjs';
|
|
@@ -1487,7 +1488,10 @@ function assertThemeSourceFile(filePath, cwd, mode = {}) {
|
|
|
1487
1488
|
* `ownsOutputs` says the caller made the folder the outputs go into and owns
|
|
1488
1489
|
* every file there named like one (the theme editor's theme folder), so a
|
|
1489
1490
|
* damaged or half-written output is replaced, never refused.
|
|
1490
|
-
*
|
|
1491
|
+
* `warnings` takes each warning message of the build, in check mode too,
|
|
1492
|
+
* where the receipt carries none (the theme editor, recording a source as
|
|
1493
|
+
* built without building it, keeps the warnings that build gives).
|
|
1494
|
+
* @typedef {{warnings?: string[], ownsOutputs?: boolean, prepareFamily?: boolean, familyLoader?: any, familyInterception?: any, writeRoot?: string, claimedOutputs?: Map<string, string>, deferredWrites?: Array<Array<{dest: string, content: string}>>, commandWords?: {group: string, build: string}, colorModes?: ['light'] | ['dark'] | null, fontHelp?: FontHelp | null, loadedFonts?: ((family: string) => boolean) | null, install?: string | null}} ThemeBuildHandOff
|
|
1491
1495
|
*/
|
|
1492
1496
|
|
|
1493
1497
|
/**
|
|
@@ -1682,15 +1686,20 @@ function assertOutputsReplaceable(
|
|
|
1682
1686
|
// that source.
|
|
1683
1687
|
const owner = /** @type {{source?: string}} */ (write).source ?? filePath;
|
|
1684
1688
|
if (key === sourceKey) {
|
|
1689
|
+
// The module is named after the theme, so a .js source of that name
|
|
1690
|
+
// (brand.js for theme brand) has its built module at its own path:
|
|
1691
|
+
// only another folder takes every output.
|
|
1692
|
+
const free = freeOutPath(writes);
|
|
1685
1693
|
throw new AstryxError(
|
|
1686
|
-
`The output ${rel(write.dest)} is the theme source itself.
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
+
`The output ${rel(write.dest)} is the theme source itself, so the build does not write it. Build the outputs into another folder with --out${free ? `, such as --out ${rel(free)}` : ''}.`,
|
|
1695
|
+
free && rerun
|
|
1696
|
+
? [
|
|
1697
|
+
{
|
|
1698
|
+
name: rerun(rel(free)),
|
|
1699
|
+
reason: 'a folder where no output of this build exists yet',
|
|
1700
|
+
},
|
|
1701
|
+
]
|
|
1702
|
+
: [],
|
|
1694
1703
|
ERROR_CODES.ERR_THEME_INVALID,
|
|
1695
1704
|
);
|
|
1696
1705
|
}
|
|
@@ -2000,14 +2009,8 @@ function resolveCoreRoot() {
|
|
|
2000
2009
|
function corePackageRoot(file) {
|
|
2001
2010
|
let dir = path.dirname(file);
|
|
2002
2011
|
for (;;) {
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
fs.readFileSync(path.join(dir, 'package.json'), 'utf-8'),
|
|
2006
|
-
);
|
|
2007
|
-
if (pkg?.name === '@astryxdesign/core') return dir;
|
|
2008
|
-
} catch {
|
|
2009
|
-
// No readable package.json here; keep walking up.
|
|
2010
|
-
}
|
|
2012
|
+
if (packageNameAt(path.join(dir, 'package.json')) === '@astryxdesign/core')
|
|
2013
|
+
return dir;
|
|
2011
2014
|
const parent = path.dirname(dir);
|
|
2012
2015
|
if (parent === dir) return null;
|
|
2013
2016
|
dir = parent;
|
|
@@ -3139,7 +3142,7 @@ async function extractThemeDefinition(filePath, interception, /** @type {any} */
|
|
|
3139
3142
|
? jitiError
|
|
3140
3143
|
: new Error(`it threw ${thrownText(jitiError)}`);
|
|
3141
3144
|
throw new Error(
|
|
3142
|
-
`Failed to load theme from ${filePath}: ${themeLoadReason(je)}`,
|
|
3145
|
+
`Failed to load theme from ${filePath}: ${themeLoadReason(je)}${await baseImportHint(filePath, je)}`,
|
|
3143
3146
|
{cause: jitiError},
|
|
3144
3147
|
);
|
|
3145
3148
|
}
|
|
@@ -3319,6 +3322,53 @@ function thrownText(value) {
|
|
|
3319
3322
|
}
|
|
3320
3323
|
}
|
|
3321
3324
|
|
|
3325
|
+
/**
|
|
3326
|
+
* The import that fixes a base Core refuses as no theme, when the theme
|
|
3327
|
+
* extends a package's default export or the package as one object: a theme
|
|
3328
|
+
* package exports its themes by name, and the hint names them.
|
|
3329
|
+
* @param {string} filePath
|
|
3330
|
+
* @param {Error} error
|
|
3331
|
+
* @returns {Promise<string>} '' when the base is no such import
|
|
3332
|
+
*/
|
|
3333
|
+
async function baseImportHint(filePath, error) {
|
|
3334
|
+
if (!/`extends` must be a theme from defineTheme\(\)/.test(error.message))
|
|
3335
|
+
return '';
|
|
3336
|
+
const binding = themeBaseBinding(filePath, 'default');
|
|
3337
|
+
const specifier = binding?.importPath;
|
|
3338
|
+
if (
|
|
3339
|
+
!specifier ||
|
|
3340
|
+
specifier.startsWith('.') ||
|
|
3341
|
+
path.isAbsolute(specifier) ||
|
|
3342
|
+
(binding.exportName !== 'default' && binding.exportName !== '*')
|
|
3343
|
+
)
|
|
3344
|
+
return '';
|
|
3345
|
+
/** @type {string[]} */
|
|
3346
|
+
let themes = [];
|
|
3347
|
+
try {
|
|
3348
|
+
const resolved = createRequire(filePath).resolve(specifier);
|
|
3349
|
+
const mod = await import(pathToFileURL(resolved).href);
|
|
3350
|
+
themes = Object.entries(mod)
|
|
3351
|
+
.filter(
|
|
3352
|
+
([name, value]) =>
|
|
3353
|
+
name !== 'default' &&
|
|
3354
|
+
value &&
|
|
3355
|
+
typeof value === 'object' &&
|
|
3356
|
+
typeof value.name === 'string' &&
|
|
3357
|
+
value.tokens &&
|
|
3358
|
+
typeof value.tokens === 'object',
|
|
3359
|
+
)
|
|
3360
|
+
.map(([name]) => name);
|
|
3361
|
+
} catch {
|
|
3362
|
+
// The package's exports are not read: the hint names the form only.
|
|
3363
|
+
}
|
|
3364
|
+
const how =
|
|
3365
|
+
binding.exportName === '*'
|
|
3366
|
+
? `all of ${specifier} as one object`
|
|
3367
|
+
: `the default export of ${specifier}`;
|
|
3368
|
+
const example = themes[0] ?? '<theme>';
|
|
3369
|
+
return `\nThe theme extends ${how}, which is not a theme: a theme package exports its theme by name${themes.length ? ` (${themes.join(', ')})` : ''}. Import it so: import {${example}} from '${specifier}', and extend ${example}.`;
|
|
3370
|
+
}
|
|
3371
|
+
|
|
3322
3372
|
/**
|
|
3323
3373
|
* Why a theme module did not load, with the step that fixes it. A module
|
|
3324
3374
|
* whose default export is null or a primitive trips the loader's interop
|
|
@@ -6233,6 +6283,7 @@ async function themeBuildInternal(
|
|
|
6233
6283
|
);
|
|
6234
6284
|
}
|
|
6235
6285
|
warnMissingDeclarations(writes, cwd);
|
|
6286
|
+
handOff.warnings?.push(...warningMessages);
|
|
6236
6287
|
return /** @type {import('../theme.type.mjs').ThemeBuildCheckResponse} */ ({
|
|
6237
6288
|
type: 'theme.build.check',
|
|
6238
6289
|
data: {
|
|
@@ -466,6 +466,10 @@ function keyProblem(key, value, kind, pseudoProblem) {
|
|
|
466
466
|
if (isBlock(value)) {
|
|
467
467
|
if (key.startsWith(':') && kind !== 'pseudo') return pseudoProblem(key);
|
|
468
468
|
if (kind === 'style' && MODE_KEYS.includes(key)) return null;
|
|
469
|
+
// Variants written as other styling libraries write them: named with
|
|
470
|
+
// the style keys that write them, by the build and the editor alike.
|
|
471
|
+
const keys = kind === 'style' ? variantMapKeys(key, value) : null;
|
|
472
|
+
if (keys) return variantMapMessage(key, keys);
|
|
469
473
|
return `${key} holds a block, but ${kind === 'pseudo' ? 'a pseudo key holds properties only' : `only a pseudo key (':hover', '::before')${kind === 'style' ? ' or @light / @dark' : ''} holds one here`}, so the build writes it as a declaration the browser drops`;
|
|
470
474
|
}
|
|
471
475
|
if (key.startsWith(':') || key.startsWith('@')) return null;
|
|
@@ -722,11 +726,6 @@ export function styleKeyProblems(theme) {
|
|
|
722
726
|
const block = (node, at, kind, depth) => {
|
|
723
727
|
if (!isBlock(node) || depth > 12) return;
|
|
724
728
|
for (const [k, v] of Object.entries(node)) {
|
|
725
|
-
const keys = kind === 'style' ? variantMapKeys(k, v) : null;
|
|
726
|
-
if (keys) {
|
|
727
|
-
out.push({path: [...at, k], why: variantMapMessage(k, keys)});
|
|
728
|
-
continue;
|
|
729
|
-
}
|
|
730
729
|
const why = keyProblem(k, v, kind, key => checked(key).problem);
|
|
731
730
|
if (why) {
|
|
732
731
|
out.push({path: [...at, k], why});
|
|
@@ -64,6 +64,11 @@ export function moduleBindings(ast) {
|
|
|
64
64
|
source: node.source.value,
|
|
65
65
|
imported: 'default',
|
|
66
66
|
});
|
|
67
|
+
else if (spec.type === 'ImportNamespaceSpecifier')
|
|
68
|
+
imports.set(spec.local.name, {
|
|
69
|
+
source: node.source.value,
|
|
70
|
+
imported: '*',
|
|
71
|
+
});
|
|
67
72
|
addDeclaration(node);
|
|
68
73
|
if (node.type === 'ExportNamedDeclaration') {
|
|
69
74
|
addDeclaration(node.declaration);
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @param {number} red
|
|
6
|
+
* @param {number} green
|
|
7
|
+
* @param {number} blue
|
|
8
|
+
* @returns {ColorTriple}
|
|
9
|
+
*/
|
|
10
|
+
export function linearRgbToOklab(red: number, green: number, blue: number): ColorTriple;
|
|
4
11
|
/**
|
|
5
12
|
* @param {number} lightness
|
|
6
13
|
* @param {number} a
|
|
@@ -40,11 +47,44 @@ export function oklchClampedHex(lightness: number, chroma: number, hue: number):
|
|
|
40
47
|
* @returns {number}
|
|
41
48
|
*/
|
|
42
49
|
export function toneToOklabLightness(tone: number): number;
|
|
50
|
+
/**
|
|
51
|
+
* A hex color's linear-light red, green and blue, each 0 to 1.
|
|
52
|
+
* @param {string} hex
|
|
53
|
+
* @returns {ColorTriple}
|
|
54
|
+
*/
|
|
55
|
+
export function hexToLinearRgb(hex: string): ColorTriple;
|
|
43
56
|
/**
|
|
44
57
|
* @param {string} hex
|
|
45
58
|
* @returns {number}
|
|
46
59
|
*/
|
|
47
60
|
export function luminance(hex: string): number;
|
|
61
|
+
/**
|
|
62
|
+
* A hex color's red, green and blue, 0 to 255.
|
|
63
|
+
* @param {string} hex
|
|
64
|
+
* @returns {ColorTriple}
|
|
65
|
+
*/
|
|
66
|
+
export function hexToRgbTriple(hex: string): ColorTriple;
|
|
67
|
+
/**
|
|
68
|
+
* Red, green and blue (0 to 255, rounded) as a lowercase hex.
|
|
69
|
+
* @param {ReadonlyArray<number>} rgb
|
|
70
|
+
* @returns {string}
|
|
71
|
+
*/
|
|
72
|
+
export function rgbTripleToHex(rgb: ReadonlyArray<number>): string;
|
|
73
|
+
/**
|
|
74
|
+
* A color drawn at `alpha` over `under`, as the opaque color the eye sees.
|
|
75
|
+
* @param {ReadonlyArray<number>} over
|
|
76
|
+
* @param {number} alpha
|
|
77
|
+
* @param {ReadonlyArray<number>} under
|
|
78
|
+
* @returns {ColorTriple}
|
|
79
|
+
*/
|
|
80
|
+
export function compositeOver(over: ReadonlyArray<number>, alpha: number, under: ReadonlyArray<number>): ColorTriple;
|
|
81
|
+
/**
|
|
82
|
+
* The WCAG contrast ratio of two opaque colors.
|
|
83
|
+
* @param {string} a
|
|
84
|
+
* @param {string} b
|
|
85
|
+
* @returns {number}
|
|
86
|
+
*/
|
|
87
|
+
export function contrastRatio(a: string, b: string): number;
|
|
48
88
|
/**
|
|
49
89
|
* @param {string} hex
|
|
50
90
|
* @returns {ColorTriple}
|
|
@@ -55,4 +95,11 @@ export function oklabCoordinates(hex: string): ColorTriple;
|
|
|
55
95
|
* @returns {string}
|
|
56
96
|
*/
|
|
57
97
|
export function oklabCoordinatesToHex(coordinates: ColorTriple): string;
|
|
98
|
+
/**
|
|
99
|
+
* A contrast ratio to two decimals, cut down and never rounded up, so a
|
|
100
|
+
* pair just under the bar never prints as meeting it.
|
|
101
|
+
* @param {number} ratio
|
|
102
|
+
* @returns {number}
|
|
103
|
+
*/
|
|
104
|
+
export function ratioDown(ratio: number): number;
|
|
58
105
|
export type ColorTriple = [number, number, number];
|
|
@@ -70,7 +70,7 @@ function rgbToHex(red, green, blue) {
|
|
|
70
70
|
* @param {number} blue
|
|
71
71
|
* @returns {ColorTriple}
|
|
72
72
|
*/
|
|
73
|
-
function linearRgbToOklab(red, green, blue) {
|
|
73
|
+
export function linearRgbToOklab(red, green, blue) {
|
|
74
74
|
const lRoot = Math.cbrt(
|
|
75
75
|
0.4122214708 * red + 0.5363325363 * green + 0.0514459929 * blue,
|
|
76
76
|
);
|
|
@@ -228,6 +228,15 @@ export function toneToOklabLightness(tone) {
|
|
|
228
228
|
const relative = tone > 8 ? Math.pow((tone + 16) / 116, 3) : tone / 903.3;
|
|
229
229
|
return Math.cbrt(relative);
|
|
230
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* A hex color's linear-light red, green and blue, each 0 to 1.
|
|
233
|
+
* @param {string} hex
|
|
234
|
+
* @returns {ColorTriple}
|
|
235
|
+
*/
|
|
236
|
+
export function hexToLinearRgb(hex) {
|
|
237
|
+
const [red, green, blue] = hexToRgb(hex).map(srgbToLinear);
|
|
238
|
+
return [red, green, blue];
|
|
239
|
+
}
|
|
231
240
|
/**
|
|
232
241
|
* @param {string} hex
|
|
233
242
|
* @returns {number}
|
|
@@ -236,6 +245,45 @@ export function luminance(hex) {
|
|
|
236
245
|
const [red, green, blue] = hexToRgb(hex).map(srgbToLinear);
|
|
237
246
|
return 0.2126 * red + 0.7152 * green + 0.0722 * blue;
|
|
238
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* A hex color's red, green and blue, 0 to 255.
|
|
250
|
+
* @param {string} hex
|
|
251
|
+
* @returns {ColorTriple}
|
|
252
|
+
*/
|
|
253
|
+
export function hexToRgbTriple(hex) {
|
|
254
|
+
return hexToRgb(hex);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Red, green and blue (0 to 255, rounded) as a lowercase hex.
|
|
258
|
+
* @param {ReadonlyArray<number>} rgb
|
|
259
|
+
* @returns {string}
|
|
260
|
+
*/
|
|
261
|
+
export function rgbTripleToHex(rgb) {
|
|
262
|
+
return rgbToHex(Math.round(rgb[0]), Math.round(rgb[1]), Math.round(rgb[2]));
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* A color drawn at `alpha` over `under`, as the opaque color the eye sees.
|
|
266
|
+
* @param {ReadonlyArray<number>} over
|
|
267
|
+
* @param {number} alpha
|
|
268
|
+
* @param {ReadonlyArray<number>} under
|
|
269
|
+
* @returns {ColorTriple}
|
|
270
|
+
*/
|
|
271
|
+
export function compositeOver(over, alpha, under) {
|
|
272
|
+
return /** @type {ColorTriple} */ (
|
|
273
|
+
over.map((x, n) => x * alpha + under[n] * (1 - alpha))
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* The WCAG contrast ratio of two opaque colors.
|
|
278
|
+
* @param {string} a
|
|
279
|
+
* @param {string} b
|
|
280
|
+
* @returns {number}
|
|
281
|
+
*/
|
|
282
|
+
export function contrastRatio(a, b) {
|
|
283
|
+
const x = luminance(a);
|
|
284
|
+
const y = luminance(b);
|
|
285
|
+
return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05);
|
|
286
|
+
}
|
|
239
287
|
/**
|
|
240
288
|
* @param {string} hex
|
|
241
289
|
* @returns {ColorTriple}
|
|
@@ -255,3 +303,12 @@ export function oklabCoordinatesToHex(coordinates) {
|
|
|
255
303
|
const hue = ((Math.atan2(b, a) * 180) / Math.PI + 360) % 360;
|
|
256
304
|
return oklchClampedHex(Math.min(1, Math.max(0, lightness)), chroma, hue);
|
|
257
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* A contrast ratio to two decimals, cut down and never rounded up, so a
|
|
308
|
+
* pair just under the bar never prints as meeting it.
|
|
309
|
+
* @param {number} ratio
|
|
310
|
+
* @returns {number}
|
|
311
|
+
*/
|
|
312
|
+
export function ratioDown(ratio) {
|
|
313
|
+
return Math.floor(ratio * 100 + 1e-9) / 100;
|
|
314
|
+
}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The seeds of the derived hues: Core's hues at the strength of the accent,
|
|
6
|
+
* in steps of 0.05 so an accent of about the same strength leaves them as
|
|
7
|
+
* they are, turned a little toward the accent's and a tinted neutral's hue
|
|
8
|
+
* (hueLean); Core's strength without a colored accent.
|
|
9
|
+
* @param {string | null | undefined} accent
|
|
10
|
+
* @param {string | null} [neutral]
|
|
11
|
+
* @returns {Record<string, string>}
|
|
12
|
+
*/
|
|
13
|
+
export function lookSeeds(accent: string | null | undefined, neutral?: string | null): Record<string, string>;
|
|
14
|
+
/**
|
|
15
|
+
* Where a look's card tints start, `[light, dark]`: a strong or dark
|
|
16
|
+
* accent draws them a step deeper, a pale accent a step paler; the
|
|
17
|
+
* official neutral theme's stops otherwise.
|
|
18
|
+
* @param {string | null | undefined} accent
|
|
19
|
+
* @returns {readonly [number, number]}
|
|
20
|
+
*/
|
|
21
|
+
export function tintStops(accent: string | null | undefined): readonly [number, number];
|
|
22
|
+
/**
|
|
23
|
+
* Whether a family is one lookSeeds grows: an id, a name and a seed at
|
|
24
|
+
* Core's own lightness and hue for that id (only its strength follows the
|
|
25
|
+
* look).
|
|
26
|
+
* @param {unknown} family
|
|
27
|
+
* @returns {boolean}
|
|
28
|
+
*/
|
|
29
|
+
export function isLookFamily(family: unknown): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The category and chart colors a palette derives.
|
|
32
|
+
* @param {DeriveLookInput} param0
|
|
33
|
+
* @returns {DerivedLook}
|
|
34
|
+
*/
|
|
35
|
+
export function deriveLookColors({ palette, accent, stops, modes, text, grounds, wanted, shown, }: DeriveLookInput): DerivedLook;
|
|
36
|
+
/**
|
|
37
|
+
* The seeds of the status roles a look derives: each role's own hue and
|
|
38
|
+
* lightness (the base theme's color for it) at the accent's strength. A
|
|
39
|
+
* role keeps its hue whatever the accent: an error stays the base's red,
|
|
40
|
+
* info its blue. Only its strength follows the look; a role that would
|
|
41
|
+
* then read as the accent takes the nearest shade apart from it
|
|
42
|
+
* (deriveStatusColors).
|
|
43
|
+
* `base` holds each role's base color by dial id (info, success, warning,
|
|
44
|
+
* danger).
|
|
45
|
+
* @param {Record<string, string>} base
|
|
46
|
+
* @param {string | null | undefined} accent
|
|
47
|
+
* @returns {Record<string, string>}
|
|
48
|
+
*/
|
|
49
|
+
export function statusSeeds(base: Record<string, string>, accent: string | null | undefined): Record<string, string>;
|
|
50
|
+
/**
|
|
51
|
+
* The status colors a palette derives for the roles a theme leaves unset.
|
|
52
|
+
* @param {DeriveStatusInput} param0
|
|
53
|
+
* @returns {DerivedStatus}
|
|
54
|
+
*/
|
|
55
|
+
export function deriveStatusColors({ palette, stops, modes, roles, grounds, inks, accent, wanted, shown, }: DeriveStatusInput): DerivedStatus;
|
|
56
|
+
/**
|
|
57
|
+
* The code colors and the overlay scrim a palette derives: each syntax role
|
|
58
|
+
* from its hue's family, the nearest stop that reads at 4.5:1 on the code
|
|
59
|
+
* background and on the page; the code background and the scrim from the
|
|
60
|
+
* neutral. A role that cannot read keeps the base theme's.
|
|
61
|
+
* @param {DeriveCodeInput} param0
|
|
62
|
+
* @returns {{ tokens: Record<string, DerivedToken>; unreadable: string[]; }}
|
|
63
|
+
*/
|
|
64
|
+
export function deriveCodeColors({ palette, stops, modes, grounds, codeGround, wanted, }: DeriveCodeInput): {
|
|
65
|
+
tokens: Record<string, DerivedToken>;
|
|
66
|
+
unreadable: string[];
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* The pairs of status fills that someone red-weak or green-weak may not
|
|
70
|
+
* tell apart: their colors as that vision sees them sit closer than
|
|
71
|
+
* CVD_ALIKE. `fills` holds opaque hex by role.
|
|
72
|
+
* @param {Record<string, string>} fills
|
|
73
|
+
* @returns {{a: string; b: string; vision: 'red-weak' | 'green-weak'}[]}
|
|
74
|
+
*/
|
|
75
|
+
export function cvdClashes(fills: Record<string, string>): {
|
|
76
|
+
a: string;
|
|
77
|
+
b: string;
|
|
78
|
+
vision: "red-weak" | "green-weak";
|
|
79
|
+
}[];
|
|
80
|
+
export { ratioDown };
|
|
81
|
+
/** Core's category hues; gray is the neutral family's. */
|
|
82
|
+
export const CATEGORY_HUES: readonly ["red", "orange", "yellow", "green", "teal", "cyan", "blue", "purple", "pink", "gray"];
|
|
83
|
+
/** The chart's series hues, in Core's series order. */
|
|
84
|
+
export const CHART_SERIES: readonly ["blue", "orange", "purple", "green", "pink", "cyan", "red", "teal", "brown", "indigo"];
|
|
85
|
+
/**
|
|
86
|
+
* Each chart scale and the family it is drawn from.
|
|
87
|
+
* @type {Readonly<Record<string, string>>}
|
|
88
|
+
*/
|
|
89
|
+
export const CHART_SCALES: Readonly<Record<string, string>>;
|
|
90
|
+
/**
|
|
91
|
+
* The seed each derived hue grows from: the official neutral palette's
|
|
92
|
+
* category seeds (packages/themes/neutral/palette.config.json; a test keeps
|
|
93
|
+
* them equal), and Core's own chart colors for the two series no category
|
|
94
|
+
* has.
|
|
95
|
+
* @type {Readonly<Record<string, string>>}
|
|
96
|
+
*/
|
|
97
|
+
export const HUE_SEEDS: Readonly<Record<string, string>>;
|
|
98
|
+
export namespace CATEGORY_STOPS {
|
|
99
|
+
let background: readonly [85, 25];
|
|
100
|
+
let border: readonly [80, 65];
|
|
101
|
+
let icon: readonly [25, 75];
|
|
102
|
+
let text: readonly [25, 80];
|
|
103
|
+
let grayBackground: readonly [90, 20];
|
|
104
|
+
let grayBorder: readonly [85, 15];
|
|
105
|
+
let grayIcon: readonly [30, 65];
|
|
106
|
+
let grayText: readonly [10, 85];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The status roles a palette derives for a look that leaves them unset: each
|
|
110
|
+
* role's dial id and the word its tokens carry.
|
|
111
|
+
* @type {Readonly<Record<string, string>>}
|
|
112
|
+
*/
|
|
113
|
+
export const STATUS_ROLES: Readonly<Record<string, string>>;
|
|
114
|
+
export namespace STATUS_STOPS {
|
|
115
|
+
export let fill: readonly [50, 70];
|
|
116
|
+
export let warningFill: readonly [85, 85];
|
|
117
|
+
let text_1: readonly [45, 80];
|
|
118
|
+
export { text_1 as text };
|
|
119
|
+
export let muted: readonly [85, 75];
|
|
120
|
+
export let mutedDarkAlpha: "3D";
|
|
121
|
+
export let onMuted: readonly [25, 80];
|
|
122
|
+
}
|
|
123
|
+
export namespace SYNTAX_STOPS {
|
|
124
|
+
export let keyword: readonly ["purple", 30, 80];
|
|
125
|
+
export let string: readonly ["green", 30, 80];
|
|
126
|
+
export let comment: readonly ["neutral", 35, 75];
|
|
127
|
+
export let number: readonly ["orange", 30, 80];
|
|
128
|
+
let _function: readonly ["blue", 30, 80];
|
|
129
|
+
export { _function as function };
|
|
130
|
+
export let type: readonly ["purple", 30, 80];
|
|
131
|
+
export let variable: readonly ["neutral", 5, 90];
|
|
132
|
+
export let operator: readonly ["neutral", 35, 75];
|
|
133
|
+
export let constant: readonly ["orange", 30, 80];
|
|
134
|
+
export let tag: readonly ["red", 30, 80];
|
|
135
|
+
export let attribute: readonly ["yellow", 30, 80];
|
|
136
|
+
export let property: readonly ["teal", 30, 80];
|
|
137
|
+
export let punctuation: readonly ["neutral", 35, 75];
|
|
138
|
+
}
|
|
139
|
+
export type Mode = "light" | "dark";
|
|
140
|
+
export type Stop = {
|
|
141
|
+
stop: number;
|
|
142
|
+
color: string;
|
|
143
|
+
family?: string | undefined;
|
|
144
|
+
alpha?: string | undefined;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* A derived token: its family and its shade in each mode.
|
|
148
|
+
*/
|
|
149
|
+
export type DerivedToken = {
|
|
150
|
+
family: string;
|
|
151
|
+
light: Stop;
|
|
152
|
+
dark: Stop;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* The category and chart colors a palette derives. Each set is always
|
|
156
|
+
* written when the palette has its hues.
|
|
157
|
+
*/
|
|
158
|
+
export type DerivedLook = {
|
|
159
|
+
tokens: Record<string, DerivedToken>;
|
|
160
|
+
badges: "derived" | "none";
|
|
161
|
+
chart: "derived" | "none";
|
|
162
|
+
/**
|
|
163
|
+
* Each limit no shade meets: a color still drawn alike, or one under its contrast at its most readable shade.
|
|
164
|
+
*/
|
|
165
|
+
limits: string[];
|
|
166
|
+
/**
|
|
167
|
+
* Each color moved apart from an earlier one (a tint also from the page).
|
|
168
|
+
*/
|
|
169
|
+
moved: string[];
|
|
170
|
+
/**
|
|
171
|
+
* Whether a color is still drawn like an earlier one.
|
|
172
|
+
*/
|
|
173
|
+
alike: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Whether a color is under its contrast at its most readable shade.
|
|
176
|
+
*/
|
|
177
|
+
unread: boolean;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* What deriveLookColors reads.
|
|
181
|
+
*/
|
|
182
|
+
export type DeriveLookInput = {
|
|
183
|
+
/**
|
|
184
|
+
* Generated families by id.
|
|
185
|
+
*/
|
|
186
|
+
palette: Record<string, Record<Mode, Record<string | number, string>>>;
|
|
187
|
+
/**
|
|
188
|
+
* The palette's stops.
|
|
189
|
+
*/
|
|
190
|
+
stops: ReadonlyArray<number>;
|
|
191
|
+
modes: ReadonlyArray<Mode>;
|
|
192
|
+
/**
|
|
193
|
+
* The theme's text and secondary text colors (opaque hex) in a mode.
|
|
194
|
+
*/
|
|
195
|
+
text: (m: Mode) => string[];
|
|
196
|
+
/**
|
|
197
|
+
* The look's accent seed: how deep its card tints sit (tintStops).
|
|
198
|
+
*/
|
|
199
|
+
accent?: string | null | undefined;
|
|
200
|
+
/**
|
|
201
|
+
* The surfaces text sits on in a mode: page, surface, card (opaque hex).
|
|
202
|
+
*/
|
|
203
|
+
grounds: (m: Mode) => string[];
|
|
204
|
+
/**
|
|
205
|
+
* Whether a token is written (Core has it and the theme does not set it by hand).
|
|
206
|
+
*/
|
|
207
|
+
wanted?: ((token: string) => boolean) | undefined;
|
|
208
|
+
/**
|
|
209
|
+
* The modes the theme shows: notes name only these. Every mode by default.
|
|
210
|
+
*/
|
|
211
|
+
shown?: readonly Mode[] | undefined;
|
|
212
|
+
};
|
|
213
|
+
export type Badge = {
|
|
214
|
+
fill: Stop;
|
|
215
|
+
ink: {
|
|
216
|
+
stop: Stop;
|
|
217
|
+
r: number;
|
|
218
|
+
};
|
|
219
|
+
icon: {
|
|
220
|
+
stop: Stop;
|
|
221
|
+
r: number;
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* What deriveStatusColors reads.
|
|
226
|
+
*/
|
|
227
|
+
export type DeriveStatusInput = {
|
|
228
|
+
/**
|
|
229
|
+
* Generated families by id; a role's family has the role's dial id.
|
|
230
|
+
*/
|
|
231
|
+
palette: Record<string, Record<Mode, Record<string | number, string>>>;
|
|
232
|
+
stops: ReadonlyArray<number>;
|
|
233
|
+
modes: ReadonlyArray<Mode>;
|
|
234
|
+
/**
|
|
235
|
+
* The dial ids to derive (info, success, warning, danger).
|
|
236
|
+
*/
|
|
237
|
+
roles: ReadonlyArray<string>;
|
|
238
|
+
/**
|
|
239
|
+
* Page, surface, card (opaque hex).
|
|
240
|
+
*/
|
|
241
|
+
grounds: (m: Mode) => string[];
|
|
242
|
+
/**
|
|
243
|
+
* The text the theme draws on a role's fill in a mode, preferred first (white or near-black).
|
|
244
|
+
*/
|
|
245
|
+
inks: (m: Mode, role: string) => (Stop & {
|
|
246
|
+
family: string;
|
|
247
|
+
})[];
|
|
248
|
+
/**
|
|
249
|
+
* The accent fill in a mode, kept apart from.
|
|
250
|
+
*/
|
|
251
|
+
accent: (m: Mode) => string | null;
|
|
252
|
+
wanted?: ((token: string) => boolean) | undefined;
|
|
253
|
+
/**
|
|
254
|
+
* The modes the theme shows: notes name only these. Every mode by default.
|
|
255
|
+
*/
|
|
256
|
+
shown?: readonly Mode[] | undefined;
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* The status colors a palette derives, and each role's state. A token's stop may name its own family (the text on a fill is the neutral color's, or white or black).
|
|
260
|
+
*/
|
|
261
|
+
export type DerivedStatus = {
|
|
262
|
+
tokens: Record<string, DerivedToken>;
|
|
263
|
+
/**
|
|
264
|
+
* The roles derived and written.
|
|
265
|
+
*/
|
|
266
|
+
roles: Record<string, "derived">;
|
|
267
|
+
/**
|
|
268
|
+
* What the roles gave up to stay written (a fill that cannot meet every limit), and each role that keeps the base theme's colors because its text, icon or border reads at no shade.
|
|
269
|
+
*/
|
|
270
|
+
why: string[];
|
|
271
|
+
/**
|
|
272
|
+
* The roles `why` names, by dial id.
|
|
273
|
+
*/
|
|
274
|
+
short: string[];
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* What deriveCodeColors reads.
|
|
278
|
+
*/
|
|
279
|
+
export type DeriveCodeInput = {
|
|
280
|
+
palette: Record<string, Record<Mode, Record<string | number, string>>>;
|
|
281
|
+
stops: ReadonlyArray<number>;
|
|
282
|
+
modes: ReadonlyArray<Mode>;
|
|
283
|
+
/**
|
|
284
|
+
* The page colors code sits on, opaque hex.
|
|
285
|
+
*/
|
|
286
|
+
grounds: (m: Mode) => string[];
|
|
287
|
+
/**
|
|
288
|
+
* The code background the theme sets itself in a mode (opaque hex), which code colors read on instead of the neutral's.
|
|
289
|
+
*/
|
|
290
|
+
codeGround?: ((m: Mode) => string | null) | undefined;
|
|
291
|
+
wanted?: ((token: string) => boolean) | undefined;
|
|
292
|
+
};
|
|
293
|
+
import { ratioDown } from './color.mjs';
|