domma-cms 0.101.4 → 0.101.5

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.
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * Domma Tools CSS v0.50.0
2
+ * Domma Tools CSS v0.50.1
3
3
  * Dynamic Object Manipulation & Modeling API
4
4
  * (c) 2026 Darryl Waterhouse & DCBW-IT
5
- * Built: 2026-09-28T07:51:39.095Z
6
- * Commit: d400172
5
+ * Built: 2026-09-28T12:14:42.245Z
6
+ * Commit: 49f4331
7
7
  */
8
8
 
9
9
  /*!
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * Domma Tools v0.50.0
2
+ * Domma Tools v0.50.1
3
3
  * Developer tools: Theme Roller & Page Roller
4
4
  * (c) 2026 Darryl Waterhouse & DCBW-IT
5
- * Built: 2026-09-28T07:51:27.470Z
6
- * Commit: d400172
5
+ * Built: 2026-09-28T12:14:27.201Z
6
+ * Commit: 49f4331
7
7
  *
8
8
  * Requires: domma.min.js
9
9
  */
@@ -0,0 +1,128 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en-GB">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Component Preview</title>
6
+ <link rel="stylesheet" href="/dist/domma/domma.css">
7
+ <link rel="stylesheet" href="/dist/domma/elements.css">
8
+ <link rel="stylesheet" href="/dist/domma/themes/domma-themes.css">
9
+ <style>
10
+ html, body { margin: 0; padding: 0; }
11
+ body { padding: 1rem; font-family: system-ui, sans-serif; }
12
+ #mount { display: block; }
13
+ #err {
14
+ color: #c92a2a;
15
+ background: #fff0f0;
16
+ border: 1px solid #f5c6cb;
17
+ border-radius: 4px;
18
+ padding: .75rem;
19
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
20
+ font-size: .8rem;
21
+ white-space: pre-wrap;
22
+ }
23
+ /* Mirror the public-site rule - hide undefined custom elements until they upgrade. */
24
+ :not(:defined) { visibility: hidden; }
25
+ </style>
26
+ <script src="/dist/domma/domma.min.js"></script>
27
+ </head>
28
+ <body class="dm-theme-charcoal-dark">
29
+ <div id="mount"></div>
30
+ <pre id="err" hidden></pre>
31
+ <script>
32
+ // Protocol (admin ↔ iframe):
33
+ // admin → iframe: { type: 'mount', payload: { compiledJs, tagName, props } }
34
+ // { type: 'update', payload: { props } }
35
+ // { type: 'remount', payload: { compiledJs, tagName, props } }
36
+ // iframe → admin: { type: 'ready', height }
37
+ // { type: 'resize', height }
38
+ // { type: 'error', message, stack? }
39
+
40
+ let currentEl = null;
41
+
42
+ function postParent(msg) {
43
+ parent.postMessage(msg, '*');
44
+ }
45
+
46
+ function showError(message) {
47
+ const err = document.getElementById('err');
48
+ err.hidden = false;
49
+ err.textContent = message;
50
+ postParent({ type: 'error', message });
51
+ }
52
+
53
+ function clearMount() {
54
+ const mount = document.getElementById('mount');
55
+ while (mount.firstChild) mount.removeChild(mount.firstChild);
56
+ document.getElementById('err').hidden = true;
57
+ currentEl = null;
58
+ }
59
+
60
+ function applyPropsToEl(el, props) {
61
+ for (const [k, v] of Object.entries(props || {})) {
62
+ const attr = k.replace(/([A-Z])/g, '-$1').toLowerCase();
63
+ if (v === null || v === undefined) el.removeAttribute(attr);
64
+ else el.setAttribute(attr, String(v));
65
+ }
66
+ }
67
+
68
+ async function mount({ compiledJs, tagName, props }) {
69
+ clearMount();
70
+ try {
71
+ // Execute the compiled source by injecting it as a plain <script> element.
72
+ // Dynamic import of a blob: URL is blocked by the site CSP (script-src
73
+ // doesn't include blob:), but 'unsafe-inline' permits inline <script>.
74
+ // The compiled output is top-level JS with no import/export, so a regular
75
+ // script tag is both simpler and CSP-friendly.
76
+ await new Promise((resolve, reject) => {
77
+ const script = document.createElement('script');
78
+ script.textContent = compiledJs;
79
+ script.dataset.dmcomponent = 'true';
80
+ // Inline scripts execute synchronously on append; errors surface via
81
+ // window.onerror. Use a microtask to give the element a chance to run.
82
+ document.body.appendChild(script);
83
+ queueMicrotask(resolve);
84
+ script.addEventListener('error', () => reject(new Error('Script load error')));
85
+ });
86
+
87
+ // If customElements hasn't defined the tag yet (first mount), wait; on
88
+ // repeat mounts the same tag is already defined and whenDefined resolves
89
+ // instantly - Domma.component() skips re-registration with a warning.
90
+ await customElements.whenDefined(tagName);
91
+
92
+ currentEl = document.createElement(tagName);
93
+ applyPropsToEl(currentEl, props);
94
+ document.getElementById('mount').appendChild(currentEl);
95
+ postParent({ type: 'ready', height: document.body.scrollHeight });
96
+ } catch (e) {
97
+ showError((e && (e.stack || e.message)) || 'Unknown mount error.');
98
+ }
99
+ }
100
+
101
+ function updateProps(props) {
102
+ if (!currentEl) return;
103
+ applyPropsToEl(currentEl, props);
104
+ }
105
+
106
+ window.addEventListener('message', (e) => {
107
+ const msg = e.data || {};
108
+ if (msg.type === 'mount') mount(msg.payload || {});
109
+ else if (msg.type === 'update') updateProps(msg.payload?.props);
110
+ else if (msg.type === 'remount') mount(msg.payload || {});
111
+ });
112
+
113
+ // Post our height whenever the mounted content resizes.
114
+ new ResizeObserver(() => {
115
+ postParent({ type: 'resize', height: document.body.scrollHeight });
116
+ }).observe(document.body);
117
+
118
+ // Catch any otherwise-unhandled errors from the compiled module so the
119
+ // admin can surface them.
120
+ window.addEventListener('error', (e) => {
121
+ showError((e.error && (e.error.stack || e.error.message)) || e.message || 'Script error.');
122
+ });
123
+ window.addEventListener('unhandledrejection', (e) => {
124
+ showError((e.reason && (e.reason.stack || e.reason.message)) || String(e.reason));
125
+ });
126
+ </script>
127
+ </body>
128
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "0.101.4",
3
+ "version": "0.101.5",
4
4
  "description": "File-based CMS powered by Domma and Fastify. Run npx domma-cms my-site to create a new project.",
5
5
  "type": "module",
6
6
  "main": "server/server.js",
@@ -13,6 +13,7 @@
13
13
  "admin/js/",
14
14
  "admin/css/",
15
15
  "admin/index.html",
16
+ "admin/preview/",
16
17
  "admin/dist/domma/domma-tools.css",
17
18
  "admin/dist/domma/domma-tools.min.js",
18
19
  "public/js/",
@@ -83,7 +84,7 @@
83
84
  "@fastify/rate-limit": "^10.3.0",
84
85
  "@fastify/static": "9.1.1",
85
86
  "bcryptjs": "^3.0.3",
86
- "domma-js": "0.50.0",
87
+ "domma-js": "0.50.1",
87
88
  "dotenv": "^17.2.3",
88
89
  "fastify": "5.8.5",
89
90
  "gray-matter": "^4.0.3",