@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
|
@@ -156,7 +156,11 @@ function sweepTemps(dir) {
|
|
|
156
156
|
}
|
|
157
157
|
continue;
|
|
158
158
|
}
|
|
159
|
-
|
|
159
|
+
// A picture taken under its own name (`.<picture>.part-<pid>.png`) by a
|
|
160
|
+
// run stopped while the browser ran.
|
|
161
|
+
const m =
|
|
162
|
+
/^\..+\.astryx-(\d+)-[a-z0-9]+\.tmp$/.exec(n) ??
|
|
163
|
+
/^\.[\w-]+\.part-(\d+)\.png$/.exec(n);
|
|
160
164
|
if (!m) continue;
|
|
161
165
|
const p = path.join(dir, n);
|
|
162
166
|
try {
|
|
@@ -203,12 +207,14 @@ export function removeEmptyFolder(dir, opts = {}) {
|
|
|
203
207
|
|
|
204
208
|
/**
|
|
205
209
|
* Whether a file name is one of the editor's own temp files: a whole-file
|
|
206
|
-
* write's `.<name>.astryx-<pid>-<random>.tmp`,
|
|
207
|
-
* `.<
|
|
210
|
+
* write's `.<name>.astryx-<pid>-<random>.tmp`, a build's `.<name>.tmp-<id>`,
|
|
211
|
+
* or a picture's `.<picture>.part-<pid>.png`. A command stopped part way can
|
|
212
|
+
* leave one behind.
|
|
208
213
|
* @param {string} name
|
|
209
214
|
*/
|
|
210
215
|
export const isEditorTemp = name =>
|
|
211
|
-
/^\..+\.(astryx-\d+-[a-z0-9]+\.tmp|tmp-[\w-]+)$/.test(name)
|
|
216
|
+
/^\..+\.(astryx-\d+-[a-z0-9]+\.tmp|tmp-[\w-]+)$/.test(name) ||
|
|
217
|
+
/^\.[\w-]+\.part-\d+\.png$/.test(name);
|
|
212
218
|
|
|
213
219
|
/**
|
|
214
220
|
* A temp file beside `file` for a whole write, named so only the editor
|
|
@@ -142,6 +142,10 @@ export type PartRecord = {
|
|
|
142
142
|
tokens: Record<string, string[]>;
|
|
143
143
|
values: string[];
|
|
144
144
|
}>;
|
|
145
|
+
/**
|
|
146
|
+
* - property -> the value under each condition, private variables resolved
|
|
147
|
+
*/
|
|
148
|
+
at?: Record<string, Record<string, string>> | undefined;
|
|
145
149
|
/**
|
|
146
150
|
* - tokens read by unnamed elements inside the part -> properties
|
|
147
151
|
*/
|
|
@@ -154,6 +158,10 @@ export type PartRecord = {
|
|
|
154
158
|
* - parts rendered inside it
|
|
155
159
|
*/
|
|
156
160
|
contains: string[];
|
|
161
|
+
/**
|
|
162
|
+
* - state -> property -> the token Core paints it with as an inline style in that state, which outranks any theme rule
|
|
163
|
+
*/
|
|
164
|
+
inline?: Record<string, Record<string, string>> | undefined;
|
|
157
165
|
};
|
|
158
166
|
export type PaintSide = {
|
|
159
167
|
target: string | null;
|
|
@@ -31,14 +31,16 @@ import {
|
|
|
31
31
|
import {SAMPLE_PAGE, elementNames, pageSource} from './_catalog.mjs';
|
|
32
32
|
|
|
33
33
|
/** Bump when the shape of the cached part data changes. */
|
|
34
|
-
const PART_DATA_VERSION =
|
|
34
|
+
const PART_DATA_VERSION = 6;
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* @typedef {object} PartRecord
|
|
38
38
|
* @property {Record<string, {tokens: Record<string, string[]>, values: string[]}>} own - property -> tokens (with conditions) and raw values
|
|
39
|
+
* @property {Record<string, Record<string, string>>} [at] - property -> the value under each condition, private variables resolved
|
|
39
40
|
* @property {Record<string, string[]>} inside - tokens read by unnamed elements inside the part -> properties
|
|
40
41
|
* @property {Record<string, string[]>} attrs - data attributes seen on the part
|
|
41
42
|
* @property {string[]} contains - parts rendered inside it
|
|
43
|
+
* @property {Record<string, Record<string, string>>} [inline] - state -> property -> the token Core paints it with as an inline style in that state, which outranks any theme rule
|
|
42
44
|
*/
|
|
43
45
|
|
|
44
46
|
/**
|
|
@@ -473,6 +475,79 @@ export async function partData(project) {
|
|
|
473
475
|
return data;
|
|
474
476
|
}
|
|
475
477
|
|
|
478
|
+
/**
|
|
479
|
+
* Add the paint Core writes as an inline style when it sets a theme state
|
|
480
|
+
* at run time (a table row's selection wash, set by the selection plugin
|
|
481
|
+
* beside the row's `selected` state): something the server render never
|
|
482
|
+
* shows. A built module under a component's folder that writes a state's
|
|
483
|
+
* attribute (`themeDataAttributes({selected: 'selected'})`) and an inline
|
|
484
|
+
* property from a color token (`el.style.backgroundColor = …` with
|
|
485
|
+
* `colorVars['--color-accent-muted']`) paints that state with it, on each
|
|
486
|
+
* of the component's targets that lists the state.
|
|
487
|
+
* @param {import('./_project.mjs').ThemeProject} project
|
|
488
|
+
* @param {Record<string, PartRecord>} map
|
|
489
|
+
*/
|
|
490
|
+
function addInlineStatePaint(project, map) {
|
|
491
|
+
const dist = path.join(project.coreDir, 'dist');
|
|
492
|
+
/** @param {string} dir @returns {string[]} */
|
|
493
|
+
const modules = dir => {
|
|
494
|
+
let entries;
|
|
495
|
+
try {
|
|
496
|
+
entries = fs.readdirSync(dir, {withFileTypes: true});
|
|
497
|
+
} catch {
|
|
498
|
+
return [];
|
|
499
|
+
}
|
|
500
|
+
return entries.flatMap(e =>
|
|
501
|
+
e.isDirectory()
|
|
502
|
+
? modules(path.join(dir, e.name))
|
|
503
|
+
: e.name.endsWith('.js')
|
|
504
|
+
? [path.join(dir, e.name)]
|
|
505
|
+
: [],
|
|
506
|
+
);
|
|
507
|
+
};
|
|
508
|
+
for (const [name, info] of Object.entries(project.components)) {
|
|
509
|
+
const folder = info.importPath?.split('/').pop();
|
|
510
|
+
if (!folder || folder !== name) continue;
|
|
511
|
+
const withStates = info.targets.filter(t => t.states.length);
|
|
512
|
+
if (!withStates.length) continue;
|
|
513
|
+
for (const file of modules(path.join(dist, folder))) {
|
|
514
|
+
const source = fs.readFileSync(file, 'utf8');
|
|
515
|
+
const states = [
|
|
516
|
+
...source.matchAll(
|
|
517
|
+
/themeDataAttributes\(\{\s*([\w-]+):\s*'\1'\s*\}\)/g,
|
|
518
|
+
),
|
|
519
|
+
].map(m => m[1]);
|
|
520
|
+
if (!states.length) continue;
|
|
521
|
+
const props = [
|
|
522
|
+
...source.matchAll(/\.style\.([a-z][A-Za-z]*)\s*=(?!=)/g),
|
|
523
|
+
].map(m => m[1].replace(/[A-Z]/g, c => `-${c.toLowerCase()}`));
|
|
524
|
+
const colorTokens = [
|
|
525
|
+
...source.matchAll(/colorVars\[['"](--color-[\w-]+)['"]\]/g),
|
|
526
|
+
].map(m => m[1]);
|
|
527
|
+
if (!props.length || colorTokens.length !== 1) continue;
|
|
528
|
+
for (const t of withStates) {
|
|
529
|
+
const key = t.className.replace(/^astryx-/, '');
|
|
530
|
+
const rec = map[key];
|
|
531
|
+
if (!rec) continue;
|
|
532
|
+
for (const state of states.filter(st => t.states.includes(st)))
|
|
533
|
+
for (const prop of props) {
|
|
534
|
+
(rec.inline ??= {})[state] = {
|
|
535
|
+
...rec.inline?.[state],
|
|
536
|
+
[prop]: colorTokens[0],
|
|
537
|
+
};
|
|
538
|
+
const own = (rec.own[prop] ??= {tokens: {}, values: []});
|
|
539
|
+
own.tokens[colorTokens[0]] = [
|
|
540
|
+
...new Set([
|
|
541
|
+
...(own.tokens[colorTokens[0]] ?? []),
|
|
542
|
+
`${state}=${state}`,
|
|
543
|
+
]),
|
|
544
|
+
];
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
476
551
|
/**
|
|
477
552
|
* Build the part data: render the catalog, then walk its markup.
|
|
478
553
|
* @param {import('./_project.mjs').ThemeProject} project
|
|
@@ -497,6 +572,7 @@ async function buildPartData(project) {
|
|
|
497
572
|
}
|
|
498
573
|
const tokens = new Set(Object.keys(project.core.tokenDefaults ?? {}));
|
|
499
574
|
const result = walkMarkup(markup, declarations(css), tokens);
|
|
575
|
+
addInlineStatePaint(project, result.map);
|
|
500
576
|
return {
|
|
501
577
|
version: PART_DATA_VERSION,
|
|
502
578
|
coreKey: project.coreKey,
|
|
@@ -666,6 +742,24 @@ function expand(v, env, tokens, seen = new Set(), depth = 0) {
|
|
|
666
742
|
return out;
|
|
667
743
|
}
|
|
668
744
|
|
|
745
|
+
/**
|
|
746
|
+
* A value with the private variables set on the element or its ancestors
|
|
747
|
+
* put in (a variable with no fallback only), so it reads public tokens and
|
|
748
|
+
* literal values alone where it can.
|
|
749
|
+
* @param {string} v
|
|
750
|
+
* @param {Record<string, string>} env
|
|
751
|
+
* @param {Set<string>} tokens
|
|
752
|
+
* @param {number} [depth]
|
|
753
|
+
* @returns {string}
|
|
754
|
+
*/
|
|
755
|
+
function resolvePrivate(v, env, tokens, depth = 0) {
|
|
756
|
+
if (depth > 8) return v;
|
|
757
|
+
const out = v.replace(/var\((--[a-zA-Z0-9_-]+)\)/g, (m, name) =>
|
|
758
|
+
!tokens.has(name) && env[name] != null ? env[name] : m,
|
|
759
|
+
);
|
|
760
|
+
return out === v ? v : resolvePrivate(out, env, tokens, depth + 1);
|
|
761
|
+
}
|
|
762
|
+
|
|
669
763
|
/**
|
|
670
764
|
* Walk server-rendered markup: for each element, its classes' declarations
|
|
671
765
|
* become what its part reads; text records the color pair it sits on.
|
|
@@ -675,7 +769,7 @@ function expand(v, env, tokens, seen = new Set(), depth = 0) {
|
|
|
675
769
|
* @returns {{map: Record<string, PartRecord>, pairs: TextPair[]}}
|
|
676
770
|
*/
|
|
677
771
|
export function walkMarkup(html, decls, tokens) {
|
|
678
|
-
/** @type {Record<string, {own: Record<string, {tokens: Record<string, Set<string>>, values: Set<string>}>, inside: Record<string, Set<string>>, attrs: Record<string, Set<string>>, contains: Set<string>}>} */
|
|
772
|
+
/** @type {Record<string, {own: Record<string, {tokens: Record<string, Set<string>>, values: Set<string>}>, at: Record<string, Record<string, string>>, inside: Record<string, Set<string>>, attrs: Record<string, Set<string>>, contains: Set<string>}>} */
|
|
679
773
|
const map = {};
|
|
680
774
|
/** @type {Array<{env: Record<string, string>, target: string | null, fg: PaintSide | null, bg: PaintSide | null}>} */
|
|
681
775
|
const stack = [{env: {}, target: null, fg: null, bg: null}];
|
|
@@ -726,6 +820,7 @@ export function walkMarkup(html, decls, tokens) {
|
|
|
726
820
|
if (target) {
|
|
727
821
|
const T = (map[target] ??= {
|
|
728
822
|
own: {},
|
|
823
|
+
at: {},
|
|
729
824
|
inside: {},
|
|
730
825
|
attrs: {},
|
|
731
826
|
contains: new Set(),
|
|
@@ -742,6 +837,11 @@ export function walkMarkup(html, decls, tokens) {
|
|
|
742
837
|
const cond = [cond0, d.cond].filter(Boolean).join(' ');
|
|
743
838
|
if (ownsTarget) {
|
|
744
839
|
const P = (T.own[d.prop] ??= {tokens: {}, values: new Set()});
|
|
840
|
+
(T.at[d.prop] ??= {})[cond || 'always'] ??= resolvePrivate(
|
|
841
|
+
d.value,
|
|
842
|
+
env,
|
|
843
|
+
tokens,
|
|
844
|
+
);
|
|
745
845
|
P.values.add(
|
|
746
846
|
d.value.length > 80 ? `${d.value.slice(0, 80)}...` : d.value,
|
|
747
847
|
);
|
|
@@ -792,6 +892,7 @@ export function walkMarkup(html, decls, tokens) {
|
|
|
792
892
|
},
|
|
793
893
|
]),
|
|
794
894
|
),
|
|
895
|
+
at: v.at,
|
|
795
896
|
inside: Object.fromEntries(
|
|
796
897
|
Object.entries(v.inside).map(([k, s]) => [k, [...s]]),
|
|
797
898
|
),
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file One picture of a page through the project's Playwright, run as its
|
|
5
|
+
* own process by the editor's browser runner.
|
|
6
|
+
* @input argv: the Playwright entry file, the page (.html), the picture
|
|
7
|
+
* (.png), the color mode, and a browser to use instead of Playwright's own
|
|
8
|
+
* @output the picture at the path given; on failure, Playwright's error on
|
|
9
|
+
* stderr and exit code 1
|
|
10
|
+
* @position run by `screenshot` in _preview.mjs through `runBrowser`, which
|
|
11
|
+
* gives it a temp folder of its own, its time bound and its stop
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {pathToFileURL} from 'node:url';
|
|
15
|
+
|
|
16
|
+
const [entry, html, png, mode, executablePath] = process.argv.slice(2);
|
|
17
|
+
try {
|
|
18
|
+
const pw = await import(pathToFileURL(entry).href);
|
|
19
|
+
const chromium = pw.chromium ?? pw.default?.chromium;
|
|
20
|
+
const browser = await chromium.launch(executablePath ? {executablePath} : {});
|
|
21
|
+
try {
|
|
22
|
+
const page = await browser.newPage({
|
|
23
|
+
viewport: {width: 1280, height: 900},
|
|
24
|
+
colorScheme: mode === 'dark' ? 'dark' : 'light',
|
|
25
|
+
});
|
|
26
|
+
await page.goto(pathToFileURL(html).href, {waitUntil: 'load'});
|
|
27
|
+
await page.screenshot({path: png, fullPage: true});
|
|
28
|
+
} finally {
|
|
29
|
+
await browser.close();
|
|
30
|
+
}
|
|
31
|
+
} catch (e) {
|
|
32
|
+
process.stderr.write(`${e instanceof Error ? e.message : String(e)}\n`);
|
|
33
|
+
process.exitCode = 1;
|
|
34
|
+
}
|
|
@@ -68,12 +68,18 @@ export function refreshPreviewRoute(cwd: string, slug: string): Promise<{
|
|
|
68
68
|
* @param {'colors' | 'components' | 'overview'} focus
|
|
69
69
|
* @param {{code: string, cause: string} | null} [notChecked] why the change
|
|
70
70
|
* could not be rendered
|
|
71
|
+
* @param {{pictureProblem?: string | null, stale?: string[]}} [extra] this
|
|
72
|
+
* result's picture problem (what kept --png from taking pictures) and its
|
|
73
|
+
* previewStale entries (an in-app preview changed by hand)
|
|
71
74
|
* @returns {string}
|
|
72
75
|
*/
|
|
73
76
|
export function seeLine(cwd: string, slug: string, focus: "colors" | "components" | "overview", notChecked?: {
|
|
74
77
|
code: string;
|
|
75
78
|
cause: string;
|
|
76
|
-
} | null
|
|
79
|
+
} | null, extra?: {
|
|
80
|
+
pictureProblem?: string | null;
|
|
81
|
+
stale?: string[];
|
|
82
|
+
}): string;
|
|
77
83
|
/**
|
|
78
84
|
* Add pages to the in-app theme preview, and write the preview route the
|
|
79
85
|
* first time. With a description, the build ranking picks the template
|