@astryxdesign/cli 0.7.17-canary.gffd1c8e → 0.7.17
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/CHANGELOG.md +1877 -0
- package/README.md +90 -85
- package/api/build/_adapter.d.mts +51 -0
- package/api/build/_adapter.mjs +133 -8
- package/api/build/build.doc.mjs +3 -3
- package/api/build/build.mjs +1 -1
- package/api/build/build.type.d.mts +1 -1
- package/api/build/build.type.mjs +2 -2
- package/api/build/help/help.d.mts +15 -14
- package/api/build/help/help.mjs +65 -6
- package/api/build/kit/kit.mjs +1 -1
- package/api/build/kit/start.mjs +1 -1
- package/api/component/_adapter.d.mts +28 -4
- package/api/component/_adapter.mjs +79 -45
- package/api/component/component.d.mts +1 -1
- package/api/component/component.mjs +18 -7
- package/api/component/detail/blocks/blocks.mjs +1 -2
- package/api/component/detail/showcase/showcase.mjs +19 -8
- package/api/discover/_adapter.d.mts +68 -5
- package/api/discover/_adapter.mjs +311 -63
- package/api/discover/_catalog-view.d.mts +22 -0
- package/api/discover/_catalog-view.mjs +30 -1
- package/api/discover/_icon-set-coverage.d.mts +22 -0
- package/api/discover/_icon-set-coverage.mjs +32 -0
- package/api/discover/detail/detail.d.mts +6 -3
- package/api/discover/detail/detail.mjs +14 -6
- package/api/discover/detail/doc/doc.mjs +1 -1
- package/api/discover/detail/item/item.d.mts +11 -1
- package/api/discover/detail/item/item.mjs +29 -8
- package/api/discover/discover.d.mts +36 -0
- package/api/discover/discover.doc.mjs +1 -1
- package/api/discover/discover.mjs +205 -28
- package/api/discover/discover.type.d.mts +33 -7
- package/api/discover/discover.type.mjs +21 -7
- package/api/discover/search/search.d.mts +22 -0
- package/api/discover/search/search.mjs +293 -70
- package/api/docs/_adapter.d.mts +92 -1
- package/api/docs/_adapter.mjs +264 -14
- package/api/docs/docs.d.mts +4 -2
- package/api/docs/docs.doc.mjs +10 -0
- package/api/docs/docs.mjs +25 -5
- package/api/docs/docs.type.d.mts +48 -0
- package/api/docs/docs.type.mjs +26 -0
- package/api/docs/skills/skills.d.mts +51 -0
- package/api/docs/skills/skills.mjs +216 -0
- package/api/doctor/_adapter.d.mts +254 -9
- package/api/doctor/_adapter.mjs +1228 -50
- package/api/doctor/built-checks.d.mts +39 -3
- package/api/doctor/built-checks.mjs +203 -7
- package/api/doctor/doctor.d.mts +205 -4
- package/api/doctor/doctor.doc.mjs +4 -4
- package/api/doctor/doctor.mjs +962 -22
- package/api/doctor/doctor.type.d.mts +6 -1
- package/api/doctor/doctor.type.mjs +3 -1
- package/api/doctor/theme-checks.d.mts +20 -1
- package/api/doctor/theme-checks.mjs +280 -8
- package/api/error.d.mts +12 -1
- package/api/error.mjs +18 -6
- package/api/icon/_adapter.d.mts +11 -1
- package/api/icon/_adapter.mjs +22 -1
- package/api/icon/_authoring.mjs +21 -7
- package/api/icon/add/add.mjs +1 -1
- package/api/icon/definitions/definitions.mjs +19 -8
- package/api/icon/icon.doc.mjs +3 -3
- package/api/icon/icon.type.d.mts +49 -2
- package/api/icon/icon.type.mjs +23 -4
- package/api/icon/iconMap.doc.mjs +2 -2
- package/api/icon/list/list.mjs +4 -5
- package/api/icon/map/map.mjs +13 -4
- package/api/icon/search/icon-index.mjs +4 -1
- package/api/icon/search/search.d.mts +28 -7
- package/api/icon/search/search.mjs +177 -26
- package/api/init/_adapter.d.mts +87 -3
- package/api/init/_adapter.mjs +264 -16
- package/api/init/init.d.mts +2 -2
- package/api/init/init.doc.mjs +29 -5
- package/api/init/init.mjs +149 -10
- package/api/init/init.type.d.mts +75 -9
- package/api/init/init.type.mjs +32 -4
- package/api/init/remove/remove.d.mts +7 -4
- package/api/init/remove/remove.mjs +124 -26
- package/api/init/run/run.d.mts +38 -3
- package/api/init/run/run.mjs +366 -39
- package/api/integration/_adapter.d.mts +16 -0
- package/api/integration/_adapter.mjs +45 -1
- package/api/integration/integrationCheck.doc.mjs +1 -1
- package/api/integration/pack-check.d.mts +2 -1
- package/api/integration/pack-check.mjs +10 -18
- package/api/integration/validate-integration.d.mts +5 -2
- package/api/integration/validate-integration.mjs +81 -14
- package/api/integration/validate-integration.type.d.mts +9 -4
- package/api/integration/validate-integration.type.mjs +9 -4
- package/api/integration/validateIntegration.doc.mjs +4 -2
- package/api/render/_adapter.d.mts +6 -2
- package/api/render/_adapter.mjs +301 -51
- package/api/render/render.doc.d.mts +1 -1
- package/api/render/render.doc.mjs +20 -10
- package/api/render/render.mjs +16 -13
- package/api/render/render.type.d.mts +57 -10
- package/api/render/render.type.mjs +26 -13
- package/api/search/ORDERING.md +3 -3
- package/api/search/_adapter.d.mts +31 -0
- package/api/search/_adapter.mjs +107 -15
- package/api/search/_candidate-score.d.mts +12 -4
- package/api/search/_candidate-score.mjs +94 -16
- package/api/search/_cards.json +4 -1
- package/api/search/_entries.d.mts +8 -3
- package/api/search/_entries.mjs +109 -12
- package/api/search/_fit-order.d.mts +8 -4
- package/api/search/_fit-order.mjs +35 -7
- package/api/search/_gather-docs.mjs +71 -28
- package/api/search/_gather-templates.mjs +7 -2
- package/api/search/_icons.d.mts +50 -0
- package/api/search/_icons.mjs +85 -0
- package/api/search/_lexical.d.mts +14 -1
- package/api/search/_lexical.mjs +240 -12
- package/api/search/_main-searcher.mjs +1 -1
- package/api/search/_named-keywords.d.mts +6 -3
- package/api/search/_named-keywords.mjs +70 -19
- package/api/search/_order.d.mts +27 -12
- package/api/search/_order.mjs +132 -51
- package/api/search/_result.d.mts +30 -0
- package/api/search/_result.mjs +38 -0
- package/api/search/_score.d.mts +20 -6
- package/api/search/_score.mjs +96 -16
- package/api/search/_titles.d.mts +14 -0
- package/api/search/_titles.mjs +16 -3
- package/api/search/_words.d.mts +8 -0
- package/api/search/_words.mjs +26 -1
- package/api/search/search-index.mjs +23 -12
- package/api/search/search.d.mts +3 -1
- package/api/search/search.doc.mjs +5 -4
- package/api/search/search.mjs +69 -26
- package/api/search/search.type.d.mts +55 -1
- package/api/search/search.type.mjs +35 -1
- package/api/swizzle/_adapter.d.mts +1 -1
- package/api/swizzle/_adapter.mjs +1 -5
- package/api/swizzle/_moduleGraph.d.mts +0 -6
- package/api/swizzle/_moduleGraph.mjs +0 -12
- package/api/swizzle/copy/copy.mjs +1 -1
- package/api/template/_adapter.d.mts +46 -0
- package/api/template/_adapter.mjs +198 -2
- package/api/template/cdn/cdn.mjs +5 -3
- package/api/template/copy/copy.d.mts +12 -2
- package/api/template/copy/copy.mjs +95 -21
- package/api/template/list/list.mjs +1 -2
- package/api/template/show/show.d.mts +10 -3
- package/api/template/show/show.mjs +17 -6
- package/api/template/skeleton/skeleton.mjs +1 -2
- package/api/template/template.doc.mjs +3 -3
- package/api/template/template.mjs +37 -7
- package/api/template/template.type.d.mts +3 -0
- package/api/template/template.type.mjs +5 -2
- package/api/theme/_adapter.d.mts +28 -2
- package/api/theme/_adapter.mjs +675 -17
- package/api/theme/_app-provider.d.mts +42 -0
- package/api/theme/_app-provider.mjs +61 -27
- package/api/theme/_shared-source.d.mts +33 -0
- package/api/theme/_shared-source.mjs +348 -0
- package/api/theme/add/add.d.mts +3 -0
- package/api/theme/add/add.mjs +21 -4
- package/api/theme/build/build.d.mts +57 -30
- package/api/theme/build/build.mjs +403 -441
- package/api/theme/build/core-interception.d.mts +10 -0
- package/api/theme/build/core-interception.mjs +24 -0
- package/api/theme/build/family.mjs +4 -2
- package/api/theme/build/import-specifier.d.mts +14 -0
- package/api/theme/build/import-specifier.mjs +36 -0
- package/api/theme/build/null-values.d.mts +22 -0
- package/api/theme/build/null-values.mjs +110 -21
- package/api/theme/build/self-contained.mjs +32 -11
- package/api/theme/build/setting-effects.d.mts +254 -0
- package/api/theme/build/setting-effects.mjs +1065 -0
- package/api/theme/build/style-keys.d.mts +33 -0
- package/api/theme/build/style-keys.mjs +154 -0
- package/api/theme/build/theme-object.d.mts +47 -0
- package/api/theme/build/theme-object.mjs +144 -0
- package/api/theme/eject/eject.mjs +6 -1
- package/api/theme/palette/generate/color.d.mts +41 -9
- package/api/theme/palette/generate/color.mjs +108 -39
- package/api/theme/palette/generate/generate.mjs +10 -0
- package/api/theme/palette/generate/generator.d.mts +45 -27
- package/api/theme/palette/generate/generator.mjs +330 -156
- package/api/theme/palette/generate/mapping.d.mts +456 -0
- package/api/theme/palette/generate/mapping.mjs +1903 -0
- package/api/theme/palette/generate/newer-recipe.d.mts +28 -0
- package/api/theme/palette/generate/newer-recipe.mjs +87 -0
- package/api/theme/palette/generate/types.d.mts +270 -0
- package/api/theme/palette/generate/types.mjs +123 -0
- package/api/theme/theme.d.mts +25 -4
- package/api/theme/theme.mjs +55 -5
- package/api/theme/theme.type.d.mts +71 -2
- package/api/theme/theme.type.mjs +37 -5
- package/api/theme/themeAdd.doc.mjs +3 -2
- package/api/theme/themeBuild.doc.mjs +3 -3
- package/api/theme/themeEject.doc.mjs +1 -1
- package/api/theme/themeRemove.doc.mjs +1 -1
- package/api/theme/themeTargets.doc.mjs +1 -1
- package/api/theme-edit/_catalog.mjs +1 -1
- package/api/theme-edit/_check.mjs +129 -45
- package/api/theme-edit/_color.d.mts +2 -74
- package/api/theme-edit/_color.mjs +33 -869
- package/api/theme-edit/_context.d.mts +3 -1
- package/api/theme-edit/_context.mjs +16 -3
- package/api/theme-edit/_css.d.mts +4 -35
- package/api/theme-edit/_css.mjs +10 -91
- package/api/theme-edit/_edit.mjs +244 -32
- package/api/theme-edit/_how-question.d.mts +1 -0
- package/api/theme-edit/_how-question.mjs +1188 -52
- package/api/theme-edit/_how.mjs +19 -3
- package/api/theme-edit/_missed.d.mts +2 -1
- package/api/theme-edit/_missed.mjs +21 -2
- package/api/theme-edit/_normal.d.mts +5 -2
- package/api/theme-edit/_normal.mjs +11 -1
- package/api/theme-edit/_palette.d.mts +26 -75
- package/api/theme-edit/_palette.mjs +242 -1384
- package/api/theme-edit/_part-words.mjs +13 -3
- package/api/theme-edit/_parts.d.mts +8 -2
- package/api/theme-edit/_parts.mjs +56 -11
- package/api/theme-edit/_preview-app.d.mts +16 -0
- package/api/theme-edit/_preview-app.mjs +47 -15
- package/api/theme-edit/_preview.mjs +49 -22
- package/api/theme-edit/_project.d.mts +14 -2
- package/api/theme-edit/_project.mjs +25 -3
- package/api/theme-edit/_settings.d.mts +3 -2
- package/api/theme-edit/_settings.mjs +166 -45
- package/api/theme-edit/_tables.d.mts +3 -11
- package/api/theme-edit/_tables.mjs +21 -33
- package/api/theme-edit/theme-edit.type.d.mts +7 -1
- package/api/theme-edit/theme-edit.type.mjs +3 -2
- package/api/upgrade/_adapter.d.mts +38 -0
- package/api/upgrade/_adapter.mjs +274 -3
- package/api/upgrade/run/run.mjs +4 -0
- package/api/upgrade/upgrade.mjs +1 -1
- package/api/upgrade/upgrade.type.d.mts +46 -7
- package/api/upgrade/upgrade.type.mjs +24 -9
- package/assets/codemods/registry.mjs +1 -0
- package/assets/codemods/transforms/next/index.mjs +1 -11
- package/assets/codemods/transforms/v0.7.17/index.mjs +28 -0
- package/assets/codemods/transforms/v0.7.17/migrate-item-swipe-actions-to-swipe.mjs +2160 -0
- package/assets/codemods/transforms/v0.7.17/preserve-chat-radius.mjs +515 -0
- package/assets/component-list.generated.json +1 -1
- package/assets/discover/official-packages.json +72 -0
- package/assets/docs/author-a-theme.doc.mjs +7 -4
- package/assets/docs/getting-started.doc.mjs +1 -1
- package/assets/docs/principles.doc.dense.mjs +1 -1
- package/assets/docs/principles.doc.mjs +1 -1
- package/assets/docs/principles.doc.zh.mjs +1 -1
- package/assets/docs/styling-overview.doc.mjs +5 -1
- package/assets/docs/tree/agent-guidance.doc.mjs +33 -2
- package/assets/docs/tree/check-the-props.doc.mjs +1 -1
- package/assets/docs/tree/checks.doc.mjs +1 -1
- package/assets/docs/tree/computer-integrations.doc.mjs +1 -1
- package/assets/docs/tree/doc-syntax.doc.mjs +1 -1
- package/assets/docs/tree/export-pages.doc.mjs +164 -0
- package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
- package/assets/docs/tree/host-entry.doc.mjs +4 -0
- package/assets/docs/tree/i18n-library-integration.doc.mjs +7 -3
- package/assets/docs/tree/icon-sets.doc.mjs +85 -9
- package/assets/docs/tree/layout.doc.mjs +16 -5
- package/assets/docs/tree/problems.doc.mjs +2 -2
- package/assets/docs/tree/responsive.doc.mjs +2 -2
- package/assets/docs/tree/scaffold.doc.mjs +1 -0
- package/assets/docs/tree/share-a-page.doc.mjs +14 -16
- package/assets/docs/tree/skill-places.doc.mjs +91 -0
- package/assets/docs/tree/styling.doc.mjs +41 -3
- package/assets/docs/tree/template-grading-rubric.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/tokens-and-setup.doc.mjs +2 -4
- package/assets/docs/tree/tokens-color.doc.mjs +2 -2
- package/assets/docs/tree/tokens-radius.doc.mjs +1 -1
- package/assets/docs/tree/tokens.doc.mjs +32 -0
- package/assets/docs/tree/troubleshooting.doc.mjs +8 -0
- package/assets/docs/tree/typography.doc.mjs +31 -2
- package/assets/docs/use-a-theme.doc.mjs +4 -0
- package/assets/docs/working-with-ai.doc.mjs +4 -4
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/icons/definitions/alert.doc.mjs +9 -0
- package/assets/icons/definitions/alignBottom.doc.mjs +1 -0
- package/assets/icons/definitions/alignCenter.doc.mjs +1 -0
- package/assets/icons/definitions/alignEnd.doc.mjs +1 -0
- package/assets/icons/definitions/alignJustify.doc.mjs +1 -0
- package/assets/icons/definitions/alignMiddle.doc.mjs +1 -0
- package/assets/icons/definitions/alignStart.doc.mjs +1 -0
- package/assets/icons/definitions/alignTop.doc.mjs +1 -0
- package/assets/icons/definitions/arrowDown.doc.mjs +1 -0
- package/assets/icons/definitions/arrowLeft.doc.mjs +1 -0
- package/assets/icons/definitions/arrowRight.doc.mjs +1 -0
- package/assets/icons/definitions/arrowUp.doc.mjs +1 -0
- package/assets/icons/definitions/arrowsUpDown.doc.mjs +1 -0
- package/assets/icons/definitions/bank.doc.mjs +1 -0
- package/assets/icons/definitions/block.doc.mjs +9 -0
- package/assets/icons/definitions/bold.doc.mjs +1 -0
- package/assets/icons/definitions/bookmark.doc.mjs +1 -0
- package/assets/icons/definitions/bookmarkAdd.doc.mjs +1 -0
- package/assets/icons/definitions/cart.doc.mjs +1 -0
- package/assets/icons/definitions/channel.doc.mjs +9 -0
- package/assets/icons/definitions/check.doc.mjs +1 -0
- package/assets/icons/definitions/checkDouble.doc.mjs +1 -0
- package/assets/icons/definitions/checklist.doc.mjs +9 -0
- package/assets/icons/definitions/chevronDown.doc.mjs +1 -0
- package/assets/icons/definitions/chevronLeft.doc.mjs +1 -0
- package/assets/icons/definitions/chevronRight.doc.mjs +1 -0
- package/assets/icons/definitions/chevronUp.doc.mjs +1 -0
- package/assets/icons/definitions/chevronsLeft.doc.mjs +1 -0
- package/assets/icons/definitions/chevronsRight.doc.mjs +1 -0
- package/assets/icons/definitions/clipboard.doc.mjs +1 -0
- package/assets/icons/definitions/cloud.doc.mjs +1 -1
- package/assets/icons/definitions/collapse.doc.mjs +1 -0
- package/assets/icons/definitions/columnSettings.doc.mjs +9 -0
- package/assets/icons/definitions/compose.doc.mjs +1 -0
- package/assets/icons/definitions/conversation.doc.mjs +1 -0
- package/assets/icons/definitions/copy.doc.mjs +1 -0
- package/assets/icons/definitions/copyText.doc.mjs +9 -0
- package/assets/icons/definitions/cornerRadius.doc.mjs +1 -0
- package/assets/icons/definitions/create.doc.mjs +9 -0
- package/assets/icons/definitions/creditCard.doc.mjs +1 -0
- package/assets/icons/definitions/currency.doc.mjs +9 -0
- package/assets/icons/definitions/cut.doc.mjs +1 -0
- package/assets/icons/definitions/desktop.doc.mjs +1 -0
- package/assets/icons/definitions/discount.doc.mjs +1 -0
- package/assets/icons/definitions/document.doc.mjs +1 -0
- package/assets/icons/definitions/documentSearch.doc.mjs +1 -0
- package/assets/icons/definitions/download.doc.mjs +1 -0
- package/assets/icons/definitions/error.doc.mjs +1 -0
- package/assets/icons/definitions/exitFullScreen.doc.mjs +16 -0
- package/assets/icons/definitions/expand.doc.mjs +1 -0
- package/assets/icons/definitions/eye.doc.mjs +1 -0
- package/assets/icons/definitions/eyeSlash.doc.mjs +1 -0
- package/assets/icons/definitions/file.doc.mjs +1 -0
- package/assets/icons/definitions/flipHorizontal.doc.mjs +1 -0
- package/assets/icons/definitions/flipVertical.doc.mjs +1 -0
- package/assets/icons/definitions/folder.doc.mjs +1 -0
- package/assets/icons/definitions/folderAdd.doc.mjs +1 -0
- package/assets/icons/definitions/fullScreen.doc.mjs +16 -0
- package/assets/icons/definitions/globe.doc.mjs +1 -1
- package/assets/icons/definitions/groupRows.doc.mjs +9 -0
- package/assets/icons/definitions/halftone.doc.mjs +9 -0
- package/assets/icons/definitions/help.doc.mjs +9 -0
- package/assets/icons/definitions/house.doc.mjs +9 -0
- package/assets/icons/definitions/info.doc.mjs +1 -0
- package/assets/icons/definitions/italic.doc.mjs +1 -0
- package/assets/icons/definitions/listView.doc.mjs +9 -0
- package/assets/icons/definitions/lock.doc.mjs +1 -0
- package/assets/icons/definitions/lowercase.doc.mjs +1 -0
- package/assets/icons/definitions/mail.doc.mjs +1 -1
- package/assets/icons/definitions/media.doc.mjs +9 -0
- package/assets/icons/definitions/message.doc.mjs +2 -1
- package/assets/icons/definitions/mobile.doc.mjs +1 -0
- package/assets/icons/definitions/money.doc.mjs +1 -0
- package/assets/icons/definitions/moon.doc.mjs +1 -0
- package/assets/icons/definitions/moveToFolder.doc.mjs +9 -0
- package/assets/icons/definitions/notification.doc.mjs +1 -0
- package/assets/icons/definitions/notificationActive.doc.mjs +1 -0
- package/assets/icons/definitions/notificationOff.doc.mjs +1 -0
- package/assets/icons/definitions/paddingHorizontal.doc.mjs +1 -0
- package/assets/icons/definitions/paddingPerSide.doc.mjs +1 -0
- package/assets/icons/definitions/paddingVertical.doc.mjs +1 -0
- package/assets/icons/definitions/panelBottom.doc.mjs +1 -0
- package/assets/icons/definitions/panelLeft.doc.mjs +1 -0
- package/assets/icons/definitions/panelRight.doc.mjs +1 -0
- package/assets/icons/definitions/paste.doc.mjs +9 -0
- package/assets/icons/definitions/pause.doc.mjs +1 -0
- package/assets/icons/definitions/play.doc.mjs +1 -0
- package/assets/icons/definitions/radiusPerCorner.doc.mjs +1 -0
- package/assets/icons/definitions/redo.doc.mjs +1 -0
- package/assets/icons/definitions/review.doc.mjs +9 -0
- package/assets/icons/definitions/rotate.doc.mjs +1 -0
- package/assets/icons/definitions/rotateCounterclockwise.doc.mjs +1 -0
- package/assets/icons/definitions/scale.doc.mjs +1 -2
- package/assets/icons/definitions/schedule.doc.mjs +9 -0
- package/assets/icons/definitions/search.doc.mjs +1 -0
- package/assets/icons/definitions/send.doc.mjs +1 -0
- package/assets/icons/definitions/shoppingBag.doc.mjs +1 -0
- package/assets/icons/definitions/signal.doc.mjs +9 -0
- package/assets/icons/definitions/stop.doc.mjs +1 -0
- package/assets/icons/definitions/strikethrough.doc.mjs +1 -0
- package/assets/icons/definitions/success.doc.mjs +1 -0
- package/assets/icons/definitions/sun.doc.mjs +1 -0
- package/assets/icons/definitions/tablet.doc.mjs +1 -0
- package/assets/icons/definitions/team.doc.mjs +9 -0
- package/assets/icons/definitions/textCase.doc.mjs +2 -1
- package/assets/icons/definitions/textRegular.doc.mjs +1 -0
- package/assets/icons/definitions/thumbsDown.doc.mjs +1 -0
- package/assets/icons/definitions/thumbsUp.doc.mjs +1 -0
- package/assets/icons/definitions/transfer.doc.mjs +1 -0
- package/assets/icons/definitions/trendDown.doc.mjs +1 -0
- package/assets/icons/definitions/trendUp.doc.mjs +1 -0
- package/assets/icons/definitions/underline.doc.mjs +1 -0
- package/assets/icons/definitions/undo.doc.mjs +1 -0
- package/assets/icons/definitions/unlock.doc.mjs +1 -0
- package/assets/icons/definitions/upload.doc.mjs +1 -0
- package/assets/icons/definitions/uppercase.doc.mjs +1 -0
- package/assets/icons/definitions/user.doc.mjs +1 -0
- package/assets/icons/definitions/userAdd.doc.mjs +1 -0
- package/assets/icons/definitions/userCircle.doc.mjs +1 -0
- package/assets/icons/definitions/userRemove.doc.mjs +1 -0
- package/assets/icons/definitions/users.doc.mjs +1 -0
- package/assets/icons/definitions/verified.doc.mjs +9 -0
- package/assets/icons/definitions/wallet.doc.mjs +1 -0
- package/assets/icons/definitions/warning.doc.mjs +1 -0
- package/assets/icons/definitions/wrench.doc.mjs +1 -1
- package/assets/icons/template-icons.json +661 -0
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/AppShell/AppShellShowcase.doc.mjs +0 -7
- package/assets/templates/blocks/components/AppShell/AppShellShowcase.tsx +8 -10
- package/assets/templates/blocks/components/AppShell/AppShellSideNavOnly.doc.mjs +0 -8
- package/assets/templates/blocks/components/AppShell/AppShellSideNavOnly.tsx +10 -8
- package/assets/templates/blocks/components/AppShell/AppShellTopNavOnly.doc.mjs +0 -1
- package/assets/templates/blocks/components/AppShell/AppShellTopNavOnly.tsx +4 -2
- package/assets/templates/blocks/components/AppShell/AppShellTopNavWithSideNav.doc.mjs +0 -8
- package/assets/templates/blocks/components/AppShell/AppShellTopNavWithSideNav.tsx +10 -8
- package/assets/templates/blocks/components/AppShell/AppShellWithBanner.doc.mjs +0 -8
- package/assets/templates/blocks/components/AppShell/AppShellWithBanner.tsx +10 -8
- package/assets/templates/blocks/components/AspectRatio/AspectRatioImageGallery.tsx +1 -1
- package/assets/templates/blocks/components/AspectRatio/AspectRatioWidescreen.tsx +1 -1
- package/assets/templates/blocks/components/AspectRatio/AspectRatioWithSkeleton.tsx +1 -1
- package/assets/templates/blocks/components/Avatar/AvatarInteractive.tsx +6 -1
- package/assets/templates/blocks/components/Avatar/AvatarShowcase.tsx +1 -1
- package/assets/templates/blocks/components/Avatar/AvatarTooltip.tsx +1 -1
- package/assets/templates/blocks/components/Avatar/AvatarWithStatus.tsx +1 -1
- package/assets/templates/blocks/components/AvatarStatusDot/AvatarStatusDotShowcase.tsx +1 -1
- package/assets/templates/blocks/components/AvatarStatusDot/AvatarStatusDotVariants.tsx +1 -1
- package/assets/templates/blocks/components/Badge/BadgeShowcase.tsx +2 -2
- package/assets/templates/blocks/components/Banner/BannerCollapsibleContent.tsx +14 -1
- package/assets/templates/blocks/components/Banner/BannerSectionVariant.tsx +10 -1
- package/assets/templates/blocks/components/Banner/BannerWithActionButton.tsx +25 -3
- package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.doc.mjs +0 -1
- package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.tsx +2 -2
- package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadMenu.doc.mjs +0 -1
- package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadMenu.tsx +1 -1
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSnapPoints.doc.mjs +0 -8
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSnapPoints.tsx +5 -5
- package/assets/templates/blocks/components/BreadcrumbItem/BreadcrumbItemShowcase.doc.mjs +0 -1
- package/assets/templates/blocks/components/BreadcrumbItem/BreadcrumbItemShowcase.tsx +1 -1
- package/assets/templates/blocks/components/Breadcrumbs/BreadcrumbsDeepHierarchy.doc.mjs +0 -1
- package/assets/templates/blocks/components/Breadcrumbs/BreadcrumbsDeepHierarchy.tsx +1 -1
- package/assets/templates/blocks/components/Breadcrumbs/BreadcrumbsWithIcons.doc.mjs +0 -1
- package/assets/templates/blocks/components/Breadcrumbs/BreadcrumbsWithIcons.tsx +2 -2
- package/assets/templates/blocks/components/Button/ButtonFloating.doc.mjs +0 -1
- package/assets/templates/blocks/components/Button/ButtonFloating.tsx +25 -2
- package/assets/templates/blocks/components/Button/ButtonShowcase.tsx +42 -4
- package/assets/templates/blocks/components/Button/ButtonSizeVariants.tsx +24 -2
- package/assets/templates/blocks/components/Button/ButtonVariants.tsx +28 -1
- package/assets/templates/blocks/components/Button/ButtonWithEndSlot.tsx +9 -0
- package/assets/templates/blocks/components/Button/ButtonWithIcon.doc.mjs +0 -6
- package/assets/templates/blocks/components/Button/ButtonWithIcon.tsx +35 -9
- package/assets/templates/blocks/components/ButtonGroup/ButtonGroupBasic.tsx +20 -3
- package/assets/templates/blocks/components/ButtonGroup/ButtonGroupFloating.tsx +16 -3
- package/assets/templates/blocks/components/ButtonGroup/ButtonGroupShowcase.doc.mjs +0 -6
- package/assets/templates/blocks/components/ButtonGroup/ButtonGroupShowcase.tsx +37 -8
- package/assets/templates/blocks/components/Center/CenterHorizontal.doc.mjs +0 -8
- package/assets/templates/blocks/components/Center/CenterHorizontal.tsx +23 -5
- package/assets/templates/blocks/components/Center/CenterInsideACard.doc.mjs +0 -1
- package/assets/templates/blocks/components/Center/CenterInsideACard.tsx +1 -1
- package/assets/templates/blocks/components/ChatComposer/ChatComposerFlat.doc.mjs +0 -5
- package/assets/templates/blocks/components/ChatComposer/ChatComposerFlat.tsx +8 -3
- package/assets/templates/blocks/components/ChatComposer/ChatComposerFooterActions.doc.mjs +0 -5
- package/assets/templates/blocks/components/ChatComposer/ChatComposerFooterActions.tsx +8 -3
- package/assets/templates/blocks/components/ChatComposer/ChatComposerFullFeatured.doc.mjs +0 -7
- package/assets/templates/blocks/components/ChatComposer/ChatComposerFullFeatured.tsx +10 -7
- package/assets/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerShowcase.doc.mjs +0 -1
- package/assets/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerShowcase.tsx +2 -2
- package/assets/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerWithProgress.doc.mjs +0 -1
- package/assets/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerWithProgress.tsx +3 -3
- package/assets/templates/blocks/components/ChatMessageMetadata/ChatMessageMetadataFooter.doc.mjs +0 -6
- package/assets/templates/blocks/components/ChatMessageMetadata/ChatMessageMetadataFooter.tsx +9 -9
- package/assets/templates/blocks/components/ChatMessageMetadata/ChatMessageMetadataShowcase.doc.mjs +0 -6
- package/assets/templates/blocks/components/ChatMessageMetadata/ChatMessageMetadataShowcase.tsx +10 -10
- package/assets/templates/blocks/components/ChatSendButton/ChatSendButtonCustomIcon.doc.mjs +0 -6
- package/assets/templates/blocks/components/ChatSendButton/ChatSendButtonCustomIcon.tsx +8 -5
- package/assets/templates/blocks/components/ChatSendButton/ChatSendButtonShowcase.doc.mjs +0 -1
- package/assets/templates/blocks/components/ChatSendButton/ChatSendButtonShowcase.tsx +1 -1
- package/assets/templates/blocks/components/ChatSystemMessage/ChatSystemMessageStatusUpdates.doc.mjs +0 -5
- package/assets/templates/blocks/components/ChatSystemMessage/ChatSystemMessageStatusUpdates.tsx +7 -7
- package/assets/templates/blocks/components/ChatSystemMessage/ChatSystemMessageWithIcon.doc.mjs +0 -6
- package/assets/templates/blocks/components/ChatSystemMessage/ChatSystemMessageWithIcon.tsx +7 -7
- package/assets/templates/blocks/components/ContextMenu/ContextMenuBottomSheet.doc.mjs +0 -6
- package/assets/templates/blocks/components/ContextMenu/ContextMenuBottomSheet.tsx +7 -7
- package/assets/templates/blocks/components/DropdownMenu/DropdownMenuBottomSheet.doc.mjs +0 -6
- package/assets/templates/blocks/components/DropdownMenu/DropdownMenuBottomSheet.tsx +7 -7
- package/assets/templates/blocks/components/DropdownMenu/DropdownMenuNoChevron.doc.mjs +0 -1
- package/assets/templates/blocks/components/DropdownMenu/DropdownMenuNoChevron.tsx +2 -2
- package/assets/templates/blocks/components/EmptyState/EmptyStateActions.doc.mjs +0 -1
- package/assets/templates/blocks/components/EmptyState/EmptyStateActions.tsx +2 -2
- package/assets/templates/blocks/components/EmptyState/EmptyStateCompact.doc.mjs +0 -1
- package/assets/templates/blocks/components/EmptyState/EmptyStateCompact.tsx +1 -1
- package/assets/templates/blocks/components/EmptyState/EmptyStateContainer.doc.mjs +0 -1
- package/assets/templates/blocks/components/EmptyState/EmptyStateContainer.tsx +2 -2
- package/assets/templates/blocks/components/EmptyState/EmptyStateShowcase.doc.mjs +0 -1
- package/assets/templates/blocks/components/EmptyState/EmptyStateShowcase.tsx +2 -2
- package/assets/templates/blocks/components/Grid/GridShowcase.tsx +1 -1
- package/assets/templates/blocks/components/GridSpan/GridSpanColumns.tsx +1 -1
- package/assets/templates/blocks/components/GridSpan/GridSpanShowcase.tsx +1 -1
- package/assets/templates/blocks/components/Heading/HeadingTruncation.tsx +3 -2
- package/assets/templates/blocks/components/Hooks/useClipboardHookUsage.tsx +1 -1
- package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.doc.mjs +0 -1
- package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +38 -19
- package/assets/templates/blocks/components/Hooks/useGridFocusHookUsage.tsx +6 -6
- package/assets/templates/blocks/components/Hooks/useHotkeysHookUsage.tsx +1 -1
- package/assets/templates/blocks/components/Hooks/useInputContainerHookUsage.doc.mjs +0 -1
- package/assets/templates/blocks/components/Hooks/useInputContainerHookUsage.tsx +2 -2
- package/assets/templates/blocks/components/Hooks/useKeyboardHintHookUsage.doc.mjs +0 -1
- package/assets/templates/blocks/components/Hooks/useKeyboardHintHookUsage.tsx +2 -2
- package/assets/templates/blocks/components/Hooks/useListFocusHookUsage.tsx +8 -1
- package/assets/templates/blocks/components/Hooks/useOverflowHookUsage.tsx +17 -6
- package/assets/templates/blocks/components/Hooks/useStreamingTextHookUsage.tsx +1 -1
- package/assets/templates/blocks/components/Hooks/useTreeFocusHookUsage.doc.mjs +0 -1
- package/assets/templates/blocks/components/Hooks/useTreeFocusHookUsage.tsx +1 -1
- package/assets/templates/blocks/components/HoverCard/HoverCardInteractiveContent.doc.mjs +0 -1
- package/assets/templates/blocks/components/HoverCard/HoverCardInteractiveContent.tsx +1 -1
- package/assets/templates/blocks/components/HoverCard/HoverCardProfileHoverCard.doc.mjs +0 -1
- package/assets/templates/blocks/components/HoverCard/HoverCardProfileHoverCard.tsx +1 -1
- package/assets/templates/blocks/components/Icon/useIconHookUsage.doc.mjs +0 -5
- package/assets/templates/blocks/components/Icon/useIconHookUsage.tsx +7 -7
- package/assets/templates/blocks/components/IconButton/IconButtonActionBar.tsx +11 -0
- package/assets/templates/blocks/components/IconButton/IconButtonFloating.doc.mjs +0 -1
- package/assets/templates/blocks/components/IconButton/IconButtonFloating.tsx +25 -2
- package/assets/templates/blocks/components/IconButton/IconButtonShowcase.tsx +3 -0
- package/assets/templates/blocks/components/IconButton/IconButtonTooltipIconButton.tsx +5 -0
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.doc.mjs +3 -3
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.tsx +36 -13
- package/assets/templates/blocks/components/Item/ItemDocumentTabs.doc.mjs +0 -1
- package/assets/templates/blocks/components/Item/ItemDocumentTabs.tsx +4 -4
- package/assets/templates/blocks/components/Item/ItemShowcase.doc.mjs +0 -1
- package/assets/templates/blocks/components/Item/ItemShowcase.tsx +7 -3
- package/assets/templates/blocks/components/Layout/LayoutBasicCardLayout.tsx +14 -2
- package/assets/templates/blocks/components/Layout/LayoutContentWidth.tsx +14 -2
- package/assets/templates/blocks/components/Layout/LayoutFullBleedContent.tsx +8 -1
- package/assets/templates/blocks/components/Layout/LayoutShowcase.tsx +8 -1
- package/assets/templates/blocks/components/Layout/LayoutSidebarLayout.tsx +14 -2
- package/assets/templates/blocks/components/LinkProvider/LinkProviderCustomLink.tsx +3 -1
- package/assets/templates/blocks/components/Markdown/MarkdownShowcase.tsx +1 -1
- package/assets/templates/blocks/components/MediaTheme/MediaThemeImageOverlay.tsx +18 -4
- package/assets/templates/blocks/components/MediaTheme/MediaThemeLightScrim.tsx +11 -3
- package/assets/templates/blocks/components/MediaTheme/MediaThemeShowcase.tsx +27 -5
- package/assets/templates/blocks/components/MobileNav/MobileNavBasicMobileNav.doc.mjs +0 -7
- package/assets/templates/blocks/components/MobileNav/MobileNavBasicMobileNav.tsx +5 -9
- package/assets/templates/blocks/components/MobileNav/MobileNavEndSideMobileNav.doc.mjs +0 -1
- package/assets/templates/blocks/components/MobileNav/MobileNavEndSideMobileNav.tsx +2 -2
- package/assets/templates/blocks/components/MobileNav/MobileNavWithoutTitleMobileNav.doc.mjs +0 -1
- package/assets/templates/blocks/components/MobileNav/MobileNavWithoutTitleMobileNav.tsx +1 -1
- package/assets/templates/blocks/components/MoreMenu/MoreMenuBottomSheet.doc.mjs +0 -6
- package/assets/templates/blocks/components/MoreMenu/MoreMenuBottomSheet.tsx +15 -15
- package/assets/templates/blocks/components/MoreMenu/MoreMenuWithDividers.doc.mjs +0 -5
- package/assets/templates/blocks/components/MoreMenu/MoreMenuWithDividers.tsx +4 -8
- package/assets/templates/blocks/components/MoreMenu/MoreMenuWithSections.doc.mjs +0 -5
- package/assets/templates/blocks/components/MoreMenu/MoreMenuWithSections.tsx +4 -8
- package/assets/templates/blocks/components/MultiSelector/useMultiComboboxHookUsage.doc.mjs +0 -1
- package/assets/templates/blocks/components/MultiSelector/useMultiComboboxHookUsage.tsx +1 -1
- package/assets/templates/blocks/components/OverflowList/OverflowListCappedToolbar.tsx +38 -2
- package/assets/templates/blocks/components/OverflowList/OverflowListCollapseFromStartList.tsx +17 -5
- package/assets/templates/blocks/components/OverflowList/OverflowListOverflowDropdownActions.tsx +46 -7
- package/assets/templates/blocks/components/OverflowList/OverflowListShowcase.tsx +45 -5
- package/assets/templates/blocks/components/Overlay/OverlayHoverReveal.tsx +14 -1
- package/assets/templates/blocks/components/Overlay/OverlayShowcase.tsx +10 -1
- package/assets/templates/blocks/components/Overlay/useOverlayHookUsage.tsx +12 -1
- package/assets/templates/blocks/components/Pagination/PaginationDotsCarousel.doc.mjs +0 -1
- package/assets/templates/blocks/components/Pagination/PaginationDotsCarousel.tsx +1 -1
- package/assets/templates/blocks/components/Popover/PopoverBottomSheetAlternative.doc.mjs +0 -1
- package/assets/templates/blocks/components/Popover/PopoverBottomSheetAlternative.tsx +1 -1
- package/assets/templates/blocks/components/Resizable/ResizableShowcase.tsx +12 -2
- package/assets/templates/blocks/components/Resizable/ResizableSidebar.tsx +1 -1
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.tsx +1 -1
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.tsx +1 -1
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.tsx +1 -1
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.tsx +1 -1
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.tsx +1 -1
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.tsx +1 -1
- package/assets/templates/blocks/components/Section/SectionWashHighlight.doc.mjs +0 -1
- package/assets/templates/blocks/components/Section/SectionWashHighlight.tsx +10 -2
- package/assets/templates/blocks/components/Selector/SelectorOptionDescriptions.doc.mjs +0 -1
- package/assets/templates/blocks/components/Selector/SelectorOptionDescriptions.tsx +3 -3
- package/assets/templates/blocks/components/SelectorOption/SelectorOptionShowcase.doc.mjs +0 -1
- package/assets/templates/blocks/components/SelectorOption/SelectorOptionShowcase.tsx +1 -1
- package/assets/templates/blocks/components/Stack/StackAlignment.tsx +50 -6
- package/assets/templates/blocks/components/Stack/StackDirections.tsx +1 -1
- package/assets/templates/blocks/components/Stack/StackFillItem.tsx +10 -1
- package/assets/templates/blocks/components/Step/StepContent.tsx +13 -4
- package/assets/templates/blocks/components/Step/StepIndicator.tsx +3 -2
- package/assets/templates/blocks/components/Step/StepShowcase.tsx +1 -1
- package/assets/templates/blocks/components/Step/StepStates.tsx +3 -2
- package/assets/templates/blocks/components/Stepper/StepperCustomContent.tsx +18 -14
- package/assets/templates/blocks/components/Stepper/StepperOnTrackHorizontal.tsx +1 -1
- package/assets/templates/blocks/components/Table/TableInCard.tsx +1 -1
- package/assets/templates/blocks/components/Table/TableShowcase.tsx +1 -1
- package/assets/templates/blocks/components/TextArea/TextAreaWithIcon.doc.mjs +0 -1
- package/assets/templates/blocks/components/TextArea/TextAreaWithIcon.tsx +2 -2
- package/assets/templates/blocks/components/TextInput/TextInputIcon.doc.mjs +0 -1
- package/assets/templates/blocks/components/TextInput/TextInputIcon.tsx +3 -7
- package/assets/templates/blocks/components/TextInput/TextInputSearch.doc.mjs +0 -1
- package/assets/templates/blocks/components/TextInput/TextInputSearch.tsx +3 -3
- package/assets/templates/blocks/components/Theme/ThemeApply.tsx +8 -1
- package/assets/templates/blocks/components/Theme/ThemeNested.tsx +11 -1
- package/assets/templates/blocks/components/Theme/ThemeShowcase.tsx +26 -3
- package/assets/templates/blocks/components/Theme/ThemeSwitcher.tsx +8 -1
- package/assets/templates/blocks/components/ToggleButton/ToggleButtonColor.doc.mjs +0 -11
- package/assets/templates/blocks/components/ToggleButton/ToggleButtonColor.tsx +5 -5
- package/assets/templates/blocks/components/ToggleButton/ToggleButtonGroup.doc.mjs +0 -9
- package/assets/templates/blocks/components/ToggleButton/ToggleButtonGroup.tsx +5 -9
- package/assets/templates/blocks/components/ToggleButton/ToggleButtonIconSwap.doc.mjs +0 -6
- package/assets/templates/blocks/components/ToggleButton/ToggleButtonIconSwap.tsx +6 -6
- package/assets/templates/blocks/components/ToggleButton/ToggleButtonLabel.doc.mjs +0 -6
- package/assets/templates/blocks/components/ToggleButton/ToggleButtonLabel.tsx +3 -3
- package/assets/templates/blocks/components/ToggleButton/ToggleButtonShowcase.doc.mjs +0 -6
- package/assets/templates/blocks/components/ToggleButton/ToggleButtonShowcase.tsx +6 -6
- package/assets/templates/blocks/components/ToggleButton/ToggleButtonStates.doc.mjs +0 -1
- package/assets/templates/blocks/components/ToggleButton/ToggleButtonStates.tsx +2 -2
- package/assets/templates/blocks/components/Token/TokenIcon.doc.mjs +0 -6
- package/assets/templates/blocks/components/Token/TokenIcon.tsx +3 -3
- package/assets/templates/blocks/components/Token/TokenShowcase.doc.mjs +0 -1
- package/assets/templates/blocks/components/Token/TokenShowcase.tsx +1 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +14 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.doc.mjs +0 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +2 -2
- package/assets/templates/blocks/components/Toolbar/ToolbarBulkActions.doc.mjs +0 -1
- package/assets/templates/blocks/components/Toolbar/ToolbarBulkActions.tsx +36 -3
- package/assets/templates/blocks/components/Toolbar/ToolbarCardHeader.doc.mjs +0 -1
- package/assets/templates/blocks/components/Toolbar/ToolbarCardHeader.tsx +4 -3
- package/assets/templates/blocks/components/Toolbar/ToolbarSizes.doc.mjs +0 -1
- package/assets/templates/blocks/components/Toolbar/ToolbarSizes.tsx +3 -3
- package/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.doc.mjs +0 -1
- package/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.tsx +8 -3
- package/assets/templates/blocks/components/Toolbar/ToolbarThreeSlot.doc.mjs +0 -1
- package/assets/templates/blocks/components/Toolbar/ToolbarThreeSlot.tsx +6 -2
- package/assets/templates/blocks/components/Toolbar/ToolbarWithTabs.doc.mjs +0 -1
- package/assets/templates/blocks/components/Toolbar/ToolbarWithTabs.tsx +11 -2
- package/assets/templates/blocks/components/Tooltip/TooltipActionBarTooltips.tsx +33 -3
- package/assets/templates/blocks/components/TopNav/TopNavCenteredNavigation.doc.mjs +0 -1
- package/assets/templates/blocks/components/TopNav/TopNavCenteredNavigation.tsx +2 -2
- package/assets/templates/blocks/components/TopNav/TopNavEnterpriseDashboard.doc.mjs +0 -6
- package/assets/templates/blocks/components/TopNav/TopNavEnterpriseDashboard.tsx +7 -7
- package/assets/templates/blocks/components/TopNav/TopNavHoverMenu.doc.mjs +0 -8
- package/assets/templates/blocks/components/TopNav/TopNavHoverMenu.tsx +14 -9
- package/assets/templates/blocks/components/TopNav/TopNavMegaMenu.doc.mjs +0 -8
- package/assets/templates/blocks/components/TopNav/TopNavMegaMenu.tsx +11 -11
- package/assets/templates/blocks/components/TopNav/TopNavMultipleDropdowns.doc.mjs +0 -5
- package/assets/templates/blocks/components/TopNav/TopNavMultipleDropdowns.tsx +4 -8
- package/assets/templates/blocks/components/TopNav/TopNavShowcase.doc.mjs +0 -5
- package/assets/templates/blocks/components/TopNav/TopNavShowcase.tsx +8 -4
- package/assets/templates/blocks/components/TopNav/TopNavWithLogo.doc.mjs +0 -1
- package/assets/templates/blocks/components/TopNav/TopNavWithLogo.tsx +7 -2
- package/assets/templates/blocks/components/TopNavItem/TopNavItemShowcase.tsx +1 -1
- package/assets/templates/blocks/components/TopNavMegaMenu/TopNavMegaMenuBasic.doc.mjs +0 -1
- package/assets/templates/blocks/components/TopNavMegaMenu/TopNavMegaMenuBasic.tsx +4 -4
- package/assets/templates/blocks/components/TopNavMegaMenu/TopNavMegaMenuShowcase.doc.mjs +0 -7
- package/assets/templates/blocks/components/TopNavMegaMenu/TopNavMegaMenuShowcase.tsx +12 -12
- package/assets/templates/blocks/components/TopNavMegaMenuItem/TopNavMegaMenuItemBasic.doc.mjs +0 -1
- package/assets/templates/blocks/components/TopNavMegaMenuItem/TopNavMegaMenuItemBasic.tsx +2 -2
- package/assets/templates/blocks/components/TopNavMenu/TopNavMenuBasic.doc.mjs +0 -1
- package/assets/templates/blocks/components/TopNavMenu/TopNavMenuBasic.tsx +4 -4
- package/assets/templates/blocks/components/TopNavMenu/TopNavMenuShowcase.doc.mjs +0 -6
- package/assets/templates/blocks/components/TopNavMenu/TopNavMenuShowcase.tsx +11 -8
- package/assets/templates/blocks/components/TreeList/TreeListFileTreeWithIcons.doc.mjs +0 -1
- package/assets/templates/blocks/components/TreeList/TreeListFileTreeWithIcons.tsx +4 -4
- package/assets/templates/blocks/components/TreeList/TreeListInteractiveSettings.doc.mjs +0 -1
- package/assets/templates/blocks/components/TreeList/TreeListInteractiveSettings.tsx +6 -3
- package/assets/templates/blocks/components/Typeahead/TypeaheadSearchField.doc.mjs +0 -1
- package/assets/templates/blocks/components/Typeahead/TypeaheadSearchField.tsx +2 -2
- package/assets/templates/blocks/components/VisuallyHidden/VisuallyHiddenShowcase.doc.mjs +0 -6
- package/assets/templates/blocks/components/VisuallyHidden/VisuallyHiddenShowcase.tsx +30 -7
- package/assets/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.doc.mjs +0 -1
- package/assets/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.tsx +4 -1
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/page.tsx +19 -15
- package/assets/templates/pages/ai-chat/template.doc.mjs +0 -9
- package/assets/templates/pages/ai-chat-landing/page.tsx +16 -16
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +0 -11
- package/assets/templates/pages/blank/page.tsx +4 -2
- package/assets/templates/pages/canvas-editor/page.tsx +200 -110
- package/assets/templates/pages/canvas-editor/template.doc.mjs +0 -46
- package/assets/templates/pages/centered-hero/page.tsx +2 -2
- package/assets/templates/pages/centered-hero/template.doc.mjs +0 -1
- package/assets/templates/pages/checkout-wizard/page.tsx +31 -18
- package/assets/templates/pages/checkout-wizard/template.doc.mjs +0 -7
- package/assets/templates/pages/classic-gallery/page.tsx +1 -1
- package/assets/templates/pages/contact-form/page.tsx +15 -10
- package/assets/templates/pages/contact-form/template.doc.mjs +0 -5
- package/assets/templates/pages/course-detail/page.tsx +10 -10
- package/assets/templates/pages/course-detail/template.doc.mjs +0 -11
- package/assets/templates/pages/dashboard/page.tsx +13 -11
- package/assets/templates/pages/dashboard/template.doc.mjs +0 -6
- package/assets/templates/pages/dashboard-alert-rail/page.tsx +12 -12
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +0 -8
- package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +7 -13
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +0 -7
- package/assets/templates/pages/dashboard-comparison/page.tsx +12 -10
- package/assets/templates/pages/dashboard-comparison/template.doc.mjs +0 -8
- package/assets/templates/pages/dashboard-composition/page.tsx +30 -19
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +0 -1
- package/assets/templates/pages/dashboard-progress/page.tsx +101 -108
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +0 -7
- package/assets/templates/pages/dashboard-scorecard/page.tsx +61 -33
- package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +0 -7
- package/assets/templates/pages/detail-page/page.tsx +28 -11
- package/assets/templates/pages/detail-page/template.doc.mjs +0 -10
- package/assets/templates/pages/documentation/page.tsx +11 -4
- package/assets/templates/pages/documentation-design/page.tsx +39 -12
- package/assets/templates/pages/documentation-design/template.doc.mjs +0 -5
- package/assets/templates/pages/documentation-technical/page.tsx +8 -6
- package/assets/templates/pages/documentation-technical/template.doc.mjs +0 -5
- package/assets/templates/pages/editor/page.tsx +70 -48
- package/assets/templates/pages/editor/template.doc.mjs +0 -26
- package/assets/templates/pages/file-explorer/page.tsx +19 -19
- package/assets/templates/pages/file-explorer/template.doc.mjs +0 -15
- package/assets/templates/pages/form-two-column/page.tsx +1 -1
- package/assets/templates/pages/form-wizard/page.tsx +12 -5
- package/assets/templates/pages/form-wizard-dialog/page.tsx +6 -2
- package/assets/templates/pages/form-wizard-inline/page.tsx +16 -12
- package/assets/templates/pages/form-wizard-inline/template.doc.mjs +0 -6
- package/assets/templates/pages/form-wizard-vertical/page.tsx +21 -24
- package/assets/templates/pages/form-wizard-vertical/template.doc.mjs +0 -13
- package/assets/templates/pages/gallery-hero/page.tsx +2 -2
- package/assets/templates/pages/gallery-hero/template.doc.mjs +0 -1
- package/assets/templates/pages/ide/page.tsx +12 -7
- package/assets/templates/pages/ide/template.doc.mjs +0 -5
- package/assets/templates/pages/incident-console/page.tsx +4 -4
- package/assets/templates/pages/incident-console/template.doc.mjs +0 -1
- package/assets/templates/pages/kanban-board/page.tsx +128 -47
- package/assets/templates/pages/kanban-board/template.doc.mjs +0 -11
- package/assets/templates/pages/library/page.tsx +34 -64
- package/assets/templates/pages/library/template.doc.mjs +0 -1
- package/assets/templates/pages/login/page.tsx +6 -4
- package/assets/templates/pages/login/template.doc.mjs +0 -1
- package/assets/templates/pages/login-card/page.tsx +6 -4
- package/assets/templates/pages/login-card/template.doc.mjs +0 -1
- package/assets/templates/pages/login-split/page.tsx +6 -5
- package/assets/templates/pages/login-split/template.doc.mjs +0 -1
- package/assets/templates/pages/login-sso/page.tsx +6 -6
- package/assets/templates/pages/login-sso/template.doc.mjs +0 -1
- package/assets/templates/pages/messaging-shell/page.tsx +14 -14
- package/assets/templates/pages/messaging-shell/template.doc.mjs +0 -9
- package/assets/templates/pages/mixed-gallery/page.tsx +1 -1
- package/assets/templates/pages/payment-form/page.tsx +50 -29
- package/assets/templates/pages/payment-form/template.doc.mjs +0 -6
- package/assets/templates/pages/product-detail/page.tsx +21 -9
- package/assets/templates/pages/product-detail/template.doc.mjs +0 -1
- package/assets/templates/pages/product-gallery/page.tsx +3 -3
- package/assets/templates/pages/product-gallery/template.doc.mjs +0 -1
- package/assets/templates/pages/settings/page.tsx +35 -14
- package/assets/templates/pages/settings/template.doc.mjs +0 -1
- package/assets/templates/pages/settings-dialog/page.tsx +96 -93
- package/assets/templates/pages/settings-dialog/template.doc.mjs +0 -53
- package/assets/templates/pages/settings-sidebar/page.tsx +74 -36
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +0 -16
- package/assets/templates/pages/shell-nav/page.tsx +32 -20
- package/assets/templates/pages/shell-nav/template.doc.mjs +0 -6
- package/assets/templates/pages/shell-side-nav/page.tsx +23 -22
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +0 -11
- package/assets/templates/pages/shell-top-nav/page.tsx +13 -13
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +0 -19
- package/assets/templates/pages/side-gallery/page.tsx +5 -2
- package/assets/templates/pages/table/page.tsx +21 -21
- package/assets/templates/pages/table/template.doc.mjs +0 -10
- package/assets/templates/pages/table-collapsible/page.tsx +8 -8
- package/assets/templates/pages/table-collapsible/template.doc.mjs +0 -6
- package/assets/templates/pages/table-comparison/page.tsx +23 -23
- package/assets/templates/pages/table-comparison/template.doc.mjs +0 -14
- package/assets/templates/pages/table-filter/page.tsx +75 -47
- package/assets/templates/pages/table-filter/template.doc.mjs +0 -19
- package/assets/templates/pages/table-grouped/page.tsx +16 -15
- package/assets/templates/pages/table-grouped/template.doc.mjs +0 -11
- package/assets/templates/pages/table-inbox/page.tsx +65 -33
- package/assets/templates/pages/table-inbox/template.doc.mjs +0 -17
- package/assets/templates/pages/table-page/page.tsx +3 -6
- package/assets/templates/pages/table-page/template.doc.mjs +0 -1
- package/assets/templates/pages/table-tree/page.tsx +35 -35
- package/assets/templates/pages/table-tree/template.doc.mjs +0 -15
- package/assets/templates/pages/theme-showcase/page.tsx +48 -43
- package/assets/templates/pages/theme-showcase/template.doc.mjs +0 -19
- package/assets/templates/pages/work-item-detail/page.tsx +60 -33
- package/assets/templates/pages/work-item-detail/template.doc.mjs +0 -12
- package/assets/templates/themes/butter/butterTheme.ts +50 -9
- package/assets/templates/themes/chocolate/chocolateTheme.ts +13 -6
- package/assets/templates/themes/gothic/gothicTheme.ts +14 -2
- package/assets/templates/themes/matcha/matchaTheme.ts +10 -2
- package/assets/templates/themes/neutral/neutralTheme.ts +16 -0
- package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/stone/stoneTheme.ts +32 -10
- package/assets/templates/themes/y2k/y2kTheme.ts +11 -3
- package/assets/theme.template.ts +17 -7
- package/authoring/config/config.doc.mjs +8 -1
- package/authoring/config/parse.mjs +15 -0
- package/authoring/config/skill-places.d.mts +23 -0
- package/authoring/config/skill-places.mjs +35 -0
- package/authoring/config/type.ts +16 -0
- package/authoring/debug/parse.d.mts +1 -1
- package/authoring/debug/type.ts +4 -0
- package/authoring/discover/parse.d.mts +2 -1
- package/authoring/discover/parse.mjs +73 -38
- package/authoring/discover/type.ts +9 -2
- package/authoring/doctypes/_schema.d.mts +36 -16
- package/authoring/doctypes/_schema.mjs +29 -0
- package/authoring/doctypes/base/type.ts +19 -0
- package/authoring/doctypes/command/command.doc.mjs +6 -0
- package/authoring/doctypes/command/type.ts +7 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +16 -0
- package/authoring/doctypes/icon-definition/parse.mjs +12 -0
- package/authoring/doctypes/icon-definition/type.ts +18 -0
- package/authoring/doctypes/reference/reference.doc.mjs +13 -0
- package/authoring/doctypes/reference/skill.d.mts +29 -0
- package/authoring/doctypes/reference/skill.mjs +56 -0
- package/authoring/doctypes/reference/type.ts +19 -0
- package/authoring/gap-report/parse.d.mts +1 -1
- package/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +21 -3
- package/authoring/integration/schema.mjs +25 -5
- package/authoring/integration/type.ts +14 -0
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/build.doc.mjs +1 -1
- package/clients/cli/commands/build.mjs +11 -11
- package/clients/cli/commands/component.doc.mjs +3 -1
- package/clients/cli/commands/component.mjs +7 -3
- package/clients/cli/commands/discover.doc.mjs +2 -2
- package/clients/cli/commands/discover.mjs +108 -8
- package/clients/cli/commands/docs.doc.mjs +7 -2
- package/clients/cli/commands/docs.mjs +64 -172
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +4 -2
- package/clients/cli/commands/doctor.doc.mjs +3 -1
- package/clients/cli/commands/doctor.mjs +16 -3
- package/clients/cli/commands/experimental/export.mjs +64 -0
- package/clients/cli/commands/experimental/icon.mjs +67 -12
- package/clients/cli/commands/experimental/import.mjs +70 -0
- package/clients/cli/commands/experimental/index.mjs +152 -13
- package/clients/cli/commands/experimental/render-output.mjs +242 -0
- package/clients/cli/commands/experimental/theme.mjs +34 -13
- package/clients/cli/commands/experimental-export.doc.mjs +73 -0
- package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
- package/clients/cli/commands/experimental-import.doc.mjs +53 -0
- package/clients/cli/commands/experimental-theme-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +6 -1
- package/clients/cli/commands/experimental-theme.doc.mjs +1 -1
- package/clients/cli/commands/experimental.doc.mjs +4 -4
- package/clients/cli/commands/init.doc.mjs +34 -14
- package/clients/cli/commands/integration-check.doc.mjs +1 -1
- package/clients/cli/commands/mcp.doc.mjs +5 -1
- package/clients/cli/commands/search.mjs +68 -7
- package/clients/cli/commands/template.doc.mjs +14 -5
- package/clients/cli/commands/template.mjs +18 -0
- package/clients/cli/commands/theme-add.doc.mjs +6 -2
- package/clients/cli/commands/theme-remove.doc.mjs +1 -1
- package/clients/cli/commands/theme-targets.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +76 -5
- package/clients/cli/commands/upgrade.doc.mjs +2 -1
- package/clients/cli/commands.generated.json +1 -1
- package/clients/cli/index.mjs +30 -31
- package/clients/cli/lib/cli-error.mjs +20 -10
- package/clients/cli/lib/component-format.mjs +167 -74
- package/clients/cli/lib/define-command.mjs +10 -0
- package/clients/cli/lib/hook-format.mjs +28 -24
- package/clients/cli/lib/json-shim.mjs +9 -3
- package/clients/cli/lib/mcp-tools.mjs +8 -2
- package/clients/cli/lib/other-cli-words.mjs +99 -0
- package/clients/cli/lib/renamed-commands.mjs +21 -0
- package/clients/cli/lib/root-args.mjs +10 -3
- package/clients/cli/lib/stray-option.mjs +79 -1
- package/clients/cli/lib/unknown-command.mjs +406 -13
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +27 -0
- package/foundation/agent-docs/agent-doc-state.d.mts +20 -2
- package/foundation/agent-docs/agent-doc-state.mjs +71 -4
- package/foundation/agent-docs/agent-docs.d.mts +43 -4
- package/foundation/agent-docs/agent-docs.mjs +54 -5
- package/foundation/agent-docs/computer-agent-text.d.mts +28 -14
- package/foundation/agent-docs/computer-agent-text.mjs +85 -172
- package/foundation/agent-docs/folder-scope.d.mts +51 -0
- package/foundation/agent-docs/folder-scope.mjs +86 -0
- package/foundation/agent-docs/managed-skill-file.d.mts +115 -0
- package/foundation/agent-docs/managed-skill-file.mjs +224 -0
- package/foundation/agent-docs/skill-place-files.d.mts +119 -0
- package/foundation/agent-docs/skill-place-files.mjs +374 -0
- package/foundation/agent-docs/skill-places.d.mts +139 -0
- package/foundation/agent-docs/skill-places.mjs +321 -0
- package/foundation/color/css-color.d.mts +150 -0
- package/foundation/color/css-color.mjs +960 -0
- package/foundation/config/config-path.d.mts +2 -2
- package/foundation/config/config-path.mjs +5 -6
- package/foundation/config/config-writer.d.mts +5 -1
- package/foundation/config/config-writer.mjs +20 -4
- package/foundation/config/project.d.mts +3 -1
- package/foundation/config/project.mjs +8 -5
- package/foundation/config/theme-state.d.mts +13 -0
- package/foundation/config/theme-state.mjs +28 -0
- package/foundation/debug/event.d.mts +2 -1
- package/foundation/debug/event.mjs +2 -1
- package/foundation/discovery/button-actions.d.mts +220 -0
- package/foundation/discovery/button-actions.mjs +1527 -0
- package/foundation/discovery/cli-self-docs.d.mts +7 -0
- package/foundation/discovery/cli-self-docs.mjs +67 -6
- package/foundation/discovery/color-modes.d.mts +14 -0
- package/foundation/discovery/color-modes.mjs +53 -0
- package/foundation/discovery/command-pointers.d.mts +21 -4
- package/foundation/discovery/command-pointers.mjs +25 -4
- package/foundation/discovery/component-discovery.d.mts +10 -0
- package/foundation/discovery/component-discovery.mjs +99 -43
- package/foundation/discovery/component-replacement.d.mts +8 -0
- package/foundation/discovery/component-replacement.mjs +13 -0
- package/foundation/discovery/core-augmentation-points.d.mts +90 -0
- package/foundation/discovery/core-augmentation-points.mjs +1030 -0
- package/foundation/discovery/core-component-views.d.mts +15 -0
- package/foundation/discovery/core-component-views.mjs +176 -0
- package/foundation/discovery/core-elements.d.mts +29 -0
- package/foundation/discovery/core-elements.mjs +57 -0
- package/foundation/discovery/core-prop-types.d.mts +65 -0
- package/foundation/discovery/core-prop-types.mjs +221 -0
- package/foundation/discovery/core-props.d.mts +33 -0
- package/foundation/discovery/core-props.mjs +64 -0
- package/foundation/discovery/doc-types.d.mts +10 -42
- package/foundation/discovery/doc-types.mjs +26 -7
- package/foundation/discovery/docs-discovery.d.mts +33 -2
- package/foundation/discovery/docs-discovery.mjs +149 -72
- package/foundation/discovery/docs-section-key.d.mts +21 -1
- package/foundation/discovery/docs-section-key.mjs +57 -19
- package/foundation/discovery/hook-discovery.d.mts +2 -0
- package/foundation/discovery/hook-discovery.mjs +6 -5
- package/foundation/discovery/icon-definition-discovery.d.mts +155 -3
- package/foundation/discovery/icon-definition-discovery.mjs +197 -5
- package/foundation/discovery/icon-imports.d.mts +66 -0
- package/foundation/discovery/icon-imports.mjs +225 -0
- package/foundation/discovery/icon-ranking.d.mts +108 -4
- package/foundation/discovery/icon-ranking.mjs +277 -70
- package/foundation/discovery/icon-set-checks.d.mts +2 -0
- package/foundation/discovery/icon-set-checks.mjs +16 -2
- package/foundation/discovery/icon-set-discovery.d.mts +42 -2
- package/foundation/discovery/icon-set-discovery.mjs +85 -23
- package/foundation/discovery/icon-set-writer.d.mts +7 -2
- package/foundation/discovery/icon-set-writer.mjs +86 -7
- package/foundation/discovery/integration-skills.d.mts +62 -0
- package/foundation/discovery/integration-skills.mjs +116 -0
- package/foundation/discovery/module-exports.d.mts +8 -0
- package/foundation/discovery/module-exports.mjs +20 -21
- package/foundation/discovery/package-exports.d.mts +22 -0
- package/foundation/discovery/package-exports.mjs +44 -3
- package/foundation/discovery/project-typescript.d.mts +5 -1
- package/foundation/discovery/project-typescript.mjs +8 -2
- package/foundation/discovery/prop-drift.d.mts +16 -0
- package/foundation/discovery/prop-drift.mjs +154 -3
- package/foundation/discovery/replacement-aliases.d.mts +51 -0
- package/foundation/discovery/replacement-aliases.mjs +95 -0
- package/foundation/discovery/runner-allowlist.d.mts +1 -1
- package/foundation/discovery/runner-allowlist.mjs +1 -1
- package/foundation/discovery/stored-component-list.mjs +34 -2
- package/foundation/discovery/template-adapter.d.mts +26 -0
- package/foundation/discovery/template-adapter.mjs +221 -10
- package/foundation/discovery/template-destination.d.mts +14 -6
- package/foundation/discovery/template-destination.mjs +42 -8
- package/foundation/discovery/template-icon-meanings.d.mts +7 -2
- package/foundation/discovery/template-icon-meanings.mjs +52 -12
- package/foundation/discovery/template-icons.d.mts +44 -1
- package/foundation/discovery/template-icons.mjs +60 -63
- package/foundation/discovery/template-needs.d.mts +17 -8
- package/foundation/discovery/template-needs.mjs +119 -31
- package/foundation/discovery/template-placeholders.d.mts +149 -0
- package/foundation/discovery/template-placeholders.mjs +463 -0
- package/foundation/discovery/template-source-tree.d.mts +6 -3
- package/foundation/discovery/template-source-tree.mjs +8 -5
- package/foundation/discovery/theme-discovery.d.mts +8 -0
- package/foundation/discovery/theme-discovery.mjs +23 -6
- package/foundation/discovery/theme-imports.d.mts +1 -3
- package/foundation/discovery/theme-imports.mjs +5 -30
- package/foundation/doc-compiler/compile.mjs +6 -8
- package/foundation/doc-compiler/doc-syntax.d.mts +25 -1
- package/foundation/doc-compiler/doc-syntax.mjs +85 -10
- package/foundation/doc-compiler/doc-text.d.mts +52 -0
- package/foundation/doc-compiler/doc-text.mjs +176 -0
- package/foundation/doc-compiler/links.d.mts +8 -2
- package/foundation/doc-compiler/links.mjs +27 -6
- package/foundation/doc-compiler/read.d.mts +1 -1
- package/foundation/doc-compiler/stored-docs.d.mts +14 -3
- package/foundation/doc-compiler/stored-docs.mjs +12 -6
- package/foundation/env/cli-command.d.mts +68 -10
- package/foundation/env/cli-command.mjs +116 -22
- package/foundation/env/package-manager.d.mts +33 -2
- package/foundation/env/package-manager.mjs +68 -6
- package/foundation/env/user-dirs.d.mts +14 -0
- package/foundation/env/user-dirs.mjs +34 -1
- package/foundation/env/user-settings.d.mts +15 -0
- package/foundation/env/user-settings.mjs +56 -2
- package/foundation/fonts/font-stylesheet.d.mts +11 -0
- package/foundation/fonts/font-stylesheet.mjs +62 -7
- package/foundation/fs/cache-eviction.d.mts +7 -5
- package/foundation/fs/cache-eviction.mjs +20 -13
- package/foundation/fs/empty-folder.d.mts +12 -0
- package/foundation/fs/empty-folder.mjs +30 -0
- package/foundation/fs/file-protection.d.mts +11 -0
- package/foundation/fs/file-protection.mjs +49 -3
- package/foundation/fs/gather-cache.d.mts +14 -7
- package/foundation/fs/gather-cache.mjs +163 -67
- package/foundation/fs/import-url.d.mts +7 -5
- package/foundation/fs/import-url.mjs +7 -5
- package/foundation/fs/jiti-cache.d.mts +47 -26
- package/foundation/fs/jiti-cache.mjs +222 -130
- package/foundation/fs/loaded-files.d.mts +15 -1
- package/foundation/fs/loaded-files.mjs +40 -3
- package/foundation/fs/module-loader.d.mts +3 -1
- package/foundation/fs/module-loader.mjs +85 -5
- package/foundation/fs/path-safety.d.mts +1 -0
- package/foundation/fs/path-safety.mjs +2 -0
- package/foundation/fs/relative-specifier.d.mts +10 -0
- package/foundation/fs/relative-specifier.mjs +28 -0
- package/foundation/integrations/computer-integrations.mjs +11 -10
- package/foundation/integrations/icon-features.d.mts +1 -1
- package/foundation/integrations/icon-features.mjs +1 -1
- package/foundation/integrations/integration-warnings.d.mts +10 -0
- package/foundation/integrations/integration-warnings.mjs +12 -3
- package/foundation/integrations/integrations.d.mts +16 -2
- package/foundation/integrations/integrations.mjs +50 -8
- package/foundation/integrations/may-have-integrations.mjs +7 -6
- package/foundation/integrations/provider-resolution.mjs +19 -2
- package/foundation/integrations/validate-contributions.d.mts +4 -0
- package/foundation/integrations/validate-contributions.mjs +24 -0
- package/foundation/release/agent-text-worker.mjs +33 -1
- package/foundation/release/cache.d.mts +48 -3
- package/foundation/release/cache.mjs +196 -20
- package/foundation/release/choose.d.mts +5 -2
- package/foundation/release/choose.mjs +54 -4
- package/foundation/release/global-state.mjs +10 -2
- package/foundation/release/handoff.mjs +7 -1
- package/foundation/release/notices.d.mts +97 -9
- package/foundation/release/notices.mjs +381 -56
- package/foundation/release/project.d.mts +21 -4
- package/foundation/release/project.mjs +74 -42
- package/foundation/release/run-context.d.mts +6 -0
- package/foundation/release/run-context.mjs +9 -0
- package/foundation/render/assets.d.mts +7 -0
- package/foundation/render/assets.mjs +30 -17
- package/foundation/render/charts.d.mts +11 -10
- package/foundation/render/charts.mjs +112 -1
- package/foundation/render/class-alias.d.mts +23 -0
- package/foundation/render/class-alias.mjs +333 -0
- package/foundation/render/client-bundle.d.mts +183 -0
- package/foundation/render/client-bundle.mjs +1026 -0
- package/foundation/render/component-map.mjs +1 -1
- package/foundation/render/css-cut.d.mts +26 -0
- package/foundation/render/css-cut.mjs +344 -2
- package/foundation/render/dropped-text.d.mts +43 -0
- package/foundation/render/dropped-text.mjs +90 -0
- package/foundation/render/embedded-files.d.mts +24 -1
- package/foundation/render/embedded-files.mjs +41 -4
- package/foundation/render/embedded-imports.d.mts +72 -12
- package/foundation/render/embedded-imports.mjs +206 -70
- package/foundation/render/esbuild-dependency.d.mts +14 -0
- package/foundation/render/esbuild-dependency.mjs +41 -0
- package/foundation/render/file-header.d.mts +7 -2
- package/foundation/render/file-header.mjs +19 -10
- package/foundation/render/html-reader.d.mts +36 -17
- package/foundation/render/html-reader.mjs +239 -32
- package/foundation/render/image-attributes.d.mts +25 -0
- package/foundation/render/image-attributes.mjs +33 -0
- package/foundation/render/markup-edits.mjs +1 -1
- package/foundation/render/package-resolve-hooks.d.mts +54 -0
- package/foundation/render/package-resolve-hooks.mjs +144 -0
- package/foundation/render/page-host.mjs +1 -1
- package/foundation/render/page-worker.mjs +1307 -107
- package/foundation/render/picture-chrome.mjs +13 -1
- package/foundation/render/picture-playwright.mjs +13 -0
- package/foundation/render/picture-window.d.mts +18 -5
- package/foundation/render/picture-window.mjs +211 -19
- package/foundation/render/rebuild.mjs +2 -2
- package/foundation/render/remote-images.d.mts +83 -0
- package/foundation/render/remote-images.mjs +384 -0
- package/foundation/render/render-page.d.mts +214 -6
- package/foundation/render/render-page.mjs +1673 -163
- package/foundation/render/restore-folder.d.mts +13 -0
- package/foundation/render/restore-folder.mjs +30 -0
- package/foundation/render/served-packages.d.mts +14 -1
- package/foundation/render/served-packages.mjs +50 -6
- package/foundation/render/share-checks.d.mts +35 -0
- package/foundation/render/share-checks.mjs +95 -0
- package/foundation/render/source-block.d.mts +14 -3
- package/foundation/render/source-block.mjs +44 -9
- package/foundation/render/srcset.d.mts +32 -0
- package/foundation/render/srcset.mjs +64 -0
- package/foundation/render/ts-paths.d.mts +52 -1
- package/foundation/render/ts-paths.mjs +114 -4
- 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 +16 -10
- package/foundation/response/error-codes.mjs +19 -8
- package/foundation/response/json.d.mts +0 -15
- package/foundation/response/json.mjs +1 -51
- package/foundation/response/response-types.doc.mjs +24 -13
- package/foundation/runtime/css-tree.d.mts +16 -0
- package/foundation/runtime/css-tree.mjs +46 -3
- package/foundation/runtime/lazy-dependencies.d.mts +7 -0
- package/foundation/runtime/lazy-dependencies.mjs +25 -3
- package/foundation/runtime/locked-versions.d.mts +4 -2
- package/foundation/runtime/locked-versions.mjs +18 -10
- package/foundation/runtime/package-root.d.mts +25 -0
- package/foundation/runtime/package-root.mjs +48 -0
- package/foundation/runtime/word-table.d.mts +18 -0
- package/foundation/runtime/word-table.mjs +33 -0
- package/foundation/suggest/other-command.d.mts +23 -0
- package/foundation/suggest/other-command.mjs +49 -5
- package/foundation/text/default-variant.d.mts +20 -0
- package/foundation/text/default-variant.mjs +24 -0
- package/foundation/text/definition-coverage.d.mts +21 -0
- package/foundation/text/definition-coverage.mjs +20 -0
- package/foundation/text/icon-set-next.d.mts +11 -10
- package/foundation/text/icon-set-next.mjs +19 -11
- package/foundation/text/string-utils.mjs +14 -41
- package/foundation/text/suggest-order.d.mts +10 -4
- package/foundation/text/suggest-order.mjs +20 -13
- package/package.json +8 -6
- package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +0 -394
- package/assets/docs/tree/render-pages.doc.mjs +0 -135
- package/clients/cli/commands/experimental/render.mjs +0 -154
- package/clients/cli/commands/experimental-render.doc.mjs +0 -73
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file Worker for `astryx experimental
|
|
4
|
+
* @file Worker for `astryx experimental export`: loads one page module from
|
|
5
5
|
* the project (TypeScript, JSX and StyleX compiled in memory) and renders its
|
|
6
6
|
* default export to static markup with the project's own React.
|
|
7
7
|
*
|
|
@@ -26,15 +26,19 @@
|
|
|
26
26
|
* (through the global layers.mjs names) is drawn the same way and put where
|
|
27
27
|
* its marker is, with each overlay it opened after it.
|
|
28
28
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
29
|
+
* With `buildScript`, the page's modules and the modules they use are also
|
|
30
|
+
* bundled for the browser by esbuild (client-bundle.mjs) into one script,
|
|
31
|
+
* which draws the page over its markup in the browser.
|
|
32
|
+
*
|
|
33
|
+
* @input workerData {entry, root, scope, served, withoutSegmenter, openLayers, buildScript, esbuild}
|
|
34
|
+
* @output one message: {ok: true, markup, css, files, texts, logs, script} or
|
|
31
35
|
* {ok: false, error: {code, message, detail?}}
|
|
32
36
|
* @position foundation/render — started by page-host.mjs
|
|
33
37
|
*/
|
|
34
38
|
|
|
35
39
|
import * as fs from 'node:fs';
|
|
36
40
|
import * as path from 'node:path';
|
|
37
|
-
import Module, {createRequire, register} from 'node:module';
|
|
41
|
+
import Module, {builtinModules, createRequire, register} from 'node:module';
|
|
38
42
|
import {pathToFileURL} from 'node:url';
|
|
39
43
|
import {format, stripVTControlCharacters} from 'node:util';
|
|
40
44
|
import {parentPort, workerData} from 'node:worker_threads';
|
|
@@ -42,9 +46,16 @@ import {transformSync} from '@babel/core';
|
|
|
42
46
|
import {LOAD_EXTENSIONS, existingFile, matchPath, pathsFor, resolvePath} from './ts-paths.mjs';
|
|
43
47
|
import {createJiti} from 'jiti';
|
|
44
48
|
import {assetDataUri, isAssetPath} from './assets.mjs';
|
|
45
|
-
import {
|
|
49
|
+
import {NOT_AN_IMAGE, showsImage} from './image-attributes.mjs';
|
|
50
|
+
import {parseSrcset} from './srcset.mjs';
|
|
51
|
+
import {SINGLE_COPY, isServedPackage, packageOf, resolveServed, servedImportTarget} from './served-packages.mjs';
|
|
52
|
+
import {packageResolveHooks} from './package-resolve-hooks.mjs';
|
|
46
53
|
import {findNodeModulesPackage} from '../fs/paths.mjs';
|
|
47
|
-
import {importSpecifiers} from './embedded-imports.mjs';
|
|
54
|
+
import {importSpecifiers, moduleImports} from './embedded-imports.mjs';
|
|
55
|
+
import {sha256} from './source-block.mjs';
|
|
56
|
+
import {BundleError, CARRIED_MODULE, bundleForBrowser} from './client-bundle.mjs';
|
|
57
|
+
import {droppedImports, importUses} from './value-uses.mjs';
|
|
58
|
+
import {coreComponentOf} from '../discovery/core-elements.mjs';
|
|
48
59
|
import {CHART_GLOBAL, CHART_ROOTS, FOLLOWS_WIDTH, boxHeights, chartDocument, chartDrawings, foldLegends, roundCoordinates, separateIds} from './charts.mjs';
|
|
49
60
|
import {LAYER_GLOBAL, LAYER_PLACEHOLDER, countQueuedImmediates, layerDocument, layerPlaceholder, openLayerMarkup, settled} from './layers.mjs';
|
|
50
61
|
|
|
@@ -78,8 +89,17 @@ for (const level of /** @type {const} */ (['log', 'info', 'warn', 'error', 'debu
|
|
|
78
89
|
|
|
79
90
|
const requireFromCli = createRequire(import.meta.url);
|
|
80
91
|
const stylexPlugin = /** @type {any} */ (requireFromCli('@stylexjs/babel-plugin'));
|
|
92
|
+
/**
|
|
93
|
+
* The class-name prefix of the page's own compiled styles. Core's built sheet
|
|
94
|
+
* uses StyleX's default, `x`. A page rule with the same declaration as a Core
|
|
95
|
+
* rule would otherwise get the same class, unlayered, and override Core's
|
|
96
|
+
* layered rules on Core's own elements. With its own prefix the page's rules
|
|
97
|
+
* apply to the page's elements only, as in an app that @astryxdesign/build
|
|
98
|
+
* compiles with one prefix for Astryx and another for product files.
|
|
99
|
+
*/
|
|
100
|
+
const PAGE_CLASS_PREFIX = 'p';
|
|
81
101
|
|
|
82
|
-
/** StyleX rules collected from every local module the page loads. */
|
|
102
|
+
/** StyleX rules collected from every local module the page loads, and from each package file that holds StyleX source. */
|
|
83
103
|
/** @type {unknown[]} */
|
|
84
104
|
const stylexRules = [];
|
|
85
105
|
/** CSS text of local stylesheets the page imports, in load order. */
|
|
@@ -88,11 +108,68 @@ const importedCss = [];
|
|
|
88
108
|
/** Every local (non-package) module the page loaded, page first. */
|
|
89
109
|
/** @type {string[]} */
|
|
90
110
|
const localFiles = [];
|
|
111
|
+
/** The page's own files that load as modules, not as text (`?raw`) or data. @type {Set<string>} */
|
|
112
|
+
const moduleFiles = new Set();
|
|
113
|
+
/**
|
|
114
|
+
* Local files the page uses that the file cannot carry: a module or JSON
|
|
115
|
+
* file it reaches by a relative import from outside the folder it carries
|
|
116
|
+
* from, and a Sass or Less stylesheet, which a render does not compile.
|
|
117
|
+
* @type {string[]}
|
|
118
|
+
*/
|
|
119
|
+
const outsideFiles = [];
|
|
91
120
|
/** Package stylesheets the page imports, by specifier and importing file. */
|
|
92
121
|
/** @type {{spec: string, from: string}[]} */
|
|
93
122
|
const packageCss = [];
|
|
94
123
|
/** Sass and Less stylesheets the page imports, which a render cannot compile. @type {string[]} */
|
|
95
124
|
const skippedCss = [];
|
|
125
|
+
/** https image addresses the page's own files name as literals, which the first paint may not show. @type {Set<string>} */
|
|
126
|
+
const remoteLiterals = new Set();
|
|
127
|
+
/**
|
|
128
|
+
* Of those, the addresses that count only because a name says they are
|
|
129
|
+
* images (`imageUploadUrl`, an object's `src`), never by their path or an
|
|
130
|
+
* element that shows them: such a name can hold an API's or a player's
|
|
131
|
+
* address. @type {Set<string>}
|
|
132
|
+
*/
|
|
133
|
+
const namedOnlyLiterals = new Set();
|
|
134
|
+
/** The addresses that count by their path or an element that shows them. @type {Set<string>} */
|
|
135
|
+
const placedLiterals = new Set();
|
|
136
|
+
/**
|
|
137
|
+
* Record an https literal the render fetches as an image. A `srcSet` value
|
|
138
|
+
* lists candidates (`a.png 1x, a@2x.png 2x`): each https one is an image.
|
|
139
|
+
* @param {string} value
|
|
140
|
+
* @param {{srcset: boolean, byName: boolean} | null} why see imageLiteralKind
|
|
141
|
+
*/
|
|
142
|
+
function noteRemoteLiteral(value, why) {
|
|
143
|
+
if (!why) return;
|
|
144
|
+
const urls = why.srcset ? srcsetCandidates(value).filter(url => /^https:\/\//i.test(url) && !namesNoImage(url)) : [value];
|
|
145
|
+
for (const url of urls) {
|
|
146
|
+
remoteLiterals.add(url);
|
|
147
|
+
(why.byName ? namedOnlyLiterals : placedLiterals).add(url);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Whether an address's path names a type that is never an image.
|
|
153
|
+
* @param {string} url
|
|
154
|
+
*/
|
|
155
|
+
function namesNoImage(url) {
|
|
156
|
+
try {
|
|
157
|
+
return NOT_AN_IMAGE.test(new URL(url).pathname);
|
|
158
|
+
} catch {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* The addresses a `srcset` value lists, one per candidate.
|
|
165
|
+
* @param {string} value
|
|
166
|
+
* @returns {string[]}
|
|
167
|
+
*/
|
|
168
|
+
function srcsetCandidates(value) {
|
|
169
|
+
return parseSrcset(value).map(candidate => candidate.url);
|
|
170
|
+
}
|
|
171
|
+
/** https image addresses the page builds in code where an image goes, which a render cannot carry. @type {{text: string, file: string, line: number}[]} */
|
|
172
|
+
const builtRemote = [];
|
|
96
173
|
/** Local files inlined from asset imports. */
|
|
97
174
|
/** @type {Set<string>} */
|
|
98
175
|
const assetsInlined = new Set();
|
|
@@ -100,11 +177,17 @@ const assetsInlined = new Set();
|
|
|
100
177
|
/** @type {Set<string>} */
|
|
101
178
|
const packages = new Set();
|
|
102
179
|
/** Static JSX text per element, for the dropped-children warning. */
|
|
103
|
-
/** @type {{file: string, component: string, text: string, hidden: boolean, fn: string, line: number}[]} */
|
|
180
|
+
/** @type {{file: string, component: string, text: string, hidden: boolean, fn: string, line: number, chain: {component: string, line: number, from: string | null, name: string}[]}[]} */
|
|
104
181
|
const texts = [];
|
|
105
182
|
/** Every static JSX text, by the function it is in. */
|
|
106
183
|
/** @type {Record<string, string[]>} */
|
|
107
184
|
const fnTexts = {};
|
|
185
|
+
/**
|
|
186
|
+
* Each string a page's own file gives a Core component's prop
|
|
187
|
+
* (`<Button variant="danger">`), for the unknown-prop-value warning.
|
|
188
|
+
* @type {{component: string, prop: string, value: string, file: string, line: number}[]}
|
|
189
|
+
*/
|
|
190
|
+
const propValues = [];
|
|
108
191
|
/** Each media query the page's own code asks in JavaScript, for the screen-query warning. */
|
|
109
192
|
/** @type {{call: string, file: string, line: number}[]} */
|
|
110
193
|
const screenQueries = [];
|
|
@@ -180,6 +263,23 @@ const jsxName = node => {
|
|
|
180
263
|
: '';
|
|
181
264
|
};
|
|
182
265
|
|
|
266
|
+
/**
|
|
267
|
+
* The module a JSX component name is imported from, and the name that module
|
|
268
|
+
* exports it under; `from` is null for a component the page defines itself.
|
|
269
|
+
* @param {any} p a JSX element path
|
|
270
|
+
* @param {string} name the element's name as the page writes it
|
|
271
|
+
* @returns {{from: string | null, name: string}}
|
|
272
|
+
*/
|
|
273
|
+
const importOf = (p, name) => {
|
|
274
|
+
const binding = p.scope.getBinding(name);
|
|
275
|
+
if (binding?.kind !== 'module') return {from: null, name};
|
|
276
|
+
const spec = binding.path.node;
|
|
277
|
+
return {
|
|
278
|
+
from: binding.path.parent.source.value,
|
|
279
|
+
name: spec.type === 'ImportSpecifier' ? (spec.imported.name ?? spec.imported.value) : name,
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
|
|
183
283
|
/** @type {Record<string, string>} */
|
|
184
284
|
const ENTITIES = {
|
|
185
285
|
amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: '\u00a0',
|
|
@@ -212,6 +312,82 @@ const NODE_MODULES = `${path.sep}node_modules${path.sep}`;
|
|
|
212
312
|
const isLocal = file =>
|
|
213
313
|
!file.includes(NODE_MODULES) && (file === entry || file.startsWith(SCOPE_PREFIX));
|
|
214
314
|
|
|
315
|
+
/**
|
|
316
|
+
* The real folders of the packages that a `node_modules` folder links to
|
|
317
|
+
* inside the folder whose modules the page carries (`npm link`, a `file:`
|
|
318
|
+
* dependency, a workspace package). Node loads such a package's modules by
|
|
319
|
+
* their real path, so they read as the page's own. They compile as the
|
|
320
|
+
* page's own do, but the file carries only what the page reaches by a path
|
|
321
|
+
* (see dropLinkedPackageFiles), because the page imports the package by its
|
|
322
|
+
* name. The search covers each `node_modules` folder that Node reads for the
|
|
323
|
+
* page's imports, from the page's folder up, and the `node_modules` folders
|
|
324
|
+
* of each linked package and of the folders above it, as a workspace links
|
|
325
|
+
* one package into another. A link to a folder that holds the page is not a
|
|
326
|
+
* package of the page's. Empty when no link leads into the carried folder.
|
|
327
|
+
* @returns {string[]} each folder, with a trailing separator
|
|
328
|
+
*/
|
|
329
|
+
function linkedPackageRoots() {
|
|
330
|
+
/** @type {Set<string>} */
|
|
331
|
+
const roots = new Set();
|
|
332
|
+
/** @type {Set<string>} */
|
|
333
|
+
const scanned = new Set();
|
|
334
|
+
/** @type {string[]} */
|
|
335
|
+
const found = [];
|
|
336
|
+
/** @param {string} link */
|
|
337
|
+
const addIfLinkedIn = link => {
|
|
338
|
+
let real;
|
|
339
|
+
try {
|
|
340
|
+
if (!fs.lstatSync(link).isSymbolicLink()) return;
|
|
341
|
+
real = fs.realpathSync(link);
|
|
342
|
+
} catch {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
const folder = real + path.sep;
|
|
346
|
+
if (isLocal(folder) && !entry.startsWith(folder) && !roots.has(folder)) {
|
|
347
|
+
roots.add(folder);
|
|
348
|
+
found.push(real);
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
/** Read the links in `dir`'s `node_modules` folder and in those above it, up to `top`. @param {string} dir @param {string | null} top */
|
|
352
|
+
const scanUp = (dir, top) => {
|
|
353
|
+
for (let at = dir; ; at = path.dirname(at)) {
|
|
354
|
+
if (!scanned.has(at)) {
|
|
355
|
+
scanned.add(at);
|
|
356
|
+
const modules = path.join(at, 'node_modules');
|
|
357
|
+
/** @type {string[]} */
|
|
358
|
+
let names = [];
|
|
359
|
+
try {
|
|
360
|
+
names = fs.readdirSync(modules);
|
|
361
|
+
} catch {
|
|
362
|
+
// No node_modules folder here.
|
|
363
|
+
}
|
|
364
|
+
for (const name of names) {
|
|
365
|
+
const link = path.join(modules, name);
|
|
366
|
+
if (!name.startsWith('@')) {
|
|
367
|
+
addIfLinkedIn(link);
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
try {
|
|
371
|
+
for (const scoped of fs.readdirSync(link)) addIfLinkedIn(path.join(link, scoped));
|
|
372
|
+
} catch {
|
|
373
|
+
// A scope that cannot be read holds no package that Node can load.
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (at === top || path.dirname(at) === at) break;
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
scanUp(path.dirname(entry), null);
|
|
381
|
+
// A linked package resolves its own imports from its folder up.
|
|
382
|
+
for (let next = found.shift(); next !== undefined; next = found.shift()) scanUp(next, scope);
|
|
383
|
+
return [...roots];
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const LINKED_ROOTS = linkedPackageRoots();
|
|
387
|
+
|
|
388
|
+
/** A file of a package linked into the carried folder (see linkedPackageRoots). @param {string} file */
|
|
389
|
+
const inLinkedPackage = file => LINKED_ROOTS.some(root => file.startsWith(root));
|
|
390
|
+
|
|
215
391
|
/** Charts the server render set aside, drawn after it. @type {any[]} */
|
|
216
392
|
const charts = [];
|
|
217
393
|
/** The props each chart was last drawn with in the page-wide draw. @type {any[]} */
|
|
@@ -482,6 +658,26 @@ async function withLoadDocument(fn) {
|
|
|
482
658
|
}
|
|
483
659
|
}
|
|
484
660
|
|
|
661
|
+
/**
|
|
662
|
+
* Run `fn` with console.timeStamp hidden. A development build of React DOM
|
|
663
|
+
* decides as it loads whether to log every render to the Performance panel
|
|
664
|
+
* (console.timeStamp and performance.measure), and logs only when both are
|
|
665
|
+
* there. The worker has no Performance panel, and Node copies the props a
|
|
666
|
+
* logged re-render changed into its user timing buffer: a page of four
|
|
667
|
+
* charts of 50,000 points each spent most of its drawing time there.
|
|
668
|
+
* @param {() => Promise<unknown>} fn
|
|
669
|
+
*/
|
|
670
|
+
async function withoutRenderTimings(fn) {
|
|
671
|
+
const had = Object.getOwnPropertyDescriptor(console, 'timeStamp');
|
|
672
|
+
/** @type {any} */ (console).timeStamp = undefined;
|
|
673
|
+
try {
|
|
674
|
+
await fn();
|
|
675
|
+
} finally {
|
|
676
|
+
if (had) Object.defineProperty(console, 'timeStamp', had);
|
|
677
|
+
else delete (/** @type {any} */ (console)).timeStamp;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
485
681
|
/**
|
|
486
682
|
* Draw each part the page asked to be drawn open, in the layer document
|
|
487
683
|
* (layers.mjs), and put each where its marker is: the part as drawn, then
|
|
@@ -618,50 +814,340 @@ async function drawOpenLayers(elements, React) {
|
|
|
618
814
|
|
|
619
815
|
/**
|
|
620
816
|
* Babel plugin: a bare import that a path alias places loads from that file,
|
|
621
|
-
* as in TypeScript, before any installed copy.
|
|
622
|
-
*
|
|
817
|
+
* as in TypeScript, before any installed copy. A relative `.js`-family import
|
|
818
|
+
* that names no file loads the TypeScript source it stands for (`./fmt.js`
|
|
819
|
+
* for fmt.ts). Any other import is left alone, so an installed package
|
|
820
|
+
* loads. It runs on the page's
|
|
623
821
|
* own files, before {@link pagePlugin}, and on every module the page loads
|
|
624
822
|
* from outside them and outside `node_modules` (a sibling package's source,
|
|
625
823
|
* say).
|
|
626
824
|
*/
|
|
627
825
|
function aliasPlugin() {
|
|
628
826
|
return () => {
|
|
629
|
-
/**
|
|
630
|
-
|
|
827
|
+
/**
|
|
828
|
+
* Point a string literal at the file an alias places, or at the
|
|
829
|
+
* TypeScript source a relative `.js`-family name stands for when no file
|
|
830
|
+
* has that name (`./fmt.js` for fmt.ts), as TypeScript and bundlers read
|
|
831
|
+
* it.
|
|
832
|
+
* @param {any} node
|
|
833
|
+
* @param {string} from the importing file
|
|
834
|
+
*/
|
|
835
|
+
const point = (node, from) => {
|
|
631
836
|
if (node?.type !== 'StringLiteral') return;
|
|
632
837
|
const file = resolvePath(PATHS, node.value);
|
|
633
|
-
if (file)
|
|
838
|
+
if (file) {
|
|
839
|
+
node.value = file;
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
const source = from ? typeScriptSourceOf(node.value, from) : null;
|
|
843
|
+
if (source) node.value = source;
|
|
634
844
|
};
|
|
635
845
|
return {
|
|
636
846
|
visitor: {
|
|
637
|
-
'ImportDeclaration|ExportNamedDeclaration|ExportAllDeclaration'(/** @type {any} */ p) {
|
|
638
|
-
point(p.node.source);
|
|
847
|
+
'ImportDeclaration|ExportNamedDeclaration|ExportAllDeclaration'(/** @type {any} */ p, /** @type {any} */ state) {
|
|
848
|
+
point(p.node.source, state.filename);
|
|
639
849
|
},
|
|
640
|
-
CallExpression(/** @type {any} */ p) {
|
|
850
|
+
CallExpression(/** @type {any} */ p, /** @type {any} */ state) {
|
|
641
851
|
const callee = p.node.callee;
|
|
642
|
-
if (callee?.type === 'Import' || (callee?.type === 'Identifier' && callee.name === 'require'))
|
|
852
|
+
if (callee?.type === 'Import' || (callee?.type === 'Identifier' && callee.name === 'require'))
|
|
853
|
+
point(p.node.arguments?.[0], state.filename);
|
|
643
854
|
},
|
|
644
|
-
ImportExpression(/** @type {any} */ p) {
|
|
645
|
-
point(p.node.source);
|
|
855
|
+
ImportExpression(/** @type {any} */ p, /** @type {any} */ state) {
|
|
856
|
+
point(p.node.source, state.filename);
|
|
646
857
|
},
|
|
647
858
|
},
|
|
648
859
|
};
|
|
649
860
|
};
|
|
650
861
|
}
|
|
651
862
|
|
|
863
|
+
/** An image file's extension at the end of an address's path. */
|
|
864
|
+
const IMAGE_PATH = /\.(png|jpe?g|gif|webp|avif|svg|ico)$/i;
|
|
865
|
+
|
|
866
|
+
/** The words a property or attribute name uses for an image. */
|
|
867
|
+
const IMAGE_WORDS = new Set([
|
|
868
|
+
'avatar',
|
|
869
|
+
'image',
|
|
870
|
+
'img',
|
|
871
|
+
'photo',
|
|
872
|
+
'picture',
|
|
873
|
+
'thumbnail',
|
|
874
|
+
'thumb',
|
|
875
|
+
'logo',
|
|
876
|
+
'icon',
|
|
877
|
+
'cover',
|
|
878
|
+
'banner',
|
|
879
|
+
'poster',
|
|
880
|
+
'background',
|
|
881
|
+
]);
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Whether a property or attribute name names an image: one of its words
|
|
885
|
+
* (`avatarUrl`, `cover_image`, `hero-photos`) is an image word, singular or
|
|
886
|
+
* plural. A word that only holds one (`logoutUrl`, `discoverUrl`) does not.
|
|
887
|
+
* @param {string} name
|
|
888
|
+
*/
|
|
889
|
+
function namesImage(name) {
|
|
890
|
+
return name
|
|
891
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
892
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')
|
|
893
|
+
.split(/[^A-Za-z0-9]+/)
|
|
894
|
+
.some(word => {
|
|
895
|
+
const lower = word.toLowerCase();
|
|
896
|
+
return IMAGE_WORDS.has(lower) || (lower.endsWith('s') && IMAGE_WORDS.has(lower.slice(0, -1)));
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/** The attributes where JSX puts an image's address. */
|
|
901
|
+
const SRC_ATTR = /^(src|srcset|poster)$/i;
|
|
902
|
+
|
|
903
|
+
/** The attributes and properties where a page puts a link's address. */
|
|
904
|
+
const LINK_ATTR = /^(href|xlinkHref)$/i;
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* The name a value is given, through the expressions that only choose or
|
|
908
|
+
* wrap it (`a ? x : y`, `x ?? y`, `x as string`): the key of the object
|
|
909
|
+
* property it is the value of, or the JSX attribute it is in.
|
|
910
|
+
* @param {any} p a path to the value
|
|
911
|
+
* @returns {{name: string, jsx: boolean, element?: string | null} | null}
|
|
912
|
+
* `element`: the JSX element's name, for an attribute
|
|
913
|
+
*/
|
|
914
|
+
function nameOfValue(p) {
|
|
915
|
+
let at = p;
|
|
916
|
+
while (
|
|
917
|
+
at.parentPath &&
|
|
918
|
+
(at.parentPath.isConditionalExpression() ||
|
|
919
|
+
at.parentPath.isLogicalExpression() ||
|
|
920
|
+
at.parentPath.isParenthesizedExpression?.() ||
|
|
921
|
+
at.parentPath.isTSAsExpression?.() ||
|
|
922
|
+
at.parentPath.isTSSatisfiesExpression?.() ||
|
|
923
|
+
at.parentPath.isJSXExpressionContainer())
|
|
924
|
+
) {
|
|
925
|
+
if (at.parentPath.isConditionalExpression() && at.parentPath.node.test === at.node) return null;
|
|
926
|
+
at = at.parentPath;
|
|
927
|
+
}
|
|
928
|
+
const holder = at.parentPath;
|
|
929
|
+
if (!holder) return null;
|
|
930
|
+
if (holder.isJSXAttribute() && holder.node.value === at.node) {
|
|
931
|
+
const n = holder.node.name;
|
|
932
|
+
const tag = holder.parentPath?.node?.name;
|
|
933
|
+
return {
|
|
934
|
+
name: n.type === 'JSXNamespacedName' ? n.name.name : n.name,
|
|
935
|
+
jsx: true,
|
|
936
|
+
element: tag?.type === 'JSXIdentifier' ? tag.name : null,
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
if (holder.isObjectProperty() && holder.node.value === at.node && !holder.node.computed) {
|
|
940
|
+
const k = holder.node.key;
|
|
941
|
+
const name = k.type === 'Identifier' ? k.name : k.type === 'StringLiteral' ? k.value : null;
|
|
942
|
+
return name === null ? null : {name, jsx: false};
|
|
943
|
+
}
|
|
944
|
+
return null;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
/**
|
|
948
|
+
* What the place a value is given says about it: `shown` where an HTML
|
|
949
|
+
* element shows an image from it (showsImage), `name` where only a name
|
|
950
|
+
* says it is an image (a component's or an object's `src`, `srcSet` or
|
|
951
|
+
* `poster`, or a name with an image word), `other` at an HTML element's
|
|
952
|
+
* `src`, `srcset` or `poster` that shows no image (an `<iframe>`'s or a
|
|
953
|
+
* `<video>`'s `src`), and null where nothing says.
|
|
954
|
+
* @param {{name: string, jsx: boolean, element?: string | null} | null} named
|
|
955
|
+
* @returns {'shown' | 'name' | 'other' | null}
|
|
956
|
+
*/
|
|
957
|
+
function imagePlace(named) {
|
|
958
|
+
if (!named) return null;
|
|
959
|
+
if (named.jsx && named.element && /^[a-z]/.test(named.element) && SRC_ATTR.test(named.name)) {
|
|
960
|
+
return showsImage(named.element, named.name.toLowerCase()) ? 'shown' : 'other';
|
|
961
|
+
}
|
|
962
|
+
return SRC_ATTR.test(named.name) || namesImage(named.name) ? 'name' : null;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* Where a value the page writes in its code goes: the place it is given, or,
|
|
967
|
+
* for a variable's value, the place a read of the variable gives it
|
|
968
|
+
* (`const hero = '…'` with `<img src={hero}>`). A read where an element
|
|
969
|
+
* shows it wins over one where only a name says so.
|
|
970
|
+
* @param {any} p a path to the value
|
|
971
|
+
* @returns {{place: 'shown' | 'name' | 'other' | null, srcset: boolean}}
|
|
972
|
+
* `srcset` when that place is a `srcset`, whose candidates are the images
|
|
973
|
+
*/
|
|
974
|
+
function placeOf(p) {
|
|
975
|
+
const own = nameOfValue(p);
|
|
976
|
+
const ownPlace = imagePlace(own);
|
|
977
|
+
if (own && ownPlace) return {place: ownPlace, srcset: /^srcset$/i.test(own.name)};
|
|
978
|
+
const reads = readsOf(p).map(ref => {
|
|
979
|
+
const named = nameOfValue(ref);
|
|
980
|
+
return {place: imagePlace(named), srcset: Boolean(named && /^srcset$/i.test(named.name))};
|
|
981
|
+
});
|
|
982
|
+
return (
|
|
983
|
+
reads.find(read => read.place === 'shown') ??
|
|
984
|
+
reads.find(read => read.place === 'name') ??
|
|
985
|
+
reads.find(read => read.place === 'other') ?? {place: null, srcset: false}
|
|
986
|
+
);
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* Whether a literal is the value of a variable that the page uses as a
|
|
991
|
+
* link's address (`const full = 'https://…/a.png'` with `<a href={full}>`).
|
|
992
|
+
* @param {any} p a path to the literal
|
|
993
|
+
*/
|
|
994
|
+
function reachesLink(p) {
|
|
995
|
+
return readsOf(p).some(ref => {
|
|
996
|
+
const named = nameOfValue(ref);
|
|
997
|
+
return Boolean(named && LINK_ATTR.test(named.name));
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* The reads of the variable a literal is the value of (`const full = '…'`),
|
|
1003
|
+
* through the expressions that only choose or wrap it; none when the literal
|
|
1004
|
+
* is not a variable's value.
|
|
1005
|
+
* @param {any} p a path to the literal
|
|
1006
|
+
* @returns {any[]}
|
|
1007
|
+
*/
|
|
1008
|
+
function readsOf(p) {
|
|
1009
|
+
let at = p;
|
|
1010
|
+
while (
|
|
1011
|
+
at.parentPath &&
|
|
1012
|
+
(at.parentPath.isConditionalExpression() ||
|
|
1013
|
+
at.parentPath.isLogicalExpression() ||
|
|
1014
|
+
at.parentPath.isParenthesizedExpression?.() ||
|
|
1015
|
+
at.parentPath.isTSAsExpression?.() ||
|
|
1016
|
+
at.parentPath.isTSSatisfiesExpression?.())
|
|
1017
|
+
) {
|
|
1018
|
+
at = at.parentPath;
|
|
1019
|
+
}
|
|
1020
|
+
const declarator = at.parentPath;
|
|
1021
|
+
if (!declarator?.isVariableDeclarator() || declarator.node.init !== at.node) return [];
|
|
1022
|
+
const id = declarator.node.id;
|
|
1023
|
+
if (id.type !== 'Identifier') return [];
|
|
1024
|
+
return declarator.scope.getBinding(id.name)?.referencePaths ?? [];
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* The address a template or a `+` chain builds, with each value it puts in
|
|
1029
|
+
* written as `x`, so its fixed parts read as an address.
|
|
1030
|
+
* @param {any} node
|
|
1031
|
+
* @returns {string}
|
|
1032
|
+
*/
|
|
1033
|
+
function builtSkeleton(node) {
|
|
1034
|
+
if (node.type === 'StringLiteral') return node.value;
|
|
1035
|
+
if (node.type === 'TemplateLiteral') return node.quasis.map((/** @type {any} */ q) => q.value.cooked ?? '').join('x');
|
|
1036
|
+
if (node.type === 'BinaryExpression' && node.operator === '+') return builtSkeleton(node.left) + builtSkeleton(node.right);
|
|
1037
|
+
return 'x';
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* Why an https address the page writes as a literal is an image the
|
|
1042
|
+
* render fetches: its path ends in an image extension; an HTML element shows
|
|
1043
|
+
* it (showsImage), where the literal is written or where the page reads the
|
|
1044
|
+
* variable it is the value of; or a name says it is one: a component's or an
|
|
1045
|
+
* object's `src`, `srcSet` or `poster`, or a name with an image word. A
|
|
1046
|
+
* link's address, written in `href` or in a variable only links read, never
|
|
1047
|
+
* counts, nor does an address an HTML element takes for something else (an
|
|
1048
|
+
* `<iframe>`'s or a `<video>`'s `src`) or one whose path names a type that is
|
|
1049
|
+
* never an image (`clip.mp4`), and no other address does. A variable counts
|
|
1050
|
+
* by the reads in its own file.
|
|
1051
|
+
* @param {string} value
|
|
1052
|
+
* @param {any} p a path to the literal
|
|
1053
|
+
* @returns {{srcset: boolean, byName: boolean} | null} whether it is a
|
|
1054
|
+
* `srcSet` (whose candidates are the images) and whether only a name says
|
|
1055
|
+
* it is an image; null for no image the render fetches
|
|
1056
|
+
*/
|
|
1057
|
+
function imageLiteralKind(value, p) {
|
|
1058
|
+
const {place, srcset} = placeOf(p);
|
|
1059
|
+
// A srcset lists candidates, each with its own address, so any of them
|
|
1060
|
+
// can be an https image (`./a.png 1x, https://cdn.example.com/a@2x.png 2x`,
|
|
1061
|
+
// or a value written over several lines).
|
|
1062
|
+
if (srcset ? !srcsetCandidates(value).some(url => /^https:\/\//i.test(url)) : !/^https:\/\//i.test(value)) return null;
|
|
1063
|
+
const named = nameOfValue(p);
|
|
1064
|
+
// A link's address is where the reader goes, even when it names an image
|
|
1065
|
+
// file: the file keeps it as written.
|
|
1066
|
+
// A variable a link and an image both read is an image's address too.
|
|
1067
|
+
const image = place === 'shown' || place === 'name';
|
|
1068
|
+
if ((named && LINK_ATTR.test(named.name)) || (reachesLink(p) && !image)) return null;
|
|
1069
|
+
if (place === 'other') return null;
|
|
1070
|
+
if (srcset) return {srcset: true, byName: place === 'name'};
|
|
1071
|
+
/** @type {string} */
|
|
1072
|
+
let pathname;
|
|
1073
|
+
try {
|
|
1074
|
+
pathname = new URL(value).pathname;
|
|
1075
|
+
} catch {
|
|
1076
|
+
return null;
|
|
1077
|
+
}
|
|
1078
|
+
// A clip, a font or a document is never an image, whatever name holds it.
|
|
1079
|
+
if (NOT_AN_IMAGE.test(pathname)) return null;
|
|
1080
|
+
if (IMAGE_PATH.test(pathname)) return {srcset: false, byName: false};
|
|
1081
|
+
return image ? {srcset: false, byName: place === 'name'} : null;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/**
|
|
1085
|
+
* The TypeScript source a relative `.js`-family import names when no file has
|
|
1086
|
+
* the name as written, as the import walk and the browser bundle resolve it,
|
|
1087
|
+
* or null.
|
|
1088
|
+
* @param {string} spec
|
|
1089
|
+
* @param {string} from the importing file
|
|
1090
|
+
*/
|
|
1091
|
+
function typeScriptSourceOf(spec, from) {
|
|
1092
|
+
if (!spec.startsWith('.') || spec.includes('?')) return null;
|
|
1093
|
+
const written = path.resolve(path.dirname(from), spec);
|
|
1094
|
+
const file = existingFile(written, []);
|
|
1095
|
+
return file && file !== written ? file : null;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* The name a browser module calls `carried` by, imported once at its top.
|
|
1100
|
+
* @param {any} p an import declaration's path
|
|
1101
|
+
* @param {any} t Babel's types
|
|
1102
|
+
*/
|
|
1103
|
+
function carriedName(p, t) {
|
|
1104
|
+
const program = p.scope.getProgramParent();
|
|
1105
|
+
const name = '__astryxCarried';
|
|
1106
|
+
if (!program.hasBinding(name)) {
|
|
1107
|
+
program.path.unshiftContainer(
|
|
1108
|
+
'body',
|
|
1109
|
+
t.importDeclaration(
|
|
1110
|
+
[t.importSpecifier(t.identifier(name), t.identifier('carried'))],
|
|
1111
|
+
t.stringLiteral(CARRIED_MODULE),
|
|
1112
|
+
),
|
|
1113
|
+
);
|
|
1114
|
+
program.crawl();
|
|
1115
|
+
}
|
|
1116
|
+
return t.identifier(name);
|
|
1117
|
+
}
|
|
1118
|
+
|
|
652
1119
|
/**
|
|
653
1120
|
* Babel plugin: replace asset imports with data: URIs and stylesheet imports
|
|
654
1121
|
* with nothing (their CSS is inlined into the page), and record static text
|
|
655
1122
|
* children of capitalized JSX elements.
|
|
1123
|
+
*
|
|
1124
|
+
* For the browser (`browser`), the same imports load the same way, but the
|
|
1125
|
+
* page keeps its real charts and nothing is recorded: the server render
|
|
1126
|
+
* recorded it already.
|
|
656
1127
|
* @param {string} filename
|
|
1128
|
+
* @param {boolean} [browser]
|
|
657
1129
|
*/
|
|
658
|
-
function pagePlugin(filename) {
|
|
1130
|
+
function pagePlugin(filename, browser = false) {
|
|
659
1131
|
const dir = path.dirname(filename);
|
|
1132
|
+
/**
|
|
1133
|
+
* Record an https image address the page builds in code (a template with
|
|
1134
|
+
* values, or `+`) that would count as an image if it were whole (see
|
|
1135
|
+
* imageLiteralKind), read with each value it puts in as `x`
|
|
1136
|
+
* (`https://cdn.example.com/x.png`): the render cannot know it, so the
|
|
1137
|
+
* file asks the network for it when the script draws it.
|
|
1138
|
+
* @param {any} p
|
|
1139
|
+
*/
|
|
1140
|
+
const builtAddress = p => {
|
|
1141
|
+
if (!imageLiteralKind(builtSkeleton(p.node), p)) return;
|
|
1142
|
+
const {start, end} = p.node;
|
|
1143
|
+
const text = typeof start === 'number' && typeof end === 'number' ? p.hub?.file?.code?.slice(start, end) : null;
|
|
1144
|
+
builtRemote.push({text: text ?? '(an address built in code)', file: filename, line: p.node.loc?.start.line ?? 0});
|
|
1145
|
+
};
|
|
660
1146
|
return (/** @type {any} */ {types: t}) => ({
|
|
661
1147
|
visitor: {
|
|
662
1148
|
ImportDeclaration(/** @type {any} */ p) {
|
|
663
1149
|
const spec = /** @type {string} */ (p.node.source.value);
|
|
664
|
-
if (spec === 'recharts') setChartsAside(p, t);
|
|
1150
|
+
if (spec === 'recharts' && !browser) setChartsAside(p, t);
|
|
665
1151
|
const raw = spec.split('?')[0];
|
|
666
1152
|
// A stylesheet, image or JSON file imported through a project alias
|
|
667
1153
|
// (`@/styles/site.css`) resolves the way modules do.
|
|
@@ -722,7 +1208,13 @@ function pagePlugin(filename) {
|
|
|
722
1208
|
}
|
|
723
1209
|
if (/\.(scss|sass|less)$/i.test(bare)) {
|
|
724
1210
|
// Sass and Less need their compiler: say so rather than drop them.
|
|
725
|
-
|
|
1211
|
+
if (!browser) {
|
|
1212
|
+
skippedCss.push(bare);
|
|
1213
|
+
if (bare.startsWith('.') || path.isAbsolute(bare)) {
|
|
1214
|
+
const file = path.resolve(dir, bare);
|
|
1215
|
+
if (!outsideFiles.includes(file)) outsideFiles.push(file);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
726
1218
|
p.remove();
|
|
727
1219
|
return;
|
|
728
1220
|
}
|
|
@@ -760,7 +1252,7 @@ function pagePlugin(filename) {
|
|
|
760
1252
|
} else {
|
|
761
1253
|
// A package stylesheet (a theme's, say): the caller resolves it
|
|
762
1254
|
// from this file and inlines the rules the page uses.
|
|
763
|
-
packageCss.push({spec: bare, from: filename});
|
|
1255
|
+
if (!browser) packageCss.push({spec: bare, from: filename});
|
|
764
1256
|
}
|
|
765
1257
|
p.remove();
|
|
766
1258
|
return;
|
|
@@ -777,22 +1269,75 @@ function pagePlugin(filename) {
|
|
|
777
1269
|
p.remove();
|
|
778
1270
|
return;
|
|
779
1271
|
}
|
|
1272
|
+
// In the browser the image comes from the embedded source, which
|
|
1273
|
+
// carries it; the render inlines one the source leaves out.
|
|
1274
|
+
const base64 = browser ? /^(data:[^,]*;base64),/.exec(uri) : null;
|
|
780
1275
|
p.replaceWith(
|
|
781
1276
|
t.variableDeclaration('const', [
|
|
782
|
-
t.variableDeclarator(
|
|
1277
|
+
t.variableDeclarator(
|
|
1278
|
+
t.identifier(local.local.name),
|
|
1279
|
+
base64
|
|
1280
|
+
? t.callExpression(carriedName(p, t), [
|
|
1281
|
+
t.stringLiteral(sha256(fs.readFileSync(file))),
|
|
1282
|
+
t.stringLiteral(base64[1]),
|
|
1283
|
+
])
|
|
1284
|
+
: t.stringLiteral(uri),
|
|
1285
|
+
),
|
|
783
1286
|
]),
|
|
784
1287
|
);
|
|
785
1288
|
}
|
|
786
1289
|
},
|
|
787
1290
|
'CallExpression|OptionalCallExpression'(/** @type {any} */ p) {
|
|
1291
|
+
if (browser) return;
|
|
788
1292
|
const call = screenQuery(p);
|
|
789
1293
|
if (call) screenQueries.push({call, file: filename, line: p.node.loc?.start.line ?? 0});
|
|
790
1294
|
},
|
|
1295
|
+
StringLiteral(/** @type {any} */ p) {
|
|
1296
|
+
if (browser || p.parentPath.isImportDeclaration() || p.parentPath.isExportDeclaration()) return;
|
|
1297
|
+
// The first part of an address built with `+` is not an address: the
|
|
1298
|
+
// chain gets its own warning.
|
|
1299
|
+
if (p.parentPath.isBinaryExpression({operator: '+'})) return;
|
|
1300
|
+
noteRemoteLiteral(p.node.value, imageLiteralKind(p.node.value, p));
|
|
1301
|
+
},
|
|
1302
|
+
TemplateLiteral(/** @type {any} */ p) {
|
|
1303
|
+
if (browser || p.parentPath.isTaggedTemplateExpression()) return;
|
|
1304
|
+
if (p.node.expressions.length === 0) {
|
|
1305
|
+
if (p.parentPath.isBinaryExpression({operator: '+'})) return;
|
|
1306
|
+
const value = p.node.quasis[0]?.value.cooked ?? '';
|
|
1307
|
+
noteRemoteLiteral(value, imageLiteralKind(value, p));
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
// A template inside a `+` chain is part of the chain's address.
|
|
1311
|
+
if (p.parentPath.isBinaryExpression({operator: '+'})) return;
|
|
1312
|
+
builtAddress(p);
|
|
1313
|
+
},
|
|
1314
|
+
BinaryExpression(/** @type {any} */ p) {
|
|
1315
|
+
if (browser || p.node.operator !== '+' || p.parentPath.isBinaryExpression({operator: '+'})) return;
|
|
1316
|
+
builtAddress(p);
|
|
1317
|
+
},
|
|
1318
|
+
JSXOpeningElement(/** @type {any} */ p) {
|
|
1319
|
+
if (browser) return;
|
|
1320
|
+
const component = coreComponentOf(p.node.name, p.scope);
|
|
1321
|
+
if (!component) return;
|
|
1322
|
+
for (const attr of p.node.attributes) {
|
|
1323
|
+
if (attr.type !== 'JSXAttribute' || attr.name.type !== 'JSXIdentifier') continue;
|
|
1324
|
+
const value =
|
|
1325
|
+
attr.value?.type === 'StringLiteral'
|
|
1326
|
+
? attr.value.value
|
|
1327
|
+
: attr.value?.type === 'JSXExpressionContainer' && attr.value.expression.type === 'StringLiteral'
|
|
1328
|
+
? attr.value.expression.value
|
|
1329
|
+
: null;
|
|
1330
|
+
if (value === null) continue;
|
|
1331
|
+
propValues.push({component, prop: attr.name.name, value, file: filename, line: attr.loc?.start.line ?? 0});
|
|
1332
|
+
}
|
|
1333
|
+
},
|
|
791
1334
|
JSXText(/** @type {any} */ p) {
|
|
1335
|
+
if (browser) return;
|
|
792
1336
|
const v = cleanText(p.node);
|
|
793
1337
|
if (v.length >= 2) (fnTexts[fnKey(p)] ??= []).push(v);
|
|
794
1338
|
},
|
|
795
1339
|
JSXElement(/** @type {any} */ p) {
|
|
1340
|
+
if (browser) return;
|
|
796
1341
|
const component = jsxName(p.node);
|
|
797
1342
|
if (!/^[A-Z]/.test(component)) return;
|
|
798
1343
|
// Only children that are all static text: the whole text must show.
|
|
@@ -857,6 +1402,17 @@ function pagePlugin(filename) {
|
|
|
857
1402
|
}
|
|
858
1403
|
}
|
|
859
1404
|
}
|
|
1405
|
+
// The element and the components around it in the same JSX tree,
|
|
1406
|
+
// innermost first: any of them can be the one that drops the text.
|
|
1407
|
+
/** @type {{component: string, line: number, from: string | null, name: string}[]} */
|
|
1408
|
+
const chain = [];
|
|
1409
|
+
for (let up = p; up && (up.isJSXElement() || up.isJSXFragment()); up = up.parentPath) {
|
|
1410
|
+
if (!up.isJSXElement()) continue;
|
|
1411
|
+
const name = jsxName(up.node);
|
|
1412
|
+
// Host elements are not components; a member name (`ui.Box`) is.
|
|
1413
|
+
if (!/^[A-Z]/.test(name) && !name.includes('.')) continue;
|
|
1414
|
+
chain.push({component: name, line: up.node.loc?.start.line ?? 0, ...importOf(up, name)});
|
|
1415
|
+
}
|
|
860
1416
|
texts.push({
|
|
861
1417
|
file: filename,
|
|
862
1418
|
component,
|
|
@@ -864,6 +1420,7 @@ function pagePlugin(filename) {
|
|
|
864
1420
|
hidden: hidden || conditional,
|
|
865
1421
|
fn: fnKey(p),
|
|
866
1422
|
line: p.node.loc?.start.line ?? 0,
|
|
1423
|
+
chain,
|
|
867
1424
|
});
|
|
868
1425
|
},
|
|
869
1426
|
},
|
|
@@ -969,13 +1526,32 @@ function serveFromSet() {
|
|
|
969
1526
|
? packageOf(request)
|
|
970
1527
|
: null;
|
|
971
1528
|
if (!name || !isServedPackage(name, served.integrations)) throw e;
|
|
972
|
-
const file = resolveFilename.call(this, request, servedParent, false);
|
|
1529
|
+
const file = servedFile(request, () => resolveFilename.call(this, request, servedParent, false));
|
|
973
1530
|
if (!fromSet.has(name)) fromSet.set(name, packageDirOf(file, name));
|
|
974
1531
|
return file;
|
|
975
1532
|
}
|
|
976
1533
|
};
|
|
977
1534
|
}
|
|
978
1535
|
|
|
1536
|
+
/**
|
|
1537
|
+
* The file the set serves for `request`: what the CommonJS resolve gives,
|
|
1538
|
+
* or, when that finds the subpath not exported, the file the package exports
|
|
1539
|
+
* to an ES module import (a subpath exported under `import` only).
|
|
1540
|
+
* @param {string} request
|
|
1541
|
+
* @param {() => string} resolveAsRequire
|
|
1542
|
+
* @returns {string}
|
|
1543
|
+
*/
|
|
1544
|
+
function servedFile(request, resolveAsRequire) {
|
|
1545
|
+
try {
|
|
1546
|
+
return resolveAsRequire();
|
|
1547
|
+
} catch (e) {
|
|
1548
|
+
const file =
|
|
1549
|
+
/** @type {any} */ (e)?.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED' && served ? servedImportTarget(request, served.dir) : null;
|
|
1550
|
+
if (!file) throw e;
|
|
1551
|
+
return file;
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
|
|
979
1555
|
/**
|
|
980
1556
|
* React and StyleX keep state per copy, and the packages from the set load
|
|
981
1557
|
* the set's copy. So outside a project the page's own modules load that copy
|
|
@@ -1004,6 +1580,12 @@ if (servedParent && Object.keys(SINGLE_COPY_ALIASES).length > 0) {
|
|
|
1004
1580
|
data: {parent: pathToFileURL(servedParent.filename).href, names: Object.keys(SINGLE_COPY_ALIASES)},
|
|
1005
1581
|
});
|
|
1006
1582
|
}
|
|
1583
|
+
// Imports between the files of an installed package resolve by path (a
|
|
1584
|
+
// Node without in-thread hooks resolves them itself). The hook answers only
|
|
1585
|
+
// relative imports inside a package, and single-copy-hooks.mjs answers only
|
|
1586
|
+
// package names, so neither changes what the other resolves.
|
|
1587
|
+
const registerHooks = /** @type {any} */ (Module).registerHooks;
|
|
1588
|
+
if (typeof registerHooks === 'function') registerHooks(packageResolveHooks());
|
|
1007
1589
|
|
|
1008
1590
|
/** What the StyleX compiler reads as a theme or constants file, by name. */
|
|
1009
1591
|
const STYLEX_THEME_FILE = /\.(?:stylex(?:\.const)?|transformed)(?:\.(?:js|ts|tsx|jsx|mjs|cjs))?$/;
|
|
@@ -1031,6 +1613,106 @@ function servedThemeFiles(source, filename) {
|
|
|
1031
1613
|
return Object.keys(files).length > 0 ? files : null;
|
|
1032
1614
|
}
|
|
1033
1615
|
|
|
1616
|
+
/**
|
|
1617
|
+
* The StyleX compiler and its options for one file: the page's class-name
|
|
1618
|
+
* prefix, and the theme files a module outside a project imports.
|
|
1619
|
+
* @param {string} source
|
|
1620
|
+
* @param {string} filename
|
|
1621
|
+
* @returns {[unknown, object]}
|
|
1622
|
+
*/
|
|
1623
|
+
function stylexPluginFor(source, filename) {
|
|
1624
|
+
const themeFiles = servedThemeFiles(source, filename);
|
|
1625
|
+
return [
|
|
1626
|
+
stylexPlugin,
|
|
1627
|
+
{
|
|
1628
|
+
dev: false,
|
|
1629
|
+
runtimeInjection: false,
|
|
1630
|
+
treeshakeCompensation: true,
|
|
1631
|
+
classNamePrefix: PAGE_CLASS_PREFIX,
|
|
1632
|
+
unstable_moduleResolution: {type: 'commonJS', rootDir: root},
|
|
1633
|
+
...(themeFiles ? {aliases: themeFiles} : {}),
|
|
1634
|
+
},
|
|
1635
|
+
];
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
/**
|
|
1639
|
+
* A StyleX call that the compiler replaces at build time. Compiled StyleX
|
|
1640
|
+
* keeps only runtime calls such as `props`, so a package file without one of
|
|
1641
|
+
* these calls ships compiled styles.
|
|
1642
|
+
*/
|
|
1643
|
+
const STYLEX_BUILD_CALL = /\b(?:create|keyframes|defineVars|defineConsts|createTheme|firstThatWorks|positionTry|defineMarker|defaultMarker|viewTransitionClass)\s*\(/g;
|
|
1644
|
+
|
|
1645
|
+
/** @param {string} code how many StyleX build-time calls the code holds */
|
|
1646
|
+
const buildCalls = code => code.match(STYLEX_BUILD_CALL)?.length ?? 0;
|
|
1647
|
+
|
|
1648
|
+
/** Each package file checked for StyleX source: its compiled code, or null when it stays as it ships. @type {Map<string, string | null>} */
|
|
1649
|
+
const packageStylex = new Map();
|
|
1650
|
+
/** Each package file that holds StyleX source, for the page's script. @type {Set<string>} */
|
|
1651
|
+
const stylexSourceFiles = new Set();
|
|
1652
|
+
|
|
1653
|
+
/**
|
|
1654
|
+
* A package file (installed, or a workspace package linked in) that ships
|
|
1655
|
+
* StyleX source, compiled with StyleX only, as an app's build compiles it:
|
|
1656
|
+
* with the page's class-name prefix, its rules joining the page's. Null for
|
|
1657
|
+
* every other file, which stays byte for byte as it ships. Each file is
|
|
1658
|
+
* compiled once, for the server and the browser both.
|
|
1659
|
+
* @param {string} source
|
|
1660
|
+
* @param {string} filename
|
|
1661
|
+
* @returns {string | null}
|
|
1662
|
+
*/
|
|
1663
|
+
function compilePackageStylex(source, filename) {
|
|
1664
|
+
const known = packageStylex.get(filename);
|
|
1665
|
+
if (known !== undefined) return known;
|
|
1666
|
+
/** @type {string | null} */
|
|
1667
|
+
let code = null;
|
|
1668
|
+
if (source.includes('@stylexjs/stylex') && buildCalls(source) > 0) {
|
|
1669
|
+
const ts = /\.(tsx?|mts|cts)$/.test(filename);
|
|
1670
|
+
const result = transformSync(source, {
|
|
1671
|
+
filename,
|
|
1672
|
+
babelrc: false,
|
|
1673
|
+
configFile: false,
|
|
1674
|
+
sourceType: 'unambiguous',
|
|
1675
|
+
parserOpts: {
|
|
1676
|
+
plugins: /** @type {import('@babel/core').ParserOptions['plugins']} */ (
|
|
1677
|
+
ts ? [...(/\.[cm]?tsx$/.test(filename) ? ['jsx'] : []), 'typescript', 'decorators-legacy'] : ['jsx']
|
|
1678
|
+
),
|
|
1679
|
+
},
|
|
1680
|
+
generatorOpts: {retainLines: true},
|
|
1681
|
+
compact: false,
|
|
1682
|
+
plugins: [stylexPluginFor(source, filename)],
|
|
1683
|
+
});
|
|
1684
|
+
const rules = /** @type {any} */ (result?.metadata)?.stylex;
|
|
1685
|
+
// A marker (`defineMarker`, `defaultMarker`) compiles to a class name with
|
|
1686
|
+
// no rule, so a file whose compile replaced a build-time call counts too.
|
|
1687
|
+
// Compiled StyleX keeps its count: only comments and other names match.
|
|
1688
|
+
const hasRules = Array.isArray(rules) && rules.length > 0;
|
|
1689
|
+
if (result?.code && (hasRules || buildCalls(result.code) < buildCalls(source))) {
|
|
1690
|
+
if (hasRules) stylexRules.push(...rules);
|
|
1691
|
+
code = result.code;
|
|
1692
|
+
stylexSourceFiles.add(filename);
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
packageStylex.set(filename, code);
|
|
1696
|
+
return code;
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
/**
|
|
1700
|
+
* The package files in a built script that no render checked yet, checked
|
|
1701
|
+
* for StyleX source now: files only the browser loads, such as a package a
|
|
1702
|
+
* click imports or a module of one that only a lazily loaded module imports.
|
|
1703
|
+
* @param {string[]} files
|
|
1704
|
+
* @returns {boolean} whether one of them holds StyleX source
|
|
1705
|
+
*/
|
|
1706
|
+
function checkScriptFiles(files) {
|
|
1707
|
+
let found = false;
|
|
1708
|
+
for (const file of files) {
|
|
1709
|
+
if (packageStylex.has(file) || isLocal(file) || !/\.(tsx?|jsx?|mjs|cjs|mts|cts)$/.test(file)) continue;
|
|
1710
|
+
if (!fs.existsSync(file)) continue;
|
|
1711
|
+
if (compilePackageStylex(fs.readFileSync(file, 'utf8'), file) !== null) found = true;
|
|
1712
|
+
}
|
|
1713
|
+
return found;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1034
1716
|
const plain = createJiti(entry, {fsCache: false, jsx: {runtime: 'automatic'}});
|
|
1035
1717
|
|
|
1036
1718
|
const jiti = createJiti(entry, {
|
|
@@ -1041,79 +1723,92 @@ const jiti = createJiti(entry, {
|
|
|
1041
1723
|
interopDefault: true,
|
|
1042
1724
|
alias: SINGLE_COPY_ALIASES,
|
|
1043
1725
|
jsx: {runtime: 'automatic'},
|
|
1044
|
-
transform(opts)
|
|
1045
|
-
// jiti names the file with forward slashes on Windows (`C:/...`), while
|
|
1046
|
-
// `entry`, `root` and the node_modules test use the platform separator.
|
|
1047
|
-
// Without this, no file reads as local there and none is transformed.
|
|
1048
|
-
const filename = opts.filename ? path.normalize(opts.filename) : '';
|
|
1049
|
-
let source = opts.source;
|
|
1050
|
-
if (filename && isLocal(filename) && /\.json$/i.test(filename) && !localFiles.includes(filename)) {
|
|
1051
|
-
localFiles.push(filename);
|
|
1052
|
-
}
|
|
1053
|
-
if (filename && isLocal(filename) && /\.(tsx?|jsx?|mjs|cjs|mts|cts)$/.test(filename)) {
|
|
1054
|
-
if (!localFiles.includes(filename)) localFiles.push(filename);
|
|
1055
|
-
const ts = /\.(tsx?|mts|cts)$/.test(filename);
|
|
1056
|
-
const themeFiles = source.includes('stylex') ? servedThemeFiles(source, filename) : null;
|
|
1057
|
-
const result = transformSync(source, {
|
|
1058
|
-
filename,
|
|
1059
|
-
babelrc: false,
|
|
1060
|
-
configFile: false,
|
|
1061
|
-
sourceType: 'module',
|
|
1062
|
-
parserOpts: {plugins: ts ? ['jsx', 'typescript'] : ['jsx']},
|
|
1063
|
-
generatorOpts: {retainLines: true},
|
|
1064
|
-
compact: false,
|
|
1065
|
-
plugins: [
|
|
1066
|
-
aliasPlugin(),
|
|
1067
|
-
pagePlugin(filename),
|
|
1068
|
-
...(source.includes('stylex')
|
|
1069
|
-
? [
|
|
1070
|
-
[
|
|
1071
|
-
stylexPlugin,
|
|
1072
|
-
{
|
|
1073
|
-
dev: false,
|
|
1074
|
-
runtimeInjection: false,
|
|
1075
|
-
treeshakeCompensation: true,
|
|
1076
|
-
unstable_moduleResolution: {type: 'commonJS', rootDir: root},
|
|
1077
|
-
...(themeFiles ? {aliases: themeFiles} : {}),
|
|
1078
|
-
},
|
|
1079
|
-
],
|
|
1080
|
-
]
|
|
1081
|
-
: []),
|
|
1082
|
-
],
|
|
1083
|
-
});
|
|
1084
|
-
const rules = /** @type {any} */ (result?.metadata)?.stylex;
|
|
1085
|
-
if (Array.isArray(rules)) stylexRules.push(...rules);
|
|
1086
|
-
source = result?.code ?? source;
|
|
1087
|
-
} else if (
|
|
1088
|
-
PATHS.length > 0 &&
|
|
1089
|
-
filename &&
|
|
1090
|
-
!filename.includes(NODE_MODULES) &&
|
|
1091
|
-
/\.(tsx?|jsx?|mjs|cjs|mts|cts)$/.test(filename)
|
|
1092
|
-
) {
|
|
1093
|
-
const ts = /\.(tsx?|mts|cts)$/.test(filename);
|
|
1094
|
-
const result = transformSync(source, {
|
|
1095
|
-
filename,
|
|
1096
|
-
babelrc: false,
|
|
1097
|
-
configFile: false,
|
|
1098
|
-
sourceType: 'unambiguous',
|
|
1099
|
-
// The options jiti compiles these files with: JSX only in .jsx and
|
|
1100
|
-
// .tsx files (so `<string>value` stays a type assertion), and legacy
|
|
1101
|
-
// decorators.
|
|
1102
|
-
parserOpts: {
|
|
1103
|
-
plugins: /** @type {import('@babel/core').ParserOptions['plugins']} */ (
|
|
1104
|
-
ts ? [...(/\.[cm]?tsx$/.test(filename) ? ['jsx'] : []), 'typescript', 'decorators-legacy'] : ['jsx']
|
|
1105
|
-
),
|
|
1106
|
-
},
|
|
1107
|
-
generatorOpts: {retainLines: true},
|
|
1108
|
-
compact: false,
|
|
1109
|
-
plugins: [aliasPlugin()],
|
|
1110
|
-
});
|
|
1111
|
-
source = result?.code ?? source;
|
|
1112
|
-
}
|
|
1113
|
-
return {code: plain.transform({...opts, source, babel: {...opts.babel, compact: false}})};
|
|
1114
|
-
},
|
|
1726
|
+
transform: opts => transformModule(opts),
|
|
1115
1727
|
});
|
|
1116
1728
|
|
|
1729
|
+
/**
|
|
1730
|
+
* One of the page's own files, or a file outside them and outside
|
|
1731
|
+
* `node_modules` that a path alias may reach, compiled as the server
|
|
1732
|
+
* compiles it: the page's files with its plugins and StyleX, the other with
|
|
1733
|
+
* its path aliases. A package file that ships StyleX source compiles with
|
|
1734
|
+
* StyleX ({@link compilePackageStylex}). The code stays an ES module with its
|
|
1735
|
+
* JSX and types. For the browser (`browser`), the page's files keep their
|
|
1736
|
+
* real charts and record nothing. Null for any other file.
|
|
1737
|
+
* @param {string} source
|
|
1738
|
+
* @param {string} filename
|
|
1739
|
+
* @param {boolean} [browser]
|
|
1740
|
+
* @returns {string | null}
|
|
1741
|
+
*/
|
|
1742
|
+
function compilePageModule(source, filename, browser = false) {
|
|
1743
|
+
if (isLocal(filename) && /\.(tsx?|jsx?|mjs|cjs|mts|cts)$/.test(filename)) {
|
|
1744
|
+
if (!localFiles.includes(filename)) localFiles.push(filename);
|
|
1745
|
+
moduleFiles.add(filename);
|
|
1746
|
+
const ts = /\.(tsx?|mts|cts)$/.test(filename);
|
|
1747
|
+
const result = transformSync(source, {
|
|
1748
|
+
filename,
|
|
1749
|
+
babelrc: false,
|
|
1750
|
+
configFile: false,
|
|
1751
|
+
sourceType: 'module',
|
|
1752
|
+
parserOpts: {plugins: ts ? ['jsx', 'typescript'] : ['jsx']},
|
|
1753
|
+
generatorOpts: {retainLines: true},
|
|
1754
|
+
compact: false,
|
|
1755
|
+
plugins: [
|
|
1756
|
+
aliasPlugin(),
|
|
1757
|
+
pagePlugin(filename, browser),
|
|
1758
|
+
...(source.includes('stylex') ? [stylexPluginFor(source, filename)] : []),
|
|
1759
|
+
],
|
|
1760
|
+
});
|
|
1761
|
+
const rules = /** @type {any} */ (result?.metadata)?.stylex;
|
|
1762
|
+
if (Array.isArray(rules)) stylexRules.push(...rules);
|
|
1763
|
+
return result?.code ?? source;
|
|
1764
|
+
}
|
|
1765
|
+
if (!/\.(tsx?|jsx?|mjs|cjs|mts|cts)$/.test(filename)) return null;
|
|
1766
|
+
const packageCode = compilePackageStylex(source, filename);
|
|
1767
|
+
if (packageCode !== null) source = packageCode;
|
|
1768
|
+
if (PATHS.length > 0 && !filename.includes(NODE_MODULES)) {
|
|
1769
|
+
const ts = /\.(tsx?|mts|cts)$/.test(filename);
|
|
1770
|
+
const result = transformSync(source, {
|
|
1771
|
+
filename,
|
|
1772
|
+
babelrc: false,
|
|
1773
|
+
configFile: false,
|
|
1774
|
+
sourceType: 'unambiguous',
|
|
1775
|
+
// The options jiti compiles these files with: JSX only in .jsx and
|
|
1776
|
+
// .tsx files (so `<string>value` stays a type assertion), and legacy
|
|
1777
|
+
// decorators.
|
|
1778
|
+
parserOpts: {
|
|
1779
|
+
plugins: /** @type {import('@babel/core').ParserOptions['plugins']} */ (
|
|
1780
|
+
ts ? [...(/\.[cm]?tsx$/.test(filename) ? ['jsx'] : []), 'typescript', 'decorators-legacy'] : ['jsx']
|
|
1781
|
+
),
|
|
1782
|
+
},
|
|
1783
|
+
generatorOpts: {retainLines: true},
|
|
1784
|
+
compact: false,
|
|
1785
|
+
plugins: [aliasPlugin()],
|
|
1786
|
+
});
|
|
1787
|
+
return result?.code ?? source;
|
|
1788
|
+
}
|
|
1789
|
+
return packageCode;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
/**
|
|
1793
|
+
* One module as CommonJS, for the server render: {@link compilePageModule}
|
|
1794
|
+
* for the page's files and the files its aliases reach, then jiti.
|
|
1795
|
+
* @param {import('jiti').TransformOptions} opts
|
|
1796
|
+
* @returns {{code: string}}
|
|
1797
|
+
*/
|
|
1798
|
+
function transformModule(opts) {
|
|
1799
|
+
// jiti names the file with forward slashes on Windows (`C:/...`), while
|
|
1800
|
+
// `entry`, `root` and the node_modules test use the platform separator.
|
|
1801
|
+
// Without this, no file reads as local there and none is transformed.
|
|
1802
|
+
const filename = opts.filename ? path.normalize(opts.filename) : '';
|
|
1803
|
+
let source = opts.source;
|
|
1804
|
+
if (filename && isLocal(filename) && /\.json$/i.test(filename) && !localFiles.includes(filename)) {
|
|
1805
|
+
localFiles.push(filename);
|
|
1806
|
+
}
|
|
1807
|
+
const compiled = filename ? compilePageModule(source, filename) : null;
|
|
1808
|
+
if (compiled !== null) source = compiled;
|
|
1809
|
+
return {code: plain.transform({...opts, source, babel: {...opts.babel, compact: false}})};
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1117
1812
|
/**
|
|
1118
1813
|
* @param {string} code
|
|
1119
1814
|
* @param {string} message
|
|
@@ -1145,10 +1840,7 @@ function compileText(err) {
|
|
|
1145
1840
|
*/
|
|
1146
1841
|
function compileSite(err) {
|
|
1147
1842
|
const {text, named} = compileText(err);
|
|
1148
|
-
const
|
|
1149
|
-
const file = named
|
|
1150
|
-
? (fromRoot.startsWith('..') || path.isAbsolute(fromRoot) ? path.basename(named) : fromRoot).split(path.sep).join('/')
|
|
1151
|
-
: undefined;
|
|
1843
|
+
const file = named ? siteFile(named) : undefined;
|
|
1152
1844
|
const frame = /^>\s*(\d+)\s*\|(.*)\n\s*\|(\s*)(\^+)/m.exec(text);
|
|
1153
1845
|
const line = err?.loc?.line ?? (frame ? Number(frame[1]) : undefined);
|
|
1154
1846
|
const column = err?.loc ? err.loc.column + 1 : frame ? frame[3].length : undefined;
|
|
@@ -1165,6 +1857,33 @@ function compileSite(err) {
|
|
|
1165
1857
|
};
|
|
1166
1858
|
}
|
|
1167
1859
|
|
|
1860
|
+
/**
|
|
1861
|
+
* A file as a compile error names it: a path from the project, or its name
|
|
1862
|
+
* when it lies outside the project.
|
|
1863
|
+
* @param {string} named
|
|
1864
|
+
*/
|
|
1865
|
+
function siteFile(named) {
|
|
1866
|
+
const fromRoot = path.relative(root, named);
|
|
1867
|
+
return (fromRoot.startsWith('..') || path.isAbsolute(fromRoot) ? path.basename(named) : fromRoot)
|
|
1868
|
+
.split(path.sep)
|
|
1869
|
+
.join('/');
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
/**
|
|
1873
|
+
* Refuse a page that imports a name its module does not export, as a build
|
|
1874
|
+
* refuses it.
|
|
1875
|
+
* @param {{source: string, line: number, names: string[], module?: string}} absent
|
|
1876
|
+
*/
|
|
1877
|
+
function failMissingExport(absent) {
|
|
1878
|
+
const file = siteFile(absent.source);
|
|
1879
|
+
const module = absent.module ?? importedFrom(absent.source, absent.line) ?? 'its module';
|
|
1880
|
+
fail(
|
|
1881
|
+
'ERR_RENDER_COMPILE',
|
|
1882
|
+
`The page does not compile (${file}, line ${absent.line}): ${module} has no export ${absent.names.join(', ')}`,
|
|
1883
|
+
{file, line: absent.line},
|
|
1884
|
+
);
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1168
1887
|
/**
|
|
1169
1888
|
* The module an import declaration names, read from the line of one of its
|
|
1170
1889
|
* names onward (an import can span lines).
|
|
@@ -1186,12 +1905,80 @@ function importedFrom(file, line) {
|
|
|
1186
1905
|
return undefined;
|
|
1187
1906
|
}
|
|
1188
1907
|
|
|
1908
|
+
/**
|
|
1909
|
+
* A package subpath that the package's `exports` do not list, as Node names
|
|
1910
|
+
* it, with the import in the page's own files that asks for it when one does.
|
|
1911
|
+
* @param {string} message
|
|
1912
|
+
* @returns {{module: string, subpath: string, source?: string, line?: number} | null}
|
|
1913
|
+
*/
|
|
1914
|
+
function unexportedSubpath(message) {
|
|
1915
|
+
const named = /Package subpath '([^']+)' is not defined by "exports" in (\S+package\.json)/.exec(message);
|
|
1916
|
+
if (!named) return null;
|
|
1917
|
+
const [, subpath, manifest] = named;
|
|
1918
|
+
/** @type {string} */
|
|
1919
|
+
let module;
|
|
1920
|
+
try {
|
|
1921
|
+
module = String(JSON.parse(fs.readFileSync(manifest, 'utf8')).name);
|
|
1922
|
+
} catch {
|
|
1923
|
+
module = describeFile(manifest);
|
|
1924
|
+
}
|
|
1925
|
+
const spec = `${module}${subpath.slice(1)}`;
|
|
1926
|
+
for (const file of new Set([entry, ...localFiles])) {
|
|
1927
|
+
let records;
|
|
1928
|
+
try {
|
|
1929
|
+
records = moduleImports(fs.readFileSync(file, 'utf8'), file);
|
|
1930
|
+
} catch {
|
|
1931
|
+
continue;
|
|
1932
|
+
}
|
|
1933
|
+
const asked = records?.find(record => record.specifier.split('?')[0] === spec);
|
|
1934
|
+
if (asked) return {module, subpath, source: file, line: asked.line ?? 1};
|
|
1935
|
+
}
|
|
1936
|
+
return {module, subpath};
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
/**
|
|
1940
|
+
* The subpath of a package import that the package's `exports` do not list,
|
|
1941
|
+
* when Node refuses the import for that reason, as the importing file or the
|
|
1942
|
+
* served Core sees it.
|
|
1943
|
+
* @param {string} spec
|
|
1944
|
+
* @param {string} file the importing file
|
|
1945
|
+
* @returns {string | null} the subpath, as `./tokens/spacing.stylex`
|
|
1946
|
+
*/
|
|
1947
|
+
function notExportedSubpath(spec, file) {
|
|
1948
|
+
if (spec.startsWith('.') || path.isAbsolute(spec)) return null;
|
|
1949
|
+
const pkg = packageOf(spec);
|
|
1950
|
+
const attempts = [() => createRequire(file).resolve(spec)];
|
|
1951
|
+
if (served && isServedPackage(pkg, served.integrations)) {
|
|
1952
|
+
const servedDir = served.dir;
|
|
1953
|
+
attempts.push(() =>
|
|
1954
|
+
servedFile(spec, () => createRequire(path.join(servedDir, 'package.json')).resolve(spec, {paths: [servedDir]})),
|
|
1955
|
+
);
|
|
1956
|
+
}
|
|
1957
|
+
for (const attempt of attempts) {
|
|
1958
|
+
try {
|
|
1959
|
+
attempt();
|
|
1960
|
+
return null;
|
|
1961
|
+
} catch (e) {
|
|
1962
|
+
if (/** @type {any} */ (e)?.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') return `.${spec.slice(pkg.length)}`;
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
return null;
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1189
1968
|
/** @param {unknown} e */
|
|
1190
1969
|
function classify(e) {
|
|
1191
1970
|
const err = /** @type {any} */ (e);
|
|
1192
1971
|
if (err?.renderCode) return fail(err.renderCode, compileText(err).text);
|
|
1193
1972
|
// Babel prefixes errors raised while compiling with the file's path.
|
|
1194
1973
|
const message = compileText(err).text;
|
|
1974
|
+
// A build refuses an import of a subpath the package does not export.
|
|
1975
|
+
const unexported = unexportedSubpath(message);
|
|
1976
|
+
if (unexported?.source && unexported.line) {
|
|
1977
|
+
return failMissingExport({source: unexported.source, line: unexported.line, module: unexported.module, names: [unexported.subpath]});
|
|
1978
|
+
}
|
|
1979
|
+
if (unexported) {
|
|
1980
|
+
return fail('ERR_RENDER_COMPILE', `The page does not compile: ${unexported.module} has no export ${unexported.subpath}`);
|
|
1981
|
+
}
|
|
1195
1982
|
if (/suspended while responding to synchronous input|A component suspended/.test(message)) {
|
|
1196
1983
|
return fail(
|
|
1197
1984
|
'ERR_RENDER_FAILED',
|
|
@@ -1224,6 +2011,10 @@ function classify(e) {
|
|
|
1224
2011
|
// only from a file it can read, which it says without naming the import.
|
|
1225
2012
|
if (reason.startsWith('Could not resolve the path to the imported file')) {
|
|
1226
2013
|
const spec = site.source && site.line ? importedFrom(site.source, site.line) : undefined;
|
|
2014
|
+
const subpath = spec && site.source && site.line ? notExportedSubpath(spec, site.source) : null;
|
|
2015
|
+
if (spec && subpath && site.source && site.line) {
|
|
2016
|
+
return failMissingExport({source: site.source, line: site.line, module: packageOf(spec), names: [subpath]});
|
|
2017
|
+
}
|
|
1227
2018
|
const value = site.token ? `\`${site.token}\`` : 'an imported value';
|
|
1228
2019
|
reason =
|
|
1229
2020
|
spec && /\.stylex(?:\.[cm]?[jt]sx?)?$/.test(spec)
|
|
@@ -1250,6 +2041,219 @@ function classify(e) {
|
|
|
1250
2041
|
return fail('ERR_RENDER_FAILED', `The page threw while rendering: ${message.split('\n')[0]}`);
|
|
1251
2042
|
}
|
|
1252
2043
|
|
|
2044
|
+
/**
|
|
2045
|
+
* One of the page's files for esbuild (client-bundle.mjs), compiled as the
|
|
2046
|
+
* server compiled it; null for a file esbuild loads itself.
|
|
2047
|
+
* @param {string} file
|
|
2048
|
+
* @returns {{contents: string, loader: 'tsx' | 'ts' | 'jsx'} | null}
|
|
2049
|
+
*/
|
|
2050
|
+
function browserSource(file) {
|
|
2051
|
+
const filename = path.normalize(file);
|
|
2052
|
+
const compiled = compilePageModule(fs.readFileSync(filename, 'utf8'), filename, true);
|
|
2053
|
+
if (compiled === null) return null;
|
|
2054
|
+
const loader = /\.[cm]?tsx$/.test(filename) ? 'tsx' : /\.[cm]?ts$/.test(filename) ? 'ts' : 'jsx';
|
|
2055
|
+
return {contents: compiled, loader};
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
/**
|
|
2059
|
+
* A package file that holds StyleX source, for esbuild (client-bundle.mjs):
|
|
2060
|
+
* compiled with StyleX, else null, and esbuild loads it as it ships.
|
|
2061
|
+
* @param {string} file
|
|
2062
|
+
* @returns {{contents: string, loader: 'tsx' | 'ts' | 'jsx'} | null}
|
|
2063
|
+
*/
|
|
2064
|
+
function browserPackageSource(file) {
|
|
2065
|
+
const filename = path.normalize(file);
|
|
2066
|
+
if (!/\.(tsx?|jsx?|mjs|cjs|mts|cts)$/.test(filename)) return null;
|
|
2067
|
+
const compiled = compilePackageStylex(fs.readFileSync(filename, 'utf8'), filename);
|
|
2068
|
+
if (compiled === null) return null;
|
|
2069
|
+
const loader = /\.[cm]?tsx$/.test(filename) ? 'tsx' : /\.[cm]?ts$/.test(filename) ? 'ts' : 'jsx';
|
|
2070
|
+
return {contents: compiled, loader};
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
/**
|
|
2074
|
+
* The folder a package import resolves from in the browser bundle when it
|
|
2075
|
+
* must be the copy the server loaded: React, React DOM and StyleX from the
|
|
2076
|
+
* package set outside a project (one copy for every module), and a served
|
|
2077
|
+
* package the importer has no copy of. Null when the importer's own copy
|
|
2078
|
+
* serves.
|
|
2079
|
+
* @param {string} name
|
|
2080
|
+
* @param {string} importerDir
|
|
2081
|
+
* @returns {string | null}
|
|
2082
|
+
*/
|
|
2083
|
+
function browserPackageDir(name, importerDir) {
|
|
2084
|
+
if (!served) return null;
|
|
2085
|
+
const pkg = packageOf(name);
|
|
2086
|
+
if (pkg in SINGLE_COPY_ALIASES) return served.dir;
|
|
2087
|
+
if (!findNodeModulesPackage(importerDir, pkg) && isServedPackage(pkg, served.integrations)) return served.dir;
|
|
2088
|
+
return null;
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
/**
|
|
2092
|
+
* Whether a package import resolves for the module that makes it: installed
|
|
2093
|
+
* where the module is, served from the package set, or found by Node.
|
|
2094
|
+
* @param {string} spec the import as written, without a query
|
|
2095
|
+
* @param {string} file the importing module
|
|
2096
|
+
*/
|
|
2097
|
+
function packageResolves(spec, file) {
|
|
2098
|
+
const pkg = packageOf(spec);
|
|
2099
|
+
if (findNodeModulesPackage(path.dirname(file), pkg)) return true;
|
|
2100
|
+
// A package the set serves counts only when the set holds it.
|
|
2101
|
+
if (served && pkg in SINGLE_COPY_ALIASES) return true;
|
|
2102
|
+
if (served && isServedPackage(pkg, served.integrations) && resolveServed(spec, file, served)) return true;
|
|
2103
|
+
const require = createRequire(file);
|
|
2104
|
+
for (const request of [spec, `${pkg}/package.json`]) {
|
|
2105
|
+
try {
|
|
2106
|
+
require.resolve(request);
|
|
2107
|
+
return true;
|
|
2108
|
+
} catch {
|
|
2109
|
+
// Not found by this request: try the next one.
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
return false;
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
/**
|
|
2116
|
+
* One of the page's modules as Babel parses it: TypeScript in a TypeScript
|
|
2117
|
+
* file, JSX in a `.jsx` or `.tsx` file and in JavaScript.
|
|
2118
|
+
* @param {string} source
|
|
2119
|
+
* @param {string} file
|
|
2120
|
+
*/
|
|
2121
|
+
function parseModule(source, file) {
|
|
2122
|
+
const typed = /\.[cm]?tsx?$/.test(file);
|
|
2123
|
+
return requireFromCli('@babel/parser').parse(source, {
|
|
2124
|
+
sourceType: 'module',
|
|
2125
|
+
plugins: typed ? (/x$/.test(file) ? ['typescript', 'jsx'] : ['typescript']) : ['jsx'],
|
|
2126
|
+
});
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
/**
|
|
2130
|
+
* Every package the page's own modules import that does not resolve, found
|
|
2131
|
+
* before the page loads, so one refusal names them all.
|
|
2132
|
+
* @returns {string[]} package names, sorted
|
|
2133
|
+
*/
|
|
2134
|
+
function missingPackages() {
|
|
2135
|
+
/** @type {Set<string>} */
|
|
2136
|
+
const missing = new Set();
|
|
2137
|
+
const seen = new Set([entry]);
|
|
2138
|
+
const queue = [entry];
|
|
2139
|
+
while (queue.length > 0) {
|
|
2140
|
+
const file = /** @type {string} */ (queue.shift());
|
|
2141
|
+
if (!/\.[cm]?[jt]sx?$/.test(file)) continue;
|
|
2142
|
+
let source;
|
|
2143
|
+
try {
|
|
2144
|
+
source = fs.readFileSync(file, 'utf8');
|
|
2145
|
+
} catch {
|
|
2146
|
+
continue;
|
|
2147
|
+
}
|
|
2148
|
+
// TypeScript drops a static import that the module uses only as a type,
|
|
2149
|
+
// or not at all; JavaScript loads every import.
|
|
2150
|
+
/** @type {Set<string>} */
|
|
2151
|
+
let dropped = new Set();
|
|
2152
|
+
if (/\.[cm]?tsx?$/.test(file)) {
|
|
2153
|
+
try {
|
|
2154
|
+
dropped = droppedImports(parseModule(source, file));
|
|
2155
|
+
} catch {
|
|
2156
|
+
// A module that does not parse is reported where it is compiled.
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
for (const {specifier, typeOnly, declaration} of moduleImports(source, file) ?? []) {
|
|
2160
|
+
if (typeOnly || (declaration && dropped.has(specifier))) continue;
|
|
2161
|
+
const raw = specifier.split('?')[0];
|
|
2162
|
+
const target = importedFile(raw, file);
|
|
2163
|
+
if (target && path.isAbsolute(target)) {
|
|
2164
|
+
if (isLocal(target) && !seen.has(target)) {
|
|
2165
|
+
seen.add(target);
|
|
2166
|
+
queue.push(target);
|
|
2167
|
+
}
|
|
2168
|
+
continue;
|
|
2169
|
+
}
|
|
2170
|
+
if (raw.startsWith('.') || path.isAbsolute(raw) || namesAlias(raw) || /^[@~#]\/|^#/.test(raw)) continue;
|
|
2171
|
+
if (raw.startsWith('node:') || builtinModules.includes(raw.split('/')[0])) continue;
|
|
2172
|
+
// A package's stylesheet the page imports is a missing-asset warning
|
|
2173
|
+
// when absent, as the render reports it today, not a refusal.
|
|
2174
|
+
if (/\.(css|scss|sass|less|styl)$/i.test(raw)) continue;
|
|
2175
|
+
if (!packageResolves(raw, file)) missing.add(packageOf(raw));
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
return [...missing].sort();
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2181
|
+
/**
|
|
2182
|
+
* The refusal for packages the page imports that are not installed.
|
|
2183
|
+
* @param {string[]} packages sorted, at least one
|
|
2184
|
+
*/
|
|
2185
|
+
function failMissing(packages) {
|
|
2186
|
+
const names =
|
|
2187
|
+
packages.length === 1 ? packages[0] : `${packages.slice(0, -1).join(', ')} and ${packages[packages.length - 1]}`;
|
|
2188
|
+
fail(
|
|
2189
|
+
'ERR_RENDER_MISSING_DEPENDENCY',
|
|
2190
|
+
`The page imports ${names}, which ${packages.length === 1 ? 'is' : 'are'} not installed`,
|
|
2191
|
+
{package: packages[0], packages},
|
|
2192
|
+
);
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
/**
|
|
2196
|
+
* A file named for a message: a path from the page's folder for the page's
|
|
2197
|
+
* own files, else the package that holds it.
|
|
2198
|
+
* @param {string} file
|
|
2199
|
+
*/
|
|
2200
|
+
function describeFile(file) {
|
|
2201
|
+
const at = file.lastIndexOf(NODE_MODULES);
|
|
2202
|
+
if (at < 0) return path.relative(path.dirname(entry), file).split(path.sep).join('/');
|
|
2203
|
+
const parts = file.slice(at + NODE_MODULES.length).split(path.sep);
|
|
2204
|
+
return parts[0].startsWith('@') ? `${parts[0]}/${parts[1]}` : parts[0];
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
/**
|
|
2208
|
+
* Keep only the files of a linked package (see linkedPackageRoots) that the
|
|
2209
|
+
* page reaches by a path, as --reverse walks it: from the page, through each
|
|
2210
|
+
* relative or path-alias import of a carried module. The rest belong to the
|
|
2211
|
+
* package, and so do the files that only its modules import: none is
|
|
2212
|
+
* carried or named as not carried. A file that no module imports by a path
|
|
2213
|
+
* (one Node loaded by itself) and is not a linked package's stays, as do the
|
|
2214
|
+
* images, which the page's script reads from the file.
|
|
2215
|
+
* @returns {string[]} the modules left out, whose image names the script may still draw
|
|
2216
|
+
*/
|
|
2217
|
+
function dropLinkedPackageFiles() {
|
|
2218
|
+
/** @type {Map<string, Set<string>>} */
|
|
2219
|
+
const importers = new Map();
|
|
2220
|
+
for (const file of [...localFiles, ...outsideFiles]) {
|
|
2221
|
+
if (!/\.[cm]?[jt]sx?$/.test(file)) continue;
|
|
2222
|
+
let source;
|
|
2223
|
+
try {
|
|
2224
|
+
source = fs.readFileSync(file, 'utf8');
|
|
2225
|
+
} catch {
|
|
2226
|
+
continue;
|
|
2227
|
+
}
|
|
2228
|
+
for (const spec of importSpecifiers(source, file)) {
|
|
2229
|
+
const target = importedFile(spec, file);
|
|
2230
|
+
if (!target || !path.isAbsolute(target)) continue;
|
|
2231
|
+
const set = importers.get(target) ?? new Set();
|
|
2232
|
+
set.add(file);
|
|
2233
|
+
importers.set(target, set);
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
const reached = new Set([entry]);
|
|
2237
|
+
const queue = [entry];
|
|
2238
|
+
for (let file = queue.shift(); file !== undefined; file = queue.shift()) {
|
|
2239
|
+
for (const [target, from] of importers) {
|
|
2240
|
+
if (!reached.has(target) && from.has(file)) {
|
|
2241
|
+
reached.add(target);
|
|
2242
|
+
queue.push(target);
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
/** @param {string} file */
|
|
2247
|
+
const kept = file =>
|
|
2248
|
+
reached.has(file) || assetsInlined.has(file) || (!importers.has(file) && !inLinkedPackage(file));
|
|
2249
|
+
const dropped = localFiles.filter(file => !kept(file) && /\.[cm]?[jt]sx?$/.test(file));
|
|
2250
|
+
const keptLocal = localFiles.filter(kept);
|
|
2251
|
+
localFiles.splice(0, localFiles.length, ...keptLocal);
|
|
2252
|
+
const keptOutside = outsideFiles.filter(kept);
|
|
2253
|
+
outsideFiles.splice(0, outsideFiles.length, ...keptOutside);
|
|
2254
|
+
return dropped;
|
|
2255
|
+
}
|
|
2256
|
+
|
|
1253
2257
|
/**
|
|
1254
2258
|
* Tell the host what the page is doing, so an end without an answer can say
|
|
1255
2259
|
* where it ended.
|
|
@@ -1259,6 +2263,101 @@ function reach(name) {
|
|
|
1259
2263
|
parentPort?.postMessage({stage: name});
|
|
1260
2264
|
}
|
|
1261
2265
|
|
|
2266
|
+
/** Statements that make a module an ES module. */
|
|
2267
|
+
const MODULE_STATEMENTS = new Set(['ImportDeclaration', 'ExportNamedDeclaration', 'ExportDefaultDeclaration', 'ExportAllDeclaration']);
|
|
2268
|
+
|
|
2269
|
+
/**
|
|
2270
|
+
* Whether one of the page's modules is CommonJS: a `.cjs` or `.cts` file, or
|
|
2271
|
+
* one with no `import` or `export` statement. A bundler reads a CommonJS
|
|
2272
|
+
* module's exports by interop, so it does not refuse a named import from it.
|
|
2273
|
+
* @param {string} file
|
|
2274
|
+
*/
|
|
2275
|
+
function isCommonJs(file) {
|
|
2276
|
+
if (/\.c[jt]s$/.test(file)) return true;
|
|
2277
|
+
try {
|
|
2278
|
+
return !parseModule(fs.readFileSync(file, 'utf8'), file).program.body.some(
|
|
2279
|
+
(/** @type {any} */ statement) => MODULE_STATEMENTS.has(statement.type),
|
|
2280
|
+
);
|
|
2281
|
+
} catch {
|
|
2282
|
+
return false;
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
/**
|
|
2287
|
+
* The first import in the page's own files of a name its module does not
|
|
2288
|
+
* export (a named import), where the page uses that name as a value: a
|
|
2289
|
+
* reference that resolves to the import binding, not to a parameter or a
|
|
2290
|
+
* local binding of the same name. The page's own modules, Astryx packages
|
|
2291
|
+
* and StyleX variables modules (`.stylex`) are checked. A missing component
|
|
2292
|
+
* renders as "Element type is invalid", and StyleX compiles a missing value
|
|
2293
|
+
* to a variable that nothing defines; a bundler would refuse the import in
|
|
2294
|
+
* both cases.
|
|
2295
|
+
* @returns {Promise<{source: string, line: number, module: string, names: string[]} | null>}
|
|
2296
|
+
*/
|
|
2297
|
+
async function missingNamedExports() {
|
|
2298
|
+
for (const file of localFiles) {
|
|
2299
|
+
if (!moduleFiles.has(file)) continue;
|
|
2300
|
+
let ast;
|
|
2301
|
+
try {
|
|
2302
|
+
ast = parseModule(fs.readFileSync(file, 'utf8'), file);
|
|
2303
|
+
} catch {
|
|
2304
|
+
// A file that does not parse is reported where it is compiled.
|
|
2305
|
+
continue;
|
|
2306
|
+
}
|
|
2307
|
+
for (const [node, bindings] of importUses(ast)) {
|
|
2308
|
+
if (node.importKind === 'type') continue;
|
|
2309
|
+
const spec = String(node.source.value).split('?')[0];
|
|
2310
|
+
const target = importedFile(spec, file);
|
|
2311
|
+
const local = Boolean(target && path.isAbsolute(target) && isLocal(target) && /\.[cm]?[jt]sx?$/.test(target));
|
|
2312
|
+
if (!local && !spec.startsWith('@astryxdesign/') && !/\.stylex(?:\.[cm]?[jt]sx?)?$/.test(spec)) continue;
|
|
2313
|
+
if (local && isCommonJs(/** @type {string} */ (target))) continue;
|
|
2314
|
+
// In TypeScript a plain re-export (`export {ButtonProps}`) may name a
|
|
2315
|
+
// type, which the module cannot tell from a value's, so it is no use.
|
|
2316
|
+
// In JavaScript it names a value, which a build refuses when missing.
|
|
2317
|
+
const typed = /\.[cm]?tsx?$/.test(file);
|
|
2318
|
+
const needed = bindings
|
|
2319
|
+
.map(({specifier, values}) => ({
|
|
2320
|
+
specifier,
|
|
2321
|
+
values: typed ? values.filter(ref => !ref.parentPath.isExportSpecifier()) : values,
|
|
2322
|
+
}))
|
|
2323
|
+
.filter(({specifier, values}) => specifier.type === 'ImportSpecifier' && specifier.importKind !== 'type' && values.length > 0);
|
|
2324
|
+
if (needed.length === 0) continue;
|
|
2325
|
+
/** @type {any} */
|
|
2326
|
+
let exports;
|
|
2327
|
+
try {
|
|
2328
|
+
exports = await jiti.import(local ? /** @type {string} */ (target) : spec);
|
|
2329
|
+
} catch {
|
|
2330
|
+
// A module that does not load is reported where it is loaded.
|
|
2331
|
+
continue;
|
|
2332
|
+
}
|
|
2333
|
+
/** @param {any} s */
|
|
2334
|
+
const nameOf = s => (s.imported.type === 'Identifier' ? s.imported.name : s.imported.value);
|
|
2335
|
+
// jiti hands back a module with a default export as that export with the
|
|
2336
|
+
// named ones on it (interopDefault), so a name is read, not listed.
|
|
2337
|
+
const missing = needed
|
|
2338
|
+
.map(({specifier}) => specifier)
|
|
2339
|
+
.filter(s => exports == null || (exports[nameOf(s)] === undefined && !Object.hasOwn(exports, nameOf(s))));
|
|
2340
|
+
if (missing.length > 0) {
|
|
2341
|
+
return {source: file, line: missing[0].loc.start.line, module: spec, names: missing.map(nameOf)};
|
|
2342
|
+
}
|
|
2343
|
+
// An element drawn as `<Name.Member>` whose export has no such member
|
|
2344
|
+
// renders as "Element type is invalid" too.
|
|
2345
|
+
for (const {specifier, values} of needed) {
|
|
2346
|
+
const value = exports[nameOf(specifier)];
|
|
2347
|
+
if (value == null || (typeof value !== 'object' && typeof value !== 'function')) continue;
|
|
2348
|
+
const absentMember = values.find(
|
|
2349
|
+
ref => ref.parentPath.isJSXMemberExpression() && ref.key === 'object' && value[ref.parent.property.name] === undefined,
|
|
2350
|
+
);
|
|
2351
|
+
if (absentMember) {
|
|
2352
|
+
const line = absentMember.node.loc?.start.line ?? specifier.loc.start.line;
|
|
2353
|
+
return {source: file, line, module: spec, names: [`${nameOf(specifier)}.${absentMember.parent.property.name}`]};
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
return null;
|
|
2359
|
+
}
|
|
2360
|
+
|
|
1262
2361
|
try {
|
|
1263
2362
|
/** @type {any} */
|
|
1264
2363
|
let mod;
|
|
@@ -1268,12 +2367,27 @@ try {
|
|
|
1268
2367
|
// into a field: a typeahead's search would reach no change handler. It is
|
|
1269
2368
|
// loaded first, with a document that fires input events as a browser's
|
|
1270
2369
|
// does; the page then renders on the server with no document.
|
|
1271
|
-
await withLoadDocument(() => jiti.import('react-dom/client'));
|
|
2370
|
+
await withoutRenderTimings(() => withLoadDocument(() => jiti.import('react-dom/client')));
|
|
1272
2371
|
try {
|
|
1273
2372
|
reach('importing the page');
|
|
2373
|
+
const notInstalled = missingPackages();
|
|
2374
|
+
if (notInstalled.length > 0) {
|
|
2375
|
+
failMissing(notInstalled);
|
|
2376
|
+
throw null;
|
|
2377
|
+
}
|
|
1274
2378
|
mod = await jiti.import(entry);
|
|
1275
2379
|
} catch (e) {
|
|
1276
|
-
|
|
2380
|
+
if (e === null) throw null;
|
|
2381
|
+
// A missing name the page calls as it loads throws here; it is named as
|
|
2382
|
+
// a build names it, not by what it broke.
|
|
2383
|
+
const absent = await missingNamedExports().catch(() => null);
|
|
2384
|
+
if (absent) failMissingExport(absent);
|
|
2385
|
+
else classify(e);
|
|
2386
|
+
throw null;
|
|
2387
|
+
}
|
|
2388
|
+
const absent = await missingNamedExports();
|
|
2389
|
+
if (absent) {
|
|
2390
|
+
failMissingExport(absent);
|
|
1277
2391
|
throw null;
|
|
1278
2392
|
}
|
|
1279
2393
|
const Page = mod?.default ?? (typeof mod === 'function' ? mod : undefined);
|
|
@@ -1342,21 +2456,86 @@ try {
|
|
|
1342
2456
|
for (const [name, dir] of Object.entries(SINGLE_COPY_ALIASES)) {
|
|
1343
2457
|
if (name !== '@stylexjs/stylex' || packages.has(name)) fromSet.set(name, dir);
|
|
1344
2458
|
}
|
|
2459
|
+
// The page's script is built first: it compiles every module the page
|
|
2460
|
+
// can load, a lazily imported one included, and their styles join the
|
|
2461
|
+
// stylesheet below.
|
|
2462
|
+
/** @type {{code: string, modules: number, astryx: boolean, module: boolean, files: string[]} | null} */
|
|
2463
|
+
let script = null;
|
|
2464
|
+
if (workerData.buildScript) {
|
|
2465
|
+
reach("building the page's script");
|
|
2466
|
+
try {
|
|
2467
|
+
const loaded = await import(pathToFileURL(workerData.esbuild).href);
|
|
2468
|
+
const build = () => bundleForBrowser({
|
|
2469
|
+
esbuild: loaded.default ?? loaded,
|
|
2470
|
+
entry,
|
|
2471
|
+
source: browserSource,
|
|
2472
|
+
stylexFiles: [...stylexSourceFiles],
|
|
2473
|
+
packageSource: browserPackageSource,
|
|
2474
|
+
// The files compilePageModule compiles: the page's own, and, when
|
|
2475
|
+
// the project has path aliases, every module outside node_modules.
|
|
2476
|
+
isPageFile: file => {
|
|
2477
|
+
const filename = path.normalize(file);
|
|
2478
|
+
return (
|
|
2479
|
+
isLocal(filename) ||
|
|
2480
|
+
(PATHS.length > 0 && !filename.includes(NODE_MODULES) && /\.(tsx?|jsx?|mjs|cjs|mts|cts)$/.test(filename))
|
|
2481
|
+
);
|
|
2482
|
+
},
|
|
2483
|
+
resolveFile: (name, dir) => existingFile(path.resolve(dir, name), LOAD_EXTENSIONS),
|
|
2484
|
+
packageDir: browserPackageDir,
|
|
2485
|
+
builtin: name => name.startsWith('node:') || builtinModules.includes(packageOf(name)),
|
|
2486
|
+
describe: describeFile,
|
|
2487
|
+
oneCopy: served ? Object.keys(SINGLE_COPY_ALIASES) : [],
|
|
2488
|
+
});
|
|
2489
|
+
script = await build();
|
|
2490
|
+
// A package file only the browser loads can hold StyleX source too: the
|
|
2491
|
+
// script is built once more with it compiled. Compiling only removes
|
|
2492
|
+
// StyleX calls, so the second build holds no file the first did not.
|
|
2493
|
+
if (checkScriptFiles(script.files)) script = await build();
|
|
2494
|
+
} catch (e) {
|
|
2495
|
+
if (e instanceof BundleError && e.compile !== undefined) {
|
|
2496
|
+
classify(e.compile);
|
|
2497
|
+
} else if (e instanceof BundleError && e.missingExport) {
|
|
2498
|
+
failMissingExport(e.missingExport);
|
|
2499
|
+
} else if (e instanceof BundleError) {
|
|
2500
|
+
fail('ERR_RENDER_SCRIPT', e.message, e.detail);
|
|
2501
|
+
} else {
|
|
2502
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
2503
|
+
fail('ERR_RENDER_SCRIPT', `The page's script cannot be built for the browser: ${message.split('\n')[0]}`);
|
|
2504
|
+
}
|
|
2505
|
+
throw null;
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
1345
2508
|
/** @type {string} */
|
|
1346
2509
|
let css = '';
|
|
1347
2510
|
if (stylexRules.length > 0) {
|
|
1348
2511
|
reach('compiling styles');
|
|
1349
|
-
|
|
2512
|
+
// A module compiled for the server and again for the browser gives its
|
|
2513
|
+
// rules twice; each rule is written once.
|
|
2514
|
+
const seen = new Set();
|
|
2515
|
+
const rules = stylexRules.filter(rule => {
|
|
2516
|
+
const key = JSON.stringify(rule);
|
|
2517
|
+
if (seen.has(key)) return false;
|
|
2518
|
+
seen.add(key);
|
|
2519
|
+
return true;
|
|
2520
|
+
});
|
|
2521
|
+
css = stylexPlugin.processStylexRules(rules, {useLayers: false});
|
|
1350
2522
|
}
|
|
1351
2523
|
// Node loads some local modules itself (jiti hands it a plain ES module,
|
|
1352
2524
|
// such as a built theme), so they never pass the transform that records
|
|
1353
2525
|
// local files. Follow the imports of every local module instead, so the
|
|
1354
|
-
// file carries each module the page reaches, as --reverse expects.
|
|
2526
|
+
// file carries each module the page reaches, as --reverse expects. The
|
|
2527
|
+
// modules outside the folder it carries from are followed too, so each
|
|
2528
|
+
// file they import is named.
|
|
1355
2529
|
/** Every path-alias import a local module makes, with the file it names. @type {{spec: string, file: string}[]} */
|
|
1356
2530
|
const aliasImports = [];
|
|
1357
|
-
|
|
1358
|
-
|
|
2531
|
+
/** @type {Set<string>} */
|
|
2532
|
+
const followed = new Set();
|
|
2533
|
+
const nextToFollow = () =>
|
|
2534
|
+
localFiles.find(f => !followed.has(f)) ?? outsideFiles.find(f => !followed.has(f));
|
|
2535
|
+
for (let file = nextToFollow(); file !== undefined; file = nextToFollow()) {
|
|
2536
|
+
followed.add(file);
|
|
1359
2537
|
if (!/\.[cm]?[jt]sx?$/.test(file)) continue;
|
|
2538
|
+
const carriedModule = localFiles.includes(file);
|
|
1360
2539
|
let source;
|
|
1361
2540
|
try {
|
|
1362
2541
|
source = fs.readFileSync(file, 'utf8');
|
|
@@ -1366,14 +2545,22 @@ try {
|
|
|
1366
2545
|
for (const spec of importSpecifiers(source, file)) {
|
|
1367
2546
|
const target = importedFile(spec, file);
|
|
1368
2547
|
const raw = spec.split('?')[0];
|
|
1369
|
-
if (target && !raw.startsWith('.')) aliasImports.push({spec: raw, file: target});
|
|
2548
|
+
if (target && carriedModule && !raw.startsWith('.')) aliasImports.push({spec: raw, file: target});
|
|
1370
2549
|
// Modules and JSON only: the transform already carries the stylesheets
|
|
1371
2550
|
// and images a module imports, and a Sass file is never carried.
|
|
1372
2551
|
if (target && /\.([cm]?[jt]sx?|json)$/i.test(target) && isLocal(target) && !localFiles.includes(target)) {
|
|
1373
2552
|
localFiles.push(target);
|
|
2553
|
+
} else if (
|
|
2554
|
+
target &&
|
|
2555
|
+
!target.includes(NODE_MODULES) &&
|
|
2556
|
+
!isLocal(target) &&
|
|
2557
|
+
!outsideFiles.includes(target)
|
|
2558
|
+
) {
|
|
2559
|
+
outsideFiles.push(target);
|
|
1374
2560
|
}
|
|
1375
2561
|
}
|
|
1376
2562
|
}
|
|
2563
|
+
const linkedModules = LINKED_ROOTS.length > 0 ? dropLinkedPackageFiles() : [];
|
|
1377
2564
|
parentPort?.postMessage({
|
|
1378
2565
|
ok: true,
|
|
1379
2566
|
markup,
|
|
@@ -1387,11 +2574,24 @@ try {
|
|
|
1387
2574
|
chartsAlone,
|
|
1388
2575
|
assets: [...assetsInlined],
|
|
1389
2576
|
files: localFiles,
|
|
2577
|
+
uncarried: outsideFiles,
|
|
2578
|
+
linkedRoots: LINKED_ROOTS,
|
|
2579
|
+
linkedModules,
|
|
1390
2580
|
aliasImports,
|
|
1391
2581
|
texts,
|
|
1392
2582
|
fnTexts,
|
|
1393
2583
|
screenQueries,
|
|
2584
|
+
remoteLiterals: [...remoteLiterals],
|
|
2585
|
+
remoteNamedOnly: [...namedOnlyLiterals].filter(url => !placedLiterals.has(url)),
|
|
2586
|
+
builtRemote,
|
|
2587
|
+
propValues: propValues.map(v => ({...v, file: path.relative(path.dirname(entry), v.file).split(path.sep).join('/')})),
|
|
1394
2588
|
logs,
|
|
2589
|
+
script: script?.code ?? null,
|
|
2590
|
+
scriptModules: script?.modules ?? 0,
|
|
2591
|
+
// Whether the script's module graph holds an Astryx module; null when no
|
|
2592
|
+
// script was built. The stylesheets it imports are read by the render.
|
|
2593
|
+
astryx: script ? script.astryx : null,
|
|
2594
|
+
scriptIsModule: script?.module ?? false,
|
|
1395
2595
|
});
|
|
1396
2596
|
} catch (e) {
|
|
1397
2597
|
if (e !== null) classify(e);
|