@prismicio/next 2.3.4-pr.175.297ba88 → 2.3.4-pr.175.c252006
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/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/pages/exitPreview.cjs +2 -1
- package/dist/pages/exitPreview.cjs.map +1 -1
- package/dist/pages/exitPreview.d.cts.map +1 -1
- package/dist/pages/exitPreview.d.ts.map +1 -1
- package/dist/pages/exitPreview.js +2 -1
- package/dist/pages/exitPreview.js.map +1 -1
- package/package.json +1 -1
- package/src/pages/exitPreview.ts +5 -1
package/dist/package.cjs
CHANGED
package/dist/package.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_previewSessionCookie = require("../lib/previewSessionCookie.cjs");
|
|
2
2
|
const require_appendCookie = require("./appendCookie.cjs");
|
|
3
|
+
let _prismicio_client = require("@prismicio/client");
|
|
3
4
|
//#region src/pages/exitPreview.ts
|
|
4
5
|
/**
|
|
5
6
|
* Ends a Prismic preview session within a Next.js app. This function should be used in an API
|
|
@@ -18,7 +19,7 @@ const require_appendCookie = require("./appendCookie.cjs");
|
|
|
18
19
|
*/
|
|
19
20
|
function exitPreview(config) {
|
|
20
21
|
config.res.clearPreviewData();
|
|
21
|
-
require_appendCookie.appendCookie(config.res, `${
|
|
22
|
+
for (const name of [_prismicio_client.cookie.preview, require_previewSessionCookie.previewSessionCookie]) require_appendCookie.appendCookie(config.res, `${name}=; Expires=${(/* @__PURE__ */ new Date(0)).toUTCString()}`);
|
|
22
23
|
config.res.setHeader("Cache-Control", "no-store");
|
|
23
24
|
config.res.json({ success: true });
|
|
24
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.cjs","names":["previewSessionCookie"],"sources":["../../src/pages/exitPreview.ts"],"sourcesContent":["import { previewSessionCookie } from \"../lib/previewSessionCookie\"\nimport { appendCookie } from \"./appendCookie\"\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `exitPreview()`. */\nexport type ExitPreviewAPIRouteConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in an API\n * route.\n *\n * @example\n * \t;```typescript\n * \t// src/pages/api/exit-preview.js\n *\n * \timport { exitPreview } from \"@prismicio/next\"\n *\n * \texport default function handler(_req, res) {\n * \t\treturn exitPreview({ res })\n * \t}\n * \t```\n */\nexport function exitPreview(config: ExitPreviewAPIRouteConfig): void {\n\tconfig.res.clearPreviewData()\n\tappendCookie(config.res, `${
|
|
1
|
+
{"version":3,"file":"exitPreview.cjs","names":["prismicCookie","previewSessionCookie"],"sources":["../../src/pages/exitPreview.ts"],"sourcesContent":["import { cookie as prismicCookie } from \"@prismicio/client\"\n\nimport { previewSessionCookie } from \"../lib/previewSessionCookie\"\nimport { appendCookie } from \"./appendCookie\"\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `exitPreview()`. */\nexport type ExitPreviewAPIRouteConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in an API\n * route.\n *\n * @example\n * \t;```typescript\n * \t// src/pages/api/exit-preview.js\n *\n * \timport { exitPreview } from \"@prismicio/next\"\n *\n * \texport default function handler(_req, res) {\n * \t\treturn exitPreview({ res })\n * \t}\n * \t```\n */\nexport function exitPreview(config: ExitPreviewAPIRouteConfig): void {\n\tconfig.res.clearPreviewData()\n\tfor (const name of [prismicCookie.preview, previewSessionCookie]) {\n\t\tappendCookie(config.res, `${name}=; Expires=${new Date(0).toUTCString()}`)\n\t}\n\n\t// `Cache-Control` header is used to prevent CDN-level caching.\n\tconfig.res.setHeader(\"Cache-Control\", \"no-store\")\n\n\tconfig.res.json({ success: true })\n\n\treturn\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,YAAY,QAAyC;CACpE,OAAO,IAAI,iBAAiB;CAC5B,KAAK,MAAM,QAAQ,CAACA,kBAAAA,OAAc,SAASC,6BAAAA,oBAAoB,GAC9D,qBAAA,aAAa,OAAO,KAAK,GAAG,KAAK,8BAAa,IAAI,KAAK,CAAC,EAAA,CAAE,YAAY,GAAG;CAI1E,OAAO,IAAI,UAAU,iBAAiB,UAAU;CAEhD,OAAO,IAAI,KAAK,EAAE,SAAS,KAAK,CAAC;AAGlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.d.cts","names":[],"sources":["../../src/pages/exitPreview.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"exitPreview.d.cts","names":[],"sources":["../../src/pages/exitPreview.ts"],"mappings":";;;YAOY;;;;;;EAMX,MAAM;;;;;;EAON,KAAK;;;;;;;;;;;;;;;;;wBAkBU,YAAY,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.d.ts","names":[],"sources":["../../src/pages/exitPreview.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"exitPreview.d.ts","names":[],"sources":["../../src/pages/exitPreview.ts"],"mappings":";;;YAOY;;;;;;EAMX,MAAM;;;;;;EAON,KAAK;;;;;;;;;;;;;;;;;wBAkBU,YAAY,QAAQ"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { previewSessionCookie } from "../lib/previewSessionCookie.js";
|
|
2
2
|
import { appendCookie } from "./appendCookie.js";
|
|
3
|
+
import { cookie } from "@prismicio/client";
|
|
3
4
|
//#region src/pages/exitPreview.ts
|
|
4
5
|
/**
|
|
5
6
|
* Ends a Prismic preview session within a Next.js app. This function should be used in an API
|
|
@@ -18,7 +19,7 @@ import { appendCookie } from "./appendCookie.js";
|
|
|
18
19
|
*/
|
|
19
20
|
function exitPreview(config) {
|
|
20
21
|
config.res.clearPreviewData();
|
|
21
|
-
appendCookie(config.res, `${
|
|
22
|
+
for (const name of [cookie.preview, previewSessionCookie]) appendCookie(config.res, `${name}=; Expires=${(/* @__PURE__ */ new Date(0)).toUTCString()}`);
|
|
22
23
|
config.res.setHeader("Cache-Control", "no-store");
|
|
23
24
|
config.res.json({ success: true });
|
|
24
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exitPreview.js","names":[],"sources":["../../src/pages/exitPreview.ts"],"sourcesContent":["import { previewSessionCookie } from \"../lib/previewSessionCookie\"\nimport { appendCookie } from \"./appendCookie\"\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `exitPreview()`. */\nexport type ExitPreviewAPIRouteConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in an API\n * route.\n *\n * @example\n * \t;```typescript\n * \t// src/pages/api/exit-preview.js\n *\n * \timport { exitPreview } from \"@prismicio/next\"\n *\n * \texport default function handler(_req, res) {\n * \t\treturn exitPreview({ res })\n * \t}\n * \t```\n */\nexport function exitPreview(config: ExitPreviewAPIRouteConfig): void {\n\tconfig.res.clearPreviewData()\n\tappendCookie(config.res, `${
|
|
1
|
+
{"version":3,"file":"exitPreview.js","names":["prismicCookie"],"sources":["../../src/pages/exitPreview.ts"],"sourcesContent":["import { cookie as prismicCookie } from \"@prismicio/client\"\n\nimport { previewSessionCookie } from \"../lib/previewSessionCookie\"\nimport { appendCookie } from \"./appendCookie\"\nimport type { NextApiRequestLike, NextApiResponseLike } from \"./types\"\n\n/** Configuration for `exitPreview()`. */\nexport type ExitPreviewAPIRouteConfig = {\n\t/**\n\t * The `req` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\treq?: NextApiRequestLike\n\n\t/**\n\t * The `res` object from a Next.js API route.\n\t *\n\t * @see Next.js API route docs: \\<https://nextjs.org/docs/api-routes/introduction\\>\n\t */\n\tres: NextApiResponseLike\n}\n\n/**\n * Ends a Prismic preview session within a Next.js app. This function should be used in an API\n * route.\n *\n * @example\n * \t;```typescript\n * \t// src/pages/api/exit-preview.js\n *\n * \timport { exitPreview } from \"@prismicio/next\"\n *\n * \texport default function handler(_req, res) {\n * \t\treturn exitPreview({ res })\n * \t}\n * \t```\n */\nexport function exitPreview(config: ExitPreviewAPIRouteConfig): void {\n\tconfig.res.clearPreviewData()\n\tfor (const name of [prismicCookie.preview, previewSessionCookie]) {\n\t\tappendCookie(config.res, `${name}=; Expires=${new Date(0).toUTCString()}`)\n\t}\n\n\t// `Cache-Control` header is used to prevent CDN-level caching.\n\tconfig.res.setHeader(\"Cache-Control\", \"no-store\")\n\n\tconfig.res.json({ success: true })\n\n\treturn\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,YAAY,QAAyC;CACpE,OAAO,IAAI,iBAAiB;CAC5B,KAAK,MAAM,QAAQ,CAACA,OAAc,SAAS,oBAAoB,GAC9D,aAAa,OAAO,KAAK,GAAG,KAAK,8BAAa,IAAI,KAAK,CAAC,EAAA,CAAE,YAAY,GAAG;CAI1E,OAAO,IAAI,UAAU,iBAAiB,UAAU;CAEhD,OAAO,IAAI,KAAK,EAAE,SAAS,KAAK,CAAC;AAGlC"}
|
package/package.json
CHANGED
package/src/pages/exitPreview.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { cookie as prismicCookie } from "@prismicio/client"
|
|
2
|
+
|
|
1
3
|
import { previewSessionCookie } from "../lib/previewSessionCookie"
|
|
2
4
|
import { appendCookie } from "./appendCookie"
|
|
3
5
|
import type { NextApiRequestLike, NextApiResponseLike } from "./types"
|
|
@@ -36,7 +38,9 @@ export type ExitPreviewAPIRouteConfig = {
|
|
|
36
38
|
*/
|
|
37
39
|
export function exitPreview(config: ExitPreviewAPIRouteConfig): void {
|
|
38
40
|
config.res.clearPreviewData()
|
|
39
|
-
|
|
41
|
+
for (const name of [prismicCookie.preview, previewSessionCookie]) {
|
|
42
|
+
appendCookie(config.res, `${name}=; Expires=${new Date(0).toUTCString()}`)
|
|
43
|
+
}
|
|
40
44
|
|
|
41
45
|
// `Cache-Control` header is used to prevent CDN-level caching.
|
|
42
46
|
config.res.setHeader("Cache-Control", "no-store")
|