@prismicio/client 7.22.3-pr.477.05c1a53 → 7.22.3-pr.477.578edad
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/getToolbarSrc.cjs +6 -2
- package/dist/getToolbarSrc.cjs.map +1 -1
- package/dist/getToolbarSrc.d.cts +5 -0
- package/dist/getToolbarSrc.d.cts.map +1 -1
- package/dist/getToolbarSrc.d.ts +5 -0
- package/dist/getToolbarSrc.d.ts.map +1 -1
- package/dist/getToolbarSrc.js +6 -2
- package/dist/getToolbarSrc.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/package.json +1 -1
- package/src/getToolbarSrc.ts +10 -1
package/dist/getToolbarSrc.cjs
CHANGED
|
@@ -34,8 +34,12 @@ const require_isRepositoryName = require("./isRepositoryName.cjs");
|
|
|
34
34
|
* @returns The URL for the given Prismic repository's Prismic Toolbar script.
|
|
35
35
|
*/
|
|
36
36
|
const getToolbarSrc = (repositoryName, config) => {
|
|
37
|
-
if (require_isRepositoryName.isRepositoryName(repositoryName))
|
|
38
|
-
|
|
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);
|
|
39
43
|
};
|
|
40
44
|
//#endregion
|
|
41
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 * @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},\n): string => {\n\tif (isRepositoryName(repositoryName)) {\n\t\
|
|
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"}
|
package/dist/getToolbarSrc.d.cts
CHANGED
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
export declare const getToolbarSrc: (repositoryName: string, config?: {
|
|
35
35
|
/** The version of the Prismic Toolbar to load. Defaults to 4. */
|
|
36
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;
|
|
37
42
|
}) => string;
|
|
38
43
|
//#endregion
|
|
39
44
|
//# sourceMappingURL=getToolbarSrc.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getToolbarSrc.d.cts","names":[],"sources":["../src/getToolbarSrc.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAmCa,gBAAa,wBACH;;EAGrB"}
|
|
1
|
+
{"version":3,"file":"getToolbarSrc.d.cts","names":[],"sources":["../src/getToolbarSrc.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAmCa,gBAAa,wBACH;;EAGrB;;;;;EAKA"}
|
package/dist/getToolbarSrc.d.ts
CHANGED
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
export declare const getToolbarSrc: (repositoryName: string, config?: {
|
|
35
35
|
/** The version of the Prismic Toolbar to load. Defaults to 4. */
|
|
36
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;
|
|
37
42
|
}) => string;
|
|
38
43
|
//#endregion
|
|
39
44
|
//# sourceMappingURL=getToolbarSrc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getToolbarSrc.d.ts","names":[],"sources":["../src/getToolbarSrc.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAmCa,gBAAa,wBACH;;EAGrB"}
|
|
1
|
+
{"version":3,"file":"getToolbarSrc.d.ts","names":[],"sources":["../src/getToolbarSrc.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAmCa,gBAAa,wBACH;;EAGrB;;;;;EAKA"}
|
package/dist/getToolbarSrc.js
CHANGED
|
@@ -34,8 +34,12 @@ import { isRepositoryName } from "./isRepositoryName.js";
|
|
|
34
34
|
* @returns The URL for the given Prismic repository's Prismic Toolbar script.
|
|
35
35
|
*/
|
|
36
36
|
const getToolbarSrc = (repositoryName, config) => {
|
|
37
|
-
if (isRepositoryName(repositoryName))
|
|
38
|
-
|
|
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);
|
|
39
43
|
};
|
|
40
44
|
//#endregion
|
|
41
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 * @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},\n): string => {\n\tif (isRepositoryName(repositoryName)) {\n\t\
|
|
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
package/dist/package.js
CHANGED
package/package.json
CHANGED
package/src/getToolbarSrc.ts
CHANGED
|
@@ -38,10 +38,19 @@ export const getToolbarSrc = (
|
|
|
38
38
|
config?: {
|
|
39
39
|
/** The version of the Prismic Toolbar to load. Defaults to 4. */
|
|
40
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
|
|
41
46
|
},
|
|
42
47
|
): string => {
|
|
43
48
|
if (isRepositoryName(repositoryName)) {
|
|
44
|
-
|
|
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()
|
|
45
54
|
} else {
|
|
46
55
|
throw new PrismicError(
|
|
47
56
|
`An invalid Prismic repository name was given: ${repositoryName}`,
|