solely 0.0.11 → 0.0.13

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/solely.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './utils';
2
- export { default as BaseElement } from './elements/base/base-element';
3
- export { CustomElement } from './elements/base/decorators';
4
- export type { Manifest } from './elements/base/decorators';
2
+ export { default as BaseElement } from './base/base-element';
3
+ export { CustomElement } from './base/decorators';
4
+ export type { Manifest } from './base/decorators';
package/dist/solely.js CHANGED
@@ -1,53 +1,53 @@
1
1
  var M = (e) => {
2
2
  throw TypeError(e);
3
3
  };
4
- var S = (e, t, n) => t.has(e) || M("Cannot " + n);
5
- var h = (e, t, n) => (S(e, t, "read from private field"), n ? n.call(e) : t.get(e)), y = (e, t, n) => t.has(e) ? M("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), g = (e, t, n, s) => (S(e, t, "write to private field"), s ? s.call(e, n) : t.set(e, n), n), k = (e, t, n) => (S(e, t, "access private method"), n);
6
- const Q = /<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g, X = /<\/?([^\s]+?)[/\s>]/, J = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g, K = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"], w = /\{\{(.+?)\}\}/g;
7
- function Z(e) {
4
+ var T = (e, t, n) => t.has(e) || M("Cannot " + n);
5
+ var m = (e, t, n) => (T(e, t, "read from private field"), n ? n.call(e) : t.get(e)), g = (e, t, n) => t.has(e) ? M("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), d = (e, t, n, s) => (T(e, t, "write to private field"), s ? s.call(e, n) : t.set(e, n), n), k = (e, t, n) => (T(e, t, "access private method"), n);
6
+ const J = /<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g, K = /<\/?([^\s]+?)[/\s>]/, Z = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g, G = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"], w = /\{\{(.+?)\}\}/g;
7
+ function U(e) {
8
8
  return e.replace(/>\s+</g, "><").replace(/\s+/g, " ");
9
9
  }
10
- function G(e, t) {
11
- const n = (t.match(X) || [])[1] || "", s = {
10
+ function Y(e, t) {
11
+ const n = (t.match(K) || [])[1] || "", s = {
12
12
  rootId: 0,
13
13
  tagName: n,
14
14
  attrs: {},
15
15
  props: {},
16
16
  on: {},
17
17
  children: []
18
- }, o = new RegExp(J);
18
+ }, r = new RegExp(Z);
19
19
  for (; ; ) {
20
- const r = o.exec(t);
21
- if (r === null) break;
22
- if (!r[0].trim()) continue;
23
- const [a, i] = r[1] ? r[1].trim().split("=") : [r[2], r[3].trim().slice(1, -1)];
24
- if (U.includes(a) || a.startsWith("on-"))
20
+ const o = r.exec(t);
21
+ if (o === null) break;
22
+ if (!o[0].trim()) continue;
23
+ const [a, i] = o[1] ? o[1].trim().split("=") : [o[2], o[3].trim().slice(1, -1)];
24
+ if (tt.includes(a) || a.startsWith("on-"))
25
25
  s.on[a.startsWith("on-") ? a.slice(3) : a.slice(2)] = R(e, `return (${i})`);
26
26
  else if (a.startsWith("s-")) {
27
- const m = a.slice(2);
28
- switch (m) {
27
+ const f = a.slice(2);
28
+ switch (f) {
29
29
  case "model":
30
30
  s.model = i;
31
31
  break;
32
32
  case "style":
33
- s.styles = (l) => f(e, i, l);
33
+ s.styles = (l) => h(e, i, l);
34
34
  break;
35
35
  case "class":
36
- s.classes = (l) => f(e, i, l);
36
+ s.classes = (l) => h(e, i, l);
37
37
  break;
38
38
  case "readonly":
39
- s.props.readOnly = (l) => f(e, i, l);
39
+ s.props.readOnly = (l) => h(e, i, l);
40
40
  break;
41
41
  default:
42
- s.props[m] = (l) => f(e, i, l);
42
+ s.props[f] = (l) => h(e, i, l);
43
43
  break;
44
44
  }
45
45
  } else
46
46
  s.attrs[a] = i;
47
- o.lastIndex--;
47
+ r.lastIndex--;
48
48
  }
49
- if (n === "For" ? s.fn = (r) => f(e, s.attrs.each, r) : (n === "If" || n === "ElseIf") && (s.fn = (r) => f(e, s.attrs.condition, r)), s.model) {
50
- const r = s.model.replace("this.", "").replace("$data.", ""), a = (m) => f(e, `$data.${r}`, m), i = (m) => R(e, `$data.${r}=${m}`);
49
+ if (n === "For" ? s.fn = (o) => h(e, s.attrs.each, o) : (n === "If" || n === "ElseIf") && (s.fn = (o) => h(e, s.attrs.condition, o)), s.model) {
50
+ const o = s.model.replace("this.", "").replace("$data.", ""), a = (f) => h(e, `$data.${o}`, f), i = (f) => R(e, `$data.${o}=${f}`);
51
51
  n === "input" ? s.attrs.type === "checkbox" || s.attrs.type === "radio" ? (s.props.checked = a, s.on.change = i("checked")) : (s.props.value = a, s.on.input = i("value")) : n === "textarea" ? (s.props.value = a, s.on.input = i("value")) : n === "select" && (s.props.value = a, s.on.change = i("value"));
52
52
  }
53
53
  return s;
@@ -55,31 +55,31 @@ function G(e, t) {
55
55
  function N(e, t) {
56
56
  const n = [];
57
57
  if (!t) return n;
58
- t = Z(t);
59
- const s = [], o = [], r = () => {
58
+ t = U(t);
59
+ const s = [], r = [], o = () => {
60
60
  var i;
61
61
  return s.length === 0 ? n : (i = s[s.length - 1]).children || (i.children = []);
62
62
  };
63
63
  let a = 0;
64
- return t.replace(Q, (i, m) => {
65
- const l = r();
66
- if (m > a) {
67
- const c = t.substring(a, m).trim();
64
+ return t.replace(J, (i, f) => {
65
+ const l = o();
66
+ if (f > a) {
67
+ const c = t.substring(a, f).trim();
68
68
  if (c) {
69
69
  w.lastIndex = 0;
70
- const A = !w.test(c) ? c : ($) => c.replace(w, (L, C) => f(e, C, $));
70
+ const I = !w.test(c) ? c : (C) => c.replace(w, (j, S) => h(e, S, C));
71
71
  l.push({
72
72
  rootId: 0,
73
73
  tagName: "text",
74
74
  attrs: {},
75
75
  props: {},
76
76
  on: {},
77
- content: A,
77
+ content: I,
78
78
  children: []
79
79
  });
80
80
  }
81
81
  }
82
- if (a = m + i.length, i.startsWith("<!--") && i.endsWith("-->"))
82
+ if (a = f + i.length, i.startsWith("<!--") && i.endsWith("-->"))
83
83
  l.push({
84
84
  rootId: 0,
85
85
  tagName: "comment",
@@ -90,13 +90,13 @@ function N(e, t) {
90
90
  children: []
91
91
  });
92
92
  else if (i.startsWith("</")) {
93
- const c = o.pop();
93
+ const c = r.pop();
94
94
  for (; s.length > 0 && s[s.length - 1].tagName !== c; )
95
95
  s.pop();
96
96
  s.pop();
97
97
  } else {
98
- const c = G(e, i), u = i.endsWith("/>") || K.includes(c.tagName);
99
- l.push(c), u || (s.push(c), o.push(c.tagName));
98
+ const c = Y(e, i), u = i.endsWith("/>") || G.includes(c.tagName);
99
+ l.push(c), u || (s.push(c), r.push(c.tagName));
100
100
  }
101
101
  return "";
102
102
  }), t.length > a && n.push({
@@ -109,13 +109,13 @@ function N(e, t) {
109
109
  children: []
110
110
  }), n;
111
111
  }
112
- const f = (e, t, n) => {
112
+ const h = (e, t, n) => {
113
113
  try {
114
- return P(["$data", ...n.map((o) => o.item), `return (${t})`]).bind(e)(e.$data, ...n.map((o) => o.value));
114
+ return P(["$data", ...n.map((r) => r.item), `return (${t})`]).bind(e)(e.$data, ...n.map((r) => r.value));
115
115
  } catch (s) {
116
116
  console.error(s);
117
117
  }
118
- }, R = (e, t) => (n, s) => P(["$data", "event", "value", "checked", ...s.map((r) => r.item), t]).bind(e)(e.$data, n, n.target.value, n.target.checked, ...s.map((r) => r.value)), U = [
118
+ }, R = (e, t) => (n, s) => P(["$data", "event", "value", "checked", ...s.map((o) => o.item), t]).bind(e)(e.$data, n, n.target.value, n.target.checked, ...s.map((o) => o.value)), tt = [
119
119
  "onabort",
120
120
  "onautocomplete",
121
121
  "onautocompleteerror",
@@ -178,28 +178,28 @@ const f = (e, t, n) => {
178
178
  "ontoggle",
179
179
  "onvolumechange",
180
180
  "onwaiting"
181
- ], Y = /* @__PURE__ */ (() => {
181
+ ], et = /* @__PURE__ */ (() => {
182
182
  const e = typeof requestAnimationFrame == "function" ? (t) => requestAnimationFrame(t) : typeof Promise < "u" ? (t) => Promise.resolve().then(t) : (t) => setTimeout(t, 0);
183
183
  return (t, ...n) => {
184
184
  if (typeof t != "function")
185
185
  throw new Error("runInAsyncQueue expects a function as its first argument");
186
186
  e(() => t(...n));
187
187
  };
188
- })(), T = {};
188
+ })(), W = {};
189
189
  function P(e) {
190
190
  const t = e.join(",");
191
- if (!T[t]) {
191
+ if (!W[t]) {
192
192
  const n = e[e.length - 1];
193
193
  if (n.trim() === "")
194
194
  throw new Error("Function body is empty");
195
- if (tt(n))
195
+ if (nt(n))
196
196
  throw new Error("Input contains potentially dangerous code: " + n);
197
197
  const s = new Function(...e);
198
- T[t] = s;
198
+ W[t] = s;
199
199
  }
200
- return T[t];
200
+ return W[t];
201
201
  }
202
- function tt(e) {
202
+ function nt(e) {
203
203
  return [
204
204
  "eval",
205
205
  "Function",
@@ -220,93 +220,98 @@ function tt(e) {
220
220
  "JSON.parse"
221
221
  ].some((n) => e.includes(n));
222
222
  }
223
- const et = "http://www.w3.org/1999/xlink", nt = "http://www.w3.org/2000/xmlns/", st = "http://www.w3.org/XML/1998/namespace", rt = "http://www.w3.org/2000/svg", V = (e) => typeof e.content == "function" ? e.content(e.loops || []) : e.content || "", ot = (e) => {
223
+ const st = "http://www.w3.org/1999/xlink", rt = "http://www.w3.org/2000/xmlns/", ot = "http://www.w3.org/XML/1998/namespace", at = "http://www.w3.org/2000/svg", V = (e) => typeof e.content == "function" ? e.content(e.loops || []) : e.content || "", ct = (e) => {
224
224
  const t = V(e), n = e.elm;
225
225
  n.textContent !== t && (n.textContent = t);
226
226
  }, D = (e, t, n = []) => {
227
227
  Object.keys(t).forEach((s) => {
228
- const o = t[s](n);
229
- e[s] !== o && (e[s] = o);
228
+ const r = t[s](n);
229
+ e[s] !== r && (e[s] = r);
230
230
  });
231
- }, O = (e, t) => {
232
- const { styles: n, attrs: s, loops: o = [] } = t;
233
- if (!n) return;
234
- const r = [];
235
- s != null && s.style && r.push(s.style);
236
- const a = n(o);
237
- r.push(...at(a)), e.style.cssText = r.join(";");
238
231
  }, _ = (e, t) => {
239
- const { classes: n, attrs: s, loops: o = [] } = t;
232
+ const { styles: n, attrs: s, loops: r = [] } = t;
233
+ if (!n) return;
234
+ const o = [];
235
+ s != null && s.style && o.push(s.style);
236
+ const a = n(r);
237
+ o.push(...it(a)), e.style.cssText = o.join(";");
238
+ }, z = (e, t) => {
239
+ const { classes: n, attrs: s, loops: r = [] } = t;
240
240
  if (!n) return;
241
- const r = [];
242
- s != null && s.class && r.push(...s.class.split(" ").filter((i) => i !== ""));
243
- const a = n(o);
244
- r.push(...ct(a)), e.className = Array.from(new Set(r)).join(" ");
245
- }, at = (e) => typeof e == "object" && !Array.isArray(e) ? Object.keys(e).map((t) => `${t}:${e[t]}`) : typeof e == "string" ? [e] : Array.isArray(e) ? e.flatMap(
241
+ const o = [];
242
+ s != null && s.class && o.push(...s.class.split(" ").filter((i) => i !== ""));
243
+ const a = n(r);
244
+ o.push(...lt(a)), e.className = Array.from(new Set(o)).join(" ");
245
+ }, it = (e) => typeof e == "object" && !Array.isArray(e) ? Object.keys(e).map((t) => `${t}:${e[t]}`) : typeof e == "string" ? [e] : Array.isArray(e) ? e.flatMap(
246
246
  (t) => typeof t == "string" ? [t] : Object.keys(t).map((n) => `${n}:${t[n]}`)
247
- ) : [], ct = (e) => typeof e == "object" && !Array.isArray(e) ? Object.keys(e).filter((t) => e[t]).map((t) => t) : typeof e == "string" ? e.split(" ").filter((t) => t !== "") : Array.isArray(e) ? e.flatMap(
247
+ ) : [], lt = (e) => typeof e == "object" && !Array.isArray(e) ? Object.keys(e).filter((t) => e[t]).map((t) => t) : typeof e == "string" ? e.split(" ").filter((t) => t !== "") : Array.isArray(e) ? e.flatMap(
248
248
  (t) => typeof t == "string" ? t.split(" ").filter((n) => n !== "") : Object.keys(t).filter((n) => t[n])
249
- ) : [], it = (e, t) => {
249
+ ) : [], B = (e, t, n) => {
250
+ const s = (r) => n.on[t](r, n.loops || []);
251
+ e.addEventListener(t, s, !1), n.handlers = n.handlers || {}, n.handlers[t] = s;
252
+ }, ut = (e, t) => {
250
253
  const n = t.elm;
251
- D(n, t.props, t.loops), _(n, t), O(n, t), z(n, e.children, t.children);
252
- }, lt = (e, t) => {
254
+ Object.keys(t.on).forEach((s) => {
255
+ e.handlers && e.handlers[s] && n.removeEventListener(s, e.handlers[s], !1), B(n, s, t);
256
+ }), D(n, t.props, t.loops), z(n, t), _(n, t), Q(n, e.children, t.children);
257
+ }, ft = (e, t) => {
253
258
  switch (t.elm = e.elm, t.tagName) {
254
259
  case "comment":
255
260
  break;
256
261
  case "text":
257
- ot(t);
262
+ ct(t);
258
263
  break;
259
264
  case "slot":
260
265
  break;
261
266
  default:
262
- it(e, t);
267
+ ut(e, t);
263
268
  break;
264
269
  }
265
- }, H = (e, t, n) => {
270
+ }, L = (e, t, n) => {
266
271
  n ? e.insertBefore(t, n) : e.appendChild(t);
267
- }, ut = (e, t, n) => {
268
- const s = V(t), o = document.createTextNode(s);
269
- t.elm = o, H(e, o, n);
270
272
  }, mt = (e, t, n) => {
271
- const s = t.content, o = document.createComment(s);
272
- t.elm = o, H(e, o, n);
273
- }, ft = (e, t, n, s) => {
274
- t.tagName === "svg" && (s = rt);
275
- const o = s ? document.createElementNS(s, t.tagName) : document.createElement(t.tagName);
276
- Object.keys(t.attrs).forEach((r) => {
277
- const a = t.attrs[r] || "";
278
- r.charAt(0) !== "x" ? o.setAttribute(r, a) : r.startsWith("xml:") ? o.setAttributeNS(st, r, a) : r.startsWith("xlink:") ? o.setAttributeNS(et, r, a) : r.startsWith("xmlns:") ? o.setAttributeNS(nt, r, a) : o.setAttribute(r, a);
279
- }), Object.keys(t.on).forEach((r) => {
280
- o.addEventListener(r, (a) => t.on[r](a, t.loops || []), !1);
281
- }), D(o, t.props, t.loops), _(o, t), O(o, t), t.elm = o, H(e, o, n), t.tagName === "foreignObject" && (s = void 0), t.children.forEach((r) => {
282
- I(o, r, void 0, s);
273
+ const s = V(t), r = document.createTextNode(s);
274
+ t.elm = r, L(e, r, n);
275
+ }, ht = (e, t, n) => {
276
+ const s = t.content, r = document.createComment(s);
277
+ t.elm = r, L(e, r, n);
278
+ }, pt = (e, t, n, s) => {
279
+ t.tagName === "svg" && (s = at);
280
+ const r = s ? document.createElementNS(s, t.tagName) : document.createElement(t.tagName);
281
+ Object.keys(t.attrs).forEach((o) => {
282
+ const a = t.attrs[o] || "";
283
+ o.charAt(0) !== "x" ? r.setAttribute(o, a) : o.startsWith("xml:") ? r.setAttributeNS(ot, o, a) : o.startsWith("xlink:") ? r.setAttributeNS(st, o, a) : o.startsWith("xmlns:") ? r.setAttributeNS(rt, o, a) : r.setAttribute(o, a);
284
+ }), Object.keys(t.on).forEach((o) => {
285
+ B(r, o, t);
286
+ }), D(r, t.props, t.loops), z(r, t), _(r, t), t.elm = r, L(e, r, n), t.tagName === "foreignObject" && (s = void 0), t.children.forEach((o) => {
287
+ $(r, o, void 0, s);
283
288
  });
284
- }, I = (e, t, n, s) => {
289
+ }, $ = (e, t, n, s) => {
285
290
  switch (t.tagName) {
286
291
  case "comment":
287
- mt(e, t, n);
292
+ ht(e, t, n);
288
293
  break;
289
294
  case "text":
290
- ut(e, t, n);
295
+ mt(e, t, n);
291
296
  break;
292
297
  default:
293
- ft(e, t, n, s);
298
+ pt(e, t, n, s);
294
299
  break;
295
300
  }
296
- }, pt = (e) => e && (e.tagName === "ElseIf" || e.tagName === "comment"), ht = (e) => e && e.tagName === "Else", b = (e, t, n = [], s = 0, o = !0, r = !1) => {
297
- var a, i, m;
301
+ }, gt = (e) => e && (e.tagName === "ElseIf" || e.tagName === "comment"), dt = (e) => e && e.tagName === "Else", y = (e, t, n = [], s = 0, r = !0, o = !1) => {
302
+ var a, i, f;
298
303
  for (let l = 0; l < t.length; l++) {
299
304
  const c = t[l];
300
305
  if (c.tagName === "If") {
301
306
  let u = !1;
302
- for (((a = c.fn) == null ? void 0 : a.call(c, n)) && (b(e, c.children, n, s, !1, !0), u = !0); l + 1 < t.length && pt(t[l + 1]); )
303
- ((m = (i = t[l + 1]).fn) == null ? void 0 : m.call(i, n)) && !u && (b(e, t[l + 1].children, n, s, !1, !0), u = !0), l++;
304
- l + 1 < t.length && ht(t[l + 1]) && !u && (b(e, t[l + 1].children, n, s, !1, !0), u = !0), l++;
307
+ for (((a = c.fn) == null ? void 0 : a.call(c, n)) && (y(e, c.children, n, s, !1, !0), u = !0); l + 1 < t.length && gt(t[l + 1]); )
308
+ ((f = (i = t[l + 1]).fn) == null ? void 0 : f.call(i, n)) && !u && (y(e, t[l + 1].children, n, s, !1, !0), u = !0), l++;
309
+ l + 1 < t.length && dt(t[l + 1]) && (u || (y(e, t[l + 1].children, n, s, !1, !0), u = !0), l++);
305
310
  } else if (c.tagName === "For") {
306
- const { item: u = "item", index: A = "index" } = c.attrs;
307
- (c.fn(n) || []).forEach((L, C) => {
308
- const B = { item: u, value: L, index: A, valueIndex: C };
309
- b(e, c.children, [...n, B], s, !1);
311
+ const { item: u = "item", index: I = "index" } = c.attrs;
312
+ (c.fn(n) || []).forEach((j, S) => {
313
+ const X = { item: u, value: j, index: I, valueIndex: S };
314
+ y(e, c.children, [...n, X], s, !1);
310
315
  });
311
316
  } else {
312
317
  const u = {
@@ -314,53 +319,54 @@ const et = "http://www.w3.org/1999/xlink", nt = "http://www.w3.org/2000/xmlns/",
314
319
  loops: n,
315
320
  children: [],
316
321
  rootId: s,
317
- isIf: r
322
+ isIf: o
318
323
  };
319
- b(u.children, c.children, n), e.push(u);
324
+ y(u.children, c.children, n), e.push(u);
320
325
  }
321
- o && s++;
326
+ r && s++;
322
327
  }
323
- }, z = (e, t, n) => {
324
- var r, a, i, m, l;
325
- let s = 0, o = 0;
326
- for (; s < t.length && o < n.length; ) {
327
- const c = t[s], u = n[o];
328
- c.rootId === u.rootId ? (u.isIf ? ((r = c.elm) == null || r.remove(), I(e, u, (a = t[s + 1]) == null ? void 0 : a.elm)) : lt(c, u), o++, s++) : c.rootId > u.rootId ? ((i = c.elm) == null || i.remove(), s++) : (I(e, u, (m = t[s + 1]) == null ? void 0 : m.elm), o++);
328
+ }, Q = (e, t, n) => {
329
+ var o, a, i, f, l;
330
+ let s = 0, r = 0;
331
+ for (; s < t.length && r < n.length; ) {
332
+ const c = t[s], u = n[r];
333
+ c.rootId === u.rootId ? (u.isIf ? ((o = c.elm) == null || o.remove(), $(e, u, (a = t[s + 1]) == null ? void 0 : a.elm)) : ft(c, u), r++, s++) : c.rootId > u.rootId ? ((i = c.elm) == null || i.remove(), s++) : ($(e, u, (f = t[s + 1]) == null ? void 0 : f.elm), r++);
329
334
  }
330
335
  for (; s < t.length; )
331
336
  (l = t[s].elm) == null || l.remove(), s++;
332
- for (; o < n.length; ) {
333
- const c = n[o];
334
- I(e, c), o++;
337
+ for (; r < n.length; ) {
338
+ const c = n[r];
339
+ $(e, c), r++;
335
340
  }
336
- }, j = (e, t, n = []) => {
341
+ }, q = (e, t, n = []) => {
337
342
  if (!t || t.length === 0) return [];
338
343
  const s = [];
339
- return b(s, t || [], [], 0, !0), z(e, n, s), s;
340
- }, q = (e) => typeof e == "object" && e != null;
341
- var x, E, d, v, p, W, F;
342
- class yt extends HTMLElement {
344
+ return y(s, t || [], [], 0, !0), Q(e, n, s), s;
345
+ }, O = (e) => typeof e == "object" && e != null;
346
+ var x, E, b, v, A, p, F, H;
347
+ class Et extends HTMLElement {
343
348
  constructor() {
344
349
  super();
345
- y(this, p);
346
- y(this, x, {});
347
- y(this, E, []);
348
- y(this, d, []);
349
- y(this, v, !1);
350
+ g(this, p);
351
+ g(this, x, {});
352
+ g(this, E, []);
353
+ g(this, b, []);
354
+ g(this, v, !1);
355
+ g(this, A, []);
350
356
  const n = this._manifest || {};
351
- n.template && typeof n.template == "string" && g(this, E, N(this, n.template)), (n.className || n.tagName || "").split(" ").forEach((o) => {
352
- this.classList.add(o);
357
+ n.template && typeof n.template == "string" && d(this, E, N(this, n.template)), (n.className || n.tagName || "").split(" ").forEach((r) => {
358
+ m(this, A).push(r);
353
359
  });
354
360
  }
355
361
  get $data() {
356
- let n = h(this, x);
357
- return q(n) && (n = k(this, p, W).call(this, n)), n;
362
+ let n = m(this, x);
363
+ return O(n) && (n = k(this, p, F).call(this, n)), n;
358
364
  }
359
365
  set $data(n) {
360
- g(this, x, n), k(this, p, F).call(this);
366
+ d(this, x, n || {}), k(this, p, H).call(this);
361
367
  }
362
368
  connectedCallback() {
363
- g(this, d, j(this, h(this, E), h(this, d))), this.onInit();
369
+ d(this, b, q(this, m(this, E), m(this, b))), this.onInit();
364
370
  }
365
371
  onInit() {
366
372
  }
@@ -368,35 +374,35 @@ class yt extends HTMLElement {
368
374
  console.log("disconnectedCallback");
369
375
  }
370
376
  }
371
- x = new WeakMap(), E = new WeakMap(), d = new WeakMap(), v = new WeakMap(), p = new WeakSet(), W = function(n) {
377
+ x = new WeakMap(), E = new WeakMap(), b = new WeakMap(), v = new WeakMap(), A = new WeakMap(), p = new WeakSet(), F = function(n) {
372
378
  return new Proxy(n, {
373
- get: (s, o) => {
374
- let r = s[o];
375
- return q(r) && (r = k(this, p, W).call(this, r)), r;
379
+ get: (s, r) => {
380
+ let o = s[r];
381
+ return O(o) && (o = k(this, p, F).call(this, o)), o;
376
382
  },
377
- set: (s, o, r) => (s[o] !== r && (s[o] = r, k(this, p, F).call(this)), !0)
383
+ set: (s, r, o) => (s[r] !== o && (s[r] = o, k(this, p, H).call(this)), !0)
378
384
  });
379
- }, F = function() {
380
- h(this, v) || (g(this, v, !0), Y(() => {
381
- g(this, d, j(this, h(this, E), h(this, d))), g(this, v, !1);
385
+ }, H = function() {
386
+ m(this, v) || (d(this, v, !0), et(() => {
387
+ d(this, b, q(this, m(this, E), m(this, b))), m(this, A).forEach((n) => this.classList.add(n)), d(this, v, !1);
382
388
  }));
383
389
  };
384
- const bt = (e) => (t) => {
390
+ const vt = (e) => (t) => {
385
391
  if (customElements.get(e.tagName)) {
386
392
  console.warn(`标签名称 "${e.tagName}" 已经被注册`);
387
393
  return;
388
394
  }
389
- return t.prototype._manifest = gt(e), customElements.define(e.tagName, t), t;
390
- }, gt = (e) => (e = Object.assign({
395
+ return t.prototype._manifest = bt(e), customElements.define(e.tagName, t), t;
396
+ }, bt = (e) => (e = Object.assign({
391
397
  hasConfig: !1
392
398
  }, e), e);
393
399
  export {
394
- yt as BaseElement,
395
- bt as CustomElement,
400
+ Et as BaseElement,
401
+ vt as CustomElement,
396
402
  P as createFunction,
397
- q as isObject,
398
- U as listeners,
403
+ O as isObject,
404
+ tt as listeners,
399
405
  N as parseHtml,
400
- j as patch,
401
- Y as runInAsyncQueue
406
+ q as patch,
407
+ et as runInAsyncQueue
402
408
  };
@@ -1 +1 @@
1
- (function(i,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(i=typeof globalThis<"u"?globalThis:i||self,f(i.solely={}))})(this,function(i){"use strict";var G=i=>{throw TypeError(i)};var O=(i,f,h)=>f.has(i)||G("Cannot "+h);var b=(i,f,h)=>(O(i,f,"read from private field"),h?h.call(i):f.get(i)),I=(i,f,h)=>f.has(i)?G("Cannot add the same private member more than once"):f instanceof WeakSet?f.add(i):f.set(i,h),E=(i,f,h,S)=>(O(i,f,"write to private field"),S?S.call(i,h):f.set(i,h),h),C=(i,f,h)=>(O(i,f,"access private method"),h);var x,k,y,A,g,P,q;const f=/<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g,h=/<\/?([^\s]+?)[/\s>]/,S=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,N=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],w=/\{\{(.+?)\}\}/g;function U(e){return e.replace(/>\s+</g,"><").replace(/\s+/g," ")}function Y(e,t){const n=(t.match(h)||[])[1]||"",s={rootId:0,tagName:n,attrs:{},props:{},on:{},children:[]},r=new RegExp(S);for(;;){const o=r.exec(t);if(o===null)break;if(!o[0].trim())continue;const[a,l]=o[1]?o[1].trim().split("="):[o[2],o[3].trim().slice(1,-1)];if(D.includes(a)||a.startsWith("on-"))s.on[a.startsWith("on-")?a.slice(3):a.slice(2)]=B(e,`return (${l})`);else if(a.startsWith("s-")){const p=a.slice(2);switch(p){case"model":s.model=l;break;case"style":s.styles=u=>d(e,l,u);break;case"class":s.classes=u=>d(e,l,u);break;case"readonly":s.props.readOnly=u=>d(e,l,u);break;default:s.props[p]=u=>d(e,l,u);break}}else s.attrs[a]=l;r.lastIndex--}if(n==="For"?s.fn=o=>d(e,s.attrs.each,o):(n==="If"||n==="ElseIf")&&(s.fn=o=>d(e,s.attrs.condition,o)),s.model){const o=s.model.replace("this.","").replace("$data.",""),a=p=>d(e,`$data.${o}`,p),l=p=>B(e,`$data.${o}=${p}`);n==="input"?s.attrs.type==="checkbox"||s.attrs.type==="radio"?(s.props.checked=a,s.on.change=l("checked")):(s.props.value=a,s.on.input=l("value")):n==="textarea"?(s.props.value=a,s.on.input=l("value")):n==="select"&&(s.props.value=a,s.on.change=l("value"))}return s}function V(e,t){const n=[];if(!t)return n;t=U(t);const s=[],r=[],o=()=>{var l;return s.length===0?n:(l=s[s.length-1]).children||(l.children=[])};let a=0;return t.replace(f,(l,p)=>{const u=o();if(p>a){const c=t.substring(a,p).trim();if(c){w.lastIndex=0;const T=!w.test(c)?c:L=>c.replace(w,(Z,R)=>d(e,R,L));u.push({rootId:0,tagName:"text",attrs:{},props:{},on:{},content:T,children:[]})}}if(a=p+l.length,l.startsWith("<!--")&&l.endsWith("-->"))u.push({rootId:0,tagName:"comment",attrs:{},props:{},on:{},content:l.slice(4,-3),children:[]});else if(l.startsWith("</")){const c=r.pop();for(;s.length>0&&s[s.length-1].tagName!==c;)s.pop();s.pop()}else{const c=Y(e,l),m=l.endsWith("/>")||N.includes(c.tagName);u.push(c),m||(s.push(c),r.push(c.tagName))}return""}),t.length>a&&n.push({rootId:0,tagName:"text",attrs:{},props:{},on:{},content:t.substring(a).trim(),children:[]}),n}const d=(e,t,n)=>{try{return W(["$data",...n.map(r=>r.item),`return (${t})`]).bind(e)(e.$data,...n.map(r=>r.value))}catch(s){console.error(s)}},B=(e,t)=>(n,s)=>W(["$data","event","value","checked",...s.map(o=>o.item),t]).bind(e)(e.$data,n,n.target.value,n.target.checked,...s.map(o=>o.value)),D=["onabort","onautocomplete","onautocompleteerror","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragexit","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onwheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting"],Q=(()=>{const e=typeof requestAnimationFrame=="function"?t=>requestAnimationFrame(t):typeof Promise<"u"?t=>Promise.resolve().then(t):t=>setTimeout(t,0);return(t,...n)=>{if(typeof t!="function")throw new Error("runInAsyncQueue expects a function as its first argument");e(()=>t(...n))}})(),F={};function W(e){const t=e.join(",");if(!F[t]){const n=e[e.length-1];if(n.trim()==="")throw new Error("Function body is empty");if(tt(n))throw new Error("Input contains potentially dangerous code: "+n);const s=new Function(...e);F[t]=s}return F[t]}function tt(e){return["eval","Function","setTimeout","setInterval","window","global","require","XMLHttpRequest","fetch","console","debugger","process","document","importScripts","String.raw","Object.prototype","JSON.parse"].some(n=>e.includes(n))}const et="http://www.w3.org/1999/xlink",nt="http://www.w3.org/2000/xmlns/",st="http://www.w3.org/XML/1998/namespace",ot="http://www.w3.org/2000/svg",_=e=>typeof e.content=="function"?e.content(e.loops||[]):e.content||"",rt=e=>{const t=_(e),n=e.elm;n.textContent!==t&&(n.textContent=t)},z=(e,t,n=[])=>{Object.keys(t).forEach(s=>{const r=t[s](n);e[s]!==r&&(e[s]=r)})},X=(e,t)=>{const{styles:n,attrs:s,loops:r=[]}=t;if(!n)return;const o=[];s!=null&&s.style&&o.push(s.style);const a=n(r);o.push(...at(a)),e.style.cssText=o.join(";")},J=(e,t)=>{const{classes:n,attrs:s,loops:r=[]}=t;if(!n)return;const o=[];s!=null&&s.class&&o.push(...s.class.split(" ").filter(l=>l!==""));const a=n(r);o.push(...ct(a)),e.className=Array.from(new Set(o)).join(" ")},at=e=>typeof e=="object"&&!Array.isArray(e)?Object.keys(e).map(t=>`${t}:${e[t]}`):typeof e=="string"?[e]:Array.isArray(e)?e.flatMap(t=>typeof t=="string"?[t]:Object.keys(t).map(n=>`${n}:${t[n]}`)):[],ct=e=>typeof e=="object"&&!Array.isArray(e)?Object.keys(e).filter(t=>e[t]).map(t=>t):typeof e=="string"?e.split(" ").filter(t=>t!==""):Array.isArray(e)?e.flatMap(t=>typeof t=="string"?t.split(" ").filter(n=>n!==""):Object.keys(t).filter(n=>t[n])):[],it=(e,t)=>{const n=t.elm;z(n,t.props,t.loops),J(n,t),X(n,t),K(n,e.children,t.children)},lt=(e,t)=>{switch(t.elm=e.elm,t.tagName){case"comment":break;case"text":rt(t);break;case"slot":break;default:it(e,t);break}},j=(e,t,n)=>{n?e.insertBefore(t,n):e.appendChild(t)},ut=(e,t,n)=>{const s=_(t),r=document.createTextNode(s);t.elm=r,j(e,r,n)},ft=(e,t,n)=>{const s=t.content,r=document.createComment(s);t.elm=r,j(e,r,n)},mt=(e,t,n,s)=>{t.tagName==="svg"&&(s=ot);const r=s?document.createElementNS(s,t.tagName):document.createElement(t.tagName);Object.keys(t.attrs).forEach(o=>{const a=t.attrs[o]||"";o.charAt(0)!=="x"?r.setAttribute(o,a):o.startsWith("xml:")?r.setAttributeNS(st,o,a):o.startsWith("xlink:")?r.setAttributeNS(et,o,a):o.startsWith("xmlns:")?r.setAttributeNS(nt,o,a):r.setAttribute(o,a)}),Object.keys(t.on).forEach(o=>{r.addEventListener(o,a=>t.on[o](a,t.loops||[]),!1)}),z(r,t.props,t.loops),J(r,t),X(r,t),t.elm=r,j(e,r,n),t.tagName==="foreignObject"&&(s=void 0),t.children.forEach(o=>{$(r,o,void 0,s)})},$=(e,t,n,s)=>{switch(t.tagName){case"comment":ft(e,t,n);break;case"text":ut(e,t,n);break;default:mt(e,t,n,s);break}},pt=e=>e&&(e.tagName==="ElseIf"||e.tagName==="comment"),ht=e=>e&&e.tagName==="Else",v=(e,t,n=[],s=0,r=!0,o=!1)=>{var a,l,p;for(let u=0;u<t.length;u++){const c=t[u];if(c.tagName==="If"){let m=!1;for(((a=c.fn)==null?void 0:a.call(c,n))&&(v(e,c.children,n,s,!1,!0),m=!0);u+1<t.length&&pt(t[u+1]);)((p=(l=t[u+1]).fn)==null?void 0:p.call(l,n))&&!m&&(v(e,t[u+1].children,n,s,!1,!0),m=!0),u++;u+1<t.length&&ht(t[u+1])&&!m&&(v(e,t[u+1].children,n,s,!1,!0),m=!0),u++}else if(c.tagName==="For"){const{item:m="item",index:T="index"}=c.attrs;(c.fn(n)||[]).forEach((Z,R)=>{const bt={item:m,value:Z,index:T,valueIndex:R};v(e,c.children,[...n,bt],s,!1)})}else{const m={...c,loops:n,children:[],rootId:s,isIf:o};v(m.children,c.children,n),e.push(m)}r&&s++}},K=(e,t,n)=>{var o,a,l,p,u;let s=0,r=0;for(;s<t.length&&r<n.length;){const c=t[s],m=n[r];c.rootId===m.rootId?(m.isIf?((o=c.elm)==null||o.remove(),$(e,m,(a=t[s+1])==null?void 0:a.elm)):lt(c,m),r++,s++):c.rootId>m.rootId?((l=c.elm)==null||l.remove(),s++):($(e,m,(p=t[s+1])==null?void 0:p.elm),r++)}for(;s<t.length;)(u=t[s].elm)==null||u.remove(),s++;for(;r<n.length;){const c=n[r];$(e,c),r++}},H=(e,t,n=[])=>{if(!t||t.length===0)return[];const s=[];return v(s,t||[],[],0,!0),K(e,n,s),s},M=e=>typeof e=="object"&&e!=null;class dt extends HTMLElement{constructor(){super();I(this,g);I(this,x,{});I(this,k,[]);I(this,y,[]);I(this,A,!1);const n=this._manifest||{};n.template&&typeof n.template=="string"&&E(this,k,V(this,n.template)),(n.className||n.tagName||"").split(" ").forEach(r=>{this.classList.add(r)})}get $data(){let n=b(this,x);return M(n)&&(n=C(this,g,P).call(this,n)),n}set $data(n){E(this,x,n),C(this,g,q).call(this)}connectedCallback(){E(this,y,H(this,b(this,k),b(this,y))),this.onInit()}onInit(){}disconnectedCallback(){console.log("disconnectedCallback")}}x=new WeakMap,k=new WeakMap,y=new WeakMap,A=new WeakMap,g=new WeakSet,P=function(n){return new Proxy(n,{get:(s,r)=>{let o=s[r];return M(o)&&(o=C(this,g,P).call(this,o)),o},set:(s,r,o)=>(s[r]!==o&&(s[r]=o,C(this,g,q).call(this)),!0)})},q=function(){b(this,A)||(E(this,A,!0),Q(()=>{E(this,y,H(this,b(this,k),b(this,y))),E(this,A,!1)}))};const gt=e=>t=>{if(customElements.get(e.tagName)){console.warn(`标签名称 "${e.tagName}" 已经被注册`);return}return t.prototype._manifest=yt(e),customElements.define(e.tagName,t),t},yt=e=>(e=Object.assign({hasConfig:!1},e),e);i.BaseElement=dt,i.CustomElement=gt,i.createFunction=W,i.isObject=M,i.listeners=D,i.parseHtml=V,i.patch=H,i.runInAsyncQueue=Q,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
1
+ (function(i,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(i=typeof globalThis<"u"?globalThis:i||self,f(i.solely={}))})(this,function(i){"use strict";var Y=i=>{throw TypeError(i)};var P=(i,f,p)=>f.has(i)||Y("Cannot "+p);var d=(i,f,p)=>(P(i,f,"read from private field"),p?p.call(i):f.get(i)),E=(i,f,p)=>f.has(i)?Y("Cannot add the same private member more than once"):f instanceof WeakSet?f.add(i):f.set(i,p),v=(i,f,p,$)=>(P(i,f,"write to private field"),$?$.call(i,p):f.set(i,p),p),S=(i,f,p)=>(P(i,f,"access private method"),p);var x,A,b,I,C,y,q,V;const f=/<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g,p=/<\/?([^\s]+?)[/\s>]/,$=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,N=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],F=/\{\{(.+?)\}\}/g;function tt(e){return e.replace(/>\s+</g,"><").replace(/\s+/g," ")}function et(e,t){const n=(t.match(p)||[])[1]||"",s={rootId:0,tagName:n,attrs:{},props:{},on:{},children:[]},r=new RegExp($);for(;;){const o=r.exec(t);if(o===null)break;if(!o[0].trim())continue;const[a,l]=o[1]?o[1].trim().split("="):[o[2],o[3].trim().slice(1,-1)];if(Q.includes(a)||a.startsWith("on-"))s.on[a.startsWith("on-")?a.slice(3):a.slice(2)]=D(e,`return (${l})`);else if(a.startsWith("s-")){const h=a.slice(2);switch(h){case"model":s.model=l;break;case"style":s.styles=u=>g(e,l,u);break;case"class":s.classes=u=>g(e,l,u);break;case"readonly":s.props.readOnly=u=>g(e,l,u);break;default:s.props[h]=u=>g(e,l,u);break}}else s.attrs[a]=l;r.lastIndex--}if(n==="For"?s.fn=o=>g(e,s.attrs.each,o):(n==="If"||n==="ElseIf")&&(s.fn=o=>g(e,s.attrs.condition,o)),s.model){const o=s.model.replace("this.","").replace("$data.",""),a=h=>g(e,`$data.${o}`,h),l=h=>D(e,`$data.${o}=${h}`);n==="input"?s.attrs.type==="checkbox"||s.attrs.type==="radio"?(s.props.checked=a,s.on.change=l("checked")):(s.props.value=a,s.on.input=l("value")):n==="textarea"?(s.props.value=a,s.on.input=l("value")):n==="select"&&(s.props.value=a,s.on.change=l("value"))}return s}function B(e,t){const n=[];if(!t)return n;t=tt(t);const s=[],r=[],o=()=>{var l;return s.length===0?n:(l=s[s.length-1]).children||(l.children=[])};let a=0;return t.replace(f,(l,h)=>{const u=o();if(h>a){const c=t.substring(a,h).trim();if(c){F.lastIndex=0;const w=!F.test(c)?c:O=>c.replace(F,(U,R)=>g(e,R,O));u.push({rootId:0,tagName:"text",attrs:{},props:{},on:{},content:w,children:[]})}}if(a=h+l.length,l.startsWith("<!--")&&l.endsWith("-->"))u.push({rootId:0,tagName:"comment",attrs:{},props:{},on:{},content:l.slice(4,-3),children:[]});else if(l.startsWith("</")){const c=r.pop();for(;s.length>0&&s[s.length-1].tagName!==c;)s.pop();s.pop()}else{const c=et(e,l),m=l.endsWith("/>")||N.includes(c.tagName);u.push(c),m||(s.push(c),r.push(c.tagName))}return""}),t.length>a&&n.push({rootId:0,tagName:"text",attrs:{},props:{},on:{},content:t.substring(a).trim(),children:[]}),n}const g=(e,t,n)=>{try{return j(["$data",...n.map(r=>r.item),`return (${t})`]).bind(e)(e.$data,...n.map(r=>r.value))}catch(s){console.error(s)}},D=(e,t)=>(n,s)=>j(["$data","event","value","checked",...s.map(o=>o.item),t]).bind(e)(e.$data,n,n.target.value,n.target.checked,...s.map(o=>o.value)),Q=["onabort","onautocomplete","onautocompleteerror","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragexit","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onwheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting"],_=(()=>{const e=typeof requestAnimationFrame=="function"?t=>requestAnimationFrame(t):typeof Promise<"u"?t=>Promise.resolve().then(t):t=>setTimeout(t,0);return(t,...n)=>{if(typeof t!="function")throw new Error("runInAsyncQueue expects a function as its first argument");e(()=>t(...n))}})(),W={};function j(e){const t=e.join(",");if(!W[t]){const n=e[e.length-1];if(n.trim()==="")throw new Error("Function body is empty");if(nt(n))throw new Error("Input contains potentially dangerous code: "+n);const s=new Function(...e);W[t]=s}return W[t]}function nt(e){return["eval","Function","setTimeout","setInterval","window","global","require","XMLHttpRequest","fetch","console","debugger","process","document","importScripts","String.raw","Object.prototype","JSON.parse"].some(n=>e.includes(n))}const st="http://www.w3.org/1999/xlink",rt="http://www.w3.org/2000/xmlns/",ot="http://www.w3.org/XML/1998/namespace",at="http://www.w3.org/2000/svg",z=e=>typeof e.content=="function"?e.content(e.loops||[]):e.content||"",ct=e=>{const t=z(e),n=e.elm;n.textContent!==t&&(n.textContent=t)},X=(e,t,n=[])=>{Object.keys(t).forEach(s=>{const r=t[s](n);e[s]!==r&&(e[s]=r)})},J=(e,t)=>{const{styles:n,attrs:s,loops:r=[]}=t;if(!n)return;const o=[];s!=null&&s.style&&o.push(s.style);const a=n(r);o.push(...it(a)),e.style.cssText=o.join(";")},K=(e,t)=>{const{classes:n,attrs:s,loops:r=[]}=t;if(!n)return;const o=[];s!=null&&s.class&&o.push(...s.class.split(" ").filter(l=>l!==""));const a=n(r);o.push(...lt(a)),e.className=Array.from(new Set(o)).join(" ")},it=e=>typeof e=="object"&&!Array.isArray(e)?Object.keys(e).map(t=>`${t}:${e[t]}`):typeof e=="string"?[e]:Array.isArray(e)?e.flatMap(t=>typeof t=="string"?[t]:Object.keys(t).map(n=>`${n}:${t[n]}`)):[],lt=e=>typeof e=="object"&&!Array.isArray(e)?Object.keys(e).filter(t=>e[t]).map(t=>t):typeof e=="string"?e.split(" ").filter(t=>t!==""):Array.isArray(e)?e.flatMap(t=>typeof t=="string"?t.split(" ").filter(n=>n!==""):Object.keys(t).filter(n=>t[n])):[],Z=(e,t,n)=>{const s=r=>n.on[t](r,n.loops||[]);e.addEventListener(t,s,!1),n.handlers=n.handlers||{},n.handlers[t]=s},ut=(e,t)=>{const n=t.elm;Object.keys(t.on).forEach(s=>{e.handlers&&e.handlers[s]&&n.removeEventListener(s,e.handlers[s],!1),Z(n,s,t)}),X(n,t.props,t.loops),K(n,t),J(n,t),G(n,e.children,t.children)},ft=(e,t)=>{switch(t.elm=e.elm,t.tagName){case"comment":break;case"text":ct(t);break;case"slot":break;default:ut(e,t);break}},H=(e,t,n)=>{n?e.insertBefore(t,n):e.appendChild(t)},mt=(e,t,n)=>{const s=z(t),r=document.createTextNode(s);t.elm=r,H(e,r,n)},ht=(e,t,n)=>{const s=t.content,r=document.createComment(s);t.elm=r,H(e,r,n)},pt=(e,t,n,s)=>{t.tagName==="svg"&&(s=at);const r=s?document.createElementNS(s,t.tagName):document.createElement(t.tagName);Object.keys(t.attrs).forEach(o=>{const a=t.attrs[o]||"";o.charAt(0)!=="x"?r.setAttribute(o,a):o.startsWith("xml:")?r.setAttributeNS(ot,o,a):o.startsWith("xlink:")?r.setAttributeNS(st,o,a):o.startsWith("xmlns:")?r.setAttributeNS(rt,o,a):r.setAttribute(o,a)}),Object.keys(t.on).forEach(o=>{Z(r,o,t)}),X(r,t.props,t.loops),K(r,t),J(r,t),t.elm=r,H(e,r,n),t.tagName==="foreignObject"&&(s=void 0),t.children.forEach(o=>{T(r,o,void 0,s)})},T=(e,t,n,s)=>{switch(t.tagName){case"comment":ht(e,t,n);break;case"text":mt(e,t,n);break;default:pt(e,t,n,s);break}},dt=e=>e&&(e.tagName==="ElseIf"||e.tagName==="comment"),gt=e=>e&&e.tagName==="Else",k=(e,t,n=[],s=0,r=!0,o=!1)=>{var a,l,h;for(let u=0;u<t.length;u++){const c=t[u];if(c.tagName==="If"){let m=!1;for(((a=c.fn)==null?void 0:a.call(c,n))&&(k(e,c.children,n,s,!1,!0),m=!0);u+1<t.length&&dt(t[u+1]);)((h=(l=t[u+1]).fn)==null?void 0:h.call(l,n))&&!m&&(k(e,t[u+1].children,n,s,!1,!0),m=!0),u++;u+1<t.length&&gt(t[u+1])&&(m||(k(e,t[u+1].children,n,s,!1,!0),m=!0),u++)}else if(c.tagName==="For"){const{item:m="item",index:w="index"}=c.attrs;(c.fn(n)||[]).forEach((U,R)=>{const vt={item:m,value:U,index:w,valueIndex:R};k(e,c.children,[...n,vt],s,!1)})}else{const m={...c,loops:n,children:[],rootId:s,isIf:o};k(m.children,c.children,n),e.push(m)}r&&s++}},G=(e,t,n)=>{var o,a,l,h,u;let s=0,r=0;for(;s<t.length&&r<n.length;){const c=t[s],m=n[r];c.rootId===m.rootId?(m.isIf?((o=c.elm)==null||o.remove(),T(e,m,(a=t[s+1])==null?void 0:a.elm)):ft(c,m),r++,s++):c.rootId>m.rootId?((l=c.elm)==null||l.remove(),s++):(T(e,m,(h=t[s+1])==null?void 0:h.elm),r++)}for(;s<t.length;)(u=t[s].elm)==null||u.remove(),s++;for(;r<n.length;){const c=n[r];T(e,c),r++}},L=(e,t,n=[])=>{if(!t||t.length===0)return[];const s=[];return k(s,t||[],[],0,!0),G(e,n,s),s},M=e=>typeof e=="object"&&e!=null;class yt extends HTMLElement{constructor(){super();E(this,y);E(this,x,{});E(this,A,[]);E(this,b,[]);E(this,I,!1);E(this,C,[]);const n=this._manifest||{};n.template&&typeof n.template=="string"&&v(this,A,B(this,n.template)),(n.className||n.tagName||"").split(" ").forEach(r=>{d(this,C).push(r)})}get $data(){let n=d(this,x);return M(n)&&(n=S(this,y,q).call(this,n)),n}set $data(n){v(this,x,n||{}),S(this,y,V).call(this)}connectedCallback(){v(this,b,L(this,d(this,A),d(this,b))),this.onInit()}onInit(){}disconnectedCallback(){console.log("disconnectedCallback")}}x=new WeakMap,A=new WeakMap,b=new WeakMap,I=new WeakMap,C=new WeakMap,y=new WeakSet,q=function(n){return new Proxy(n,{get:(s,r)=>{let o=s[r];return M(o)&&(o=S(this,y,q).call(this,o)),o},set:(s,r,o)=>(s[r]!==o&&(s[r]=o,S(this,y,V).call(this)),!0)})},V=function(){d(this,I)||(v(this,I,!0),_(()=>{v(this,b,L(this,d(this,A),d(this,b))),d(this,C).forEach(n=>this.classList.add(n)),v(this,I,!1)}))};const bt=e=>t=>{if(customElements.get(e.tagName)){console.warn(`标签名称 "${e.tagName}" 已经被注册`);return}return t.prototype._manifest=Et(e),customElements.define(e.tagName,t),t},Et=e=>(e=Object.assign({hasConfig:!1},e),e);i.BaseElement=yt,i.CustomElement=bt,i.createFunction=j,i.isObject=M,i.listeners=Q,i.parseHtml=B,i.patch=L,i.runInAsyncQueue=_,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
@@ -5,6 +5,7 @@ export interface Loop {
5
5
  valueIndex: number;
6
6
  }
7
7
  export interface ASTNode {
8
+ handlers?: Record<string, EventListenerOrEventListenerObject>;
8
9
  rootId: number;
9
10
  tagName: string;
10
11
  attrs: Record<string, string>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solely",
3
3
  "private": false,
4
- "version": "0.0.11",
4
+ "version": "0.0.13",
5
5
  "type": "module",
6
6
  "module": "./dist/solely.js",
7
7
  "types": "./dist/solely.d.ts",
@@ -19,7 +19,9 @@
19
19
  "preview": "vite preview"
20
20
  },
21
21
  "devDependencies": {
22
+ "sass": "^1.83.0",
22
23
  "typescript": "~5.6.2",
23
- "vite": "^5.4.10"
24
+ "vite": "^5.4.10",
25
+ "vite-plugin-dts": "^4.4.0"
24
26
  }
25
- }
27
+ }
File without changes
File without changes