@payloadcms/next 3.4.0 → 3.4.1-canary.2a8fa30
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/routes/rest/collections/preview.d.ts.map +1 -1
- package/dist/routes/rest/collections/preview.js +4 -0
- package/dist/routes/rest/collections/preview.js.map +1 -1
- package/dist/views/LivePreview/index.d.ts.map +1 -1
- package/dist/views/LivePreview/index.js +5 -1
- package/dist/views/LivePreview/index.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/preview.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/preview.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,OAAO,EAAE,4BAiDrB,CAAA"}
|
|
@@ -29,6 +29,10 @@ export const preview = async ({
|
|
|
29
29
|
req,
|
|
30
30
|
token
|
|
31
31
|
});
|
|
32
|
+
// Support relative URLs by prepending the origin, if necessary
|
|
33
|
+
if (previewURL && previewURL.startsWith('/')) {
|
|
34
|
+
previewURL = `${req.protocol}//${req.host}${previewURL}`;
|
|
35
|
+
}
|
|
32
36
|
} catch (err) {
|
|
33
37
|
return routeError({
|
|
34
38
|
collection,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.js","names":["httpStatus","extractJWT","findByIDOperation","isNumber","headersWithCors","routeError","preview","id","collection","req","searchParams","depth","get","result","Number","undefined","draft","previewURL","generatePreviewURL","payload","config","collections","find","slug","admin","token","locale","err","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/preview.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { extractJWT, findByIDOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { routeError } from '../routeError.js'\n\nexport const preview: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const result = await findByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: searchParams.get('draft') === 'true',\n req,\n })\n\n let previewURL: string\n\n const generatePreviewURL = req.payload.config.collections.find(\n (config) => config.slug === collection.config.slug,\n )?.admin?.preview\n\n const token = extractJWT(req)\n\n if (typeof generatePreviewURL === 'function') {\n try {\n previewURL = await generatePreviewURL(result, {\n locale: req.locale,\n req,\n token,\n })\n } catch (err) {\n return routeError({\n collection,\n config: req.payload.config,\n err,\n req,\n })\n }\n }\n\n return Response.json(previewURL, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,UAAU,EAAEC,iBAAiB,QAAQ;AAC9C,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,UAAU,QAAQ;AAE3B,OAAO,MAAMC,OAAA,GAAwC,MAAAA,CAAO;EAAEC,EAAE;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACjF,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAE/B,MAAMC,MAAA,GAAS,MAAMX,iBAAA,CAAkB;IACrCK,EAAA;IACAC,UAAA;IACAG,KAAA,EAAOR,QAAA,CAASQ,KAAA,IAASG,MAAA,CAAOH,KAAA,IAASI,SAAA;IACzCC,KAAA,EAAON,YAAA,CAAaE,GAAG,CAAC,aAAa;IACrCH;EACF;EAEA,IAAIQ,UAAA;EAEJ,MAAMC,kBAAA,GAAqBT,GAAA,CAAIU,OAAO,CAACC,MAAM,CAACC,WAAW,CAACC,IAAI,CAC3DF,MAAA,IAAWA,MAAA,CAAOG,IAAI,KAAKf,UAAA,CAAWY,MAAM,CAACG,IAAI,GACjDC,KAAA,EAAOlB,OAAA;EAEV,MAAMmB,KAAA,GAAQxB,UAAA,CAAWQ,GAAA;EAEzB,IAAI,OAAOS,kBAAA,KAAuB,YAAY;IAC5C,IAAI;MACFD,UAAA,GAAa,MAAMC,kBAAA,CAAmBL,MAAA,EAAQ;QAC5Ca,MAAA,EAAQjB,GAAA,CAAIiB,MAAM;QAClBjB,GAAA;QACAgB;MACF;IACF,EAAE,
|
|
1
|
+
{"version":3,"file":"preview.js","names":["httpStatus","extractJWT","findByIDOperation","isNumber","headersWithCors","routeError","preview","id","collection","req","searchParams","depth","get","result","Number","undefined","draft","previewURL","generatePreviewURL","payload","config","collections","find","slug","admin","token","locale","startsWith","protocol","host","err","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/preview.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { extractJWT, findByIDOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { routeError } from '../routeError.js'\n\nexport const preview: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const result = await findByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: searchParams.get('draft') === 'true',\n req,\n })\n\n let previewURL: string\n\n const generatePreviewURL = req.payload.config.collections.find(\n (config) => config.slug === collection.config.slug,\n )?.admin?.preview\n\n const token = extractJWT(req)\n\n if (typeof generatePreviewURL === 'function') {\n try {\n previewURL = await generatePreviewURL(result, {\n locale: req.locale,\n req,\n token,\n })\n\n // Support relative URLs by prepending the origin, if necessary\n if (previewURL && previewURL.startsWith('/')) {\n previewURL = `${req.protocol}//${req.host}${previewURL}`\n }\n } catch (err) {\n return routeError({\n collection,\n config: req.payload.config,\n err,\n req,\n })\n }\n }\n\n return Response.json(previewURL, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,UAAU,EAAEC,iBAAiB,QAAQ;AAC9C,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,UAAU,QAAQ;AAE3B,OAAO,MAAMC,OAAA,GAAwC,MAAAA,CAAO;EAAEC,EAAE;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACjF,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAE/B,MAAMC,MAAA,GAAS,MAAMX,iBAAA,CAAkB;IACrCK,EAAA;IACAC,UAAA;IACAG,KAAA,EAAOR,QAAA,CAASQ,KAAA,IAASG,MAAA,CAAOH,KAAA,IAASI,SAAA;IACzCC,KAAA,EAAON,YAAA,CAAaE,GAAG,CAAC,aAAa;IACrCH;EACF;EAEA,IAAIQ,UAAA;EAEJ,MAAMC,kBAAA,GAAqBT,GAAA,CAAIU,OAAO,CAACC,MAAM,CAACC,WAAW,CAACC,IAAI,CAC3DF,MAAA,IAAWA,MAAA,CAAOG,IAAI,KAAKf,UAAA,CAAWY,MAAM,CAACG,IAAI,GACjDC,KAAA,EAAOlB,OAAA;EAEV,MAAMmB,KAAA,GAAQxB,UAAA,CAAWQ,GAAA;EAEzB,IAAI,OAAOS,kBAAA,KAAuB,YAAY;IAC5C,IAAI;MACFD,UAAA,GAAa,MAAMC,kBAAA,CAAmBL,MAAA,EAAQ;QAC5Ca,MAAA,EAAQjB,GAAA,CAAIiB,MAAM;QAClBjB,GAAA;QACAgB;MACF;MAEA;MACA,IAAIR,UAAA,IAAcA,UAAA,CAAWU,UAAU,CAAC,MAAM;QAC5CV,UAAA,GAAa,GAAGR,GAAA,CAAImB,QAAQ,KAAKnB,GAAA,CAAIoB,IAAI,GAAGZ,UAAA,EAAY;MAC1D;IACF,EAAE,OAAOa,GAAA,EAAK;MACZ,OAAOzB,UAAA,CAAW;QAChBG,UAAA;QACAY,MAAA,EAAQX,GAAA,CAAIU,OAAO,CAACC,MAAM;QAC1BU,GAAA;QACArB;MACF;IACF;EACF;EAEA,OAAOsB,QAAA,CAASC,IAAI,CAACf,UAAA,EAAY;IAC/BgB,OAAA,EAAS7B,eAAA,CAAgB;MACvB6B,OAAA,EAAS,IAAIC,OAAA;MACbzB;IACF;IACA0B,MAAA,EAAQnC,UAAA,CAAWoC;EACrB;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/LivePreview/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAqB,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAIhG,OAAO,cAAc,CAAA;AAGrB,eAAO,MAAM,eAAe,EAAE,2BAA2B,CAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/LivePreview/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAqB,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAIhG,OAAO,cAAc,CAAA;AAGrB,eAAO,MAAM,eAAe,EAAE,2BAA2B,CAAC,iBAAiB,CAgD1E,CAAA"}
|
|
@@ -31,13 +31,17 @@ export const LivePreviewView = async props => {
|
|
|
31
31
|
label: 'Responsive',
|
|
32
32
|
width: '100%'
|
|
33
33
|
}];
|
|
34
|
-
|
|
34
|
+
let url = typeof livePreviewConfig?.url === 'function' ? await livePreviewConfig.url({
|
|
35
35
|
collectionConfig,
|
|
36
36
|
data: doc,
|
|
37
37
|
globalConfig,
|
|
38
38
|
locale,
|
|
39
39
|
payload: initPageResult.req.payload
|
|
40
40
|
}) : livePreviewConfig?.url;
|
|
41
|
+
// Support relative URLs by prepending the origin, if necessary
|
|
42
|
+
if (url && url.startsWith('/')) {
|
|
43
|
+
url = `${initPageResult.req.protocol}//${initPageResult.req.host}${url}`;
|
|
44
|
+
}
|
|
41
45
|
return /*#__PURE__*/_jsx(LivePreviewClient, {
|
|
42
46
|
breakpoints: breakpoints,
|
|
43
47
|
initialData: doc,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","LivePreviewClient","LivePreviewView","props","doc","initPageResult","collectionConfig","globalConfig","locale","req","livePreviewConfig","payload","config","admin","livePreview","breakpoints","name","height","label","width","url","data","_jsx","initialData"],"sources":["../../../src/views/LivePreview/index.tsx"],"sourcesContent":["import type { EditViewComponent, LivePreviewConfig, PayloadServerReactComponent } from 'payload'\n\nimport React from 'react'\n\nimport './index.scss'\nimport { LivePreviewClient } from './index.client.js'\n\nexport const LivePreviewView: PayloadServerReactComponent<EditViewComponent> = async (props) => {\n const { doc, initPageResult } = props\n\n const { collectionConfig, globalConfig, locale, req } = initPageResult\n\n let livePreviewConfig: LivePreviewConfig = req.payload.config?.admin?.livePreview\n\n if (collectionConfig) {\n livePreviewConfig = {\n ...(livePreviewConfig || {}),\n ...(collectionConfig.admin.livePreview || {}),\n }\n }\n\n if (globalConfig) {\n livePreviewConfig = {\n ...(livePreviewConfig || {}),\n ...(globalConfig.admin.livePreview || {}),\n }\n }\n\n const breakpoints: LivePreviewConfig['breakpoints'] = [\n ...(livePreviewConfig?.breakpoints || []),\n {\n name: 'responsive',\n height: '100%',\n label: 'Responsive',\n width: '100%',\n },\n ]\n\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","LivePreviewClient","LivePreviewView","props","doc","initPageResult","collectionConfig","globalConfig","locale","req","livePreviewConfig","payload","config","admin","livePreview","breakpoints","name","height","label","width","url","data","startsWith","protocol","host","_jsx","initialData"],"sources":["../../../src/views/LivePreview/index.tsx"],"sourcesContent":["import type { EditViewComponent, LivePreviewConfig, PayloadServerReactComponent } from 'payload'\n\nimport React from 'react'\n\nimport './index.scss'\nimport { LivePreviewClient } from './index.client.js'\n\nexport const LivePreviewView: PayloadServerReactComponent<EditViewComponent> = async (props) => {\n const { doc, initPageResult } = props\n\n const { collectionConfig, globalConfig, locale, req } = initPageResult\n\n let livePreviewConfig: LivePreviewConfig = req.payload.config?.admin?.livePreview\n\n if (collectionConfig) {\n livePreviewConfig = {\n ...(livePreviewConfig || {}),\n ...(collectionConfig.admin.livePreview || {}),\n }\n }\n\n if (globalConfig) {\n livePreviewConfig = {\n ...(livePreviewConfig || {}),\n ...(globalConfig.admin.livePreview || {}),\n }\n }\n\n const breakpoints: LivePreviewConfig['breakpoints'] = [\n ...(livePreviewConfig?.breakpoints || []),\n {\n name: 'responsive',\n height: '100%',\n label: 'Responsive',\n width: '100%',\n },\n ]\n\n let url =\n typeof livePreviewConfig?.url === 'function'\n ? await livePreviewConfig.url({\n collectionConfig,\n data: doc,\n globalConfig,\n locale,\n payload: initPageResult.req.payload,\n })\n : livePreviewConfig?.url\n\n // Support relative URLs by prepending the origin, if necessary\n if (url && url.startsWith('/')) {\n url = `${initPageResult.req.protocol}//${initPageResult.req.host}${url}`\n }\n\n return <LivePreviewClient breakpoints={breakpoints} initialData={doc} url={url} />\n}\n"],"mappings":";AAEA,OAAOA,KAAA,MAAW;AAGlB,SAASC,iBAAiB,QAAQ;AAElC,OAAO,MAAMC,eAAA,GAAkE,MAAOC,KAAA;EACpF,MAAM;IAAEC,GAAG;IAAEC;EAAc,CAAE,GAAGF,KAAA;EAEhC,MAAM;IAAEG,gBAAgB;IAAEC,YAAY;IAAEC,MAAM;IAAEC;EAAG,CAAE,GAAGJ,cAAA;EAExD,IAAIK,iBAAA,GAAuCD,GAAA,CAAIE,OAAO,CAACC,MAAM,EAAEC,KAAA,EAAOC,WAAA;EAEtE,IAAIR,gBAAA,EAAkB;IACpBI,iBAAA,GAAoB;MAClB,IAAIA,iBAAA,IAAqB,CAAC,CAAC;MAC3B,IAAIJ,gBAAA,CAAiBO,KAAK,CAACC,WAAW,IAAI,CAAC,CAAC;IAC9C;EACF;EAEA,IAAIP,YAAA,EAAc;IAChBG,iBAAA,GAAoB;MAClB,IAAIA,iBAAA,IAAqB,CAAC,CAAC;MAC3B,IAAIH,YAAA,CAAaM,KAAK,CAACC,WAAW,IAAI,CAAC,CAAC;IAC1C;EACF;EAEA,MAAMC,WAAA,GAAgD,C,IAChDL,iBAAA,EAAmBK,WAAA,IAAe,EAAE,GACxC;IACEC,IAAA,EAAM;IACNC,MAAA,EAAQ;IACRC,KAAA,EAAO;IACPC,KAAA,EAAO;EACT,EACD;EAED,IAAIC,GAAA,GACF,OAAOV,iBAAA,EAAmBU,GAAA,KAAQ,aAC9B,MAAMV,iBAAA,CAAkBU,GAAG,CAAC;IAC1Bd,gBAAA;IACAe,IAAA,EAAMjB,GAAA;IACNG,YAAA;IACAC,MAAA;IACAG,OAAA,EAASN,cAAA,CAAeI,GAAG,CAACE;EAC9B,KACAD,iBAAA,EAAmBU,GAAA;EAEzB;EACA,IAAIA,GAAA,IAAOA,GAAA,CAAIE,UAAU,CAAC,MAAM;IAC9BF,GAAA,GAAM,GAAGf,cAAA,CAAeI,GAAG,CAACc,QAAQ,KAAKlB,cAAA,CAAeI,GAAG,CAACe,IAAI,GAAGJ,GAAA,EAAK;EAC1E;EAEA,oBAAOK,IAAA,CAACxB,iBAAA;IAAkBc,WAAA,EAAaA,WAAA;IAAaW,WAAA,EAAatB,GAAA;IAAKgB,GAAA,EAAKA;;AAC7E","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/next",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.1-canary.2a8fa30",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -79,9 +79,9 @@
|
|
|
79
79
|
"sass": "1.77.4",
|
|
80
80
|
"sonner": "^1.7.0",
|
|
81
81
|
"uuid": "10.0.0",
|
|
82
|
-
"@payloadcms/graphql": "3.4.
|
|
83
|
-
"@payloadcms/translations": "3.4.
|
|
84
|
-
"@payloadcms/ui": "3.4.
|
|
82
|
+
"@payloadcms/graphql": "3.4.1-canary.2a8fa30",
|
|
83
|
+
"@payloadcms/translations": "3.4.1-canary.2a8fa30",
|
|
84
|
+
"@payloadcms/ui": "3.4.1-canary.2a8fa30"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@babel/cli": "7.25.9",
|
|
@@ -99,13 +99,13 @@
|
|
|
99
99
|
"esbuild-sass-plugin": "3.3.1",
|
|
100
100
|
"eslint-plugin-react-compiler": "19.0.0-beta-df7b47d-20241124",
|
|
101
101
|
"swc-plugin-transform-remove-imports": "2.0.0",
|
|
102
|
-
"
|
|
103
|
-
"
|
|
102
|
+
"@payloadcms/eslint-config": "3.0.0",
|
|
103
|
+
"payload": "3.4.1-canary.2a8fa30"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
106
|
"graphql": "^16.8.1",
|
|
107
107
|
"next": "^15.0.0",
|
|
108
|
-
"payload": "3.4.
|
|
108
|
+
"payload": "3.4.1-canary.2a8fa30"
|
|
109
109
|
},
|
|
110
110
|
"engines": {
|
|
111
111
|
"node": "^18.20.2 || >=20.9.0"
|