@oktis-works/cms 0.17.0 → 0.19.1

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,329 @@
1
+ // @oktis-works/cms - Scaffold sources for compiled themes (React/Solid)
2
+ //
3
+ // These files are written verbatim by `okcms theme:create --engine react|solid`.
4
+ // They are intentionally self-contained and mirror the public template keys.
5
+ const TEMPLATE_KEYS = ['home', 'index', 'single', 'page', 'archive', '404'];
6
+ function packageJson(name, engine) {
7
+ const framework = engine === 'react'
8
+ ? {
9
+ dependencies: {
10
+ react: '^19.0.0',
11
+ 'react-dom': '^19.0.0',
12
+ '@oktis-works/theme-sdk': '^0.8.0',
13
+ },
14
+ devDependencies: {
15
+ '@types/react': '^19.0.0',
16
+ '@types/react-dom': '^19.0.0',
17
+ '@vitejs/plugin-react': '^6.0.0',
18
+ vite: '^8.0.0',
19
+ typescript: '5.7.3',
20
+ },
21
+ }
22
+ : {
23
+ dependencies: {
24
+ 'solid-js': '^1.9.0',
25
+ '@oktis-works/theme-sdk': '^0.8.0',
26
+ },
27
+ devDependencies: {
28
+ 'vite-plugin-solid': '^2.11.0',
29
+ vite: '^8.0.0',
30
+ typescript: '5.7.3',
31
+ },
32
+ };
33
+ return JSON.stringify({
34
+ name: `okcms-theme-${name}`,
35
+ version: '0.1.0',
36
+ private: true,
37
+ type: 'module',
38
+ scripts: {
39
+ build: 'okcms theme:build --name ' + name,
40
+ 'build:standalone': 'vite build',
41
+ dev: 'vite build --watch',
42
+ },
43
+ ...framework,
44
+ }, null, 2);
45
+ }
46
+ function tsconfig(engine) {
47
+ return JSON.stringify({
48
+ compilerOptions: {
49
+ target: 'ES2022',
50
+ module: 'ESNext',
51
+ moduleResolution: 'Bundler',
52
+ lib: ['ES2022', 'DOM'],
53
+ strict: true,
54
+ skipLibCheck: true,
55
+ esModuleInterop: true,
56
+ resolveJsonModule: true,
57
+ isolatedModules: true,
58
+ noEmit: true,
59
+ ...(engine === 'react'
60
+ ? { jsx: 'react-jsx', jsxImportSource: 'react' }
61
+ : { jsx: 'preserve', jsxImportSource: 'solid-js' }),
62
+ },
63
+ include: ['*.tsx', 'src/**/*.ts', 'src/**/*.tsx'],
64
+ }, null, 2);
65
+ }
66
+ function viteConfig(engine) {
67
+ const plugin = engine === 'react' ? 'react' : 'solid';
68
+ return [
69
+ "import { defineConfig } from 'vite';",
70
+ engine === 'react'
71
+ ? "import react from '@vitejs/plugin-react';"
72
+ : "import solid from 'vite-plugin-solid';",
73
+ "import { fileURLToPath } from 'node:url';",
74
+ '',
75
+ 'export default defineConfig({',
76
+ ` plugins: [${plugin}()],`,
77
+ ' build: {',
78
+ " ssr: fileURLToPath(new URL('./src/entry-server.tsx', import.meta.url)),",
79
+ " outDir: 'dist/server',",
80
+ ' emptyOutDir: true,',
81
+ " target: 'node22',",
82
+ " rollupOptions: { output: { format: 'esm', entryFileNames: 'entry.js' } },",
83
+ ' },',
84
+ ' ssr: { noExternal: true },',
85
+ '});',
86
+ '',
87
+ ].join('\n');
88
+ }
89
+ const REACT_PAGES = {
90
+ home: `import type { ThemePageData } from '@oktis-works/theme-sdk';
91
+
92
+ export default function Home({ site, items, settings }: ThemePageData) {
93
+ const theme = (settings.theme ?? {}) as Record<string, unknown>;
94
+ return (
95
+ <main className="site">
96
+ <header className="site-header">
97
+ <h1>{String(theme.siteTitle ?? site.title)}</h1>
98
+ <p>{site.description}</p>
99
+ </header>
100
+ <section className="listing">
101
+ {items.map((item) => (
102
+ <article className="card" key={String(item.slug)}>
103
+ <h2><a href={\`/\${String(item.slug)}\`}>{String(item.title ?? '')}</a></h2>
104
+ {item.excerpt ? <p>{String(item.excerpt)}</p> : null}
105
+ </article>
106
+ ))}
107
+ </section>
108
+ </main>
109
+ );
110
+ }
111
+ `,
112
+ index: `import type { ThemePageData } from '@oktis-works/theme-sdk';
113
+
114
+ export default function Index({ page, content }: ThemePageData) {
115
+ return (
116
+ <main className="site page">
117
+ <h1>{page.title}</h1>
118
+ <div className="entry-content" dangerouslySetInnerHTML={{ __html: String(content.html ?? '') }} />
119
+ </main>
120
+ );
121
+ }
122
+ `,
123
+ single: `import type { ThemePageData } from '@oktis-works/theme-sdk';
124
+
125
+ export default function Single({ page, content }: ThemePageData) {
126
+ return (
127
+ <article className="site single">
128
+ <h1>{page.title}</h1>
129
+ <div className="entry-content" dangerouslySetInnerHTML={{ __html: String(content.html ?? '') }} />
130
+ </article>
131
+ );
132
+ }
133
+ `,
134
+ page: `import type { ThemePageData } from '@oktis-works/theme-sdk';
135
+
136
+ export default function Page({ page, content }: ThemePageData) {
137
+ return (
138
+ <main className="site page">
139
+ <h1>{page.title}</h1>
140
+ <div className="entry-content" dangerouslySetInnerHTML={{ __html: String(content.html ?? '') }} />
141
+ </main>
142
+ );
143
+ }
144
+ `,
145
+ archive: `import type { ThemePageData } from '@oktis-works/theme-sdk';
146
+
147
+ export default function Archive({ page, items }: ThemePageData) {
148
+ return (
149
+ <main className="site archive">
150
+ <h1>{page.title}</h1>
151
+ <section className="listing">
152
+ {items.map((item) => (
153
+ <article className="card" key={String(item.slug)}>
154
+ <h2><a href={\`/\${String(item.slug)}\`}>{String(item.title ?? '')}</a></h2>
155
+ {item.excerpt ? <p>{String(item.excerpt)}</p> : null}
156
+ </article>
157
+ ))}
158
+ </section>
159
+ </main>
160
+ );
161
+ }
162
+ `,
163
+ '404': `export default function NotFound() {
164
+ return (
165
+ <main className="site not-found">
166
+ <h1>404</h1>
167
+ <p>Page not found.</p>
168
+ </main>
169
+ );
170
+ }
171
+ `,
172
+ };
173
+ const SOLID_PAGES = {
174
+ home: `import { For } from 'solid-js';
175
+ import type { ThemePageData } from '@oktis-works/theme-sdk';
176
+
177
+ export default function Home(props: ThemePageData) {
178
+ const theme = (props.settings.theme ?? {}) as Record<string, unknown>;
179
+ return (
180
+ <main class="site">
181
+ <header class="site-header">
182
+ <h1>{String(theme.siteTitle ?? props.site.title)}</h1>
183
+ <p>{props.site.description}</p>
184
+ </header>
185
+ <section class="listing">
186
+ <For each={props.items}>
187
+ {(item) => (
188
+ <article class="card">
189
+ <h2><a href={\`/\${String(item.slug)}\`}>{String(item.title ?? '')}</a></h2>
190
+ {item.excerpt ? <p>{String(item.excerpt)}</p> : null}
191
+ </article>
192
+ )}
193
+ </For>
194
+ </section>
195
+ </main>
196
+ );
197
+ }
198
+ `,
199
+ index: `import type { ThemePageData } from '@oktis-works/theme-sdk';
200
+
201
+ export default function Index(props: ThemePageData) {
202
+ return (
203
+ <main class="site page">
204
+ <h1>{props.page.title}</h1>
205
+ <div class="entry-content" innerHTML={String(props.content.html ?? '')} />
206
+ </main>
207
+ );
208
+ }
209
+ `,
210
+ single: `import type { ThemePageData } from '@oktis-works/theme-sdk';
211
+
212
+ export default function Single(props: ThemePageData) {
213
+ return (
214
+ <article class="site single">
215
+ <h1>{props.page.title}</h1>
216
+ <div class="entry-content" innerHTML={String(props.content.html ?? '')} />
217
+ </article>
218
+ );
219
+ }
220
+ `,
221
+ page: `import type { ThemePageData } from '@oktis-works/theme-sdk';
222
+
223
+ export default function Page(props: ThemePageData) {
224
+ return (
225
+ <main class="site page">
226
+ <h1>{props.page.title}</h1>
227
+ <div class="entry-content" innerHTML={String(props.content.html ?? '')} />
228
+ </main>
229
+ );
230
+ }
231
+ `,
232
+ archive: `import { For } from 'solid-js';
233
+ import type { ThemePageData } from '@oktis-works/theme-sdk';
234
+
235
+ export default function Archive(props: ThemePageData) {
236
+ return (
237
+ <main class="site archive">
238
+ <h1>{props.page.title}</h1>
239
+ <section class="listing">
240
+ <For each={props.items}>
241
+ {(item) => (
242
+ <article class="card">
243
+ <h2><a href={\`/\${String(item.slug)}\`}>{String(item.title ?? '')}</a></h2>
244
+ {item.excerpt ? <p>{String(item.excerpt)}</p> : null}
245
+ </article>
246
+ )}
247
+ </For>
248
+ </section>
249
+ </main>
250
+ );
251
+ }
252
+ `,
253
+ '404': `export default function NotFound() {
254
+ return (
255
+ <main class="site not-found">
256
+ <h1>404</h1>
257
+ <p>Page not found.</p>
258
+ </main>
259
+ );
260
+ }
261
+ `,
262
+ };
263
+ function entryServer(engine) {
264
+ const imports = TEMPLATE_KEYS.map((key) => {
265
+ const symbol = key === '404' ? 'NotFound' : key.charAt(0).toUpperCase() + key.slice(1);
266
+ return `import ${symbol} from '../${key}';`;
267
+ }).join('\n');
268
+ const mapping = TEMPLATE_KEYS.map((key) => {
269
+ const symbol = key === '404' ? 'NotFound' : key.charAt(0).toUpperCase() + key.slice(1);
270
+ return ` '${key}': ${symbol},`;
271
+ }).join('\n');
272
+ if (engine === 'react') {
273
+ return `${imports}
274
+ import { renderToStaticMarkup } from 'react-dom/server';
275
+ import type { ComponentType } from 'react';
276
+ import type { ThemePageData, ThemeRenderContext, ThemeRenderOutput } from '@oktis-works/theme-sdk';
277
+
278
+ const templates: Record<string, ComponentType<ThemePageData>> = {
279
+ ${mapping}
280
+ };
281
+
282
+ export const templateKeys = Object.keys(templates);
283
+
284
+ export function render(
285
+ key: string,
286
+ data: ThemePageData,
287
+ _ctx?: ThemeRenderContext
288
+ ): ThemeRenderOutput {
289
+ const Component = templates[key] ?? templates['404'];
290
+ return { html: renderToStaticMarkup(<Component {...data} />) };
291
+ }
292
+ `;
293
+ }
294
+ return `${imports}
295
+ import { renderToString } from 'solid-js/web';
296
+ import type { Component } from 'solid-js';
297
+ import type { ThemePageData, ThemeRenderContext, ThemeRenderOutput } from '@oktis-works/theme-sdk';
298
+
299
+ const templates: Record<string, Component<ThemePageData>> = {
300
+ ${mapping}
301
+ };
302
+
303
+ export const templateKeys = Object.keys(templates);
304
+
305
+ export function render(
306
+ key: string,
307
+ data: ThemePageData,
308
+ _ctx?: ThemeRenderContext
309
+ ): ThemeRenderOutput {
310
+ const Component = templates[key] ?? templates['404'];
311
+ return { html: renderToString(() => <Component {...data} />) };
312
+ }
313
+ `;
314
+ }
315
+ export function compiledThemeFiles(name, engine) {
316
+ const pages = engine === 'react' ? REACT_PAGES : SOLID_PAGES;
317
+ const files = {
318
+ 'package.json': packageJson(name, engine),
319
+ 'tsconfig.json': tsconfig(engine),
320
+ 'vite.config.ts': viteConfig(engine),
321
+ 'src/entry-server.tsx': entryServer(engine),
322
+ };
323
+ for (const key of TEMPLATE_KEYS) {
324
+ files[`${key}.tsx`] = pages[key];
325
+ }
326
+ return files;
327
+ }
328
+ export { TEMPLATE_KEYS };
329
+ //# sourceMappingURL=theme-engine-assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-engine-assets.js","sourceRoot":"","sources":["../src/theme-engine-assets.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,EAAE;AACF,iFAAiF;AACjF,6EAA6E;AAI7E,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAU,CAAC;AAErF,SAAS,WAAW,CAAC,IAAY,EAAE,MAAyB;IAC1D,MAAM,SAAS,GACb,MAAM,KAAK,OAAO;QAChB,CAAC,CAAC;YACE,YAAY,EAAE;gBACZ,KAAK,EAAE,SAAS;gBAChB,WAAW,EAAE,SAAS;gBACtB,wBAAwB,EAAE,QAAQ;aACnC;YACD,eAAe,EAAE;gBACf,cAAc,EAAE,SAAS;gBACzB,kBAAkB,EAAE,SAAS;gBAC7B,sBAAsB,EAAE,QAAQ;gBAChC,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,OAAO;aACpB;SACF;QACH,CAAC,CAAC;YACE,YAAY,EAAE;gBACZ,UAAU,EAAE,QAAQ;gBACpB,wBAAwB,EAAE,QAAQ;aACnC;YACD,eAAe,EAAE;gBACf,mBAAmB,EAAE,SAAS;gBAC9B,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,OAAO;aACpB;SACF,CAAC;IAER,OAAO,IAAI,CAAC,SAAS,CACnB;QACE,IAAI,EAAE,eAAe,IAAI,EAAE;QAC3B,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,QAAQ;Q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AE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvF,OAAO,MAAM,GAAG,MAAM,MAAM,GAAG,CAAC;IAClC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;QACvB,OAAO,GAAG,OAAO;;;;;;EAMnB,OAAO;;;;;;;;;;;;;CAaR,CAAC;IACA,CAAC;IAED,OAAO,GAAG,OAAO;;;;;;EAMjB,OAAO;;;;;;;;;;;;;CAaR,CAAC;AACF,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,MAAyB;IACxE,MAAM,KAAK,GAAG,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC;IAC7D,MAAM,KAAK,GAA2B;QACpC,cAAc,EAAE,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC;QACzC,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC;QACjC,gBAAgB,EAAE,UAAU,CAAC,MAAM,CAAC;QACpC,sBAAsB,EAAE,WAAW,CAAC,MAAM,CAAC;KAC5C,CAAC;IACF,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;QAChC,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,CAAE,CAAC;IACpC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -5,7 +5,7 @@
5
5
  "type": "theme",
6
6
  "author": "Oktis Works",
7
7
  "compatibility": {
8
- "okcms": "^0.40.0"
8
+ "okcms": "^0.42.0"
9
9
  },
10
10
  "screenshots": [
11
11
  "screenshot.png"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oktis-works/cms",
3
- "version": "0.17.0",
3
+ "version": "0.19.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -23,12 +23,13 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@clack/prompts": "1.8.1",
26
- "@oktis-works/auth": "^0.9.0",
27
- "@oktis-works/config": "^0.7.1",
28
- "@oktis-works/core": "^0.18.2",
29
- "@oktis-works/database": "^0.16.2",
30
- "@oktis-works/theme-runtime": "^0.12.0",
31
- "@oktis-works/validation": "^0.8.2",
26
+ "@oktis-works/auth": "^0.9.3",
27
+ "@oktis-works/config": "^0.7.3",
28
+ "@oktis-works/core": "^0.20.1",
29
+ "@oktis-works/database": "^0.16.4",
30
+ "@oktis-works/theme-runtime": "^0.14.1",
31
+ "@oktis-works/theme-builder": "^0.2.2",
32
+ "@oktis-works/validation": "^0.9.1",
32
33
  "mysql2": "^3.14.1"
33
34
  },
34
35
  "devDependencies": {