eddev 0.3.35 → 2.0.0-beta.1
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/bin/eddev.js +1 -3
- package/css/devtools.css +15 -0
- package/css/editor-styles.css +94 -0
- package/dist/app/entry/Root.d.ts +1 -0
- package/dist/app/entry/Root.js +9 -0
- package/dist/app/entry/main.admin.d.ts +3 -0
- package/dist/app/entry/main.admin.js +10 -0
- package/dist/app/entry/main.frontend.spa.d.ts +3 -0
- package/dist/app/entry/main.frontend.spa.js +13 -0
- package/dist/app/entry/main.frontend.ssr.d.ts +21 -0
- package/dist/app/entry/main.frontend.ssr.js +79 -0
- package/dist/app/entry/main.serverless.dev.d.ts +4 -0
- package/dist/app/entry/main.serverless.dev.js +21 -0
- package/{admin → dist/app/lib/admin}/defineField.d.ts +2 -2
- package/dist/app/lib/admin/defineField.js +3 -0
- package/{admin → dist/app/lib/admin}/defineWidget.d.ts +1 -1
- package/dist/app/lib/admin/defineWidget.js +6 -0
- package/dist/app/lib/admin/index.d.ts +2 -0
- package/dist/app/lib/admin/index.js +2 -0
- package/dist/app/lib/admin/installFieldTypes.js +92 -0
- package/dist/app/lib/admin/runWidgets.js +38 -0
- package/dist/app/lib/blocks/ContentBlocks.d.ts +83 -0
- package/dist/app/lib/blocks/ContentBlocks.js +92 -0
- package/dist/app/lib/blocks/EditableText.d.ts +41 -0
- package/dist/app/lib/blocks/EditableText.js +50 -0
- package/{blocks → dist/app/lib/blocks}/ErrorBoundaryFrontend.d.ts +2 -2
- package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +35 -0
- package/dist/app/lib/blocks/InnerBlocks.d.ts +42 -0
- package/dist/app/lib/blocks/InnerBlocks.js +55 -0
- package/dist/app/lib/blocks/block-utils.d.ts +24 -0
- package/dist/app/lib/blocks/block-utils.js +41 -0
- package/dist/app/lib/blocks/defineBlock.d.ts +2 -0
- package/dist/app/lib/blocks/defineBlock.js +3 -0
- package/dist/app/lib/blocks/editor/EditorSupport.d.ts +5 -0
- package/dist/app/lib/blocks/editor/EditorSupport.js +19 -0
- package/{blocks → dist/app/lib/blocks/editor}/ErrorBoundaryEditor.d.ts +1 -1
- package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.js +28 -0
- package/dist/app/lib/blocks/editor/block-templates.d.ts +3 -0
- package/dist/app/lib/blocks/editor/block-templates.js +9 -0
- package/dist/app/lib/blocks/editor/blocks-by-tag.d.ts +7 -0
- package/dist/app/lib/blocks/editor/blocks-by-tag.js +42 -0
- package/dist/app/lib/blocks/editor/controls.d.ts +10 -0
- package/dist/app/lib/blocks/editor/controls.js +20 -0
- package/dist/app/lib/blocks/editor/editor-config.d.ts +58 -0
- package/dist/app/lib/blocks/editor/editor-config.js +191 -0
- package/dist/app/lib/blocks/editor/installGutenbergHooks.d.ts +2 -0
- package/dist/app/lib/blocks/editor/installGutenbergHooks.js +131 -0
- package/dist/app/lib/blocks/editor/usePostEditor.d.ts +27 -0
- package/dist/app/lib/blocks/editor/usePostEditor.js +79 -0
- package/dist/app/lib/blocks/index.d.ts +9 -0
- package/dist/app/lib/blocks/index.js +9 -0
- package/dist/app/lib/blocks/inline-editing.d.ts +54 -0
- package/dist/app/lib/blocks/inline-editing.js +114 -0
- package/dist/app/lib/devtools/components/BreakpointIndicator.js +79 -0
- package/{dev-ui → dist/app/lib/devtools}/components/DevUI.d.ts +1 -0
- package/dist/app/lib/devtools/components/DevUI.js +6 -0
- package/dist/app/lib/devtools/hooks/usePersistState.js +31 -0
- package/dist/app/lib/devtools/hooks/useTailwind.d.ts +4184 -0
- package/dist/app/lib/devtools/hooks/useTailwind.js +6 -0
- package/dist/app/lib/devtools/index.js +1 -0
- package/dist/app/lib/devtools/loader.js +23 -0
- package/dist/app/lib/devtools/tailwind.config.d.ts +23 -0
- package/dist/app/lib/devtools/tailwind.config.js +24 -0
- package/{hooks → dist/app/lib/devtools}/useQueryDebug.d.ts +1 -1
- package/dist/app/lib/devtools/useQueryDebug.js +13 -0
- package/dist/app/lib/dynamic/dynamic.d.ts +8 -0
- package/dist/app/lib/dynamic/dynamic.js +25 -0
- package/dist/app/lib/dynamic/index.d.ts +1 -0
- package/dist/app/lib/dynamic/index.js +1 -0
- package/dist/app/lib/hooks/apiConfig.d.ts +18 -0
- package/dist/app/lib/hooks/apiConfig.js +4 -0
- package/{hooks → dist/app/lib/hooks}/index.d.ts +2 -0
- package/dist/app/lib/hooks/index.js +5 -0
- package/dist/app/lib/hooks/queryUtils.d.ts +46 -0
- package/dist/app/lib/hooks/queryUtils.js +183 -0
- package/dist/app/lib/hooks/useAppData.d.ts +4 -0
- package/dist/app/lib/hooks/useAppData.js +11 -0
- package/{hooks → dist/app/lib/hooks}/usePageLoad.d.ts +1 -1
- package/dist/app/lib/hooks/usePageLoad.js +5 -0
- package/dist/app/lib/hooks/useRPC.d.ts +9 -0
- package/dist/app/lib/hooks/useRPC.js +9 -0
- package/dist/app/lib/internal/index.d.ts +4 -0
- package/dist/app/lib/internal/index.js +4 -0
- package/dist/app/lib/internal/internal-store.d.ts +11 -0
- package/dist/app/lib/internal/internal-store.js +9 -0
- package/dist/app/lib/internal/read-admin-manifest.d.ts +19 -0
- package/dist/app/lib/internal/read-admin-manifest.js +17 -0
- package/dist/app/lib/internal/read-block-manifest.d.ts +15 -0
- package/dist/app/lib/internal/read-block-manifest.js +16 -0
- package/dist/app/lib/internal/read-view-manifest.d.ts +12 -0
- package/dist/app/lib/internal/read-view-manifest.js +3 -0
- package/dist/app/lib/legacy-stitches/createStitches.d.ts +615 -0
- package/dist/app/lib/legacy-stitches/createStitches.js +439 -0
- package/dist/app/lib/legacy-stitches/index.js +1 -0
- package/{components → dist/app/lib/routing/components}/BrowserRouter.d.ts +2 -4
- package/dist/app/lib/routing/components/BrowserRouter.js +351 -0
- package/dist/app/lib/routing/components/ClientOnly.d.ts +12 -0
- package/dist/app/lib/routing/components/ClientOnly.js +14 -0
- package/dist/app/lib/routing/components/Link.d.ts +26 -0
- package/dist/app/lib/routing/components/Link.js +93 -0
- package/dist/app/lib/routing/components/RouteRenderer.d.ts +9 -0
- package/dist/app/lib/routing/components/RouteRenderer.js +28 -0
- package/dist/app/lib/routing/components/SSRRouter.d.ts +9 -0
- package/dist/app/lib/routing/components/SSRRouter.js +14 -0
- package/dist/app/lib/routing/components/ScrollRestoration.d.ts +15 -0
- package/dist/app/lib/routing/components/ScrollRestoration.js +32 -0
- package/dist/app/lib/routing/context.d.ts +5 -0
- package/dist/app/lib/routing/context.js +129 -0
- package/dist/app/lib/routing/hooks/useIsSSR.d.ts +8 -0
- package/dist/app/lib/routing/hooks/useIsSSR.js +22 -0
- package/dist/app/lib/routing/hooks/useRestorableState.d.ts +5 -0
- package/dist/app/lib/routing/hooks/useRestorableState.js +17 -0
- package/dist/app/lib/routing/hooks/useRoute.d.ts +2 -0
- package/dist/app/lib/routing/hooks/useRoute.js +5 -0
- package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +4 -0
- package/dist/app/lib/routing/hooks/useRouteTransition.js +12 -0
- package/dist/app/lib/routing/hooks/useRouter.d.ts +2 -0
- package/dist/app/lib/routing/hooks/useRouter.js +11 -0
- package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +2 -0
- package/dist/app/lib/routing/hooks/useRouterEvents.js +10 -0
- package/dist/app/lib/routing/hooks/useRouterState.d.ts +2 -0
- package/dist/app/lib/routing/hooks/useRouterState.js +8 -0
- package/dist/app/lib/routing/hooks/useSearchParams.d.ts +10 -0
- package/dist/app/lib/routing/hooks/useSearchParams.js +30 -0
- package/dist/app/lib/routing/index.d.ts +13 -0
- package/dist/app/lib/routing/index.js +13 -0
- package/dist/app/lib/routing/loader.d.ts +30 -0
- package/dist/app/lib/routing/loader.js +106 -0
- package/dist/app/lib/routing/types.d.ts +138 -0
- package/dist/app/lib/routing/utils.d.ts +15 -0
- package/dist/app/lib/routing/utils.js +94 -0
- package/dist/app/lib/views/defineView.d.ts +4 -0
- package/dist/app/lib/views/defineView.js +3 -0
- package/dist/app/lib/views/index.js +1 -0
- package/dist/app/server/create-api-builtin-hono.d.ts +8 -0
- package/dist/app/server/create-api-builtin-hono.js +80 -0
- package/dist/app/server/create-ssr-hono.d.ts +18 -0
- package/dist/app/server/create-ssr-hono.js +104 -0
- package/dist/app/server/utils/headers.d.ts +4 -0
- package/dist/app/server/utils/headers.js +11 -0
- package/dist/app/server/utils/index.html.d.ts +2 -0
- package/dist/app/server/utils/index.html.js +14 -0
- package/dist/app/server/utils/replace-host.d.ts +8 -0
- package/dist/app/server/utils/replace-host.js +14 -0
- package/dist/app/utils/query-client.d.ts +2 -0
- package/dist/app/utils/query-client.js +16 -0
- package/dist/app/utils/wp.d.ts +26 -0
- package/dist/node/cli/cli-mode.d.ts +10 -0
- package/dist/node/cli/cli-mode.js +12 -0
- package/dist/node/cli/cli-worker.d.ts +13 -0
- package/dist/node/cli/cli-worker.js +114 -0
- package/dist/node/cli/cli.js +166 -0
- package/dist/node/cli/display/CLIApp.d.ts +16 -0
- package/dist/node/cli/display/CLIApp.js +117 -0
- package/dist/node/cli/display/boot-cli-app.d.ts +2 -0
- package/dist/node/cli/display/boot-cli-app.js +10 -0
- package/{cli → dist/node/cli}/display/components/Fullscreen.d.ts +1 -1
- package/dist/node/cli/display/components/Fullscreen.js +24 -0
- package/dist/node/cli/display/components/LogEntries.d.ts +13 -0
- package/dist/node/cli/display/components/LogEntries.js +87 -0
- package/dist/node/cli/display/components/MenuItem.d.ts +6 -0
- package/dist/node/cli/display/components/MenuItem.js +11 -0
- package/dist/node/cli/display/components/TextInput.d.ts +44 -0
- package/dist/node/cli/display/components/TextInput.js +105 -0
- package/dist/node/cli/display/hooks/useManifest.d.ts +2 -0
- package/dist/node/cli/display/hooks/useManifest.js +8 -0
- package/dist/node/cli/display/hooks/useStatefulLog.d.ts +11 -0
- package/dist/node/cli/display/hooks/useStatefulLog.js +51 -0
- package/dist/node/cli/display/tools/BlockList.d.ts +2 -0
- package/dist/node/cli/display/tools/BlockList.js +10 -0
- package/dist/node/cli/display/tools/CreateBlock.d.ts +2 -0
- package/dist/node/cli/display/tools/CreateBlock.js +8 -0
- package/dist/node/cli/display/tools/cli-tool-list.d.ts +2 -0
- package/dist/node/cli/display/tools/cli-tool-list.js +23 -0
- package/dist/node/cli/display/tools/cli-tools.d.ts +26 -0
- package/dist/node/cli/display/tools/cli-tools.js +15 -0
- package/dist/node/cli/display/util/colors.d.ts +4 -0
- package/dist/node/cli/display/util/colors.js +63 -0
- package/dist/node/cli/version.d.ts +1 -0
- package/dist/node/cli/version.js +1 -0
- package/dist/node/compiler/bundler.admin.d.ts +13 -0
- package/dist/node/compiler/bundler.admin.js +37 -0
- package/dist/node/compiler/bundler.frontend.d.ts +13 -0
- package/dist/node/compiler/bundler.frontend.js +37 -0
- package/dist/node/compiler/index.html.d.ts +2 -0
- package/dist/node/compiler/index.html.js +15 -0
- package/dist/node/compiler/serverless.dev.d.ts +16 -0
- package/dist/node/compiler/serverless.dev.js +215 -0
- package/dist/node/compiler/vite/get-vite-config.d.ts +13 -0
- package/dist/node/compiler/vite/get-vite-config.js +315 -0
- package/dist/node/compiler/vite/plugin-admin.d.ts +4 -0
- package/dist/node/compiler/vite/plugin-admin.js +67 -0
- package/dist/node/compiler/vite/plugin-blocks.d.ts +4 -0
- package/dist/node/compiler/vite/plugin-blocks.js +73 -0
- package/dist/node/compiler/vite/plugin-entry.d.ts +6 -0
- package/dist/node/compiler/vite/plugin-entry.js +16 -0
- package/dist/node/compiler/vite/plugin-resolved-tailwind.d.ts +4 -0
- package/dist/node/compiler/vite/plugin-resolved-tailwind.js +29 -0
- package/dist/node/compiler/vite/plugin-theme.d.ts +4 -0
- package/dist/node/compiler/vite/plugin-theme.js +40 -0
- package/dist/node/compiler/vite/plugin-views.d.ts +4 -0
- package/dist/node/compiler/vite/plugin-views.js +51 -0
- package/dist/node/graphql/graphql-codegen.d.ts +30 -0
- package/dist/node/graphql/graphql-codegen.js +503 -0
- package/dist/node/graphql/graphql-schema-loader.d.ts +17 -0
- package/dist/node/graphql/graphql-schema-loader.js +94 -0
- package/dist/node/graphql/plugins/gql-plugin-files.d.ts +14 -0
- package/dist/node/graphql/plugins/gql-plugin-files.js +66 -0
- package/dist/node/graphql/plugins/gql-plugin-no-duplicates.d.ts +8 -0
- package/dist/node/graphql/plugins/gql-plugin-no-duplicates.js +10 -0
- package/dist/node/graphql/plugins/gql-plugin-queries.d.ts +8 -0
- package/dist/node/graphql/plugins/gql-plugin-queries.js +263 -0
- package/dist/node/graphql/query-files-loader.d.ts +26 -0
- package/dist/node/graphql/query-files-loader.js +54 -0
- package/dist/node/graphql/wp-info-query.d.ts +1 -0
- package/dist/node/graphql/wp-info-query.js +29 -0
- package/{config/config-schema.d.ts → dist/node/project/config.d.ts} +54 -38
- package/dist/node/project/config.js +138 -0
- package/dist/node/project/eddev-build-file.d.ts +10 -0
- package/dist/node/project/eddev-build-file.js +79 -0
- package/dist/node/project/env.d.ts +39 -0
- package/dist/node/project/env.js +77 -0
- package/dist/node/project/favicons.d.ts +0 -0
- package/dist/node/project/favicons.js +1 -0
- package/dist/node/project/manifest/block-manifest.d.ts +19 -0
- package/dist/node/project/manifest/block-manifest.js +206 -0
- package/dist/node/project/manifest/field-manifest.d.ts +17 -0
- package/dist/node/project/manifest/field-manifest.js +42 -0
- package/dist/node/project/manifest/manifest.d.ts +30 -0
- package/dist/node/project/manifest/manifest.js +105 -0
- package/dist/node/project/manifest/view-manifest.d.ts +19 -0
- package/dist/node/project/manifest/view-manifest.js +152 -0
- package/dist/node/project/manifest/widget-manifest.d.ts +17 -0
- package/dist/node/project/manifest/widget-manifest.js +42 -0
- package/dist/node/project/project.d.ts +57 -0
- package/dist/node/project/project.js +115 -0
- package/dist/node/project/wp-info.d.ts +32 -0
- package/dist/node/project/wp-info.js +34 -0
- package/dist/node/types/block-type.d.ts +92 -0
- package/dist/node/types/block-type.js +82 -0
- package/dist/node/types/view-type.d.ts +31 -0
- package/dist/node/types/view-type.js +54 -0
- package/dist/node/utils/console.d.ts +21 -0
- package/dist/node/utils/console.js +28 -0
- package/dist/node/utils/export-extractor.d.ts +9 -0
- package/dist/node/utils/export-extractor.js +71 -0
- package/dist/node/utils/formatZodError.d.ts +3 -0
- package/dist/node/utils/formatZodError.js +33 -0
- package/dist/node/utils/fs.d.ts +106 -0
- package/dist/node/utils/fs.js +56 -0
- package/dist/node/utils/getRepoInfo.d.ts +7 -0
- package/dist/node/utils/getRepoInfo.js +21 -0
- package/dist/node/utils/helpers.d.ts +2 -0
- package/dist/node/utils/helpers.js +14 -0
- package/dist/node/utils/highlightCode.d.ts +10 -0
- package/dist/node/utils/highlightCode.js +30 -0
- package/dist/node/utils/isDeploying.d.ts +4 -0
- package/dist/node/utils/isDeploying.js +6 -0
- package/dist/node/utils/report-builder.d.ts +9 -0
- package/dist/node/utils/report-builder.js +51 -0
- package/dist/node/utils/selfSignedCert.d.ts +4 -0
- package/dist/node/utils/selfSignedCert.js +35 -0
- package/dist/node/utils/statefulLog.d.ts +65 -0
- package/dist/node/utils/statefulLog.js +223 -0
- package/dist/node/utils/unsafe-fetch.d.ts +2 -0
- package/dist/node/utils/unsafe-fetch.js +19 -0
- package/dist/node/utils/watchFileTree.d.ts +11 -0
- package/dist/node/utils/watchFileTree.js +58 -0
- package/package.json +123 -102
- package/stitches-archive/config.d.ts +210 -0
- package/stitches-archive/css-util.d.ts +119 -0
- package/stitches-archive/css.d.ts +9797 -0
- package/stitches-archive/index.d.mts +144 -0
- package/stitches-archive/index.d.ts +82 -0
- package/stitches-archive/index.mjs +2 -0
- package/stitches-archive/stitches.d.ts +288 -0
- package/stitches-archive/styled-component.d.ts +163 -0
- package/stitches-archive/theme.d.ts +43 -0
- package/stitches-archive/util.d.ts +32 -0
- package/tsconfig.app.json +20 -0
- package/tsconfig.json +2 -104
- package/tsconfig.node.json +20 -0
- package/tsup.config.ts +40 -0
- package/types.app.d.ts +22 -0
- package/types.app.internal.d.ts +13 -0
- package/types.env.d.ts +16 -0
- package/types.manifests.d.ts +22 -0
- package/types.meta.d.ts +319 -0
- package/types.node.d.ts +3 -0
- package/admin/components/FileWell.d.ts +0 -8
- package/admin/components/FileWell.js +0 -189
- package/admin/components/ImageWell.d.ts +0 -9
- package/admin/components/ImageWell.js +0 -209
- package/admin/defineField.js +0 -7
- package/admin/defineWidget.js +0 -10
- package/admin/index.d.ts +0 -4
- package/admin/index.js +0 -16
- package/admin/installFieldTypes.js +0 -71
- package/admin/runWidgets.js +0 -55
- package/admin/selectMedia.d.ts +0 -31
- package/admin/selectMedia.js +0 -9
- package/blocks/ContentBlocks.d.ts +0 -40
- package/blocks/ContentBlocks.js +0 -125
- package/blocks/ErrorBoundaryEditor.js +0 -64
- package/blocks/ErrorBoundaryFrontend.js +0 -69
- package/blocks/InspectorControls.d.ts +0 -2
- package/blocks/InspectorControls.js +0 -13
- package/blocks/blockAttributes.d.ts +0 -20
- package/blocks/blockAttributes.js +0 -81
- package/blocks/defineBlock.d.ts +0 -2
- package/blocks/defineBlock.js +0 -7
- package/blocks/index.d.ts +0 -5
- package/blocks/index.js +0 -23
- package/blocks/inlineEditing.d.ts +0 -32
- package/blocks/inlineEditing.js +0 -141
- package/blocks/installGutenbergHooks.d.ts +0 -2
- package/blocks/installGutenbergHooks.js +0 -211
- package/build/babel/plugin-name-defined-components.d.ts +0 -7
- package/build/babel/plugin-name-defined-components.js +0 -47
- package/build/build-favicon.d.ts +0 -1
- package/build/build-favicon.js +0 -71
- package/build/clean.d.ts +0 -1
- package/build/clean.js +0 -60
- package/build/create-codegen-worker.d.ts +0 -3
- package/build/create-codegen-worker.js +0 -71
- package/build/create-serverless-dev-worker.d.ts +0 -3
- package/build/create-serverless-dev-worker.js +0 -99
- package/build/create-webpack-worker.d.ts +0 -3
- package/build/create-webpack-worker.js +0 -64
- package/build/file-tree.d.ts +0 -5
- package/build/file-tree.js +0 -45
- package/build/get-webpack-config.d.ts +0 -3
- package/build/get-webpack-config.js +0 -426
- package/build/graphql-codegen/graphql-codegen-blocks.d.ts +0 -1
- package/build/graphql-codegen/graphql-codegen-blocks.js +0 -7
- package/build/graphql-codegen/graphql-codegen-files.js +0 -64
- package/build/graphql-codegen/graphql-codegen-no-duplicates.js +0 -13
- package/build/graphql-codegen/graphql-codegen-queries.d.ts +0 -1
- package/build/graphql-codegen/graphql-codegen-queries.js +0 -248
- package/build/manifests/manifest-blocks.d.ts +0 -12
- package/build/manifests/manifest-blocks.js +0 -61
- package/build/manifests/manifest-fields.d.ts +0 -12
- package/build/manifests/manifest-fields.js +0 -42
- package/build/manifests/manifest-views.d.ts +0 -12
- package/build/manifests/manifest-views.js +0 -49
- package/build/manifests/manifest-widgets.d.ts +0 -12
- package/build/manifests/manifest-widgets.js +0 -42
- package/build/manifests/manifest.d.ts +0 -11
- package/build/manifests/manifest.js +0 -100
- package/build/reporter.d.ts +0 -12
- package/build/reporter.js +0 -102
- package/build/serverless/create-next-app.d.ts +0 -9
- package/build/serverless/create-next-app.js +0 -536
- package/build/state/codegen-state.d.ts +0 -32
- package/build/state/codegen-state.js +0 -2
- package/build/state/compiler-state.d.ts +0 -49
- package/build/state/compiler-state.js +0 -2
- package/build/state/serverless-state.d.ts +0 -26
- package/build/state/serverless-state.js +0 -2
- package/build/workers/codegen-worker-script.d.ts +0 -2
- package/build/workers/codegen-worker-script.js +0 -624
- package/build/workers/serverless-worker-dev-script.d.ts +0 -1
- package/build/workers/serverless-worker-dev-script.js +0 -21
- package/build/workers/webpack-worker-script.d.ts +0 -2
- package/build/workers/webpack-worker-script.js +0 -171
- package/cli/build.dev.d.ts +0 -7
- package/cli/build.dev.js +0 -136
- package/cli/build.prod.d.ts +0 -5
- package/cli/build.prod.js +0 -107
- package/cli/cli.js +0 -90
- package/cli/display/components/BundleDisplay.d.ts +0 -5
- package/cli/display/components/BundleDisplay.js +0 -56
- package/cli/display/components/CodegenDisplay.d.ts +0 -5
- package/cli/display/components/CodegenDisplay.js +0 -62
- package/cli/display/components/DevCLIDisplay.d.ts +0 -12
- package/cli/display/components/DevCLIDisplay.js +0 -42
- package/cli/display/components/Fullscreen.js +0 -39
- package/cli/display/components/ServerlessDisplay.d.ts +0 -8
- package/cli/display/components/ServerlessDisplay.js +0 -68
- package/cli/display/components/StatusIcon.d.ts +0 -5
- package/cli/display/components/StatusIcon.js +0 -9
- package/cli/preinstall.d.ts +0 -1
- package/cli/preinstall.js +0 -19
- package/cli/setup.d.ts +0 -1
- package/cli/setup.js +0 -90
- package/components/AdminBar.d.ts +0 -1
- package/components/AdminBar.js +0 -9
- package/components/BrowserRouter.js +0 -155
- package/components/InlinePage.d.ts +0 -11
- package/components/InlinePage.js +0 -70
- package/components/NextRouter.d.ts +0 -9
- package/components/NextRouter.js +0 -45
- package/components/index.d.ts +0 -2
- package/components/index.js +0 -14
- package/config/config-schema.js +0 -38
- package/config/create-schema-file.d.ts +0 -1
- package/config/create-schema-file.js +0 -20
- package/config/get-config.d.ts +0 -78
- package/config/get-config.js +0 -32
- package/config/index.d.ts +0 -2
- package/config/index.js +0 -14
- package/config/parse-config.d.ts +0 -51
- package/config/parse-config.js +0 -8
- package/config/print-zod-errors.d.ts +0 -2
- package/config/print-zod-errors.js +0 -14
- package/dev-ui/components/BreakpointColumnHeader.d.ts +0 -10
- package/dev-ui/components/BreakpointColumnHeader.js +0 -47
- package/dev-ui/components/BreakpointIndicator.js +0 -139
- package/dev-ui/components/DevUI.js +0 -28
- package/dev-ui/components/Launcher.d.ts +0 -98
- package/dev-ui/components/Launcher.js +0 -94
- package/dev-ui/components/PanelWrapper.d.ts +0 -8
- package/dev-ui/components/PanelWrapper.js +0 -37
- package/dev-ui/components/ResponsiveLerpControl.d.ts +0 -7
- package/dev-ui/components/ResponsiveLerpControl.js +0 -176
- package/dev-ui/components/ResponsiveScaleEditor.d.ts +0 -25
- package/dev-ui/components/ResponsiveScaleEditor.js +0 -238
- package/dev-ui/components/atoms/Button.d.ts +0 -47
- package/dev-ui/components/atoms/Button.js +0 -67
- package/dev-ui/components/atoms/Dropdown.d.ts +0 -13
- package/dev-ui/components/atoms/Dropdown.js +0 -50
- package/dev-ui/components/atoms/NumberField.d.ts +0 -11
- package/dev-ui/components/atoms/NumberField.js +0 -111
- package/dev-ui/components/atoms/Spacer.d.ts +0 -42
- package/dev-ui/components/atoms/Spacer.js +0 -8
- package/dev-ui/components/atoms/Text.d.ts +0 -45
- package/dev-ui/components/atoms/Text.js +0 -39
- package/dev-ui/components/atoms/ToggleButton.d.ts +0 -8
- package/dev-ui/components/atoms/ToggleButton.js +0 -41
- package/dev-ui/components/atoms/Tooltip.d.ts +0 -9
- package/dev-ui/components/atoms/Tooltip.js +0 -66
- package/dev-ui/components/panels/AppDataDebugger.d.ts +0 -1
- package/dev-ui/components/panels/AppDataDebugger.js +0 -29
- package/dev-ui/components/panels/ColorEditor.d.ts +0 -1
- package/dev-ui/components/panels/ColorEditor.js +0 -128
- package/dev-ui/components/panels/PageDataDebugger.d.ts +0 -1
- package/dev-ui/components/panels/PageDataDebugger.js +0 -30
- package/dev-ui/components/panels/QueryDebugger.d.ts +0 -1
- package/dev-ui/components/panels/QueryDebugger.js +0 -46
- package/dev-ui/components/panels/SpacingEditor.d.ts +0 -1
- package/dev-ui/components/panels/SpacingEditor.js +0 -88
- package/dev-ui/components/panels/TypographyEditor.d.ts +0 -1
- package/dev-ui/components/panels/TypographyEditor.js +0 -97
- package/dev-ui/hooks/useBreakpoint.d.ts +0 -11
- package/dev-ui/hooks/useBreakpoint.js +0 -59
- package/dev-ui/hooks/usePersistState.js +0 -36
- package/dev-ui/hooks/useStylesheet.d.ts +0 -4
- package/dev-ui/hooks/useStylesheet.js +0 -31
- package/dev-ui/icons.d.ts +0 -15
- package/dev-ui/icons.js +0 -30
- package/dev-ui/index.d.ts +0 -1
- package/dev-ui/index.js +0 -13
- package/dev-ui/loader.js +0 -44
- package/dev-ui/panels.d.ts +0 -11
- package/dev-ui/panels.js +0 -47
- package/dev-ui/theme.d.ts +0 -151
- package/dev-ui/theme.js +0 -50
- package/dynamic/dynamic-component.d.ts +0 -10
- package/dynamic/dynamic-component.js +0 -8
- package/dynamic/index.d.ts +0 -1
- package/dynamic/index.js +0 -13
- package/entry/Root.d.ts +0 -3
- package/entry/Root.js +0 -56
- package/entry/entry.admin.dev.d.ts +0 -1
- package/entry/entry.admin.dev.js +0 -26
- package/entry/entry.admin.prod.d.ts +0 -1
- package/entry/entry.admin.prod.js +0 -16
- package/entry/entry.monolith.dev.d.ts +0 -6
- package/entry/entry.monolith.dev.js +0 -19
- package/entry/entry.monolith.prod.d.ts +0 -6
- package/entry/entry.monolith.prod.js +0 -18
- package/entry/entry.publicPath.js +0 -6
- package/gravityforms/index.d.ts +0 -2
- package/gravityforms/index.js +0 -14
- package/gravityforms/types.d.ts +0 -140
- package/gravityforms/types.js +0 -2
- package/gravityforms/useGravityForm.d.ts +0 -30
- package/gravityforms/useGravityForm.js +0 -292
- package/hooks/index.js +0 -15
- package/hooks/queryUtils.d.ts +0 -63
- package/hooks/queryUtils.js +0 -281
- package/hooks/useAppData.d.ts +0 -10
- package/hooks/useAppData.js +0 -37
- package/hooks/usePageLoad.js +0 -11
- package/hooks/useQuery.d.ts +0 -1
- package/hooks/useQuery.js +0 -10
- package/hooks/useQueryDebug.js +0 -21
- package/hooks/useRPC.d.ts +0 -12
- package/hooks/useRPC.js +0 -20
- package/index.d.ts +0 -1
- package/index.js +0 -5
- package/routing/index.d.ts +0 -1
- package/routing/index.js +0 -13
- package/routing/remoteProps.d.ts +0 -22
- package/routing/remoteProps.js +0 -103
- package/routing/routing.d.ts +0 -96
- package/routing/routing.js +0 -442
- package/routing/updateEditLink.d.ts +0 -1
- package/routing/updateEditLink.js +0 -12
- package/routing/updateHeadTags.d.ts +0 -2
- package/routing/updateHeadTags.js +0 -11
- package/serverless/define-api.d.ts +0 -2
- package/serverless/define-api.js +0 -66
- package/serverless/define-rpc-router.d.ts +0 -6
- package/serverless/define-rpc-router.js +0 -35
- package/serverless/error-codes.d.ts +0 -2
- package/serverless/error-codes.js +0 -14
- package/serverless/index.d.ts +0 -5
- package/serverless/index.js +0 -18
- package/serverless/rpc-provider.d.ts +0 -1
- package/serverless/rpc-provider.js +0 -5
- package/serverless-template/README.md +0 -34
- package/serverless-template/_utils/PageMeta.tsx +0 -44
- package/serverless-template/_utils/ed-config.ts +0 -5
- package/serverless-template/_utils/fetch-wordpress-props.ts +0 -62
- package/serverless-template/_utils/fetch-wp.ts +0 -34
- package/serverless-template/_utils/swr.ts +0 -43
- package/serverless-template/global.d.ts +0 -15
- package/serverless-template/next-env.d.ts +0 -3
- package/serverless-template/next.config.js +0 -119
- package/serverless-template/null.ts +0 -1
- package/serverless-template/package.json +0 -21
- package/serverless-template/pages/404.tsx +0 -12
- package/serverless-template/pages/[...slug].tsx +0 -35
- package/serverless-template/pages/_app.tsx +0 -55
- package/serverless-template/pages/_document.tsx +0 -65
- package/serverless-template/pages/api/rest/[...method].ts +0 -54
- package/serverless-template/pages/api/robots.ts +0 -49
- package/serverless-template/pages/api/sitemap/[...sitemap].ts +0 -56
- package/serverless-template/pages/api/trpc/[...trpc].ts +0 -41
- package/serverless-template/pages/index.tsx +0 -15
- package/serverless-template/tsconfig.json +0 -39
- package/style/createStitches.d.ts +0 -1058
- package/style/createStitches.js +0 -443
- package/style/index.js +0 -13
- package/utils/Observable.d.ts +0 -11
- package/utils/Observable.js +0 -34
- package/utils/getRepoName.d.ts +0 -4
- package/utils/getRepoName.js +0 -30
- package/utils/merge-refs.d.ts +0 -2
- package/utils/merge-refs.js +0 -17
- package/utils/promptIfRepoNameIncorrect.d.ts +0 -1
- package/utils/promptIfRepoNameIncorrect.js +0 -72
- package/utils/refreshOverlayInterop.d.ts +0 -4
- package/utils/refreshOverlayInterop.js +0 -12
- package/utils/reportErrorStack.d.ts +0 -7
- package/utils/reportErrorStack.js +0 -13
- package/utils/serverlessAppContext.d.ts +0 -3
- package/utils/serverlessAppContext.js +0 -6
- package/utils/updateEnvFile.d.ts +0 -1
- package/utils/updateEnvFile.js +0 -76
- package/utils/useObservable.d.ts +0 -2
- package/utils/useObservable.js +0 -12
- package/views/defineView.d.ts +0 -2
- package/views/defineView.js +0 -7
- package/views/index.js +0 -13
- /package/{admin → dist/app/lib/admin}/installFieldTypes.d.ts +0 -0
- /package/{admin → dist/app/lib/admin}/runWidgets.d.ts +0 -0
- /package/{dev-ui → dist/app/lib/devtools}/components/BreakpointIndicator.d.ts +0 -0
- /package/{dev-ui → dist/app/lib/devtools}/hooks/usePersistState.d.ts +0 -0
- /package/{entry/entry.publicPath.d.ts → dist/app/lib/devtools/index.d.ts} +0 -0
- /package/{dev-ui → dist/app/lib/devtools}/loader.d.ts +0 -0
- /package/{style → dist/app/lib/legacy-stitches}/index.d.ts +0 -0
- /package/{build/graphql-codegen/graphql-codegen-files.d.ts → dist/app/lib/routing/types.js} +0 -0
- /package/{views → dist/app/lib/views}/index.d.ts +0 -0
- /package/{build/graphql-codegen/graphql-codegen-no-duplicates.d.ts → dist/app/utils/wp.js} +0 -0
- /package/{cli → dist/node/cli}/cli.d.ts +0 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState, useTransition } from "react";
|
|
3
|
+
import { isRelative, parseURL, resolveURL } from "ufo";
|
|
4
|
+
import { RouterContext, RouterStateContext } from "../context";
|
|
5
|
+
import { RouteLoader } from "../loader";
|
|
6
|
+
import { getLinkHandlerMode, normalizeRoute, parseQuery, stringifyRouteLink } from "../utils";
|
|
7
|
+
import { AppRenderer } from "./RouteRenderer";
|
|
8
|
+
const loader = new RouteLoader();
|
|
9
|
+
let initialRoute;
|
|
10
|
+
let initialRouteHydrated = false;
|
|
11
|
+
if (env.client && !env.admin) {
|
|
12
|
+
const initialData = window._PAGE_DATA;
|
|
13
|
+
const appData = initialData.appData;
|
|
14
|
+
loader.setAppData(appData.data);
|
|
15
|
+
loader.populateRouteData(document.location.pathname, initialData);
|
|
16
|
+
const initialURL = parseURL(document.location.href);
|
|
17
|
+
initialRoute = normalizeRoute({
|
|
18
|
+
id: "initial",
|
|
19
|
+
component: loader.getRouteComponent(initialData.view),
|
|
20
|
+
pathname: initialURL.pathname,
|
|
21
|
+
hash: "",
|
|
22
|
+
props: initialData.viewData?.data ?? {},
|
|
23
|
+
search: "",
|
|
24
|
+
query: {},
|
|
25
|
+
view: initialData.view,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function parseHrefPath(url) {
|
|
29
|
+
if (isRelative(url)) {
|
|
30
|
+
url = resolveURL(document.location.href, url);
|
|
31
|
+
}
|
|
32
|
+
const parsed = parseURL(url);
|
|
33
|
+
return parsed.pathname;
|
|
34
|
+
}
|
|
35
|
+
function parseHref(url) {
|
|
36
|
+
if (isRelative(url)) {
|
|
37
|
+
url = resolveURL(document.location.href, url);
|
|
38
|
+
}
|
|
39
|
+
return parseURL(url);
|
|
40
|
+
}
|
|
41
|
+
function parseRouteLink(url) {
|
|
42
|
+
const parsed = parseHref(url);
|
|
43
|
+
return {
|
|
44
|
+
pathname: parsed.pathname,
|
|
45
|
+
query: parseQuery(parsed.search),
|
|
46
|
+
hash: parsed.hash,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function historyStateForRoute(route) {
|
|
50
|
+
return {
|
|
51
|
+
id: route.id,
|
|
52
|
+
key: route.key,
|
|
53
|
+
view: route.view,
|
|
54
|
+
state: route.returnState,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
let index = 0;
|
|
58
|
+
function getHistoryId() {
|
|
59
|
+
return String(index++);
|
|
60
|
+
}
|
|
61
|
+
let lastRouterState = null;
|
|
62
|
+
export function BrowserRouter(props) {
|
|
63
|
+
const pendingRoute = useRef(null);
|
|
64
|
+
// const [activeRoute, setActiveRoute] = useState<RouteState>(initialRoute)
|
|
65
|
+
const [transitioning, startTransition] = useTransition();
|
|
66
|
+
const [routerState, setRouterState] = useState(() => ({
|
|
67
|
+
activeRoute: initialRoute,
|
|
68
|
+
history: [initialRoute],
|
|
69
|
+
blockers: [],
|
|
70
|
+
}));
|
|
71
|
+
if (lastRouterState !== routerState) {
|
|
72
|
+
lastRouterState = routerState;
|
|
73
|
+
}
|
|
74
|
+
const { internals, api } = useMemo(() => {
|
|
75
|
+
let subscribers = new Set();
|
|
76
|
+
let state = routerState;
|
|
77
|
+
const setState = (update) => {
|
|
78
|
+
state = {
|
|
79
|
+
...state,
|
|
80
|
+
...update,
|
|
81
|
+
};
|
|
82
|
+
setRouterState(state);
|
|
83
|
+
};
|
|
84
|
+
const internals = {
|
|
85
|
+
transitionEnded: null,
|
|
86
|
+
updateRoute: null,
|
|
87
|
+
poppedState: null,
|
|
88
|
+
};
|
|
89
|
+
history.scrollRestoration = "manual";
|
|
90
|
+
const emitEvent = (event) => {
|
|
91
|
+
subscribers.forEach((fn) => fn(event));
|
|
92
|
+
};
|
|
93
|
+
const captureState = () => {
|
|
94
|
+
const state = {
|
|
95
|
+
scrollTop: document.scrollingElement.scrollTop,
|
|
96
|
+
scrollLeft: document.scrollingElement.scrollLeft,
|
|
97
|
+
};
|
|
98
|
+
emitEvent({ type: "capture-restorable-state", state: state });
|
|
99
|
+
return state;
|
|
100
|
+
};
|
|
101
|
+
internals.updateRoute = (route) => {
|
|
102
|
+
replaceRoute({
|
|
103
|
+
...state.activeRoute,
|
|
104
|
+
...route,
|
|
105
|
+
}, false);
|
|
106
|
+
};
|
|
107
|
+
const historyCache = new Map();
|
|
108
|
+
function setHistory(history) {
|
|
109
|
+
setState({
|
|
110
|
+
history,
|
|
111
|
+
activeRoute: history[history.length - 1],
|
|
112
|
+
});
|
|
113
|
+
for (let item of history) {
|
|
114
|
+
historyCache.set(item.id, item);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
internals.poppedState = (href, data) => {
|
|
118
|
+
const stack = state.history;
|
|
119
|
+
// Is the route in our history stack? (going back)
|
|
120
|
+
const index = stack.findIndex((item) => item.id === data.id);
|
|
121
|
+
if (index >= 0) {
|
|
122
|
+
const route = stack[index];
|
|
123
|
+
return doRouteTransition({
|
|
124
|
+
url: route.uri,
|
|
125
|
+
route,
|
|
126
|
+
goingBack: true,
|
|
127
|
+
history: stack.slice(0, index),
|
|
128
|
+
restoreState: route.returnState ?? data.state,
|
|
129
|
+
shouldPush: false,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
// Is the route in our history _cache_? (probably going forward)
|
|
133
|
+
if (historyCache.has(data.id)) {
|
|
134
|
+
const route = historyCache.get(data.id);
|
|
135
|
+
return doRouteTransition({
|
|
136
|
+
url: route.uri,
|
|
137
|
+
route,
|
|
138
|
+
goingBack: false,
|
|
139
|
+
history: stack,
|
|
140
|
+
restoreState: route.returnState ?? data.state,
|
|
141
|
+
shouldPush: false,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return doRouteTransition({
|
|
145
|
+
url: href,
|
|
146
|
+
goingBack: true,
|
|
147
|
+
history: [],
|
|
148
|
+
restoreState: data.state,
|
|
149
|
+
shouldPush: false,
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
const replaceRoute = (_route, updateBrowser = true) => {
|
|
153
|
+
const route = normalizeRoute(_route);
|
|
154
|
+
setHistory([...state.history.slice(0, -1), route]);
|
|
155
|
+
if (updateBrowser) {
|
|
156
|
+
history.replaceState(historyStateForRoute(route), "", route.uri);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
function getActiveRoute() {
|
|
160
|
+
const stack = state.history;
|
|
161
|
+
return stack[stack.length - 1];
|
|
162
|
+
}
|
|
163
|
+
async function doRouteTransition(args) {
|
|
164
|
+
// clearPending()
|
|
165
|
+
const link = parseRouteLink(args.url);
|
|
166
|
+
let cancelled = false;
|
|
167
|
+
const currentRoute = getActiveRoute();
|
|
168
|
+
// Remember scroll position and other state on the outgoing route
|
|
169
|
+
currentRoute.returnState = captureState();
|
|
170
|
+
const hasRouteData = !!args.route || loader.hasRouteData(link.pathname);
|
|
171
|
+
// Emit a navigation event
|
|
172
|
+
emitEvent({
|
|
173
|
+
type: "navigate:start",
|
|
174
|
+
link,
|
|
175
|
+
currentRoute: currentRoute,
|
|
176
|
+
hasPreloadedData: hasRouteData,
|
|
177
|
+
goingBack: !!args.goingBack,
|
|
178
|
+
cancel() {
|
|
179
|
+
cancelled = true;
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
if (cancelled)
|
|
183
|
+
return;
|
|
184
|
+
const data = await loader.loadRouteData(parseHrefPath(args.url));
|
|
185
|
+
if (!data.view) {
|
|
186
|
+
console.error("No `view` property in route data");
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const lazyComponent = loader.getRouteComponent(data.view);
|
|
190
|
+
if (!lazyComponent) {
|
|
191
|
+
console.error(`No component found for view: ${data.view}`);
|
|
192
|
+
}
|
|
193
|
+
const route = args.route ??
|
|
194
|
+
normalizeRoute({
|
|
195
|
+
id: getHistoryId(),
|
|
196
|
+
hash: link.hash,
|
|
197
|
+
search: "",
|
|
198
|
+
query: link.query,
|
|
199
|
+
pathname: link.pathname,
|
|
200
|
+
view: data.view,
|
|
201
|
+
props: data.viewData?.data ?? {},
|
|
202
|
+
component: lazyComponent,
|
|
203
|
+
returnState: args.restoreState ?? {},
|
|
204
|
+
});
|
|
205
|
+
setState({
|
|
206
|
+
pendingRoute: route,
|
|
207
|
+
});
|
|
208
|
+
emitEvent({
|
|
209
|
+
type: "navigate:data-ready",
|
|
210
|
+
currentRoute,
|
|
211
|
+
loadedRoute: route,
|
|
212
|
+
link,
|
|
213
|
+
});
|
|
214
|
+
emitEvent({
|
|
215
|
+
type: "navigate:will-change",
|
|
216
|
+
currentRoute,
|
|
217
|
+
loadedRoute: route,
|
|
218
|
+
link,
|
|
219
|
+
});
|
|
220
|
+
internals.transitionEnded = () => {
|
|
221
|
+
internals.transitionEnded = null;
|
|
222
|
+
// Update the URL
|
|
223
|
+
// if (!returnState) {
|
|
224
|
+
// route.returnState = captureState()
|
|
225
|
+
// }
|
|
226
|
+
emitEvent({
|
|
227
|
+
type: "navigate:changed",
|
|
228
|
+
currentRoute: route,
|
|
229
|
+
lastRoute: currentRoute,
|
|
230
|
+
link,
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
startTransition(() => {
|
|
234
|
+
pendingRoute.current = route;
|
|
235
|
+
setHistory([...(args.history || state.history), route]);
|
|
236
|
+
if (args.shouldPush) {
|
|
237
|
+
history.pushState(historyStateForRoute(route), "", stringifyRouteLink(route));
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
const api = {
|
|
242
|
+
loader: loader,
|
|
243
|
+
async navigate(url) {
|
|
244
|
+
doRouteTransition({
|
|
245
|
+
url: url,
|
|
246
|
+
shouldPush: true,
|
|
247
|
+
goingBack: false,
|
|
248
|
+
});
|
|
249
|
+
},
|
|
250
|
+
replaceHash(hash) {
|
|
251
|
+
replaceRoute({
|
|
252
|
+
...getActiveRoute(),
|
|
253
|
+
hash,
|
|
254
|
+
});
|
|
255
|
+
},
|
|
256
|
+
replaceQuery(query) {
|
|
257
|
+
replaceRoute({
|
|
258
|
+
...getActiveRoute(),
|
|
259
|
+
query,
|
|
260
|
+
});
|
|
261
|
+
},
|
|
262
|
+
async prefetch(url) {
|
|
263
|
+
try {
|
|
264
|
+
const link = parseRouteLink(url);
|
|
265
|
+
if (loader.hasRouteData(link.pathname))
|
|
266
|
+
return;
|
|
267
|
+
emitEvent({ type: "preload:start", currentRoute: getActiveRoute(), link });
|
|
268
|
+
const data = await loader.loadRouteData(link.pathname).then((data) => {
|
|
269
|
+
emitEvent({ type: "preload:data-ready", currentRoute: getActiveRoute(), link, data });
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
catch (err) {
|
|
273
|
+
emitEvent({ type: "error", error: err, critical: false });
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
async preload(url) {
|
|
277
|
+
try {
|
|
278
|
+
const link = parseRouteLink(url);
|
|
279
|
+
if (loader.hasRouteData(link.pathname))
|
|
280
|
+
return;
|
|
281
|
+
emitEvent({ type: "preload:start", currentRoute: getActiveRoute(), link });
|
|
282
|
+
const data = await loader.loadRouteData(link.pathname);
|
|
283
|
+
emitEvent({ type: "preload:data-ready", currentRoute: getActiveRoute(), link, data });
|
|
284
|
+
if (data.view) {
|
|
285
|
+
const lazyComponent = loader.getRouteComponent(data.view);
|
|
286
|
+
await lazyComponent.preload();
|
|
287
|
+
emitEvent({ type: "preload:finished", currentRoute: getActiveRoute(), link, data });
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
catch (err) {
|
|
291
|
+
emitEvent({ type: "error", error: err, critical: false });
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
subscribe(fn) {
|
|
295
|
+
subscribers.add(fn);
|
|
296
|
+
return () => {
|
|
297
|
+
subscribers.delete(fn);
|
|
298
|
+
};
|
|
299
|
+
},
|
|
300
|
+
handleClickEvent(e, originalHref) {
|
|
301
|
+
const { mode, href } = getLinkHandlerMode(e, originalHref);
|
|
302
|
+
if (mode === "ignore") {
|
|
303
|
+
e.preventDefault();
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
else if (mode === "native") {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
else if (mode === "navigate" && href) {
|
|
310
|
+
e.preventDefault();
|
|
311
|
+
api.navigate(href);
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
emitEvent,
|
|
315
|
+
};
|
|
316
|
+
return {
|
|
317
|
+
api,
|
|
318
|
+
internals,
|
|
319
|
+
};
|
|
320
|
+
}, []);
|
|
321
|
+
useEffect(() => {
|
|
322
|
+
if (!transitioning && internals.transitionEnded) {
|
|
323
|
+
internals.transitionEnded();
|
|
324
|
+
}
|
|
325
|
+
}, [transitioning]);
|
|
326
|
+
useEffect(() => {
|
|
327
|
+
if (!initialRouteHydrated && !transitioning) {
|
|
328
|
+
initialRouteHydrated = true;
|
|
329
|
+
// Calculate the bits we care about
|
|
330
|
+
const hash = document.location.hash;
|
|
331
|
+
const query = parseQuery(document.location.search);
|
|
332
|
+
if (Object.keys(query).length > 0 || hash) {
|
|
333
|
+
startTransition(() => {
|
|
334
|
+
internals.updateRoute?.({ query, hash });
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}, [transitioning]);
|
|
339
|
+
useEffect(() => {
|
|
340
|
+
// Handle popState
|
|
341
|
+
// const router = useRouterStore.getState()
|
|
342
|
+
const onPopState = (e) => {
|
|
343
|
+
internals.poppedState?.(document.location.href, e.state ?? {});
|
|
344
|
+
};
|
|
345
|
+
window.addEventListener("popstate", onPopState);
|
|
346
|
+
return () => {
|
|
347
|
+
window.removeEventListener("popstate", onPopState);
|
|
348
|
+
};
|
|
349
|
+
}, []);
|
|
350
|
+
return (_jsx(RouterContext.Provider, { value: api, children: _jsx(RouterStateContext.Provider, { value: routerState, children: _jsx(AppRenderer, {}) }) }));
|
|
351
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
type Props = PropsWithChildren<{
|
|
3
|
+
/** An optional fallback, to be shown before the client component. */
|
|
4
|
+
fallback?: React.ReactNode;
|
|
5
|
+
}>;
|
|
6
|
+
/**
|
|
7
|
+
* Renders children, but only on the client.
|
|
8
|
+
*
|
|
9
|
+
* The optional 'fallback' prop can be used to show a loading state or placeholder content while the client bundle is loading.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ClientOnly(props: Props): string | number | boolean | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from "react";
|
|
3
|
+
import { useIsSSR } from "../hooks/useIsSSR";
|
|
4
|
+
/**
|
|
5
|
+
* Renders children, but only on the client.
|
|
6
|
+
*
|
|
7
|
+
* The optional 'fallback' prop can be used to show a loading state or placeholder content while the client bundle is loading.
|
|
8
|
+
*/
|
|
9
|
+
export function ClientOnly(props) {
|
|
10
|
+
const mounted = useIsSSR();
|
|
11
|
+
if (!mounted)
|
|
12
|
+
return props.fallback ?? null;
|
|
13
|
+
return _jsx(Fragment, { children: props.children });
|
|
14
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ElementType, ReactElement } from "react";
|
|
2
|
+
type Props<T extends ElementType = "a"> = NoInfer<Omit<ComponentPropsWithRef<T>, "href">> & {
|
|
3
|
+
href?: string | null;
|
|
4
|
+
target?: string | null;
|
|
5
|
+
as?: T;
|
|
6
|
+
};
|
|
7
|
+
export declare const Link: <T extends ElementType = "a">(props: Props<T>) => ReactElement;
|
|
8
|
+
/**
|
|
9
|
+
* Provides information about the given href parameter, such as whether it is active, whether a child page is active, or whether it is loading.
|
|
10
|
+
*
|
|
11
|
+
* This is used internally by the `<Link />` component for the `data-active`, `data-child-active` and `data-pending` attributes, but is exposed for use in custom components.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useLinkState(href: string): {
|
|
14
|
+
active: boolean;
|
|
15
|
+
childActive?: undefined;
|
|
16
|
+
pending?: undefined;
|
|
17
|
+
} | {
|
|
18
|
+
active?: undefined;
|
|
19
|
+
childActive?: undefined;
|
|
20
|
+
pending?: undefined;
|
|
21
|
+
} | {
|
|
22
|
+
active: "path" | "query" | "exact" | undefined;
|
|
23
|
+
childActive: boolean | undefined;
|
|
24
|
+
pending: "path" | "query" | "exact" | undefined;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useMemo } from "react";
|
|
3
|
+
import { parseURL, resolveURL, withoutTrailingSlash } from "ufo";
|
|
4
|
+
import { useIsSSR } from "../hooks/useIsSSR";
|
|
5
|
+
import { useRouter } from "../hooks/useRouter";
|
|
6
|
+
import { isSameOrigin } from "../utils";
|
|
7
|
+
import { useRoute } from "../hooks/useRoute";
|
|
8
|
+
import { useRouterState } from "../hooks/useRouterState";
|
|
9
|
+
export const Link = forwardRef((props, ref) => {
|
|
10
|
+
const Comp = props.as || "a";
|
|
11
|
+
if (env.admin) {
|
|
12
|
+
return (_jsx(Comp, { ref: ref, ...props, href: props.href ?? undefined, onClick: (e) => {
|
|
13
|
+
props.onClick?.(e);
|
|
14
|
+
e.preventDefault();
|
|
15
|
+
} }));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
const preload = useRouter((r) => r.preload);
|
|
19
|
+
const handleClickEvent = useRouter((r) => r.handleClickEvent);
|
|
20
|
+
const state = useLinkState(props.href ?? "");
|
|
21
|
+
return (_jsx(Comp, { ref: ref, "data-active": state.active ?? undefined, "data-child-active": state.childActive ?? undefined, "data-pending": state.pending ?? undefined, ...props, href: props.href ?? undefined, onMouseEnter: (e) => {
|
|
22
|
+
if (props.onMouseEnter) {
|
|
23
|
+
props.onMouseEnter(e);
|
|
24
|
+
}
|
|
25
|
+
preload(props.href);
|
|
26
|
+
}, onClick: (e) => {
|
|
27
|
+
props.onClick?.(e);
|
|
28
|
+
handleClickEvent(e, props.href ?? undefined);
|
|
29
|
+
} }));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
Link.displayName = "Link";
|
|
34
|
+
/**
|
|
35
|
+
* Provides information about the given href parameter, such as whether it is active, whether a child page is active, or whether it is loading.
|
|
36
|
+
*
|
|
37
|
+
* This is used internally by the `<Link />` component for the `data-active`, `data-child-active` and `data-pending` attributes, but is exposed for use in custom components.
|
|
38
|
+
*/
|
|
39
|
+
export function useLinkState(href) {
|
|
40
|
+
const route = useRoute();
|
|
41
|
+
const pendingRoute = useRouterState((r) => r.pendingRoute);
|
|
42
|
+
const isSSR = useIsSSR();
|
|
43
|
+
const state = useMemo(() => {
|
|
44
|
+
// If we're in SSR mode, do a quick and dirty check, which relies on the href being relative.
|
|
45
|
+
if (isSSR) {
|
|
46
|
+
if (href === route.pathname)
|
|
47
|
+
return {
|
|
48
|
+
active: true,
|
|
49
|
+
};
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
// Bail out for external links
|
|
53
|
+
if (!href || !isSameOrigin(href)) {
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
const hrefUrl = parseURL(resolveURL(href));
|
|
57
|
+
const active = route ? compareUri(route, hrefUrl) : undefined;
|
|
58
|
+
const childActive = !active && route ? isSubpath(hrefUrl.pathname, route.pathname) : undefined;
|
|
59
|
+
const pending = pendingRoute ? compareUri(pendingRoute, hrefUrl) : undefined;
|
|
60
|
+
return {
|
|
61
|
+
active,
|
|
62
|
+
childActive,
|
|
63
|
+
pending,
|
|
64
|
+
};
|
|
65
|
+
}, [isSSR, href, route, pendingRoute]);
|
|
66
|
+
return state;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns the active-ness state for the given link.
|
|
70
|
+
* path = the path matches, but not the query/hash
|
|
71
|
+
* query = the path and query matches, but not the hash
|
|
72
|
+
* exact = the path, query and hash all match exactly
|
|
73
|
+
*/
|
|
74
|
+
function compareUri(route, href) {
|
|
75
|
+
// If they're directly equal, then jump straight to a 'hash' match
|
|
76
|
+
if (withoutTrailingSlash(route.pathname) === withoutTrailingSlash(href.pathname)) {
|
|
77
|
+
if (route.search.replace(/^\?/, "") === href.search.replace(/^\?/, "")) {
|
|
78
|
+
if (route.hash === href.hash) {
|
|
79
|
+
return "exact";
|
|
80
|
+
}
|
|
81
|
+
return "query";
|
|
82
|
+
}
|
|
83
|
+
return "path";
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function isSubpath(parentPath, childPath) {
|
|
87
|
+
if (withoutTrailingSlash(parentPath) === withoutTrailingSlash(childPath)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
if (childPath.startsWith(parentPath)) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RouteState } from "../types";
|
|
2
|
+
export declare const AppRenderer: import("react").MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
|
|
3
|
+
export declare function MainRoute(): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function RouteDisplay(props: {
|
|
5
|
+
route: RouteState;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare namespace RouteDisplay {
|
|
8
|
+
var displayName: string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo, Suspense, useMemo } from "react";
|
|
3
|
+
import { RouteItemContext } from "../context";
|
|
4
|
+
import { useRouter } from "../hooks/useRouter";
|
|
5
|
+
import { useRouterState } from "../hooks/useRouterState";
|
|
6
|
+
export const AppRenderer = memo(() => {
|
|
7
|
+
const { appData, appComponent: AppComponent } = useRouter().loader;
|
|
8
|
+
const { activeRoute } = useRouterState();
|
|
9
|
+
const app = useMemo(() => {
|
|
10
|
+
return (_jsx(AppComponent, { ...appData, children: _jsx(MainRoute, {}) }));
|
|
11
|
+
}, [AppComponent, appData]);
|
|
12
|
+
return (_jsx(Suspense, { children: _jsx(RouteItemContext.Provider, { value: activeRoute, children: app }) }));
|
|
13
|
+
});
|
|
14
|
+
export function MainRoute() {
|
|
15
|
+
const activeRoute = useRouterState((s) => s.activeRoute);
|
|
16
|
+
return _jsx(RouteDisplay, { route: activeRoute });
|
|
17
|
+
}
|
|
18
|
+
export function RouteDisplay(props) {
|
|
19
|
+
const Component = props.route.component;
|
|
20
|
+
if (!Component) {
|
|
21
|
+
console.error("No component for route");
|
|
22
|
+
}
|
|
23
|
+
return useMemo(() => {
|
|
24
|
+
let child = !!Component && _jsx(Component, { ...props.route.props });
|
|
25
|
+
return _jsx(RouteItemContext.Provider, { value: props.route, children: child });
|
|
26
|
+
}, [Component, props.route, props.route]);
|
|
27
|
+
}
|
|
28
|
+
RouteDisplay.displayName = "RouteDisplay";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
import { RouteLoader } from "../loader";
|
|
3
|
+
import { RouteState } from "../types";
|
|
4
|
+
type Props = PropsWithChildren<{
|
|
5
|
+
route: RouteState;
|
|
6
|
+
loader: RouteLoader;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function SSRRouter(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense } from "react";
|
|
3
|
+
import { RouterContext, RouterStateContext } from "../context";
|
|
4
|
+
import { useRouter } from "../hooks/useRouter";
|
|
5
|
+
import { useRouterState } from "../hooks/useRouterState";
|
|
6
|
+
import { AppRenderer } from "./RouteRenderer";
|
|
7
|
+
export function SSRRouter(props) {
|
|
8
|
+
const router = useRouter();
|
|
9
|
+
const routerState = useRouterState();
|
|
10
|
+
router.loader = props.loader;
|
|
11
|
+
routerState.history = [props.route];
|
|
12
|
+
routerState.activeRoute = props.route;
|
|
13
|
+
return (_jsx(Suspense, { children: _jsx(RouterContext.Provider, { value: router, children: _jsx(RouterStateContext.Provider, { value: routerState, children: _jsx(AppRenderer, {}) }) }) }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
/** An optional restoration function, allowing you to handle scroll restoration manually */
|
|
3
|
+
restore?: (scroll: {
|
|
4
|
+
top: number;
|
|
5
|
+
left: number;
|
|
6
|
+
direction: "back" | "forward";
|
|
7
|
+
}) => void;
|
|
8
|
+
/** The scroll behaviour @default instant */
|
|
9
|
+
behaviour?: ScrollBehavior;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Enables scroll restoration when navigation backwards, as well as resetting scroll position when navigating forwards.
|
|
13
|
+
*/
|
|
14
|
+
export declare function ScrollRestoration(props: Props): null;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useRouterEvents } from "../hooks/useRouterEvents";
|
|
2
|
+
/**
|
|
3
|
+
* Enables scroll restoration when navigation backwards, as well as resetting scroll position when navigating forwards.
|
|
4
|
+
*/
|
|
5
|
+
export function ScrollRestoration(props) {
|
|
6
|
+
const restore = props.restore ??
|
|
7
|
+
((scroll) => document.scrollingElement?.scrollTo({
|
|
8
|
+
behavior: props.behaviour ?? "instant",
|
|
9
|
+
left: scroll.left,
|
|
10
|
+
top: scroll.top,
|
|
11
|
+
}));
|
|
12
|
+
useRouterEvents((event) => {
|
|
13
|
+
if (event.type === "navigate:changed") {
|
|
14
|
+
// console.log("Changed! Restoring scroll", event.currentRoute)
|
|
15
|
+
if (event.currentRoute.returnState) {
|
|
16
|
+
restore({
|
|
17
|
+
top: event.currentRoute.returnState.scrollTop ?? 0,
|
|
18
|
+
left: event.currentRoute.returnState.scrollLeft ?? 0,
|
|
19
|
+
direction: "back",
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
restore({
|
|
24
|
+
top: 0,
|
|
25
|
+
left: 0,
|
|
26
|
+
direction: "forward",
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Context } from "react";
|
|
2
|
+
import { RouterAPI, RouterAPIState } from "./types";
|
|
3
|
+
export declare const RouterContext: Context<RouterAPI>;
|
|
4
|
+
export declare const RouterStateContext: Context<RouterAPIState>;
|
|
5
|
+
export declare const RouteItemContext: Context<import("./types").TypedRouteState<"_unknown", {}>>;
|