@astryxdesign/cli 0.7.16 → 0.7.17-canary.g49a475f
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.d.mts +4 -2
- package/api/build/kit/rank.mjs +125 -24
- package/api/build/kit/start.d.mts +5 -4
- package/api/build/kit/start.mjs +12 -8
- package/api/build/kit/weights.d.mts +39 -3
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +340 -43
- 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/_adapter.d.mts +9 -0
- package/api/search/_adapter.mjs +85 -0
- 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 +75 -0
- package/api/theme/build/build.mjs +243 -58
- package/api/theme/build/font-warning.d.mts +7 -0
- package/api/theme/build/font-warning.mjs +17 -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 +63 -2
- package/api/theme-edit/_adapter.mjs +771 -57
- package/api/theme-edit/_check.d.mts +40 -22
- package/api/theme-edit/_check.mjs +2029 -336
- 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.d.mts +3 -3
- package/api/theme-edit/_context.mjs +111 -48
- package/api/theme-edit/_css.d.mts +14 -0
- package/api/theme-edit/_css.mjs +46 -1
- package/api/theme-edit/_edit.d.mts +18 -4
- package/api/theme-edit/_edit.mjs +1685 -155
- package/api/theme-edit/_how-commands.d.mts +65 -0
- package/api/theme-edit/_how-commands.mjs +633 -1
- package/api/theme-edit/_how-question.d.mts +84 -0
- package/api/theme-edit/_how-question.mjs +5124 -281
- package/api/theme-edit/_how.mjs +140 -29
- package/api/theme-edit/_marks.d.mts +31 -5
- package/api/theme-edit/_marks.mjs +57 -5
- package/api/theme-edit/_name-rule.d.mts +11 -0
- package/api/theme-edit/_name-rule.mjs +12 -0
- package/api/theme-edit/_normal.d.mts +257 -0
- package/api/theme-edit/_normal.mjs +1252 -0
- package/api/theme-edit/_palette.mjs +10 -4
- package/api/theme-edit/_parts.d.mts +10 -1
- package/api/theme-edit/_parts.mjs +179 -3
- package/api/theme-edit/_preview-app.d.mts +7 -1
- package/api/theme-edit/_preview-app.mjs +515 -148
- package/api/theme-edit/_preview.d.mts +100 -14
- package/api/theme-edit/_preview.mjs +549 -137
- package/api/theme-edit/_settings.d.mts +347 -30
- package/api/theme-edit/_settings.mjs +2971 -327
- 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.d.mts +0 -1
- package/api/theme-edit/themeEditNew.doc.mjs +7 -4
- 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/search-catalog.generated.json +2 -0
- 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 +163 -28
- 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 +10 -3
- 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/experimental-theme-preview.doc.mjs +2 -1
- package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
- 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 +209 -8
- 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-search-catalog.d.mts +115 -0
- package/foundation/discovery/stored-search-catalog.mjs +297 -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/picture-chrome.d.mts +4 -0
- package/foundation/render/picture-chrome.mjs +185 -0
- package/foundation/render/picture-playwright.d.mts +4 -0
- package/foundation/render/picture-playwright.mjs +34 -0
- 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
|
@@ -129,6 +129,12 @@ export const WRAPPED_PARTS: Record<string, {
|
|
|
129
129
|
}>;
|
|
130
130
|
/** States every part takes, beyond the ones its doc lists. */
|
|
131
131
|
export const COMMON_STATES: string[];
|
|
132
|
+
/**
|
|
133
|
+
* Mode words a value or a saved entry may be labeled with, and the mode
|
|
134
|
+
* each means: `set` reads a typed label by it, and loading reads a saved
|
|
135
|
+
* entry's mode by it.
|
|
136
|
+
*/
|
|
137
|
+
export const MODE_WORDS: Record<string, "light" | "dark">;
|
|
132
138
|
export type Dial = {
|
|
133
139
|
/**
|
|
134
140
|
* - What the dial does, its rungs, and where it applies.
|
|
@@ -201,6 +201,10 @@ const ONE_SYSTEM_FAMILIES = new Map(
|
|
|
201
201
|
'segoe ui',
|
|
202
202
|
'segoe ui emoji',
|
|
203
203
|
'segoe ui symbol',
|
|
204
|
+
'segoe ui light',
|
|
205
|
+
'segoe ui semilight',
|
|
206
|
+
'segoe ui semibold',
|
|
207
|
+
'segoe ui black',
|
|
204
208
|
'consolas',
|
|
205
209
|
'cambria',
|
|
206
210
|
'calibri',
|
|
@@ -607,6 +611,14 @@ export const GROUPS = wordTable(
|
|
|
607
611
|
'margin',
|
|
608
612
|
'margin-block',
|
|
609
613
|
'margin-inline',
|
|
614
|
+
'margin-top',
|
|
615
|
+
'margin-bottom',
|
|
616
|
+
'margin-left',
|
|
617
|
+
'margin-right',
|
|
618
|
+
'margin-block-start',
|
|
619
|
+
'margin-block-end',
|
|
620
|
+
'margin-inline-start',
|
|
621
|
+
'margin-inline-end',
|
|
610
622
|
],
|
|
611
623
|
font: [
|
|
612
624
|
'font-family',
|
|
@@ -712,7 +724,23 @@ export const THING_HINTS = wordTable({
|
|
|
712
724
|
`${P} set <theme> spacing roomy${on ? ` --on ${on}` : ''}`,
|
|
713
725
|
`${P} set <theme> padding 12px --on ${on ?? '<part>'}`,
|
|
714
726
|
],
|
|
715
|
-
density:
|
|
727
|
+
// The density named carries over: a spacing rung as it is, a word for
|
|
728
|
+
// more or less room as the rung that way; else how spacing.
|
|
729
|
+
density: (v, on) => {
|
|
730
|
+
const w = v.trim().toLowerCase();
|
|
731
|
+
const rung = SPACING.some(([n]) => n === w)
|
|
732
|
+
? w
|
|
733
|
+
: /^(airy|loose|relaxed|comfortable|open|sparse|generous)$/.test(w)
|
|
734
|
+
? 'roomy'
|
|
735
|
+
: /^(dense|cramped|condensed|packed|small|less)$/.test(w)
|
|
736
|
+
? 'compact'
|
|
737
|
+
: null;
|
|
738
|
+
return [
|
|
739
|
+
rung
|
|
740
|
+
? `${P} set <theme> spacing ${rung}${on ? ` --on ${on}` : ''}`
|
|
741
|
+
: `${HOW} spacing`,
|
|
742
|
+
];
|
|
743
|
+
},
|
|
716
744
|
bold: (v, on) => [
|
|
717
745
|
`${P} set <theme> font-weight ${/^(none|false|off|no|normal)$/i.test(v.trim()) ? 'normal' : 'bold'} --on ${on ?? '<part>'}`,
|
|
718
746
|
],
|
|
@@ -758,6 +786,20 @@ export const COMMON_STATES = [
|
|
|
758
786
|
'disabled',
|
|
759
787
|
];
|
|
760
788
|
|
|
789
|
+
/**
|
|
790
|
+
* Mode words a value or a saved entry may be labeled with, and the mode
|
|
791
|
+
* each means: `set` reads a typed label by it, and loading reads a saved
|
|
792
|
+
* entry's mode by it.
|
|
793
|
+
*/
|
|
794
|
+
export const MODE_WORDS = /** @type {Record<string, 'light' | 'dark'>} */ ({
|
|
795
|
+
light: 'light',
|
|
796
|
+
'light-mode': 'light',
|
|
797
|
+
day: 'light',
|
|
798
|
+
dark: 'dark',
|
|
799
|
+
'dark-mode': 'dark',
|
|
800
|
+
night: 'dark',
|
|
801
|
+
});
|
|
802
|
+
|
|
761
803
|
// These tables are looked up by words people type: with no prototype,
|
|
762
804
|
// `constructor` or `__proto__` is never found in them.
|
|
763
805
|
for (const table of [
|
|
@@ -774,5 +816,6 @@ for (const table of [
|
|
|
774
816
|
DIRECT,
|
|
775
817
|
THING_HINTS,
|
|
776
818
|
DESIGN,
|
|
819
|
+
MODE_WORDS,
|
|
777
820
|
])
|
|
778
821
|
Object.setPrototypeOf(table, null);
|
|
@@ -40,3 +40,21 @@ export function readSetLine(name: string, slug: string): {
|
|
|
40
40
|
* @returns {T}
|
|
41
41
|
*/
|
|
42
42
|
export function vetSuggestions<T>(e: T, ctx: import("./_settings.mjs").Ctx | null | undefined, slug: string, data: import("./_settings.mjs").ThemeData | null | undefined): T;
|
|
43
|
+
/**
|
|
44
|
+
* Follow a suggested command before it is offered: `check` runs the line as
|
|
45
|
+
* its command would (in memory, nothing written) and gives null when it
|
|
46
|
+
* runs, else the refusal. The refusal's own repair (its first suggestion
|
|
47
|
+
* `isRepair` takes that was not tried) replaces the line, until the line
|
|
48
|
+
* runs or no repair is offered; `why` then names what is still refused.
|
|
49
|
+
* Every refusal-suggested `set`, `undo`, `new` and `compile` that is a
|
|
50
|
+
* repair of a typed command goes through here.
|
|
51
|
+
* @param {string} line
|
|
52
|
+
* @param {(line: string) => Promise<AstryxError | null> | AstryxError | null} check
|
|
53
|
+
* @param {(name: string) => boolean} isRepair
|
|
54
|
+
* @returns {Promise<{line: string, why: string | null}>}
|
|
55
|
+
*/
|
|
56
|
+
export function followLine(line: string, check: (line: string) => Promise<AstryxError | null> | AstryxError | null, isRepair: (name: string) => boolean): Promise<{
|
|
57
|
+
line: string;
|
|
58
|
+
why: string | null;
|
|
59
|
+
}>;
|
|
60
|
+
import { AstryxError } from '../error.mjs';
|
package/api/theme-edit/_vet.mjs
CHANGED
|
@@ -142,3 +142,35 @@ export function vetSuggestions(e, ctx, slug, data) {
|
|
|
142
142
|
: [{name: `${P} set --help`, reason: 'see what set takes'}];
|
|
143
143
|
return e;
|
|
144
144
|
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Follow a suggested command before it is offered: `check` runs the line as
|
|
148
|
+
* its command would (in memory, nothing written) and gives null when it
|
|
149
|
+
* runs, else the refusal. The refusal's own repair (its first suggestion
|
|
150
|
+
* `isRepair` takes that was not tried) replaces the line, until the line
|
|
151
|
+
* runs or no repair is offered; `why` then names what is still refused.
|
|
152
|
+
* Every refusal-suggested `set`, `undo`, `new` and `compile` that is a
|
|
153
|
+
* repair of a typed command goes through here.
|
|
154
|
+
* @param {string} line
|
|
155
|
+
* @param {(line: string) => Promise<AstryxError | null> | AstryxError | null} check
|
|
156
|
+
* @param {(name: string) => boolean} isRepair
|
|
157
|
+
* @returns {Promise<{line: string, why: string | null}>}
|
|
158
|
+
*/
|
|
159
|
+
export async function followLine(line, check, isRepair) {
|
|
160
|
+
const tried = new Set([line]);
|
|
161
|
+
let now = line;
|
|
162
|
+
for (;;) {
|
|
163
|
+
const refused = await check(now);
|
|
164
|
+
if (!refused) return {line: now, why: null};
|
|
165
|
+
const next = (refused.suggestions ?? []).find(
|
|
166
|
+
x => isRepair(x.name) && !tried.has(x.name),
|
|
167
|
+
);
|
|
168
|
+
if (!next)
|
|
169
|
+
return {
|
|
170
|
+
line: now,
|
|
171
|
+
why: refused.message.replace(/\s*Nothing was changed\.$/, ''),
|
|
172
|
+
};
|
|
173
|
+
now = next.name;
|
|
174
|
+
tried.add(now);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -123,7 +123,7 @@ export type ThemeEditPreviewFields = {
|
|
|
123
123
|
*/
|
|
124
124
|
previewStale?: string[] | undefined;
|
|
125
125
|
/**
|
|
126
|
-
* - One line on how to see the change: first a look that changes nothing in the app (the editor's preview.html, current after the change, and `png`, which takes pictures with no dev server), then the in-app preview page most about it (Colors for a color, Components for a part, else Overview) at its own URL when there is a preview, and adding one to the app last, as an option. When the change could not be rendered, it names why instead of the editor's page.
|
|
126
|
+
* - One line on how to see the change: first a look that changes nothing in the app (the editor's preview.html, current after the change, and `png`, which takes pictures with no dev server; when this result's own picture run was blocked, what blocked it instead), then the in-app preview page most about it (Colors for a color, Components for a part, else Overview) at its own URL when there is a preview, and adding one to the app last, as an option. When the change could not be rendered, it names why instead of the editor's page.
|
|
127
127
|
*/
|
|
128
128
|
see: string;
|
|
129
129
|
/**
|
|
@@ -132,6 +132,10 @@ export type ThemeEditPreviewFields = {
|
|
|
132
132
|
appCopy?: {
|
|
133
133
|
wrote: string[];
|
|
134
134
|
} | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* - Set when the app copy (src/themes/<theme>/) was not written: a file, folder or link of yours at one of its names; a link on the way to it (src/, src/themes/ or the copy's folder; the editor writes nothing through one); a file where src/, src/themes/ or the copy's folder goes; or a folder that cannot be written, or a write that failed (with the system's reason, such as not writable or the disk is full). The app keeps the theme as it was, and this says what is in the way and why.
|
|
137
|
+
*/
|
|
138
|
+
appCopyStale?: string | undefined;
|
|
135
139
|
};
|
|
136
140
|
/**
|
|
137
141
|
* `astryx --json experimental theme editor new <theme>`.
|
|
@@ -249,6 +253,10 @@ export type ThemeEditChangeData = {
|
|
|
249
253
|
* - Set when sheet.html shows the theme as it was before this change: see ThemeEditPreviewFields.
|
|
250
254
|
*/
|
|
251
255
|
sheetStale?: string | undefined;
|
|
256
|
+
/**
|
|
257
|
+
* - Set when the app copy could not be written (something of yours at a copy name or on the way, or a write that failed): see ThemeEditPreviewFields.
|
|
258
|
+
*/
|
|
259
|
+
appCopyStale?: string | undefined;
|
|
252
260
|
/**
|
|
253
261
|
* - Only the first time the theme's app copy is written: see ThemeEditPreviewFields.
|
|
254
262
|
*/
|
|
@@ -305,6 +313,7 @@ export type ThemeEditShowResponse = {
|
|
|
305
313
|
appCopy?: {
|
|
306
314
|
wrote: string[];
|
|
307
315
|
} | undefined;
|
|
316
|
+
appCopyStale?: string | undefined;
|
|
308
317
|
wiring: string[];
|
|
309
318
|
};
|
|
310
319
|
};
|
|
@@ -53,8 +53,9 @@
|
|
|
53
53
|
* @property {{code: string, cause: string} | null} notChecked - Set when the change is saved but the components could not be rendered, so it was not checked and has no preview: the cause, such as two copies of React.
|
|
54
54
|
* @property {string} [sheetStale] - Set when sheet.html (the sheet of every component, made by `show`) shows the theme as it was before this change: it says so at its top until `show` makes it again.
|
|
55
55
|
* @property {string[]} [previewStale] - Files of the in-app theme preview that were not written again and still show the theme as it was: changed by hand, or a preview folder where a stopped preview change waits for the next preview command.
|
|
56
|
-
* @property {string} see - One line on how to see the change: first a look that changes nothing in the app (the editor's preview.html, current after the change, and `png`, which takes pictures with no dev server), then the in-app preview page most about it (Colors for a color, Components for a part, else Overview) at its own URL when there is a preview, and adding one to the app last, as an option. When the change could not be rendered, it names why instead of the editor's page.
|
|
56
|
+
* @property {string} see - One line on how to see the change: first a look that changes nothing in the app (the editor's preview.html, current after the change, and `png`, which takes pictures with no dev server; when this result's own picture run was blocked, what blocked it instead), then the in-app preview page most about it (Colors for a color, Components for a part, else Overview) at its own URL when there is a preview, and adding one to the app last, as an option. When the change could not be rendered, it names why instead of the editor's page.
|
|
57
57
|
* @property {{wrote: string[]}} [appCopy] - Only the first time the theme's app copy is written (src/themes/<theme>/, a standard local theme `astryx theme add <theme>` takes, written again after every build): the files written.
|
|
58
|
+
* @property {string} [appCopyStale] - Set when the app copy (src/themes/<theme>/) was not written: a file, folder or link of yours at one of its names; a link on the way to it (src/, src/themes/ or the copy's folder; the editor writes nothing through one); a file where src/, src/themes/ or the copy's folder goes; or a folder that cannot be written, or a write that failed (with the system's reason, such as not writable or the disk is full). The app keeps the theme as it was, and this says what is in the way and why.
|
|
58
59
|
*/
|
|
59
60
|
|
|
60
61
|
/**
|
|
@@ -100,6 +101,7 @@
|
|
|
100
101
|
* @property {string[]} [previewStale] - In-app preview files changed by hand: see ThemeEditPreviewFields.
|
|
101
102
|
* @property {string} see - How to see the change: see ThemeEditPreviewFields.
|
|
102
103
|
* @property {string} [sheetStale] - Set when sheet.html shows the theme as it was before this change: see ThemeEditPreviewFields.
|
|
104
|
+
* @property {string} [appCopyStale] - Set when the app copy could not be written (something of yours at a copy name or on the way, or a write that failed): see ThemeEditPreviewFields.
|
|
103
105
|
* @property {{wrote: string[]}} [appCopy] - Only the first time the theme's app copy is written: see ThemeEditPreviewFields.
|
|
104
106
|
*/
|
|
105
107
|
|
|
@@ -137,6 +139,7 @@
|
|
|
137
139
|
* @property {string | null} data.pictureProblem
|
|
138
140
|
* @property {{config: string, module: string, receipt: string} | null} data.colorFiles - The generated color files: the input (in the shape `theme palette generate` reads), the module the theme imports, and the receipt; null when the theme sets no color.
|
|
139
141
|
* @property {{wrote: string[]}} [data.appCopy] - Only the first time the theme's app copy is written: the files written in src/themes/<theme>/.
|
|
142
|
+
* @property {string} [data.appCopyStale] - Set when the app copy was not written: a file, folder or link of yours at one of its names; a link on the way to it (src/, src/themes/ or the copy's folder; the editor writes nothing through one); a file where src/, src/themes/ or the copy's folder goes; or a folder that cannot be written, or a write that failed (with the system's reason, such as not writable or the disk is full).
|
|
140
143
|
* @property {string[]} data.wiring - The steps that put the theme into this app: the root file, its imports, the Theme around the app, and what builds it (`theme add <theme>`, for the app copy the editor writes in src/themes/<theme>/; the imports by hand when a folder of yours is there).
|
|
141
144
|
*/
|
|
142
145
|
|
|
@@ -13,7 +13,7 @@ export const doc = {
|
|
|
13
13
|
summary:
|
|
14
14
|
"Look up a part, group, setting or aspect; answer a question in plain words; read a picture's colors; or list what you can set.",
|
|
15
15
|
description:
|
|
16
|
-
'One command for every question. A part (button, card; --list parts): what it reads for each aspect (text, background, border, corners, shadow, spacing, font, size), each condition written as the --when and --state flags `set` takes or marked not settable with the reason, its variants, every state `set` accepts, the parts inside it (a token set --on the part reaches them), and its group; a part the part data does not have says so, with commands that still apply. A group (inputs, containers, checks, menus): its members and whether styling one styles all. A setting: a dial\'s rungs and examples, a token\'s type, default and the parts that read it (and, when none does, whether Core\'s stylesheet still uses it), or a CSS property and the parts that set it. An aspect (text, background, border, corners, shadow, spacing, font, size): the dial and the whole-theme tokens most parts read for it. `colors` (or `palette`): how the theme\'s colors are made: one seed per color, light and dark shades generated with the same generator as `theme palette generate`, the shade each token starts from, vibrancy, the Colors preview page and the exact-token escape hatch. A lookup takes any case, a plural, and a token name without its dashes. A question in plain words ("bold white text in the header", "remove shadows from cards", "cards: 8px radius; buttons: 4px"): it reads each clause for the parts (and their variant, size, state or mode), what to change, the values typed (hex, rgb(), lengths, dashed), and whether it asks for more, less or none ("shouldn\'t", "turn off", "never", "too sharp", "everything except X" included), and answers with exact commands; a typed value always wins over a color word, and a hex color with the wrong number of digits is refused by name, never replaced with a sample. "In dark mode" carries --mode dark to every color command; a change that cannot differ by mode, or a dark-mode ask on a light-only theme, says so instead. A question about what something is ("what does --color-accent do") gets the lookup. Several changes in one question come first as one sequence (`sequence: true`: run every command in order, at most 12), with repeated and overwritten steps left out; two asks that contradict each other are offered as choices. Changes come before lookups. Every suggested command names the theme (`theme`: the one named with `theme`, the only one, or the one an editor command changed last, said in `themeNote`; `themeChosenBy` says which: named, only, last-changed or none; with none, my-theme, made first), holds a real value, never a placeholder or a comment, and is checked as `set` checks it: a command `set` would refuse, or that changes nothing, is left out and listed in `refused` with the reason. A question with no answer says why in `hint`, with the next commands in `run
|
|
16
|
+
'One command for every question. A part (button, card; --list parts): what it reads for each aspect (text, background, border, corners, shadow, spacing, font, size), each condition written as the --when and --state flags `set` takes or marked not settable with the reason, its variants, every state `set` accepts, the parts inside it (a token set --on the part reaches them), and its group; a part the part data does not have says so, with commands that still apply. A group (inputs, containers, checks, menus): its members and whether styling one styles all. A setting: a dial\'s rungs and examples, a token\'s type, default and the parts that read it (and, when none does, whether Core\'s stylesheet still uses it), or a CSS property and the parts that set it. An aspect (text, background, border, corners, shadow, spacing, font, size): the dial and the whole-theme tokens most parts read for it. `colors` (or `palette`): how the theme\'s colors are made: one seed per color, light and dark shades generated with the same generator as `theme palette generate`, the shade each token starts from, vibrancy, the Colors preview page and the exact-token escape hatch. A lookup takes any case, a plural, and a token name without its dashes. A question in plain words ("bold white text in the header", "remove shadows from cards", "cards: 8px radius; buttons: 4px"): it reads each clause for the parts (and their variant, size, state or mode), what to change, the values typed (hex, rgb(), lengths, dashed), and whether it asks for more, less or none ("shouldn\'t", "turn off", "never", "too sharp", "everything except X" included), and answers with exact commands; a typed value always wins over a color word, and a hex color with the wrong number of digits is refused by name, never replaced with a sample. "In dark mode" carries --mode dark to every color command; a change that cannot differ by mode, or a dark-mode ask on a light-only theme, says so instead. A question about what something is ("what does --color-accent do") gets the lookup. Several changes in one question come first as one sequence (`sequence: true`: run every command in order, at most 12), with repeated and overwritten steps left out; two asks that contradict each other are offered as choices. Changes come before lookups. Every suggested command names the theme (`theme`: the one named with `theme`, the only one, or the one an editor command changed last, said in `themeNote`; `themeChosenBy` says which: named, only, last-changed or none; with none, my-theme, made first), holds a real value, never a placeholder or a comment, and is checked as `set` checks it: a command `set` would refuse, or that changes nothing, is left out and listed in `refused` with the reason. A question with no answer says why in `hint`, with the next commands in `run`; the command\'s help (`astryx experimental theme editor how --help`) lists the kinds of ask it understands, with examples. A PNG picture (by any file name; other formats are refused by their bytes): its main colors from every pixel (on an even grid past 4 million), biggest share first, with where each sits, see-through pixels skipped, tRNS included (a number after the file sets how many, default 14), or with --at the exact color and alpha at pixel points; a picture over 40 million pixels (20 million at 16 bits), or with pixel data that is damaged or shorter than its header says, is refused before it is decoded. --list <what> lists what a change can name (dials, tokens, parts, groups or properties, in any case, singular or plural; kinds or no word lists those kinds), and the other words filter the list. Experimental: it may change or be removed in a patch release.',
|
|
17
17
|
importPath: '@astryxdesign/cli/api/experimental',
|
|
18
18
|
signature:
|
|
19
19
|
'themeEditHow(subject?: string, options?: object): Promise<object>',
|
|
@@ -1,6 +1,5 @@
|
|
|
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
|
-
/** @file FunctionDoc for `themeEditNew()` / `astryx experimental theme editor new`. */
|
|
5
4
|
/** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
|
|
6
5
|
export const doc: import("@astryxdesign/cli/authoring").FunctionDoc;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
/** @file FunctionDoc for `themeEditNew()` / `astryx experimental theme editor new`. */
|
|
4
4
|
|
|
5
|
+
import {NAME_RULE} from './_name-rule.mjs';
|
|
6
|
+
|
|
5
7
|
/** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
|
|
6
8
|
export const doc = {
|
|
7
9
|
type: 'function',
|
|
@@ -12,7 +14,9 @@ export const doc = {
|
|
|
12
14
|
displayName: 'themeEditNew()',
|
|
13
15
|
summary: 'Start a theme in themes/<theme>/, optionally on a built-in theme.',
|
|
14
16
|
description:
|
|
15
|
-
'Makes themes/<theme>/ with <theme>.settings.json (the settings this command owns), the generated <theme>.settings.ts, <theme>.theme.ts (which extends it and is yours), and the built <theme>.css and <theme>.js (build them again with `astryx experimental theme compile themes/<theme>/<theme>.theme.ts`, which checks the editor settings first), then writes preview.html, the sample app page with the theme. --like builds on a built-in theme (neutral, stone, matcha, y2k, gothic, chocolate, butter; its package must be installed); without it the theme starts from Astryx defaults. `settings` takes any `set` dial by name ({accent: "#7c3aed", font: "inter", corners: "round", vibrancy: "60"}): the same names, values and checks as `set`, all applied in the one build, with one result that lists them. Change the base later with `astryx experimental theme editor set <theme> base <theme|none>`. Afterwards, <theme>.theme.ts is yours: it extends the generated <theme>.settings.ts, and every later change rewrites only the settings files, so your own edits in <theme>.theme.ts survive. A theme name is
|
|
17
|
+
'Makes themes/<theme>/ with <theme>.settings.json (the settings this command owns), the generated <theme>.settings.ts, <theme>.theme.ts (which extends it and is yours), and the built <theme>.css and <theme>.js (build them again with `astryx experimental theme compile themes/<theme>/<theme>.theme.ts`, which checks the editor settings first), then writes preview.html, the sample app page with the theme. --like builds on a built-in theme (neutral, stone, matcha, y2k, gothic, chocolate, butter; its package must be installed); without it the theme starts from Astryx defaults. `settings` takes any `set` dial by name ({accent: "#7c3aed", font: "inter", corners: "round", vibrancy: "60"}): the same names, values and checks as `set`, all applied in the one build, with one result that lists them. Change the base later with `astryx experimental theme editor set <theme> base <theme|none>`. Afterwards, <theme>.theme.ts is yours: it extends the generated <theme>.settings.ts, and every later change rewrites only the settings files, so your own edits in <theme>.theme.ts survive. A theme name is ' +
|
|
18
|
+
NAME_RULE +
|
|
19
|
+
'. Experimental: it may change or be removed in a patch release.',
|
|
16
20
|
importPath: '@astryxdesign/cli/api/experimental',
|
|
17
21
|
signature: 'themeEditNew(theme: string, options?: object): Promise<object>',
|
|
18
22
|
keywords: [
|
|
@@ -26,8 +30,7 @@ export const doc = {
|
|
|
26
30
|
{
|
|
27
31
|
name: 'theme',
|
|
28
32
|
type: 'string',
|
|
29
|
-
description:
|
|
30
|
-
'The theme name: lowercase letters, digits and dashes, starting with a letter, 64 characters at most, not a name Windows reserves (con, prn, aux, nul, com1-com9, lpt1-lpt9).',
|
|
33
|
+
description: `The theme name: ${NAME_RULE}.`,
|
|
31
34
|
required: true,
|
|
32
35
|
},
|
|
33
36
|
{
|
|
@@ -63,7 +66,7 @@ export const doc = {
|
|
|
63
66
|
throws: [
|
|
64
67
|
{
|
|
65
68
|
code: 'ERR_INVALID_ARGUMENT',
|
|
66
|
-
when:
|
|
69
|
+
when: `the name breaks the theme-name rule (${NAME_RULE}), or \`settings\` names something that is not a dial`,
|
|
67
70
|
},
|
|
68
71
|
{
|
|
69
72
|
code: 'ERR_FILE_EXISTS',
|
|
@@ -12,7 +12,7 @@ export const doc = {
|
|
|
12
12
|
displayName: 'themeEditPreviewApp()',
|
|
13
13
|
summary: 'Make a new starter app with the theme preview inside.',
|
|
14
14
|
description:
|
|
15
|
-
"Writes a new starter app into `dir` (Next.js app router, Core and the neutral theme, with the Astryx packages pinned to this CLI's release; with `theme`, Core and the base theme are pinned to the versions this project has, the ones the copied build was made on, with a note), with the theme preview route and its default pages (the sample app page and every component grouped) in src/app/theme-preview/. With `theme`, the theme folder is copied into the app's themes/ and the pages wear it; a base theme or font package it needs is added to package.json. No install runs: the result says how to install, run and open it. `dir` must be new or empty, inside the
|
|
15
|
+
"Writes a new starter app into `dir` (Next.js app router, Core and the neutral theme, with the Astryx packages pinned to this CLI's release; with `theme`, Core and the base theme are pinned to the versions this project has, the ones the copied build was made on, with a note), with the theme preview route and its default pages (the sample app page and every component grouped) in src/app/theme-preview/. With `theme`, the theme folder is copied into the app's themes/ and the pages wear it; a base theme or font package it needs is added to package.json. No install runs: the result says how to install, run and open it. `dir` must be new or empty, inside the project folder (from a subfolder too); a folder that is not empty is refused, with a free folder name to use instead. Every check runs before the first write, so a refusal changes nothing. Every open font the theme names is added to package.json, at the version this project has or a pinned range, and the route imports it; a theme with generated colors gets the Colors page too, and a one-mode theme starts the route in its mode. The app is written into a temp folder beside the folder and moved into place, so a failure leaves nothing behind. A folder holding only .git, .DS_Store or Thumbs.db counts as empty. The folder is refused when it is a file, a dangling link, inside this app's routes folder, themes/, node_modules/ or Next's build folder (.next/, out/ or the distDir next.config names), or written with Windows separators, white space at either end or a name too long. A theme whose build is missing or older than its settings is built first, with a note. The app's home page links to the preview, and its .gitignore leaves out node_modules, next-env.d.ts and *.tsbuildinfo. Inside a project with a tsconfig.json, a note says to exclude the new folder. With a theme, it holds that theme's lock while it builds and copies it, so an `editor set` on the same theme waits for it. A folder given from a subfolder of the project is taken from where it was given. An app is refused in public/ (served as files at the site root) and under a name Windows does not allow; a base theme passed to --theme is named as a package theme, installed or not, with the command that adds it. Experimental: it may change or be removed in a patch release.",
|
|
16
16
|
importPath: '@astryxdesign/cli/api/experimental',
|
|
17
17
|
signature:
|
|
18
18
|
'themeEditPreviewApp(dir: string, options?: object): Promise<object>',
|
|
@@ -28,7 +28,7 @@ export const doc = {
|
|
|
28
28
|
name: 'dir',
|
|
29
29
|
type: 'string',
|
|
30
30
|
description:
|
|
31
|
-
'The folder for the new app: new or empty, inside the
|
|
31
|
+
'The folder for the new app: new or empty, inside the project folder.',
|
|
32
32
|
required: true,
|
|
33
33
|
},
|
|
34
34
|
{
|
|
@@ -57,7 +57,7 @@ export const doc = {
|
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
code: 'ERR_PATH_TRAVERSAL',
|
|
60
|
-
when: '`dir` is outside the
|
|
60
|
+
when: '`dir` is outside the project folder, or a file it writes leads outside it through a link',
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
code: 'ERR_UNKNOWN_THEME',
|
|
@@ -12,7 +12,7 @@ export const doc = {
|
|
|
12
12
|
displayName: 'themeEditPreviewRemove()',
|
|
13
13
|
summary: 'Remove one page from the theme preview, or the whole preview.',
|
|
14
14
|
description:
|
|
15
|
-
'Removes one page and its nav item, and rewrites the route. With no page, or for the last page, it removes the whole preview: only the files the preview wrote (theme-preview.json lists them) are deleted, and the folder only when nothing else is in it. A path in theme-preview.json that leads outside the route folder is
|
|
15
|
+
'Removes one page and its nav item, and rewrites the route. With no page, or for the last page, it removes the whole preview: only the files the preview wrote (theme-preview.json lists them) are deleted, and the folder only when nothing else is in it. A path in theme-preview.json that leads outside the route folder is dropped from the record and named in a note; nothing outside the folder is deleted. Only files the preview wrote are deleted: a page file it did not write, or one changed by hand since it wrote it (by the hash theme-preview.json records), is kept and named in `kept`, with a note; files already gone are named in `missing`, and the route and Colors page written again in `rewritten`. Every check runs before the first delete: the theme the route wears is loaded first, so a theme that does not load is refused with nothing deleted, and the refusal names the whole-preview remove, which needs no theme. A theme that is gone is replaced by the theme of the app itself, with a note. A page id matches in any case. A damaged theme-preview.json (not JSON, the wrong shape, a duplicate page, a folder or an absolute path in its files) is refused with `ERR_THEME_INVALID`, naming the file. With no folder given and no preview in the default place, a preview recorded for a theme is used. A whole remove stops, deleting nothing, when page.tsx was changed by hand: it imports the pages. A page whose file is gone leaves the nav, with a note. Refusals never suggest deleting files. Preview commands in one project run one after another. A remove deletes only the route file, the record and the page files of recorded pages (in _pages/, or pages/ for an older release), and only when a recorded hash shows they are as the preview wrote them: any other file the record names, and any file with no recorded hash, is kept and named, so a copied or edited record never deletes a project file. A route that stays keeps the pages it imports. Experimental: it may change or be removed in a patch release.',
|
|
16
16
|
importPath: '@astryxdesign/cli/api/experimental',
|
|
17
17
|
signature:
|
|
18
18
|
'themeEditPreviewRemove(page?: string, options?: object): Promise<object>',
|
|
@@ -46,7 +46,7 @@ export const doc = {
|
|
|
46
46
|
throws: [
|
|
47
47
|
{
|
|
48
48
|
code: 'ERR_PATH_TRAVERSAL',
|
|
49
|
-
when: '
|
|
49
|
+
when: '--path leads outside the project; nothing is deleted',
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
code: 'ERR_NOT_FOUND',
|
package/api/upgrade/run/run.mjs
CHANGED
|
@@ -63,6 +63,7 @@ import {
|
|
|
63
63
|
} from '../../../foundation/fs/path-safety.mjs';
|
|
64
64
|
import {createFileProtectionResolver} from '../../../foundation/fs/file-protection.mjs';
|
|
65
65
|
import {withoutProtected} from '../../../assets/codemods/runner.mjs';
|
|
66
|
+
import {compareText} from '../../../foundation/text/compare-text.mjs';
|
|
66
67
|
|
|
67
68
|
/**
|
|
68
69
|
* Collapse per-codemod protection hits into one stable row per file.
|
|
@@ -92,7 +93,7 @@ function summarizeProtectedFiles(rows) {
|
|
|
92
93
|
declarations: [...item.declarations].sort(),
|
|
93
94
|
commands: [...item.commands].sort(),
|
|
94
95
|
}))
|
|
95
|
-
.sort((a, b) => a.file
|
|
96
|
+
.sort((a, b) => compareText(a.file, b.file));
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
/** Every declined finding for a manual migration starts with this. */
|
|
@@ -167,7 +168,7 @@ export function summarizeDeclinedCandidates(
|
|
|
167
168
|
.join('; '),
|
|
168
169
|
};
|
|
169
170
|
})
|
|
170
|
-
.sort((a, b) => a.file
|
|
171
|
+
.sort((a, b) => compareText(a.file, b.file));
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
/**
|
|
@@ -383,7 +384,7 @@ function summarizeRegenerate(protectedFiles, outcomes) {
|
|
|
383
384
|
commands: [...item.commands].sort(),
|
|
384
385
|
messages: [...item.messages].sort(),
|
|
385
386
|
}))
|
|
386
|
-
.sort((a, b) => a.file
|
|
387
|
+
.sort((a, b) => compareText(a.file, b.file));
|
|
387
388
|
}
|
|
388
389
|
|
|
389
390
|
/**
|
|
@@ -28,6 +28,7 @@ import * as path from 'node:path';
|
|
|
28
28
|
import {loadModuleWithParser} from '../../foundation/fs/module-loader.mjs';
|
|
29
29
|
import {parseCodemod} from '../../authoring/codemod/parse.mjs';
|
|
30
30
|
import {semverCompare} from '../../foundation/env/semver.mjs';
|
|
31
|
+
import {compareText} from '../../foundation/text/compare-text.mjs';
|
|
31
32
|
|
|
32
33
|
/** File extensions recognized as codemod modules. */
|
|
33
34
|
const CODEMOD_EXTENSIONS = ['.ts', '.mjs', '.js'];
|
|
@@ -100,7 +101,7 @@ function collectCodemodFiles(versionDir) {
|
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
walk(versionDir);
|
|
103
|
-
return out.sort((a, b) => a.id
|
|
104
|
+
return out.sort((a, b) => compareText(a.id, b.id));
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
/**
|
|
@@ -340,7 +340,8 @@ export function runConfigCodemod(
|
|
|
340
340
|
* A codemod as `upgrade` runs it. Core codemods may also declare `mentions`,
|
|
341
341
|
* internal to the CLI and not part of the codemod authoring type: the words a
|
|
342
342
|
* file must say for the transform to change or report it. A file that says
|
|
343
|
-
* none of them, holds
|
|
343
|
+
* none of them and parses is skipped, unless it holds a backslash and its
|
|
344
|
+
* escapes or numeric character references spell one of them.
|
|
344
345
|
* @typedef {import('../../authoring/codemod/type').CodemodEntry['codemod'] & {mentions?: string[]}} CoreCodemod
|
|
345
346
|
*/
|
|
346
347
|
|
|
@@ -352,12 +353,69 @@ export function runConfigCodemod(
|
|
|
352
353
|
*/
|
|
353
354
|
const parsedOnce = new Map();
|
|
354
355
|
|
|
356
|
+
/**
|
|
357
|
+
* What the escapes of a file with a backslash can spell, by file, while its
|
|
358
|
+
* text is the same: each file is decoded once for every codemod that reads it.
|
|
359
|
+
* @type {Map<string, {source: string, spelled: string[]}>}
|
|
360
|
+
*/
|
|
361
|
+
const spelledOnce = new Map();
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* One JavaScript escape: `\u{…}`, `\uXXXX`, `\xXX`, a legacy octal escape, a
|
|
365
|
+
* line continuation, or any other escaped character.
|
|
366
|
+
*/
|
|
367
|
+
const JS_ESCAPE =
|
|
368
|
+
/\\(?:u\{([0-9a-fA-F]+)\}|u([0-9a-fA-F]{4})|x([0-9a-fA-F]{2})|([0-3][0-7]{0,2}|[4-7][0-7]?)|(\r\n|[\n\r\u2028\u2029])|([\s\S]))/g;
|
|
369
|
+
|
|
370
|
+
/** One numeric character reference, which JSX text and attributes decode. */
|
|
371
|
+
const NUMERIC_REFERENCE = /&#(?:[xX]([0-9a-fA-F]+)|([0-9]+));?/g;
|
|
372
|
+
|
|
373
|
+
/** @type {Record<string, string>} */
|
|
374
|
+
const CONTROL_ESCAPES = {b: '\b', f: '\f', n: '\n', r: '\r', t: '\t', v: '\v'};
|
|
375
|
+
|
|
376
|
+
/** @param {number} code */
|
|
377
|
+
const fromCode = code => (code <= 0x10ffff ? String.fromCodePoint(code) : '');
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* The texts that a file's escapes spell: the source with every JavaScript
|
|
381
|
+
* escape decoded (in strings, templates and identifiers, and line
|
|
382
|
+
* continuations), and the source with every numeric character reference
|
|
383
|
+
* decoded (in JSX). A word that the file spells with an escape is in one of
|
|
384
|
+
* them.
|
|
385
|
+
* @param {string} source
|
|
386
|
+
* @param {string} filePath
|
|
387
|
+
* @returns {string[]}
|
|
388
|
+
*/
|
|
389
|
+
function spelledTexts(source, filePath) {
|
|
390
|
+
let known = spelledOnce.get(filePath);
|
|
391
|
+
if (known?.source !== source) {
|
|
392
|
+
const escapes = source.replace(
|
|
393
|
+
JS_ESCAPE,
|
|
394
|
+
(_, brace, u4, x2, octal, lineEnd, other) => {
|
|
395
|
+
if (brace !== undefined) return fromCode(parseInt(brace, 16));
|
|
396
|
+
if (u4 !== undefined) return String.fromCharCode(parseInt(u4, 16));
|
|
397
|
+
if (x2 !== undefined) return String.fromCharCode(parseInt(x2, 16));
|
|
398
|
+
if (octal !== undefined) return String.fromCharCode(parseInt(octal, 8));
|
|
399
|
+
if (lineEnd !== undefined) return '';
|
|
400
|
+
return CONTROL_ESCAPES[other] ?? other;
|
|
401
|
+
},
|
|
402
|
+
);
|
|
403
|
+
const references = source.replace(NUMERIC_REFERENCE, (_, hex, decimal) =>
|
|
404
|
+
fromCode(hex !== undefined ? parseInt(hex, 16) : parseInt(decimal, 10)),
|
|
405
|
+
);
|
|
406
|
+
known = {source, spelled: [escapes, references]};
|
|
407
|
+
spelledOnce.set(filePath, known);
|
|
408
|
+
}
|
|
409
|
+
return known.spelled;
|
|
410
|
+
}
|
|
411
|
+
|
|
355
412
|
/**
|
|
356
413
|
* Whether a codemod cannot change a source file, so its transform need not
|
|
357
414
|
* run (stylesheets always run, whatever they parse as): the
|
|
358
415
|
* codemod declares every word a file must say for it to act (`mentions`), the
|
|
359
|
-
* file says none of them
|
|
360
|
-
* and the file parses, so the
|
|
416
|
+
* file says none of them (a file with a backslash, not even through its
|
|
417
|
+
* escapes or numeric character references), and the file parses, so the
|
|
418
|
+
* transform would neither
|
|
361
419
|
* change it nor report it unparseable. A codemod that declares no words runs
|
|
362
420
|
* on every file.
|
|
363
421
|
* @param {CoreCodemod} codemod
|
|
@@ -371,9 +429,18 @@ function cannotChange(codemod, source, filePath, parser, j) {
|
|
|
371
429
|
const {mentions} = codemod;
|
|
372
430
|
if (!Array.isArray(mentions) || mentions.length === 0) return false;
|
|
373
431
|
if (mentions.some(word => source.includes(word))) return false;
|
|
374
|
-
// An escape (`\u0054ypeahead`, `'base\x2dtable'`, a line continuation)
|
|
375
|
-
//
|
|
376
|
-
|
|
432
|
+
// An escape (`\u0054ypeahead`, `'base\x2dtable'`, a line continuation) can
|
|
433
|
+
// spell a word without its letters. A file with a backslash runs when the
|
|
434
|
+
// text its escapes or numeric character references spell says one of the
|
|
435
|
+
// words.
|
|
436
|
+
if (
|
|
437
|
+
source.includes('\\') &&
|
|
438
|
+
spelledTexts(source, filePath).some(text =>
|
|
439
|
+
mentions.some(word => text.includes(word)),
|
|
440
|
+
)
|
|
441
|
+
) {
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
377
444
|
const key = `${parser}\0${filePath}`;
|
|
378
445
|
let known = parsedOnce.get(key);
|
|
379
446
|
if (known?.source !== source) {
|
|
@@ -420,6 +487,19 @@ export function runCodeCodemod(
|
|
|
420
487
|
const declinedCandidates = [];
|
|
421
488
|
/** @type {Array<{filePath: string, relativePath: string, result: string}>} */
|
|
422
489
|
const candidates = [];
|
|
490
|
+
// One jscodeshift per parser for all the files: binding a parser builds a
|
|
491
|
+
// new copy of jscodeshift's helpers, and the copies are all alike.
|
|
492
|
+
/** @type {Map<string, any>} */
|
|
493
|
+
const bound = new Map();
|
|
494
|
+
/** @param {string} parser */
|
|
495
|
+
const boundTo = parser => {
|
|
496
|
+
let j = bound.get(parser);
|
|
497
|
+
if (j == null) {
|
|
498
|
+
j = jscodeshift.withParser(parser);
|
|
499
|
+
bound.set(parser, j);
|
|
500
|
+
}
|
|
501
|
+
return j;
|
|
502
|
+
};
|
|
423
503
|
|
|
424
504
|
// Transform and validate every candidate before any write. This lets a
|
|
425
505
|
// protection source changed by this entry govern every other staged output.
|
|
@@ -432,7 +512,7 @@ export function runCodeCodemod(
|
|
|
432
512
|
const source =
|
|
433
513
|
contents?.get(filePath) ?? fs.readFileSync(filePath, 'utf-8');
|
|
434
514
|
const parser = ext === '.tsx' || ext === '.ts' ? 'tsx' : 'babel';
|
|
435
|
-
const j =
|
|
515
|
+
const j = boundTo(parser);
|
|
436
516
|
// Only source files: a stylesheet can happen to parse as JavaScript
|
|
437
517
|
// (`a.b` then `{ color: white; }`), yet its transform still changes it.
|
|
438
518
|
if (
|
|
@@ -7,4 +7,14 @@
|
|
|
7
7
|
* this file into the resolved version folder.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
import migrateItemSwipeActionsToSwipe, {
|
|
11
|
+
meta as migrateItemSwipeActionsToSwipeMeta,
|
|
12
|
+
} from './migrate-item-swipe-actions-to-swipe.mjs';
|
|
13
|
+
|
|
14
|
+
export default [
|
|
15
|
+
{
|
|
16
|
+
name: 'migrate-item-swipe-actions-to-swipe',
|
|
17
|
+
transform: migrateItemSwipeActionsToSwipe,
|
|
18
|
+
meta: migrateItemSwipeActionsToSwipeMeta,
|
|
19
|
+
},
|
|
20
|
+
];
|