@astryxdesign/cli 0.7.17-canary.g5a3fd39 → 0.7.17-canary.g5cf5d69
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 +64 -63
- package/api/build/_adapter.d.mts +51 -0
- package/api/build/_adapter.mjs +122 -6
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.mjs +23 -14
- package/api/build/build.type.d.mts +1 -1
- package/api/build/build.type.mjs +3 -3
- package/api/build/help/help.d.mts +15 -14
- package/api/build/help/help.mjs +62 -3
- package/api/build/kit/answer.mjs +2 -3
- package/api/build/kit/signals.d.mts +10 -0
- package/api/build/kit/signals.mjs +15 -2
- package/api/component/detail/blocks/blocks.mjs +2 -1
- package/api/discover/_adapter.d.mts +57 -6
- package/api/discover/_adapter.mjs +278 -49
- package/api/discover/_catalog-view.d.mts +7 -0
- package/api/discover/_catalog-view.mjs +10 -1
- package/api/discover/detail/detail.d.mts +3 -2
- package/api/discover/detail/detail.mjs +3 -2
- package/api/discover/detail/doc/doc.mjs +1 -1
- package/api/discover/discover.d.mts +24 -0
- package/api/discover/discover.doc.mjs +1 -1
- package/api/discover/discover.mjs +146 -25
- package/api/discover/discover.type.d.mts +6 -4
- package/api/discover/discover.type.mjs +6 -4
- package/api/discover/search/search.d.mts +22 -0
- package/api/discover/search/search.mjs +290 -70
- package/api/docs/_entry-names.mjs +4 -3
- package/api/doctor/_adapter.d.mts +43 -3
- package/api/doctor/_adapter.mjs +142 -18
- package/api/doctor/built-checks.d.mts +30 -3
- package/api/doctor/built-checks.mjs +132 -5
- package/api/doctor/doctor.d.mts +93 -6
- package/api/doctor/doctor.doc.mjs +2 -2
- package/api/doctor/doctor.mjs +524 -33
- package/api/doctor/doctor.type.d.mts +2 -1
- package/api/doctor/doctor.type.mjs +2 -1
- package/api/doctor/theme-checks.d.mts +19 -0
- package/api/doctor/theme-checks.mjs +74 -6
- package/api/hook/hook.type.d.mts +1 -1
- package/api/hook/hook.type.mjs +1 -1
- package/api/hook/list/list.mjs +11 -7
- package/api/icon/_adapter.d.mts +2 -1
- package/api/icon/_adapter.mjs +10 -15
- package/api/icon/_records.d.mts +3 -1
- package/api/icon/_records.mjs +30 -3
- package/api/icon/exportIconIndex.doc.mjs +1 -1
- package/api/icon/icon.doc.mjs +3 -3
- package/api/icon/icon.type.d.mts +32 -1
- package/api/icon/icon.type.mjs +19 -3
- package/api/icon/list/list.mjs +4 -1
- package/api/icon/rankIconIndex.doc.mjs +1 -1
- package/api/icon/search/icon-index.mjs +18 -8
- package/api/icon/search/search.d.mts +26 -3
- package/api/icon/search/search.mjs +155 -9
- package/api/init/_adapter.d.mts +14 -0
- package/api/init/_adapter.mjs +26 -4
- package/api/init/init.d.mts +1 -1
- package/api/init/init.doc.mjs +2 -2
- package/api/init/init.mjs +1 -1
- package/api/init/init.type.d.mts +29 -1
- package/api/init/init.type.mjs +14 -1
- package/api/init/run/run.d.mts +11 -1
- package/api/init/run/run.mjs +84 -5
- package/api/integration/_adapter.d.mts +5 -4
- package/api/integration/_adapter.mjs +7 -5
- package/api/integration/integrationCheck.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +8 -9
- package/api/integration/validate-integration.d.mts +1 -1
- package/api/integration/validate-integration.mjs +26 -24
- package/api/integration/validate-integration.type.d.mts +5 -2
- package/api/integration/validate-integration.type.mjs +5 -2
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/_adapter.d.mts +4 -2
- package/api/render/_adapter.mjs +62 -21
- package/api/render/render.doc.mjs +8 -5
- package/api/render/render.mjs +1 -1
- package/api/render/render.type.d.mts +2 -0
- package/api/render/render.type.mjs +2 -0
- package/api/search/ORDERING.md +2 -2
- package/api/search/_candidate-score.d.mts +3 -0
- package/api/search/_candidate-score.mjs +36 -3
- package/api/search/_gather-docs.mjs +29 -2
- package/api/search/_gather-templates.mjs +2 -1
- package/api/search/_main-searcher.mjs +13 -0
- package/api/search/_named-keywords.d.mts +2 -1
- package/api/search/_named-keywords.mjs +48 -6
- package/api/search/_order.d.mts +36 -1
- package/api/search/_order.mjs +141 -3
- package/api/swizzle/list/list.mjs +8 -1
- package/api/swizzle/swizzle.type.d.mts +1 -1
- package/api/swizzle/swizzle.type.mjs +1 -1
- package/api/template/copy/copy.mjs +3 -4
- package/api/template/list/list.mjs +2 -1
- package/api/template/show/show.mjs +2 -1
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.mjs +19 -1
- package/api/template/template.type.d.mts +1 -0
- package/api/template/template.type.mjs +2 -1
- package/api/theme/_adapter.d.mts +1 -0
- package/api/theme/_adapter.mjs +3 -5
- package/api/theme/_app-provider.d.mts +42 -0
- package/api/theme/_app-provider.mjs +61 -27
- package/api/theme/build/build.d.mts +4 -10
- package/api/theme/build/build.mjs +165 -116
- package/api/theme/build/input-fields.d.mts +9 -0
- package/api/theme/build/input-fields.mjs +155 -16
- package/api/theme/build/radius-values.d.mts +18 -0
- package/api/theme/build/radius-values.mjs +76 -0
- package/api/theme/build/typography-values.mjs +7 -23
- package/api/theme/build/written-values.d.mts +18 -0
- package/api/theme/build/written-values.mjs +107 -31
- package/api/theme/eject/eject.mjs +6 -1
- package/api/theme/palette/generate/generator.mjs +24 -0
- package/api/theme/theme.type.d.mts +4 -2
- package/api/theme/theme.type.mjs +3 -2
- package/api/theme/themeBuild.doc.mjs +2 -2
- package/api/theme/themeEject.doc.mjs +1 -1
- package/api/theme-edit/_catalog.d.mts +40 -0
- package/api/theme-edit/_catalog.mjs +100 -22
- package/api/theme-edit/_check.mjs +213 -43
- package/api/theme-edit/_color.d.mts +14 -0
- package/api/theme-edit/_color.mjs +22 -0
- package/api/theme-edit/_compiler.mjs +52 -0
- package/api/theme-edit/_context.d.mts +20 -2
- package/api/theme-edit/_context.mjs +157 -29
- package/api/theme-edit/_edit.mjs +426 -58
- package/api/theme-edit/_how-question.d.mts +14 -0
- package/api/theme-edit/_how-question.mjs +1541 -127
- package/api/theme-edit/_how.mjs +43 -0
- package/api/theme-edit/_missed.mjs +107 -27
- package/api/theme-edit/_normal.d.mts +18 -4
- package/api/theme-edit/_normal.mjs +84 -3
- package/api/theme-edit/_palette.d.mts +9 -0
- package/api/theme-edit/_palette.mjs +158 -33
- package/api/theme-edit/_part-words.mjs +16 -3
- package/api/theme-edit/_parts.d.mts +8 -0
- package/api/theme-edit/_parts.mjs +120 -36
- package/api/theme-edit/_png.d.mts +24 -0
- package/api/theme-edit/_png.mjs +99 -0
- package/api/theme-edit/_preview-app.d.mts +16 -0
- package/api/theme-edit/_preview-app.mjs +52 -18
- package/api/theme-edit/_preview.d.mts +44 -26
- package/api/theme-edit/_preview.mjs +255 -67
- package/api/theme-edit/_project.d.mts +12 -1
- package/api/theme-edit/_project.mjs +16 -1
- package/api/theme-edit/_settings.d.mts +116 -0
- package/api/theme-edit/_settings.mjs +1197 -58
- package/api/theme-edit/_tables.d.mts +16 -0
- package/api/theme-edit/_tables.mjs +34 -4
- package/api/theme-edit/theme-edit.type.d.mts +15 -2
- package/api/theme-edit/theme-edit.type.mjs +8 -6
- package/api/upgrade/_adapter.d.mts +46 -7
- package/api/upgrade/_adapter.mjs +110 -15
- package/api/upgrade/registry/registry.d.mts +6 -3
- package/api/upgrade/registry/registry.mjs +21 -6
- package/api/upgrade/run/run.mjs +23 -11
- package/api/upgrade/upgrade.doc.mjs +4 -3
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/tree/agent-guidance.doc.mjs +3 -2
- package/assets/docs/tree/checks.doc.mjs +2 -2
- package/assets/docs/tree/host-entry.doc.mjs +4 -0
- package/assets/docs/tree/icon-definitions.doc.mjs +3 -3
- package/assets/docs/tree/icon-sets.doc.mjs +6 -6
- package/assets/docs/tree/problems.doc.mjs +3 -3
- package/assets/docs/tree/render-pages.doc.mjs +17 -3
- package/assets/docs/tree/share-a-page.doc.mjs +5 -5
- package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
- package/assets/docs/tree/troubleshooting.doc.mjs +8 -0
- package/assets/docs/tree/updates.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +40 -5
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/icons/installed-icon-set.doc.mjs +30 -0
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Avatar/AvatarInteractive.tsx +6 -1
- package/assets/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +1 -1
- package/assets/templates/blocks/components/LinkProvider/LinkProviderCustomLink.tsx +3 -1
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/page.tsx +6 -2
- package/assets/templates/pages/ai-chat-landing/page.tsx +1 -1
- package/assets/templates/pages/blank/page.tsx +4 -2
- package/assets/templates/pages/canvas-editor/page.tsx +3 -1
- package/assets/templates/pages/centered-hero/page.tsx +1 -1
- package/assets/templates/pages/checkout-wizard/page.tsx +1 -1
- package/assets/templates/pages/classic-gallery/page.tsx +1 -1
- package/assets/templates/pages/contact-form/page.tsx +2 -2
- package/assets/templates/pages/course-detail/page.tsx +1 -1
- package/assets/templates/pages/dashboard/page.tsx +24 -8
- package/assets/templates/pages/dashboard-alert-rail/page.tsx +4 -2
- package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +7 -3
- package/assets/templates/pages/dashboard-comparison/page.tsx +5 -2
- package/assets/templates/pages/dashboard-composition/page.tsx +10 -4
- package/assets/templates/pages/dashboard-progress/page.tsx +6 -3
- package/assets/templates/pages/dashboard-scorecard/page.tsx +17 -8
- package/assets/templates/pages/detail-page/page.tsx +22 -5
- package/assets/templates/pages/documentation/page.tsx +4 -2
- package/assets/templates/pages/documentation-design/page.tsx +5 -2
- package/assets/templates/pages/documentation-technical/page.tsx +4 -2
- package/assets/templates/pages/editor/page.tsx +28 -9
- package/assets/templates/pages/file-explorer/page.tsx +3 -1
- package/assets/templates/pages/form-two-column/page.tsx +1 -1
- package/assets/templates/pages/form-wizard/page.tsx +1 -1
- package/assets/templates/pages/form-wizard-dialog/page.tsx +3 -1
- package/assets/templates/pages/form-wizard-inline/page.tsx +1 -1
- package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
- package/assets/templates/pages/gallery-hero/page.tsx +1 -1
- package/assets/templates/pages/ide/page.tsx +7 -2
- package/assets/templates/pages/kanban-board/page.tsx +10 -4
- package/assets/templates/pages/library/page.tsx +31 -61
- package/assets/templates/pages/login/page.tsx +4 -2
- package/assets/templates/pages/login-card/page.tsx +4 -2
- package/assets/templates/pages/login-split/page.tsx +3 -2
- package/assets/templates/pages/login-sso/page.tsx +4 -4
- package/assets/templates/pages/mixed-gallery/page.tsx +1 -1
- package/assets/templates/pages/payment-form/page.tsx +1 -1
- package/assets/templates/pages/product-detail/page.tsx +16 -4
- package/assets/templates/pages/product-gallery/page.tsx +1 -1
- package/assets/templates/pages/settings/page.tsx +10 -4
- package/assets/templates/pages/settings-dialog/page.tsx +5 -6
- package/assets/templates/pages/settings-sidebar/page.tsx +39 -13
- package/assets/templates/pages/side-gallery/page.tsx +1 -1
- package/assets/templates/pages/table/page.tsx +2 -2
- package/assets/templates/pages/table-filter/page.tsx +21 -6
- package/assets/templates/pages/table-grouped/page.tsx +23 -2
- package/assets/templates/pages/table-inbox/page.tsx +82 -32
- package/assets/templates/pages/theme-showcase/page.tsx +3 -2
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +12 -12
- package/assets/templates/themes/butter/butterTheme.ts +197 -4
- package/assets/templates/themes/chocolate/chocolateTheme.ts +72 -8
- package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +3 -3
- package/assets/templates/themes/gothic/gothicTheme.ts +114 -4
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +8 -8
- package/assets/templates/themes/matcha/matchaTheme.ts +48 -12
- package/assets/templates/themes/neutral/neutralTheme.ts +29 -0
- package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +2 -2
- package/assets/templates/themes/stone/stoneTheme.ts +69 -0
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +9 -9
- package/assets/templates/themes/y2k/y2kTheme.ts +249 -14
- package/authoring/codemod/parse.d.mts +0 -36
- package/authoring/codemod/parse.mjs +62 -41
- package/authoring/config/config.doc.mjs +1 -1
- package/authoring/config/parse.d.mts +0 -47
- package/authoring/config/parse.mjs +128 -103
- package/authoring/config/type.ts +4 -3
- package/authoring/debug/parse.d.mts +2 -2
- package/authoring/discover/parse.d.mts +2 -2
- package/authoring/discover/parse.mjs +52 -38
- package/authoring/discover/type.ts +2 -1
- package/authoring/doctypes/_schema.d.mts +834 -950
- package/authoring/doctypes/_schema.mjs +863 -825
- package/authoring/doctypes/command/parse.mjs +2 -2
- package/authoring/doctypes/component/parse.mjs +2 -2
- package/authoring/doctypes/enum/parse.mjs +2 -2
- package/authoring/doctypes/hook/parse.mjs +2 -2
- package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +1 -1
- package/authoring/doctypes/icon-definition/parse.d.mts +0 -24
- package/authoring/doctypes/icon-definition/parse.mjs +59 -43
- package/authoring/doctypes/icon-set/parse.d.mts +0 -75
- package/authoring/doctypes/icon-set/parse.mjs +239 -210
- package/authoring/doctypes/legacy.mjs +3 -3
- package/authoring/doctypes/namespace/parse.mjs +2 -2
- package/authoring/doctypes/reference/parse.mjs +2 -2
- package/authoring/doctypes/schema/parse.mjs +2 -2
- package/authoring/doctypes/template/parse.d.mts +0 -101
- package/authoring/doctypes/template/parse.mjs +131 -106
- package/authoring/doctypes/theme/parse.d.mts +0 -23
- package/authoring/doctypes/theme/parse.mjs +52 -36
- package/authoring/gap-report/parse.d.mts +1 -1
- package/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +14 -3
- package/authoring/integration/schema.mjs +20 -2
- package/authoring/integration/type.ts +14 -0
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/build.mjs +27 -13
- package/clients/cli/commands/component.mjs +14 -3
- package/clients/cli/commands/discover.doc.mjs +2 -2
- package/clients/cli/commands/discover.mjs +20 -3
- package/clients/cli/commands/docs.doc.mjs +11 -9
- package/clients/cli/commands/docs.mjs +50 -21
- package/clients/cli/commands/experimental/icon.mjs +330 -227
- package/clients/cli/commands/experimental/render.mjs +16 -1
- package/clients/cli/commands/experimental/theme.mjs +42 -17
- package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-map.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-use.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
- package/clients/cli/commands/experimental-render.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
- 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 +1 -1
- package/clients/cli/commands/init.doc.mjs +36 -24
- package/clients/cli/commands/integration-check.doc.mjs +1 -1
- package/clients/cli/commands/mcp.doc.mjs +53 -0
- package/clients/cli/commands/mcp.mjs +51 -0
- package/clients/cli/commands/search.mjs +46 -9
- package/clients/cli/commands/template.mjs +3 -2
- package/clients/cli/commands/theme-build.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +12 -2
- package/clients/cli/commands/upgrade.doc.mjs +3 -2
- package/clients/cli/commands.generated.json +1 -1
- package/clients/cli/formatters/index.mjs +52 -6
- package/clients/cli/index.mjs +23 -17
- package/clients/cli/lib/base-gate.mjs +37 -5
- package/clients/cli/lib/define-command.mjs +82 -4
- package/clients/cli/lib/json-shim.mjs +61 -4
- package/clients/cli/lib/manifest.mjs +9 -1
- package/clients/cli/lib/mcp-server.mjs +286 -0
- package/clients/cli/lib/mcp-tools.mjs +405 -0
- package/clients/cli/lib/other-cli-words.mjs +99 -0
- package/clients/cli/lib/stray-option.mjs +27 -1
- package/clients/cli/lib/unknown-command.mjs +326 -11
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +1 -1
- package/foundation/agent-docs/agent-docs.d.mts +49 -1
- package/foundation/agent-docs/agent-docs.mjs +108 -7
- package/foundation/agent-docs/computer-agent-text.mjs +1 -1
- package/foundation/bases/core.d.mts +1 -1
- package/foundation/bases/core.mjs +3 -3
- package/foundation/bases/resolve.d.mts +4 -8
- package/foundation/bases/resolve.mjs +15 -21
- package/foundation/bases/state.d.mts +15 -9
- package/foundation/bases/state.mjs +33 -6
- package/foundation/config/project.d.mts +5 -4
- package/foundation/config/project.mjs +33 -17
- package/foundation/discovery/component-discovery.mjs +15 -28
- package/foundation/discovery/icon-imports.d.mts +66 -0
- package/foundation/discovery/icon-imports.mjs +225 -0
- package/foundation/discovery/icon-ranking.d.mts +12 -2
- package/foundation/discovery/icon-ranking.mjs +197 -10
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.d.mts +28 -0
- package/foundation/discovery/icon-set-discovery.mjs +42 -0
- package/foundation/discovery/icon-set-writer.d.mts +2 -11
- package/foundation/discovery/icon-set-writer.mjs +3 -29
- package/foundation/discovery/module-exports.d.mts +1 -1
- package/foundation/discovery/module-exports.mjs +136 -33
- package/foundation/discovery/name-roots.d.mts +5 -0
- package/foundation/discovery/name-roots.mjs +11 -0
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/runner-commands.mjs +1 -0
- package/foundation/discovery/template-adapter.d.mts +1 -1
- package/foundation/discovery/template-destination.d.mts +14 -6
- package/foundation/discovery/template-destination.mjs +42 -8
- package/foundation/discovery/template-icons.d.mts +45 -2
- package/foundation/discovery/template-icons.mjs +26 -54
- package/foundation/discovery/template-needs.d.mts +28 -2
- package/foundation/discovery/template-needs.mjs +92 -11
- package/foundation/discovery/theme-discovery.d.mts +8 -0
- package/foundation/discovery/theme-discovery.mjs +23 -6
- package/foundation/discovery/theme-imports.mjs +2 -4
- package/foundation/doc-compiler/parse-readable.mjs +4 -3
- package/foundation/doc-compiler/stored-docs.d.mts +13 -0
- package/foundation/doc-compiler/stored-docs.mjs +74 -3
- package/foundation/env/cli-command.d.mts +68 -10
- package/foundation/env/cli-command.mjs +116 -22
- package/foundation/env/project-scope.d.mts +9 -0
- package/foundation/env/project-scope.mjs +28 -2
- package/foundation/fs/gather-cache.d.mts +23 -0
- package/foundation/fs/gather-cache.mjs +94 -2
- package/foundation/fs/module-loader.d.mts +3 -1
- package/foundation/fs/module-loader.mjs +85 -5
- package/foundation/fs/read-record.mjs +9 -5
- package/foundation/identity/package-names.d.mts +18 -0
- package/foundation/identity/package-names.mjs +19 -0
- package/foundation/identity/providers.mjs +3 -2
- package/foundation/integrations/icon-features.d.mts +63 -0
- package/foundation/integrations/icon-features.mjs +54 -0
- package/foundation/integrations/integrations.d.mts +13 -1
- package/foundation/integrations/integrations.mjs +47 -6
- package/foundation/integrations/pack-state.d.mts +21 -0
- package/foundation/integrations/pack-state.mjs +42 -19
- package/foundation/integrations/validate-contributions.d.mts +11 -3
- package/foundation/integrations/validate-contributions.mjs +51 -13
- package/foundation/release/cache.d.mts +13 -1
- package/foundation/release/cache.mjs +94 -14
- package/foundation/release/notices.d.mts +15 -0
- package/foundation/release/notices.mjs +111 -7
- package/foundation/release/project.d.mts +3 -4
- package/foundation/release/project.mjs +5 -6
- package/foundation/render/client-bundle.d.mts +126 -0
- package/foundation/render/client-bundle.mjs +565 -0
- package/foundation/render/cut-short.d.mts +7 -1
- package/foundation/render/cut-short.mjs +46 -6
- package/foundation/render/embedded-imports.d.mts +4 -3
- package/foundation/render/embedded-imports.mjs +13 -8
- package/foundation/render/esbuild-dependency.d.mts +14 -0
- package/foundation/render/esbuild-dependency.mjs +41 -0
- package/foundation/render/file-header.mjs +5 -4
- package/foundation/render/page-worker.mjs +562 -86
- package/foundation/render/picture-chrome.mjs +54 -29
- package/foundation/render/picture-playwright.mjs +78 -42
- package/foundation/render/picture-window.d.mts +33 -0
- package/foundation/render/picture-window.mjs +78 -0
- package/foundation/render/render-page.d.mts +55 -4
- package/foundation/render/render-page.mjs +199 -28
- package/foundation/render/restore-folder.d.mts +13 -0
- package/foundation/render/restore-folder.mjs +30 -0
- package/foundation/render/served-packages.d.mts +2 -1
- package/foundation/render/served-packages.mjs +5 -3
- package/foundation/render/ts-paths.d.mts +11 -0
- package/foundation/render/ts-paths.mjs +27 -2
- package/foundation/render/value-uses.d.mts +43 -0
- package/foundation/render/value-uses.mjs +110 -0
- package/foundation/response/error-codes.d.mts +2 -1
- package/foundation/response/error-codes.doc.mjs +7 -1
- package/foundation/response/error-codes.mjs +10 -2
- package/foundation/response/response-types.doc.mjs +12 -12
- package/foundation/runtime/package-root.d.mts +8 -0
- package/foundation/runtime/package-root.mjs +20 -0
- package/foundation/suggest/other-command.d.mts +11 -0
- package/foundation/suggest/other-command.mjs +1 -1
- package/foundation/text/icon-id.d.mts +20 -0
- package/foundation/text/icon-id.mjs +40 -0
- package/foundation/text/icon-set-next.d.mts +25 -0
- package/foundation/text/icon-set-next.mjs +29 -0
- package/foundation/xle/browser.d.mts +2 -2
- package/package.json +7 -6
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
* images become data: URIs; and the page's source rides along so
|
|
9
9
|
* `--reverse` can give it back exactly.
|
|
10
10
|
*
|
|
11
|
-
* The file needs no network and
|
|
12
|
-
*
|
|
11
|
+
* The file needs no network, and it carries the page's script, which draws
|
|
12
|
+
* the live page over the markup, so it works inside a sandboxed frame that
|
|
13
|
+
* allows scripts under a strict content security policy. Its colors follow
|
|
13
14
|
* `color-scheme` (and a `data-theme` of `light` or `dark` on the root), since
|
|
14
15
|
* Astryx tokens use light-dark().
|
|
15
16
|
*
|
|
@@ -32,6 +33,8 @@ import {
|
|
|
32
33
|
} from './assets.mjs';
|
|
33
34
|
import {classesIn, cutCss, layerOrderOf} from './css-cut.mjs';
|
|
34
35
|
import {asParsed, formatFor, sha256, sourceBlock} from './source-block.mjs';
|
|
36
|
+
import {LINK_OUT, ROOT_ID} from './client-bundle.mjs';
|
|
37
|
+
import {ESBUILD_MISSING, findEsbuild} from './esbuild-dependency.mjs';
|
|
35
38
|
import {embeddedPathProblem} from './embedded-files.mjs';
|
|
36
39
|
import {scanHtml} from './html-reader.mjs';
|
|
37
40
|
import {removeOnStop} from '../fs/stop-cleanup.mjs';
|
|
@@ -65,6 +68,8 @@ export {MODULE_EXTENSIONS, PAGE_EXTENSIONS} from './embedded-files.mjs';
|
|
|
65
68
|
* @property {number} images - Local files inlined as data: URIs.
|
|
66
69
|
* @property {RenderWarning[]} warnings
|
|
67
70
|
* @property {{name: string, dir: string}[]} fromSet - Packages that came from the package set the CLI runs from, not the page's folder.
|
|
71
|
+
* @property {number} [scriptBytes] - Bytes of the page's script; none in a markup-only render.
|
|
72
|
+
* @property {number} [scriptModules] - The modules the page's script holds; none in a markup-only render.
|
|
68
73
|
*/
|
|
69
74
|
|
|
70
75
|
/** An error carrying a render error code. */
|
|
@@ -670,7 +675,7 @@ export function awaitHost(host, {timeoutMs, withoutSegmenter, stateFile}) {
|
|
|
670
675
|
/**
|
|
671
676
|
* Run the page. When this Node crashes in Intl.Segmenter, run it once more
|
|
672
677
|
* without Intl.Segmenter and say so in a warning.
|
|
673
|
-
* @param {{entry: string, root: string, scope: string, served: ServedSet | null, openLayers?: boolean}} input
|
|
678
|
+
* @param {{entry: string, root: string, scope: string, served: ServedSet | null, openLayers?: boolean, buildScript?: boolean, esbuild?: string}} input
|
|
674
679
|
* @param {number} timeoutMs
|
|
675
680
|
* @param {RenderWarning[]} warnings
|
|
676
681
|
*/
|
|
@@ -690,6 +695,75 @@ async function runPage(input, timeoutMs, warnings) {
|
|
|
690
695
|
return again;
|
|
691
696
|
}
|
|
692
697
|
|
|
698
|
+
/**
|
|
699
|
+
* The markup with each link out of the file opening in a new tab, as the
|
|
700
|
+
* file's script opens it once it runs (client-bundle.mjs): a viewer's frame
|
|
701
|
+
* cannot follow a link out. A link that names its own target keeps it.
|
|
702
|
+
* @param {string} markup the page's server markup
|
|
703
|
+
* @returns {string}
|
|
704
|
+
*/
|
|
705
|
+
export function linksOpenNewTabs(markup) {
|
|
706
|
+
return markup.replace(/<a\b([^>]*)>/g, (tag, /** @type {string} */ attrs) => {
|
|
707
|
+
const href = /\shref="([^"]*)"/.exec(attrs)?.[1];
|
|
708
|
+
if (href === undefined || /\starget="/.test(attrs) || !LINK_OUT.test(href.trim())) return tag;
|
|
709
|
+
const rel = /\srel="([^"]*)"/.exec(attrs);
|
|
710
|
+
const rels = new Set([...(rel ? rel[1].split(/\s+/).filter(Boolean) : []), 'noopener', 'noreferrer']);
|
|
711
|
+
return `<a${rel ? attrs.replace(rel[0], '') : attrs} target="_blank" rel="${[...rels].join(' ')}">`;
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* The page's script with each string the markup's rewrite replaced (an
|
|
717
|
+
* image's `src`, `poster` or `srcset`, as the page wrote it) written as the
|
|
718
|
+
* same carried data, so the page the script draws shows what the first paint
|
|
719
|
+
* showed. Only a quoted string that is exactly that value changes, never a
|
|
720
|
+
* longer string that holds it.
|
|
721
|
+
* @param {string} script
|
|
722
|
+
* @param {Map<string, string>} rewrites
|
|
723
|
+
* @returns {string}
|
|
724
|
+
*/
|
|
725
|
+
export function withCarriedPaths(script, rewrites) {
|
|
726
|
+
let out = script;
|
|
727
|
+
for (const [was, now] of rewrites) {
|
|
728
|
+
if (/["'`\\\n<]/.test(now) || /["'`\\\n]/.test(was)) continue;
|
|
729
|
+
for (const quote of ['"', "'", '`']) {
|
|
730
|
+
const literal = `${quote}${was}${quote}`;
|
|
731
|
+
// Text the page shows (`children: "./photo.png"`) stays as written.
|
|
732
|
+
out = out
|
|
733
|
+
.split(literal)
|
|
734
|
+
.map((part, i, parts) =>
|
|
735
|
+
i === parts.length - 1 ? part : /\bchildren:\s*$/.test(part) ? `${part}${literal}` : `${part}${quote}${now}${quote}`,
|
|
736
|
+
)
|
|
737
|
+
.join('');
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
return out;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* A call of the script's `carried(sha256, prefix)`, which reads an image from
|
|
745
|
+
* the embedded source. It starts only where a name starts, so a long run of
|
|
746
|
+
* name characters (a large string in the page) is read once, not once per
|
|
747
|
+
* character.
|
|
748
|
+
*/
|
|
749
|
+
const CARRIED_CALL = /(?<![\w$])[A-Za-z_$][\w$]*\((["'])([0-9a-f]{64})\1,\s*(["'])(data:[^"']*;base64)\3\)/g;
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* The script with each image the embedded source does not carry written in
|
|
753
|
+
* as its data: URI (`uriOf` gives it), so the image still shows once the
|
|
754
|
+
* script draws the page.
|
|
755
|
+
* @param {string} script
|
|
756
|
+
* @param {Set<string>} carried the SHA-256 of each file the source carries
|
|
757
|
+
* @param {(sha256: string, prefix: string) => string | null} uriOf
|
|
758
|
+
*/
|
|
759
|
+
export function withUncarriedImages(script, carried, uriOf) {
|
|
760
|
+
return script.replace(CARRIED_CALL, (call, _q, sha, _p, prefix) => {
|
|
761
|
+
if (carried.has(sha)) return call;
|
|
762
|
+
const uri = uriOf(sha, prefix);
|
|
763
|
+
return uri === null ? call : JSON.stringify(uri);
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
|
|
693
767
|
/**
|
|
694
768
|
* The warning for a page rendered without Intl.Segmenter.
|
|
695
769
|
* @returns {RenderWarning}
|
|
@@ -773,7 +847,11 @@ export function assetRef(ref, at) {
|
|
|
773
847
|
* link (`href`) loads nothing, so it is left alone.
|
|
774
848
|
* @param {string} text markup or CSS
|
|
775
849
|
* @param {'html' | 'css'} kind
|
|
776
|
-
* @param {{dir: string, root: string, warnings: RenderWarning[], counted: Set<string>, localAssets: Set<string>}} ctx
|
|
850
|
+
* @param {{dir: string, root: string, warnings: RenderWarning[], counted: Set<string>, localAssets: Set<string>, leaveLargeStyleAssets?: boolean, rewrites?: Map<string, string>}} ctx
|
|
851
|
+
* `leaveLargeStyleAssets`: a stylesheet's file too large to inline is left
|
|
852
|
+
* as it is and named, as a missing one is, rather than refused;
|
|
853
|
+
* `rewrites`: each attribute value the markup's rewrite replaced, as the
|
|
854
|
+
* page wrote it, with what it became
|
|
777
855
|
*/
|
|
778
856
|
function inlineAssets(text, kind, ctx) {
|
|
779
857
|
/** @param {string} ref */
|
|
@@ -809,6 +887,24 @@ function inlineAssets(text, kind, ctx) {
|
|
|
809
887
|
return null;
|
|
810
888
|
}
|
|
811
889
|
const found = named.file;
|
|
890
|
+
// A stylesheet's file too large to carry, where the caller names such
|
|
891
|
+
// files itself (the theme editor's own pages): left as it is, as a
|
|
892
|
+
// missing one is.
|
|
893
|
+
if (
|
|
894
|
+
kind === 'css' &&
|
|
895
|
+
ctx.leaveLargeStyleAssets &&
|
|
896
|
+
(fs.statSync(found, {throwIfNoEntry: false})?.size ?? 0) > MAX_ASSET_BYTES
|
|
897
|
+
) {
|
|
898
|
+
const key = `large:${clean}`;
|
|
899
|
+
if (!ctx.counted.has(key)) {
|
|
900
|
+
ctx.counted.add(key);
|
|
901
|
+
ctx.warnings.push({
|
|
902
|
+
code: 'missing-asset',
|
|
903
|
+
message: `${clean} is larger than ${MAX_ASSET_BYTES / 1048576} MB, the most a rendered page carries of one file, so it is left as is and will not show.`,
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
return null;
|
|
907
|
+
}
|
|
812
908
|
ctx.counted.add(`file:${found}`);
|
|
813
909
|
// A relative path names a file that is part of the page: carry it.
|
|
814
910
|
if (!clean.startsWith('/')) ctx.localAssets.add(found);
|
|
@@ -824,11 +920,14 @@ function inlineAssets(text, kind, ctx) {
|
|
|
824
920
|
});
|
|
825
921
|
if (kind === 'css') return urls(text);
|
|
826
922
|
return text
|
|
827
|
-
|
|
923
|
+
// React writes `srcSet` as it is spelled in JSX; HTML reads attribute
|
|
924
|
+
// names in any case.
|
|
925
|
+
.replace(/\s(src|poster)="([^"]*)"/gi, (whole, attr, ref) => {
|
|
828
926
|
const uri = resolveRef(ref);
|
|
927
|
+
if (uri) ctx.rewrites?.set(decodeAttr(ref), uri);
|
|
829
928
|
return uri ? ` ${attr}="${uri}"` : whole;
|
|
830
929
|
})
|
|
831
|
-
.replace(/\
|
|
930
|
+
.replace(/\s(srcset)="([^"]*)"/gi, (whole, attr, set) => {
|
|
832
931
|
const parts = decodeAttr(set)
|
|
833
932
|
.split(',')
|
|
834
933
|
.map(part => {
|
|
@@ -836,7 +935,9 @@ function inlineAssets(text, kind, ctx) {
|
|
|
836
935
|
const uri = ref ? resolveRef(ref) : null;
|
|
837
936
|
return [uri ?? ref, ...rest].join(' ');
|
|
838
937
|
});
|
|
839
|
-
|
|
938
|
+
const rewritten = parts.join(', ');
|
|
939
|
+
if (rewritten !== decodeAttr(set)) ctx.rewrites?.set(decodeAttr(set), rewritten);
|
|
940
|
+
return ` ${attr}="${rewritten.replace(/"/g, '"')}"`;
|
|
840
941
|
})
|
|
841
942
|
.replace(/\sstyle="([^"]*)"/g, (whole, style) => {
|
|
842
943
|
// The attribute holds escaped text: rewrite the CSS it means, then
|
|
@@ -878,16 +979,26 @@ const SCHEME_CSS =
|
|
|
878
979
|
/**
|
|
879
980
|
* Render a page module to one self-contained HTML file.
|
|
880
981
|
* @param {string} entry absolute path of the page module
|
|
881
|
-
* @param {{title?: string, timeoutMs?: number, version?: string, served?: ServedSet | null, output?: string, cwd?: string, openLayers?: boolean}} [options]
|
|
982
|
+
* @param {{title?: string, timeoutMs?: number, version?: string, served?: ServedSet | null, output?: string, cwd?: string, openLayers?: boolean, leaveLargeStyleAssets?: boolean, markupOnly?: boolean, esbuildFrom?: string}} [options]
|
|
882
983
|
* `served`: the Core of the package set the CLI runs from, for the packages
|
|
883
984
|
* the page's folder has no copy of; `output`: the file the HTML goes to;
|
|
884
985
|
* `cwd`: the current folder, whose files are the page's own outside a
|
|
885
986
|
* project; `openLayers`: the overlays the page shows or opens are drawn
|
|
886
|
-
* and added after its markup (layers.mjs), for reading what they paint
|
|
887
|
-
*
|
|
987
|
+
* and added after its markup (layers.mjs), for reading what they paint;
|
|
988
|
+
* `leaveLargeStyleAssets`: a stylesheet's file too large to inline is
|
|
989
|
+
* left out and named in the warnings, not refused (for a caller that
|
|
990
|
+
* names such files itself). With `output`, the file describes itself: notes at its top and end name
|
|
888
991
|
* what made it and the commands that give the page back and render it
|
|
889
992
|
* again, and its embedded source records the CLI version, the packages
|
|
890
|
-
* the page rendered with, and the markup as rendered.
|
|
993
|
+
* the page rendered with, and the markup as rendered. The file also
|
|
994
|
+
* carries the page's script (client-bundle.mjs): it draws the page over
|
|
995
|
+
* its markup in the browser, so the page's controls work. The markup sits
|
|
996
|
+
* in one element the script draws into, and the stylesheet keeps the rules
|
|
997
|
+
* any of the page's modules can use, not only the markup's. esbuild, a
|
|
998
|
+
* dependency of the CLI, builds the script (`esbuildFrom`: the folder it
|
|
999
|
+
* resolves from); a page whose script cannot be built fails the render.
|
|
1000
|
+
* `markupOnly` renders the markup and its styles without the script, for a
|
|
1001
|
+
* caller that shows the markup itself (the theme editor); it writes no file.
|
|
891
1002
|
* @returns {Promise<RenderedPage>}
|
|
892
1003
|
*/
|
|
893
1004
|
export async function renderPage(entry, options = {}) {
|
|
@@ -899,8 +1010,19 @@ export async function renderPage(entry, options = {}) {
|
|
|
899
1010
|
const served = options.served ?? null;
|
|
900
1011
|
/** @type {RenderWarning[]} */
|
|
901
1012
|
const warnings = [];
|
|
1013
|
+
/** @type {string | undefined} */
|
|
1014
|
+
let esbuild;
|
|
1015
|
+
if (!options.markupOnly) {
|
|
1016
|
+
esbuild = findEsbuild(options.esbuildFrom) ?? undefined;
|
|
1017
|
+
if (!esbuild) {
|
|
1018
|
+
throw new RenderError(
|
|
1019
|
+
'ERR_RENDER_MISSING_DEPENDENCY',
|
|
1020
|
+
`The render builds the page's script, but ${ESBUILD_MISSING}; nothing was written.`,
|
|
1021
|
+
);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
902
1024
|
const message = await runPage(
|
|
903
|
-
{entry, root, scope, served, openLayers: options.openLayers === true},
|
|
1025
|
+
{entry, root, scope, served, openLayers: options.openLayers === true, buildScript: esbuild !== undefined, esbuild},
|
|
904
1026
|
options.timeoutMs ?? RENDER_TIMEOUT_MS,
|
|
905
1027
|
warnings,
|
|
906
1028
|
);
|
|
@@ -912,7 +1034,7 @@ export async function renderPage(entry, options = {}) {
|
|
|
912
1034
|
);
|
|
913
1035
|
}
|
|
914
1036
|
/** @type {string} */
|
|
915
|
-
let markup = message.markup;
|
|
1037
|
+
let markup = linksOpenNewTabs(message.markup);
|
|
916
1038
|
|
|
917
1039
|
// Stylesheets: Core's reset and components, plus each official package's
|
|
918
1040
|
// own stylesheet the page imports from.
|
|
@@ -976,6 +1098,8 @@ export async function renderPage(entry, options = {}) {
|
|
|
976
1098
|
warnings,
|
|
977
1099
|
counted: new Set(),
|
|
978
1100
|
localAssets: /** @type {Set<string>} */ (new Set()),
|
|
1101
|
+
leaveLargeStyleAssets: options.leaveLargeStyleAssets === true,
|
|
1102
|
+
rewrites: /** @type {Map<string, string>} */ (new Map()),
|
|
979
1103
|
};
|
|
980
1104
|
/** Stylesheets pulled in by another's `@import`. @type {Set<string>} */
|
|
981
1105
|
const carriedCss = new Set();
|
|
@@ -1009,6 +1133,14 @@ export async function renderPage(entry, options = {}) {
|
|
|
1009
1133
|
throw e;
|
|
1010
1134
|
}
|
|
1011
1135
|
const used = classesIn(markup);
|
|
1136
|
+
/** The page's script; none in a markup-only render. @type {string | null} */
|
|
1137
|
+
const script = typeof message.script === 'string' ? message.script : null;
|
|
1138
|
+
// The script draws the page again with the paths the page wrote, so each
|
|
1139
|
+
// image the first paint shows from its carried data keeps showing.
|
|
1140
|
+
const drawn = script === null ? null : withCarriedPaths(script, ctx.rewrites);
|
|
1141
|
+
// The script draws what the markup does not show yet (a menu as it opens,
|
|
1142
|
+
// the next tab), so the rules every class name it holds needs stay too.
|
|
1143
|
+
const kept = script ? new Set([...used, ...(script.match(/[A-Za-z_][\w-]*/g) ?? [])]) : used;
|
|
1012
1144
|
// A page that draws elements in a state (hovered, focused, pressed) marks
|
|
1013
1145
|
// them; its stylesheet then applies those states' rules to them too.
|
|
1014
1146
|
const states = markup.includes(' data-astryx-state="');
|
|
@@ -1030,7 +1162,7 @@ export async function renderPage(entry, options = {}) {
|
|
|
1030
1162
|
packageSheets,
|
|
1031
1163
|
served,
|
|
1032
1164
|
});
|
|
1033
|
-
return inlineAssets(cutCss(own,
|
|
1165
|
+
return inlineAssets(cutCss(own, kept, {states}), 'css', {
|
|
1034
1166
|
...ctx,
|
|
1035
1167
|
dir: path.dirname(file),
|
|
1036
1168
|
});
|
|
@@ -1091,19 +1223,28 @@ export async function renderPage(entry, options = {}) {
|
|
|
1091
1223
|
message: `<${t.component}> on line ${t.line} did not render the text "${t.text.length > 60 ? `${t.text.slice(0, 57)}...` : t.text}" it was given; it takes that text through a prop (often label=), so check its props.`,
|
|
1092
1224
|
});
|
|
1093
1225
|
}
|
|
1094
|
-
//
|
|
1095
|
-
//
|
|
1226
|
+
// A media query the page asks in JavaScript gets its server answer in the
|
|
1227
|
+
// markup. The file paints that answer first and asks again when its script
|
|
1228
|
+
// runs; a viewer that blocks scripts keeps the server answer, and so does
|
|
1229
|
+
// a markup-only render.
|
|
1096
1230
|
const screenQueries = [
|
|
1097
|
-
...new Set(
|
|
1231
|
+
...new Set(
|
|
1232
|
+
/** @type {{call: string}[]} */ (message.screenQueries ?? []).map(
|
|
1233
|
+
q => q.call,
|
|
1234
|
+
),
|
|
1235
|
+
),
|
|
1098
1236
|
];
|
|
1099
1237
|
if (screenQueries.length > 0) {
|
|
1100
1238
|
warnings.push({
|
|
1101
1239
|
code: 'screen-query',
|
|
1102
|
-
message:
|
|
1240
|
+
message: script
|
|
1241
|
+
? `The page asks ${screenQueries.join(', ')} in JavaScript: this file paints the server answer first and asks again when its script runs, and a viewer that blocks scripts keeps the server answer. To fit every screen from the first paint, fold the layout with CSS: Grid columns={{minWidth}}, or a StyleX @media or @container style.`
|
|
1242
|
+
: `The page asks ${screenQueries.join(', ')} in JavaScript, which this file never runs: readers on every screen get its server answer, so fold the layout with CSS: Grid columns={{minWidth}}, or a StyleX @media or @container style.`,
|
|
1103
1243
|
});
|
|
1104
1244
|
}
|
|
1105
1245
|
// A chart the render did not draw is an empty box: a ResponsiveContainer
|
|
1106
|
-
// holds only its sizing box, and a chart of fixed size an empty wrapper.
|
|
1246
|
+
// holds only its sizing box, and a chart of fixed size an empty wrapper. The
|
|
1247
|
+
// file's script draws it when it runs.
|
|
1107
1248
|
const blankCharts =
|
|
1108
1249
|
(
|
|
1109
1250
|
markup.match(
|
|
@@ -1116,7 +1257,9 @@ export async function renderPage(entry, options = {}) {
|
|
|
1116
1257
|
if (blankCharts > 0) {
|
|
1117
1258
|
warnings.push({
|
|
1118
1259
|
code: 'chart-size',
|
|
1119
|
-
message:
|
|
1260
|
+
message: script
|
|
1261
|
+
? `${blankCharts === 1 ? 'A chart' : `${blankCharts} charts`} could not be drawn without a browser, so the file paints ${blankCharts === 1 ? 'it' : 'them'} empty and its script draws ${blankCharts === 1 ? 'it' : 'them'} when it runs; a viewer that blocks scripts keeps ${blankCharts === 1 ? 'it' : 'them'} empty. The render draws a chart into the markup only when a module of the page (not an installed package) imports the chart, and its ResponsiveContainer, from recharts by name (\`import {LineChart} from 'recharts'\`).`
|
|
1262
|
+
: `${blankCharts === 1 ? 'A chart' : `${blankCharts} charts`} could not be drawn without a browser, so ${blankCharts === 1 ? 'it is' : 'they are'} empty here: the render draws a chart only when a module of the page (not an installed package) imports the chart, and its ResponsiveContainer, from recharts by name (\`import {LineChart} from 'recharts'\`).`,
|
|
1120
1263
|
});
|
|
1121
1264
|
}
|
|
1122
1265
|
if (message.chartsAlone) {
|
|
@@ -1131,7 +1274,9 @@ export async function renderPage(entry, options = {}) {
|
|
|
1131
1274
|
const why = causes[message.chartsAlone] ?? causes.error;
|
|
1132
1275
|
warnings.push({
|
|
1133
1276
|
code: 'chart-size',
|
|
1134
|
-
message:
|
|
1277
|
+
message: script
|
|
1278
|
+
? `${why}, so each chart was drawn by itself for the first paint, as the first render gave it: until the file's script draws the page again, a custom tick, label or shape in a chart sees React context defaults, not the values the page provides.`
|
|
1279
|
+
: `${why}, so each chart was drawn by itself, as the first render gave it: a custom tick, label or shape in a chart sees React context defaults, not the values the page provides.`,
|
|
1135
1280
|
});
|
|
1136
1281
|
}
|
|
1137
1282
|
for (const sheet of /** @type {string[]} */ (message.skippedCss ?? [])) {
|
|
@@ -1289,7 +1434,32 @@ export async function renderPage(entry, options = {}) {
|
|
|
1289
1434
|
? decodeAttr(heading)
|
|
1290
1435
|
: path.basename(entry).replace(/\.[^.]+$/, ''));
|
|
1291
1436
|
const generator = `<meta name="generator" content="Astryx${options.version ? ` ${escapeHtml(options.version)}` : ''}">`;
|
|
1292
|
-
const style = `<style>${SCHEME_CSS}${markup.includes('class="recharts-responsive-container"') ? CHART_CSS : ''}${css}</style>`;
|
|
1437
|
+
const style = `<style>${SCHEME_CSS}${script ? `#${ROOT_ID}{display:contents}` : ''}${markup.includes('class="recharts-responsive-container"') ? CHART_CSS : ''}${css}</style>`;
|
|
1438
|
+
// With a script, the markup sits in the one element the script draws into,
|
|
1439
|
+
// which takes no box of its own.
|
|
1440
|
+
const body = script ? `<div id="${ROOT_ID}">${markup}</div>` : markup;
|
|
1441
|
+
// An image the embedded source leaves out (under a dot-folder, say) keeps
|
|
1442
|
+
// its own data: URI in the script.
|
|
1443
|
+
const carriedSha = new Set(embedded.map(e => sha256(e.bytes)));
|
|
1444
|
+
/** @type {Map<string, Buffer>} */
|
|
1445
|
+
const imageBytes = new Map();
|
|
1446
|
+
for (const f of files) {
|
|
1447
|
+
if (!isAssetPath(f)) continue;
|
|
1448
|
+
try {
|
|
1449
|
+
const bytes = fs.readFileSync(f);
|
|
1450
|
+
imageBytes.set(sha256(bytes), bytes);
|
|
1451
|
+
} catch {
|
|
1452
|
+
// A file that went away since the page imported it stays as written.
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
const pageScript =
|
|
1456
|
+
drawn === null
|
|
1457
|
+
? null
|
|
1458
|
+
: withUncarriedImages(drawn, carriedSha, (sha, prefix) => {
|
|
1459
|
+
const bytes = imageBytes.get(sha);
|
|
1460
|
+
return bytes ? `${prefix},${bytes.toString('base64')}` : null;
|
|
1461
|
+
});
|
|
1462
|
+
const scriptTag = pageScript ? `<script>${pageScript}</script>\n` : '';
|
|
1293
1463
|
let html;
|
|
1294
1464
|
if (options.output) {
|
|
1295
1465
|
// The charset and generator metas come first: a browser reads the
|
|
@@ -1353,10 +1523,10 @@ export async function renderPage(entry, options = {}) {
|
|
|
1353
1523
|
packages,
|
|
1354
1524
|
...(Object.keys(aliases).length > 0 ? {aliases} : {}),
|
|
1355
1525
|
markup: {
|
|
1356
|
-
sha256: sha256(asParsed(
|
|
1526
|
+
sha256: sha256(asParsed(body)),
|
|
1357
1527
|
style: sha256(asParsed(style)),
|
|
1358
1528
|
text: Buffer.from(
|
|
1359
|
-
JSON.stringify({title, runs: textRuns(
|
|
1529
|
+
JSON.stringify({title, runs: textRuns(body)}),
|
|
1360
1530
|
).toString('base64'),
|
|
1361
1531
|
},
|
|
1362
1532
|
};
|
|
@@ -1364,15 +1534,15 @@ export async function renderPage(entry, options = {}) {
|
|
|
1364
1534
|
`<!doctype html><html lang="en"${rootThemeAttrs(markup)}><head><meta charset="utf-8">${generator}\n${headerNote(facts)}\n` +
|
|
1365
1535
|
'<meta name="viewport" content="width=device-width,initial-scale=1">' +
|
|
1366
1536
|
'<meta name="color-scheme" content="light dark">' +
|
|
1367
|
-
`<title>${escapeHtml(title)}</title>${style}</head><body>${
|
|
1368
|
-
`${sourceBlock(path.basename(entry), embedded, record)}\n${endNote(facts)}\n</body></html>\n`;
|
|
1537
|
+
`<title>${escapeHtml(title)}</title>${style}</head><body>${body}` +
|
|
1538
|
+
`${sourceBlock(path.basename(entry), embedded, record)}\n${endNote(facts)}\n${scriptTag}</body></html>\n`;
|
|
1369
1539
|
} else {
|
|
1370
1540
|
html =
|
|
1371
1541
|
`<!doctype html><html lang="en"${rootThemeAttrs(markup)}><head><meta charset="utf-8">` +
|
|
1372
1542
|
'<meta name="viewport" content="width=device-width,initial-scale=1">' +
|
|
1373
1543
|
'<meta name="color-scheme" content="light dark">' +
|
|
1374
|
-
`${generator}<title>${escapeHtml(title)}</title>${style}</head><body>${
|
|
1375
|
-
`${sourceBlock(path.basename(entry), embedded)}</body></html>\n`;
|
|
1544
|
+
`${generator}<title>${escapeHtml(title)}</title>${style}</head><body>${body}` +
|
|
1545
|
+
`${sourceBlock(path.basename(entry), embedded)}${scriptTag}</body></html>\n`;
|
|
1376
1546
|
}
|
|
1377
1547
|
return {
|
|
1378
1548
|
html,
|
|
@@ -1389,5 +1559,6 @@ export async function renderPage(entry, options = {}) {
|
|
|
1389
1559
|
]).size,
|
|
1390
1560
|
warnings,
|
|
1391
1561
|
fromSet: message.fromSet ?? [],
|
|
1562
|
+
...(pageScript ? {scriptBytes: Buffer.byteLength(pageScript), scriptModules: message.scriptModules ?? 0} : {}),
|
|
1392
1563
|
};
|
|
1393
1564
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The first restore folder for `file` that `dir` does not hold yet:
|
|
6
|
+
* `<name>-restored`, then `<name>-restored-2` and so on.
|
|
7
|
+
* @param {string} dir absolute
|
|
8
|
+
* @param {string} file the rendered file's name
|
|
9
|
+
* @param {(folder: string) => void} [onTaken] called with each name already
|
|
10
|
+
* taken, before the next is tried
|
|
11
|
+
* @returns {string} absolute
|
|
12
|
+
*/
|
|
13
|
+
export function freeRestoreFolder(dir: string, file: string, onTaken?: (folder: string) => void): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The folder a restore without --out writes into, by name: shared by
|
|
5
|
+
* the restore itself and the command line that the render prints for it.
|
|
6
|
+
* @position foundation/render — read by api/render/_adapter.mjs and the
|
|
7
|
+
* render command
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import * as fs from 'node:fs';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The first restore folder for `file` that `dir` does not hold yet:
|
|
15
|
+
* `<name>-restored`, then `<name>-restored-2` and so on.
|
|
16
|
+
* @param {string} dir absolute
|
|
17
|
+
* @param {string} file the rendered file's name
|
|
18
|
+
* @param {(folder: string) => void} [onTaken] called with each name already
|
|
19
|
+
* taken, before the next is tried
|
|
20
|
+
* @returns {string} absolute
|
|
21
|
+
*/
|
|
22
|
+
export function freeRestoreFolder(dir, file, onTaken = () => {}) {
|
|
23
|
+
const stem = file.replace(/\.[^.]+$/, '');
|
|
24
|
+
let folder = path.join(dir, `${stem}-restored`);
|
|
25
|
+
for (let n = 2; fs.existsSync(folder); n++) {
|
|
26
|
+
onTaken(folder);
|
|
27
|
+
folder = path.join(dir, `${stem}-restored-${n}`);
|
|
28
|
+
}
|
|
29
|
+
return folder;
|
|
30
|
+
}
|
|
@@ -10,7 +10,8 @@ export function packageOf(spec: string): string;
|
|
|
10
10
|
/**
|
|
11
11
|
* Whether a render may take `name` from the package set.
|
|
12
12
|
* @param {string} name
|
|
13
|
-
* @param {readonly string[]} integrations the integrations the host approves
|
|
13
|
+
* @param {readonly string[]} integrations the integrations the host approves,
|
|
14
|
+
* and the other packages its set declares
|
|
14
15
|
* @returns {boolean}
|
|
15
16
|
*/
|
|
16
17
|
export function isServedPackage(name: string, integrations: readonly string[]): boolean;
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Which packages a render may take from the package set the CLI runs
|
|
5
5
|
* from when the page is outside a project (architecture:cli-surface INV30):
|
|
6
|
-
* the Astryx packages, the React and StyleX they run with,
|
|
7
|
-
*
|
|
6
|
+
* the Astryx packages, the React and StyleX they run with, the integrations
|
|
7
|
+
* the host approves, and the other packages the host's set declares. Inside a
|
|
8
|
+
* project the set is never used.
|
|
8
9
|
*
|
|
9
10
|
* @input A specifier, the file that imports it, and the served Core's folder.
|
|
10
11
|
* @output The file it resolves to, or null.
|
|
@@ -37,7 +38,8 @@ export function packageOf(spec) {
|
|
|
37
38
|
/**
|
|
38
39
|
* Whether a render may take `name` from the package set.
|
|
39
40
|
* @param {string} name
|
|
40
|
-
* @param {readonly string[]} integrations the integrations the host approves
|
|
41
|
+
* @param {readonly string[]} integrations the integrations the host approves,
|
|
42
|
+
* and the other packages its set declares
|
|
41
43
|
* @returns {boolean}
|
|
42
44
|
*/
|
|
43
45
|
export function isServedPackage(name, integrations) {
|
|
@@ -51,6 +51,17 @@ export function existingFile(candidate: string, extensions?: readonly string[]):
|
|
|
51
51
|
* pattern or no target exists
|
|
52
52
|
*/
|
|
53
53
|
export function resolvePath(patterns: PathPattern[], spec: string): string | null;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the project that holds `from` maps a bare specifier to its own
|
|
56
|
+
* code, by TypeScript's rules for the config it reads for `from` (through
|
|
57
|
+
* `extends`): a `compilerOptions.paths` key matches it (`@app/*` maps
|
|
58
|
+
* `@app/c`), or its `baseUrl` holds the file (`lib/c`). Such an import is a
|
|
59
|
+
* path alias, never a package.
|
|
60
|
+
* @param {string} specifier
|
|
61
|
+
* @param {string | null} from the importing module, absolute
|
|
62
|
+
* @returns {boolean}
|
|
63
|
+
*/
|
|
64
|
+
export function projectMapsImport(specifier: string, from: string | null): boolean;
|
|
54
65
|
/** The extensions the render's module loader tries for an extensionless import, in its order. */
|
|
55
66
|
export const LOAD_EXTENSIONS: string[];
|
|
56
67
|
export function candidatesOf(match: {
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file A project's `compilerOptions.paths` (tsconfig.json or jsconfig.json),
|
|
5
|
-
* read and matched by TypeScript's rules, for `astryx experimental render
|
|
5
|
+
* read and matched by TypeScript's rules, for `astryx experimental render`,
|
|
6
|
+
* `theme build`, and Doctor.
|
|
6
7
|
* The config of a file is the nearest tsconfig.json (else jsconfig.json) in
|
|
7
8
|
* its folder or above, read through its `extends`; a config that does not
|
|
8
9
|
* include the file lends the referenced project that does, as a
|
|
@@ -14,7 +15,9 @@
|
|
|
14
15
|
* resolve from `baseUrl`, else from the folder of the config that writes
|
|
15
16
|
* `paths`.
|
|
16
17
|
*
|
|
17
|
-
* @position foundation/render — used by page-worker.mjs
|
|
18
|
+
* @position foundation/render — used by page-worker.mjs, embedded-imports.mjs,
|
|
19
|
+
* the theme build's module loader (api/theme/build/build.mjs), and Doctor's
|
|
20
|
+
* icon-imports scan (api/doctor/_adapter.mjs)
|
|
18
21
|
*/
|
|
19
22
|
|
|
20
23
|
import * as fs from 'node:fs';
|
|
@@ -422,3 +425,25 @@ export function resolvePath(patterns, spec) {
|
|
|
422
425
|
}
|
|
423
426
|
return null;
|
|
424
427
|
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Whether the project that holds `from` maps a bare specifier to its own
|
|
431
|
+
* code, by TypeScript's rules for the config it reads for `from` (through
|
|
432
|
+
* `extends`): a `compilerOptions.paths` key matches it (`@app/*` maps
|
|
433
|
+
* `@app/c`), or its `baseUrl` holds the file (`lib/c`). Such an import is a
|
|
434
|
+
* path alias, never a package.
|
|
435
|
+
* @param {string} specifier
|
|
436
|
+
* @param {string | null} from the importing module, absolute
|
|
437
|
+
* @returns {boolean}
|
|
438
|
+
*/
|
|
439
|
+
export function projectMapsImport(specifier, from) {
|
|
440
|
+
if (!from) return false;
|
|
441
|
+
const found = configFor(from);
|
|
442
|
+
if (!found) return false;
|
|
443
|
+
const configDir = path.dirname(found.file);
|
|
444
|
+
if (matchPath(patternsOf(found.config, configDir), specifier)) return true;
|
|
445
|
+
const {baseUrl} = found.config.options;
|
|
446
|
+
if (typeof baseUrl !== 'string' || /^\.{1,2}(\/|$)|^\//.test(specifier)) return false;
|
|
447
|
+
const base = configPath(baseUrl, found.config.baseUrlDir, configDir);
|
|
448
|
+
return existingFile(path.join(base, specifier)) !== null;
|
|
449
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One binding a static import makes.
|
|
6
|
+
* @typedef {object} ImportUse
|
|
7
|
+
* @property {any} specifier the import specifier
|
|
8
|
+
* @property {any[]} values the NodePaths of the references that resolve to
|
|
9
|
+
* this binding and use it as a value. A parameter or a local declaration
|
|
10
|
+
* of the same name is its own binding, so its references are not here.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Each static import declaration of a module, with the bindings it makes.
|
|
14
|
+
* @param {any} ast the module's AST (`File`)
|
|
15
|
+
* @returns {Map<any, ImportUse[]>} by import declaration, in source order
|
|
16
|
+
*/
|
|
17
|
+
export function importUses(ast: any): Map<any, ImportUse[]>;
|
|
18
|
+
/**
|
|
19
|
+
* The modules a TypeScript build drops from a module's static imports: an
|
|
20
|
+
* `import type`, or an import each binding of which is a `type` binding or
|
|
21
|
+
* is used only in types or not at all. A module that another static import
|
|
22
|
+
* of the same module keeps is not dropped. Only static import declarations
|
|
23
|
+
* are read: a re-export, an `import()` or a `require()` loads its module.
|
|
24
|
+
* JavaScript keeps every import, so call this only for a TypeScript module.
|
|
25
|
+
* @param {any} ast the module's AST (`File`)
|
|
26
|
+
* @returns {Set<string>}
|
|
27
|
+
*/
|
|
28
|
+
export function droppedImports(ast: any): Set<string>;
|
|
29
|
+
/**
|
|
30
|
+
* One binding a static import makes.
|
|
31
|
+
*/
|
|
32
|
+
export type ImportUse = {
|
|
33
|
+
/**
|
|
34
|
+
* the import specifier
|
|
35
|
+
*/
|
|
36
|
+
specifier: any;
|
|
37
|
+
/**
|
|
38
|
+
* the NodePaths of the references that resolve to
|
|
39
|
+
* this binding and use it as a value. A parameter or a local declaration
|
|
40
|
+
* of the same name is its own binding, so its references are not here.
|
|
41
|
+
*/
|
|
42
|
+
values: any[];
|
|
43
|
+
};
|