@hot-page/fun 0.0.2 → 0.0.3
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/index.d.ts.map +1 -1
- package/dist/index.js +157 -149
- package/package.json +1 -1
- package/src/index.ts +10 -11
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAU,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;AAEpB,MAAM,MAAM,cAAc,GAAG,MAAM,UAAU,CAAC,OAAO,IAAI,CAAC,CAAA;AAC1D,MAAM,MAAM,eAAe,GAAG,MAAM,IAAI,CAAA;AACxC,MAAM,MAAM,cAAc,GAAG,MAAM,eAAe,GAAG,IAAI,CAAA;AACzD,MAAM,MAAM,kBAAkB,GAAG,CAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,KAC1C,IAAI,CAAA;AAST,KAAK,gBAAgB,CAAC,KAAK,SAAS,MAAM,IAAI;KAC3C,CAAC,IAAI,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;CAC1C,CAAA;AAED,MAAM,MAAM,gBAAgB,CAAC,KAAK,SAAS,MAAM,GAAG,KAAK,IACvD,gBAAgB,CAAC,KAAK,CAAC,GAAG;IACxB,SAAS,EAAE,gBAAgB,CAAA;IAC3B,MAAM,EAAE,CAAC,EAAE,EAAE,cAAc,KAAK,IAAI,CAAA;IACpC,UAAU,EAAE,kBAAkB,CAAA;CAC/B,CAAA;AAEH,MAAM,MAAM,mBAAmB,CAAC,KAAK,SAAS,MAAM,GAAG,KAAK,IAC1D,CAAC,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,CAAA;AACP,iBAAS,aAAa,CAAC,KAAK,SAAS,MAAM,EACzC,kBAAkB,EAAE,KAAK,EAAE,EAC3B,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,mBAAmB,CAAC,KAAK,CAAC,GAC7B,IAAI,CAAA;AA2BP,QAAA,MAAM,KAAK,GAAI,CAAC,EAAE,OAAO,CAAC,oBAA4B,CAAA;AACtD,QAAA,MAAM,QAAQ,GAAI,CAAC,EAAE,IAAI,MAAM,CAAC,uBAA4B,CAAA;AAE5D,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,CAAA;AAEvD,wBAAgB,MAAM,CAAC,KAAK,SAAS,MAAM,GAAG,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,QA4OjF"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const ee = globalThis, q = ee.trustedTypes, ie = q ? q.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, pe = "$lit$", N = `lit$${Math.random().toFixed(9).slice(2)}$`, fe = "?" + N, Se = `<${fe}>`, E = document, W = () => E.createComment(""), H = (e) => e === null || typeof e != "object" && typeof e != "function", te = Array.isArray, be = (e) => te(e) || typeof e?.[Symbol.iterator] == "function", z = `[
|
|
2
2
|
\f\r]`, O = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, ne = /-->/g, ue = />/g, x = RegExp(`>|${z}(?:([^\\s"'>=/]+)(${z}*=${z}*(?:[^
|
|
3
|
-
\f\r"'\`<>=]|("|')|))|$)`, "g"), ce = /'/g, ae = /"/g, me = /^(?:script|style|textarea|title)$/i, ve = (e) => (t, ...r) => ({ _$litType$: e, strings: t, values: r }), nt = ve(1), ut = ve(2), R = Symbol.for("lit-noChange"),
|
|
3
|
+
\f\r"'\`<>=]|("|')|))|$)`, "g"), ce = /'/g, ae = /"/g, me = /^(?:script|style|textarea|title)$/i, ve = (e) => (t, ...r) => ({ _$litType$: e, strings: t, values: r }), nt = ve(1), ut = ve(2), R = Symbol.for("lit-noChange"), $ = Symbol.for("lit-nothing"), le = /* @__PURE__ */ new WeakMap(), T = E.createTreeWalker(E, 129);
|
|
4
4
|
function we(e, t) {
|
|
5
5
|
if (!te(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array");
|
|
6
6
|
return ie !== void 0 ? ie.createHTML(t) : t;
|
|
@@ -8,12 +8,12 @@ function we(e, t) {
|
|
|
8
8
|
const Ie = (e, t) => {
|
|
9
9
|
const r = e.length - 1, s = [];
|
|
10
10
|
let o, n = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", a = O;
|
|
11
|
-
for (let
|
|
12
|
-
const u = e[
|
|
13
|
-
let i,
|
|
14
|
-
for (; p < u.length && (a.lastIndex = p,
|
|
15
|
-
const
|
|
16
|
-
n += a === O ? u + Se : c >= 0 ? (s.push(i), u.slice(0, c) + pe + u.slice(c) + N +
|
|
11
|
+
for (let l = 0; l < r; l++) {
|
|
12
|
+
const u = e[l];
|
|
13
|
+
let i, h, c = -1, p = 0;
|
|
14
|
+
for (; p < u.length && (a.lastIndex = p, h = a.exec(u), h !== null); ) p = a.lastIndex, a === O ? h[1] === "!--" ? a = ne : h[1] !== void 0 ? a = ue : h[2] !== void 0 ? (me.test(h[2]) && (o = RegExp("</" + h[2], "g")), a = x) : h[3] !== void 0 && (a = x) : a === x ? h[0] === ">" ? (a = o ?? O, c = -1) : h[1] === void 0 ? c = -2 : (c = a.lastIndex - h[2].length, i = h[1], a = h[3] === void 0 ? x : h[3] === '"' ? ae : ce) : a === ae || a === ce ? a = x : a === ne || a === ue ? a = O : (a = x, o = void 0);
|
|
15
|
+
const f = a === x && e[l + 1].startsWith("/>") ? " " : "";
|
|
16
|
+
n += a === O ? u + Se : c >= 0 ? (s.push(i), u.slice(0, c) + pe + u.slice(c) + N + f) : u + N + (c === -2 ? l : f);
|
|
17
17
|
}
|
|
18
18
|
return [we(e, n + (e[r] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), s];
|
|
19
19
|
};
|
|
@@ -22,22 +22,22 @@ class P {
|
|
|
22
22
|
let o;
|
|
23
23
|
this.parts = [];
|
|
24
24
|
let n = 0, a = 0;
|
|
25
|
-
const
|
|
25
|
+
const l = t.length - 1, u = this.parts, [i, h] = Ie(t, r);
|
|
26
26
|
if (this.el = P.createElement(i, s), T.currentNode = this.el.content, r === 2 || r === 3) {
|
|
27
27
|
const c = this.el.content.firstChild;
|
|
28
28
|
c.replaceWith(...c.childNodes);
|
|
29
29
|
}
|
|
30
|
-
for (; (o = T.nextNode()) !== null && u.length <
|
|
30
|
+
for (; (o = T.nextNode()) !== null && u.length < l; ) {
|
|
31
31
|
if (o.nodeType === 1) {
|
|
32
32
|
if (o.hasAttributes()) for (const c of o.getAttributeNames()) if (c.endsWith(pe)) {
|
|
33
|
-
const p =
|
|
34
|
-
u.push({ type: 1, index: n, name:
|
|
33
|
+
const p = h[a++], f = o.getAttribute(c).split(N), y = /([.?@])?(.*)/.exec(p);
|
|
34
|
+
u.push({ type: 1, index: n, name: y[2], strings: f, ctor: y[1] === "." ? Me : y[1] === "?" ? We : y[1] === "@" ? He : j }), o.removeAttribute(c);
|
|
35
35
|
} else c.startsWith(N) && (u.push({ type: 6, index: n }), o.removeAttribute(c));
|
|
36
36
|
if (me.test(o.tagName)) {
|
|
37
37
|
const c = o.textContent.split(N), p = c.length - 1;
|
|
38
38
|
if (p > 0) {
|
|
39
39
|
o.textContent = q ? q.emptyScript : "";
|
|
40
|
-
for (let
|
|
40
|
+
for (let f = 0; f < p; f++) o.append(c[f], W()), T.nextNode(), u.push({ type: 2, index: ++n });
|
|
41
41
|
o.append(c[p], W());
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -73,11 +73,11 @@ class Oe {
|
|
|
73
73
|
u(t) {
|
|
74
74
|
const { el: { content: r }, parts: s } = this._$AD, o = (t?.creationScope ?? E).importNode(r, !0);
|
|
75
75
|
T.currentNode = o;
|
|
76
|
-
let n = T.nextNode(), a = 0,
|
|
76
|
+
let n = T.nextNode(), a = 0, l = 0, u = s[0];
|
|
77
77
|
for (; u !== void 0; ) {
|
|
78
78
|
if (a === u.index) {
|
|
79
79
|
let i;
|
|
80
|
-
u.type === 2 ? i = new k(n, n.nextSibling, this, t) : u.type === 1 ? i = new u.ctor(n, u.name, u.strings, this, t) : u.type === 6 && (i = new Re(n, this, t)), this._$AV.push(i), u = s[++
|
|
80
|
+
u.type === 2 ? i = new k(n, n.nextSibling, this, t) : u.type === 1 ? i = new u.ctor(n, u.name, u.strings, this, t) : u.type === 6 && (i = new Re(n, this, t)), this._$AV.push(i), u = s[++l];
|
|
81
81
|
}
|
|
82
82
|
a !== u?.index && (n = T.nextNode(), a++);
|
|
83
83
|
}
|
|
@@ -93,7 +93,7 @@ class k {
|
|
|
93
93
|
return this._$AM?._$AU ?? this._$Cv;
|
|
94
94
|
}
|
|
95
95
|
constructor(t, r, s, o) {
|
|
96
|
-
this.type = 2, this._$AH =
|
|
96
|
+
this.type = 2, this._$AH = $, this._$AN = void 0, this._$AA = t, this._$AB = r, this._$AM = s, this.options = o, this._$Cv = o?.isConnected ?? !0;
|
|
97
97
|
}
|
|
98
98
|
get parentNode() {
|
|
99
99
|
let t = this._$AA.parentNode;
|
|
@@ -107,7 +107,7 @@ class k {
|
|
|
107
107
|
return this._$AB;
|
|
108
108
|
}
|
|
109
109
|
_$AI(t, r = this) {
|
|
110
|
-
t = b(this, t, r), H(t) ? t ===
|
|
110
|
+
t = b(this, t, r), H(t) ? t === $ || t == null || t === "" ? (this._$AH !== $ && this._$AR(), this._$AH = $) : t !== this._$AH && t !== R && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : be(t) ? this.k(t) : this._(t);
|
|
111
111
|
}
|
|
112
112
|
O(t) {
|
|
113
113
|
return this._$AA.parentNode.insertBefore(t, this._$AB);
|
|
@@ -116,7 +116,7 @@ class k {
|
|
|
116
116
|
this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
|
|
117
117
|
}
|
|
118
118
|
_(t) {
|
|
119
|
-
this._$AH !==
|
|
119
|
+
this._$AH !== $ && H(this._$AH) ? this._$AA.nextSibling.data = t : this.T(E.createTextNode(t)), this._$AH = t;
|
|
120
120
|
}
|
|
121
121
|
$(t) {
|
|
122
122
|
const { values: r, _$litType$: s } = t, o = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = P.createElement(we(s.h, s.h[0]), this.options)), s);
|
|
@@ -155,21 +155,21 @@ class j {
|
|
|
155
155
|
return this._$AM._$AU;
|
|
156
156
|
}
|
|
157
157
|
constructor(t, r, s, o, n) {
|
|
158
|
-
this.type = 1, this._$AH =
|
|
158
|
+
this.type = 1, this._$AH = $, this._$AN = void 0, this.element = t, this.name = r, this._$AM = o, this.options = n, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = $;
|
|
159
159
|
}
|
|
160
160
|
_$AI(t, r = this, s, o) {
|
|
161
161
|
const n = this.strings;
|
|
162
162
|
let a = !1;
|
|
163
163
|
if (n === void 0) t = b(this, t, r, 0), a = !H(t) || t !== this._$AH && t !== R, a && (this._$AH = t);
|
|
164
164
|
else {
|
|
165
|
-
const
|
|
165
|
+
const l = t;
|
|
166
166
|
let u, i;
|
|
167
|
-
for (t = n[0], u = 0; u < n.length - 1; u++) i = b(this,
|
|
167
|
+
for (t = n[0], u = 0; u < n.length - 1; u++) i = b(this, l[s + u], r, u), i === R && (i = this._$AH[u]), a ||= !H(i) || i !== this._$AH[u], i === $ ? t = $ : t !== $ && (t += (i ?? "") + n[u + 1]), this._$AH[u] = i;
|
|
168
168
|
}
|
|
169
169
|
a && !o && this.j(t);
|
|
170
170
|
}
|
|
171
171
|
j(t) {
|
|
172
|
-
t ===
|
|
172
|
+
t === $ ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
class Me extends j {
|
|
@@ -177,7 +177,7 @@ class Me extends j {
|
|
|
177
177
|
super(...arguments), this.type = 3;
|
|
178
178
|
}
|
|
179
179
|
j(t) {
|
|
180
|
-
this.element[this.name] = t ===
|
|
180
|
+
this.element[this.name] = t === $ ? void 0 : t;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
class We extends j {
|
|
@@ -185,7 +185,7 @@ class We extends j {
|
|
|
185
185
|
super(...arguments), this.type = 4;
|
|
186
186
|
}
|
|
187
187
|
j(t) {
|
|
188
|
-
this.element.toggleAttribute(this.name, !!t && t !==
|
|
188
|
+
this.element.toggleAttribute(this.name, !!t && t !== $);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
class He extends j {
|
|
@@ -193,8 +193,8 @@ class He extends j {
|
|
|
193
193
|
super(t, r, s, o, n), this.type = 5;
|
|
194
194
|
}
|
|
195
195
|
_$AI(t, r = this) {
|
|
196
|
-
if ((t = b(this, t, r, 0) ??
|
|
197
|
-
const s = this._$AH, o = t ===
|
|
196
|
+
if ((t = b(this, t, r, 0) ?? $) === R) return;
|
|
197
|
+
const s = this._$AH, o = t === $ && s !== $ || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, n = t !== $ && (s === $ || o);
|
|
198
198
|
o && this.element.removeEventListener(this.name, this, s), n && this.element.addEventListener(this.name, this, t), this._$AH = t;
|
|
199
199
|
}
|
|
200
200
|
handleEvent(t) {
|
|
@@ -234,14 +234,14 @@ var ke = Object.defineProperty, Le = (e, t, r) => t in e ? ke(e, t, { enumerable
|
|
|
234
234
|
function $e(e, t) {
|
|
235
235
|
return Object.is(e, t);
|
|
236
236
|
}
|
|
237
|
-
let
|
|
237
|
+
let w = null, M = !1, D = 1;
|
|
238
238
|
const U = /* @__PURE__ */ Symbol("SIGNAL");
|
|
239
239
|
function S(e) {
|
|
240
|
-
const t =
|
|
241
|
-
return
|
|
240
|
+
const t = w;
|
|
241
|
+
return w = e, t;
|
|
242
242
|
}
|
|
243
243
|
function De() {
|
|
244
|
-
return
|
|
244
|
+
return w;
|
|
245
245
|
}
|
|
246
246
|
function qe() {
|
|
247
247
|
return M;
|
|
@@ -271,15 +271,15 @@ function B(e) {
|
|
|
271
271
|
throw new Error(
|
|
272
272
|
typeof ngDevMode < "u" && ngDevMode ? "Assertion error: signal read during notification phase" : ""
|
|
273
273
|
);
|
|
274
|
-
if (
|
|
274
|
+
if (w === null)
|
|
275
275
|
return;
|
|
276
|
-
|
|
277
|
-
const t =
|
|
278
|
-
if (I(
|
|
279
|
-
const r =
|
|
280
|
-
G(r,
|
|
276
|
+
w.consumerOnSignalRead(e);
|
|
277
|
+
const t = w.nextProducerIndex++;
|
|
278
|
+
if (I(w), t < w.producerNode.length && w.producerNode[t] !== e && Q(w)) {
|
|
279
|
+
const r = w.producerNode[t];
|
|
280
|
+
G(r, w.producerIndexOfThis[t]);
|
|
281
281
|
}
|
|
282
|
-
|
|
282
|
+
w.producerNode[t] !== e && (w.producerNode[t] = e, w.producerIndexOfThis[t] = Q(w) ? ge(e, w, t) : 0), w.producerLastReadVersion[t] = e.version;
|
|
283
283
|
}
|
|
284
284
|
function Ue() {
|
|
285
285
|
D++;
|
|
@@ -306,7 +306,7 @@ function _e(e) {
|
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
function je() {
|
|
309
|
-
return
|
|
309
|
+
return w?.consumerAllowSignalWrites !== !1;
|
|
310
310
|
}
|
|
311
311
|
function Be(e) {
|
|
312
312
|
var t;
|
|
@@ -437,7 +437,7 @@ const rt = {
|
|
|
437
437
|
function st(e) {
|
|
438
438
|
e.version++, Ue(), _e(e);
|
|
439
439
|
}
|
|
440
|
-
const
|
|
440
|
+
const A = Symbol("node");
|
|
441
441
|
var C;
|
|
442
442
|
((e) => {
|
|
443
443
|
var t, r, s, o;
|
|
@@ -445,7 +445,7 @@ var C;
|
|
|
445
445
|
constructor(u, i = {}) {
|
|
446
446
|
V(this, r), F(this, t);
|
|
447
447
|
const c = Xe(u)[U];
|
|
448
|
-
if (this[
|
|
448
|
+
if (this[A] = c, c.wrapper = this, i) {
|
|
449
449
|
const p = i.equals;
|
|
450
450
|
p && (c.equal = p), c.watched = i[e.subtle.watched], c.unwatched = i[e.subtle.unwatched];
|
|
451
451
|
}
|
|
@@ -453,25 +453,25 @@ var C;
|
|
|
453
453
|
get() {
|
|
454
454
|
if (!(0, e.isState)(this))
|
|
455
455
|
throw new TypeError("Wrong receiver type for Signal.State.prototype.get");
|
|
456
|
-
return et.call(this[
|
|
456
|
+
return et.call(this[A]);
|
|
457
457
|
}
|
|
458
458
|
set(u) {
|
|
459
459
|
if (!(0, e.isState)(this))
|
|
460
460
|
throw new TypeError("Wrong receiver type for Signal.State.prototype.set");
|
|
461
461
|
if (qe())
|
|
462
462
|
throw new Error("Writes to signals not permitted during Watcher callback");
|
|
463
|
-
const i = this[
|
|
463
|
+
const i = this[A];
|
|
464
464
|
tt(i, u);
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
-
t =
|
|
467
|
+
t = A, r = /* @__PURE__ */ new WeakSet(), e.isState = (l) => typeof l == "object" && K(r, l), e.State = n;
|
|
468
468
|
class a {
|
|
469
469
|
// Create a Signal which evaluates to the value returned by the callback.
|
|
470
470
|
// Callback is called with this signal as the parameter.
|
|
471
471
|
constructor(u, i) {
|
|
472
472
|
V(this, o), F(this, s);
|
|
473
473
|
const c = Fe(u)[U];
|
|
474
|
-
if (c.consumerAllowSignalWrites = !0, this[
|
|
474
|
+
if (c.consumerAllowSignalWrites = !0, this[A] = c, c.wrapper = this, i) {
|
|
475
475
|
const p = i.equals;
|
|
476
476
|
p && (c.equal = p), c.watched = i[e.subtle.watched], c.unwatched = i[e.subtle.unwatched];
|
|
477
477
|
}
|
|
@@ -479,87 +479,87 @@ var C;
|
|
|
479
479
|
get() {
|
|
480
480
|
if (!(0, e.isComputed)(this))
|
|
481
481
|
throw new TypeError("Wrong receiver type for Signal.Computed.prototype.get");
|
|
482
|
-
return ye(this[
|
|
482
|
+
return ye(this[A]);
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
|
-
s =
|
|
486
|
-
var u, i,
|
|
487
|
-
function p(
|
|
488
|
-
let
|
|
485
|
+
s = A, o = /* @__PURE__ */ new WeakSet(), e.isComputed = (l) => typeof l == "object" && K(o, l), e.Computed = a, ((l) => {
|
|
486
|
+
var u, i, h, c;
|
|
487
|
+
function p(v) {
|
|
488
|
+
let m, d = null;
|
|
489
489
|
try {
|
|
490
|
-
d = S(null),
|
|
490
|
+
d = S(null), m = v();
|
|
491
491
|
} finally {
|
|
492
492
|
S(d);
|
|
493
493
|
}
|
|
494
|
-
return
|
|
494
|
+
return m;
|
|
495
495
|
}
|
|
496
|
-
|
|
497
|
-
function v
|
|
498
|
-
var
|
|
499
|
-
if (!(0, e.isComputed)(
|
|
496
|
+
l.untrack = p;
|
|
497
|
+
function f(v) {
|
|
498
|
+
var m;
|
|
499
|
+
if (!(0, e.isComputed)(v) && !(0, e.isWatcher)(v))
|
|
500
500
|
throw new TypeError("Called introspectSources without a Computed or Watcher argument");
|
|
501
|
-
return ((
|
|
501
|
+
return ((m = v[A].producerNode) == null ? void 0 : m.map((d) => d.wrapper)) ?? [];
|
|
502
502
|
}
|
|
503
|
-
|
|
504
|
-
function
|
|
505
|
-
var
|
|
506
|
-
if (!(0, e.isComputed)(
|
|
503
|
+
l.introspectSources = f;
|
|
504
|
+
function y(v) {
|
|
505
|
+
var m;
|
|
506
|
+
if (!(0, e.isComputed)(v) && !(0, e.isState)(v))
|
|
507
507
|
throw new TypeError("Called introspectSinks without a Signal argument");
|
|
508
|
-
return ((
|
|
508
|
+
return ((m = v[A].liveConsumerNode) == null ? void 0 : m.map((d) => d.wrapper)) ?? [];
|
|
509
509
|
}
|
|
510
|
-
|
|
511
|
-
function
|
|
512
|
-
if (!(0, e.isComputed)(
|
|
510
|
+
l.introspectSinks = y;
|
|
511
|
+
function _(v) {
|
|
512
|
+
if (!(0, e.isComputed)(v) && !(0, e.isState)(v))
|
|
513
513
|
throw new TypeError("Called hasSinks without a Signal argument");
|
|
514
|
-
const
|
|
515
|
-
return
|
|
514
|
+
const m = v[A].liveConsumerNode;
|
|
515
|
+
return m ? m.length > 0 : !1;
|
|
516
516
|
}
|
|
517
|
-
|
|
518
|
-
function Z(
|
|
519
|
-
if (!(0, e.isComputed)(
|
|
517
|
+
l.hasSinks = _;
|
|
518
|
+
function Z(v) {
|
|
519
|
+
if (!(0, e.isComputed)(v) && !(0, e.isWatcher)(v))
|
|
520
520
|
throw new TypeError("Called hasSources without a Computed or Watcher argument");
|
|
521
|
-
const
|
|
522
|
-
return
|
|
521
|
+
const m = v[A].producerNode;
|
|
522
|
+
return m ? m.length > 0 : !1;
|
|
523
523
|
}
|
|
524
|
-
|
|
524
|
+
l.hasSources = Z;
|
|
525
525
|
class xe {
|
|
526
526
|
// When a (recursive) source of Watcher is written to, call this callback,
|
|
527
527
|
// if it hasn't already been called since the last `watch` call.
|
|
528
528
|
// No signals may be read or written during the notify.
|
|
529
|
-
constructor(
|
|
530
|
-
V(this, i), V(this,
|
|
529
|
+
constructor(m) {
|
|
530
|
+
V(this, i), V(this, h), F(this, u);
|
|
531
531
|
let d = Object.create(re);
|
|
532
|
-
d.wrapper = this, d.consumerMarkedDirty =
|
|
532
|
+
d.wrapper = this, d.consumerMarkedDirty = m, d.consumerIsAlwaysLive = !0, d.consumerAllowSignalWrites = !1, d.producerNode = [], this[A] = d;
|
|
533
533
|
}
|
|
534
534
|
// Add these signals to the Watcher's set, and set the watcher to run its
|
|
535
535
|
// notify callback next time any signal in the set (or one of its dependencies) changes.
|
|
536
536
|
// Can be called with no arguments just to reset the "notified" state, so that
|
|
537
537
|
// the notify callback will be invoked again.
|
|
538
|
-
watch(...
|
|
538
|
+
watch(...m) {
|
|
539
539
|
if (!(0, e.isWatcher)(this))
|
|
540
540
|
throw new TypeError("Called unwatch without Watcher receiver");
|
|
541
|
-
de(this,
|
|
542
|
-
const d = this[
|
|
541
|
+
de(this, h, c).call(this, m);
|
|
542
|
+
const d = this[A];
|
|
543
543
|
d.dirty = !1;
|
|
544
|
-
const
|
|
545
|
-
for (const L of
|
|
546
|
-
B(L[
|
|
547
|
-
S(
|
|
544
|
+
const g = S(d);
|
|
545
|
+
for (const L of m)
|
|
546
|
+
B(L[A]);
|
|
547
|
+
S(g);
|
|
548
548
|
}
|
|
549
549
|
// Remove these signals from the watched set (e.g., for an effect which is disposed)
|
|
550
|
-
unwatch(...
|
|
550
|
+
unwatch(...m) {
|
|
551
551
|
if (!(0, e.isWatcher)(this))
|
|
552
552
|
throw new TypeError("Called unwatch without Watcher receiver");
|
|
553
|
-
de(this,
|
|
554
|
-
const d = this[
|
|
553
|
+
de(this, h, c).call(this, m);
|
|
554
|
+
const d = this[A];
|
|
555
555
|
I(d);
|
|
556
|
-
for (let
|
|
557
|
-
if (
|
|
558
|
-
G(d.producerNode[
|
|
556
|
+
for (let g = d.producerNode.length - 1; g >= 0; g--)
|
|
557
|
+
if (m.includes(d.producerNode[g].wrapper)) {
|
|
558
|
+
G(d.producerNode[g], d.producerIndexOfThis[g]);
|
|
559
559
|
const L = d.producerNode.length - 1;
|
|
560
|
-
if (d.producerNode[
|
|
561
|
-
const Ee = d.producerIndexOfThis[
|
|
562
|
-
se(oe), oe.liveConsumerIndexOfThis[Ee] =
|
|
560
|
+
if (d.producerNode[g] = d.producerNode[L], d.producerIndexOfThis[g] = d.producerIndexOfThis[L], d.producerNode.length--, d.producerIndexOfThis.length--, d.nextProducerIndex--, g < d.producerNode.length) {
|
|
561
|
+
const Ee = d.producerIndexOfThis[g], oe = d.producerNode[g];
|
|
562
|
+
se(oe), oe.liveConsumerIndexOfThis[Ee] = g;
|
|
563
563
|
}
|
|
564
564
|
}
|
|
565
565
|
}
|
|
@@ -568,19 +568,19 @@ var C;
|
|
|
568
568
|
getPending() {
|
|
569
569
|
if (!(0, e.isWatcher)(this))
|
|
570
570
|
throw new TypeError("Called getPending without Watcher receiver");
|
|
571
|
-
return this[
|
|
571
|
+
return this[A].producerNode.filter((d) => d.dirty).map((d) => d.wrapper);
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
|
-
u =
|
|
575
|
-
for (const
|
|
576
|
-
if (!(0, e.isComputed)(
|
|
574
|
+
u = A, i = /* @__PURE__ */ new WeakSet(), h = /* @__PURE__ */ new WeakSet(), c = function(v) {
|
|
575
|
+
for (const m of v)
|
|
576
|
+
if (!(0, e.isComputed)(m) && !(0, e.isState)(m))
|
|
577
577
|
throw new TypeError("Called watch/unwatch without a Computed or State argument");
|
|
578
|
-
}, e.isWatcher = (
|
|
578
|
+
}, e.isWatcher = (v) => K(i, v), l.Watcher = xe;
|
|
579
579
|
function Te() {
|
|
580
|
-
var
|
|
581
|
-
return (
|
|
580
|
+
var v;
|
|
581
|
+
return (v = De()) == null ? void 0 : v.wrapper;
|
|
582
582
|
}
|
|
583
|
-
|
|
583
|
+
l.currentComputed = Te, l.watched = Symbol("watched"), l.unwatched = Symbol("unwatched");
|
|
584
584
|
})(e.subtle || (e.subtle = {}));
|
|
585
585
|
})(C || (C = {}));
|
|
586
586
|
const ot = /* @__PURE__ */ new Set(["internals", "effect", "styleProps"]);
|
|
@@ -607,24 +607,25 @@ function Ne(e) {
|
|
|
607
607
|
useShadow: o = !0,
|
|
608
608
|
formAssociated: n = !1,
|
|
609
609
|
styles: a
|
|
610
|
-
} = e,
|
|
611
|
-
if (!
|
|
610
|
+
} = e, l = r ?? t.name.replaceAll(/([a-z0-9])([A-Z])/g, "$1-$2").replaceAll(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").toLowerCase();
|
|
611
|
+
if (!l.includes("-"))
|
|
612
612
|
throw new Error(`Function ${t.name} must include at least one capital letter to be converted to a valid custom element name`);
|
|
613
|
-
if (customElements.get(
|
|
614
|
-
throw new Error(`Custom element with name ${
|
|
613
|
+
if (customElements.get(l))
|
|
614
|
+
throw new Error(`Custom element with name ${l} already defined`);
|
|
615
615
|
s.forEach((i) => {
|
|
616
616
|
if (ot.has(i))
|
|
617
617
|
throw new Error(`Attribute name "${i}" conflicts with a reserved context property.`);
|
|
618
618
|
});
|
|
619
619
|
let u;
|
|
620
|
-
a !== void 0 && (u = new CSSStyleSheet(), o ? u.replaceSync(a) : (u.replaceSync(`@scope (${
|
|
620
|
+
a !== void 0 && (u = new CSSStyleSheet(), o ? u.replaceSync(a) : (u.replaceSync(`@scope (${l}) { ${a} }`), document.adoptedStyleSheets = [
|
|
621
621
|
...document.adoptedStyleSheets,
|
|
622
622
|
u
|
|
623
|
-
])), customElements.define(
|
|
623
|
+
])), customElements.define(l, class extends HTMLElement {
|
|
624
624
|
#e;
|
|
625
625
|
#t;
|
|
626
|
-
#r
|
|
627
|
-
#s =
|
|
626
|
+
#r;
|
|
627
|
+
#s = [];
|
|
628
|
+
#o = /* @__PURE__ */ new Map();
|
|
628
629
|
static get observedAttributes() {
|
|
629
630
|
return s;
|
|
630
631
|
}
|
|
@@ -638,96 +639,103 @@ function Ne(e) {
|
|
|
638
639
|
]);
|
|
639
640
|
const i = {
|
|
640
641
|
internals: this.attachInternals(),
|
|
641
|
-
effect: (p) => this.#
|
|
642
|
+
effect: (p) => this.#s.push({ fn: p }),
|
|
642
643
|
styleProps: (p) => {
|
|
643
|
-
Object.keys(p).forEach((
|
|
644
|
-
const
|
|
645
|
-
|
|
644
|
+
Object.keys(p).forEach((f) => {
|
|
645
|
+
const y = p[f], _ = it(f);
|
|
646
|
+
y === null ? this.style.removeProperty(_) : this.style.setProperty(_, String(y));
|
|
646
647
|
});
|
|
647
648
|
}
|
|
648
649
|
};
|
|
649
650
|
s.forEach((p) => {
|
|
650
|
-
const
|
|
651
|
-
equals: (
|
|
651
|
+
const f = new C.State(this.getAttribute(p), {
|
|
652
|
+
equals: (_, Z) => _ === Z
|
|
652
653
|
});
|
|
653
|
-
this.#
|
|
654
|
+
this.#o.set(p, f), i[p] = f, Object.defineProperty(this, p, {
|
|
654
655
|
get() {
|
|
655
|
-
return
|
|
656
|
+
return f.get();
|
|
656
657
|
},
|
|
657
|
-
set(
|
|
658
|
-
if (
|
|
659
|
-
throw new TypeError(`Attribute "${p}" only accepts strings or null, got ${typeof
|
|
660
|
-
|
|
658
|
+
set(_) {
|
|
659
|
+
if (_ !== null && typeof _ != "string")
|
|
660
|
+
throw new TypeError(`Attribute "${p}" only accepts strings or null, got ${typeof _}.`);
|
|
661
|
+
f.set(_);
|
|
661
662
|
},
|
|
662
663
|
enumerable: !0,
|
|
663
664
|
configurable: !0
|
|
664
665
|
});
|
|
665
|
-
const
|
|
666
|
+
const y = new C.subtle.Watcher(() => {
|
|
666
667
|
queueMicrotask(() => {
|
|
667
|
-
const
|
|
668
|
-
|
|
668
|
+
const _ = f.get();
|
|
669
|
+
_ === null ? this.removeAttribute(p) : this.setAttribute(p, _), y.watch();
|
|
669
670
|
});
|
|
670
671
|
});
|
|
671
|
-
|
|
672
|
+
y.watch(f);
|
|
672
673
|
});
|
|
673
|
-
const
|
|
674
|
-
if (typeof
|
|
675
|
-
this.#e = new C.Computed(() =>
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
typeof w == "string" ? c.innerHTML = w : w != null && he(w, c);
|
|
674
|
+
const h = t.call(this, i), c = o ? this.shadowRoot : this;
|
|
675
|
+
if (typeof h == "function") {
|
|
676
|
+
this.#e = new C.Computed(() => h()), this.#r = () => {
|
|
677
|
+
const f = this.#e.get();
|
|
678
|
+
typeof f == "string" ? c.innerHTML = f : he(f, c);
|
|
679
679
|
};
|
|
680
|
-
let
|
|
680
|
+
let p = !1;
|
|
681
681
|
this.#t = new C.subtle.Watcher(() => {
|
|
682
|
-
|
|
683
|
-
|
|
682
|
+
p || (p = !0, queueMicrotask(() => {
|
|
683
|
+
p = !1;
|
|
684
684
|
try {
|
|
685
|
-
|
|
686
|
-
} catch (
|
|
685
|
+
this.#r();
|
|
686
|
+
} catch (f) {
|
|
687
687
|
console.error(
|
|
688
|
-
`Error in render function for <${
|
|
689
|
-
|
|
688
|
+
`Error in render function for <${l}> fun element: `,
|
|
689
|
+
f
|
|
690
690
|
);
|
|
691
691
|
}
|
|
692
692
|
this.#t.watch();
|
|
693
693
|
}));
|
|
694
|
-
})
|
|
695
|
-
} else
|
|
696
|
-
|
|
697
|
-
)
|
|
694
|
+
});
|
|
695
|
+
} else if (typeof h == "string")
|
|
696
|
+
c.innerHTML = h;
|
|
697
|
+
else if (typeof h == "object" && "_$litType$" in h)
|
|
698
|
+
he(h, c);
|
|
699
|
+
else {
|
|
700
|
+
if (h === void 0)
|
|
701
|
+
return;
|
|
702
|
+
console.error(
|
|
703
|
+
`Setup function for <${l}> returned an unexpected value. Expected a render function, a template (html\`...\`), a string, or nothing. Got: ${typeof h}`
|
|
704
|
+
);
|
|
705
|
+
}
|
|
698
706
|
}
|
|
699
707
|
connectedCallback() {
|
|
700
|
-
this.#t && this.#e && this.#t.watch(this.#e), this.#r.forEach((i) => {
|
|
708
|
+
this.#t && this.#e && (this.#t.watch(this.#e), this.#r?.()), this.#s.forEach((i) => {
|
|
701
709
|
try {
|
|
702
710
|
i.computed = new C.Computed(() => i.fn()), i.watcher = new C.subtle.Watcher(() => {
|
|
703
711
|
queueMicrotask(() => {
|
|
704
712
|
typeof i.cleanup == "function" && i.cleanup(), i.computed = new C.Computed(() => i.fn());
|
|
705
713
|
try {
|
|
706
714
|
i.cleanup = i.computed.get();
|
|
707
|
-
} catch (
|
|
715
|
+
} catch (h) {
|
|
708
716
|
console.error(
|
|
709
|
-
`Error in effect for <${
|
|
710
|
-
|
|
717
|
+
`Error in effect for <${l}> fun element: `,
|
|
718
|
+
h
|
|
711
719
|
);
|
|
712
720
|
}
|
|
713
721
|
i.watcher.watch(i.computed);
|
|
714
722
|
});
|
|
715
723
|
}), i.cleanup = i.computed.get(), i.watcher.watch(i.computed);
|
|
716
|
-
} catch (
|
|
724
|
+
} catch (h) {
|
|
717
725
|
console.error(
|
|
718
|
-
`Error in effect for <${
|
|
719
|
-
|
|
726
|
+
`Error in effect for <${l}> fun element: `,
|
|
727
|
+
h
|
|
720
728
|
);
|
|
721
729
|
}
|
|
722
730
|
});
|
|
723
731
|
}
|
|
724
732
|
disconnectedCallback() {
|
|
725
|
-
this.#t && this.#e && this.#t.unwatch(this.#e), this.#
|
|
733
|
+
this.#t && this.#e && this.#t.unwatch(this.#e), this.#s.forEach((i) => {
|
|
726
734
|
i.watcher.unwatch(i.computed), typeof i.cleanup == "function" && i.cleanup(), i.cleanup = void 0;
|
|
727
735
|
});
|
|
728
736
|
}
|
|
729
|
-
attributeChangedCallback(i,
|
|
730
|
-
this.#
|
|
737
|
+
attributeChangedCallback(i, h, c) {
|
|
738
|
+
this.#o.get(i)?.set(c);
|
|
731
739
|
}
|
|
732
740
|
});
|
|
733
741
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -163,6 +163,7 @@ export function define<Attrs extends string = never>(options: DefineOptions<Attr
|
|
|
163
163
|
customElements.define(elementName, class extends HTMLElement {
|
|
164
164
|
#template: Signal.Computed<ReturnType<typeof html>> | undefined
|
|
165
165
|
#watcher: any
|
|
166
|
+
#renderTemplate: (() => void) | undefined
|
|
166
167
|
#effects: EffectEntry[] = []
|
|
167
168
|
#attributeSignals: Map<string, Signal.State<string | null>> = new Map()
|
|
168
169
|
|
|
@@ -246,12 +247,11 @@ export function define<Attrs extends string = never>(options: DefineOptions<Attr
|
|
|
246
247
|
if (typeof setupResult === 'function') {
|
|
247
248
|
this.#template = new Signal.Computed(() => setupResult())
|
|
248
249
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const result = template.get()
|
|
250
|
+
this.#renderTemplate = () => {
|
|
251
|
+
const result = this.#template!.get()
|
|
252
252
|
if (typeof result === 'string') {
|
|
253
253
|
target.innerHTML = result
|
|
254
|
-
} else
|
|
254
|
+
} else {
|
|
255
255
|
render(result, target)
|
|
256
256
|
}
|
|
257
257
|
}
|
|
@@ -263,10 +263,10 @@ export function define<Attrs extends string = never>(options: DefineOptions<Attr
|
|
|
263
263
|
queueMicrotask(() => {
|
|
264
264
|
renderPending = false
|
|
265
265
|
try {
|
|
266
|
-
renderTemplate()
|
|
266
|
+
this.#renderTemplate!()
|
|
267
267
|
} catch (error) {
|
|
268
268
|
console.error(
|
|
269
|
-
`Error in render function for <${
|
|
269
|
+
`Error in render function for <${elementName}> fun element: `,
|
|
270
270
|
error,
|
|
271
271
|
)
|
|
272
272
|
}
|
|
@@ -274,17 +274,15 @@ export function define<Attrs extends string = never>(options: DefineOptions<Attr
|
|
|
274
274
|
})
|
|
275
275
|
})
|
|
276
276
|
|
|
277
|
-
this.#watcher.watch(this.#template)
|
|
278
|
-
|
|
279
|
-
renderTemplate()
|
|
280
|
-
} else if (setupResult === undefined) {
|
|
281
277
|
} else if (typeof setupResult === 'string') {
|
|
282
278
|
target.innerHTML = setupResult
|
|
283
279
|
} else if (typeof setupResult === 'object' && '_$litType$' in (setupResult as object)) {
|
|
284
280
|
render(setupResult, target)
|
|
281
|
+
} else if (setupResult === undefined) {
|
|
282
|
+
return
|
|
285
283
|
} else {
|
|
286
284
|
console.error(
|
|
287
|
-
`Setup function for <${
|
|
285
|
+
`Setup function for <${elementName}> returned an unexpected value. ` +
|
|
288
286
|
`Expected a render function, a template (html\`...\`), a string, or nothing. ` +
|
|
289
287
|
`Got: ${typeof setupResult}`
|
|
290
288
|
)
|
|
@@ -294,6 +292,7 @@ export function define<Attrs extends string = never>(options: DefineOptions<Attr
|
|
|
294
292
|
connectedCallback() {
|
|
295
293
|
if (this.#watcher && this.#template) {
|
|
296
294
|
this.#watcher.watch(this.#template)
|
|
295
|
+
this.#renderTemplate?.()
|
|
297
296
|
}
|
|
298
297
|
|
|
299
298
|
this.#effects.forEach(entry => {
|