keits 0.0.4 → 0.1.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.
Files changed (71) hide show
  1. package/README.md +93 -79
  2. package/dist/dev/api.js +8 -3
  3. package/dist/dev/forms.js +10 -5
  4. package/dist/dev/index.js +28 -35
  5. package/dist/dev/router.js +24 -7
  6. package/dist/dev/shared/{computed-3UO-KiH1.js → computed-DrF8O8b4.js} +1 -1
  7. package/dist/dev/shared/element-Bgf6SNbW.js +21 -0
  8. package/dist/dev/shared/{graph-D6-x_CWC.js → graph-SIvYLXSv.js} +62 -3
  9. package/dist/dev/shared/hydrate-g_akkVyT.js +588 -0
  10. package/dist/dev/shared/{element-CQPqagu1.js → insert-DadcXJL8.js} +116 -86
  11. package/dist/dev/shared/mount-BtpMEhSZ.js +23 -0
  12. package/dist/dev/shared/{owner-Dmge21OW.js → owner-BuwIoI4j.js} +12 -2
  13. package/dist/dev/shared/render-context-k2uu_dM_.js +34 -0
  14. package/dist/dev/shared/render-effect-Uk9dDmuU.js +32 -0
  15. package/dist/dev/shared/{resource-CbXVATvq.js → resource-DlgzdtcG.js} +24 -33
  16. package/dist/dev/shared/{signal-BOXkY-Iv.js → signal-B3xOKbVm.js} +1 -1
  17. package/dist/dev/shared/{store-BzUN1qE5.js → store-0vEg2bQV.js} +7 -3
  18. package/dist/dev/shared/unsafe-keys-CB1P22No.js +8 -0
  19. package/dist/dev/static.js +76 -0
  20. package/dist/dev/svg.js +2 -1
  21. package/dist/dev/testing.js +236 -0
  22. package/dist/dev/vite.js +141 -0
  23. package/dist/prod/api.js +76 -71
  24. package/dist/prod/forms.js +89 -84
  25. package/dist/prod/index.js +58 -66
  26. package/dist/prod/router.js +86 -73
  27. package/dist/prod/shared/{computed-CAPpOLCY.js → computed-BjqJ6Pps.js} +1 -1
  28. package/dist/prod/shared/element-B-0tH1YW.js +15 -0
  29. package/dist/prod/shared/{graph-C_aA46c6.js → graph-CR2WKbwr.js} +107 -63
  30. package/dist/prod/shared/hydrate-DhHCtdOz.js +480 -0
  31. package/dist/prod/shared/insert-CbcOsYmu.js +192 -0
  32. package/dist/prod/shared/mount-BEAO35S_.js +18 -0
  33. package/dist/prod/shared/owner-DBi3odT4.js +67 -0
  34. package/dist/prod/shared/render-context-DF8lr1uu.js +30 -0
  35. package/dist/prod/shared/render-effect-UFDi2Pfh.js +25 -0
  36. package/dist/prod/shared/resource-Ch5tVseZ.js +91 -0
  37. package/dist/prod/shared/signal-BDMlfa0Z.js +16 -0
  38. package/dist/prod/shared/store-CvW0DbmK.js +110 -0
  39. package/dist/prod/shared/unsafe-keys-C5PMlerl.js +7 -0
  40. package/dist/prod/static.js +48 -0
  41. package/dist/prod/svg.js +3 -2
  42. package/dist/prod/testing.js +161 -0
  43. package/dist/prod/vite.js +106 -0
  44. package/dist/types/async/render-context.d.ts +10 -0
  45. package/dist/types/core/effect.d.ts +1 -0
  46. package/dist/types/core/graph.d.ts +11 -0
  47. package/dist/types/core/owner.d.ts +1 -0
  48. package/dist/types/core/unsafe-keys.d.ts +2 -0
  49. package/dist/types/dom/hooks.d.ts +4 -0
  50. package/dist/types/dom/props.d.ts +2 -0
  51. package/dist/types/dom/types.d.ts +5 -0
  52. package/dist/types/router/index.d.ts +1 -0
  53. package/dist/types/router/match.d.ts +1 -0
  54. package/dist/types/router/types.d.ts +1 -0
  55. package/dist/types/static/head.d.ts +36 -0
  56. package/dist/types/static/hydrate.d.ts +3 -0
  57. package/dist/types/static/index.d.ts +4 -0
  58. package/dist/types/static/island.d.ts +14 -0
  59. package/dist/types/static/json.d.ts +1 -0
  60. package/dist/types/static/render.d.ts +11 -0
  61. package/dist/types/static/server-dom.d.ts +100 -0
  62. package/dist/types/testing/index.d.ts +69 -0
  63. package/dist/types/vite/index.d.ts +24 -0
  64. package/package.json +35 -8
  65. package/dist/dev/shared/render-effect-kOGnLNbL.js +0 -26
  66. package/dist/prod/shared/element-DGyQ01Vs.js +0 -164
  67. package/dist/prod/shared/owner-6BFHIPR9.js +0 -59
  68. package/dist/prod/shared/render-effect-DjaUT3Cn.js +0 -23
  69. package/dist/prod/shared/resource-CNC2DBO3.js +0 -109
  70. package/dist/prod/shared/signal-DGrl3r9T.js +0 -16
  71. package/dist/prod/shared/store-Dcscpk_h.js +0 -109
@@ -0,0 +1,480 @@
1
+ import { _ as e, p as t, s as n, u as r, v as i, y as a } from "./graph-CR2WKbwr.js";
2
+ import { t as o } from "./render-effect-UFDi2Pfh.js";
3
+ import { a as s, i as c } from "./owner-DBi3odT4.js";
4
+ import { a as l, i as u, o as d, r as f, t as p } from "./render-context-DF8lr1uu.js";
5
+ import { a as m, c as h, i as g, o as _, t as v } from "./insert-CbcOsYmu.js";
6
+ // src/static/json.ts
7
+ function y(e) {
8
+ return JSON.stringify(e).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
9
+ }
10
+ // src/static/head.ts
11
+ var b = u(null);
12
+ function x(e) {
13
+ let t = d(b) ?? (typeof document > "u" ? null : E());
14
+ if (t === null) return;
15
+ let n = {};
16
+ o(() => t.set(n, ee(e))), s(() => t.remove(n));
17
+ }
18
+ var S = (e) => typeof e == "function" ? e() : e, C = (e) => `"${e.replace(/["\\]/g, "\\$&")}"`;
19
+ function ee(e) {
20
+ let t = [], n = (e, n, r) => {
21
+ r !== void 0 && t.push({
22
+ key: `${e}:${n}`,
23
+ tag: "meta",
24
+ attrs: {
25
+ [e]: n,
26
+ content: r
27
+ },
28
+ selector: `meta[${e}=${C(n)}]`
29
+ });
30
+ }, r = S(e.title);
31
+ r !== void 0 && t.push({
32
+ key: "title",
33
+ tag: "title",
34
+ attrs: {},
35
+ text: r,
36
+ selector: "title"
37
+ }), n("name", "description", S(e.description)), n("name", "robots", S(e.robots));
38
+ let i = S(e.canonical);
39
+ i !== void 0 && t.push({
40
+ key: "link:canonical",
41
+ tag: "link",
42
+ attrs: {
43
+ rel: "canonical",
44
+ href: i
45
+ },
46
+ selector: "link[rel=\"canonical\"]"
47
+ });
48
+ for (let [t, r] of Object.entries(e.og ?? {})) n("property", `og:${t}`, S(r));
49
+ for (let [t, r] of Object.entries(e.twitter ?? {})) n("name", `twitter:${t}`, S(r));
50
+ for (let t of e.meta ?? []) t.property === void 0 ? t.name !== void 0 && n("name", t.name, S(t.content)) : n("property", t.property, S(t.content));
51
+ for (let n of e.link ?? []) t.push({
52
+ key: `link:${n.rel}:${n.href}`,
53
+ tag: "link",
54
+ attrs: { ...n },
55
+ selector: `link[rel=${C(n.rel)}][href=${C(n.href)}]`
56
+ });
57
+ let a = typeof e.jsonLd == "function" ? e.jsonLd() : e.jsonLd;
58
+ return a !== void 0 && t.push({
59
+ key: "jsonld",
60
+ tag: "script",
61
+ attrs: { type: "application/ld+json" },
62
+ text: y(a),
63
+ selector: "script[type=\"application/ld+json\"]"
64
+ }), t;
65
+ }
66
+ function w(e = () => {}) {
67
+ let t = /* @__PURE__ */ new Map(), n = {
68
+ set(r, i) {
69
+ t.set(r, i), e(n.winners());
70
+ },
71
+ remove(r) {
72
+ t.delete(r), e(n.winners());
73
+ },
74
+ winners() {
75
+ let e = /* @__PURE__ */ new Map();
76
+ for (let n of t.values()) for (let t of n) e.set(t.key, t);
77
+ return e;
78
+ }
79
+ };
80
+ return n;
81
+ }
82
+ var T = null;
83
+ function E() {
84
+ if (T !== null) return T;
85
+ let e = /* @__PURE__ */ new Map(), t = document.title;
86
+ return T = w((n) => {
87
+ for (let [r, i] of e) n.has(r) || (i === null ? document.title = t : i.remove(), e.delete(r));
88
+ for (let [t, r] of n) {
89
+ if (r.tag === "title") {
90
+ document.title !== r.text && (document.title = r.text ?? ""), e.set(t, null);
91
+ continue;
92
+ }
93
+ let n = e.get(t) ?? null;
94
+ n !== null && !n.isConnected && (n = null);
95
+ let i = n ?? document.head.querySelector(r.selector);
96
+ i === null && (i = document.createElement(r.tag), document.head.append(i));
97
+ for (let [e, t] of Object.entries(r.attrs)) i.getAttribute(e) !== t && i.setAttribute(e, t);
98
+ r.text !== void 0 && i.textContent !== r.text && (i.textContent = r.text), e.set(t, i);
99
+ }
100
+ }), T;
101
+ }
102
+ // src/static/server-dom.ts
103
+ var D = class {
104
+ parentNode = null;
105
+ previousSibling = null;
106
+ nextSibling = null;
107
+ remove() {
108
+ this.parentNode?.removeChild(this);
109
+ }
110
+ before(...e) {
111
+ let t = this.parentNode;
112
+ if (t !== null) for (let n of e) t.insertBefore(z(n), this);
113
+ }
114
+ after(...e) {
115
+ let t = this.parentNode, n = this.nextSibling;
116
+ if (t !== null) for (let r of e) t.insertBefore(z(r), n);
117
+ }
118
+ }, O = class extends D {
119
+ firstChild = null;
120
+ lastChild = null;
121
+ insertBefore(e, t) {
122
+ if (e instanceof k) {
123
+ for (; e.firstChild !== null;) this.insertBefore(e.firstChild, t);
124
+ return e;
125
+ }
126
+ return e.remove(), e.parentNode = this, e.nextSibling = t, e.previousSibling = t === null ? this.lastChild : t.previousSibling, e.previousSibling === null ? this.firstChild = e : e.previousSibling.nextSibling = e, t === null ? this.lastChild = e : t.previousSibling = e, e;
127
+ }
128
+ appendChild(e) {
129
+ return this.insertBefore(e, null);
130
+ }
131
+ append(...e) {
132
+ for (let t of e) this.insertBefore(z(t), null);
133
+ }
134
+ removeChild(e) {
135
+ return e.previousSibling === null ? this.firstChild = e.nextSibling : e.previousSibling.nextSibling = e.nextSibling, e.nextSibling === null ? this.lastChild = e.previousSibling : e.nextSibling.previousSibling = e.previousSibling, e.parentNode = e.previousSibling = e.nextSibling = null, e;
136
+ }
137
+ get textContent() {
138
+ let e = "";
139
+ for (let t = this.firstChild; t !== null; t = t.nextSibling) e += t.textContent;
140
+ return e;
141
+ }
142
+ set textContent(e) {
143
+ for (; this.firstChild !== null;) this.removeChild(this.firstChild);
144
+ e !== "" && this.appendChild(new A(e));
145
+ }
146
+ printChildren(e, t) {
147
+ for (let n = this.firstChild; n !== null; n = n.nextSibling) n.print(e, t);
148
+ }
149
+ }, k = class extends O {
150
+ nodeType = 11;
151
+ print(e, t) {
152
+ this.printChildren(e, t);
153
+ }
154
+ }, A = class extends D {
155
+ nodeType = 3;
156
+ data;
157
+ constructor(e) {
158
+ super(), this.data = e;
159
+ }
160
+ get textContent() {
161
+ return this.data;
162
+ }
163
+ print(e, t) {
164
+ e.push(t ? H(this.data) : B(this.data));
165
+ }
166
+ }, j = class extends D {
167
+ nodeType = 8;
168
+ data;
169
+ constructor(e) {
170
+ super(), this.data = e;
171
+ }
172
+ get textContent() {
173
+ return "";
174
+ }
175
+ print() {}
176
+ }, M = class extends D {
177
+ nodeType = 3;
178
+ html;
179
+ constructor(e) {
180
+ super(), this.html = e;
181
+ }
182
+ get textContent() {
183
+ return "";
184
+ }
185
+ print(e) {
186
+ e.push(this.html);
187
+ }
188
+ }, N = /* @__PURE__ */ new Set([
189
+ "area",
190
+ "base",
191
+ "br",
192
+ "col",
193
+ "embed",
194
+ "hr",
195
+ "img",
196
+ "input",
197
+ "link",
198
+ "meta",
199
+ "source",
200
+ "track",
201
+ "wbr"
202
+ ]), P = /* @__PURE__ */ new Set(["script", "style"]), F = /^[^\s"'<>/=\u0000-\u001f\u007f]+$/, te = {
203
+ className: "class",
204
+ htmlFor: "for",
205
+ httpEquiv: "http-equiv",
206
+ acceptCharset: "accept-charset"
207
+ }, I = class extends O {
208
+ nodeType = 1;
209
+ localName;
210
+ namespaceURI;
211
+ classList;
212
+ style;
213
+ #e = /* @__PURE__ */ new Map();
214
+ #t = {};
215
+ constructor(e, t) {
216
+ if (super(), !F.test(e)) throw Error("[keits/static] bad tag");
217
+ this.localName = t === null ? e.toLowerCase() : e, this.namespaceURI = t, this.classList = new L(this), this.style = new R(this);
218
+ }
219
+ getAttribute(e) {
220
+ return this.#e.get(this.#n(e)) ?? null;
221
+ }
222
+ hasAttribute(e) {
223
+ return this.#e.has(this.#n(e));
224
+ }
225
+ setAttribute(e, t) {
226
+ if (!F.test(e)) throw Error("[keits/static] bad attribute");
227
+ this.#e.set(this.#n(e), String(t));
228
+ }
229
+ removeAttribute(e) {
230
+ this.#e.delete(this.#n(e));
231
+ }
232
+ toggleAttribute(e, t) {
233
+ let n = t ?? !this.hasAttribute(e);
234
+ return n ? this.setAttribute(e, "") : this.removeAttribute(e), n;
235
+ }
236
+ #n(e) {
237
+ return this.namespaceURI === null ? e.toLowerCase() : e;
238
+ }
239
+ get value() {
240
+ return this.#t.value ?? "";
241
+ }
242
+ set value(e) {
243
+ this.#t.value = e;
244
+ }
245
+ get checked() {
246
+ return this.#t.checked === !0;
247
+ }
248
+ set checked(e) {
249
+ this.#t.checked = e;
250
+ }
251
+ get selected() {
252
+ return this.#t.selected === !0;
253
+ }
254
+ set selected(e) {
255
+ this.#t.selected = e;
256
+ }
257
+ get textContent() {
258
+ return super.textContent;
259
+ }
260
+ set textContent(e) {
261
+ super.textContent = e == null ? "" : String(e);
262
+ }
263
+ set className(e) {
264
+ this.setAttribute("class", e);
265
+ }
266
+ set htmlFor(e) {
267
+ this.setAttribute(te.htmlFor, e);
268
+ }
269
+ set draggable(e) {
270
+ this.setAttribute("draggable", String(e));
271
+ }
272
+ set spellcheck(e) {
273
+ this.setAttribute("spellcheck", String(e));
274
+ }
275
+ print(e) {
276
+ e.push(`<${this.localName}`);
277
+ for (let [t, n] of this.#e) e.push(n === "" ? ` ${t}` : ` ${t}="${V(n)}"`);
278
+ e.push(">"), this.namespaceURI === null && N.has(this.localName) || (this.printChildren(e, this.namespaceURI === null && P.has(this.localName)), e.push(`</${this.localName}>`));
279
+ }
280
+ }, L = class {
281
+ #e;
282
+ constructor(e) {
283
+ this.#e = e;
284
+ }
285
+ #t() {
286
+ return (this.#e.getAttribute("class") ?? "").split(/\s+/).filter(Boolean);
287
+ }
288
+ #n(e) {
289
+ e.length === 0 ? this.#e.removeAttribute("class") : this.#e.setAttribute("class", e.join(" "));
290
+ }
291
+ contains(e) {
292
+ return this.#t().includes(e);
293
+ }
294
+ add(...e) {
295
+ let t = this.#t();
296
+ for (let n of e) t.includes(n) || t.push(n);
297
+ this.#n(t);
298
+ }
299
+ remove(...e) {
300
+ this.#n(this.#t().filter((t) => !e.includes(t)));
301
+ }
302
+ toggle(e, t) {
303
+ let n = t ?? !this.contains(e);
304
+ return n ? this.add(e) : this.remove(e), n;
305
+ }
306
+ }, R = class {
307
+ #e;
308
+ #t = /* @__PURE__ */ new Map();
309
+ constructor(e) {
310
+ this.#e = e;
311
+ }
312
+ getPropertyValue(e) {
313
+ return this.#t.get(e) ?? "";
314
+ }
315
+ setProperty(e, t) {
316
+ t === "" ? this.#t.delete(e) : this.#t.set(e, t), this.#n();
317
+ }
318
+ removeProperty(e) {
319
+ let t = this.getPropertyValue(e);
320
+ return this.#t.delete(e), this.#n(), t;
321
+ }
322
+ get cssText() {
323
+ return [...this.#t].map(([e, t]) => `${e}: ${t};`).join(" ");
324
+ }
325
+ set cssText(e) {
326
+ this.#t.clear();
327
+ for (let t of e.split(";")) {
328
+ let e = t.indexOf(":");
329
+ e > 0 && this.#t.set(t.slice(0, e).trim(), t.slice(e + 1).trim());
330
+ }
331
+ this.#n();
332
+ }
333
+ get display() {
334
+ return this.getPropertyValue("display");
335
+ }
336
+ set display(e) {
337
+ this.setProperty("display", e);
338
+ }
339
+ #n() {
340
+ this.#t.size === 0 ? this.#e.removeAttribute("style") : this.#e.setAttribute("style", this.cssText);
341
+ }
342
+ };
343
+ function z(e) {
344
+ return typeof e == "string" ? new A(e) : e;
345
+ }
346
+ function B(e) {
347
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
348
+ }
349
+ function V(e) {
350
+ return B(e).replace(/"/g, "&quot;");
351
+ }
352
+ function H(e) {
353
+ return e.replace(/<\/(script|style)/gi, "<\\/$1");
354
+ }
355
+ var U = {
356
+ element(e, n) {
357
+ let i = new I(e, n === "http://www.w3.org/2000/svg" ? g : n), a = t();
358
+ return a !== null && r() && i.setAttribute("data-k", a), i;
359
+ },
360
+ text: (e) => new A(e),
361
+ marker: () => new j(""),
362
+ fragment: () => new k(),
363
+ html: (e) => {
364
+ let t = new k();
365
+ return t.appendChild(new M(e)), t;
366
+ }
367
+ };
368
+ function W(e) {
369
+ let t = [];
370
+ return e.print(t, !1), t.join("");
371
+ }
372
+ // src/static/render.ts
373
+ var G = 0, K = null;
374
+ async function q(t, o = {}) {
375
+ G++ === 0 && (K = h(U)), e();
376
+ let s = /* @__PURE__ */ new Set(), c = {}, u = {
377
+ wait(e) {
378
+ s.add(e);
379
+ let t = () => s.delete(e);
380
+ e.then(t, t);
381
+ },
382
+ store(e, t, n) {
383
+ r(n) && (c[e] = t);
384
+ }
385
+ }, d = w(), f = () => {};
386
+ try {
387
+ let e = i((e) => {
388
+ f = e;
389
+ let r = U.fragment();
390
+ return l(p, u, () => l(b, d, () => {
391
+ let e = n();
392
+ e.key = "0", e.keyCount = 0, o.hydrate && (e.hydratable = !0), v(r, t());
393
+ })), r;
394
+ }), r = o.timeout ?? 1e4, a = Date.now() + r;
395
+ for (; s.size > 0;) await J(Promise.all(s), a - Date.now(), r);
396
+ return {
397
+ html: W(e),
398
+ head: Y(d.winners()),
399
+ data: X(c)
400
+ };
401
+ } finally {
402
+ f(), a(), --G === 0 && h(K);
403
+ }
404
+ }
405
+ function J(e, t, n) {
406
+ return new Promise((r, i) => {
407
+ let a = setTimeout(() => i(/* @__PURE__ */ Error(`[keits/static] Data was still loading after ${n} ms: the page could not be rendered.`)), Math.max(0, t));
408
+ e.then((e) => (clearTimeout(a), r(e)), (e) => (clearTimeout(a), i(e)));
409
+ });
410
+ }
411
+ function Y(e) {
412
+ let t = "";
413
+ for (let n of e.values()) {
414
+ let e = Object.entries(n.attrs).map(([e, t]) => {
415
+ if (!F.test(e)) throw Error("[keits/static] bad attribute");
416
+ return ` ${e}="${V(t)}"`;
417
+ }).join("");
418
+ n.tag === "title" ? t += `<title>${B(n.text ?? "")}</title>` : n.tag === "script" ? t += `<script${e}>${n.text ?? ""}<\/script>` : t += `<${n.tag}${e}>`;
419
+ }
420
+ return t;
421
+ }
422
+ function X(e) {
423
+ return Object.keys(e).length === 0 ? "" : `<script type="application/json" id="keits-data">${y(e)}<\/script>`;
424
+ }
425
+ // src/static/hydrate.ts
426
+ var Z = null, Q = null;
427
+ function ne(e) {
428
+ if (Q === null) {
429
+ let e = [...document.querySelectorAll("script[type=\"application/json\"]#keits-data")].pop() ?? null;
430
+ Q = e === null ? {} : JSON.parse(e.textContent ?? "{}");
431
+ }
432
+ return Object.hasOwn(Q, e) ? { value: Q[e] } : void 0;
433
+ }
434
+ function re() {
435
+ Q = null;
436
+ }
437
+ var ie = {
438
+ ..._,
439
+ element(e, n) {
440
+ let r = t();
441
+ if (Z !== null && r !== null && !m()) {
442
+ let t = Z.byKey.get(r);
443
+ if (t !== void 0 && t.localName === (n === null ? e.toLowerCase() : e)) return Z.byKey.delete(r), t.removeAttribute("data-k"), $(t), t;
444
+ Z.mismatch ??= t === void 0 ? `no <${e}> with key ${r}` : `<${t.localName}> instead of <${e}> at key ${r}`;
445
+ }
446
+ return _.element(e, n);
447
+ }
448
+ };
449
+ function $(e) {
450
+ for (let t = e.firstChild; t !== null;) {
451
+ let n = t.nextSibling;
452
+ t.nodeType === 1 && t.hasAttribute("data-k") || e.removeChild(t), t = n;
453
+ }
454
+ }
455
+ function ae(t, n, r = "0") {
456
+ let i = /* @__PURE__ */ new Map();
457
+ for (let e of n.querySelectorAll("[data-k]")) i.set(e.getAttribute("data-k"), e);
458
+ let o = {
459
+ byKey: i,
460
+ mismatch: null
461
+ };
462
+ f(ne);
463
+ let s = Z, l = h(ie);
464
+ Z = o, e();
465
+ let u;
466
+ try {
467
+ $(n), u = c(r, !1, (e) => (v(n, t()), e));
468
+ } finally {
469
+ a(), Z = s, h(l);
470
+ }
471
+ let d = n.querySelector("[data-k]");
472
+ if (o.mismatch === null && d === null) return u;
473
+ u(), n.textContent = "", e();
474
+ try {
475
+ return c(r, !1, (e) => (v(n, t()), e));
476
+ } finally {
477
+ a();
478
+ }
479
+ }
480
+ export { x as i, re as n, q as r, ae as t };
@@ -0,0 +1,192 @@
1
+ import { d as e, g as t, i as n, l as r, s as i } from "./graph-CR2WKbwr.js";
2
+ import { t as a } from "./unsafe-keys-C5PMlerl.js";
3
+ import { t as o } from "./render-effect-UFDi2Pfh.js";
4
+ // src/dom/hooks.ts
5
+ var s = {
6
+ element: (e, t) => t === null ? document.createElement(e) : document.createElementNS(t, e),
7
+ text: (e) => document.createTextNode(e),
8
+ marker: () => document.createComment(""),
9
+ fragment: () => document.createDocumentFragment()
10
+ }, c = 0;
11
+ function l(e) {
12
+ c++;
13
+ try {
14
+ return e();
15
+ } finally {
16
+ c--;
17
+ }
18
+ }
19
+ function u() {
20
+ return c > 0;
21
+ }
22
+ var d = s;
23
+ function f(e) {
24
+ let t = d;
25
+ return d = e, t;
26
+ }
27
+ // src/dom/events.ts
28
+ function p(t, n, r) {
29
+ let i = r, a;
30
+ if (Array.isArray(r) && ([i, a] = r), typeof i != "function") throw Error("[keits] bad handler");
31
+ e() || m(t, n.slice(2), i, a);
32
+ }
33
+ function m(e, a, o, s) {
34
+ let c = i();
35
+ e.addEventListener(a, (e) => {
36
+ n(() => {
37
+ try {
38
+ let i = t(c, () => o(e));
39
+ h(i) && i.then(void 0, (e) => n(() => r(e, c)));
40
+ } catch (e) {
41
+ r(e, c);
42
+ }
43
+ });
44
+ }, s);
45
+ }
46
+ function h(e) {
47
+ return typeof e?.then == "function";
48
+ }
49
+ // src/dom/namespaces.ts
50
+ var g = "http://www.w3.org/2000/svg", _ = /* @__PURE__ */ new Set([
51
+ "innerhtml",
52
+ "outerhtml",
53
+ "srcdoc"
54
+ ]), v = /* @__PURE__ */ new Set([
55
+ "href",
56
+ "src",
57
+ "action",
58
+ "formaction",
59
+ "poster",
60
+ "cite",
61
+ "data",
62
+ "xlink:href",
63
+ "to",
64
+ "from",
65
+ "values"
66
+ ]), y = "about:invalid#keits-blocked";
67
+ function b(e, t) {
68
+ for (let n in t) {
69
+ let r = t[n];
70
+ n !== "ref" && (n === "class" ? O(e, r) : n === "style" ? M(e, r) : n.toLowerCase().startsWith("on") ? p(e, n, r) : typeof r == "function" ? o(() => x(e, n, r())) : x(e, n, r));
71
+ }
72
+ }
73
+ function x(t, n, r) {
74
+ let i = n.toLowerCase();
75
+ if (_.has(i) || a.has(n) || i.startsWith("on") && typeof r == "string") throw Error("[keits] unsafe prop");
76
+ v.has(i) && r != null && r !== !1 && T(String(r)) && (r = y), n in t && t.namespaceURI !== "http://www.w3.org/2000/svg" ? (t[n] = r, e() ? E(t, n, r) : n === "value" && t.localName === "select" && C(t, r)) : n.startsWith("aria-") && typeof r == "boolean" ? t.setAttribute(n, String(r)) : r == null || r === !1 ? t.removeAttribute(n) : t.setAttribute(n, r === !0 ? "" : String(r));
77
+ }
78
+ var S = /* @__PURE__ */ new WeakMap();
79
+ function C(e, t) {
80
+ S.has(e) || e.addEventListener("change", () => S.set(e, e.value)), S.set(e, t == null ? "" : String(t));
81
+ }
82
+ function w(e) {
83
+ let t = e;
84
+ t?.localName === "optgroup" && (t = t.parentElement);
85
+ let n = t && S.get(t);
86
+ n != null && t.value !== n && (t.value = n);
87
+ }
88
+ function T(e) {
89
+ return e.replace(/[\u0000-\u0020]/g, "").toLowerCase().split(";").some((e) => e.startsWith("javascript:"));
90
+ }
91
+ function E(e, t, n) {
92
+ t === "value" ? e.localName === "textarea" ? e.textContent = n == null ? "" : String(n) : e.localName === "select" ? D(e, n == null ? "" : String(n)) : n == null ? e.removeAttribute("value") : e.setAttribute("value", String(n)) : (t === "checked" || t === "selected") && e.toggleAttribute(t, n === !0);
93
+ }
94
+ function D(e, t) {
95
+ for (let n = e.firstChild; n !== null; n = n.nextSibling) {
96
+ if (n.nodeType !== 1) continue;
97
+ let e = n;
98
+ e.localName === "option" ? e.toggleAttribute("selected", (e.getAttribute("value") ?? e.textContent) === t) : D(e, t);
99
+ }
100
+ }
101
+ function O(e, t) {
102
+ if (typeof t == "function") {
103
+ o(() => k(e, j(t())));
104
+ return;
105
+ }
106
+ let n = [], r = [];
107
+ A(t, n, (e, t) => r.push([e, t])), n.length > 0 && e.classList.add(...n);
108
+ for (let [t, n] of r) o(() => e.classList.toggle(t, n()));
109
+ }
110
+ function k(e, t) {
111
+ t === "" ? e.removeAttribute("class") : e.setAttribute("class", t);
112
+ }
113
+ function A(e, t, n) {
114
+ if (e) {
115
+ if (typeof e == "string") for (let n of e.split(/\s+/)) n && t.push(n);
116
+ else if (Array.isArray(e)) for (let r of e) A(r, t, n);
117
+ else for (let [r, i] of Object.entries(e)) typeof i == "function" ? n ? n(r, i) : i() && t.push(r) : i && t.push(r);
118
+ }
119
+ }
120
+ function j(e) {
121
+ let t = [];
122
+ return A(e, t), t.join(" ");
123
+ }
124
+ function M(e, t) {
125
+ let n = e.style;
126
+ if (typeof t == "function") {
127
+ let e = [];
128
+ o(() => {
129
+ let r = t();
130
+ if (typeof r == "string" || r == null) {
131
+ n.cssText = r ?? "", e = [];
132
+ return;
133
+ }
134
+ let i = Object.keys(r);
135
+ for (let t of e) t in r || n.removeProperty(t);
136
+ for (let e of i) P(n, e, N(r[e]));
137
+ e = i;
138
+ });
139
+ } else if (typeof t == "string") n.cssText = t;
140
+ else if (t != null) for (let [e, r] of Object.entries(t)) typeof r == "function" ? o(() => P(n, e, r())) : P(n, e, r);
141
+ }
142
+ function N(e) {
143
+ return typeof e == "function" ? e() : e;
144
+ }
145
+ function P(e, t, n) {
146
+ n == null || n === "" ? e.removeProperty(t) : e.setProperty(t, String(n));
147
+ }
148
+ // src/dom/insert.ts
149
+ function F(e, t, n = null) {
150
+ if (t != null && typeof t != "boolean") {
151
+ if (typeof t == "function") return z(e, t, n);
152
+ if (I(t)) for (let r of t) F(e, r, n);
153
+ else if (typeof t == "object") {
154
+ if (!t.nodeType) throw Error("[keits] bad child");
155
+ e.insertBefore(t, n);
156
+ } else e.insertBefore(d.text(String(t)), n);
157
+ }
158
+ }
159
+ function I(e) {
160
+ return Array.isArray(e);
161
+ }
162
+ function L(e) {
163
+ return e === null || typeof e != "object" && typeof e != "function";
164
+ }
165
+ function R(e) {
166
+ return e == null || typeof e == "boolean" ? "" : String(e);
167
+ }
168
+ function z(e, t, n) {
169
+ let r = d.text("");
170
+ e.insertBefore(r, n);
171
+ let i = null, a = null;
172
+ o(() => {
173
+ let e = t();
174
+ if (i === null || a === null) {
175
+ if (L(e)) {
176
+ let t = R(e);
177
+ r.data !== t && (r.data = t);
178
+ return;
179
+ }
180
+ i = d.marker(), a = d.marker(), r.before(i), r.after(a), r.remove();
181
+ }
182
+ B(i, a), F(a.parentNode, e, a), w(a.parentNode);
183
+ });
184
+ }
185
+ function B(e, t) {
186
+ let n = e.nextSibling;
187
+ for (; n !== null && n !== t;) {
188
+ let e = n.nextSibling;
189
+ n.remove(), n = e;
190
+ }
191
+ }
192
+ export { u as a, f as c, g as i, l, b as n, s as o, w as r, d as s, F as t };
@@ -0,0 +1,18 @@
1
+ import { n as e } from "./owner-DBi3odT4.js";
2
+ import { s as t, t as n } from "./insert-CbcOsYmu.js";
3
+ // src/dom/mount.ts
4
+ function r(r, i) {
5
+ if (i === null) throw Error("[keits] no target");
6
+ let a = t.marker(), o = t.marker();
7
+ i.append(a, o);
8
+ let s = e((e) => (n(i, r(), o), e));
9
+ return () => {
10
+ s();
11
+ let e = a;
12
+ for (; e !== null;) {
13
+ let t = e === o ? null : e.nextSibling;
14
+ e.remove(), e = t;
15
+ }
16
+ };
17
+ }
18
+ export { r as t };