opacacms 0.3.4 → 0.3.6
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/admin/webcomponent.js +34 -34
- package/dist/cli/index.js +36 -24
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -119
- package/package.json +31 -19
package/dist/cli/index.js
CHANGED
|
@@ -2017,12 +2017,12 @@ var init_init = __esm(() => {
|
|
|
2017
2017
|
}
|
|
2018
2018
|
const srcDir = fs3.existsSync(resolve(targetDir, "src")) ? "src/" : "";
|
|
2019
2019
|
const nextPathPrefix = framework === "nextjs" ? `${srcDir}app/(opaca)/` : "";
|
|
2020
|
-
const cfPathPrefix = framework === "cloudflare-workers" ? "src/" : "";
|
|
2020
|
+
const cfPathPrefix = framework === "cloudflare-workers" ? "src/(opaca)/" : "";
|
|
2021
2021
|
const pathPrefix = framework === "nextjs" ? nextPathPrefix : cfPathPrefix;
|
|
2022
2022
|
const configCode = `import { defineConfig } from 'opacacms/config';
|
|
2023
2023
|
${dbImport}
|
|
2024
|
-
import { posts } from './${pathPrefix}
|
|
2025
|
-
import { siteSettings } from './${pathPrefix}
|
|
2024
|
+
import { posts } from './${pathPrefix}_collections/posts';
|
|
2025
|
+
import { siteSettings } from './${pathPrefix}_globals/site-settings';
|
|
2026
2026
|
|
|
2027
2027
|
${dbType === "d1" ? `const getConfig = (env: any, request: Request) => defineConfig({
|
|
2028
2028
|
appName: "My OpacaCMS App",
|
|
@@ -2074,13 +2074,13 @@ export const siteSettings = defineGlobal({
|
|
|
2074
2074
|
writeFile("opaca.config.ts", configCode);
|
|
2075
2075
|
if (framework === "nextjs") {
|
|
2076
2076
|
const baseDir = `${srcDir}app/(opaca)`;
|
|
2077
|
-
createDir(`${baseDir}/
|
|
2078
|
-
createDir(`${baseDir}/
|
|
2079
|
-
createDir(`${baseDir}/api/
|
|
2077
|
+
createDir(`${baseDir}/_collections`);
|
|
2078
|
+
createDir(`${baseDir}/_globals`);
|
|
2079
|
+
createDir(`${baseDir}/api/[[...slug]]`);
|
|
2080
2080
|
createDir(`${baseDir}/admin/[[...slug]]`);
|
|
2081
|
-
writeFile(`${baseDir}/
|
|
2082
|
-
writeFile(`${baseDir}/
|
|
2083
|
-
const importSteps = srcDir ? "
|
|
2081
|
+
writeFile(`${baseDir}/_collections/posts.ts`, postsCode);
|
|
2082
|
+
writeFile(`${baseDir}/_globals/site-settings.ts`, globalsCode);
|
|
2083
|
+
const importSteps = srcDir ? "../../../../../" : "../../../../";
|
|
2084
2084
|
const routeCode = `import { createNextHandler } from 'opacacms/runtimes/next';
|
|
2085
2085
|
import config from '${importSteps}opaca.config';
|
|
2086
2086
|
|
|
@@ -2093,7 +2093,7 @@ export const PATCH = handler.PATCH;
|
|
|
2093
2093
|
export const DELETE = handler.DELETE;
|
|
2094
2094
|
export const OPTIONS = handler.OPTIONS;
|
|
2095
2095
|
`;
|
|
2096
|
-
writeFile(`${baseDir}/api/
|
|
2096
|
+
writeFile(`${baseDir}/api/[[...slug]]/route.ts`, routeCode);
|
|
2097
2097
|
const pageCode = `'use client';
|
|
2098
2098
|
|
|
2099
2099
|
import { useEffect, useState } from 'react';
|
|
@@ -2136,10 +2136,10 @@ export default function Page() {
|
|
|
2136
2136
|
`;
|
|
2137
2137
|
writeFile(`${baseDir}/admin/[[...slug]]/page.tsx`, pageCode);
|
|
2138
2138
|
} else if (framework === "cloudflare-workers") {
|
|
2139
|
-
createDir("src/opaca/
|
|
2140
|
-
createDir("src/opaca/
|
|
2141
|
-
writeFile("src/opaca/
|
|
2142
|
-
writeFile("src/opaca/
|
|
2139
|
+
createDir("src/(opaca)/_collections");
|
|
2140
|
+
createDir("src/(opaca)/_globals");
|
|
2141
|
+
writeFile("src/(opaca)/_collections/posts.ts", postsCode);
|
|
2142
|
+
writeFile("src/(opaca)/_globals/site-settings.ts", globalsCode);
|
|
2143
2143
|
const indexCode = `import { createCloudflareWorkersHandler } from "opacacms/runtimes/cloudflare-workers";
|
|
2144
2144
|
import config from "../opaca.config";
|
|
2145
2145
|
|
|
@@ -2147,11 +2147,11 @@ export default createCloudflareWorkersHandler(config, { enableAdmin: true });
|
|
|
2147
2147
|
`;
|
|
2148
2148
|
writeFile("src/index.ts", indexCode);
|
|
2149
2149
|
} else if (framework === "nuxt") {
|
|
2150
|
-
createDir("opaca/
|
|
2151
|
-
createDir("opaca/
|
|
2150
|
+
createDir("(opaca)/_collections");
|
|
2151
|
+
createDir("(opaca)/_globals");
|
|
2152
2152
|
createDir("server/api/opaca");
|
|
2153
|
-
writeFile("opaca/
|
|
2154
|
-
writeFile("opaca/
|
|
2153
|
+
writeFile("(opaca)/_collections/posts.ts", postsCode);
|
|
2154
|
+
writeFile("(opaca)/_globals/site-settings.ts", globalsCode);
|
|
2155
2155
|
const routeCode = `import { createAPIRouter } from 'opacacms/server/router';
|
|
2156
2156
|
import config from '../../../opaca.config';
|
|
2157
2157
|
|
|
@@ -2162,10 +2162,10 @@ export default defineEventHandler(async (event) => {
|
|
|
2162
2162
|
`;
|
|
2163
2163
|
writeFile("server/api/opaca/[...slug].ts", routeCode);
|
|
2164
2164
|
} else {
|
|
2165
|
-
createDir("opaca/
|
|
2166
|
-
createDir("opaca/
|
|
2167
|
-
writeFile("opaca/
|
|
2168
|
-
writeFile("opaca/
|
|
2165
|
+
createDir("(opaca)/_collections");
|
|
2166
|
+
createDir("(opaca)/_globals");
|
|
2167
|
+
writeFile("(opaca)/_collections/posts.ts", postsCode);
|
|
2168
|
+
writeFile("(opaca)/_globals/site-settings.ts", globalsCode);
|
|
2169
2169
|
const serverCode = `import { createBunHandler } from 'opacacms/runtimes/bun';
|
|
2170
2170
|
import config from './opaca.config';
|
|
2171
2171
|
|
|
@@ -2183,12 +2183,24 @@ console.log('\uD83D\uDE80 OpacaCMS Backend Listening on http://localhost:3001');
|
|
|
2183
2183
|
pkg.dependencies = {};
|
|
2184
2184
|
if (!pkg.dependencies.opacacms) {
|
|
2185
2185
|
pkg.dependencies.opacacms = "latest";
|
|
2186
|
-
fs3.writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2));
|
|
2187
2186
|
}
|
|
2187
|
+
if (dbType === "sqlite") {
|
|
2188
|
+
if (!pkg.dependencies["better-sqlite3"])
|
|
2189
|
+
pkg.dependencies["better-sqlite3"] = "latest";
|
|
2190
|
+
} else if (dbType === "postgres") {
|
|
2191
|
+
if (!pkg.dependencies["postgres"])
|
|
2192
|
+
pkg.dependencies["postgres"] = "latest";
|
|
2193
|
+
} else if (dbType === "d1") {
|
|
2194
|
+
if (!pkg.devDependencies)
|
|
2195
|
+
pkg.devDependencies = {};
|
|
2196
|
+
if (!pkg.devDependencies["@cloudflare/workers-types"])
|
|
2197
|
+
pkg.devDependencies["@cloudflare/workers-types"] = "latest";
|
|
2198
|
+
}
|
|
2199
|
+
fs3.writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2));
|
|
2188
2200
|
} catch (e) {}
|
|
2189
2201
|
}
|
|
2190
2202
|
s.stop(`Scaffolding complete!`);
|
|
2191
|
-
Vt2(`1. Check the newly created \`opaca.config.ts\` and \`opaca\` folder.
|
|
2203
|
+
Vt2(`1. Check the newly created \`opaca.config.ts\` and \`(opaca)\` folder.
|
|
2192
2204
|
2. Run \`npm install\` (or your preferred package manager) to install dependencies.
|
|
2193
2205
|
3. Start your dev server!`, "Next Steps");
|
|
2194
2206
|
Gt(`Build something awesome! \uD83C\uDF88`);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -32,134 +32,15 @@ import {
|
|
|
32
32
|
import"./chunk-jq1drsen.js";
|
|
33
33
|
import"./chunk-h8v093av.js";
|
|
34
34
|
import"./chunk-8sqjbsgt.js";
|
|
35
|
-
// src/client/RichText.tsx
|
|
36
|
-
import { CodeNode } from "@lexical/code";
|
|
37
|
-
import { AutoLinkNode, LinkNode } from "@lexical/link";
|
|
38
|
-
import { ListItemNode, ListNode } from "@lexical/list";
|
|
39
|
-
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
40
|
-
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
41
|
-
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
42
|
-
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
|
|
43
|
-
import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
|
|
44
|
-
import { ListPlugin } from "@lexical/react/LexicalListPlugin";
|
|
45
|
-
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
46
|
-
import { HeadingNode, QuoteNode } from "@lexical/rich-text";
|
|
47
|
-
import { useMemo } from "react";
|
|
48
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
49
|
-
"use client";
|
|
50
|
-
var theme = {
|
|
51
|
-
ltr: "ltr",
|
|
52
|
-
rtl: "rtl",
|
|
53
|
-
placeholder: "opaca-rich-text-placeholder",
|
|
54
|
-
paragraph: "opaca-rich-text-p",
|
|
55
|
-
quote: "opaca-rich-text-quote",
|
|
56
|
-
heading: {
|
|
57
|
-
h1: "opaca-rich-text-h1",
|
|
58
|
-
h2: "opaca-rich-text-h2",
|
|
59
|
-
h3: "opaca-rich-text-h3"
|
|
60
|
-
},
|
|
61
|
-
list: {
|
|
62
|
-
ol: "opaca-rich-text-ol",
|
|
63
|
-
ul: "opaca-rich-text-ul",
|
|
64
|
-
listitem: "opaca-rich-text-li"
|
|
65
|
-
},
|
|
66
|
-
link: "opaca-rich-text-link",
|
|
67
|
-
text: {
|
|
68
|
-
bold: "opaca-rich-text-bold",
|
|
69
|
-
italic: "opaca-rich-text-italic",
|
|
70
|
-
underline: "opaca-rich-text-underline",
|
|
71
|
-
strikethrough: "opaca-rich-text-strikethrough",
|
|
72
|
-
code: "opaca-rich-text-code"
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
function RichText({ content, className }) {
|
|
76
|
-
const initialConfig = useMemo(() => {
|
|
77
|
-
let editorState = content;
|
|
78
|
-
if (typeof content === "string" && content.startsWith("{")) {
|
|
79
|
-
try {
|
|
80
|
-
editorState = content;
|
|
81
|
-
} catch (e) {
|
|
82
|
-
editorState = undefined;
|
|
83
|
-
}
|
|
84
|
-
} else if (typeof content === "object" && content !== null) {
|
|
85
|
-
editorState = JSON.stringify(content);
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
namespace: "OpacaRichTextRenderer",
|
|
89
|
-
theme,
|
|
90
|
-
editable: false,
|
|
91
|
-
nodes: [HeadingNode, ListNode, ListItemNode, QuoteNode, CodeNode, LinkNode, AutoLinkNode],
|
|
92
|
-
onError: (error) => {
|
|
93
|
-
console.error("RichText Renderer Error:", error);
|
|
94
|
-
},
|
|
95
|
-
editorState
|
|
96
|
-
};
|
|
97
|
-
}, [content]);
|
|
98
|
-
if (!content)
|
|
99
|
-
return null;
|
|
100
|
-
return /* @__PURE__ */ jsxDEV("div", {
|
|
101
|
-
className: `opaca-rich-text-renderer ${className || ""}`,
|
|
102
|
-
children: /* @__PURE__ */ jsxDEV(LexicalComposer, {
|
|
103
|
-
initialConfig,
|
|
104
|
-
children: [
|
|
105
|
-
/* @__PURE__ */ jsxDEV(RichTextPlugin, {
|
|
106
|
-
contentEditable: /* @__PURE__ */ jsxDEV(ContentEditable, {
|
|
107
|
-
className: "opaca-rich-text-content"
|
|
108
|
-
}, undefined, false, undefined, this),
|
|
109
|
-
placeholder: null,
|
|
110
|
-
ErrorBoundary: LexicalErrorBoundary
|
|
111
|
-
}, undefined, false, undefined, this),
|
|
112
|
-
/* @__PURE__ */ jsxDEV(ListPlugin, {}, undefined, false, undefined, this),
|
|
113
|
-
/* @__PURE__ */ jsxDEV(LinkPlugin, {}, undefined, false, undefined, this),
|
|
114
|
-
/* @__PURE__ */ jsxDEV(HistoryPlugin, {}, undefined, false, undefined, this)
|
|
115
|
-
]
|
|
116
|
-
}, undefined, true, undefined, this)
|
|
117
|
-
}, undefined, false, undefined, this);
|
|
118
|
-
}
|
|
119
|
-
// src/client/rich-text-utils.ts
|
|
120
|
-
function getRichTextText(content) {
|
|
121
|
-
if (!content)
|
|
122
|
-
return "";
|
|
123
|
-
if (typeof content === "string") {
|
|
124
|
-
if (content.startsWith("{") && content.includes('"root"')) {
|
|
125
|
-
try {
|
|
126
|
-
return getRichTextText(JSON.parse(content));
|
|
127
|
-
} catch {
|
|
128
|
-
return content;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return content;
|
|
132
|
-
}
|
|
133
|
-
if (content.root) {
|
|
134
|
-
return extractLexicalNodes(content.root.children);
|
|
135
|
-
}
|
|
136
|
-
if (Array.isArray(content)) {
|
|
137
|
-
return extractLexicalNodes(content);
|
|
138
|
-
}
|
|
139
|
-
return "";
|
|
140
|
-
}
|
|
141
|
-
function extractLexicalNodes(nodes) {
|
|
142
|
-
if (!nodes || !Array.isArray(nodes))
|
|
143
|
-
return "";
|
|
144
|
-
return nodes.map((node) => {
|
|
145
|
-
if (node.text)
|
|
146
|
-
return node.text;
|
|
147
|
-
if (node.children)
|
|
148
|
-
return extractLexicalNodes(node.children);
|
|
149
|
-
return "";
|
|
150
|
-
}).join(" ").replace(/\s+/g, " ").trim();
|
|
151
|
-
}
|
|
152
35
|
export {
|
|
153
36
|
zodToOpacaFields,
|
|
154
37
|
z,
|
|
155
38
|
sanitizeConfig,
|
|
156
|
-
getRichTextText,
|
|
157
39
|
defineGlobal,
|
|
158
40
|
defineConfig,
|
|
159
41
|
defineCollection,
|
|
160
42
|
createClient,
|
|
161
43
|
createAuth,
|
|
162
|
-
RichText,
|
|
163
44
|
OpacaError,
|
|
164
45
|
$ZodString,
|
|
165
46
|
$ZodOptional,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opacacms",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "OpacaCMS: A lightweight, type-safe, and developer-first Headless CMS for the edge and beyond.",
|
|
6
6
|
"keywords": [
|
|
@@ -136,17 +136,11 @@
|
|
|
136
136
|
}
|
|
137
137
|
},
|
|
138
138
|
"devDependencies": {
|
|
139
|
-
"@aws-sdk/client-s3": "^3.1009.0",
|
|
140
|
-
"@aws-sdk/s3-request-presigner": "^3.1009.0",
|
|
141
|
-
"@better-auth/api-key": "^1.5.5",
|
|
142
|
-
"@better-auth/core": "^1.5.5",
|
|
143
139
|
"@cloudflare/workers-types": "^4.20260313.1",
|
|
144
140
|
"@faker-js/faker": "^10.3.0",
|
|
145
141
|
"@happy-dom/global-registrator": "^20.8.4",
|
|
146
|
-
"@hono-rate-limiter/cloudflare": "^0.2.2",
|
|
147
142
|
"@hono/bun-transpiler": "^0.2.1",
|
|
148
143
|
"@hono/esbuild-transpiler": "^0.1.4",
|
|
149
|
-
"@hono/node-server": "^1.19.11",
|
|
150
144
|
"@lexical/code": "^0.41.0",
|
|
151
145
|
"@lexical/history": "^0.41.0",
|
|
152
146
|
"@lexical/html": "^0.41.0",
|
|
@@ -162,7 +156,6 @@
|
|
|
162
156
|
"@nanostores/react": "^1.0.0",
|
|
163
157
|
"@nanostores/router": "^1.0.0",
|
|
164
158
|
"@r2wc/react-to-web-component": "^2.1.1",
|
|
165
|
-
"@scalar/hono-api-reference": "^0.10.4",
|
|
166
159
|
"@tanstack/react-form": "^1.28.5",
|
|
167
160
|
"@testing-library/dom": "^10.4.1",
|
|
168
161
|
"@testing-library/react": "^16.3.2",
|
|
@@ -170,22 +163,15 @@
|
|
|
170
163
|
"@types/bun": "latest",
|
|
171
164
|
"@types/react": "^19.2.14",
|
|
172
165
|
"@types/react-dom": "^19.2.3",
|
|
173
|
-
"better-sqlite3": "^12.6.2",
|
|
174
166
|
"bun-plugin-scss": "^1.0.0",
|
|
175
167
|
"class-variance-authority": "^0.7.1",
|
|
176
|
-
"dotenv": "^17.3.1",
|
|
177
168
|
"esbuild": "^0.27.4",
|
|
178
169
|
"esbuild-wasm": "^0.27.4",
|
|
179
170
|
"happy-dom": "^20.8.4",
|
|
180
171
|
"hono": "^4.12.7",
|
|
181
|
-
"ky": "^1.14.3",
|
|
182
|
-
"kysely-bun-sqlite": "^0.4.0",
|
|
183
|
-
"kysely-d1": "^0.4.0",
|
|
184
|
-
"kysely-postgres-js": "^3.0.0",
|
|
185
172
|
"lexical": "^0.41.0",
|
|
186
173
|
"lucide-react": "^0.577.0",
|
|
187
174
|
"nanostores": "^1.1.1",
|
|
188
|
-
"postgres": "^3.4.8",
|
|
189
175
|
"radix-ui": "^1.4.3",
|
|
190
176
|
"sass": "^1.98.0",
|
|
191
177
|
"zod": "^4.3.6",
|
|
@@ -197,24 +183,50 @@
|
|
|
197
183
|
"react": "^19.2.4",
|
|
198
184
|
"react-dom": "^19.2.4",
|
|
199
185
|
"typescript": "^5.9.3",
|
|
200
|
-
"zod": "^4.3.6"
|
|
186
|
+
"zod": "^4.3.6",
|
|
187
|
+
"@aws-sdk/client-s3": "^3.1009.0",
|
|
188
|
+
"@aws-sdk/s3-request-presigner": "^3.1009.0",
|
|
189
|
+
"better-sqlite3": "^12.6.2",
|
|
190
|
+
"kysely-bun-sqlite": "^0.4.0",
|
|
191
|
+
"kysely-d1": "^0.4.0",
|
|
192
|
+
"kysely-postgres-js": "^3.0.0",
|
|
193
|
+
"postgres": "^3.4.8"
|
|
201
194
|
},
|
|
202
195
|
"peerDependenciesMeta": {
|
|
203
|
-
"@
|
|
196
|
+
"@aws-sdk/client-s3": {
|
|
204
197
|
"optional": true
|
|
205
198
|
},
|
|
206
|
-
"
|
|
199
|
+
"@aws-sdk/s3-request-presigner": {
|
|
207
200
|
"optional": true
|
|
208
201
|
},
|
|
209
|
-
"
|
|
202
|
+
"better-sqlite3": {
|
|
203
|
+
"optional": true
|
|
204
|
+
},
|
|
205
|
+
"kysely-bun-sqlite": {
|
|
206
|
+
"optional": true
|
|
207
|
+
},
|
|
208
|
+
"kysely-d1": {
|
|
209
|
+
"optional": true
|
|
210
|
+
},
|
|
211
|
+
"kysely-postgres-js": {
|
|
212
|
+
"optional": true
|
|
213
|
+
},
|
|
214
|
+
"postgres": {
|
|
210
215
|
"optional": true
|
|
211
216
|
}
|
|
212
217
|
},
|
|
213
218
|
"dependencies": {
|
|
219
|
+
"@better-auth/api-key": "^1.5.5",
|
|
220
|
+
"@better-auth/core": "^1.5.5",
|
|
221
|
+
"@hono-rate-limiter/cloudflare": "^0.2.2",
|
|
214
222
|
"@hono/graphql-server": "^0.7.0",
|
|
223
|
+
"@hono/node-server": "^1.19.11",
|
|
224
|
+
"@scalar/hono-api-reference": "^0.10.4",
|
|
215
225
|
"better-auth": "^1.5.5",
|
|
226
|
+
"dotenv": "^17.3.1",
|
|
216
227
|
"graphql": "^16.13.1",
|
|
217
228
|
"hono-rate-limiter": "^0.5.3",
|
|
229
|
+
"ky": "^1.14.3",
|
|
218
230
|
"kysely": "^0.28.11",
|
|
219
231
|
"zod-to-json-schema": "^3.25.1"
|
|
220
232
|
},
|