@payloadcms/tanstack-start 4.0.0-internal.21320b5 → 4.0.0-internal.22d1431
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 +3 -0
- package/dist/adapters/handleServerFunctions.d.ts.map +1 -0
- package/dist/adapters/handleServerFunctions.js +17 -0
- package/dist/adapters/handleServerFunctions.js.map +1 -0
- package/dist/adapters/layout/RootProviders/index.d.ts +9 -0
- package/dist/adapters/layout/RootProviders/index.d.ts.map +1 -0
- package/dist/adapters/layout/RootProviders/index.js +21 -0
- package/dist/adapters/layout/RootProviders/index.js.map +1 -0
- package/dist/{layouts/Root/withPayloadRoot.d.ts → adapters/layout/index.d.ts} +32 -4
- package/dist/adapters/layout/index.d.ts.map +1 -0
- package/dist/adapters/layout/index.js +107 -0
- package/dist/adapters/layout/index.js.map +1 -0
- package/dist/adapters/layout/lazy.d.ts +7 -0
- package/dist/adapters/layout/lazy.d.ts.map +1 -0
- package/dist/adapters/layout/lazy.js +17 -0
- package/dist/adapters/layout/lazy.js.map +1 -0
- package/dist/adapters/layout/outlet.d.ts +4 -0
- package/dist/adapters/layout/outlet.d.ts.map +1 -0
- package/dist/adapters/layout/outlet.js +9 -0
- package/dist/adapters/layout/outlet.js.map +1 -0
- package/dist/adapters/layout/server.d.ts +23 -0
- package/dist/adapters/layout/server.d.ts.map +1 -0
- package/dist/adapters/layout/server.js +65 -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 -15
- 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} +3 -30
- package/dist/adapters/server.js.map +1 -0
- package/dist/{routes/adminRoutes.d.ts → adapters/views/index.d.ts} +12 -18
- package/dist/adapters/views/index.d.ts.map +1 -0
- package/dist/{routes/adminRoutes.js → adapters/views/index.js} +36 -49
- package/dist/adapters/views/index.js.map +1 -0
- package/dist/adapters/views/lazy.d.ts +4 -0
- package/dist/adapters/views/lazy.d.ts.map +1 -0
- package/dist/adapters/views/lazy.js +44 -0
- package/dist/adapters/views/lazy.js.map +1 -0
- package/dist/{utilities/loadAdminPage.d.ts → adapters/views/server.d.ts} +12 -6
- package/dist/adapters/views/server.d.ts.map +1 -0
- package/dist/{utilities/loadAdminPage.js → adapters/views/server.js} +25 -78
- 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/layout.d.ts +2 -0
- package/dist/exports/client/layout.d.ts.map +1 -0
- package/dist/exports/client/layout.js +4 -0
- package/dist/exports/client/layout.js.map +1 -0
- 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/routes.d.ts +2 -0
- package/dist/exports/routes.d.ts.map +1 -0
- package/dist/exports/routes.js +3 -0
- package/dist/exports/routes.js.map +1 -0
- package/dist/exports/server.d.ts +6 -11
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +6 -11
- package/dist/exports/server.js.map +1 -1
- package/dist/{utilities/graphqlHandler.server.d.ts → routes/graphql/handler.server.d.ts} +1 -3
- package/dist/routes/graphql/handler.server.d.ts.map +1 -0
- package/dist/{utilities/graphqlHandler.server.js → routes/graphql/handler.server.js} +9 -6
- package/dist/routes/graphql/handler.server.js.map +1 -0
- package/dist/routes/rest/handler.server.d.ts +11 -0
- package/dist/routes/rest/handler.server.d.ts.map +1 -0
- package/dist/routes/rest/handler.server.js +14 -0
- package/dist/routes/rest/handler.server.js.map +1 -0
- package/dist/routes/{apiRoute.d.ts → rest/index.d.ts} +5 -4
- package/dist/routes/rest/index.d.ts.map +1 -0
- package/dist/routes/{apiRoute.js → rest/index.js} +6 -5
- package/dist/routes/rest/index.js.map +1 -0
- package/dist/rsc/CollectionCards.js +1 -1
- package/dist/rsc/CollectionCards.js.map +1 -1
- package/dist/utilities/devConfigReload.server.js +29 -6
- package/dist/utilities/devConfigReload.server.js.map +1 -1
- 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/serverFunctionClient.d.ts +2 -23
- package/dist/utilities/serverFunctionClient.d.ts.map +1 -1
- package/dist/utilities/serverFunctionClient.js +12 -101
- package/dist/utilities/serverFunctionClient.js.map +1 -1
- package/dist/withPayload/config/external.d.ts +19 -21
- package/dist/withPayload/config/external.d.ts.map +1 -1
- package/dist/withPayload/config/external.js +38 -32
- 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/importProtection.js +1 -1
- package/dist/withPayload/importProtection.js.map +1 -1
- package/dist/withPayload/index.d.ts +24 -11
- package/dist/withPayload/index.d.ts.map +1 -1
- package/dist/withPayload/index.js +37 -17
- 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 +35 -29
- 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/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 +0 -11
- package/dist/utilities/handleAPIRoute.server.d.ts.map +0 -1
- package/dist/utilities/handleAPIRoute.server.js +0 -17
- package/dist/utilities/handleAPIRoute.server.js.map +0 -1
- package/dist/utilities/handleServerFunctions.d.ts +0 -2
- 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 -20
- package/dist/utilities/initReq.server.d.ts.map +0 -1
- package/dist/utilities/initReq.server.js +0 -90
- 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/serializeForRsc.d.ts +0 -26
- package/dist/utilities/serializeForRsc.d.ts.map +0 -1
- package/dist/utilities/serializeForRsc.js +0 -122
- package/dist/utilities/serializeForRsc.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/toSerializable.d.ts +0 -2
- package/dist/utilities/toSerializable.d.ts.map +0 -1
- package/dist/utilities/toSerializable.js +0 -111
- package/dist/utilities/toSerializable.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/tanstack-start",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.22d1431",
|
|
4
4
|
"description": "TanStack Start framework adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/payloadcms/payload.git",
|
|
9
|
-
"directory": "packages/tanstack-start"
|
|
10
|
-
},
|
|
11
6
|
"license": "MIT",
|
|
12
7
|
"author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
|
|
13
8
|
"maintainers": [
|
|
@@ -17,7 +12,17 @@
|
|
|
17
12
|
"url": "https://payloadcms.com"
|
|
18
13
|
}
|
|
19
14
|
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/payloadcms/payload.git",
|
|
18
|
+
"directory": "packages/tanstack-start"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
20
23
|
"type": "module",
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
21
26
|
"exports": {
|
|
22
27
|
".": {
|
|
23
28
|
"import": "./dist/index.js",
|
|
@@ -34,6 +39,11 @@
|
|
|
34
39
|
"types": "./dist/exports/server.d.ts",
|
|
35
40
|
"default": "./dist/exports/server.js"
|
|
36
41
|
},
|
|
42
|
+
"./routes": {
|
|
43
|
+
"import": "./dist/exports/routes.js",
|
|
44
|
+
"types": "./dist/exports/routes.d.ts",
|
|
45
|
+
"default": "./dist/exports/routes.js"
|
|
46
|
+
},
|
|
37
47
|
"./shared": {
|
|
38
48
|
"import": "./dist/exports/shared.js",
|
|
39
49
|
"types": "./dist/exports/shared.d.ts",
|
|
@@ -51,37 +61,35 @@
|
|
|
51
61
|
"default": "./dist/exports/rsc.js"
|
|
52
62
|
}
|
|
53
63
|
},
|
|
54
|
-
"main": "./dist/index.js",
|
|
55
|
-
"types": "./dist/index.d.ts",
|
|
56
|
-
"files": [
|
|
57
|
-
"dist"
|
|
58
|
-
],
|
|
59
64
|
"dependencies": {
|
|
60
|
-
"
|
|
61
|
-
"@payloadcms/translations": "4.0.0-internal.
|
|
62
|
-
"@payloadcms/ui": "4.0.0-internal.
|
|
65
|
+
"@payloadcms/graphql": "4.0.0-internal.22d1431",
|
|
66
|
+
"@payloadcms/translations": "4.0.0-internal.22d1431",
|
|
67
|
+
"@payloadcms/ui": "4.0.0-internal.22d1431",
|
|
68
|
+
"graphql-http": "1.22.4",
|
|
69
|
+
"qs-esm": "^7.0.2"
|
|
63
70
|
},
|
|
64
71
|
"devDependencies": {
|
|
65
|
-
"@tanstack/react-router": "^1.
|
|
66
|
-
"@tanstack/react-start": "^1.
|
|
72
|
+
"@tanstack/react-router": "^1.170.44",
|
|
73
|
+
"@tanstack/react-start": "^1.169.1",
|
|
67
74
|
"@types/react": "^19.0.0",
|
|
68
75
|
"@types/react-dom": "^19.0.0",
|
|
69
76
|
"@vitejs/plugin-react": "^6.0.0",
|
|
70
77
|
"@vitejs/plugin-rsc": "^0.5.21",
|
|
71
|
-
"
|
|
72
|
-
"react
|
|
73
|
-
"
|
|
74
|
-
"
|
|
78
|
+
"payload": "4.0.0-internal.22d1431",
|
|
79
|
+
"react": "19.3.1",
|
|
80
|
+
"react-dom": "19.3.1",
|
|
81
|
+
"vite": ">=8.0.0"
|
|
75
82
|
},
|
|
76
83
|
"peerDependencies": {
|
|
77
|
-
"@tanstack/react-router": "^1.
|
|
78
|
-
"@tanstack/react-start": "^1.
|
|
84
|
+
"@tanstack/react-router": "^1.170.44",
|
|
85
|
+
"@tanstack/react-start": "^1.169.1",
|
|
79
86
|
"@vitejs/plugin-react": "^6.0.0",
|
|
80
87
|
"@vitejs/plugin-rsc": "^0.5.21",
|
|
88
|
+
"graphql": "^16.8.1",
|
|
89
|
+
"payload": "4.0.0-internal.22d1431",
|
|
81
90
|
"react": "^19.0.0",
|
|
82
91
|
"react-dom": "^19.0.0",
|
|
83
|
-
"vite": ">=8.0.0"
|
|
84
|
-
"payload": "4.0.0-internal.21320b5"
|
|
92
|
+
"vite": ">=8.0.0"
|
|
85
93
|
},
|
|
86
94
|
"peerDependenciesMeta": {
|
|
87
95
|
"@vitejs/plugin-react": {
|
|
@@ -95,17 +103,15 @@
|
|
|
95
103
|
}
|
|
96
104
|
},
|
|
97
105
|
"engines": {
|
|
98
|
-
"node": "
|
|
106
|
+
"node": ">=24.22.1"
|
|
99
107
|
},
|
|
100
108
|
"scripts": {
|
|
101
|
-
"build": "pnpm build:types && pnpm
|
|
109
|
+
"build": "pnpm build:types && pnpm test:types && pnpm build:swc",
|
|
102
110
|
"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
111
|
"build:debug": "pnpm build",
|
|
105
112
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
106
113
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
107
114
|
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
108
|
-
"
|
|
109
|
-
"lint:fix": "eslint . --fix"
|
|
115
|
+
"test:types": "tsc --project test/tsconfig.json"
|
|
110
116
|
}
|
|
111
117
|
}
|
|
@@ -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;AA6DvE,eAAO,MAAM,qBAAqB,EAAE,sBAqHnC,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, useRouteTransition } from '@payloadcms/ui'\nimport {\n Link as TanStackLink,\n useLocation,\n useParams,\n useRouter,\n useRouterState,\n} from '@tanstack/react-router'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useEffect, 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 const isRouterLoading = useRouterState({ select: (state) => state.isLoading })\n const { holdRouteTransition } = useRouteTransition()\n\n useEffect(() => {\n if (!isRouterLoading) {\n return\n }\n\n const releaseRouteTransition = holdRouteTransition()\n\n return () => releaseRouteTransition()\n }, [holdRouteTransition, isRouterLoading])\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","useRouteTransition","Link","TanStackLink","useLocation","useParams","useRouter","useRouterState","qs","React","useCallback","useEffect","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","isRouterLoading","select","state","isLoading","holdRouteTransition","releaseRouteTransition","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,EAAEC,kBAAkB,QAAQ,iBAAgB;AACzE,SACEC,QAAQC,YAAY,EACpBC,WAAW,EACXC,SAAS,EACTC,SAAS,EACTC,cAAc,QACT,yBAAwB;AAC/B,YAAYC,QAAQ,SAAQ;AAC5B,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,QAAO;AAE9D,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;AAEA,MAAMO,sBAAkD,CAAC,EACvDC,QAAQ,EACRC,IAAI,EACJC,QAAQ,EACRC,GAAG,EACHC,OAAO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1E,MAAMG,eAAe1D,QAAQ,IAAM,IAAI2D,gBAAgBrC,SAASsC,SAAS,GAAG;QAACtC,SAASsC,SAAS;KAAC;IAEhG,MAAMC,QAAmC7D,QACvC,IAAO,CAAA;YACLV,MAAMmB;YACNc,QAAQQ;YACR5B,UAAUmB,SAASnB,QAAQ;YAC3BkB,QAAQoC;YACRC;QACF,CAAA,GACA;QAAC3B;QAAeT,SAASnB,QAAQ;QAAEsD;QAAeC;KAAa;IAGjE,qBAAO,KAACtE;QAAqByE,OAAOA;kBAAQnD;;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,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
-
'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"}
|
|
@@ -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
|
-
*/
|
|
8
|
-
import { register } from 'node:module'
|
|
9
|
-
|
|
10
|
-
register('./cssLoader.mjs', import.meta.url)
|