@puckeditor/plugin-pages 0.6.1-canary.b4fc2343

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/server.js ADDED
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // server.ts
31
+ var server_exports = {};
32
+ __export(server_exports, {
33
+ getPage: () => getPage
34
+ });
35
+ module.exports = __toCommonJS(server_exports);
36
+
37
+ // ../tsup-config/react-import.js
38
+ var import_react = __toESM(require("react"));
39
+
40
+ // ../cloud-client/src/lib/get-api-key.ts
41
+ var getApiKey = () => process.env.PUCK_API_KEY;
42
+
43
+ // api/lib/transport.ts
44
+ var resolveRequestOptions = (options = {}) => {
45
+ const {
46
+ apiKey = getApiKey(),
47
+ host = "https://cloud.puckeditor.com/api",
48
+ token
49
+ } = options;
50
+ if (!apiKey && !token) {
51
+ throw new Error(
52
+ "No Puck API key specified. Set the PUCK_API_KEY environment variable, or provide one to the function"
53
+ );
54
+ }
55
+ return {
56
+ apiKey,
57
+ host,
58
+ token
59
+ };
60
+ };
61
+ var assertPuckResponse = async (res) => {
62
+ if (!res.body) {
63
+ throw new Error(`Puck ${res.status} (${res.statusText})`);
64
+ }
65
+ if (!res.ok) {
66
+ const body = await res.json();
67
+ throw new Error(
68
+ `Puck ${res.status} (${res.statusText}): ${body.error ?? "Unknown reason"}`
69
+ );
70
+ }
71
+ };
72
+ var requestPage = async (route, {
73
+ path,
74
+ siteId,
75
+ versionId,
76
+ body,
77
+ method = "GET"
78
+ }, options = {}) => {
79
+ const { apiKey, host, token } = resolveRequestOptions(options);
80
+ const searchParams = new URLSearchParams();
81
+ if (method === "GET") {
82
+ if (path) {
83
+ searchParams.set("path", path);
84
+ }
85
+ if (versionId) {
86
+ searchParams.set("versionId", versionId);
87
+ }
88
+ }
89
+ const queryString = searchParams.toString();
90
+ const res = await fetch(
91
+ `${host}${route}${queryString ? `?${queryString}` : ""}`,
92
+ {
93
+ method,
94
+ headers: {
95
+ "x-site-id": siteId,
96
+ ...token ? { "x-one-time-token": token } : {},
97
+ ...apiKey && !token ? { "x-api-key": apiKey } : {},
98
+ ...body ? { "content-type": "application/json" } : {}
99
+ },
100
+ ...body ? { body: JSON.stringify(body) } : {}
101
+ }
102
+ );
103
+ await assertPuckResponse(res);
104
+ return res;
105
+ };
106
+
107
+ // api/lib/read-page.ts
108
+ var getPublishedPage = (args, options = {}) => requestPage("/pages/published", args, options);
109
+
110
+ // src/lib/get-page.ts
111
+ var getPage = async ({
112
+ apiKey,
113
+ host,
114
+ path,
115
+ siteId
116
+ }) => {
117
+ const data = await getPublishedPage(
118
+ { path, siteId },
119
+ {
120
+ host: `${host}/api`,
121
+ apiKey
122
+ }
123
+ );
124
+ return (await data.json()).page?.versions?.at(0)?.data ?? null;
125
+ };
126
+ // Annotate the CommonJS export names for ESM import in node:
127
+ 0 && (module.exports = {
128
+ getPage
129
+ });
@@ -0,0 +1,13 @@
1
+ import {
2
+ getPage
3
+ } from "./chunk-CFUMG5V5.mjs";
4
+ import "./chunk-BZD7XJC3.mjs";
5
+ import {
6
+ init_react_import
7
+ } from "./chunk-UYZYALB5.mjs";
8
+
9
+ // server.ts
10
+ init_react_import();
11
+ export {
12
+ getPage
13
+ };
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@puckeditor/plugin-pages",
3
+ "version": "0.6.1-canary.b4fc2343",
4
+ "author": "Chris Villa <chris@puckeditor.com>",
5
+ "repository": "puckeditor/puck",
6
+ "bugs": "https://github.com/puckeditor/puck/issues",
7
+ "homepage": "https://puckeditor.com",
8
+ "keywords": [
9
+ "puck-ecosystem",
10
+ "puck-plugin"
11
+ ],
12
+ "main": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "import": "./dist/index.mjs",
17
+ "types": "./dist/index.d.ts"
18
+ },
19
+ "./server": {
20
+ "import": "./dist/server.mjs",
21
+ "require": "./dist/server.js"
22
+ },
23
+ "./styles.css": "./dist/index.css"
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "devDependencies": {
29
+ "@radix-ui/react-popover": "^1.1.15",
30
+ "@testing-library/dom": "^10.4.1",
31
+ "@testing-library/react": "^16.3.2",
32
+ "@types/jest": "^30.0.0",
33
+ "@types/node": "^24.3.0",
34
+ "@types/react": "^19.1.8",
35
+ "@types/react-dom": "^19.1.6",
36
+ "date-fns": "^4.1.0",
37
+ "eslint": "^7.32.0",
38
+ "fast-equals": "^6.0.0",
39
+ "jsdom": "^28.1.0",
40
+ "lucide-react": "^0.452.0",
41
+ "tsup": "^8.2.4",
42
+ "typescript": "^5.5.4",
43
+ "vite-tsconfig-paths": "^5.1.4",
44
+ "vitest": "^3.2.4",
45
+ "zod": "^4.1.9",
46
+ "zustand": "^5.0.8",
47
+ "eslint-config-custom": "0.6.1-canary.b4fc2343",
48
+ "@puckeditor/platform-types": "0.6.1-canary.b4fc2343",
49
+ "tsup-config": "0.6.1-canary.b4fc2343",
50
+ "tsconfig": "0.6.1-canary.b4fc2343"
51
+ },
52
+ "peerDependencies": {
53
+ "@puckeditor/core": "^0.21.0 || 0.21.0-canary.de0baf39",
54
+ "react": "^18.0.0 || ^19.0.0"
55
+ },
56
+ "scripts": {
57
+ "lint": "eslint \"**/*.ts*\"",
58
+ "build": "rm -rf dist && tsup index.ts server.ts api/view.ts api/edit.ts",
59
+ "dev": "tsup index.ts server.ts api/view.ts api/edit.ts --watch src api",
60
+ "test": "vitest run --config vitest.config.ts"
61
+ }
62
+ }