@astryxdesign/cli 0.7.16 → 0.7.17-canary.g335a172
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 +76 -86
- package/api/build/_adapter.d.mts +12 -0
- package/api/build/_adapter.mjs +51 -34
- package/api/build/blocks/blocks.d.mts +7 -5
- package/api/build/blocks/blocks.mjs +113 -26
- package/api/build/build.doc.mjs +4 -3
- package/api/build/build.type.d.mts +2 -2
- package/api/build/build.type.mjs +3 -3
- package/api/build/kit/kind.d.mts +2 -1
- package/api/build/kit/kind.mjs +199 -10
- package/api/build/kit/kit.mjs +6 -4
- package/api/build/kit/rank.mjs +69 -16
- package/api/build/kit/start.d.mts +5 -4
- package/api/build/kit/start.mjs +12 -8
- package/api/build/kit/weights.d.mts +16 -3
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +251 -35
- package/api/build/kit/word-model.d.mts +23 -0
- package/api/build/kit/word-model.mjs +46 -0
- package/api/build/kit/words.d.mts +48 -0
- package/api/build/kit/words.mjs +90 -1
- package/api/component/__fixtures__/resolutions/modules.txt +4 -5
- package/api/component/list/list.d.mts +1 -1
- package/api/component/list/list.mjs +48 -6
- package/api/discover/_adapter.d.mts +1 -1
- package/api/discover/search/search.mjs +3 -2
- package/api/docs/_adapter.d.mts +26 -2
- package/api/docs/_adapter.mjs +219 -6
- package/api/docs/docs.d.mts +3 -0
- package/api/docs/docs.doc.mjs +7 -1
- package/api/docs/docs.mjs +12 -0
- package/api/docs/docs.type.d.mts +5 -0
- package/api/docs/docs.type.mjs +2 -0
- package/api/docs/node/node.mjs +1 -1
- package/api/doctor/_adapter.d.mts +27 -5
- package/api/doctor/_adapter.mjs +83 -10
- package/api/doctor/built-checks.mjs +40 -14
- package/api/doctor/doctor.d.mts +4 -3
- package/api/doctor/doctor.mjs +14 -7
- package/api/doctor/theme-checks.mjs +121 -17
- package/api/icon/_records.mjs +2 -1
- package/api/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/integration/_adapter.d.mts +44 -0
- package/api/integration/_adapter.mjs +77 -1
- package/api/integration/authoring-checks.mjs +6 -6
- package/api/integration/example-scope.d.mts +14 -0
- package/api/integration/example-scope.mjs +44 -0
- package/api/integration/example-scope.type.d.mts +29 -0
- package/api/integration/example-scope.type.mjs +25 -0
- package/api/integration/integrationExampleScope.doc.d.mts +11 -0
- package/api/integration/integrationExampleScope.doc.mjs +59 -0
- package/api/integration/validate-integration.mjs +19 -1
- package/api/integration/validate-integration.type.d.mts +9 -0
- package/api/integration/validate-integration.type.mjs +1 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/_adapter.mjs +591 -195
- package/api/render/render.doc.mjs +11 -3
- package/api/render/render.type.d.mts +52 -0
- package/api/render/render.type.mjs +31 -1
- package/api/search/ORDERING.md +1 -1
- package/api/search/_candidate-score.mjs +51 -32
- package/api/search/_fit-order.mjs +3 -3
- package/api/search/_gather-components.d.mts +3 -2
- package/api/search/_gather-components.mjs +12 -3
- package/api/search/_lexical.d.mts +5 -0
- package/api/search/_lexical.mjs +8 -2
- package/api/search/_result.d.mts +11 -9
- package/api/search/_result.mjs +4 -4
- package/api/search/_score.d.mts +6 -1
- package/api/search/_score.mjs +15 -3
- package/api/search/search-index.mjs +7 -1
- package/api/search/search.d.mts +1 -1
- package/api/theme/_adapter.mjs +12 -1
- package/api/theme/build/build.d.mts +60 -0
- package/api/theme/build/build.mjs +210 -54
- package/api/theme/build/font-warning.d.mts +8 -0
- package/api/theme/build/font-warning.mjs +19 -0
- package/api/theme/theme.type.d.mts +10 -0
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme-edit/_adapter.d.mts +55 -0
- package/api/theme-edit/_adapter.mjs +673 -42
- package/api/theme-edit/_check.d.mts +28 -22
- package/api/theme-edit/_check.mjs +1858 -312
- package/api/theme-edit/_color.d.mts +10 -0
- package/api/theme-edit/_color.mjs +49 -1
- package/api/theme-edit/_compiler.mjs +9 -0
- package/api/theme-edit/_context.mjs +60 -3
- package/api/theme-edit/_css.mjs +21 -1
- package/api/theme-edit/_edit.d.mts +22 -0
- package/api/theme-edit/_edit.mjs +1533 -92
- package/api/theme-edit/_how-commands.d.mts +57 -0
- package/api/theme-edit/_how-commands.mjs +587 -1
- package/api/theme-edit/_how-question.d.mts +78 -0
- package/api/theme-edit/_how-question.mjs +4716 -235
- package/api/theme-edit/_how.mjs +134 -8
- package/api/theme-edit/_marks.d.mts +31 -5
- package/api/theme-edit/_marks.mjs +57 -5
- package/api/theme-edit/_normal.d.mts +219 -0
- package/api/theme-edit/_normal.mjs +1041 -0
- package/api/theme-edit/_palette.mjs +10 -4
- package/api/theme-edit/_parts.d.mts +8 -0
- package/api/theme-edit/_parts.mjs +103 -2
- package/api/theme-edit/_playwright-picture.d.mts +4 -0
- package/api/theme-edit/_playwright-picture.mjs +34 -0
- package/api/theme-edit/_preview-app.d.mts +7 -1
- package/api/theme-edit/_preview-app.mjs +394 -74
- package/api/theme-edit/_preview.d.mts +69 -8
- package/api/theme-edit/_preview.mjs +531 -108
- package/api/theme-edit/_settings.d.mts +243 -6
- package/api/theme-edit/_settings.mjs +2415 -147
- package/api/theme-edit/_tables.d.mts +6 -0
- package/api/theme-edit/_tables.mjs +44 -1
- package/api/theme-edit/_vet.d.mts +18 -0
- package/api/theme-edit/_vet.mjs +32 -0
- package/api/theme-edit/theme-edit.type.d.mts +10 -1
- package/api/theme-edit/theme-edit.type.mjs +4 -1
- package/api/theme-edit/themeEditHow.doc.mjs +1 -1
- package/api/theme-edit/themeEditNew.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
- package/api/upgrade/run/run.mjs +4 -3
- package/assets/codemods/integration-discovery.mjs +2 -1
- package/assets/codemods/run-codemod.mjs +87 -7
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
- package/assets/component-list.generated.json +1 -0
- package/assets/docs/author-a-theme.doc.mjs +1 -0
- package/assets/docs/theme.doc.dense.mjs +2 -2
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
- package/assets/docs/tree/checks.doc.mjs +1 -1
- package/assets/docs/tree/cli-command.doc.mjs +2 -3
- package/assets/docs/tree/render-pages.doc.mjs +44 -3
- package/assets/docs/tree/single-component.doc.mjs +4 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
- package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +2 -1
- package/assets/templates/pages/blank/template.doc.mjs +1 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
- package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
- package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
- package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
- package/assets/templates/pages/documentation/template.doc.mjs +4 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
- package/assets/templates/pages/editor/template.doc.mjs +2 -8
- package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
- package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
- package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
- package/assets/templates/pages/ide/page.tsx +24 -2
- package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
- package/assets/templates/pages/library/template.doc.mjs +4 -1
- package/assets/templates/pages/login/template.doc.mjs +2 -1
- package/assets/templates/pages/login-card/template.doc.mjs +2 -1
- package/assets/templates/pages/login-split/template.doc.mjs +2 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
- package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
- package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
- package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
- package/assets/templates/pages/table-page/template.doc.mjs +5 -4
- package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
- package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
- package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
- package/assets/theme.template.ts +6 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +3 -3
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/component/categories.d.mts +37 -0
- package/authoring/doctypes/component/categories.mjs +54 -0
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +9 -0
- package/authoring/example/example.doc.d.mts +12 -0
- package/authoring/example/example.doc.mjs +69 -0
- package/authoring/example/preview.d.mts +92 -0
- package/authoring/example/preview.mjs +994 -0
- package/authoring/example/type.ts +102 -0
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +12 -0
- package/authoring/index.mjs +3 -1
- package/clients/cli/bin/astryx.mjs +6 -9
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.doc.mjs +1 -1
- package/clients/cli/commands/component.mjs +22 -3
- package/clients/cli/commands/docs.doc.mjs +7 -1
- package/clients/cli/commands/docs.mjs +3 -1
- package/clients/cli/commands/doctor.mjs +32 -14
- package/clients/cli/commands/experimental/render.mjs +42 -1
- package/clients/cli/commands/experimental/theme.mjs +145 -16
- package/clients/cli/commands/experimental-render.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- 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-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
- package/clients/cli/commands/search.doc.mjs +2 -1
- package/clients/cli/commands/search.mjs +6 -1
- package/clients/cli/commands/template.mjs +4 -2
- package/clients/cli/commands/theme-build.doc.mjs +5 -1
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +183 -6
- package/clients/cli/commands/upgrade.mjs +42 -7
- package/clients/cli/index.mjs +1 -1
- package/clients/cli/lib/cli-error.mjs +2 -1
- package/clients/cli/lib/component-format.mjs +205 -98
- package/clients/cli/lib/hook-format.mjs +9 -19
- package/clients/cli/lib/json-shim.mjs +77 -21
- package/clients/cli/lib/manifest.mjs +3 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/theme-state.d.mts +13 -1
- package/foundation/config/theme-state.mjs +47 -7
- package/foundation/discovery/authoring-self-docs.mjs +1 -0
- package/foundation/discovery/component-discovery.d.mts +11 -0
- package/foundation/discovery/component-discovery.mjs +56 -8
- package/foundation/discovery/component-replacement.mjs +130 -1
- package/foundation/discovery/copied-passages.mjs +2 -1
- package/foundation/discovery/doc-types.mjs +4 -3
- package/foundation/discovery/entry-name-files.d.mts +43 -0
- package/foundation/discovery/entry-name-files.mjs +264 -0
- package/foundation/discovery/hook-discovery.d.mts +8 -2
- package/foundation/discovery/hook-discovery.mjs +22 -8
- package/foundation/discovery/icon-definition-discovery.mjs +2 -1
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.mjs +2 -1
- package/foundation/discovery/integration-doc-files.mjs +2 -1
- package/foundation/discovery/package-exports.d.mts +10 -0
- package/foundation/discovery/package-exports.mjs +56 -3
- package/foundation/discovery/prop-drift.mjs +9 -9
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/stored-component-list.d.mts +43 -0
- package/foundation/discovery/stored-component-list.mjs +90 -0
- package/foundation/discovery/stored-self-audit.d.mts +26 -10
- package/foundation/discovery/stored-self-audit.mjs +38 -18
- package/foundation/discovery/template-adapter.d.mts +52 -0
- package/foundation/discovery/template-adapter.mjs +176 -12
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/theme-discovery.mjs +3 -2
- package/foundation/discovery/theme-imports.d.mts +14 -0
- package/foundation/discovery/theme-imports.mjs +43 -1
- package/foundation/discovery/theming-targets.mjs +3 -2
- package/foundation/doc-compiler/import.mjs +7 -1
- package/foundation/doc-compiler/inputs.mjs +3 -2
- package/foundation/doc-compiler/parse-readable.mjs +4 -1
- package/foundation/doc-compiler/stored-docs.d.mts +22 -0
- package/foundation/doc-compiler/stored-docs.mjs +49 -0
- package/foundation/env/semver.mjs +3 -1
- package/foundation/fonts/font-stylesheet.d.mts +31 -0
- package/foundation/fonts/font-stylesheet.mjs +115 -0
- package/foundation/fs/cache-eviction.d.mts +21 -0
- package/foundation/fs/cache-eviction.mjs +73 -0
- package/foundation/fs/file-protection.mjs +4 -3
- package/foundation/fs/gather-cache.d.mts +25 -4
- package/foundation/fs/gather-cache.mjs +164 -55
- package/foundation/fs/jiti-cache.d.mts +19 -1
- package/foundation/fs/jiti-cache.mjs +130 -6
- package/foundation/fs/kept-tree.d.mts +60 -0
- package/foundation/fs/kept-tree.mjs +154 -0
- package/foundation/fs/listing-cache.d.mts +7 -0
- package/foundation/fs/listing-cache.mjs +10 -0
- package/foundation/fs/module-loader.d.mts +24 -2
- package/foundation/fs/module-loader.mjs +94 -21
- package/foundation/fs/paths.d.mts +18 -0
- package/foundation/fs/paths.mjs +15 -2
- package/foundation/identity/provider-identity.d.mts +6 -0
- package/foundation/identity/provider-identity.mjs +10 -1
- package/foundation/integrations/contribution-inventory.mjs +4 -3
- package/foundation/integrations/example-code.d.mts +63 -0
- package/foundation/integrations/example-code.mjs +416 -0
- package/foundation/integrations/public-imports.d.mts +9 -0
- package/foundation/integrations/public-imports.mjs +3 -2
- package/foundation/integrations/validate-contributions.mjs +17 -45
- package/foundation/render/embedded-files.d.mts +6 -0
- package/foundation/render/embedded-files.mjs +25 -5
- package/foundation/render/embedded-imports.d.mts +39 -7
- package/foundation/render/embedded-imports.mjs +66 -27
- package/foundation/render/file-header.d.mts +66 -0
- package/foundation/render/file-header.mjs +118 -0
- package/foundation/render/host-answer.d.mts +18 -0
- package/foundation/render/host-answer.mjs +46 -0
- package/foundation/render/host-exit.d.mts +1 -0
- package/foundation/render/host-exit.mjs +6 -1
- package/foundation/render/html-reader.d.mts +55 -2
- package/foundation/render/html-reader.mjs +145 -26
- package/foundation/render/markup-edits.d.mts +57 -0
- package/foundation/render/markup-edits.mjs +182 -0
- package/foundation/render/page-host.mjs +29 -12
- package/foundation/render/page-worker.mjs +121 -13
- package/foundation/render/rebuild.mjs +2 -1
- package/foundation/render/render-page.d.mts +35 -3
- package/foundation/render/render-page.mjs +316 -42
- package/foundation/render/source-block.d.mts +85 -6
- package/foundation/render/source-block.mjs +211 -20
- package/foundation/render/ts-paths.d.mts +69 -6
- package/foundation/render/ts-paths.mjs +326 -40
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +12 -1
- package/foundation/response/error-codes.mjs +11 -1
- package/foundation/response/response-types.doc.mjs +2 -2
- package/foundation/text/compare-text.d.mts +14 -0
- package/foundation/text/compare-text.mjs +68 -0
- package/foundation/text/string-utils.d.mts +3 -2
- package/foundation/text/string-utils.mjs +18 -4
- package/foundation/text/suggest-order.d.mts +9 -0
- package/foundation/text/suggest-order.mjs +15 -1
- package/foundation/xle/expand.mjs +2 -1
- package/host/index.mjs +8 -6
- package/package.json +7 -6
|
@@ -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
|
+
* The colors written inside a value (a shadow's layers, a gradient's
|
|
6
|
+
* stops): each hex color and each color function, in order.
|
|
7
|
+
* @param {string} value
|
|
8
|
+
* @returns {string[]}
|
|
9
|
+
*/
|
|
10
|
+
export function colorsIn(value: string): string[];
|
|
4
11
|
/**
|
|
5
12
|
* The opacity of a CSS color, 0 to 1: the alpha of an 8- or 4-digit hex,
|
|
6
13
|
* `rgba()`/`hsla()`, or a `/ alpha` part; 0 for `transparent`; 1 otherwise.
|
|
@@ -72,6 +79,9 @@ export function isSafeValue(v: string): boolean;
|
|
|
72
79
|
export { splitTop };
|
|
73
80
|
/** The CSS named colors, for suggestions. */
|
|
74
81
|
export const COLOR_NAMES: string[];
|
|
82
|
+
export function namedColorHex(name: string): string | null;
|
|
83
|
+
/** One color written inside a value: a hex color or a color function. */
|
|
84
|
+
export const COLOR_IN_VALUE: RegExp;
|
|
75
85
|
export function hex(rgb: number[]): string;
|
|
76
86
|
export function isColorValue(v: unknown): boolean;
|
|
77
87
|
export function isSize(v: unknown, name?: string): boolean;
|
|
@@ -179,6 +179,14 @@ const NAMED = wordTable(
|
|
|
179
179
|
/** The CSS named colors, for suggestions. */
|
|
180
180
|
export const COLOR_NAMES = Object.keys(NAMED);
|
|
181
181
|
|
|
182
|
+
/**
|
|
183
|
+
* The hex a CSS color name is, or null.
|
|
184
|
+
* @param {string} name
|
|
185
|
+
* @returns {string | null}
|
|
186
|
+
*/
|
|
187
|
+
export const namedColorHex = name =>
|
|
188
|
+
Object.hasOwn(NAMED, name) ? NAMED[name] : null;
|
|
189
|
+
|
|
182
190
|
/** Color keywords that are valid colors but have no fixed value. */
|
|
183
191
|
const KEYWORDS = ['transparent', 'currentcolor', ...CSS_WIDE];
|
|
184
192
|
|
|
@@ -441,6 +449,20 @@ const polar = (c, h) => [
|
|
|
441
449
|
c * Math.sin((h * Math.PI) / 180),
|
|
442
450
|
];
|
|
443
451
|
|
|
452
|
+
/**
|
|
453
|
+
* The colors written inside a value (a shadow's layers, a gradient's
|
|
454
|
+
* stops): each hex color and each color function, in order.
|
|
455
|
+
* @param {string} value
|
|
456
|
+
* @returns {string[]}
|
|
457
|
+
*/
|
|
458
|
+
export function colorsIn(value) {
|
|
459
|
+
return [...String(value ?? '').matchAll(COLOR_IN_VALUE)].map(m => m[0]);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/** One color written inside a value: a hex color or a color function. */
|
|
463
|
+
export const COLOR_IN_VALUE =
|
|
464
|
+
/#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\((?:[^()]|\([^()]*\))*\)/gi;
|
|
465
|
+
|
|
444
466
|
/**
|
|
445
467
|
* The opacity of a CSS color, 0 to 1: the alpha of an 8- or 4-digit hex,
|
|
446
468
|
* `rgba()`/`hsla()`, or a `/ alpha` part; 0 for `transparent`; 1 otherwise.
|
|
@@ -514,7 +536,33 @@ export function mixSide(side) {
|
|
|
514
536
|
if (w == null) return null;
|
|
515
537
|
const plain = /^calc\(\s*(.*?)\s*\)$/i.exec(w)?.[1] ?? w;
|
|
516
538
|
const n = cssNumber(plain);
|
|
517
|
-
return n
|
|
539
|
+
if (n) return n.unit === '%' ? n.value : null;
|
|
540
|
+
// Math of two terms that gives a percentage: percentages added or
|
|
541
|
+
// taken away (`25% + 25%`), a percentage scaled by a number
|
|
542
|
+
// (`50% * 1`, `100% / 2`).
|
|
543
|
+
const m = /^(\S+)\s*([*/+-])\s*(\S+)$/.exec(plain);
|
|
544
|
+
if (!m) return null;
|
|
545
|
+
const [a, b] = [cssNumber(m[1]), cssNumber(m[3])];
|
|
546
|
+
if (!a || !b) return null;
|
|
547
|
+
const pct = (/** @type {{unit: string}} */ x) => x.unit === '%';
|
|
548
|
+
const plainNum = (/** @type {{unit: string}} */ x) => x.unit === '';
|
|
549
|
+
const r =
|
|
550
|
+
m[2] === '+' || m[2] === '-'
|
|
551
|
+
? pct(a) && pct(b)
|
|
552
|
+
? m[2] === '+'
|
|
553
|
+
? a.value + b.value
|
|
554
|
+
: a.value - b.value
|
|
555
|
+
: null
|
|
556
|
+
: m[2] === '*'
|
|
557
|
+
? pct(a) && plainNum(b)
|
|
558
|
+
? a.value * b.value
|
|
559
|
+
: plainNum(a) && pct(b)
|
|
560
|
+
? a.value * b.value
|
|
561
|
+
: null
|
|
562
|
+
: pct(a) && plainNum(b) && b.value !== 0
|
|
563
|
+
? a.value / b.value
|
|
564
|
+
: null;
|
|
565
|
+
return r != null && Number.isFinite(r) ? r : null;
|
|
518
566
|
};
|
|
519
567
|
if (words.length < 2) return {color: side.trim(), pct: null};
|
|
520
568
|
const last = share(words.at(-1));
|
|
@@ -384,7 +384,16 @@ export function makeCompiler(project, parts) {
|
|
|
384
384
|
function variantValues(target) {
|
|
385
385
|
const comp = TARGET.get(target)?.component;
|
|
386
386
|
const info = comp ? project.components[comp] : undefined;
|
|
387
|
+
// The component named like the part (Heading for heading) owns its
|
|
388
|
+
// values before any other component whose docs name the same class.
|
|
389
|
+
const pascal = target.replace(/(^|-)([a-z0-9])/g, (_, __, ch) =>
|
|
390
|
+
ch.toUpperCase(),
|
|
391
|
+
);
|
|
392
|
+
const own = project.components?.[pascal]?.targets?.find(
|
|
393
|
+
(/** @type {any} */ x) => x.className === `astryx-${target}`,
|
|
394
|
+
);
|
|
387
395
|
const t =
|
|
396
|
+
own ??
|
|
388
397
|
info?.targets.find(x => x.className === `astryx-${target}`) ??
|
|
389
398
|
info?.targets[0];
|
|
390
399
|
const fromDocs = t?.values ?? {};
|
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
recordWritten,
|
|
50
50
|
themeFiles,
|
|
51
51
|
refuseThemesNotFolder,
|
|
52
|
+
shown,
|
|
52
53
|
} from './_settings.mjs';
|
|
53
54
|
import {SHOWCASE_GROUPS, renderPreview, screenshot} from './_preview.mjs';
|
|
54
55
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
@@ -422,8 +423,58 @@ export async function pictures(project, shots, modes) {
|
|
|
422
423
|
for (const {html, png} of shots) {
|
|
423
424
|
for (const m of modes) {
|
|
424
425
|
const out = outOf(png, m);
|
|
425
|
-
|
|
426
|
-
|
|
426
|
+
// Taken under a name of its own and moved into place once whole: a
|
|
427
|
+
// run stopped while the browser runs leaves no picture at the real
|
|
428
|
+
// name (one the next run would read as a file of yours). A part left
|
|
429
|
+
// by a run stopped before is cleared.
|
|
430
|
+
const part = path.join(
|
|
431
|
+
path.dirname(out),
|
|
432
|
+
`.${path.basename(out, '.png')}.part-${process.pid}.png`,
|
|
433
|
+
);
|
|
434
|
+
for (const n of fs.existsSync(path.dirname(out))
|
|
435
|
+
? fs.readdirSync(path.dirname(out))
|
|
436
|
+
: [])
|
|
437
|
+
if (n.startsWith(`.${path.basename(out, '.png')}.part-`)) {
|
|
438
|
+
// Only a file is a part: a folder by that name is left alone.
|
|
439
|
+
const p = path.join(path.dirname(out), n);
|
|
440
|
+
try {
|
|
441
|
+
if (fs.lstatSync(p).isFile()) fs.rmSync(p, {force: true});
|
|
442
|
+
} catch {
|
|
443
|
+
// Gone already.
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
// A folder (or anything else) where this run's part goes: no
|
|
447
|
+
// picture, the path named, never a crash after a saved change.
|
|
448
|
+
if (fs.existsSync(part) && !fs.lstatSync(part).isFile())
|
|
449
|
+
return {
|
|
450
|
+
files,
|
|
451
|
+
problem: `${path.relative(project.cwd, part)} is a folder, where --png writes a picture before moving it into place, so no picture was taken; move it out of ${path.relative(project.cwd, path.dirname(out))}/`,
|
|
452
|
+
};
|
|
453
|
+
// A folder it cannot write gets no picture: named before the browser
|
|
454
|
+
// starts, never read as a browser that failed.
|
|
455
|
+
try {
|
|
456
|
+
fs.accessSync(path.dirname(out), fs.constants.W_OK);
|
|
457
|
+
} catch (e) {
|
|
458
|
+
return {
|
|
459
|
+
files,
|
|
460
|
+
problem: `${path.relative(project.cwd, path.dirname(out))}/ cannot be written (${/** @type {any} */ (e)?.code ?? 'no access'}), so no picture was taken; fix its permissions, then run the command again`,
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
const r = await screenshot(project, html, part, m);
|
|
464
|
+
if (!r.ok) {
|
|
465
|
+
fs.rmSync(part, {force: true});
|
|
466
|
+
return {files, problem: r.reason};
|
|
467
|
+
}
|
|
468
|
+
try {
|
|
469
|
+
fs.renameSync(part, out);
|
|
470
|
+
} catch (e) {
|
|
471
|
+
fs.rmSync(part, {force: true});
|
|
472
|
+
return {
|
|
473
|
+
files,
|
|
474
|
+
problem: `the picture could not be moved into ${path.relative(project.cwd, out)} (${/** @type {any} */ (e)?.code ?? e})`,
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
r.file = path.relative(project.cwd, out).split(path.sep).join('/');
|
|
427
478
|
files.push(r.file);
|
|
428
479
|
// A picture in a theme folder is recorded as the editor's, so a later
|
|
429
480
|
// change removes it and never a picture of the user's.
|
|
@@ -650,6 +701,7 @@ export async function previewAfter(ctx, slug, data, png) {
|
|
|
650
701
|
/** @type {string | null} */
|
|
651
702
|
let preview = null;
|
|
652
703
|
let cause = ctx.unchecked ?? null;
|
|
704
|
+
const f0 = themeFiles(ctx.project.cwd, slug);
|
|
653
705
|
try {
|
|
654
706
|
preview = await renderPreview(ctx, slug, data);
|
|
655
707
|
} catch (e) {
|
|
@@ -659,7 +711,12 @@ export async function previewAfter(ctx, slug, data, png) {
|
|
|
659
711
|
? renderCause(ctx.project, /** @type {Error} */ (e).message)
|
|
660
712
|
: ['ENOSPC', 'EACCES', 'EPERM', 'EROFS', 'EIO'].includes(code)
|
|
661
713
|
? `preview.html could not be written (${code === 'ENOSPC' ? 'the disk is full' : code}), so it still shows the theme as it was`
|
|
662
|
-
:
|
|
714
|
+
: // A folder (or another thing) where preview.html goes: the page
|
|
715
|
+
// was rendered, and could not be written there.
|
|
716
|
+
code === ERROR_CODES.ERR_WRITE_FAILED ||
|
|
717
|
+
(fs.existsSync(f0.preview) && !fs.statSync(f0.preview).isFile())
|
|
718
|
+
? `preview.html could not be written (${shown(ctx.project.cwd, f0.preview)} is ${fs.existsSync(f0.preview) && fs.statSync(f0.preview).isDirectory() ? 'a folder' : 'in the way'}; move it, then run ${P} show ${slug}), so it still shows the theme as it was`
|
|
719
|
+
: `checking it failed: ${e instanceof Error ? e.message : String(e)}`;
|
|
663
720
|
}
|
|
664
721
|
const f = themeFiles(ctx.project.cwd, slug);
|
|
665
722
|
// The sheet of every component is made by show only: after a change it
|
package/api/theme-edit/_css.mjs
CHANGED
|
@@ -235,6 +235,17 @@ export function matchType(type, value) {
|
|
|
235
235
|
*/
|
|
236
236
|
function matchWith(value, match) {
|
|
237
237
|
const {lexer, parse} = csstree();
|
|
238
|
+
// A color function holding a variable (color-mix(…, var(--x))) is a
|
|
239
|
+
// color whatever the variable holds: it is matched as one, so a value
|
|
240
|
+
// with many of them is read like the same value with plain colors.
|
|
241
|
+
for (let i = 0; i < 4; i++) {
|
|
242
|
+
const next = value.replace(
|
|
243
|
+
/\b(?:color-mix|light-dark|rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\((?:[^()]|\((?:[^()]|\([^()]*\))*\))*\)/gi,
|
|
244
|
+
m => (/\bvar\(/i.test(m) ? 'red' : m),
|
|
245
|
+
);
|
|
246
|
+
if (next === value) break;
|
|
247
|
+
value = next;
|
|
248
|
+
}
|
|
238
249
|
const vars =
|
|
239
250
|
value.match(/(?:var|env)\([^()]*(?:\([^()]*\)[^()]*)*\)/gi) ?? [];
|
|
240
251
|
/** @param {string} v */
|
|
@@ -263,7 +274,16 @@ function matchWith(value, match) {
|
|
|
263
274
|
return null;
|
|
264
275
|
}
|
|
265
276
|
}
|
|
266
|
-
|
|
277
|
+
// Many variables: each stands for the same kind of value at once.
|
|
278
|
+
if (vars.length > 3) {
|
|
279
|
+
for (const stand of VAR_STANDS_FOR) {
|
|
280
|
+
let v = value;
|
|
281
|
+
for (const x of vars) v = v.replace(x, stand);
|
|
282
|
+
const ast = tryOne(v);
|
|
283
|
+
if (ast) return ast;
|
|
284
|
+
}
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
267
287
|
/** @param {string} v @param {number} i @returns {any | null} */
|
|
268
288
|
const fill = (v, i) => {
|
|
269
289
|
if (i === vars.length) return tryOne(v);
|
|
@@ -20,6 +20,18 @@ export function themeEditNew(name: string, options?: import("./theme-edit.type.m
|
|
|
20
20
|
* @returns {string[]}
|
|
21
21
|
*/
|
|
22
22
|
export function newFlagList(like: string | null | undefined, settings: Record<string, string | string[] | undefined>, png?: boolean): string[];
|
|
23
|
+
/**
|
|
24
|
+
* A signal handler for the checks and pictures after a change is saved: it
|
|
25
|
+
* says what is saved (in the words of the command that ran) and how to run
|
|
26
|
+
* what did not, with the project's own CLI invocation, then lets the
|
|
27
|
+
* signal end the process (the render's own handler re-raises it; with none,
|
|
28
|
+
* this one does).
|
|
29
|
+
* @param {string} slug
|
|
30
|
+
* @param {'set' | 'undo' | 'new'} [kind] the command that saved
|
|
31
|
+
* @param {string} [cwd] the project, for the CLI invocation
|
|
32
|
+
* @returns {(sig: NodeJS.Signals) => void}
|
|
33
|
+
*/
|
|
34
|
+
export function stoppedAfterSave(slug: string, kind?: "set" | "undo" | "new", cwd?: string): (sig: NodeJS.Signals) => void;
|
|
23
35
|
/**
|
|
24
36
|
* Change one thing in a theme: checked, built, previewed.
|
|
25
37
|
* @experimental
|
|
@@ -38,6 +50,14 @@ export function themeEditSet(theme: string, thing: string, value: string, option
|
|
|
38
50
|
* @returns {Promise<import('../error.mjs').AstryxError | null>}
|
|
39
51
|
*/
|
|
40
52
|
export function editorStoredRefusal(root: string, slug: string): Promise<import("../error.mjs").AstryxError | null>;
|
|
53
|
+
/**
|
|
54
|
+
* The refusal `compile` gives an editor theme whose own source gives a
|
|
55
|
+
* token a value `set` refuses, or null.
|
|
56
|
+
* @param {string} root
|
|
57
|
+
* @param {string} slug
|
|
58
|
+
* @returns {Promise<AstryxError | null>}
|
|
59
|
+
*/
|
|
60
|
+
export function editorOwnTokenRefusal(root: string, slug: string): Promise<AstryxError | null>;
|
|
41
61
|
/**
|
|
42
62
|
* For `compile`: the refusal of [light, dark] pairs on tokens that are not
|
|
43
63
|
* colors in what the theme builds now, or null.
|
|
@@ -75,3 +95,5 @@ export function themeEditUndo(theme: string, options?: import("./theme-edit.type
|
|
|
75
95
|
*/
|
|
76
96
|
export function editorStale(cwd: string, slug: string): Promise<string | null>;
|
|
77
97
|
export type ChangeOptions = import("./theme-edit.type.mjs").ThemeEditChangeOptions;
|
|
98
|
+
import { AstryxError } from '../error.mjs';
|
|
99
|
+
export { carriesTyped, offersTyped } from "./_normal.mjs";
|