@payloadcms/live-preview-vue 3.0.0-canary.4de9e42

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.
@@ -0,0 +1,16 @@
1
+ import type { Ref } from 'vue';
2
+ /**
3
+ * Vue composable to implement Payload CMS Live Preview.
4
+ *
5
+ * {@link https://payloadcms.com/docs/live-preview/frontend View the documentation}
6
+ */
7
+ export declare const useLivePreview: <T>(props: {
8
+ apiRoute?: string;
9
+ depth?: number;
10
+ initialData: T;
11
+ serverURL: string;
12
+ }) => {
13
+ data: Ref<T>;
14
+ isLoading: Ref<boolean>;
15
+ };
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAK9B;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,CAAC,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;CAClB,KAAG;IACF,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;IACZ,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CAwCxB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useLivePreview", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useLivePreview;
9
+ }
10
+ });
11
+ const _livepreview = require("@payloadcms/live-preview");
12
+ const _vue = require("vue");
13
+ const useLivePreview = (props)=>{
14
+ const { apiRoute, depth, initialData, serverURL } = props;
15
+ const data = (0, _vue.ref)(initialData);
16
+ const isLoading = (0, _vue.ref)(true);
17
+ const hasSentReadyMessage = (0, _vue.ref)(false);
18
+ const onChange = (mergedData)=>{
19
+ data.value = mergedData;
20
+ isLoading.value = false;
21
+ };
22
+ let subscription;
23
+ (0, _vue.onMounted)(()=>{
24
+ subscription = (0, _livepreview.subscribe)({
25
+ apiRoute,
26
+ callback: onChange,
27
+ depth,
28
+ initialData,
29
+ serverURL
30
+ });
31
+ if (!hasSentReadyMessage.value) {
32
+ hasSentReadyMessage.value = true;
33
+ (0, _livepreview.ready)({
34
+ serverURL
35
+ });
36
+ }
37
+ });
38
+ (0, _vue.onUnmounted)(()=>{
39
+ (0, _livepreview.unsubscribe)(subscription);
40
+ });
41
+ return {
42
+ data,
43
+ isLoading
44
+ };
45
+ };
46
+
47
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSB7IFJlZiB9IGZyb20gJ3Z1ZSdcblxuaW1wb3J0IHsgcmVhZHksIHN1YnNjcmliZSwgdW5zdWJzY3JpYmUgfSBmcm9tICdAcGF5bG9hZGNtcy9saXZlLXByZXZpZXcnXG5pbXBvcnQgeyBvbk1vdW50ZWQsIG9uVW5tb3VudGVkLCByZWYgfSBmcm9tICd2dWUnXG5cbi8qKlxuICogVnVlIGNvbXBvc2FibGUgdG8gaW1wbGVtZW50IFBheWxvYWQgQ01TIExpdmUgUHJldmlldy5cbiAqXG4gKiB7QGxpbmsgaHR0cHM6Ly9wYXlsb2FkY21zLmNvbS9kb2NzL2xpdmUtcHJldmlldy9mcm9udGVuZCBWaWV3IHRoZSBkb2N1bWVudGF0aW9ufVxuICovXG5leHBvcnQgY29uc3QgdXNlTGl2ZVByZXZpZXcgPSA8VD4ocHJvcHM6IHtcbiAgYXBpUm91dGU/OiBzdHJpbmdcbiAgZGVwdGg/OiBudW1iZXJcbiAgaW5pdGlhbERhdGE6IFRcbiAgc2VydmVyVVJMOiBzdHJ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FQUFDO1FBQ1ZDLElBQUFBLHdCQUFXLEVBQUNOO0lBQ2Q7SUFFQSxPQUFPO1FBQ0xQO1FBQ0FFO0lBQ0Y7QUFDRiJ9
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@payloadcms/live-preview-vue",
3
+ "version": "3.0.0-canary.4de9e42",
4
+ "description": "The official live preview Vue SDK for Payload",
5
+ "homepage": "https://payloadcms.com",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/payloadcms/payload.git",
9
+ "directory": "packages/live-preview-vue"
10
+ },
11
+ "license": "MIT",
12
+ "author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
13
+ "type": "module",
14
+ "exports": {
15
+ ".": {
16
+ "default": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
19
+ }
20
+ },
21
+ "main": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "dependencies": {
27
+ "@payloadcms/live-preview": "3.0.0-beta.68"
28
+ },
29
+ "devDependencies": {
30
+ "vue": "^3.0.0",
31
+ "payload": "3.0.0-beta.68",
32
+ "@payloadcms/eslint-config": "3.0.0-beta.59"
33
+ },
34
+ "peerDependencies": {
35
+ "vue": "^3.0.0"
36
+ },
37
+ "publishConfig": {
38
+ "registry": "https://registry.npmjs.org/"
39
+ },
40
+ "scripts": {
41
+ "build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
42
+ "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
43
+ "build:types": "tsc --emitDeclarationOnly --outDir dist",
44
+ "clean": "rimraf {dist,*.tsbuildinfo}",
45
+ "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/"
46
+ }
47
+ }