@nuxtjs/prismic 4.0.0 → 4.1.0-pr.235.94cfeb5
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/LICENSE +1 -1
- package/README.md +18 -32
- package/dist/module.d.mts +48 -75
- package/dist/module.json +3 -3
- package/dist/module.mjs +193 -242
- package/dist/runtime/PrismicPreview.d.vue.ts +3 -0
- package/dist/runtime/PrismicPreview.vue +8 -14
- package/dist/runtime/PrismicPreview.vue.d.ts +3 -0
- package/dist/runtime/plugin.client.js +13 -7
- package/dist/runtime/plugin.js +89 -72
- package/dist/runtime/usePrismicPreview.d.ts +1 -5
- package/dist/runtime/usePrismicPreview.js +3 -3
- package/dist/types.d.mts +3 -1
- package/package.json +38 -45
- package/src/module.ts +352 -185
- package/src/runtime/PrismicPreview.vue +12 -16
- package/src/runtime/plugin.client.ts +16 -12
- package/src/runtime/plugin.ts +114 -103
- package/src/runtime/usePrismicPreview.ts +7 -11
- package/dist/client/200.html +0 -1
- package/dist/client/404.html +0 -1
- package/dist/client/_nuxt/BMD6bpEv.js +0 -1
- package/dist/client/_nuxt/BQB6UGbx.js +0 -25
- package/dist/client/_nuxt/CkG7IjgS.js +0 -1
- package/dist/client/_nuxt/DlAUqK2U.js +0 -1
- package/dist/client/_nuxt/H1okkFcd.js +0 -1
- package/dist/client/_nuxt/RYS3n4u0.js +0 -1
- package/dist/client/_nuxt/V_weDLQm.js +0 -1
- package/dist/client/_nuxt/builds/latest.json +0 -1
- package/dist/client/_nuxt/builds/meta/ef21bbff-0463-480b-852c-adffad3f33b7.json +0 -1
- package/dist/client/_nuxt/entry.BC9BDAld.css +0 -1
- package/dist/client/_nuxt/error-404.smTsHvdw.css +0 -1
- package/dist/client/_nuxt/error-500.Bo-s0s94.css +0 -1
- package/dist/client/_nuxt/index.C4BggqQh.css +0 -1
- package/dist/client/index.html +0 -1
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -136
- package/dist/types.d.ts +0 -1
- package/src/devtools/index.ts +0 -127
- package/src/devtools/types.ts +0 -22
- package/src/lib/fileExists.ts +0 -15
- package/src/lib/index.ts +0 -2
- package/src/lib/logger.ts +0 -3
- package/src/types.ts +0 -137
package/dist/runtime/plugin.js
CHANGED
|
@@ -1,94 +1,111 @@
|
|
|
1
|
-
import { createClient } from "@prismicio/client";
|
|
2
|
-
import { createPrismic } from "@prismicio/vue";
|
|
3
1
|
import { defineNuxtPlugin } from "#app";
|
|
4
2
|
import NuxtLink from "#app/components/nuxt-link";
|
|
5
|
-
import { useCookie, useRequestEvent, onNuxtReady, refreshNuxtData, useHead, useRuntimeConfig, useRouter } from "#imports";
|
|
6
3
|
import _client from "#build/prismic/proxy/client";
|
|
4
|
+
import defaultComponents from "#build/prismic/proxy/defaultComponents";
|
|
7
5
|
import linkResolver from "#build/prismic/proxy/linkResolver";
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
import {
|
|
7
|
+
onNuxtReady,
|
|
8
|
+
refreshNuxtData,
|
|
9
|
+
useCookie,
|
|
10
|
+
useHead,
|
|
11
|
+
useRequestEvent,
|
|
12
|
+
useRouter,
|
|
13
|
+
useRuntimeConfig
|
|
14
|
+
} from "#imports";
|
|
15
|
+
import { Client, createClient } from "@prismicio/client";
|
|
16
|
+
import { createPrismic } from "@prismicio/vue";
|
|
12
17
|
export default defineNuxtPlugin({
|
|
13
18
|
name: "prismic:setup",
|
|
14
19
|
parallel: true,
|
|
15
20
|
async setup(nuxtApp) {
|
|
16
21
|
const options = useRuntimeConfig().public.prismic;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const client = await resolveClient();
|
|
23
|
+
handlePreview();
|
|
24
|
+
addToolbar();
|
|
25
|
+
async function resolveClient() {
|
|
26
|
+
if (_client instanceof Client) {
|
|
27
|
+
return _client;
|
|
28
|
+
} else if (typeof _client === "function") {
|
|
29
|
+
try {
|
|
30
|
+
return await nuxtApp.runWithContext(
|
|
31
|
+
() => _client()
|
|
32
|
+
);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.error(
|
|
35
|
+
"[@nuxtjs/prismic] An error happened while resolving your Prismic custom client, disabling Prismic module gracefully...",
|
|
36
|
+
error
|
|
37
|
+
);
|
|
38
|
+
return createClient(
|
|
39
|
+
"error-resolving-custom-client",
|
|
40
|
+
options.clientConfig
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
return createClient(
|
|
45
|
+
options.environment || options.endpoint || "endpoint-not-provided",
|
|
46
|
+
options.clientConfig
|
|
26
47
|
);
|
|
27
48
|
}
|
|
28
|
-
} else {
|
|
29
|
-
client = _client;
|
|
30
49
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
injectComponents: false,
|
|
40
|
-
// Handled at module level
|
|
41
|
-
components: {
|
|
42
|
-
linkInternalComponent: NuxtLink,
|
|
43
|
-
linkExternalComponent: NuxtLink,
|
|
44
|
-
...options.components,
|
|
45
|
-
linkRel,
|
|
46
|
-
richTextComponents,
|
|
47
|
-
sliceZoneDefaultComponent
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
nuxtApp.vueApp.use(prismicPlugin);
|
|
51
|
-
if (options.preview) {
|
|
52
|
-
const previewCookie = useCookie("io.prismic.preview").value;
|
|
53
|
-
if (import.meta.server) {
|
|
54
|
-
const req = useRequestEvent()?.node.req;
|
|
55
|
-
if (req) {
|
|
56
|
-
prismicPlugin.client.enableAutoPreviewsFromReq(req);
|
|
50
|
+
function handlePreview() {
|
|
51
|
+
if (options.preview) {
|
|
52
|
+
const previewCookie = useCookie("io.prismic.preview").value;
|
|
53
|
+
if (import.meta.server) {
|
|
54
|
+
const req = useRequestEvent()?.node.req;
|
|
55
|
+
if (req) {
|
|
56
|
+
client.enableAutoPreviewsFromReq(req);
|
|
57
|
+
}
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
if (previewCookie) {
|
|
60
|
+
try {
|
|
61
|
+
const session = typeof previewCookie === "string" ? JSON.parse(decodeURIComponent(previewCookie)) : previewCookie;
|
|
62
|
+
if (Object.keys(session).some(
|
|
63
|
+
(key) => key in session && typeof session[key] === "object" && session[key] !== null && "preview" in session[key] && session[key].preview
|
|
64
|
+
)) {
|
|
65
|
+
let afterEachCalled = false;
|
|
66
|
+
onNuxtReady(() => {
|
|
67
|
+
if (!afterEachCalled) {
|
|
68
|
+
refreshNuxtData();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
useRouter().afterEach(() => {
|
|
72
|
+
afterEachCalled = true;
|
|
66
73
|
refreshNuxtData();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
refreshNuxtData();
|
|
72
|
-
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.warn("Failed to parse Prismic preview cookie", error);
|
|
73
78
|
}
|
|
74
|
-
} catch (error) {
|
|
75
|
-
console.warn("Failed to parse Prismic preview cookie", error);
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
function addToolbar() {
|
|
83
|
+
if (options.toolbar) {
|
|
84
|
+
useHead({
|
|
85
|
+
script: [
|
|
86
|
+
{
|
|
87
|
+
key: "prismic-preview",
|
|
88
|
+
src: `https://static.cdn.prismic.io/prismic.min.js?repo=${client.repositoryName}&new=true`,
|
|
89
|
+
async: true,
|
|
90
|
+
defer: true,
|
|
91
|
+
crossorigin: "anonymous"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
} else {
|
|
96
|
+
useCookie("io.prismic.preview").value = null;
|
|
97
|
+
}
|
|
91
98
|
}
|
|
99
|
+
const prismicPlugin = createPrismic({
|
|
100
|
+
client,
|
|
101
|
+
componentsConfig: {
|
|
102
|
+
linkResolver,
|
|
103
|
+
linkInternalComponent: NuxtLink,
|
|
104
|
+
linkExternalComponent: NuxtLink,
|
|
105
|
+
defaultComponents
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
nuxtApp.vueApp.use(prismicPlugin);
|
|
92
109
|
return {
|
|
93
110
|
provide: { prismic: prismicPlugin }
|
|
94
111
|
};
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolves Prismic previews on the preview entry page (`/preview`)
|
|
3
|
-
*
|
|
4
|
-
* @param defaultURL - The default URL to redirect to if the previewed document doesn't map to one.
|
|
5
|
-
*/
|
|
1
|
+
/** Resolves Prismic previews on the preview entry page (`/preview`) */
|
|
6
2
|
export declare const usePrismicPreview: (defaultURL?: string) => void;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { usePrismic, useRouter } from "#imports";
|
|
1
2
|
import { onMounted } from "vue";
|
|
2
|
-
import { useRouter, usePrismic } from "#imports";
|
|
3
3
|
export const usePrismicPreview = (defaultURL = "/") => {
|
|
4
|
-
const { client,
|
|
4
|
+
const { client, componentsConfig } = usePrismic();
|
|
5
5
|
const { push } = useRouter();
|
|
6
6
|
onMounted(async () => {
|
|
7
7
|
const redirectURL = await client.resolvePreviewURL({
|
|
8
|
-
linkResolver,
|
|
8
|
+
linkResolver: componentsConfig.linkResolver,
|
|
9
9
|
defaultURL
|
|
10
10
|
});
|
|
11
11
|
push(redirectURL);
|
package/dist/types.d.mts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtjs/prismic",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.1.0-pr.235.94cfeb5",
|
|
4
4
|
"description": "Easily connect your Nuxt application to your content hosted on Prismic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nuxt",
|
|
@@ -19,71 +19,64 @@
|
|
|
19
19
|
"type": "module",
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
|
-
"types": "./dist/types.d.
|
|
23
|
-
"import": "./dist/module.mjs"
|
|
24
|
-
"require": "./dist/module.cjs"
|
|
22
|
+
"types": "./dist/types.d.mts",
|
|
23
|
+
"import": "./dist/module.mjs"
|
|
25
24
|
},
|
|
26
25
|
"./runtime/*": "./dist/runtime/*",
|
|
27
26
|
"./package.json": "./package.json"
|
|
28
27
|
},
|
|
29
|
-
"main": "dist/module.
|
|
30
|
-
"
|
|
28
|
+
"main": "./dist/module.mjs",
|
|
29
|
+
"typesVersions": {
|
|
30
|
+
"*": {
|
|
31
|
+
".": [
|
|
32
|
+
"./dist/types.d.mts"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
31
36
|
"files": [
|
|
32
|
-
"dist",
|
|
33
|
-
"src"
|
|
37
|
+
"./dist",
|
|
38
|
+
"./src"
|
|
34
39
|
],
|
|
35
40
|
"scripts": {
|
|
36
|
-
"build": "
|
|
37
|
-
"build:client": "nuxt generate client",
|
|
38
|
-
"build:module": "nuxt-module-build build",
|
|
41
|
+
"build": "nuxt-module-build build",
|
|
39
42
|
"dev": "nuxt dev playground",
|
|
40
43
|
"dev:build": "nuxt build playground",
|
|
41
44
|
"dev:preview": "nuxt preview playground",
|
|
42
45
|
"dev:generate": "nuxt generate playground",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"release:rc:dry": "standard-version --release-as major --prerelease rc --dry-run",
|
|
48
|
-
"lint": "eslint .",
|
|
49
|
-
"typecheck": "tsc --noEmit",
|
|
46
|
+
"format": "prettier --write .",
|
|
47
|
+
"prepare": "nuxt-module-build prepare && npm run build",
|
|
48
|
+
"lint": "oxlint --deny-warnings",
|
|
49
|
+
"types": "vue-tsc --noEmit",
|
|
50
50
|
"unit": "vitest run --coverage",
|
|
51
51
|
"unit:watch": "vitest watch",
|
|
52
|
-
"test": "npm run
|
|
52
|
+
"test": "npm run lint && npm run types && npm run unit && npm run build"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@nuxt/
|
|
56
|
-
"@
|
|
57
|
-
"@prismicio/
|
|
58
|
-
"
|
|
59
|
-
"birpc": "2.0.19",
|
|
60
|
-
"defu": "^6.1.4",
|
|
61
|
-
"pathe": "^2.0.2",
|
|
62
|
-
"sirv": "^3.0.0",
|
|
63
|
-
"terminate": "^2.8.0"
|
|
55
|
+
"@nuxt/kit": "^4.2.2",
|
|
56
|
+
"@prismicio/client": "^7.21.1",
|
|
57
|
+
"@prismicio/vue": "pr-89",
|
|
58
|
+
"defu": "^6.1.4"
|
|
64
59
|
},
|
|
65
60
|
"devDependencies": {
|
|
66
|
-
"@
|
|
67
|
-
"@
|
|
68
|
-
"@
|
|
69
|
-
"@
|
|
70
|
-
"@
|
|
71
|
-
"@
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"typescript": "^5.7.3",
|
|
80
|
-
"vitest": "^3.0.2"
|
|
61
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
62
|
+
"@nuxt/schema": "^4.2.2",
|
|
63
|
+
"@nuxt/test-utils": "^3.21.0",
|
|
64
|
+
"@trivago/prettier-plugin-sort-imports": "^6.0.0",
|
|
65
|
+
"@types/node": "^25.0.3",
|
|
66
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
67
|
+
"nuxt": "^4.2.2",
|
|
68
|
+
"oxlint": "1.35.0",
|
|
69
|
+
"prettier": "^3.7.4",
|
|
70
|
+
"prettier-plugin-jsdoc": "^1.8.0",
|
|
71
|
+
"typescript": "^5.9.3",
|
|
72
|
+
"vitest": "^4.0.16",
|
|
73
|
+
"vue-tsc": "^3.2.1"
|
|
81
74
|
},
|
|
82
75
|
"engines": {
|
|
83
|
-
"node": ">=
|
|
76
|
+
"node": ">=20.0.0"
|
|
84
77
|
},
|
|
85
78
|
"publishConfig": {
|
|
86
79
|
"access": "public"
|
|
87
80
|
},
|
|
88
|
-
"packageManager": "pnpm@
|
|
81
|
+
"packageManager": "pnpm@10.26.2"
|
|
89
82
|
}
|