@prismicio/client 7.22.3-pr.479.36f36ab → 7.23.0-canary.4aca7e3

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/cookie.cjs CHANGED
@@ -1,7 +1,12 @@
1
1
  //#region src/cookie.ts
2
- var cookie_exports = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.cjs").__exportAll({ preview: () => preview });
2
+ var cookie_exports = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.cjs").__exportAll({
3
+ preview: () => preview,
4
+ previewSession: () => previewSession
5
+ });
3
6
  /** The well-known name of the cookie used to store a Prismic preview session's ref. */
4
7
  const preview = "io.prismic.preview";
8
+ /** The well-known name of the cookie used to store a Prismic preview session's ID. */
9
+ const previewSession = "io.prismic.previewSession";
5
10
  //#endregion
6
11
  Object.defineProperty(exports, "cookie_exports", {
7
12
  enumerable: true,
@@ -10,5 +15,6 @@ Object.defineProperty(exports, "cookie_exports", {
10
15
  }
11
16
  });
12
17
  exports.preview = preview;
18
+ exports.previewSession = previewSession;
13
19
 
14
20
  //# sourceMappingURL=cookie.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.cjs","names":[],"sources":["../src/cookie.ts"],"sourcesContent":["/** The well-known name of the cookie used to store a Prismic preview session's ref. */\nexport const preview = \"io.prismic.preview\"\n"],"mappings":";;;AACA,MAAa,UAAU"}
1
+ {"version":3,"file":"cookie.cjs","names":[],"sources":["../src/cookie.ts"],"sourcesContent":["/** The well-known name of the cookie used to store a Prismic preview session's ref. */\nexport const preview = \"io.prismic.preview\"\n\n/** The well-known name of the cookie used to store a Prismic preview session's ID. */\nexport const previewSession = \"io.prismic.previewSession\"\n"],"mappings":";;;;;;AACA,MAAa,UAAU;;AAGvB,MAAa,iBAAiB"}
package/dist/cookie.d.cts CHANGED
@@ -1,8 +1,10 @@
1
1
  declare namespace cookie_d_exports {
2
- export { preview };
2
+ export { preview, previewSession };
3
3
  }
4
4
  /** The well-known name of the cookie used to store a Prismic preview session's ref. */
5
5
  export declare const preview = "io.prismic.preview";
6
+ /** The well-known name of the cookie used to store a Prismic preview session's ID. */
7
+ export declare const previewSession = "io.prismic.previewSession";
6
8
  //#endregion
7
9
  export { cookie_d_exports };
8
10
  //# sourceMappingURL=cookie.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.d.cts","names":[],"sources":["../src/cookie.ts"],"mappings":";;;;qBACa"}
1
+ {"version":3,"file":"cookie.d.cts","names":[],"sources":["../src/cookie.ts"],"mappings":";;;;qBACa;;qBAGA"}
package/dist/cookie.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  declare namespace cookie_d_exports {
2
- export { preview };
2
+ export { preview, previewSession };
3
3
  }
4
4
  /** The well-known name of the cookie used to store a Prismic preview session's ref. */
5
5
  export declare const preview = "io.prismic.preview";
6
+ /** The well-known name of the cookie used to store a Prismic preview session's ID. */
7
+ export declare const previewSession = "io.prismic.previewSession";
6
8
  //#endregion
7
9
  export { cookie_d_exports };
8
10
  //# sourceMappingURL=cookie.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.d.ts","names":[],"sources":["../src/cookie.ts"],"mappings":";;;;qBACa"}
1
+ {"version":3,"file":"cookie.d.ts","names":[],"sources":["../src/cookie.ts"],"mappings":";;;;qBACa;;qBAGA"}
package/dist/cookie.js CHANGED
@@ -1,9 +1,14 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
2
  //#region src/cookie.ts
3
- var cookie_exports = /* @__PURE__ */ __exportAll({ preview: () => preview });
3
+ var cookie_exports = /* @__PURE__ */ __exportAll({
4
+ preview: () => preview,
5
+ previewSession: () => previewSession
6
+ });
4
7
  /** The well-known name of the cookie used to store a Prismic preview session's ref. */
5
8
  const preview = "io.prismic.preview";
9
+ /** The well-known name of the cookie used to store a Prismic preview session's ID. */
10
+ const previewSession = "io.prismic.previewSession";
6
11
  //#endregion
7
- export { cookie_exports, preview };
12
+ export { cookie_exports, preview, previewSession };
8
13
 
9
14
  //# sourceMappingURL=cookie.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.js","names":[],"sources":["../src/cookie.ts"],"sourcesContent":["/** The well-known name of the cookie used to store a Prismic preview session's ref. */\nexport const preview = \"io.prismic.preview\"\n"],"mappings":";;;;AACA,MAAa,UAAU"}
1
+ {"version":3,"file":"cookie.js","names":[],"sources":["../src/cookie.ts"],"sourcesContent":["/** The well-known name of the cookie used to store a Prismic preview session's ref. */\nexport const preview = \"io.prismic.preview\"\n\n/** The well-known name of the cookie used to store a Prismic preview session's ID. */\nexport const previewSession = \"io.prismic.previewSession\"\n"],"mappings":";;;;;;;AACA,MAAa,UAAU;;AAGvB,MAAa,iBAAiB"}
@@ -30,11 +30,16 @@ const require_isRepositoryName = require("./isRepositoryName.cjs");
30
30
  *
31
31
  * @param repositoryName - The name of the Prismic repository. For example, `"my-repo"` if the
32
32
  * repository URL is `my-repo.prismic.io`.
33
+ * @param config - Options that configure the toolbar URL.
33
34
  * @returns The URL for the given Prismic repository's Prismic Toolbar script.
34
35
  */
35
- const getToolbarSrc = (repositoryName) => {
36
- if (require_isRepositoryName.isRepositoryName(repositoryName)) return `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}`;
37
- else throw new require_errors.PrismicError(`An invalid Prismic repository name was given: ${repositoryName}`, void 0, void 0);
36
+ const getToolbarSrc = (repositoryName, config) => {
37
+ if (require_isRepositoryName.isRepositoryName(repositoryName)) {
38
+ const url = new URL(`${config?.host ?? "https://static.cdn.prismic.io"}/prismic.js`);
39
+ url.searchParams.set("repo", repositoryName);
40
+ if (config?.version) url.searchParams.set("v", config.version.toString());
41
+ return url.toString();
42
+ } else throw new require_errors.PrismicError(`An invalid Prismic repository name was given: ${repositoryName}`, void 0, void 0);
38
43
  };
39
44
  //#endregion
40
45
  exports.getToolbarSrc = getToolbarSrc;
@@ -1 +1 @@
1
- {"version":3,"file":"getToolbarSrc.cjs","names":["isRepositoryName","PrismicError"],"sources":["../src/getToolbarSrc.ts"],"sourcesContent":["import { PrismicError } from \"./errors\"\nimport { isRepositoryName } from \"./isRepositoryName\"\n\n/**\n * Returns the URL for a Prismic repository's Prismic Toolbar script. Use the URL to inject the\n * script into your app.\n *\n * @example\n * \t```typescriptreact\n * \t// In Next.js apps, use `next/script` in your `app/layout.tsx` file.\n *\n * \timport Script from \"next/script\";\n * \timport * as prismic from \"@prismicio/client\";\n *\n * \texport default function RootLayout({\n * \tchildren,\n * \t}: {\n * \tchildren: React.ReactNode,\n * \t}) {\n * \tconst toolbarSrc = prismic.getToolbarSrc(\"my-repo\");\n *\n * \treturn (\n * \t<html lang=\"en\">\n * \t<body>{children}</body>\n * \t<Script src={toolbarSrc} />\n * \t</html>\n * \t);\n * \t}\n * \t```\n *\n * @param repositoryName - The name of the Prismic repository. For example, `\"my-repo\"` if the\n * repository URL is `my-repo.prismic.io`.\n * @returns The URL for the given Prismic repository's Prismic Toolbar script.\n */\nexport const getToolbarSrc = <TRepositoryName extends string>(\n\trepositoryName: TRepositoryName,\n): `https://static.cdn.prismic.io/prismic.js?new=true&repo=${TRepositoryName}` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}` as const\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,iBACZ,mBACiF;CACjF,IAAIA,yBAAAA,iBAAiB,cAAc,GAClC,OAAO,0DAA0D;MAEjE,MAAM,IAAIC,eAAAA,aACT,iDAAiD,kBACjD,KAAA,GACA,KAAA,CACD;AAEF"}
1
+ {"version":3,"file":"getToolbarSrc.cjs","names":["isRepositoryName","PrismicError"],"sources":["../src/getToolbarSrc.ts"],"sourcesContent":["import { PrismicError } from \"./errors\"\nimport { isRepositoryName } from \"./isRepositoryName\"\n\n/**\n * Returns the URL for a Prismic repository's Prismic Toolbar script. Use the URL to inject the\n * script into your app.\n *\n * @example\n * \t```typescriptreact\n * \t// In Next.js apps, use `next/script` in your `app/layout.tsx` file.\n *\n * \timport Script from \"next/script\";\n * \timport * as prismic from \"@prismicio/client\";\n *\n * \texport default function RootLayout({\n * \tchildren,\n * \t}: {\n * \tchildren: React.ReactNode,\n * \t}) {\n * \tconst toolbarSrc = prismic.getToolbarSrc(\"my-repo\");\n *\n * \treturn (\n * \t<html lang=\"en\">\n * \t<body>{children}</body>\n * \t<Script src={toolbarSrc} />\n * \t</html>\n * \t);\n * \t}\n * \t```\n *\n * @param repositoryName - The name of the Prismic repository. For example, `\"my-repo\"` if the\n * repository URL is `my-repo.prismic.io`.\n * @param config - Options that configure the toolbar URL.\n * @returns The URL for the given Prismic repository's Prismic Toolbar script.\n */\nexport const getToolbarSrc = (\n\trepositoryName: string,\n\tconfig?: {\n\t\t/** The version of the Prismic Toolbar to load. Defaults to 4. */\n\t\tversion?: 4 | 5\n\t\t/**\n\t\t * The URL the toolbar script is loaded from, without a trailing slash. For example, a toolbar\n\t\t * preview build. Defaults to `https://static.cdn.prismic.io`.\n\t\t */\n\t\thost?: string\n\t},\n): string => {\n\tif (isRepositoryName(repositoryName)) {\n\t\tconst url = new URL(`${config?.host ?? \"https://static.cdn.prismic.io\"}/prismic.js`)\n\t\turl.searchParams.set(\"repo\", repositoryName)\n\t\tif (config?.version) url.searchParams.set(\"v\", config.version.toString())\n\n\t\treturn url.toString()\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,iBACZ,gBACA,WASY;CACZ,IAAIA,yBAAAA,iBAAiB,cAAc,GAAG;EACrC,MAAM,MAAM,IAAI,IAAI,GAAG,QAAQ,QAAQ,gCAAgC,YAAY;EACnF,IAAI,aAAa,IAAI,QAAQ,cAAc;EAC3C,IAAI,QAAQ,SAAS,IAAI,aAAa,IAAI,KAAK,OAAO,QAAQ,SAAS,CAAC;EAExE,OAAO,IAAI,SAAS;CACrB,OACC,MAAM,IAAIC,eAAAA,aACT,iDAAiD,kBACjD,KAAA,GACA,KAAA,CACD;AAEF"}
@@ -28,8 +28,17 @@
28
28
  *
29
29
  * @param repositoryName - The name of the Prismic repository. For example, `"my-repo"` if the
30
30
  * repository URL is `my-repo.prismic.io`.
31
+ * @param config - Options that configure the toolbar URL.
31
32
  * @returns The URL for the given Prismic repository's Prismic Toolbar script.
32
33
  */
33
- export declare const getToolbarSrc: <TRepositoryName extends string>(repositoryName: TRepositoryName) => `https://static.cdn.prismic.io/prismic.js?new=true&repo=${TRepositoryName}`;
34
+ export declare const getToolbarSrc: (repositoryName: string, config?: {
35
+ /** The version of the Prismic Toolbar to load. Defaults to 4. */
36
+ version?: 4 | 5;
37
+ /**
38
+ * The URL the toolbar script is loaded from, without a trailing slash. For example, a toolbar
39
+ * preview build. Defaults to `https://static.cdn.prismic.io`.
40
+ */
41
+ host?: string;
42
+ }) => string;
34
43
  //#endregion
35
44
  //# sourceMappingURL=getToolbarSrc.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getToolbarSrc.d.cts","names":[],"sources":["../src/getToolbarSrc.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAkCa,gBAAiB,gCAA8B,gBAC3C,8EAC4C"}
1
+ {"version":3,"file":"getToolbarSrc.d.cts","names":[],"sources":["../src/getToolbarSrc.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAmCa,gBAAa,wBACH;;EAGrB;;;;;EAKA"}
@@ -28,8 +28,17 @@
28
28
  *
29
29
  * @param repositoryName - The name of the Prismic repository. For example, `"my-repo"` if the
30
30
  * repository URL is `my-repo.prismic.io`.
31
+ * @param config - Options that configure the toolbar URL.
31
32
  * @returns The URL for the given Prismic repository's Prismic Toolbar script.
32
33
  */
33
- export declare const getToolbarSrc: <TRepositoryName extends string>(repositoryName: TRepositoryName) => `https://static.cdn.prismic.io/prismic.js?new=true&repo=${TRepositoryName}`;
34
+ export declare const getToolbarSrc: (repositoryName: string, config?: {
35
+ /** The version of the Prismic Toolbar to load. Defaults to 4. */
36
+ version?: 4 | 5;
37
+ /**
38
+ * The URL the toolbar script is loaded from, without a trailing slash. For example, a toolbar
39
+ * preview build. Defaults to `https://static.cdn.prismic.io`.
40
+ */
41
+ host?: string;
42
+ }) => string;
34
43
  //#endregion
35
44
  //# sourceMappingURL=getToolbarSrc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getToolbarSrc.d.ts","names":[],"sources":["../src/getToolbarSrc.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAkCa,gBAAiB,gCAA8B,gBAC3C,8EAC4C"}
1
+ {"version":3,"file":"getToolbarSrc.d.ts","names":[],"sources":["../src/getToolbarSrc.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAmCa,gBAAa,wBACH;;EAGrB;;;;;EAKA"}
@@ -30,11 +30,16 @@ import { isRepositoryName } from "./isRepositoryName.js";
30
30
  *
31
31
  * @param repositoryName - The name of the Prismic repository. For example, `"my-repo"` if the
32
32
  * repository URL is `my-repo.prismic.io`.
33
+ * @param config - Options that configure the toolbar URL.
33
34
  * @returns The URL for the given Prismic repository's Prismic Toolbar script.
34
35
  */
35
- const getToolbarSrc = (repositoryName) => {
36
- if (isRepositoryName(repositoryName)) return `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}`;
37
- else throw new PrismicError(`An invalid Prismic repository name was given: ${repositoryName}`, void 0, void 0);
36
+ const getToolbarSrc = (repositoryName, config) => {
37
+ if (isRepositoryName(repositoryName)) {
38
+ const url = new URL(`${config?.host ?? "https://static.cdn.prismic.io"}/prismic.js`);
39
+ url.searchParams.set("repo", repositoryName);
40
+ if (config?.version) url.searchParams.set("v", config.version.toString());
41
+ return url.toString();
42
+ } else throw new PrismicError(`An invalid Prismic repository name was given: ${repositoryName}`, void 0, void 0);
38
43
  };
39
44
  //#endregion
40
45
  export { getToolbarSrc };
@@ -1 +1 @@
1
- {"version":3,"file":"getToolbarSrc.js","names":[],"sources":["../src/getToolbarSrc.ts"],"sourcesContent":["import { PrismicError } from \"./errors\"\nimport { isRepositoryName } from \"./isRepositoryName\"\n\n/**\n * Returns the URL for a Prismic repository's Prismic Toolbar script. Use the URL to inject the\n * script into your app.\n *\n * @example\n * \t```typescriptreact\n * \t// In Next.js apps, use `next/script` in your `app/layout.tsx` file.\n *\n * \timport Script from \"next/script\";\n * \timport * as prismic from \"@prismicio/client\";\n *\n * \texport default function RootLayout({\n * \tchildren,\n * \t}: {\n * \tchildren: React.ReactNode,\n * \t}) {\n * \tconst toolbarSrc = prismic.getToolbarSrc(\"my-repo\");\n *\n * \treturn (\n * \t<html lang=\"en\">\n * \t<body>{children}</body>\n * \t<Script src={toolbarSrc} />\n * \t</html>\n * \t);\n * \t}\n * \t```\n *\n * @param repositoryName - The name of the Prismic repository. For example, `\"my-repo\"` if the\n * repository URL is `my-repo.prismic.io`.\n * @returns The URL for the given Prismic repository's Prismic Toolbar script.\n */\nexport const getToolbarSrc = <TRepositoryName extends string>(\n\trepositoryName: TRepositoryName,\n): `https://static.cdn.prismic.io/prismic.js?new=true&repo=${TRepositoryName}` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}` as const\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,iBACZ,mBACiF;CACjF,IAAI,iBAAiB,cAAc,GAClC,OAAO,0DAA0D;MAEjE,MAAM,IAAI,aACT,iDAAiD,kBACjD,KAAA,GACA,KAAA,CACD;AAEF"}
1
+ {"version":3,"file":"getToolbarSrc.js","names":[],"sources":["../src/getToolbarSrc.ts"],"sourcesContent":["import { PrismicError } from \"./errors\"\nimport { isRepositoryName } from \"./isRepositoryName\"\n\n/**\n * Returns the URL for a Prismic repository's Prismic Toolbar script. Use the URL to inject the\n * script into your app.\n *\n * @example\n * \t```typescriptreact\n * \t// In Next.js apps, use `next/script` in your `app/layout.tsx` file.\n *\n * \timport Script from \"next/script\";\n * \timport * as prismic from \"@prismicio/client\";\n *\n * \texport default function RootLayout({\n * \tchildren,\n * \t}: {\n * \tchildren: React.ReactNode,\n * \t}) {\n * \tconst toolbarSrc = prismic.getToolbarSrc(\"my-repo\");\n *\n * \treturn (\n * \t<html lang=\"en\">\n * \t<body>{children}</body>\n * \t<Script src={toolbarSrc} />\n * \t</html>\n * \t);\n * \t}\n * \t```\n *\n * @param repositoryName - The name of the Prismic repository. For example, `\"my-repo\"` if the\n * repository URL is `my-repo.prismic.io`.\n * @param config - Options that configure the toolbar URL.\n * @returns The URL for the given Prismic repository's Prismic Toolbar script.\n */\nexport const getToolbarSrc = (\n\trepositoryName: string,\n\tconfig?: {\n\t\t/** The version of the Prismic Toolbar to load. Defaults to 4. */\n\t\tversion?: 4 | 5\n\t\t/**\n\t\t * The URL the toolbar script is loaded from, without a trailing slash. For example, a toolbar\n\t\t * preview build. Defaults to `https://static.cdn.prismic.io`.\n\t\t */\n\t\thost?: string\n\t},\n): string => {\n\tif (isRepositoryName(repositoryName)) {\n\t\tconst url = new URL(`${config?.host ?? \"https://static.cdn.prismic.io\"}/prismic.js`)\n\t\turl.searchParams.set(\"repo\", repositoryName)\n\t\tif (config?.version) url.searchParams.set(\"v\", config.version.toString())\n\n\t\treturn url.toString()\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,iBACZ,gBACA,WASY;CACZ,IAAI,iBAAiB,cAAc,GAAG;EACrC,MAAM,MAAM,IAAI,IAAI,GAAG,QAAQ,QAAQ,gCAAgC,YAAY;EACnF,IAAI,aAAa,IAAI,QAAQ,cAAc;EAC3C,IAAI,QAAQ,SAAS,IAAI,aAAa,IAAI,KAAK,OAAO,QAAQ,SAAS,CAAC;EAExE,OAAO,IAAI,SAAS;CACrB,OACC,MAAM,IAAI,aACT,iDAAiD,kBACjD,KAAA,GACA,KAAA,CACD;AAEF"}
package/dist/package.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region package.json
2
2
  var name = "@prismicio/client";
3
- var version = "7.22.3-pr.479.36f36ab";
3
+ var version = "7.23.0-canary.4aca7e3";
4
4
  //#endregion
5
5
  Object.defineProperty(exports, "name", {
6
6
  enumerable: true,
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region package.json
2
2
  var name = "@prismicio/client";
3
- var version = "7.22.3-pr.479.36f36ab";
3
+ var version = "7.23.0-canary.4aca7e3";
4
4
  //#endregion
5
5
  export { name, version };
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/client",
3
- "version": "7.22.3-pr.479.36f36ab",
3
+ "version": "7.23.0-canary.4aca7e3",
4
4
  "description": "The official JavaScript + TypeScript client library for Prismic",
5
5
  "keywords": [
6
6
  "client",
package/src/cookie.ts CHANGED
@@ -1,2 +1,5 @@
1
1
  /** The well-known name of the cookie used to store a Prismic preview session's ref. */
2
2
  export const preview = "io.prismic.preview"
3
+
4
+ /** The well-known name of the cookie used to store a Prismic preview session's ID. */
5
+ export const previewSession = "io.prismic.previewSession"
@@ -30,13 +30,27 @@ import { isRepositoryName } from "./isRepositoryName"
30
30
  *
31
31
  * @param repositoryName - The name of the Prismic repository. For example, `"my-repo"` if the
32
32
  * repository URL is `my-repo.prismic.io`.
33
+ * @param config - Options that configure the toolbar URL.
33
34
  * @returns The URL for the given Prismic repository's Prismic Toolbar script.
34
35
  */
35
- export const getToolbarSrc = <TRepositoryName extends string>(
36
- repositoryName: TRepositoryName,
37
- ): `https://static.cdn.prismic.io/prismic.js?new=true&repo=${TRepositoryName}` => {
36
+ export const getToolbarSrc = (
37
+ repositoryName: string,
38
+ config?: {
39
+ /** The version of the Prismic Toolbar to load. Defaults to 4. */
40
+ version?: 4 | 5
41
+ /**
42
+ * The URL the toolbar script is loaded from, without a trailing slash. For example, a toolbar
43
+ * preview build. Defaults to `https://static.cdn.prismic.io`.
44
+ */
45
+ host?: string
46
+ },
47
+ ): string => {
38
48
  if (isRepositoryName(repositoryName)) {
39
- return `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}` as const
49
+ const url = new URL(`${config?.host ?? "https://static.cdn.prismic.io"}/prismic.js`)
50
+ url.searchParams.set("repo", repositoryName)
51
+ if (config?.version) url.searchParams.set("v", config.version.toString())
52
+
53
+ return url.toString()
40
54
  } else {
41
55
  throw new PrismicError(
42
56
  `An invalid Prismic repository name was given: ${repositoryName}`,