@payloadcms/tanstack-start 4.0.0-internal.7e57eed → 4.0.0-internal.8001944
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/dist/adapters/handleServerFunctions.d.ts.map +1 -0
- package/dist/adapters/handleServerFunctions.js +9 -0
- package/dist/adapters/handleServerFunctions.js.map +1 -0
- package/dist/{layouts/Root/withPayloadRoot.d.ts → adapters/layout.d.ts} +29 -4
- package/dist/adapters/layout.d.ts.map +1 -0
- package/dist/adapters/layout.js +111 -0
- package/dist/adapters/layout.js.map +1 -0
- package/dist/adapters/layout.server.d.ts +29 -0
- package/dist/adapters/layout.server.d.ts.map +1 -0
- package/dist/adapters/layout.server.js +61 -0
- package/dist/adapters/layout.server.js.map +1 -0
- package/dist/{utilities/meta.d.ts → adapters/metadata.d.ts} +10 -1
- package/dist/adapters/metadata.d.ts.map +1 -0
- package/dist/{utilities/meta.js → adapters/metadata.js} +60 -1
- package/dist/adapters/metadata.js.map +1 -0
- package/dist/{elements/RouterAdapter/index.d.ts → adapters/router.d.ts} +1 -1
- package/dist/adapters/router.d.ts.map +1 -0
- package/dist/{elements/RouterAdapter/index.js → adapters/router.js} +27 -4
- package/dist/adapters/router.js.map +1 -0
- package/dist/{utilities/serverAdapter.server.d.ts → adapters/server.d.ts} +1 -1
- package/dist/adapters/server.d.ts.map +1 -0
- package/dist/{utilities/serverAdapter.server.js → adapters/server.js} +1 -1
- package/dist/adapters/server.js.map +1 -0
- package/dist/{routes/adminRoutes.d.ts → adapters/views.d.ts} +9 -13
- package/dist/adapters/views.d.ts.map +1 -0
- package/dist/{routes/adminRoutes.js → adapters/views.js} +36 -18
- package/dist/adapters/views.js.map +1 -0
- package/dist/{utilities/loadAdminPage.d.ts → adapters/views.server.d.ts} +9 -6
- package/dist/adapters/views.server.d.ts.map +1 -0
- package/dist/{utilities/loadAdminPage.js → adapters/views.server.js} +12 -74
- package/dist/adapters/views.server.js.map +1 -0
- package/dist/auth/login.js +1 -1
- package/dist/auth/login.js.map +1 -1
- package/dist/auth/logout.js +1 -1
- package/dist/auth/logout.js.map +1 -1
- package/dist/auth/refresh.js +1 -1
- package/dist/auth/refresh.js.map +1 -1
- package/dist/exports/client.d.ts +3 -5
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +3 -5
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/layouts.d.ts +2 -3
- package/dist/exports/layouts.d.ts.map +1 -1
- package/dist/exports/layouts.js +1 -2
- package/dist/exports/layouts.js.map +1 -1
- package/dist/exports/server.d.ts +8 -10
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +7 -9
- package/dist/exports/server.js.map +1 -1
- package/dist/{utilities/graphqlHandler.server.d.ts → routes/graphql/handler.server.d.ts} +1 -1
- package/dist/routes/graphql/handler.server.d.ts.map +1 -0
- package/dist/{utilities/graphqlHandler.server.js → routes/graphql/handler.server.js} +3 -3
- package/dist/routes/graphql/handler.server.js.map +1 -0
- package/dist/{utilities/handleAPIRoute.server.d.ts → routes/rest/handler.server.d.ts} +1 -1
- package/dist/routes/rest/handler.server.d.ts.map +1 -0
- package/dist/{utilities/handleAPIRoute.server.js → routes/rest/handler.server.js} +1 -1
- package/dist/routes/rest/handler.server.js.map +1 -0
- package/dist/routes/{apiRoute.d.ts → rest/index.d.ts} +1 -1
- package/dist/routes/rest/index.d.ts.map +1 -0
- package/dist/routes/{apiRoute.js → rest/index.js} +2 -2
- package/dist/routes/rest/index.js.map +1 -0
- package/dist/utilities/devConfigReload.server.d.ts +2 -0
- package/dist/utilities/devConfigReload.server.d.ts.map +1 -0
- package/dist/utilities/devConfigReload.server.js +63 -0
- package/dist/utilities/devConfigReload.server.js.map +1 -0
- package/dist/utilities/devConfigReloadEvent.d.ts +9 -0
- package/dist/utilities/devConfigReloadEvent.d.ts.map +1 -0
- package/dist/utilities/devConfigReloadEvent.js +9 -0
- package/dist/utilities/devConfigReloadEvent.js.map +1 -0
- package/dist/utilities/getRequestI18n.server.d.ts +1 -1
- package/dist/utilities/getRequestI18n.server.js +1 -1
- package/dist/utilities/getRequestI18n.server.js.map +1 -1
- package/dist/utilities/initAdminContext.server.d.ts +9 -0
- package/dist/utilities/initAdminContext.server.d.ts.map +1 -0
- package/dist/utilities/initAdminContext.server.js +13 -0
- package/dist/utilities/initAdminContext.server.js.map +1 -0
- package/dist/utilities/serializeForRsc.d.ts.map +1 -1
- package/dist/utilities/serializeForRsc.js +6 -1
- package/dist/utilities/serializeForRsc.js.map +1 -1
- package/dist/utilities/serverFunctionClient.d.ts.map +1 -1
- package/dist/utilities/serverFunctionClient.js +6 -1
- package/dist/utilities/serverFunctionClient.js.map +1 -1
- package/dist/utilities/toSerializable.d.ts +9 -0
- package/dist/utilities/toSerializable.d.ts.map +1 -1
- package/dist/utilities/toSerializable.js +19 -3
- package/dist/utilities/toSerializable.js.map +1 -1
- package/dist/withPayload/config/external.d.ts +16 -8
- package/dist/withPayload/config/external.d.ts.map +1 -1
- package/dist/withPayload/config/external.js +24 -10
- package/dist/withPayload/config/external.js.map +1 -1
- package/dist/withPayload/config/optimizeDeps.d.ts.map +1 -1
- package/dist/withPayload/config/optimizeDeps.js +44 -7
- package/dist/withPayload/config/optimizeDeps.js.map +1 -1
- package/dist/withPayload/devConfigReload.d.ts +14 -0
- package/dist/withPayload/devConfigReload.d.ts.map +1 -0
- package/dist/withPayload/devConfigReload.js +84 -0
- package/dist/withPayload/devConfigReload.js.map +1 -0
- package/dist/withPayload/index.d.ts +19 -0
- package/dist/withPayload/index.d.ts.map +1 -1
- package/dist/withPayload/index.js +36 -5
- package/dist/withPayload/index.js.map +1 -1
- package/dist/withPayload/workarounds/stripDistStyleImports.js +1 -1
- package/dist/withPayload/workarounds/stripDistStyleImports.js.map +1 -1
- package/package.json +10 -10
- package/dist/elements/RouterAdapter/index.d.ts.map +0 -1
- package/dist/elements/RouterAdapter/index.js.map +0 -1
- package/dist/layouts/Root/getLayoutData.d.ts +0 -34
- package/dist/layouts/Root/getLayoutData.d.ts.map +0 -1
- package/dist/layouts/Root/getLayoutData.js +0 -97
- package/dist/layouts/Root/getLayoutData.js.map +0 -1
- package/dist/layouts/Root/withPayloadRoot.d.ts.map +0 -1
- package/dist/layouts/Root/withPayloadRoot.js +0 -91
- package/dist/layouts/Root/withPayloadRoot.js.map +0 -1
- package/dist/node/cssLoader.d.mts +0 -25
- package/dist/node/cssLoader.d.mts.map +0 -1
- package/dist/node/cssLoader.js +0 -70
- package/dist/node/cssLoader.js.map +0 -1
- package/dist/node/cssLoader.mjs +0 -75
- package/dist/node/registerCssLoader.d.mts +0 -2
- package/dist/node/registerCssLoader.d.mts.map +0 -1
- package/dist/node/registerCssLoader.js +0 -10
- package/dist/node/registerCssLoader.js.map +0 -1
- package/dist/node/registerCssLoader.mjs +0 -10
- package/dist/routes/adminRoutes.d.ts.map +0 -1
- package/dist/routes/adminRoutes.js.map +0 -1
- package/dist/routes/apiRoute.d.ts.map +0 -1
- package/dist/routes/apiRoute.js.map +0 -1
- package/dist/routes/layoutRoute.d.ts +0 -26
- package/dist/routes/layoutRoute.d.ts.map +0 -1
- package/dist/routes/layoutRoute.js +0 -58
- package/dist/routes/layoutRoute.js.map +0 -1
- package/dist/utilities/devReloadStrategy.d.ts +0 -10
- package/dist/utilities/devReloadStrategy.d.ts.map +0 -1
- package/dist/utilities/devReloadStrategy.js +0 -27
- package/dist/utilities/devReloadStrategy.js.map +0 -1
- package/dist/utilities/getRequestLocale.d.ts +0 -7
- package/dist/utilities/getRequestLocale.d.ts.map +0 -1
- package/dist/utilities/getRequestLocale.js +0 -19
- package/dist/utilities/getRequestLocale.js.map +0 -1
- package/dist/utilities/graphqlHandler.server.d.ts.map +0 -1
- package/dist/utilities/graphqlHandler.server.js.map +0 -1
- package/dist/utilities/handleAPIRoute.server.d.ts.map +0 -1
- package/dist/utilities/handleAPIRoute.server.js.map +0 -1
- package/dist/utilities/handleServerFunctions.d.ts.map +0 -1
- package/dist/utilities/handleServerFunctions.js +0 -12
- package/dist/utilities/handleServerFunctions.js.map +0 -1
- package/dist/utilities/initReq.server.d.ts +0 -19
- package/dist/utilities/initReq.server.d.ts.map +0 -1
- package/dist/utilities/initReq.server.js +0 -87
- package/dist/utilities/initReq.server.js.map +0 -1
- package/dist/utilities/loadAdminPage.d.ts.map +0 -1
- package/dist/utilities/loadAdminPage.js.map +0 -1
- package/dist/utilities/loadLayoutData.d.ts +0 -15
- package/dist/utilities/loadLayoutData.d.ts.map +0 -1
- package/dist/utilities/loadLayoutData.js +0 -23
- package/dist/utilities/loadLayoutData.js.map +0 -1
- package/dist/utilities/meta.d.ts.map +0 -1
- package/dist/utilities/meta.js.map +0 -1
- package/dist/utilities/serverAdapter.server.d.ts.map +0 -1
- package/dist/utilities/serverAdapter.server.js.map +0 -1
- /package/dist/{utilities → adapters}/handleServerFunctions.d.ts +0 -0
|
@@ -80,7 +80,7 @@ const STYLE_EXTENSION_RE = /\.(?:s?css|less)$/i;
|
|
|
80
80
|
// there to collect them as client stylesheets. Stripping them here means
|
|
81
81
|
// their CSS is never emitted and the admin renders unstyled (broken nav
|
|
82
82
|
// scroll/layout, etc.). The Node-side `.css` no-op is handled by
|
|
83
|
-
//
|
|
83
|
+
// the test dev server's asset loader and by Vite's CSS extraction (build), so the
|
|
84
84
|
// crash this plugin guards against does not require touching the RSC env.
|
|
85
85
|
if (envName === 'rsc') {
|
|
86
86
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/withPayload/workarounds/stripDistStyleImports.ts"],"sourcesContent":["import type { PluginOption } from 'vite'\n\nconst STYLE_EXTENSION_RE = /\\.(?:s?css|less)$/i\n\n/**\n * Static `import './foo.css'` (or .scss/.less) — top-level only.\n * Captures the entire statement so we can replace it with an empty line.\n *\n * Matches:\n * import './foo.css';\n * import \"../bar.scss\"\n * import './baz.less' ;\n */\nconst STATIC_STYLE_IMPORT_RE = /^[ \\t]*import\\s+['\"][^'\"]+\\.(?:s?css|less)['\"]\\s*(?:;[ \\t]*)?$/gm\n\n/**\n * Monorepo Payload package source, e.g. `…/packages/ui/src/…`. In the\n * core-dev / test setup Payload packages resolve to their workspace `src`\n * (not a published `dist`), so the `dist/` rule below doesn't cover them and\n * their `.css` side-effect imports survive into the SSR/RSC graph.\n */\nconst PAYLOAD_PKG_SRC_RE = /\\/packages\\/[^/]+\\/src\\//\n\n/**\n * The version-diff component trees — matched in either published `dist/` or\n * workspace `src/` form. The `.css` side-effect imports of these must be\n * stripped in the RSC env (the rest of `@payloadcms/ui` must NOT be — see the\n * note in `resolveId`/`transform` below), for two reasons rooted in the same\n * `@vitejs/plugin-rsc` behaviour: it wraps every exported CSS-importing\n * component with an async CSS-collector child\n * (`__vite_rsc_wrap_css__` → `await import('virtual:vite-rsc/css?…')`).\n *\n * 1. Correctness: the diff converters render `CheckIcon` (`icons/*`) and `File`\n * (`graphics/*`) through the SYNCHRONOUS `renderToStaticMarkup` (see\n * `reactDomServerInRsc`). The async wrapper suspends, crashing that render\n * with \"A component suspended while responding to synchronous input\" and\n * taking down the entire field-diffs tree.\n * 2. Performance: the diff view (`views/Version/*` — `RenderFieldsToDiff` and\n * its per-field components, `DiffCollapser`, `SelectComparison`, the\n * `Default` template — plus the `HTMLDiff`/`FieldDiffContainer`/\n * `FieldDiffLabel` elements and lexical's `field/Diff/*`) renders dozens of\n * these wrapped components in the Flight stream. Each async CSS import\n * serializes a round-trip, ballooning the render from ~3s to ~25s and\n * blowing past the e2e waits. Stripping them collapses it back to ~3s.\n *\n * Safe because every one of these components' styles also ship in the global\n * `@payloadcms/ui/css/app.css` the admin imports, so dropping the per-module\n * RSC collection here changes nothing visually (verified: diff + Nav stay\n * styled). The admin `Nav` etc. are deliberately excluded — they rely on the\n * RSC collection and a broad strip leaves them unstyled.\n */\nconst DIFF_VIEW_COMPONENT_RE =\n /@payloadcms\\/ui\\/(?:dist|src)\\/(?:icons|graphics|views\\/Version|elements\\/(?:HTMLDiff|FieldDiffContainer|FieldDiffLabel))\\/|@payloadcms\\/richtext-lexical\\/(?:dist|src)\\/field\\/Diff\\//\n\n/**\n * Stops Vite (and the underlying Node ESM loader) from trying to load\n * SCSS/CSS/LESS during SSR/RSC when the importer lives inside a built\n * `dist/` directory or when the specifier is a bare package name.\n *\n * We do this two ways, because either layer can fail:\n *\n * 1. `resolveId` redirects style specifiers to a virtual empty module —\n * handles cases where Vite asks us to resolve them.\n * 2. `transform` strips top-level `import './x.css'` statements out of any\n * JS/TS file living under `node_modules/.../dist/` for non-client envs.\n * This is the bulletproof path for prod-packed `@payloadcms/ui` (and\n * similar) dependencies that get pre-bundled by Vite's SSR/RSC dep\n * optimizer (esbuild). Esbuild preserves `.css` import statements as-is,\n * and Node's native ESM loader then crashes with\n * `Unknown file extension \".css\"`. Removing them at the source avoids\n * that entirely.\n */\nexport function ssrStripDistStyleImports(): PluginOption {\n return {\n name: 'payload:ssr-strip-dist-style-imports',\n enforce: 'pre',\n load(id) {\n if (id === '\\0ssr-empty-style') {\n return ''\n }\n },\n resolveId(id, importer, options) {\n const envName = (this as any).environment?.name as string | undefined\n const isServerEnv = options?.ssr || (envName && envName !== 'client')\n if (!isServerEnv) {\n return\n }\n // Do NOT strip in the RSC environment. Server components (e.g. the admin\n // `Nav`, a non-'use client' component that `import './index.css'`) render\n // in the RSC graph, and `@vitejs/plugin-rsc` must SEE their `.css` imports\n // there to collect them as client stylesheets. Stripping them here means\n // their CSS is never emitted and the admin renders unstyled (broken nav\n // scroll/layout, etc.). The Node-side `.css` no-op is handled by\n //
|
|
1
|
+
{"version":3,"sources":["../../../src/withPayload/workarounds/stripDistStyleImports.ts"],"sourcesContent":["import type { PluginOption } from 'vite'\n\nconst STYLE_EXTENSION_RE = /\\.(?:s?css|less)$/i\n\n/**\n * Static `import './foo.css'` (or .scss/.less) — top-level only.\n * Captures the entire statement so we can replace it with an empty line.\n *\n * Matches:\n * import './foo.css';\n * import \"../bar.scss\"\n * import './baz.less' ;\n */\nconst STATIC_STYLE_IMPORT_RE = /^[ \\t]*import\\s+['\"][^'\"]+\\.(?:s?css|less)['\"]\\s*(?:;[ \\t]*)?$/gm\n\n/**\n * Monorepo Payload package source, e.g. `…/packages/ui/src/…`. In the\n * core-dev / test setup Payload packages resolve to their workspace `src`\n * (not a published `dist`), so the `dist/` rule below doesn't cover them and\n * their `.css` side-effect imports survive into the SSR/RSC graph.\n */\nconst PAYLOAD_PKG_SRC_RE = /\\/packages\\/[^/]+\\/src\\//\n\n/**\n * The version-diff component trees — matched in either published `dist/` or\n * workspace `src/` form. The `.css` side-effect imports of these must be\n * stripped in the RSC env (the rest of `@payloadcms/ui` must NOT be — see the\n * note in `resolveId`/`transform` below), for two reasons rooted in the same\n * `@vitejs/plugin-rsc` behaviour: it wraps every exported CSS-importing\n * component with an async CSS-collector child\n * (`__vite_rsc_wrap_css__` → `await import('virtual:vite-rsc/css?…')`).\n *\n * 1. Correctness: the diff converters render `CheckIcon` (`icons/*`) and `File`\n * (`graphics/*`) through the SYNCHRONOUS `renderToStaticMarkup` (see\n * `reactDomServerInRsc`). The async wrapper suspends, crashing that render\n * with \"A component suspended while responding to synchronous input\" and\n * taking down the entire field-diffs tree.\n * 2. Performance: the diff view (`views/Version/*` — `RenderFieldsToDiff` and\n * its per-field components, `DiffCollapser`, `SelectComparison`, the\n * `Default` template — plus the `HTMLDiff`/`FieldDiffContainer`/\n * `FieldDiffLabel` elements and lexical's `field/Diff/*`) renders dozens of\n * these wrapped components in the Flight stream. Each async CSS import\n * serializes a round-trip, ballooning the render from ~3s to ~25s and\n * blowing past the e2e waits. Stripping them collapses it back to ~3s.\n *\n * Safe because every one of these components' styles also ship in the global\n * `@payloadcms/ui/css/app.css` the admin imports, so dropping the per-module\n * RSC collection here changes nothing visually (verified: diff + Nav stay\n * styled). The admin `Nav` etc. are deliberately excluded — they rely on the\n * RSC collection and a broad strip leaves them unstyled.\n */\nconst DIFF_VIEW_COMPONENT_RE =\n /@payloadcms\\/ui\\/(?:dist|src)\\/(?:icons|graphics|views\\/Version|elements\\/(?:HTMLDiff|FieldDiffContainer|FieldDiffLabel))\\/|@payloadcms\\/richtext-lexical\\/(?:dist|src)\\/field\\/Diff\\//\n\n/**\n * Stops Vite (and the underlying Node ESM loader) from trying to load\n * SCSS/CSS/LESS during SSR/RSC when the importer lives inside a built\n * `dist/` directory or when the specifier is a bare package name.\n *\n * We do this two ways, because either layer can fail:\n *\n * 1. `resolveId` redirects style specifiers to a virtual empty module —\n * handles cases where Vite asks us to resolve them.\n * 2. `transform` strips top-level `import './x.css'` statements out of any\n * JS/TS file living under `node_modules/.../dist/` for non-client envs.\n * This is the bulletproof path for prod-packed `@payloadcms/ui` (and\n * similar) dependencies that get pre-bundled by Vite's SSR/RSC dep\n * optimizer (esbuild). Esbuild preserves `.css` import statements as-is,\n * and Node's native ESM loader then crashes with\n * `Unknown file extension \".css\"`. Removing them at the source avoids\n * that entirely.\n */\nexport function ssrStripDistStyleImports(): PluginOption {\n return {\n name: 'payload:ssr-strip-dist-style-imports',\n enforce: 'pre',\n load(id) {\n if (id === '\\0ssr-empty-style') {\n return ''\n }\n },\n resolveId(id, importer, options) {\n const envName = (this as any).environment?.name as string | undefined\n const isServerEnv = options?.ssr || (envName && envName !== 'client')\n if (!isServerEnv) {\n return\n }\n // Do NOT strip in the RSC environment. Server components (e.g. the admin\n // `Nav`, a non-'use client' component that `import './index.css'`) render\n // in the RSC graph, and `@vitejs/plugin-rsc` must SEE their `.css` imports\n // there to collect them as client stylesheets. Stripping them here means\n // their CSS is never emitted and the admin renders unstyled (broken nav\n // scroll/layout, etc.). The Node-side `.css` no-op is handled by\n // the test dev server's asset loader and by Vite's CSS extraction (build), so the\n // crash this plugin guards against does not require touching the RSC env.\n if (envName === 'rsc') {\n return\n }\n if (!STYLE_EXTENSION_RE.test(id)) {\n return\n }\n if (importer && (/\\/dist\\//.test(importer) || PAYLOAD_PKG_SRC_RE.test(importer))) {\n return '\\0ssr-empty-style'\n }\n if (/^@?[a-z]/.test(id) && !id.startsWith('.') && !id.startsWith('/')) {\n return '\\0ssr-empty-style'\n }\n },\n transform(code, id) {\n const envName = (this as any).environment?.name as string | undefined\n const isServerEnv = envName && envName !== 'client'\n if (!isServerEnv) {\n return\n }\n // In the RSC env, only strip from the version-diff component trees (see\n // `DIFF_VIEW_COMPONENT_RE`). Every other server component (the admin\n // `Nav`, etc.) must keep its `.css` import so plugin-rsc can collect it —\n // see the matching note in `resolveId` above.\n if (envName === 'rsc' && !DIFF_VIEW_COMPONENT_RE.test(id)) {\n return\n }\n // Only touch Payload dependency files: published `node_modules/.../dist/`\n // builds, or workspace `…/packages/<pkg>/src/…` sources in the core-dev /\n // test setup. Don't strip from the consumer's own app source — devs may\n // legitimately want SSR-rendered <link>s from their own CSS imports.\n const isPayloadDistFile = /\\/node_modules\\//.test(id) && /\\/dist\\//.test(id)\n const isPayloadSrcFile = PAYLOAD_PKG_SRC_RE.test(id)\n if (!isPayloadDistFile && !isPayloadSrcFile) {\n return\n }\n // Allow a trailing query (`?v=…`, `?t=…`): Vite appends version/timestamp\n // queries to module ids, especially in the RSC graph, so a strict `$`\n // anchor would skip e.g. `icons/Check/index.js?v=83de8543`.\n if (!/\\.[mc]?[jt]sx?(?:$|\\?)/.test(id)) {\n return\n }\n if (!STATIC_STYLE_IMPORT_RE.test(code)) {\n STATIC_STYLE_IMPORT_RE.lastIndex = 0\n return\n }\n STATIC_STYLE_IMPORT_RE.lastIndex = 0\n const stripped = code.replace(STATIC_STYLE_IMPORT_RE, '')\n return { code: stripped, map: null }\n },\n }\n}\n"],"names":["STYLE_EXTENSION_RE","STATIC_STYLE_IMPORT_RE","PAYLOAD_PKG_SRC_RE","DIFF_VIEW_COMPONENT_RE","ssrStripDistStyleImports","name","enforce","load","id","resolveId","importer","options","envName","environment","isServerEnv","ssr","test","startsWith","transform","code","isPayloadDistFile","isPayloadSrcFile","lastIndex","stripped","replace","map"],"mappings":"AAEA,MAAMA,qBAAqB;AAE3B;;;;;;;;CAQC,GACD,MAAMC,yBAAy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MAAMY,oBAAoB,mBAAmBJ,IAAI,CAACR,OAAO,WAAWQ,IAAI,CAACR;YACzE,MAAMa,mBAAmBnB,mBAAmBc,IAAI,CAACR;YACjD,IAAI,CAACY,qBAAqB,CAACC,kBAAkB;gBAC3C;YACF;YACA,0EAA0E;YAC1E,sEAAsE;YACtE,4DAA4D;YAC5D,IAAI,CAAC,yBAAyBL,IAAI,CAACR,KAAK;gBACtC;YACF;YACA,IAAI,CAACP,uBAAuBe,IAAI,CAACG,OAAO;gBACtClB,uBAAuBqB,SAAS,GAAG;gBACnC;YACF;YACArB,uBAAuBqB,SAAS,GAAG;YACnC,MAAMC,WAAWJ,KAAKK,OAAO,CAACvB,wBAAwB;YACtD,OAAO;gBAAEkB,MAAMI;gBAAUE,KAAK;YAAK;QACrC;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/tanstack-start",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.8001944",
|
|
4
4
|
"description": "TanStack Start framework adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"qs-esm": "^7.0.2",
|
|
61
|
-
"@payloadcms/translations": "4.0.0-internal.
|
|
62
|
-
"@payloadcms/ui": "4.0.0-internal.
|
|
61
|
+
"@payloadcms/translations": "4.0.0-internal.8001944",
|
|
62
|
+
"@payloadcms/ui": "4.0.0-internal.8001944"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@tanstack/react-router": "^1.120.0",
|
|
@@ -68,10 +68,10 @@
|
|
|
68
68
|
"@types/react-dom": "^19.0.0",
|
|
69
69
|
"@vitejs/plugin-react": "^6.0.0",
|
|
70
70
|
"@vitejs/plugin-rsc": "^0.5.21",
|
|
71
|
-
"react": "
|
|
72
|
-
"react-dom": "
|
|
71
|
+
"react": "19.3.0",
|
|
72
|
+
"react-dom": "19.3.0",
|
|
73
73
|
"vite": ">=8.0.0",
|
|
74
|
-
"payload": "4.0.0-internal.
|
|
74
|
+
"payload": "4.0.0-internal.8001944"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"@tanstack/react-router": "^1.120.0",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"react": "^19.0.0",
|
|
82
82
|
"react-dom": "^19.0.0",
|
|
83
83
|
"vite": ">=8.0.0",
|
|
84
|
-
"payload": "4.0.0-internal.
|
|
84
|
+
"payload": "4.0.0-internal.8001944"
|
|
85
85
|
},
|
|
86
86
|
"peerDependenciesMeta": {
|
|
87
87
|
"@vitejs/plugin-react": {
|
|
@@ -98,14 +98,14 @@
|
|
|
98
98
|
"node": "^18.20.2 || >=20.9.0"
|
|
99
99
|
},
|
|
100
100
|
"scripts": {
|
|
101
|
-
"build": "pnpm build:types && pnpm
|
|
101
|
+
"build": "pnpm build:types && pnpm test:types && pnpm build:swc",
|
|
102
102
|
"build:clean": "find . \\( -type d \\( -name build -o -name dist -o -name .cache \\) -o -type f -name tsconfig.tsbuildinfo \\) -exec rm -rf {} + && pnpm build",
|
|
103
|
-
"build:copy-mjs": "node ./scripts/copyMjs.mjs",
|
|
104
103
|
"build:debug": "pnpm build",
|
|
105
104
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
106
105
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
107
106
|
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
108
107
|
"lint": "eslint .",
|
|
109
|
-
"lint:fix": "eslint . --fix"
|
|
108
|
+
"lint:fix": "eslint . --fix",
|
|
109
|
+
"test:types": "tsc --project test/tsconfig.json"
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/RouterAdapter/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAoB,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAuDvE,eAAO,MAAM,qBAAqB,EAAE,sBAyGnC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/elements/RouterAdapter/index.tsx"],"sourcesContent":["'use client'\n\nimport type { RouterAdapterContextValue } from '@payloadcms/ui'\nimport type { LinkAdapterProps, RouterAdapterComponent } from 'payload'\n\nimport { RouterAdapterContext } from '@payloadcms/ui'\nimport { Link as TanStackLink, useLocation, useParams, useRouter } from '@tanstack/react-router'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useMemo } from 'react'\n\nconst normalizeNavigationTarget = ({\n path,\n pathname,\n search,\n}: {\n path: string\n pathname: string\n search: string\n}) => {\n if (path.startsWith('http')) {\n const url = new URL(path)\n return `${url.pathname}${url.search}${url.hash}`\n }\n\n if (path.startsWith('?')) {\n return `${pathname}${path}`\n }\n\n if (path.startsWith('#')) {\n return `${pathname}${search}${path}`\n }\n\n return path\n}\n\nconst TanStackLinkAdapter: React.FC<LinkAdapterProps> = ({\n children,\n href,\n prefetch,\n ref,\n replace,\n scroll,\n ...rest\n}) => {\n return (\n <TanStackLink\n preload={prefetch === false ? false : 'intent'}\n ref={ref}\n replace={replace}\n resetScroll={scroll}\n to={href}\n {...rest}\n >\n {children}\n </TanStackLink>\n )\n}\n\nexport const TanStackRouterAdapter: RouterAdapterComponent = ({ children }) => {\n const router = useRouter()\n const location = useLocation()\n const params = useParams({ strict: false })\n\n const adaptedParams = useMemo(() => {\n const adapted: Record<string, string | string[]> = { ...params }\n\n if ('_splat' in params && typeof params._splat === 'string') {\n adapted.segments = params._splat.split('/').filter(Boolean)\n }\n\n return adapted\n }, [params])\n\n // Split a target into `to` (pathname) + a parsed `search` object, so the\n // router serializes the query via its `stringifySearch` (qs, bracket-encoded)\n // rather than embedding the raw string in `to`. Navigating with a string `to`\n // leaves the search *unencoded* in `window.location.search`\n // (e.g. `where[or][0]…`), which then never matches Payload's `qs.stringify`\n // output (`where%5Bor%5D…`) — breaking the list-view `syncPropsToURL` guard,\n // which compares the two and would otherwise clobber optimistic query state\n // (e.g. an in-progress filter condition) on every navigation.\n const toNavOptions = useCallback((path: string) => {\n const relativePath = normalizeNavigationTarget({\n path,\n pathname: window.location.pathname,\n search: window.location.search,\n })\n\n const queryIndex = relativePath.indexOf('?')\n\n if (queryIndex === -1) {\n return { to: relativePath }\n }\n\n const searchObject = qs.parse(relativePath.slice(queryIndex + 1), {\n depth: 10,\n ignoreQueryPrefix: true,\n })\n\n // Function form replaces the search entirely (no merge with current search).\n return { search: () => searchObject, to: relativePath.slice(0, queryIndex) }\n }, [])\n\n const back = useCallback(() => router.history.back(), [router])\n\n const push = useCallback(\n (path: string, options?: { scroll?: boolean }) => {\n void router.navigate({ ...toNavOptions(path), resetScroll: options?.scroll })\n },\n [router, toNavOptions],\n )\n\n const refresh = useCallback(() => {\n void router.invalidate()\n }, [router])\n\n const replace = useCallback(\n (path: string, options?: { scroll?: boolean }) => {\n void router.navigate({ ...toNavOptions(path), replace: true, resetScroll: options?.scroll })\n },\n [router, toNavOptions],\n )\n\n // Mirror Next.js' router behavior to allow syncing client state to the URL without triggering a second server load.\n // TanStack's browser history monkeypatches `window.history.replaceState` and notifies `router.load` on every call.\n // Use `_ignoreSubscribers` to suppresses that notification — the same flag TanStack uses internally when flushing history.\n const replaceState = useCallback(\n (url: string) => {\n const { history } = router\n history._ignoreSubscribers = true\n\n try {\n window.history.replaceState(null, '', url)\n } finally {\n history._ignoreSubscribers = false\n }\n },\n [router],\n )\n\n const adaptedRouter = useMemo(\n () => ({ back, push, refresh, replace, replaceState }),\n [back, push, refresh, replace, replaceState],\n )\n\n // `location.searchStr` is the serialized query string; `location.search` is\n // the parsed object (a nested structure once the router uses `qs` for search\n // serialization), which `URLSearchParams` cannot consume. Build from the\n // string so Payload's `parseSearchParams` re-parses the bracket notation.\n const searchParams = useMemo(() => new URLSearchParams(location.searchStr), [location.searchStr])\n\n const value: RouterAdapterContextValue = useMemo(\n () => ({\n Link: TanStackLinkAdapter,\n params: adaptedParams,\n pathname: location.pathname,\n router: adaptedRouter,\n searchParams,\n }),\n [adaptedParams, location.pathname, adaptedRouter, searchParams],\n )\n\n return <RouterAdapterContext value={value}>{children}</RouterAdapterContext>\n}\n"],"names":["RouterAdapterContext","Link","TanStackLink","useLocation","useParams","useRouter","qs","React","useCallback","useMemo","normalizeNavigationTarget","path","pathname","search","startsWith","url","URL","hash","TanStackLinkAdapter","children","href","prefetch","ref","replace","scroll","rest","preload","resetScroll","to","TanStackRouterAdapter","router","location","params","strict","adaptedParams","adapted","_splat","segments","split","filter","Boolean","toNavOptions","relativePath","window","queryIndex","indexOf","searchObject","parse","slice","depth","ignoreQueryPrefix","back","history","push","options","navigate","refresh","invalidate","replaceState","_ignoreSubscribers","adaptedRouter","searchParams","URLSearchParams","searchStr","value"],"mappings":"AAAA;;AAKA,SAASA,oBAAoB,QAAQ,iBAAgB;AACrD,SAASC,QAAQC,YAAY,EAAEC,WAAW,EAAEC,SAAS,EAAEC,SAAS,QAAQ,yBAAwB;AAChG,YAAYC,QAAQ,SAAQ;AAC5B,OAAOC,SAASC,WAAW,EAAEC,OAAO,QAAQ,QAAO;AAEnD,MAAMC,4BAA4B,CAAC,EACjCC,IAAI,EACJC,QAAQ,EACRC,MAAM,EAKP;IACC,IAAIF,KAAKG,UAAU,CAAC,SAAS;QAC3B,MAAMC,MAAM,IAAIC,IAAIL;QACpB,OAAO,GAAGI,IAAIH,QAAQ,GAAGG,IAAIF,MAAM,GAAGE,IAAIE,IAAI,EAAE;IAClD;IAEA,IAAIN,KAAKG,UAAU,CAAC,MAAM;QACxB,OAAO,GAAGF,WAAWD,MAAM;IAC7B;IAEA,IAAIA,KAAKG,UAAU,CAAC,MAAM;QACxB,OAAO,GAAGF,WAAWC,SAASF,MAAM;IACtC;IAEA,OAAOA;AACT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QE;YACRtB,UAAUmB,SAASnB,QAAQ;YAC3BkB,QAAQ8B;YACRC;QACF,CAAA,GACA;QAAC3B;QAAeH,SAASnB,QAAQ;QAAEgD;QAAeC;KAAa;IAGjE,qBAAO,KAAC7D;QAAqBgE,OAAOA;kBAAQ7C;;AAC9C,EAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
-
import type { Theme } from '@payloadcms/ui';
|
|
3
|
-
import type { ClientConfig, ImportMap, LanguageOptions, SanitizedConfig, SanitizedPermissions, User } from 'payload';
|
|
4
|
-
export type RootLayoutData = {
|
|
5
|
-
clientConfig: ClientConfig;
|
|
6
|
-
dateFNSKey: I18nClient['dateFNSKey'];
|
|
7
|
-
fallbackLang: string;
|
|
8
|
-
isEmbedded: boolean;
|
|
9
|
-
isNavOpen: boolean;
|
|
10
|
-
languageCode: string;
|
|
11
|
-
languageOptions: LanguageOptions;
|
|
12
|
-
locale?: string;
|
|
13
|
-
permissions: SanitizedPermissions;
|
|
14
|
-
/**
|
|
15
|
-
* Custom admin provider tree (`config.admin.components.providers`) nested
|
|
16
|
-
* around the router `<Outlet />`. Built unrendered by `getLayoutData`; the
|
|
17
|
-
* layout server function renders it to an RSC payload before it reaches the
|
|
18
|
-
* client. `undefined` when no custom providers are configured.
|
|
19
|
-
*/
|
|
20
|
-
providers?: React.ReactNode;
|
|
21
|
-
theme: Theme;
|
|
22
|
-
translations: I18nClient['translations'];
|
|
23
|
-
user: null | User;
|
|
24
|
-
};
|
|
25
|
-
export type GetLayoutDataArgs = {
|
|
26
|
-
configPromise: Promise<SanitizedConfig> | SanitizedConfig;
|
|
27
|
-
importMap: ImportMap;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Fetches all data needed by the root admin layout.
|
|
31
|
-
* Call this in your TanStack Start root route loader.
|
|
32
|
-
*/
|
|
33
|
-
export declare function getLayoutData({ configPromise, importMap, }: GetLayoutDataArgs): Promise<RootLayoutData>;
|
|
34
|
-
//# sourceMappingURL=getLayoutData.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLayoutData.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/getLayoutData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,eAAe,EACf,eAAe,EACf,oBAAoB,EAEpB,IAAI,EACL,MAAM,SAAS,CAAA;AAahB,MAAM,MAAM,cAAc,GAAG;IAC3B,YAAY,EAAE,YAAY,CAAA;IAC1B,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,CAAA;IACpC,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,OAAO,CAAA;IACnB,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,eAAe,CAAA;IAChC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,oBAAoB,CAAA;IACjC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC3B,KAAK,EAAE,KAAK,CAAA;IACZ,YAAY,EAAE,UAAU,CAAC,cAAc,CAAC,CAAA;IACxC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,aAAa,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IACzD,SAAS,EAAE,SAAS,CAAA;CACrB,CAAA;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,EAClC,aAAa,EACb,SAAS,GACV,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAwF7C"}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { getNavPrefs } from '@payloadcms/ui/elements/Nav/getNavPrefs';
|
|
2
|
-
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
3
|
-
import { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig';
|
|
4
|
-
import { getRequestEmbed } from '@payloadcms/ui/utilities/getRequestEmbed';
|
|
5
|
-
import { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme';
|
|
6
|
-
import { Outlet } from '@tanstack/react-router';
|
|
7
|
-
import { applyLocaleFiltering } from 'payload/shared';
|
|
8
|
-
import { createElement } from 'react';
|
|
9
|
-
import { initReq } from '../../utilities/initReq.server.js';
|
|
10
|
-
/**
|
|
11
|
-
* Fetches all data needed by the root admin layout.
|
|
12
|
-
* Call this in your TanStack Start root route loader.
|
|
13
|
-
*/ export async function getLayoutData({ configPromise, importMap }) {
|
|
14
|
-
const { cookies, headers, languageCode, permissions, req, req: { payload: { config } } } = await initReq({
|
|
15
|
-
configPromise,
|
|
16
|
-
importMap
|
|
17
|
-
});
|
|
18
|
-
const theme = getRequestTheme({
|
|
19
|
-
config,
|
|
20
|
-
cookies,
|
|
21
|
-
headers
|
|
22
|
-
});
|
|
23
|
-
const isEmbedded = getRequestEmbed({
|
|
24
|
-
config,
|
|
25
|
-
cookies
|
|
26
|
-
});
|
|
27
|
-
const languageOptions = Object.entries(config.i18n.supportedLanguages || {}).reduce((acc, [language, languageConfig])=>{
|
|
28
|
-
if (Object.keys(config.i18n.supportedLanguages).includes(language)) {
|
|
29
|
-
acc.push({
|
|
30
|
-
label: languageConfig.translations.general.thisLanguage,
|
|
31
|
-
value: language
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return acc;
|
|
35
|
-
}, []);
|
|
36
|
-
const navPrefs = await getNavPrefs(req);
|
|
37
|
-
const clientConfig = getClientConfig({
|
|
38
|
-
config,
|
|
39
|
-
i18n: req.i18n,
|
|
40
|
-
importMap,
|
|
41
|
-
user: req.user ?? true
|
|
42
|
-
});
|
|
43
|
-
await applyLocaleFiltering({
|
|
44
|
-
clientConfig,
|
|
45
|
-
config,
|
|
46
|
-
req
|
|
47
|
-
});
|
|
48
|
-
// Build the custom admin provider tree (`config.admin.components.providers`)
|
|
49
|
-
// nested around the router `<Outlet />`, mirroring the Next adapter's
|
|
50
|
-
// `NestProviders`. Returned as an unrendered element; the caller's server
|
|
51
|
-
// function renders it to an RSC payload (so server-component providers run
|
|
52
|
-
// server-side and client providers wrap the live Outlet). `undefined` when
|
|
53
|
-
// no custom providers are configured — the caller falls back to `<Outlet />`.
|
|
54
|
-
const providerPaths = config.admin?.components?.providers;
|
|
55
|
-
let providers = undefined;
|
|
56
|
-
if (Array.isArray(providerPaths) && providerPaths.length > 0) {
|
|
57
|
-
const serverProps = {
|
|
58
|
-
i18n: req.i18n,
|
|
59
|
-
params: {},
|
|
60
|
-
payload: req.payload,
|
|
61
|
-
permissions,
|
|
62
|
-
searchParams: {},
|
|
63
|
-
server: req.server,
|
|
64
|
-
user: req.user ?? undefined
|
|
65
|
-
};
|
|
66
|
-
// Mirror the Next adapter's `NestProviders`: render each configured provider
|
|
67
|
-
// via `RenderServerComponent` so the entry's own `clientProps`/`serverProps`
|
|
68
|
-
// (e.g. plugin-multi-tenant's `userHasAccessToAllTenants`) are merged in, and
|
|
69
|
-
// server components receive `serverProps` while client components get only
|
|
70
|
-
// `clientProps`. Nested around the router `<Outlet />` instead of `children`.
|
|
71
|
-
providers = providerPaths.reduceRight((children, provider)=>RenderServerComponent({
|
|
72
|
-
clientProps: {
|
|
73
|
-
children
|
|
74
|
-
},
|
|
75
|
-
Component: provider,
|
|
76
|
-
importMap,
|
|
77
|
-
serverProps
|
|
78
|
-
}), createElement(Outlet));
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
clientConfig,
|
|
82
|
-
dateFNSKey: req.i18n.dateFNSKey,
|
|
83
|
-
fallbackLang: config.i18n.fallbackLanguage,
|
|
84
|
-
isEmbedded,
|
|
85
|
-
isNavOpen: navPrefs?.open ?? true,
|
|
86
|
-
languageCode,
|
|
87
|
-
languageOptions,
|
|
88
|
-
locale: req.locale ?? undefined,
|
|
89
|
-
permissions,
|
|
90
|
-
providers,
|
|
91
|
-
theme,
|
|
92
|
-
translations: req.i18n.translations,
|
|
93
|
-
user: req.user
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
//# sourceMappingURL=getLayoutData.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layouts/Root/getLayoutData.ts"],"sourcesContent":["import type { AcceptedLanguages, I18nClient } from '@payloadcms/translations'\nimport type { Theme } from '@payloadcms/ui'\nimport type {\n ClientConfig,\n ImportMap,\n LanguageOptions,\n SanitizedConfig,\n SanitizedPermissions,\n ServerProps,\n User,\n} from 'payload'\n\nimport { getNavPrefs } from '@payloadcms/ui/elements/Nav/getNavPrefs'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { getRequestEmbed } from '@payloadcms/ui/utilities/getRequestEmbed'\nimport { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme'\nimport { Outlet } from '@tanstack/react-router'\nimport { applyLocaleFiltering } from 'payload/shared'\nimport { createElement } from 'react'\n\nimport { initReq } from '../../utilities/initReq.server.js'\n\nexport type RootLayoutData = {\n clientConfig: ClientConfig\n dateFNSKey: I18nClient['dateFNSKey']\n fallbackLang: string\n isEmbedded: boolean\n isNavOpen: boolean\n languageCode: string\n languageOptions: LanguageOptions\n locale?: string\n permissions: SanitizedPermissions\n /**\n * Custom admin provider tree (`config.admin.components.providers`) nested\n * around the router `<Outlet />`. Built unrendered by `getLayoutData`; the\n * layout server function renders it to an RSC payload before it reaches the\n * client. `undefined` when no custom providers are configured.\n */\n providers?: React.ReactNode\n theme: Theme\n translations: I18nClient['translations']\n user: null | User\n}\n\nexport type GetLayoutDataArgs = {\n configPromise: Promise<SanitizedConfig> | SanitizedConfig\n importMap: ImportMap\n}\n\n/**\n * Fetches all data needed by the root admin layout.\n * Call this in your TanStack Start root route loader.\n */\nexport async function getLayoutData({\n configPromise,\n importMap,\n}: GetLayoutDataArgs): Promise<RootLayoutData> {\n const {\n cookies,\n headers,\n languageCode,\n permissions,\n req,\n req: {\n payload: { config },\n },\n } = await initReq({ configPromise, importMap })\n\n const theme = getRequestTheme({ config, cookies, headers })\n const isEmbedded = getRequestEmbed({ config, cookies })\n\n const languageOptions: LanguageOptions = Object.entries(\n config.i18n.supportedLanguages || {},\n ).reduce((acc, [language, languageConfig]) => {\n if (Object.keys(config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language as AcceptedLanguages,\n })\n }\n return acc\n }, [] as LanguageOptions)\n\n const navPrefs = await getNavPrefs(req)\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n user: req.user ?? true,\n })\n\n await applyLocaleFiltering({ clientConfig, config, req })\n\n // Build the custom admin provider tree (`config.admin.components.providers`)\n // nested around the router `<Outlet />`, mirroring the Next adapter's\n // `NestProviders`. Returned as an unrendered element; the caller's server\n // function renders it to an RSC payload (so server-component providers run\n // server-side and client providers wrap the live Outlet). `undefined` when\n // no custom providers are configured — the caller falls back to `<Outlet />`.\n const providerPaths = config.admin?.components?.providers\n let providers: React.ReactNode = undefined\n if (Array.isArray(providerPaths) && providerPaths.length > 0) {\n const serverProps: ServerProps = {\n i18n: req.i18n,\n params: {},\n payload: req.payload,\n permissions,\n searchParams: {},\n server: req.server!,\n user: req.user ?? undefined,\n }\n // Mirror the Next adapter's `NestProviders`: render each configured provider\n // via `RenderServerComponent` so the entry's own `clientProps`/`serverProps`\n // (e.g. plugin-multi-tenant's `userHasAccessToAllTenants`) are merged in, and\n // server components receive `serverProps` while client components get only\n // `clientProps`. Nested around the router `<Outlet />` instead of `children`.\n providers = providerPaths.reduceRight<React.ReactNode>(\n (children, provider) =>\n RenderServerComponent({\n clientProps: { children },\n Component: provider,\n importMap,\n serverProps,\n }),\n createElement(Outlet),\n )\n }\n\n return {\n clientConfig,\n dateFNSKey: req.i18n.dateFNSKey,\n fallbackLang: config.i18n.fallbackLanguage,\n isEmbedded,\n isNavOpen: navPrefs?.open ?? true,\n languageCode,\n languageOptions,\n locale: req.locale ?? undefined,\n permissions,\n providers,\n theme,\n translations: req.i18n.translations,\n user: req.user,\n }\n}\n"],"names":["getNavPrefs","RenderServerComponent","getClientConfig","getRequestEmbed","getRequestTheme","Outlet","applyLocaleFiltering","createElement","initReq","getLayoutData","configPromise","importMap","cookies","headers","languageCode","permissions","req","payload","config","theme","isEmbedded","languageOptions","Object","entries","i18n","supportedLanguages","reduce","acc","language","languageConfig","keys","includes","push","label","translations","general","thisLanguage","value","navPrefs","clientConfig","user","providerPaths","admin","components","providers","undefined","Array","isArray","length","serverProps","params","searchParams","server","reduceRight","children","provider","clientProps","Component","dateFNSKey","fallbackLang","fallbackLanguage","isNavOpen","open","locale"],"mappings":"AAYA,SAASA,WAAW,QAAQ,0CAAyC;AACrE,SAASC,qBAAqB,QAAQ,gDAA+C;AACrF,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,MAAM,QAAQ,yBAAwB;AAC/C,SAASC,oBAAoB,QAAQ,iBAAgB;AACrD,SAASC,aAAa,QAAQ,QAAO;AAErC,SAASC,OAAO,QAAQ,oCAAmC;AA6B3D;;;CAGC,GACD,OAAO,eAAeC,cAAc,EAClCC,aAAa,EACbC,SAAS,EACS;IAClB,MAAM,EACJC,OAAO,EACPC,OAAO,EACPC,YAAY,EACZC,WAAW,EACXC,GAAG,EACHA,KAAK,EACHC,SAAS,EAAEC,MAAM,EAAE,EACpB,EACF,GAAG,MAAMV,QAAQ;QAAEE;QAAeC;IAAU;IAE7C,MAAMQ,QAAQf,gBAAgB;QAAEc;QAAQN;QAASC;IAAQ;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;gBACX5C;gBACAsC;YACF,IACF1C,cAAcF;IAElB;IAEA,OAAO;QACLkC;QACAmB,YAAY1C,IAAIQ,IAAI,CAACkC,UAAU;QAC/BC,cAAczC,OAAOM,IAAI,CAACoC,gBAAgB;QAC1CxC;QACAyC,WAAWvB,UAAUwB,QAAQ;QAC7BhD;QACAO;QACA0C,QAAQ/C,IAAI+C,MAAM,IAAIlB;QACtB9B;QACA6B;QACAzB;QACAe,cAAclB,IAAIQ,IAAI,CAACU,YAAY;QACnCM,MAAMxB,IAAIwB,IAAI;IAChB;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withPayloadRoot.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/withPayloadRoot.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CACnC,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE,sBAAsB,qBAmCrE;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC,EAC7D,OAAO,GAAE,sBAA2B,kBAIW;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,uBAc7E"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { getLanguageDir } from '@payloadcms/ui/utilities/getLanguageDir';
|
|
4
|
-
import { HeadContent, Scripts, useRouterState } from '@tanstack/react-router';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
/**
|
|
7
|
-
* The `<html>` document shell for Payload admin routes — the TanStack Start
|
|
8
|
-
* equivalent of `@payloadcms/next`'s root layout `<html>`. Sets
|
|
9
|
-
* `data-theme`/`lang`/`dir` on `<html>` from the server-computed layout data
|
|
10
|
-
* (`getLayoutData`, exposed on the `/_payload` route loader), so the admin
|
|
11
|
-
* panel renders themed with the correct text direction on the first paint with no
|
|
12
|
-
* client bootstrap script — the same server-side path Next's `RootLayout`
|
|
13
|
-
* uses, sharing `getRequestTheme`/`getLanguageDir` from `@payloadcms/ui`.
|
|
14
|
-
*/ export function PayloadAdminShell({ children }) {
|
|
15
|
-
const htmlProps = useRouterState({
|
|
16
|
-
select: (state)=>{
|
|
17
|
-
for (const match of state.matches){
|
|
18
|
-
const data = match.loaderData;
|
|
19
|
-
if (data?.theme && data?.languageCode) {
|
|
20
|
-
return {
|
|
21
|
-
'data-theme': data.theme,
|
|
22
|
-
dir: getLanguageDir({
|
|
23
|
-
languageCode: data.languageCode
|
|
24
|
-
}),
|
|
25
|
-
lang: data.languageCode
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
// No layout data yet (fresh session before the loader resolves): default
|
|
30
|
-
// to `ltr` so the `[dir='ltr']`-scoped admin layout rules (e.g. the
|
|
31
|
-
// document sidebar divider) still match, matching Next's `ltr` default.
|
|
32
|
-
return {
|
|
33
|
-
dir: 'ltr'
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
return(// eslint-disable-next-line jsx-a11y/html-has-lang -- `lang` is set from server-computed layout data when available
|
|
38
|
-
/*#__PURE__*/ _jsxs("html", {
|
|
39
|
-
...htmlProps,
|
|
40
|
-
suppressHydrationWarning: true,
|
|
41
|
-
children: [
|
|
42
|
-
/*#__PURE__*/ _jsxs("head", {
|
|
43
|
-
children: [
|
|
44
|
-
/*#__PURE__*/ _jsx("style", {
|
|
45
|
-
children: `@layer payload-default, payload;`
|
|
46
|
-
}),
|
|
47
|
-
/*#__PURE__*/ _jsx(HeadContent, {})
|
|
48
|
-
]
|
|
49
|
-
}),
|
|
50
|
-
/*#__PURE__*/ _jsxs("body", {
|
|
51
|
-
children: [
|
|
52
|
-
children,
|
|
53
|
-
/*#__PURE__*/ _jsx(Scripts, {})
|
|
54
|
-
]
|
|
55
|
-
})
|
|
56
|
-
]
|
|
57
|
-
}));
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Wraps your application's root document shell so Payload owns its own
|
|
61
|
-
* `<html>` chrome on admin routes while your shell renders everywhere else.
|
|
62
|
-
*
|
|
63
|
-
* Attach the result to the root route's `shellComponent`; it is the single
|
|
64
|
-
* integration touch point — no root loader and no manual data threading:
|
|
65
|
-
*
|
|
66
|
-
* ```tsx
|
|
67
|
-
* export const Route = createRootRoute({
|
|
68
|
-
* shellComponent: withPayloadRoot(MarketingRoot),
|
|
69
|
-
* })
|
|
70
|
-
* ```
|
|
71
|
-
*/ export function withPayloadRoot(RootShell, options = {}) {
|
|
72
|
-
const { adminRoute = '/admin' } = options;
|
|
73
|
-
return function PayloadRootShell({ children }) {
|
|
74
|
-
const isAdminRoute = useRouterState({
|
|
75
|
-
select: (s)=>{
|
|
76
|
-
const { pathname } = s.location;
|
|
77
|
-
return pathname === adminRoute || pathname.startsWith(`${adminRoute}/`);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
if (isAdminRoute) {
|
|
81
|
-
return /*#__PURE__*/ _jsx(PayloadAdminShell, {
|
|
82
|
-
children: children
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
return /*#__PURE__*/ _jsx(RootShell, {
|
|
86
|
-
children: children
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
//# sourceMappingURL=withPayloadRoot.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layouts/Root/withPayloadRoot.tsx"],"sourcesContent":["'use client'\nimport type { Theme } from '@payloadcms/ui'\n\nimport { getLanguageDir } from '@payloadcms/ui/utilities/getLanguageDir'\nimport { HeadContent, Scripts, useRouterState } from '@tanstack/react-router'\nimport React from 'react'\n\ntype AdminHTMLProps = {\n 'data-theme'?: Theme\n dir: 'ltr' | 'rtl'\n lang?: string\n}\n\nexport type PayloadAdminShellProps = {\n readonly children: React.ReactNode\n}\n\n/**\n * The `<html>` document shell for Payload admin routes — the TanStack Start\n * equivalent of `@payloadcms/next`'s root layout `<html>`. Sets\n * `data-theme`/`lang`/`dir` on `<html>` from the server-computed layout data\n * (`getLayoutData`, exposed on the `/_payload` route loader), so the admin\n * panel renders themed with the correct text direction on the first paint with no\n * client bootstrap script — the same server-side path Next's `RootLayout`\n * uses, sharing `getRequestTheme`/`getLanguageDir` from `@payloadcms/ui`.\n */\nexport function PayloadAdminShell({ children }: PayloadAdminShellProps) {\n const htmlProps = useRouterState({\n select: (state): AdminHTMLProps => {\n for (const match of state.matches) {\n const data = match.loaderData as { languageCode?: string; theme?: Theme } | undefined\n\n if (data?.theme && data?.languageCode) {\n return {\n 'data-theme': data.theme,\n dir: getLanguageDir({ languageCode: data.languageCode }),\n lang: data.languageCode,\n }\n }\n }\n\n // No layout data yet (fresh session before the loader resolves): default\n // to `ltr` so the `[dir='ltr']`-scoped admin layout rules (e.g. the\n // document sidebar divider) still match, matching Next's `ltr` default.\n return { dir: 'ltr' }\n },\n })\n\n return (\n // eslint-disable-next-line jsx-a11y/html-has-lang -- `lang` is set from server-computed layout data when available\n <html {...htmlProps} suppressHydrationWarning>\n <head>\n <style>{`@layer payload-default, payload;`}</style>\n <HeadContent />\n </head>\n <body>\n {children}\n <Scripts />\n </body>\n </html>\n )\n}\n\nexport type WithPayloadRootOptions = {\n /**\n * Path prefix that mounts the Payload admin panel (`config.routes.admin`).\n * Routes under it render the Payload admin document shell; everything else\n * renders your own shell. Defaults to `'/admin'`.\n */\n adminRoute?: string\n}\n\n/**\n * Wraps your application's root document shell so Payload owns its own\n * `<html>` chrome on admin routes while your shell renders everywhere else.\n *\n * Attach the result to the root route's `shellComponent`; it is the single\n * integration touch point — no root loader and no manual data threading:\n *\n * ```tsx\n * export const Route = createRootRoute({\n * shellComponent: withPayloadRoot(MarketingRoot),\n * })\n * ```\n */\nexport function withPayloadRoot(\n RootShell: React.ComponentType<{ children: React.ReactNode }>,\n options: WithPayloadRootOptions = {},\n) {\n const { adminRoute = '/admin' } = options\n\n return function PayloadRootShell({ children }: { children: React.ReactNode }) {\n const isAdminRoute = useRouterState({\n select: (s) => {\n const { pathname } = s.location\n return pathname === adminRoute || pathname.startsWith(`${adminRoute}/`)\n },\n })\n\n if (isAdminRoute) {\n return <PayloadAdminShell>{children}</PayloadAdminShell>\n }\n\n return <RootShell>{children}</RootShell>\n }\n}\n"],"names":["getLanguageDir","HeadContent","Scripts","useRouterState","React","PayloadAdminShell","children","htmlProps","select","state","match","matches","data","loaderData","theme","languageCode","dir","lang","html","suppressHydrationWarning","head","style","body","withPayloadRoot","RootShell","options","adminRoute","PayloadRootShell","isAdminRoute","s","pathname","location","startsWith"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,0CAAyC;AACxE,SAASC,WAAW,EAAEC,OAAO,EAAEC,cAAc,QAAQ,yBAAwB;AAC7E,OAAOC,WAAW,QAAO;AAYzB;;;;;;;;CAQC,GACD,OAAO,SAASC,kBAAkB,EAAEC,QAAQ,EAA0B;IACpE,MAAMC,YAAYJ,eAAe;QAC/BK,QAAQ,CAACC;YACP,KAAK,MAAMC,SAASD,MAAME,OAAO,CAAE;gBACjC,MAAMC,OAAOF,MAAMG,UAAU;gBAE7B,IAAID,MAAME,SAASF,MAAMG,cAAc;oBACrC,OAAO;wBACL,cAAcH,KAAKE,KAAK;wBACxBE,KAAKhB,eAAe;4BAAEe,cAAcH,KAAKG,YAAY;wBAAC;wBACtDE,MAAML,KAAKG,YAAY;oBACzB;gBACF;YACF;YAEA,yEAAyE;YACzE,oEAAoE;YACpE,wEAAwE;YACxE,OAAO;gBAAEC,KAAK;YAAM;QACtB;IACF;IAEA,OACE,mHAAmH;kBACnH,MAACE;QAAM,GAAGX,SAAS;QAAEY,wBAAwB;;0BAC3C,MAACC;;kCACC,KAACC;kCAAO,CAAC,gCAAgC,CAAC;;kCAC1C,KAACpB;;;0BAEH,MAACqB;;oBACEhB;kCACD,KAACJ;;;;;AAIT;AAWA;;;;;;;;;;;;CAYC,GACD,OAAO,SAASqB,gBACdC,SAA6D,EAC7DC,UAAkC,CAAC,CAAC;IAEpC,MAAM,EAAEC,aAAa,QAAQ,EAAE,GAAGD;IAElC,OAAO,SAASE,iBAAiB,EAAErB,QAAQ,EAAiC;QAC1E,MAAMsB,eAAezB,eAAe;YAClCK,QAAQ,CAACqB;gBACP,MAAM,EAAEC,QAAQ,EAAE,GAAGD,EAAEE,QAAQ;gBAC/B,OAAOD,aAAaJ,cAAcI,SAASE,UAAU,CAAC,GAAGN,WAAW,CAAC,CAAC;YACxE;QACF;QAEA,IAAIE,cAAc;YAChB,qBAAO,KAACvB;0BAAmBC;;QAC7B;QAEA,qBAAO,KAACkB;sBAAWlB;;IACrB;AACF"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node ESM loader hook that swallows static asset imports (CSS/SCSS/LESS,
|
|
3
|
-
* images, fonts, audio, video, etc.) encountered while running the dev
|
|
4
|
-
* server.
|
|
5
|
-
*
|
|
6
|
-
* Vite is supposed to intercept asset imports during SSR/RSC by treating
|
|
7
|
-
* the package as `noExternal`, but that resolution path silently breaks down
|
|
8
|
-
* when a dependency is installed from a packed tarball under
|
|
9
|
-
* `node_modules/.pnpm/<pkg>@file+packed+...`. In that scenario Vite hands the
|
|
10
|
-
* import to Node's native ESM loader, which has no opinion about `.css` /
|
|
11
|
-
* `.svg` / `.png` files and throws `ERR_UNKNOWN_FILE_EXTENSION`. That single
|
|
12
|
-
* throw cascades into every admin route showing "Something went wrong!"
|
|
13
|
-
* because the SSR tree dies inside `<MatchInnerImpl>`.
|
|
14
|
-
*
|
|
15
|
-
* Registering this loader (with `--import` or `register()`) makes Node treat
|
|
16
|
-
* any asset specifier as an empty ES module, which is exactly what we
|
|
17
|
-
* already do client-side for SSR.
|
|
18
|
-
*
|
|
19
|
-
* The loader is intentionally minimal and side-effect free; it only kicks in
|
|
20
|
-
* for asset specifiers and falls through to the default loader for
|
|
21
|
-
* everything else.
|
|
22
|
-
*/
|
|
23
|
-
export declare function resolve(specifier: any, context: any, nextResolve: any): Promise<any>;
|
|
24
|
-
export declare function load(url: any, context: any, nextLoad: any): Promise<any>;
|
|
25
|
-
//# sourceMappingURL=cssLoader.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cssLoader.d.mts","sourceRoot":"","sources":["../../src/node/cssLoader.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAiCH,wBAAsB,OAAO,CAAC,SAAS,KAAA,EAAE,OAAO,KAAA,EAAE,WAAW,KAAA,gBAS5D;AAED,wBAAsB,IAAI,CAAC,GAAG,KAAA,EAAE,OAAO,KAAA,EAAE,QAAQ,KAAA,gBAShD"}
|
package/dist/node/cssLoader.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node ESM loader hook that swallows static asset imports (CSS/SCSS/LESS,
|
|
3
|
-
* images, fonts, audio, video, etc.) encountered while running the dev
|
|
4
|
-
* server.
|
|
5
|
-
*
|
|
6
|
-
* Vite is supposed to intercept asset imports during SSR/RSC by treating
|
|
7
|
-
* the package as `noExternal`, but that resolution path silently breaks down
|
|
8
|
-
* when a dependency is installed from a packed tarball under
|
|
9
|
-
* `node_modules/.pnpm/<pkg>@file+packed+...`. In that scenario Vite hands the
|
|
10
|
-
* import to Node's native ESM loader, which has no opinion about `.css` /
|
|
11
|
-
* `.svg` / `.png` files and throws `ERR_UNKNOWN_FILE_EXTENSION`. That single
|
|
12
|
-
* throw cascades into every admin route showing "Something went wrong!"
|
|
13
|
-
* because the SSR tree dies inside `<MatchInnerImpl>`.
|
|
14
|
-
*
|
|
15
|
-
* Registering this loader (with `--import` or `register()`) makes Node treat
|
|
16
|
-
* any asset specifier as an empty ES module, which is exactly what we
|
|
17
|
-
* already do client-side for SSR.
|
|
18
|
-
*
|
|
19
|
-
* The loader is intentionally minimal and side-effect free; it only kicks in
|
|
20
|
-
* for asset specifiers and falls through to the default loader for
|
|
21
|
-
* everything else.
|
|
22
|
-
*/ const STYLE_EXTENSION_RE = /\.(?:s?css|less)(?:\?[^#]*)?(?:#.*)?$/i;
|
|
23
|
-
const ASSET_EXTENSION_RE = /\.(?:svg|png|jpe?g|gif|webp|avif|ico|bmp|tiff?|woff2?|ttf|otf|eot|mp[34]|webm|ogg|oga|wav|flac|m4a|m4v|mov|pdf)(?:\?[^#]*)?(?:#.*)?$/i;
|
|
24
|
-
const isStylesheet = (s)=>STYLE_EXTENSION_RE.test(s);
|
|
25
|
-
const isStaticAsset = (s)=>ASSET_EXTENSION_RE.test(s);
|
|
26
|
-
const stubSource = (specifier)=>{
|
|
27
|
-
if (isStylesheet(specifier)) {
|
|
28
|
-
// Stylesheet imports usually have no JS-visible exports, so an empty
|
|
29
|
-
// module is fine and matches Vite's `?inline` / extracted-css behaviour.
|
|
30
|
-
return '';
|
|
31
|
-
}
|
|
32
|
-
// Treat every other static asset like Vite's default asset pipeline:
|
|
33
|
-
// expose the (escaped) specifier as both a default export and a `src`
|
|
34
|
-
// property. This lets code like
|
|
35
|
-
// import logo from './logo.svg' -> uses the default export
|
|
36
|
-
// import { src } from './logo.png' -> Next.js `StaticImageData` shim
|
|
37
|
-
// logo === '/logo.svg' -> truthy, sufficient for tests
|
|
38
|
-
// continue to work without crashing during SSR.
|
|
39
|
-
const value = JSON.stringify(specifier);
|
|
40
|
-
return `const __asset = ${value};
|
|
41
|
-
export default __asset;
|
|
42
|
-
export const src = __asset;
|
|
43
|
-
export const height = 0;
|
|
44
|
-
export const width = 0;
|
|
45
|
-
export const blurWidth = 0;
|
|
46
|
-
export const blurHeight = 0;
|
|
47
|
-
`;
|
|
48
|
-
};
|
|
49
|
-
export async function resolve(specifier, context, nextResolve) {
|
|
50
|
-
if (isStylesheet(specifier) || isStaticAsset(specifier)) {
|
|
51
|
-
return {
|
|
52
|
-
format: 'module',
|
|
53
|
-
shortCircuit: true,
|
|
54
|
-
url: `data:text/javascript;base64,${Buffer.from(stubSource(specifier)).toString('base64')}`
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return nextResolve(specifier, context);
|
|
58
|
-
}
|
|
59
|
-
export async function load(url, context, nextLoad) {
|
|
60
|
-
if (isStylesheet(url) || isStaticAsset(url)) {
|
|
61
|
-
return {
|
|
62
|
-
format: 'module',
|
|
63
|
-
shortCircuit: true,
|
|
64
|
-
source: stubSource(url)
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
return nextLoad(url, context);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
//# sourceMappingURL=cssLoader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/node/cssLoader.mjs"],"sourcesContent":["/**\n * Node ESM loader hook that swallows static asset imports (CSS/SCSS/LESS,\n * images, fonts, audio, video, etc.) encountered while running the dev\n * server.\n *\n * Vite is supposed to intercept asset imports during SSR/RSC by treating\n * the package as `noExternal`, but that resolution path silently breaks down\n * when a dependency is installed from a packed tarball under\n * `node_modules/.pnpm/<pkg>@file+packed+...`. In that scenario Vite hands the\n * import to Node's native ESM loader, which has no opinion about `.css` /\n * `.svg` / `.png` files and throws `ERR_UNKNOWN_FILE_EXTENSION`. That single\n * throw cascades into every admin route showing \"Something went wrong!\"\n * because the SSR tree dies inside `<MatchInnerImpl>`.\n *\n * Registering this loader (with `--import` or `register()`) makes Node treat\n * any asset specifier as an empty ES module, which is exactly what we\n * already do client-side for SSR.\n *\n * The loader is intentionally minimal and side-effect free; it only kicks in\n * for asset specifiers and falls through to the default loader for\n * everything else.\n */\n\nconst STYLE_EXTENSION_RE = /\\.(?:s?css|less)(?:\\?[^#]*)?(?:#.*)?$/i\nconst ASSET_EXTENSION_RE =\n /\\.(?:svg|png|jpe?g|gif|webp|avif|ico|bmp|tiff?|woff2?|ttf|otf|eot|mp[34]|webm|ogg|oga|wav|flac|m4a|m4v|mov|pdf)(?:\\?[^#]*)?(?:#.*)?$/i\n\nconst isStylesheet = (s) => STYLE_EXTENSION_RE.test(s)\nconst isStaticAsset = (s) => ASSET_EXTENSION_RE.test(s)\n\nconst stubSource = (specifier) => {\n if (isStylesheet(specifier)) {\n // Stylesheet imports usually have no JS-visible exports, so an empty\n // module is fine and matches Vite's `?inline` / extracted-css behaviour.\n return ''\n }\n // Treat every other static asset like Vite's default asset pipeline:\n // expose the (escaped) specifier as both a default export and a `src`\n // property. This lets code like\n // import logo from './logo.svg' -> uses the default export\n // import { src } from './logo.png' -> Next.js `StaticImageData` shim\n // logo === '/logo.svg' -> truthy, sufficient for tests\n // continue to work without crashing during SSR.\n const value = JSON.stringify(specifier)\n return `const __asset = ${value};\nexport default __asset;\nexport const src = __asset;\nexport const height = 0;\nexport const width = 0;\nexport const blurWidth = 0;\nexport const blurHeight = 0;\n`\n}\n\nexport async function resolve(specifier, context, nextResolve) {\n if (isStylesheet(specifier) || isStaticAsset(specifier)) {\n return {\n format: 'module',\n shortCircuit: true,\n url: `data:text/javascript;base64,${Buffer.from(stubSource(specifier)).toString('base64')}`,\n }\n }\n return nextResolve(specifier, context)\n}\n\nexport async function load(url, context, nextLoad) {\n if (isStylesheet(url) || isStaticAsset(url)) {\n return {\n format: 'module',\n shortCircuit: true,\n source: stubSource(url),\n }\n }\n return nextLoad(url, context)\n}\n"],"names":["STYLE_EXTENSION_RE","ASSET_EXTENSION_RE","isStylesheet","s","test","isStaticAsset","stubSource","specifier","value","JSON","stringify","resolve","context","nextResolve","format","shortCircuit","url","Buffer","from","toString","load","nextLoad","source"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;CAqBC,GAED,MAAMA,qBAAqB;AAC3B,MAAMC,qBACJ;AAEF,MAAMC,eAAe,CAACC,IAAMH,mBAAmBI,IAAI,CAACD;AACpD,MAAME,gBAAgB,CAACF,IAAMF,mBAAmBG,IAAI,CAACD;AAErD,MAAMG,aAAa,CAACC;IAClB,IAAIL,aAAaK,YAAY;QAC3B,qEAAqE;QACrE,yEAAyE;QACzE,OAAO;IACT;IACA,qEAAqE;IACrE,sEAAsE;IACtE,gCAAgC;IAChC,oEAAoE;IACpE,2EAA2E;IAC3E,yEAAyE;IACzE,gDAAgD;IAChD,MAAMC,QAAQC,KAAKC,SAAS,CAACH;IAC7B,OAAO,CAAC,gBAAgB,EAAEC,MAAM;;;;;;;AAOlC,CAAC;AACD;AAEA,OAAO,eAAeG,QAAQJ,SAAS,EAAEK,OAAO,EAAEC,WAAW;IAC3D,IAAIX,aAAaK,cAAcF,cAAcE,YAAY;QACvD,OAAO;YACLO,QAAQ;YACRC,cAAc;YACdC,KAAK,CAAC,4BAA4B,EAAEC,OAAOC,IAAI,CAACZ,WAAWC,YAAYY,QAAQ,CAAC,WAAW;QAC7F;IACF;IACA,OAAON,YAAYN,WAAWK;AAChC;AAEA,OAAO,eAAeQ,KAAKJ,GAAG,EAAEJ,OAAO,EAAES,QAAQ;IAC/C,IAAInB,aAAac,QAAQX,cAAcW,MAAM;QAC3C,OAAO;YACLF,QAAQ;YACRC,cAAc;YACdO,QAAQhB,WAAWU;QACrB;IACF;IACA,OAAOK,SAASL,KAAKJ;AACvB"}
|
package/dist/node/cssLoader.mjs
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node ESM loader hook that swallows static asset imports (CSS/SCSS/LESS,
|
|
3
|
-
* images, fonts, audio, video, etc.) encountered while running the dev
|
|
4
|
-
* server.
|
|
5
|
-
*
|
|
6
|
-
* Vite is supposed to intercept asset imports during SSR/RSC by treating
|
|
7
|
-
* the package as `noExternal`, but that resolution path silently breaks down
|
|
8
|
-
* when a dependency is installed from a packed tarball under
|
|
9
|
-
* `node_modules/.pnpm/<pkg>@file+packed+...`. In that scenario Vite hands the
|
|
10
|
-
* import to Node's native ESM loader, which has no opinion about `.css` /
|
|
11
|
-
* `.svg` / `.png` files and throws `ERR_UNKNOWN_FILE_EXTENSION`. That single
|
|
12
|
-
* throw cascades into every admin route showing "Something went wrong!"
|
|
13
|
-
* because the SSR tree dies inside `<MatchInnerImpl>`.
|
|
14
|
-
*
|
|
15
|
-
* Registering this loader (with `--import` or `register()`) makes Node treat
|
|
16
|
-
* any asset specifier as an empty ES module, which is exactly what we
|
|
17
|
-
* already do client-side for SSR.
|
|
18
|
-
*
|
|
19
|
-
* The loader is intentionally minimal and side-effect free; it only kicks in
|
|
20
|
-
* for asset specifiers and falls through to the default loader for
|
|
21
|
-
* everything else.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
const STYLE_EXTENSION_RE = /\.(?:s?css|less)(?:\?[^#]*)?(?:#.*)?$/i
|
|
25
|
-
const ASSET_EXTENSION_RE =
|
|
26
|
-
/\.(?:svg|png|jpe?g|gif|webp|avif|ico|bmp|tiff?|woff2?|ttf|otf|eot|mp[34]|webm|ogg|oga|wav|flac|m4a|m4v|mov|pdf)(?:\?[^#]*)?(?:#.*)?$/i
|
|
27
|
-
|
|
28
|
-
const isStylesheet = (s) => STYLE_EXTENSION_RE.test(s)
|
|
29
|
-
const isStaticAsset = (s) => ASSET_EXTENSION_RE.test(s)
|
|
30
|
-
|
|
31
|
-
const stubSource = (specifier) => {
|
|
32
|
-
if (isStylesheet(specifier)) {
|
|
33
|
-
// Stylesheet imports usually have no JS-visible exports, so an empty
|
|
34
|
-
// module is fine and matches Vite's `?inline` / extracted-css behaviour.
|
|
35
|
-
return ''
|
|
36
|
-
}
|
|
37
|
-
// Treat every other static asset like Vite's default asset pipeline:
|
|
38
|
-
// expose the (escaped) specifier as both a default export and a `src`
|
|
39
|
-
// property. This lets code like
|
|
40
|
-
// import logo from './logo.svg' -> uses the default export
|
|
41
|
-
// import { src } from './logo.png' -> Next.js `StaticImageData` shim
|
|
42
|
-
// logo === '/logo.svg' -> truthy, sufficient for tests
|
|
43
|
-
// continue to work without crashing during SSR.
|
|
44
|
-
const value = JSON.stringify(specifier)
|
|
45
|
-
return `const __asset = ${value};
|
|
46
|
-
export default __asset;
|
|
47
|
-
export const src = __asset;
|
|
48
|
-
export const height = 0;
|
|
49
|
-
export const width = 0;
|
|
50
|
-
export const blurWidth = 0;
|
|
51
|
-
export const blurHeight = 0;
|
|
52
|
-
`
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export async function resolve(specifier, context, nextResolve) {
|
|
56
|
-
if (isStylesheet(specifier) || isStaticAsset(specifier)) {
|
|
57
|
-
return {
|
|
58
|
-
format: 'module',
|
|
59
|
-
shortCircuit: true,
|
|
60
|
-
url: `data:text/javascript;base64,${Buffer.from(stubSource(specifier)).toString('base64')}`,
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return nextResolve(specifier, context)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export async function load(url, context, nextLoad) {
|
|
67
|
-
if (isStylesheet(url) || isStaticAsset(url)) {
|
|
68
|
-
return {
|
|
69
|
-
format: 'module',
|
|
70
|
-
shortCircuit: true,
|
|
71
|
-
source: stubSource(url),
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return nextLoad(url, context)
|
|
75
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registerCssLoader.d.mts","sourceRoot":"","sources":["../../src/node/registerCssLoader.mjs"],"names":[],"mappings":""}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tiny shim that registers `./cssLoader.mjs` as a Node ESM loader hook.
|
|
3
|
-
*
|
|
4
|
-
* Used by the test dev-server runner via `node --import ./registerCssLoader.mjs`
|
|
5
|
-
* so the spawned Vite process can swallow stylesheet imports it would
|
|
6
|
-
* otherwise hand to Node's native ESM loader (which throws on `.css`).
|
|
7
|
-
*/ import { register } from 'node:module';
|
|
8
|
-
register('./cssLoader.mjs', import.meta.url);
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=registerCssLoader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/node/registerCssLoader.mjs"],"sourcesContent":["/**\n * Tiny shim that registers `./cssLoader.mjs` as a Node ESM loader hook.\n *\n * Used by the test dev-server runner via `node --import ./registerCssLoader.mjs`\n * so the spawned Vite process can swallow stylesheet imports it would\n * otherwise hand to Node's native ESM loader (which throws on `.css`).\n */\nimport { register } from 'node:module'\n\nregister('./cssLoader.mjs', import.meta.url)\n"],"names":["register","url"],"mappings":"AAAA;;;;;;CAMC,GACD,SAASA,QAAQ,QAAQ,cAAa;AAEtCA,SAAS,mBAAmB,YAAYC,GAAG"}
|