okno 1.0.0-beta.14 → 1.0.0-beta.15
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/runtime/wrap.d.ts.map +1 -1
- package/dist/runtime/wrap.js +30 -28
- package/package.json +1 -1
- package/src/runtime/wrap.ts +12 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../../src/runtime/wrap.ts"],"names":[],"mappings":"AAgCA;0DAC0D;AAC1D,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAElE;AAiHD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAChD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMzB;AAiBD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAc1E;AAID,mFAAmF;AACnF,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAA;AAE3D;;kFAEkF;AAClF,UAAU,UAAU;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,aAAa,CAAC,EAAE,MAAM,CAAA;CACtB;AAmDD;;;;;uDAKuD;AACvD,wBAAgB,iBAAiB,CAChC,SAAS,EAAE,OAAO,EAClB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,QAAQ,CAAA;CAAE,CAAC,EACpD,aAAa,CAAC,EAAE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CAC/B;AAyHD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAkDtE;AA6DD;2EAC2E;AAC3E,wBAAgB,mBAAmB,IAAI,IAAI,CAK1C"}
|
package/dist/runtime/wrap.js
CHANGED
|
@@ -32,18 +32,18 @@ const C = /* @__PURE__ */ new Set([
|
|
|
32
32
|
function z(t) {
|
|
33
33
|
return t.replace(/[-_]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").trim().replace(/^./, (r) => r.toUpperCase());
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function k(t, r = "") {
|
|
36
36
|
if (t == null) {
|
|
37
37
|
if (!r) return "";
|
|
38
38
|
const i = r.split(".").pop() ?? "";
|
|
39
39
|
return !i || C.has(i) ? "" : z(i);
|
|
40
40
|
}
|
|
41
|
-
return typeof t != "object" ? String(t) :
|
|
41
|
+
return typeof t != "object" ? String(t) : j(t) ? t.text ?? "" : J(t) ? t.name ?? "" : "";
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function v(t) {
|
|
44
44
|
return typeof t == "object" && t !== null && !Array.isArray(t) && "src" in t;
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function j(t) {
|
|
47
47
|
return typeof t == "object" && t !== null && !Array.isArray(t) && "url" in t && "text" in t && "external" in t;
|
|
48
48
|
}
|
|
49
49
|
function J(t) {
|
|
@@ -123,9 +123,9 @@ function b(t, r = "", i = K) {
|
|
|
123
123
|
get(n, e) {
|
|
124
124
|
if (e === "data-okno") return w + n.__path;
|
|
125
125
|
if (e === Symbol.toPrimitive || e === "toString" || e === "valueOf")
|
|
126
|
-
return () =>
|
|
126
|
+
return () => k(n.__raw, n.__path);
|
|
127
127
|
if (e === Symbol.iterator) {
|
|
128
|
-
const u =
|
|
128
|
+
const u = k(n.__raw, n.__path);
|
|
129
129
|
return function* () {
|
|
130
130
|
yield u;
|
|
131
131
|
};
|
|
@@ -179,7 +179,7 @@ function m(t, r, i) {
|
|
|
179
179
|
if (e === "data-okno") return n.__path;
|
|
180
180
|
if (e === "slot") return { "data-okno-item": n.__slot ?? n.__path };
|
|
181
181
|
if (e === "exists") return n.__raw !== null && n.__raw !== void 0;
|
|
182
|
-
if (e === "image" &&
|
|
182
|
+
if (e === "image" && v(n.__raw)) {
|
|
183
183
|
const s = n.__raw;
|
|
184
184
|
return {
|
|
185
185
|
src: x(s.src),
|
|
@@ -190,9 +190,9 @@ function m(t, r, i) {
|
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
192
|
if (e === Symbol.toPrimitive || e === "toString" || e === "valueOf")
|
|
193
|
-
return () =>
|
|
193
|
+
return () => k(n.__raw, n.__path);
|
|
194
194
|
if (e === Symbol.iterator) {
|
|
195
|
-
const s =
|
|
195
|
+
const s = k(n.__raw, n.__path);
|
|
196
196
|
return function* () {
|
|
197
197
|
yield s;
|
|
198
198
|
};
|
|
@@ -216,11 +216,13 @@ function m(t, r, i) {
|
|
|
216
216
|
) : m(u, n.__path);
|
|
217
217
|
};
|
|
218
218
|
const o = n.__raw, f = n.__path ? `${n.__path}.${String(e)}` : String(e);
|
|
219
|
-
if (
|
|
219
|
+
if (j(o) && typeof e == "string") {
|
|
220
220
|
if (e === "href") return o.url ?? "";
|
|
221
221
|
if (e === "target" && o.external) return "_blank";
|
|
222
222
|
if (e === "rel" && o.external) return "noopener noreferrer";
|
|
223
223
|
}
|
|
224
|
+
if (v(o) && typeof e == "string" && e !== "focal" && e in o)
|
|
225
|
+
return o[e];
|
|
224
226
|
if (o != null && typeof o != "object") {
|
|
225
227
|
const s = o[e];
|
|
226
228
|
return s !== void 0 ? typeof s == "function" ? (...u) => s.apply(o, u) : s : m(null, f);
|
|
@@ -234,7 +236,7 @@ function m(t, r, i) {
|
|
|
234
236
|
// For spread: expose data-okno, plus all keys for file objects (src, alt, width, height, etc.)
|
|
235
237
|
ownKeys(n) {
|
|
236
238
|
const e = n.__raw;
|
|
237
|
-
return
|
|
239
|
+
return v(e) ? [...Object.keys(e).filter((o) => o !== "focal"), "data-okno"] : j(e) ? e.external ? ["href", "target", "rel", "data-okno"] : ["href", "data-okno"] : ["data-okno"];
|
|
238
240
|
},
|
|
239
241
|
getOwnPropertyDescriptor(n, e) {
|
|
240
242
|
if (e === "data-okno")
|
|
@@ -244,13 +246,13 @@ function m(t, r, i) {
|
|
|
244
246
|
configurable: !0
|
|
245
247
|
};
|
|
246
248
|
const o = n.__raw;
|
|
247
|
-
if (
|
|
249
|
+
if (v(o) && typeof e == "string" && e in o && e !== "focal")
|
|
248
250
|
return {
|
|
249
251
|
value: o[e],
|
|
250
252
|
enumerable: !0,
|
|
251
253
|
configurable: !0
|
|
252
254
|
};
|
|
253
|
-
if (
|
|
255
|
+
if (j(o) && (e === "href" || o.external && (e === "target" || e === "rel")))
|
|
254
256
|
return { value: void 0, enumerable: !0, configurable: !0 };
|
|
255
257
|
},
|
|
256
258
|
has(n, e) {
|
|
@@ -304,12 +306,12 @@ function ut(t, r, i, c = []) {
|
|
|
304
306
|
const o = (s, u) => {
|
|
305
307
|
const l = { ...s };
|
|
306
308
|
for (const a of n) {
|
|
307
|
-
const h = r[a], y = e[h.collection], O = (
|
|
308
|
-
if (typeof
|
|
309
|
-
const $ = y.get(
|
|
310
|
-
return $ === void 0 ? null : { __oknoRef: { path: `${h.collection}.${
|
|
311
|
-
},
|
|
312
|
-
l[a] = Array.isArray(
|
|
309
|
+
const h = r[a], y = e[h.collection], O = (p) => {
|
|
310
|
+
if (typeof p != "string" || !p) return null;
|
|
311
|
+
const $ = y.get(p);
|
|
312
|
+
return $ === void 0 ? null : { __oknoRef: { path: `${h.collection}.${p}`, data: D($, u) } };
|
|
313
|
+
}, S = s[a];
|
|
314
|
+
l[a] = Array.isArray(S) ? S.map(O).filter(Boolean) : O(S);
|
|
313
315
|
}
|
|
314
316
|
return l;
|
|
315
317
|
}, f = o(t, void 0);
|
|
@@ -350,8 +352,8 @@ function st(t, r, i = []) {
|
|
|
350
352
|
}
|
|
351
353
|
return o;
|
|
352
354
|
}
|
|
353
|
-
const d = "data-okno-item",
|
|
354
|
-
function
|
|
355
|
+
const d = "data-okno-item", A = "data-okno", H = [A, d];
|
|
356
|
+
function g(t, r, i, c = H) {
|
|
355
357
|
if (r === i) return;
|
|
356
358
|
const n = (e) => {
|
|
357
359
|
for (const o of c) {
|
|
@@ -378,8 +380,8 @@ function W(t) {
|
|
|
378
380
|
}));
|
|
379
381
|
}
|
|
380
382
|
function V(t) {
|
|
381
|
-
const r = Array.from(t.querySelectorAll(`[${
|
|
382
|
-
return t.hasAttribute(
|
|
383
|
+
const r = Array.from(t.querySelectorAll(`[${A}]`));
|
|
384
|
+
return t.hasAttribute(A) && r.unshift(t), r;
|
|
383
385
|
}
|
|
384
386
|
function F(t) {
|
|
385
387
|
for (const r of V(t))
|
|
@@ -387,7 +389,7 @@ function F(t) {
|
|
|
387
389
|
}
|
|
388
390
|
function G(t, r) {
|
|
389
391
|
for (const i of V(t)) {
|
|
390
|
-
const c = i.getAttribute(
|
|
392
|
+
const c = i.getAttribute(A);
|
|
391
393
|
c && c in r && i.children.length === 0 && (i.textContent = r[c] ?? "");
|
|
392
394
|
}
|
|
393
395
|
}
|
|
@@ -423,7 +425,7 @@ function Q(t, r, i, c) {
|
|
|
423
425
|
const o = n.slice(), [f] = o.splice(i, 1);
|
|
424
426
|
o.splice(c, 0, f);
|
|
425
427
|
const s = o.map((l) => l.getAttribute(d));
|
|
426
|
-
o.forEach((l, a) =>
|
|
428
|
+
o.forEach((l, a) => g(l, s[a], `${r}.${a}`));
|
|
427
429
|
const u = n[e - 1].nextSibling;
|
|
428
430
|
for (const l of o) t.parent.insertBefore(l, u);
|
|
429
431
|
}
|
|
@@ -431,15 +433,15 @@ function tt(t, r, i) {
|
|
|
431
433
|
const c = t.wrappers;
|
|
432
434
|
if (!(i < 0 || i >= c.length)) {
|
|
433
435
|
c[i].remove();
|
|
434
|
-
for (let n = i + 1; n < c.length; n++)
|
|
436
|
+
for (let n = i + 1; n < c.length; n++) g(c[n], `${r}.${n}`, `${r}.${n - 1}`);
|
|
435
437
|
}
|
|
436
438
|
}
|
|
437
439
|
function et(t, r, i, c) {
|
|
438
440
|
const n = t.wrappers, e = n.length;
|
|
439
441
|
if (e === 0) return;
|
|
440
442
|
const o = Math.max(0, Math.min(i.index ?? e, e)), f = o < e ? o : e - 1, s = n[f].getAttribute(d), u = n[f].cloneNode(!0);
|
|
441
|
-
for (let a = e - 1; a >= o; a--)
|
|
442
|
-
|
|
443
|
+
for (let a = e - 1; a >= o; a--) g(n[a], `${r}.${a}`, `${r}.${a + 1}`);
|
|
444
|
+
g(u, s, `${r}.${o}`), i.remap && g(u, i.remap.from, i.remap.to, [A]), i.values ? G(u, i.values) : F(u), u.style.viewTransitionName = "", c(u);
|
|
443
445
|
const l = o < e ? n[o] : n[e - 1].nextSibling;
|
|
444
446
|
t.parent.insertBefore(u, l);
|
|
445
447
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "okno",
|
|
3
3
|
"description": "Git-backed CMS with live editing for any Vite framework",
|
|
4
4
|
"author": "Gabriel Uhlíř",
|
|
5
|
-
"version": "1.0.0-beta.
|
|
5
|
+
"version": "1.0.0-beta.15",
|
|
6
6
|
"homepage": "https://okno.build",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
package/src/runtime/wrap.ts
CHANGED
|
@@ -542,6 +542,18 @@ export function __oknoWrap(data: unknown, prefix: string, slot?: string): any {
|
|
|
542
542
|
if (prop === "rel" && raw.external) return "noopener noreferrer"
|
|
543
543
|
}
|
|
544
544
|
|
|
545
|
+
// Media object: the spreadable leaf attrs (src/alt/width/height) are
|
|
546
|
+
// terminal HTML attribute values — return them RAW, not a nested proxy, so
|
|
547
|
+
// `{...cover}` read via [[Get]] yields real primitives. Object spread and
|
|
548
|
+
// Vue's `v-bind`/`ssrRenderAttrs` read through Get (not descriptors), so a
|
|
549
|
+
// wrapped-proxy leaf gets dropped as a non-string object and `<img>` loses
|
|
550
|
+
// src/alt/width. Mirrors the getOwnPropertyDescriptor trap below; `.image`
|
|
551
|
+
// (optimized bundle), `.focal`, `.onedit`, `data-okno` are handled above, so
|
|
552
|
+
// only the raw scalar attrs fall here. Media edits as a unit → no per-leaf hook lost.
|
|
553
|
+
if (isMediaObject(raw) && typeof prop === "string" && prop !== "focal" && prop in (raw as object)) {
|
|
554
|
+
return (raw as Record<string, unknown>)[prop]
|
|
555
|
+
}
|
|
556
|
+
|
|
545
557
|
// For primitive values (string, number, boolean), forward native method/property access
|
|
546
558
|
// This makes home.title.length, home.title.includes("x"), etc. work
|
|
547
559
|
if (raw !== null && raw !== undefined && typeof raw !== "object") {
|