@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
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file
|
|
5
|
-
* driven over the DevTools protocol on a pipe, run as its own
|
|
6
|
-
* editor's browser runner.
|
|
7
|
-
* @input argv: the browser, the
|
|
8
|
-
* mode
|
|
9
|
-
* @output
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
4
|
+
* @file Whole-page pictures of a batch of pages through one Chrome or
|
|
5
|
+
* Chromium, driven over the DevTools protocol on a pipe, run as its own
|
|
6
|
+
* process by the editor's browser runner.
|
|
7
|
+
* @input argv: the browser, and the batch (JSON: each job's page .html,
|
|
8
|
+
* picture .png and color mode)
|
|
9
|
+
* @output each whole page, every pixel of its height, at its path, and on
|
|
10
|
+
* stdout, each line led by its job's place and a tab: the fonts it drew
|
|
11
|
+
* its text in (font-probe.mjs), the text it draws cut short
|
|
12
|
+
* (cut-short.mjs), and PICTURE_TAKEN once it is whole; on failure, the
|
|
13
|
+
* browser's reason on stderr and exit code 1
|
|
13
14
|
* @position run by `screenshot` in api/theme-edit/_preview.mjs through
|
|
14
15
|
* `runBrowser`, which gives it a temp folder of its own (the browser's
|
|
15
16
|
* profile goes there), its time bound and its stop
|
|
@@ -22,10 +23,21 @@ import * as path from 'node:path';
|
|
|
22
23
|
import {pathToFileURL} from 'node:url';
|
|
23
24
|
import {CUT_SHORT_PREFIX, cutShortText} from './cut-short.mjs';
|
|
24
25
|
import {NETWORK_URL_PATTERNS, QUIET_BROWSER_ARGS} from './offline.mjs';
|
|
25
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
PICTURE_PAGES_AT_ONCE,
|
|
28
|
+
PICTURE_TAKEN,
|
|
29
|
+
PICTURE_WINDOW,
|
|
30
|
+
SETTLE_ANIMATIONS,
|
|
31
|
+
AWAIT_QUIET,
|
|
32
|
+
eachAtOnce,
|
|
33
|
+
} from './picture-window.mjs';
|
|
26
34
|
import {FONT_PROBE_PREFIX, probeFonts} from './font-probe.mjs';
|
|
27
35
|
|
|
28
|
-
const [chrome,
|
|
36
|
+
const [chrome, batch] = process.argv.slice(2);
|
|
37
|
+
/** @type {Array<{html: string, png: string, mode: string}>} */
|
|
38
|
+
const jobs = JSON.parse(batch);
|
|
39
|
+
/** A line for one job of the batch. @param {number} i @param {string} line */
|
|
40
|
+
const say = (i, line) => process.stdout.write(`${i}\t${line}\n`);
|
|
29
41
|
|
|
30
42
|
const browser = spawn(
|
|
31
43
|
chrome,
|
|
@@ -140,8 +152,16 @@ function event(method, sessionId) {
|
|
|
140
152
|
]);
|
|
141
153
|
}
|
|
142
154
|
|
|
143
|
-
|
|
144
|
-
|
|
155
|
+
/**
|
|
156
|
+
* One page of the batch in a tab of its own: drawn, pictured whole, and
|
|
157
|
+
* measured.
|
|
158
|
+
* @param {{html: string, png: string, mode: string}} job
|
|
159
|
+
* @param {number} i
|
|
160
|
+
*/
|
|
161
|
+
async function picture({html, png, mode}, i) {
|
|
162
|
+
// Each page in a window of its own: a page in a background tab runs
|
|
163
|
+
// no animation frames, so a chart drawn over frames never finishes.
|
|
164
|
+
const {targetId} = await send('Target.createTarget', {url: 'about:blank', newWindow: true});
|
|
145
165
|
const {sessionId} = await send('Target.attachToTarget', {
|
|
146
166
|
targetId,
|
|
147
167
|
flatten: true,
|
|
@@ -171,20 +191,20 @@ try {
|
|
|
171
191
|
const loaded = event('Page.loadEventFired', sessionId);
|
|
172
192
|
await send('Page.navigate', {url: pathToFileURL(html).href}, sessionId);
|
|
173
193
|
await loaded;
|
|
194
|
+
// The page draws, at the window's size, until it is quiet (a chart's
|
|
195
|
+
// drawing over frames ends).
|
|
196
|
+
await send('Runtime.evaluate', {expression: AWAIT_QUIET, awaitPromise: true}, sessionId);
|
|
174
197
|
// An overlay drawn open plays its opening animation (a fade-in) as the
|
|
175
|
-
// page loads:
|
|
176
|
-
//
|
|
177
|
-
|
|
178
|
-
// stays as it is.
|
|
179
|
-
await send(
|
|
180
|
-
'Runtime.evaluate',
|
|
181
|
-
{
|
|
182
|
-
expression: `for (const a of document.getAnimations()) { if (a.effect?.getComputedTiming().iterations !== Infinity) a.finish(); }`,
|
|
183
|
-
},
|
|
184
|
-
sessionId,
|
|
185
|
-
);
|
|
198
|
+
// page loads: it is run to its end, and a looping one held at a frame a
|
|
199
|
+
// person sees (SETTLE_ANIMATIONS), before the picture.
|
|
200
|
+
await send('Runtime.evaluate', {expression: SETTLE_ANIMATIONS}, sessionId);
|
|
186
201
|
const metrics = await send('Page.getLayoutMetrics', {}, sessionId);
|
|
187
202
|
const size = metrics.cssContentSize ?? metrics.contentSize;
|
|
203
|
+
// A picture beyond the window makes the page see a resize; a part that
|
|
204
|
+
// redraws on it (a responsive chart) would start over and be pictured
|
|
205
|
+
// empty. The page's script is held while the picture is taken; the page
|
|
206
|
+
// stays laid out for the window (its vh, fixed parts and media queries).
|
|
207
|
+
await send('Emulation.setScriptExecutionDisabled', {value: true}, sessionId);
|
|
188
208
|
const {data} = await send(
|
|
189
209
|
'Page.captureScreenshot',
|
|
190
210
|
{
|
|
@@ -201,12 +221,12 @@ try {
|
|
|
201
221
|
sessionId,
|
|
202
222
|
);
|
|
203
223
|
fs.writeFileSync(png, Buffer.from(data, 'base64'));
|
|
224
|
+
await send('Emulation.setScriptExecutionDisabled', {value: false}, sessionId);
|
|
204
225
|
// The fonts the picture drew its text in, for the editor's note.
|
|
205
226
|
const fonts = await probeFonts((method, params) =>
|
|
206
227
|
send(method, params, sessionId),
|
|
207
228
|
).catch(() => null);
|
|
208
|
-
if (fonts)
|
|
209
|
-
process.stdout.write(`${FONT_PROBE_PREFIX}${JSON.stringify(fonts)}\n`);
|
|
229
|
+
if (fonts) say(i, `${FONT_PROBE_PREFIX}${JSON.stringify(fonts)}`);
|
|
210
230
|
// The text the picture draws cut short, measured on the page as the
|
|
211
231
|
// picture shows it. A measurement that does not run says nothing, and
|
|
212
232
|
// the picture stands.
|
|
@@ -216,9 +236,14 @@ try {
|
|
|
216
236
|
sessionId,
|
|
217
237
|
).catch(() => null);
|
|
218
238
|
if (Array.isArray(measured?.result?.value) && !measured.exceptionDetails)
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
239
|
+
say(i, `${CUT_SHORT_PREFIX}${JSON.stringify(measured.result.value)}`);
|
|
240
|
+
await send('Target.closeTarget', {targetId}).catch(() => {});
|
|
241
|
+
say(i, PICTURE_TAKEN);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
try {
|
|
245
|
+
// One browser for every page of the batch, a few tabs at a time.
|
|
246
|
+
await eachAtOnce(jobs, PICTURE_PAGES_AT_ONCE, picture);
|
|
222
247
|
await send('Browser.close').catch(() => {});
|
|
223
248
|
} catch (e) {
|
|
224
249
|
process.stderr.write(`${e instanceof Error ? e.message : String(e)}\n`);
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file
|
|
5
|
-
* own process by the editor's browser
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
4
|
+
* @file The pictures of a batch of pages through the project's Playwright,
|
|
5
|
+
* one browser for all, run as its own process by the editor's browser
|
|
6
|
+
* runner.
|
|
7
|
+
* @input argv: the Playwright entry file, the batch (JSON: each job's page
|
|
8
|
+
* .html, picture .png and color mode), and a browser to use instead of
|
|
9
|
+
* Playwright's own
|
|
10
|
+
* @output each picture at its path, and on stdout, each line led by its
|
|
11
|
+
* job's place and a tab: the fonts it drew its text in (font-probe.mjs),
|
|
12
|
+
* the text it draws cut short (cut-short.mjs), and PICTURE_TAKEN once it
|
|
13
|
+
* is whole; on failure, Playwright's error on stderr and exit code 1
|
|
12
14
|
* @position run by `screenshot` in api/theme-edit/_preview.mjs through
|
|
13
15
|
* `runBrowser`, which gives it a temp folder of its own, its time bound and its stop
|
|
14
16
|
*/
|
|
@@ -16,51 +18,85 @@
|
|
|
16
18
|
import {pathToFileURL} from 'node:url';
|
|
17
19
|
import {CUT_SHORT_PREFIX, cutShortText} from './cut-short.mjs';
|
|
18
20
|
import {LOCAL_URL, QUIET_BROWSER_ARGS} from './offline.mjs';
|
|
19
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
PICTURE_PAGES_AT_ONCE,
|
|
23
|
+
PICTURE_TAKEN,
|
|
24
|
+
PICTURE_WINDOW,
|
|
25
|
+
SETTLE_ANIMATIONS,
|
|
26
|
+
AWAIT_QUIET,
|
|
27
|
+
eachAtOnce,
|
|
28
|
+
} from './picture-window.mjs';
|
|
20
29
|
import {FONT_PROBE_PREFIX, probeFonts} from './font-probe.mjs';
|
|
21
30
|
|
|
22
|
-
const [entry,
|
|
31
|
+
const [entry, batch, executablePath] = process.argv.slice(2);
|
|
32
|
+
/** @type {Array<{html: string, png: string, mode: string}>} */
|
|
33
|
+
const jobs = JSON.parse(batch);
|
|
34
|
+
/** A line for one job of the batch. @param {number} i @param {string} line */
|
|
35
|
+
const say = (i, line) => process.stdout.write(`${i}\t${line}\n`);
|
|
23
36
|
try {
|
|
24
37
|
const pw = await import(pathToFileURL(entry).href);
|
|
25
38
|
const chromium = pw.chromium ?? pw.default?.chromium;
|
|
26
|
-
//
|
|
39
|
+
// One browser for every picture of the batch, its own network off, as
|
|
40
|
+
// for the Chrome picture script.
|
|
27
41
|
const browser = await chromium.launch({
|
|
28
42
|
args: [...QUIET_BROWSER_ARGS],
|
|
29
43
|
...(executablePath ? {executablePath} : {}),
|
|
30
44
|
});
|
|
31
45
|
try {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
await eachAtOnce(
|
|
47
|
+
jobs,
|
|
48
|
+
PICTURE_PAGES_AT_ONCE,
|
|
49
|
+
async ({html, png, mode}, i) => {
|
|
50
|
+
const page = await browser.newPage({
|
|
51
|
+
viewport: {...PICTURE_WINDOW},
|
|
52
|
+
colorScheme: mode === 'dark' ? 'dark' : 'light',
|
|
53
|
+
});
|
|
54
|
+
// The page loads its own files only: a remote stylesheet, font or
|
|
55
|
+
// image fails at once instead of holding the load on a network.
|
|
56
|
+
await page.route(
|
|
57
|
+
(/** @type {URL} */ url) => !LOCAL_URL.test(url.href),
|
|
58
|
+
(/** @type {{abort: (why: string) => Promise<void>}} */ route) =>
|
|
59
|
+
route.abort('blockedbyclient'),
|
|
60
|
+
);
|
|
61
|
+
await page.goto(pathToFileURL(html).href, {waitUntil: 'load'});
|
|
62
|
+
// The page draws until it is quiet (a chart's drawing over frames
|
|
63
|
+
// ends).
|
|
64
|
+
await page.evaluate(AWAIT_QUIET);
|
|
65
|
+
// An overlay drawn open plays its opening animation (a fade-in) as
|
|
66
|
+
// the page loads: it is run to its end, and a looping one held at a
|
|
67
|
+
// frame a person sees (SETTLE_ANIMATIONS), before the picture.
|
|
68
|
+
// Playwright's own animations: 'disabled' would put a looping one
|
|
69
|
+
// back at its first frame, where a skeleton is faint.
|
|
70
|
+
await page.evaluate(SETTLE_ANIMATIONS);
|
|
71
|
+
// A whole-page picture makes the page see a resize; a part that
|
|
72
|
+
// redraws on it (a responsive chart) would start over and be
|
|
73
|
+
// pictured empty. The page's script is held while it is taken.
|
|
74
|
+
const held = await (async () => {
|
|
75
|
+
const cdp = await page.context().newCDPSession(page);
|
|
76
|
+
await cdp.send('Emulation.setScriptExecutionDisabled', {value: true});
|
|
77
|
+
return cdp;
|
|
78
|
+
})().catch(() => null);
|
|
79
|
+
await page.screenshot({path: png, fullPage: true, animations: 'allow'});
|
|
80
|
+
await held?.send('Emulation.setScriptExecutionDisabled', {value: false}).catch(() => {});
|
|
81
|
+
// The fonts the picture drew its text in, for the editor's note.
|
|
82
|
+
const fonts = await (async () => {
|
|
83
|
+
const cdp = await page.context().newCDPSession(page);
|
|
84
|
+
return probeFonts((method, params) => cdp.send(method, params));
|
|
85
|
+
})().catch(() => null);
|
|
86
|
+
if (fonts) say(i, `${FONT_PROBE_PREFIX}${JSON.stringify(fonts)}`);
|
|
87
|
+
// The text the picture draws cut short, measured on the page as the
|
|
88
|
+
// picture shows it. A page that runs no script measures nothing, and
|
|
89
|
+
// the picture stands: nothing is said.
|
|
90
|
+
try {
|
|
91
|
+
const cut = await page.evaluate(cutShortText);
|
|
92
|
+
say(i, `${CUT_SHORT_PREFIX}${JSON.stringify(cut)}`);
|
|
93
|
+
} catch {
|
|
94
|
+
// Not measured.
|
|
95
|
+
}
|
|
96
|
+
await page.close?.().catch(() => {});
|
|
97
|
+
say(i, PICTURE_TAKEN);
|
|
98
|
+
},
|
|
42
99
|
);
|
|
43
|
-
await page.goto(pathToFileURL(html).href, {waitUntil: 'load'});
|
|
44
|
-
// An overlay drawn open plays its opening animation (a fade-in) as the
|
|
45
|
-
// page loads: the picture is taken with each animation that ends run
|
|
46
|
-
// to its end, so it shows the overlay as it looks open.
|
|
47
|
-
await page.screenshot({path: png, fullPage: true, animations: 'disabled'});
|
|
48
|
-
// The fonts the picture drew its text in, for the editor's note.
|
|
49
|
-
const fonts = await (async () => {
|
|
50
|
-
const cdp = await page.context().newCDPSession(page);
|
|
51
|
-
return probeFonts((method, params) => cdp.send(method, params));
|
|
52
|
-
})().catch(() => null);
|
|
53
|
-
if (fonts)
|
|
54
|
-
process.stdout.write(`${FONT_PROBE_PREFIX}${JSON.stringify(fonts)}\n`);
|
|
55
|
-
// The text the picture draws cut short, measured on the page as the
|
|
56
|
-
// picture shows it. A page that runs no script measures nothing, and
|
|
57
|
-
// the picture stands: nothing is said.
|
|
58
|
-
try {
|
|
59
|
-
const cut = await page.evaluate(cutShortText);
|
|
60
|
-
process.stdout.write(`${CUT_SHORT_PREFIX}${JSON.stringify(cut)}\n`);
|
|
61
|
-
} catch {
|
|
62
|
-
// Not measured.
|
|
63
|
-
}
|
|
64
100
|
} finally {
|
|
65
101
|
await browser.close();
|
|
66
102
|
}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Run each job of a list in order, a few at a time. Once one fails, no
|
|
6
|
+
* other starts; the ones running finish, then the first failure is thrown,
|
|
7
|
+
* so every job before it has had its turn.
|
|
8
|
+
* @template T
|
|
9
|
+
* @param {T[]} jobs
|
|
10
|
+
* @param {number} atOnce
|
|
11
|
+
* @param {(job: T, i: number) => Promise<void>} run
|
|
12
|
+
*/
|
|
13
|
+
export function eachAtOnce<T>(jobs: T[], atOnce: number, run: (job: T, i: number) => Promise<void>): Promise<void>;
|
|
4
14
|
/**
|
|
5
15
|
* Whether a media query matches in the window a picture is taken in
|
|
6
16
|
* (PICTURE_WINDOW, a desktop's, with a mouse): each comma-separated query
|
|
@@ -26,6 +36,29 @@ export function desktopMatches(query: string, { sure }?: {
|
|
|
26
36
|
* the stylesheet cut (css-cut.mjs), so a part drawn open or in a state
|
|
27
37
|
* lays out as the picture shows it.
|
|
28
38
|
*/
|
|
39
|
+
/**
|
|
40
|
+
* The script run on a page before its picture: each animation that ends (an
|
|
41
|
+
* overlay's fade-in) is run to its end, so the picture shows the part as it
|
|
42
|
+
* looks once it has played; each that loops (a skeleton's shimmer, a pulsing
|
|
43
|
+
* dot, a spinner) is held at the middle of its first round, a frame a person
|
|
44
|
+
* sees as it plays, never its first frame, where a part can be faint or gone.
|
|
45
|
+
*/
|
|
46
|
+
export const SETTLE_ANIMATIONS: "for (const a of document.getAnimations()) {\n const t = a.effect?.getComputedTiming();\n if (!t) continue;\n if (t.iterations !== Infinity) { a.finish(); continue; }\n a.pause();\n a.currentTime = (Number(a.effect.getTiming().delay) || 0) + (typeof t.duration === 'number' ? t.duration : 0) / 2;\n}";
|
|
47
|
+
/**
|
|
48
|
+
* The script run before the picture: it waits until the page stops
|
|
49
|
+
* changing, so a part drawn over animation frames (a responsive chart's
|
|
50
|
+
* lines) is drawn whole. Quiet means no change to the document for
|
|
51
|
+
* QUIET_MS; it waits QUIET_MOST_MS at most.
|
|
52
|
+
*/
|
|
53
|
+
export const AWAIT_QUIET: "new Promise(resolve => {\n const QUIET_MS = 300;\n const QUIET_MOST_MS = 4000;\n let timer = setTimeout(done, QUIET_MS);\n const most = setTimeout(done, QUIET_MOST_MS);\n const watch = new MutationObserver(() => {\n clearTimeout(timer);\n timer = setTimeout(done, QUIET_MS);\n });\n watch.observe(document, {subtree: true, childList: true, attributes: true, characterData: true});\n function done() {\n watch.disconnect();\n clearTimeout(timer);\n clearTimeout(most);\n resolve(true);\n }\n})";
|
|
54
|
+
/**
|
|
55
|
+
* How a picture script hands back a batch: each line it prints for a job
|
|
56
|
+
* starts with the job's place in the batch and a tab; a job's picture is
|
|
57
|
+
* whole once it prints this word.
|
|
58
|
+
*/
|
|
59
|
+
export const PICTURE_TAKEN: "taken";
|
|
60
|
+
/** How many pages of a batch a picture script draws at once. */
|
|
61
|
+
export const PICTURE_PAGES_AT_ONCE: 3;
|
|
29
62
|
export const PICTURE_WINDOW: Readonly<{
|
|
30
63
|
width: 1280;
|
|
31
64
|
height: 900;
|
|
@@ -12,6 +12,84 @@
|
|
|
12
12
|
* lays out as the picture shows it.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* The script run on a page before its picture: each animation that ends (an
|
|
17
|
+
* overlay's fade-in) is run to its end, so the picture shows the part as it
|
|
18
|
+
* looks once it has played; each that loops (a skeleton's shimmer, a pulsing
|
|
19
|
+
* dot, a spinner) is held at the middle of its first round, a frame a person
|
|
20
|
+
* sees as it plays, never its first frame, where a part can be faint or gone.
|
|
21
|
+
*/
|
|
22
|
+
export const SETTLE_ANIMATIONS = `for (const a of document.getAnimations()) {
|
|
23
|
+
const t = a.effect?.getComputedTiming();
|
|
24
|
+
if (!t) continue;
|
|
25
|
+
if (t.iterations !== Infinity) { a.finish(); continue; }
|
|
26
|
+
a.pause();
|
|
27
|
+
a.currentTime = (Number(a.effect.getTiming().delay) || 0) + (typeof t.duration === 'number' ? t.duration : 0) / 2;
|
|
28
|
+
}`;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The script run before the picture: it waits until the page stops
|
|
32
|
+
* changing, so a part drawn over animation frames (a responsive chart's
|
|
33
|
+
* lines) is drawn whole. Quiet means no change to the document for
|
|
34
|
+
* QUIET_MS; it waits QUIET_MOST_MS at most.
|
|
35
|
+
*/
|
|
36
|
+
export const AWAIT_QUIET = `new Promise(resolve => {
|
|
37
|
+
const QUIET_MS = 300;
|
|
38
|
+
const QUIET_MOST_MS = 4000;
|
|
39
|
+
let timer = setTimeout(done, QUIET_MS);
|
|
40
|
+
const most = setTimeout(done, QUIET_MOST_MS);
|
|
41
|
+
const watch = new MutationObserver(() => {
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
timer = setTimeout(done, QUIET_MS);
|
|
44
|
+
});
|
|
45
|
+
watch.observe(document, {subtree: true, childList: true, attributes: true, characterData: true});
|
|
46
|
+
function done() {
|
|
47
|
+
watch.disconnect();
|
|
48
|
+
clearTimeout(timer);
|
|
49
|
+
clearTimeout(most);
|
|
50
|
+
resolve(true);
|
|
51
|
+
}
|
|
52
|
+
})`;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* How a picture script hands back a batch: each line it prints for a job
|
|
56
|
+
* starts with the job's place in the batch and a tab; a job's picture is
|
|
57
|
+
* whole once it prints this word.
|
|
58
|
+
*/
|
|
59
|
+
export const PICTURE_TAKEN = 'taken';
|
|
60
|
+
|
|
61
|
+
/** How many pages of a batch a picture script draws at once. */
|
|
62
|
+
export const PICTURE_PAGES_AT_ONCE = 3;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Run each job of a list in order, a few at a time. Once one fails, no
|
|
66
|
+
* other starts; the ones running finish, then the first failure is thrown,
|
|
67
|
+
* so every job before it has had its turn.
|
|
68
|
+
* @template T
|
|
69
|
+
* @param {T[]} jobs
|
|
70
|
+
* @param {number} atOnce
|
|
71
|
+
* @param {(job: T, i: number) => Promise<void>} run
|
|
72
|
+
*/
|
|
73
|
+
export async function eachAtOnce(jobs, atOnce, run) {
|
|
74
|
+
let next = 0;
|
|
75
|
+
/** @type {{error: unknown} | null} */
|
|
76
|
+
let failed = null;
|
|
77
|
+
await Promise.all(
|
|
78
|
+
Array.from({length: Math.min(atOnce, jobs.length)}, async () => {
|
|
79
|
+
while (!failed && next < jobs.length) {
|
|
80
|
+
const i = next++;
|
|
81
|
+
try {
|
|
82
|
+
await run(jobs[i], i);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
failed ??= {error};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}),
|
|
88
|
+
);
|
|
89
|
+
const first = /** @type {{error: unknown} | null} */ (failed);
|
|
90
|
+
if (first) throw first.error;
|
|
91
|
+
}
|
|
92
|
+
|
|
15
93
|
export const PICTURE_WINDOW = Object.freeze({width: 1280, height: 900});
|
|
16
94
|
|
|
17
95
|
/** The pointer of the window a picture is taken in. */
|
|
@@ -25,6 +25,34 @@ export function awaitHost(host: import("node:child_process").ChildProcess, { tim
|
|
|
25
25
|
withoutSegmenter: boolean;
|
|
26
26
|
stateFile?: string;
|
|
27
27
|
}): Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* The markup with each link out of the file opening in a new tab, as the
|
|
30
|
+
* file's script opens it once it runs (client-bundle.mjs): a viewer's frame
|
|
31
|
+
* cannot follow a link out. A link that names its own target keeps it.
|
|
32
|
+
* @param {string} markup the page's server markup
|
|
33
|
+
* @returns {string}
|
|
34
|
+
*/
|
|
35
|
+
export function linksOpenNewTabs(markup: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* The page's script with each string the markup's rewrite replaced (an
|
|
38
|
+
* image's `src`, `poster` or `srcset`, as the page wrote it) written as the
|
|
39
|
+
* same carried data, so the page the script draws shows what the first paint
|
|
40
|
+
* showed. Only a quoted string that is exactly that value changes, never a
|
|
41
|
+
* longer string that holds it.
|
|
42
|
+
* @param {string} script
|
|
43
|
+
* @param {Map<string, string>} rewrites
|
|
44
|
+
* @returns {string}
|
|
45
|
+
*/
|
|
46
|
+
export function withCarriedPaths(script: string, rewrites: Map<string, string>): string;
|
|
47
|
+
/**
|
|
48
|
+
* The script with each image the embedded source does not carry written in
|
|
49
|
+
* as its data: URI (`uriOf` gives it), so the image still shows once the
|
|
50
|
+
* script draws the page.
|
|
51
|
+
* @param {string} script
|
|
52
|
+
* @param {Set<string>} carried the SHA-256 of each file the source carries
|
|
53
|
+
* @param {(sha256: string, prefix: string) => string | null} uriOf
|
|
54
|
+
*/
|
|
55
|
+
export function withUncarriedImages(script: string, carried: Set<string>, uriOf: (sha256: string, prefix: string) => string | null): string;
|
|
28
56
|
/**
|
|
29
57
|
* The warning for a page rendered without Intl.Segmenter.
|
|
30
58
|
* @returns {RenderWarning}
|
|
@@ -67,16 +95,26 @@ export function assetRef(ref: string, at: {
|
|
|
67
95
|
/**
|
|
68
96
|
* Render a page module to one self-contained HTML file.
|
|
69
97
|
* @param {string} entry absolute path of the page module
|
|
70
|
-
* @param {{title?: string, timeoutMs?: number, version?: string, served?: ServedSet | null, output?: string, cwd?: string, openLayers?: boolean}} [options]
|
|
98
|
+
* @param {{title?: string, timeoutMs?: number, version?: string, served?: ServedSet | null, output?: string, cwd?: string, openLayers?: boolean, leaveLargeStyleAssets?: boolean, markupOnly?: boolean, esbuildFrom?: string}} [options]
|
|
71
99
|
* `served`: the Core of the package set the CLI runs from, for the packages
|
|
72
100
|
* the page's folder has no copy of; `output`: the file the HTML goes to;
|
|
73
101
|
* `cwd`: the current folder, whose files are the page's own outside a
|
|
74
102
|
* project; `openLayers`: the overlays the page shows or opens are drawn
|
|
75
|
-
* and added after its markup (layers.mjs), for reading what they paint
|
|
76
|
-
*
|
|
103
|
+
* and added after its markup (layers.mjs), for reading what they paint;
|
|
104
|
+
* `leaveLargeStyleAssets`: a stylesheet's file too large to inline is
|
|
105
|
+
* left out and named in the warnings, not refused (for a caller that
|
|
106
|
+
* names such files itself). With `output`, the file describes itself: notes at its top and end name
|
|
77
107
|
* what made it and the commands that give the page back and render it
|
|
78
108
|
* again, and its embedded source records the CLI version, the packages
|
|
79
|
-
* the page rendered with, and the markup as rendered.
|
|
109
|
+
* the page rendered with, and the markup as rendered. The file also
|
|
110
|
+
* carries the page's script (client-bundle.mjs): it draws the page over
|
|
111
|
+
* its markup in the browser, so the page's controls work. The markup sits
|
|
112
|
+
* in one element the script draws into, and the stylesheet keeps the rules
|
|
113
|
+
* any of the page's modules can use, not only the markup's. esbuild, a
|
|
114
|
+
* dependency of the CLI, builds the script (`esbuildFrom`: the folder it
|
|
115
|
+
* resolves from); a page whose script cannot be built fails the render.
|
|
116
|
+
* `markupOnly` renders the markup and its styles without the script, for a
|
|
117
|
+
* caller that shows the markup itself (the theme editor); it writes no file.
|
|
80
118
|
* @returns {Promise<RenderedPage>}
|
|
81
119
|
*/
|
|
82
120
|
export function renderPage(entry: string, options?: {
|
|
@@ -87,6 +125,9 @@ export function renderPage(entry: string, options?: {
|
|
|
87
125
|
output?: string;
|
|
88
126
|
cwd?: string;
|
|
89
127
|
openLayers?: boolean;
|
|
128
|
+
leaveLargeStyleAssets?: boolean;
|
|
129
|
+
markupOnly?: boolean;
|
|
130
|
+
esbuildFrom?: string;
|
|
90
131
|
}): Promise<RenderedPage>;
|
|
91
132
|
/** How long one page may take to render before it is stopped. */
|
|
92
133
|
export const RENDER_TIMEOUT_MS: 60000;
|
|
@@ -106,6 +147,8 @@ export const RENDER_TIMEOUT_MS: 60000;
|
|
|
106
147
|
* @property {number} images - Local files inlined as data: URIs.
|
|
107
148
|
* @property {RenderWarning[]} warnings
|
|
108
149
|
* @property {{name: string, dir: string}[]} fromSet - Packages that came from the package set the CLI runs from, not the page's folder.
|
|
150
|
+
* @property {number} [scriptBytes] - Bytes of the page's script; none in a markup-only render.
|
|
151
|
+
* @property {number} [scriptModules] - The modules the page's script holds; none in a markup-only render.
|
|
109
152
|
*/
|
|
110
153
|
/** An error carrying a render error code. */
|
|
111
154
|
export class RenderError extends Error {
|
|
@@ -171,6 +214,14 @@ export type RenderedPage = {
|
|
|
171
214
|
name: string;
|
|
172
215
|
dir: string;
|
|
173
216
|
}[];
|
|
217
|
+
/**
|
|
218
|
+
* - Bytes of the page's script; none in a markup-only render.
|
|
219
|
+
*/
|
|
220
|
+
scriptBytes?: number | undefined;
|
|
221
|
+
/**
|
|
222
|
+
* - The modules the page's script holds; none in a markup-only render.
|
|
223
|
+
*/
|
|
224
|
+
scriptModules?: number | undefined;
|
|
174
225
|
};
|
|
175
226
|
export type ServedSet = {
|
|
176
227
|
dir: string;
|