@payloadcms/next 3.0.0-beta.36 → 3.0.0-beta.37
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/prod/styles.css +1 -1
- package/dist/utilities/getPayloadHMR.d.ts.map +1 -1
- package/dist/utilities/getPayloadHMR.js +5 -3
- package/dist/utilities/getPayloadHMR.js.map +1 -1
- package/dist/views/Account/index.js +1 -1
- package/dist/views/Account/index.js.map +1 -1
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js +8 -4
- package/dist/views/Root/index.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPayloadHMR.d.ts","sourceRoot":"","sources":["../../src/utilities/getPayloadHMR.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,OAAO,EAAE,MAAM,SAAS,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAgBlE,eAAO,MAAM,MAAM,WAAkB,eAAe,uBAAqB,QAAQ,IAAI,
|
|
1
|
+
{"version":3,"file":"getPayloadHMR.d.ts","sourceRoot":"","sources":["../../src/utilities/getPayloadHMR.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,OAAO,EAAE,MAAM,SAAS,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAgBlE,eAAO,MAAM,MAAM,WAAkB,eAAe,uBAAqB,QAAQ,IAAI,CAyBpF,CAAA;AAED,eAAO,MAAM,aAAa,YAAmB,WAAW,KAAG,QAAQ,OAAO,CA4DzE,CAAA"}
|
|
@@ -26,9 +26,11 @@ export const reload = async (config, payload)=>{
|
|
|
26
26
|
};
|
|
27
27
|
// TODO: support HMR for other props in the future (see payload/src/index init()) hat may change on Payload singleton
|
|
28
28
|
await payload.db.init();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
if (payload.db.connect) {
|
|
30
|
+
await payload.db.connect({
|
|
31
|
+
hotReload: true
|
|
32
|
+
});
|
|
33
|
+
}
|
|
32
34
|
};
|
|
33
35
|
export const getPayloadHMR = async (options)=>{
|
|
34
36
|
if (!options?.config) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/getPayloadHMR.ts"],"sourcesContent":["import type { GeneratedTypes, Payload } from 'payload'\nimport type { InitOptions, SanitizedConfig } from 'payload/config'\n\nimport { BasePayload } from 'payload'\nimport WebSocket from 'ws'\n\nlet cached: {\n payload: Payload | null\n promise: Promise<Payload> | null\n reload: Promise<boolean> | boolean\n} = global._payload\n\nif (!cached) {\n // eslint-disable-next-line no-multi-assign\n cached = global._payload = { payload: null, promise: null, reload: false }\n}\n\nexport const reload = async (config: SanitizedConfig, payload: Payload): Promise<void> => {\n if (typeof payload.db.destroy === 'function') {\n await payload.db.destroy()\n }\n\n payload.config = config\n\n payload.collections = config.collections.reduce((collections, collection) => {\n collections[collection.slug] = {\n config: collection,\n customIDType: payload.collections[collection.slug]?.customIDType,\n }\n return collections\n }, {})\n\n payload.globals = {\n config: config.globals,\n }\n\n // TODO: support HMR for other props in the future (see payload/src/index init()) hat may change on Payload singleton\n\n await payload.db.init()\n await payload.db.connect({ hotReload: true })\n}\n\nexport const getPayloadHMR = async (options: InitOptions): Promise<Payload> => {\n if (!options?.config) {\n throw new Error('Error: the payload config is required for getPayload to work.')\n }\n\n if (cached.payload) {\n const config = await options.config // TODO: check if we can move this inside the cached.reload === true condition\n\n if (cached.reload === true) {\n let resolve\n\n cached.reload = new Promise((res) => (resolve = res))\n\n await reload(config, cached.payload)\n\n resolve()\n }\n\n if (cached.reload instanceof Promise) {\n await cached.reload\n }\n\n return cached.payload\n }\n\n if (!cached.promise) {\n cached.promise = new BasePayload<GeneratedTypes>().init(options)\n }\n\n try {\n cached.payload = await cached.promise\n\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.NODE_ENV !== 'test' &&\n process.env.DISABLE_PAYLOAD_HMR !== 'true'\n ) {\n try {\n const port = process.env.PORT || '3000'\n const ws = new WebSocket(`ws://localhost:${port}/_next/webpack-hmr`)\n\n ws.onmessage = (event) => {\n if (typeof event.data === 'string') {\n const data = JSON.parse(event.data)\n\n if ('action' in data && data.action === 'serverComponentChanges') {\n cached.reload = true\n }\n }\n }\n } catch (_) {\n // swallow e\n }\n }\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.payload\n}\n"],"names":["BasePayload","WebSocket","cached","global","_payload","payload","promise","reload","config","db","destroy","collections","reduce","collection","slug","customIDType","globals","init","connect","hotReload","getPayloadHMR","options","Error","resolve","Promise","res","process","env","NODE_ENV","DISABLE_PAYLOAD_HMR","port","PORT","ws","onmessage","event","data","JSON","parse","action","_","e"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/getPayloadHMR.ts"],"sourcesContent":["import type { GeneratedTypes, Payload } from 'payload'\nimport type { InitOptions, SanitizedConfig } from 'payload/config'\n\nimport { BasePayload } from 'payload'\nimport WebSocket from 'ws'\n\nlet cached: {\n payload: Payload | null\n promise: Promise<Payload> | null\n reload: Promise<boolean> | boolean\n} = global._payload\n\nif (!cached) {\n // eslint-disable-next-line no-multi-assign\n cached = global._payload = { payload: null, promise: null, reload: false }\n}\n\nexport const reload = async (config: SanitizedConfig, payload: Payload): Promise<void> => {\n if (typeof payload.db.destroy === 'function') {\n await payload.db.destroy()\n }\n\n payload.config = config\n\n payload.collections = config.collections.reduce((collections, collection) => {\n collections[collection.slug] = {\n config: collection,\n customIDType: payload.collections[collection.slug]?.customIDType,\n }\n return collections\n }, {})\n\n payload.globals = {\n config: config.globals,\n }\n\n // TODO: support HMR for other props in the future (see payload/src/index init()) hat may change on Payload singleton\n\n await payload.db.init()\n if (payload.db.connect) {\n await payload.db.connect({ hotReload: true })\n }\n}\n\nexport const getPayloadHMR = async (options: InitOptions): Promise<Payload> => {\n if (!options?.config) {\n throw new Error('Error: the payload config is required for getPayload to work.')\n }\n\n if (cached.payload) {\n const config = await options.config // TODO: check if we can move this inside the cached.reload === true condition\n\n if (cached.reload === true) {\n let resolve\n\n cached.reload = new Promise((res) => (resolve = res))\n\n await reload(config, cached.payload)\n\n resolve()\n }\n\n if (cached.reload instanceof Promise) {\n await cached.reload\n }\n\n return cached.payload\n }\n\n if (!cached.promise) {\n cached.promise = new BasePayload<GeneratedTypes>().init(options)\n }\n\n try {\n cached.payload = await cached.promise\n\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.NODE_ENV !== 'test' &&\n process.env.DISABLE_PAYLOAD_HMR !== 'true'\n ) {\n try {\n const port = process.env.PORT || '3000'\n const ws = new WebSocket(`ws://localhost:${port}/_next/webpack-hmr`)\n\n ws.onmessage = (event) => {\n if (typeof event.data === 'string') {\n const data = JSON.parse(event.data)\n\n if ('action' in data && data.action === 'serverComponentChanges') {\n cached.reload = true\n }\n }\n }\n } catch (_) {\n // swallow e\n }\n }\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.payload\n}\n"],"names":["BasePayload","WebSocket","cached","global","_payload","payload","promise","reload","config","db","destroy","collections","reduce","collection","slug","customIDType","globals","init","connect","hotReload","getPayloadHMR","options","Error","resolve","Promise","res","process","env","NODE_ENV","DISABLE_PAYLOAD_HMR","port","PORT","ws","onmessage","event","data","JSON","parse","action","_","e"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,WAAW,QAAQ,UAAS;AACrC,OAAOC,eAAe,KAAI;AAE1B,IAAIC,SAIAC,OAAOC,QAAQ;AAEnB,IAAI,CAACF,QAAQ;IACX,2CAA2C;IAC3CA,SAASC,OAAOC,QAAQ,GAAG;QAAEC,SAAS;QAAMC,SAAS;QAAMC,QAAQ;IAAM;AAC3E;AAEA,OAAO,MAAMA,SAAS,OAAOC,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,OAAO;QAErC,IACEoB,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBACzBF,QAAQC,GAAG,CAACC,QAAQ,KAAK,UACzBF,QAAQC,GAAG,CAACE,mBAAmB,KAAK,QACpC;YACA,IAAI;gBACF,MAAMC,OAAOJ,QAAQC,GAAG,CAACI,IAAI,IAAI;gBACjC,MAAMC,KAAK,IAAI/B,UAAU,CAAC,eAAe,EAAE6B,KAAK,kBAAkB,CAAC;gBAEnEE,GAAGC,SAAS,GAAG,CAACC;oBACd,IAAI,OAAOA,MAAMC,IAAI,KAAK,UAAU;wBAClC,MAAMA,OAAOC,KAAKC,KAAK,CAACH,MAAMC,IAAI;wBAElC,IAAI,YAAYA,QAAQA,KAAKG,MAAM,KAAK,0BAA0B;4BAChEpC,OAAOK,MAAM,GAAG;wBAClB;oBACF;gBACF;YACF,EAAE,OAAOgC,GAAG;YACV,YAAY;YACd;QACF;IACF,EAAE,OAAOC,GAAG;QACVtC,OAAOI,OAAO,GAAG;QACjB,MAAMkC;IACR;IAEA,OAAOtC,OAAOG,OAAO;AACvB,EAAC"}
|
|
@@ -14,7 +14,7 @@ export const Account = async ({ initPageResult, params, searchParams })=>{
|
|
|
14
14
|
const { locale, permissions, req, req: { i18n, payload, payload: { config }, user } } = initPageResult;
|
|
15
15
|
const { admin: { components: { views: { Account: CustomAccountComponent } = {} } = {}, user: userSlug }, routes: { api }, serverURL } = config;
|
|
16
16
|
const collectionConfig = config.collections.find((collection)=>collection.slug === userSlug);
|
|
17
|
-
if (collectionConfig) {
|
|
17
|
+
if (collectionConfig && user?.id) {
|
|
18
18
|
const { docPermissions, hasPublishPermission, hasSavePermission } = await getDocumentPermissions({
|
|
19
19
|
id: user.id,
|
|
20
20
|
collectionConfig,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/Account/index.tsx"],"sourcesContent":["import type { ServerSideEditViewProps } from 'payload/types'\nimport type { AdminViewProps } from 'payload/types'\n\nimport { DocumentHeader } from '@payloadcms/ui/elements/DocumentHeader'\nimport { HydrateClientUser } from '@payloadcms/ui/elements/HydrateClientUser'\nimport { RenderCustomComponent } from '@payloadcms/ui/elements/RenderCustomComponent'\nimport { DocumentInfoProvider } from '@payloadcms/ui/providers/DocumentInfo'\nimport { FormQueryParamsProvider } from '@payloadcms/ui/providers/FormQueryParams'\nimport { notFound } from 'next/navigation.js'\nimport React from 'react'\n\nimport { getDocumentPermissions } from '../Document/getDocumentPermissions.js'\nimport { EditView } from '../Edit/index.js'\nimport { Settings } from './Settings/index.js'\n\nexport { generateAccountMetadata } from './meta.js'\n\nexport const Account: React.FC<AdminViewProps> = async ({\n initPageResult,\n params,\n searchParams,\n}) => {\n const {\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = initPageResult\n\n const {\n admin: { components: { views: { Account: CustomAccountComponent } = {} } = {}, user: userSlug },\n routes: { api },\n serverURL,\n } = config\n\n const collectionConfig = config.collections.find((collection) => collection.slug === userSlug)\n\n if (collectionConfig) {\n const { docPermissions, hasPublishPermission, hasSavePermission } =\n await getDocumentPermissions({\n id: user.id,\n collectionConfig,\n data: user,\n req,\n })\n\n const viewComponentProps: ServerSideEditViewProps = {\n initPageResult,\n params,\n routeSegments: [],\n searchParams,\n }\n\n return (\n <DocumentInfoProvider\n AfterFields={<Settings />}\n action={`${serverURL}${api}/${userSlug}${user?.id ? `/${user.id}` : ''}`}\n apiURL={`${serverURL}${api}/${userSlug}${user?.id ? `/${user.id}` : ''}`}\n collectionSlug={userSlug}\n docPermissions={docPermissions}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n id={user?.id.toString()}\n isEditing\n >\n <DocumentHeader\n collectionConfig={collectionConfig}\n config={payload.config}\n hideTabs\n i18n={i18n}\n permissions={permissions}\n />\n <HydrateClientUser permissions={permissions} user={user} />\n <FormQueryParamsProvider\n initialParams={{\n depth: 0,\n 'fallback-locale': 'null',\n locale: locale.code,\n uploadEdits: undefined,\n }}\n >\n <RenderCustomComponent\n CustomComponent={\n typeof CustomAccountComponent === 'function' ? CustomAccountComponent : undefined\n }\n DefaultComponent={EditView}\n componentProps={viewComponentProps}\n serverOnlyProps={{\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }}\n />\n </FormQueryParamsProvider>\n </DocumentInfoProvider>\n )\n }\n\n return notFound()\n}\n"],"names":["DocumentHeader","HydrateClientUser","RenderCustomComponent","DocumentInfoProvider","FormQueryParamsProvider","notFound","React","getDocumentPermissions","EditView","Settings","generateAccountMetadata","Account","initPageResult","params","searchParams","locale","permissions","req","i18n","payload","config","user","admin","components","views","CustomAccountComponent","userSlug","routes","api","serverURL","collectionConfig","collections","find","collection","slug","docPermissions","hasPublishPermission","hasSavePermission","
|
|
1
|
+
{"version":3,"sources":["../../../src/views/Account/index.tsx"],"sourcesContent":["import type { ServerSideEditViewProps } from 'payload/types'\nimport type { AdminViewProps } from 'payload/types'\n\nimport { DocumentHeader } from '@payloadcms/ui/elements/DocumentHeader'\nimport { HydrateClientUser } from '@payloadcms/ui/elements/HydrateClientUser'\nimport { RenderCustomComponent } from '@payloadcms/ui/elements/RenderCustomComponent'\nimport { DocumentInfoProvider } from '@payloadcms/ui/providers/DocumentInfo'\nimport { FormQueryParamsProvider } from '@payloadcms/ui/providers/FormQueryParams'\nimport { notFound } from 'next/navigation.js'\nimport React from 'react'\n\nimport { getDocumentPermissions } from '../Document/getDocumentPermissions.js'\nimport { EditView } from '../Edit/index.js'\nimport { Settings } from './Settings/index.js'\n\nexport { generateAccountMetadata } from './meta.js'\n\nexport const Account: React.FC<AdminViewProps> = async ({\n initPageResult,\n params,\n searchParams,\n}) => {\n const {\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = initPageResult\n\n const {\n admin: { components: { views: { Account: CustomAccountComponent } = {} } = {}, user: userSlug },\n routes: { api },\n serverURL,\n } = config\n\n const collectionConfig = config.collections.find((collection) => collection.slug === userSlug)\n\n if (collectionConfig && user?.id) {\n const { docPermissions, hasPublishPermission, hasSavePermission } =\n await getDocumentPermissions({\n id: user.id,\n collectionConfig,\n data: user,\n req,\n })\n\n const viewComponentProps: ServerSideEditViewProps = {\n initPageResult,\n params,\n routeSegments: [],\n searchParams,\n }\n\n return (\n <DocumentInfoProvider\n AfterFields={<Settings />}\n action={`${serverURL}${api}/${userSlug}${user?.id ? `/${user.id}` : ''}`}\n apiURL={`${serverURL}${api}/${userSlug}${user?.id ? `/${user.id}` : ''}`}\n collectionSlug={userSlug}\n docPermissions={docPermissions}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n id={user?.id.toString()}\n isEditing\n >\n <DocumentHeader\n collectionConfig={collectionConfig}\n config={payload.config}\n hideTabs\n i18n={i18n}\n permissions={permissions}\n />\n <HydrateClientUser permissions={permissions} user={user} />\n <FormQueryParamsProvider\n initialParams={{\n depth: 0,\n 'fallback-locale': 'null',\n locale: locale.code,\n uploadEdits: undefined,\n }}\n >\n <RenderCustomComponent\n CustomComponent={\n typeof CustomAccountComponent === 'function' ? CustomAccountComponent : undefined\n }\n DefaultComponent={EditView}\n componentProps={viewComponentProps}\n serverOnlyProps={{\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }}\n />\n </FormQueryParamsProvider>\n </DocumentInfoProvider>\n )\n }\n\n return notFound()\n}\n"],"names":["DocumentHeader","HydrateClientUser","RenderCustomComponent","DocumentInfoProvider","FormQueryParamsProvider","notFound","React","getDocumentPermissions","EditView","Settings","generateAccountMetadata","Account","initPageResult","params","searchParams","locale","permissions","req","i18n","payload","config","user","admin","components","views","CustomAccountComponent","userSlug","routes","api","serverURL","collectionConfig","collections","find","collection","slug","id","docPermissions","hasPublishPermission","hasSavePermission","data","viewComponentProps","routeSegments","AfterFields","action","apiURL","collectionSlug","toString","isEditing","hideTabs","initialParams","depth","code","uploadEdits","undefined","CustomComponent","DefaultComponent","componentProps","serverOnlyProps"],"rangeMappings":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eAAe,EAAE;YACjB3B;QACF;QAEA,qBACE,MAACX;YACCuC,2BAAa,KAACjC;YACdkC,QAAQ,CAAC,EAAEd,UAAU,EAAED,IAAI,CAAC,EAAEF,SAAS,EAAEL,MAAMc,KAAK,CAAC,CAAC,EAAEd,KAAKc,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC;YACxES,QAAQ,CAAC,EAAEf,UAAU,EAAED,IAAI,CAAC,EAAEF,SAAS,EAAEL,MAAMc,KAAK,CAAC,CAAC,EAAEd,KAAKc,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC;YACxEU,gBAAgBnB;YAChBU,gBAAgBA;YAChBC,sBAAsBA;YACtBC,mBAAmBA;YACnBH,IAAId,MAAMc,GAAGW;YACbC,SAAS;;8BAET,KAAC/C;oBACC8B,kBAAkBA;oBAClBV,QAAQD,QAAQC,MAAM;oBACtB4B,QAAQ;oBACR9B,MAAMA;oBACNF,aAAaA;;8BAEf,KAACf;oBAAkBe,aAAaA;oBAAaK,MAAMA;;8BACnD,KAACjB;oBACC6C,eAAe;wBACbC,OAAO;wBACP,mBAAmB;wBACnBnC,QAAQA,OAAOoC,IAAI;wBACnBC,aAAaC;oBACf;8BAEA,cAAA,KAACnD;wBACCoD,iBACE,OAAO7B,2BAA2B,aAAaA,yBAAyB4B;wBAE1EE,kBAAkB/C;wBAClBgD,gBAAgBhB;wBAChBiB,iBAAiB;4BACfvC;4BACAH;4BACAF;4BACAM;4BACAH;4BACAF;4BACAO;wBACF;;;;;IAKV;IAEA,OAAOhB;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Root/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Root/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAMpD,OAAO,KAAmB,MAAM,OAAO,CAAA;AAKvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEhD,MAAM,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE;IACxC,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,IAAI,CAAA;IACV,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAA;CAC9C,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEvB,eAAO,MAAM,QAAQ,qDAIlB;IACD,MAAM,EAAE,QAAQ,eAAe,CAAC,CAAA;IAChC,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,EAAE,CAAA;KACnB,CAAA;IACD,YAAY,EAAE;QACZ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KACjC,CAAA;CACF,+BA0FA,CAAA"}
|
package/dist/views/Root/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { WithServerSideProps } from '@payloadcms/ui/elements/WithServerSideProps';
|
|
2
3
|
import { DefaultTemplate } from '@payloadcms/ui/templates/Default';
|
|
3
4
|
import { MinimalTemplate } from '@payloadcms/ui/templates/Minimal';
|
|
4
5
|
import { notFound, redirect } from 'next/navigation.js';
|
|
@@ -36,10 +37,13 @@ export const RootPage = async ({ config: configPromise, params, searchParams })=
|
|
|
36
37
|
redirect(adminRoute);
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
|
-
const RenderedView = /*#__PURE__*/ _jsx(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
const RenderedView = /*#__PURE__*/ _jsx(WithServerSideProps, {
|
|
41
|
+
Component: DefaultView,
|
|
42
|
+
serverOnlyProps: {
|
|
43
|
+
initPageResult,
|
|
44
|
+
params,
|
|
45
|
+
searchParams
|
|
46
|
+
}
|
|
43
47
|
});
|
|
44
48
|
return /*#__PURE__*/ _jsxs(Fragment, {
|
|
45
49
|
children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/Root/index.tsx"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type { SanitizedConfig } from 'payload/types'\n\nimport { DefaultTemplate } from '@payloadcms/ui/templates/Default'\nimport { MinimalTemplate } from '@payloadcms/ui/templates/Minimal'\nimport { notFound, redirect } from 'next/navigation.js'\nimport React, { Fragment } from 'react'\n\nimport { initPage } from '../../utilities/initPage/index.js'\nimport { getViewFromConfig } from './getViewFromConfig.js'\n\nexport { generatePageMetadata } from './meta.js'\n\nexport type GenerateViewMetadata = (args: {\n config: SanitizedConfig\n i18n: I18n\n isEditing?: boolean\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const RootPage = async ({\n config: configPromise,\n params,\n searchParams,\n}: {\n config: Promise<SanitizedConfig>\n params: {\n segments: string[]\n }\n searchParams: {\n [key: string]: string | string[]\n }\n}) => {\n const config = await configPromise\n\n const {\n admin: {\n routes: { createFirstUser: createFirstUserRoute },\n user: userSlug,\n },\n routes: { admin: adminRoute },\n } = config\n\n const currentRoute = `${adminRoute}${Array.isArray(params.segments) ? `/${params.segments.join('/')}` : ''}`\n\n const segments = Array.isArray(params.segments) ? params.segments : []\n\n const { DefaultView, initPageOptions, templateClassName, templateType } = getViewFromConfig({\n adminRoute,\n config,\n currentRoute,\n searchParams,\n segments,\n })\n\n let dbHasUser = false\n\n if (!DefaultView) {\n notFound()\n }\n\n const initPageResult = await initPage(initPageOptions)\n\n if (initPageResult) {\n dbHasUser = await initPageResult?.req.payload.db\n .findOne({\n collection: userSlug,\n req: initPageResult?.req,\n })\n ?.then((doc) => !!doc)\n\n const routeWithAdmin = `${adminRoute}${createFirstUserRoute}`\n\n if (!dbHasUser && currentRoute !== routeWithAdmin) {\n redirect(routeWithAdmin)\n }\n\n if (dbHasUser && currentRoute === routeWithAdmin) {\n redirect(adminRoute)\n }\n }\n\n const RenderedView = (\n <
|
|
1
|
+
{"version":3,"sources":["../../../src/views/Root/index.tsx"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type { SanitizedConfig } from 'payload/types'\n\nimport { WithServerSideProps } from '@payloadcms/ui/elements/WithServerSideProps'\nimport { DefaultTemplate } from '@payloadcms/ui/templates/Default'\nimport { MinimalTemplate } from '@payloadcms/ui/templates/Minimal'\nimport { notFound, redirect } from 'next/navigation.js'\nimport React, { Fragment } from 'react'\n\nimport { initPage } from '../../utilities/initPage/index.js'\nimport { getViewFromConfig } from './getViewFromConfig.js'\n\nexport { generatePageMetadata } from './meta.js'\n\nexport type GenerateViewMetadata = (args: {\n config: SanitizedConfig\n i18n: I18n\n isEditing?: boolean\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const RootPage = async ({\n config: configPromise,\n params,\n searchParams,\n}: {\n config: Promise<SanitizedConfig>\n params: {\n segments: string[]\n }\n searchParams: {\n [key: string]: string | string[]\n }\n}) => {\n const config = await configPromise\n\n const {\n admin: {\n routes: { createFirstUser: createFirstUserRoute },\n user: userSlug,\n },\n routes: { admin: adminRoute },\n } = config\n\n const currentRoute = `${adminRoute}${Array.isArray(params.segments) ? `/${params.segments.join('/')}` : ''}`\n\n const segments = Array.isArray(params.segments) ? params.segments : []\n\n const { DefaultView, initPageOptions, templateClassName, templateType } = getViewFromConfig({\n adminRoute,\n config,\n currentRoute,\n searchParams,\n segments,\n })\n\n let dbHasUser = false\n\n if (!DefaultView) {\n notFound()\n }\n\n const initPageResult = await initPage(initPageOptions)\n\n if (initPageResult) {\n dbHasUser = await initPageResult?.req.payload.db\n .findOne({\n collection: userSlug,\n req: initPageResult?.req,\n })\n ?.then((doc) => !!doc)\n\n const routeWithAdmin = `${adminRoute}${createFirstUserRoute}`\n\n if (!dbHasUser && currentRoute !== routeWithAdmin) {\n redirect(routeWithAdmin)\n }\n\n if (dbHasUser && currentRoute === routeWithAdmin) {\n redirect(adminRoute)\n }\n }\n\n const RenderedView = (\n <WithServerSideProps\n Component={DefaultView}\n serverOnlyProps={\n {\n initPageResult,\n params,\n searchParams,\n } as any\n }\n />\n )\n\n return (\n <Fragment>\n {!templateType && <Fragment>{RenderedView}</Fragment>}\n {templateType === 'minimal' && (\n <MinimalTemplate className={templateClassName}>{RenderedView}</MinimalTemplate>\n )}\n {templateType === 'default' && (\n <DefaultTemplate\n i18n={initPageResult?.req.i18n}\n locale={initPageResult?.locale}\n params={params}\n payload={initPageResult?.req.payload}\n permissions={initPageResult?.permissions}\n searchParams={searchParams}\n user={initPageResult?.req.user}\n visibleEntities={{\n // The reason we are not passing in initPageResult.visibleEntities directly is due to a \"Cannot assign to read only property of object '#<Object>\" error introduced in React 19\n // which this caused as soon as initPageResult.visibleEntities is passed in\n collections: initPageResult.visibleEntities?.collections,\n globals: initPageResult.visibleEntities?.globals,\n }}\n >\n {RenderedView}\n </DefaultTemplate>\n )}\n </Fragment>\n )\n}\n"],"names":["WithServerSideProps","DefaultTemplate","MinimalTemplate","notFound","redirect","React","Fragment","initPage","getViewFromConfig","generatePageMetadata","RootPage","config","configPromise","params","searchParams","admin","routes","createFirstUser","createFirstUserRoute","user","userSlug","adminRoute","currentRoute","Array","isArray","segments","join","DefaultView","initPageOptions","templateClassName","templateType","dbHasUser","initPageResult","req","payload","db","findOne","collection","then","doc","routeWithAdmin","RenderedView","Component","serverOnlyProps","className","i18n","locale","permissions","visibleEntities","collections","globals"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAIA,SAASA,mBAAmB,QAAQ,8CAA6C;AACjF,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,QAAQ,EAAEC,QAAQ,QAAQ,qBAAoB;AACvD,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAEvC,SAASC,QAAQ,QAAQ,oCAAmC;AAC5D,SAASC,iBAAiB,QAAQ,yBAAwB;AAE1D,SAASC,oBAAoB,QAAQ,YAAW;AAShD,OAAO,MAAMC,WAAW,OAAO,EAC7BC,QAAQC,aAAa,EACrBC,MAAM,EACNC,YAAY,EASb;IACC,MAAMH,SAAS,MAAMC;IAErB,MAAM,EACJG,OAAO,EACLC,QAAQ,EAAEC,iBAAiBC,oBAAoB,EAAE,EACjDC,MAAMC,QAAQ,EACf,EACDJ,QAAQ,EAAED,OAAOM,UAAU,EAAE,EAC9B,GAAGV;IAEJ,MAAMW,eAAe,CAAC,EAAED,WAAW,EAAEE,MAAMC,OAAO,CAACX,OAAOY,QAAQ,IAAI,CAAC,CAAC,EAAEZ,OAAOY,QAAQ,CAACC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;IAE5G,MAAMD,WAAWF,MAAMC,OAAO,CAACX,OAAOY,QAAQ,IAAIZ,OAAOY,QAAQ,GAAG,EAAE;IAEtE,MAAM,EAAEE,WAAW,EAAEC,eAAe,EAAEC,iBAAiB,EAAEC,YAAY,EAAE,GAAGtB,kBAAkB;QAC1Fa;QACAV;QACAW;QACAR;QACAW;IACF;IAEA,IAAIM,YAAY;IAEhB,IAAI,CAACJ,aAAa;QAChBxB;IACF;IAEA,MAAM6B,iBAAiB,MAAMzB,SAASqB;IAEtC,IAAII,gBAAgB;QAClBD,YAAY,MAAMC,gBAAgBC,IAAIC,QAAQC,GAC3CC,QAAQ;YACPC,YAAYjB;YACZa,KAAKD,gBAAgBC;QACvB,IACEK,KAAK,CAACC,MAAQ,CAAC,CAACA;QAEpB,MAAMC,iBAAiB,CAAC,EAAEnB,WAAW,EAAEH,qBAAqB,CAAC;QAE7D,IAAI,CAACa,aAAaT,iBAAiBkB,gBAAgB;YACjDpC,SAASoC;QACX;QAEA,IAAIT,aAAaT,iBAAiBkB,gBAAgB;YAChDpC,SAASiB;QACX;IACF;IAEA,MAAMoB,6BACJ,KAACzC;QACC0C,WAAWf;QACXgB,iBACE;YACEX;YACAnB;YACAC;QACF;;IAKN,qBACE,MAACR;;YACE,CAACwB,8BAAgB,KAACxB;0BAAUmC;;YAC5BX,iBAAiB,2BAChB,KAAC5B;gBAAgB0C,WAAWf;0BAAoBY;;YAEjDX,iBAAiB,2BAChB,KAAC7B;gBACC4C,MAAMb,gBAAgBC,IAAIY;gBAC1BC,QAAQd,gBAAgBc;gBACxBjC,QAAQA;gBACRqB,SAASF,gBAAgBC,IAAIC;gBAC7Ba,aAAaf,gBAAgBe;gBAC7BjC,cAAcA;gBACdK,MAAMa,gBAAgBC,IAAId;gBAC1B6B,iBAAiB;oBACf,+KAA+K;oBAC/K,2EAA2E;oBAC3EC,aAAajB,eAAegB,eAAe,EAAEC;oBAC7CC,SAASlB,eAAegB,eAAe,EAAEE;gBAC3C;0BAECT;;;;AAKX,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/next",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.37",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"react-toastify": "10.0.5",
|
|
45
45
|
"sass": "^1.71.1",
|
|
46
46
|
"ws": "^8.16.0",
|
|
47
|
-
"@payloadcms/translations": "3.0.0-beta.
|
|
48
|
-
"@payloadcms/
|
|
49
|
-
"@payloadcms/
|
|
47
|
+
"@payloadcms/translations": "3.0.0-beta.37",
|
|
48
|
+
"@payloadcms/graphql": "3.0.0-beta.37",
|
|
49
|
+
"@payloadcms/ui": "3.0.0-beta.37"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@next/eslint-plugin-next": "^14.1.0",
|
|
@@ -64,13 +64,13 @@
|
|
|
64
64
|
"terser-webpack-plugin": "^5.3.10",
|
|
65
65
|
"webpack": "^5.78.0",
|
|
66
66
|
"webpack-cli": "^5.1.4",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
67
|
+
"payload": "3.0.0-beta.37",
|
|
68
|
+
"@payloadcms/eslint-config": "1.1.1"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"graphql": "^16.8.1",
|
|
72
72
|
"next": "^15.0.0-rc.0",
|
|
73
|
-
"payload": "3.0.0-beta.
|
|
73
|
+
"payload": "3.0.0-beta.37"
|
|
74
74
|
},
|
|
75
75
|
"engines": {
|
|
76
76
|
"node": ">=18.20.2"
|