@shane_il/pulse 0.1.0 → 0.1.2

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/pulse.js CHANGED
@@ -1,126 +1,126 @@
1
- var Z = Object.defineProperty;
2
- var v = (t, e, n) => e in t ? Z(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var b = (t, e, n) => v(t, typeof e != "symbol" ? e + "" : e, n);
4
- const L = Symbol("TEXT_NODE"), tt = Symbol("FRAGMENT");
5
- function F(t) {
1
+ var v = Object.defineProperty;
2
+ var tt = (t, e, s) => e in t ? v(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
+ var g = (t, e, s) => tt(t, typeof e != "symbol" ? e + "" : e, s);
4
+ const j = Symbol("TEXT_NODE"), et = Symbol("FRAGMENT");
5
+ function D(t) {
6
6
  return {
7
- type: L,
7
+ type: j,
8
8
  props: { nodeValue: String(t) },
9
9
  children: [],
10
10
  key: null
11
11
  };
12
12
  }
13
- function et(t) {
14
- return t == null || typeof t == "boolean" ? null : typeof t == "string" || typeof t == "number" ? F(t) : t;
13
+ function nt(t) {
14
+ return t == null || typeof t == "boolean" ? null : typeof t == "string" || typeof t == "number" ? D(t) : t;
15
15
  }
16
- function $(t) {
16
+ function z(t) {
17
17
  const e = [];
18
- for (const n of t)
19
- if (Array.isArray(n))
20
- e.push(...$(n));
18
+ for (const s of t)
19
+ if (Array.isArray(s))
20
+ e.push(...z(s));
21
21
  else {
22
- const s = et(n);
23
- s !== null && e.push(s);
22
+ const n = nt(s);
23
+ n !== null && e.push(n);
24
24
  }
25
25
  return e;
26
26
  }
27
- function I(t, e, ...n) {
27
+ function W(t, e, ...s) {
28
28
  e = e || {};
29
- const s = e.key ?? null;
29
+ const n = e.key ?? null;
30
30
  e.key !== void 0 && (e = { ...e }, delete e.key);
31
- const r = $(n);
32
- return { type: t, props: e, children: r, key: s };
31
+ const o = z(s);
32
+ return { type: t, props: e, children: o, key: n };
33
33
  }
34
- function nt(t) {
34
+ function st(t) {
35
35
  let e = t.state;
36
- const n = t.actions, s = /* @__PURE__ */ new Set();
37
- function r() {
36
+ const s = t.actions, n = /* @__PURE__ */ new Set();
37
+ function o() {
38
38
  return e;
39
39
  }
40
- function o(a, d) {
41
- const l = n[a];
42
- if (!l)
43
- throw new Error(`[pulse] Unknown action: "${a}"`);
44
- const m = l(e, d);
45
- if (m !== e) {
46
- e = m;
47
- for (const p of s)
48
- p(e);
40
+ function r(i, u) {
41
+ const h = s[i];
42
+ if (!h)
43
+ throw new Error(`[pulse] Unknown action: "${i}"`);
44
+ const p = h(e, u);
45
+ if (p !== e) {
46
+ e = p;
47
+ for (const f of n)
48
+ f(e);
49
49
  }
50
50
  }
51
- function c(a) {
52
- return s.add(a), () => {
53
- s.delete(a);
51
+ function c(i) {
52
+ return n.add(i), () => {
53
+ n.delete(i);
54
54
  };
55
55
  }
56
- function u(a) {
57
- return { store: i, selector: a };
56
+ function a(i) {
57
+ return { store: l, selector: i };
58
58
  }
59
- const i = { getState: r, dispatch: o, subscribe: c, select: u };
60
- return i;
59
+ const l = { getState: o, dispatch: r, subscribe: c, select: a };
60
+ return l;
61
61
  }
62
- let P = !1;
63
- const R = /* @__PURE__ */ new Set();
64
- function st(t) {
65
- R.add(t), P || (P = !0, queueMicrotask(ot));
62
+ let I = !1;
63
+ const V = /* @__PURE__ */ new Set();
64
+ function rt(t) {
65
+ V.add(t), I || (I = !0, queueMicrotask(ot));
66
66
  }
67
67
  function ot() {
68
- const t = [...R];
69
- R.clear(), P = !1;
68
+ const t = [...V];
69
+ V.clear(), I = !1;
70
70
  for (const e of t)
71
71
  e();
72
72
  }
73
- function pt() {
74
- const t = [...R];
75
- R.clear(), P = !1;
73
+ function ht() {
74
+ const t = [...V];
75
+ V.clear(), I = !1;
76
76
  for (const e of t)
77
77
  e();
78
78
  }
79
- const X = Symbol("PULSE_CONNECTED");
80
- function rt(t, e) {
81
- return function(s) {
82
- const r = t || {};
83
- function o(c) {
84
- const u = {};
85
- for (const i in r) {
86
- const { store: a, selector: d } = r[i];
87
- u[i] = d(a.getState());
79
+ const H = Symbol("PULSE_CONNECTED");
80
+ function ct(t, e) {
81
+ return function(n) {
82
+ const o = t || {};
83
+ function r(c) {
84
+ const a = {};
85
+ for (const l in o) {
86
+ const { store: i, selector: u } = o[l];
87
+ a[l] = u(i.getState());
88
88
  }
89
- return s({ ...u, ...c });
89
+ return n({ ...a, ...c });
90
90
  }
91
- return o[X] = !0, o._bindings = r, o._innerComponent = s, e && (o._lifecycle = e), o.displayName = `Connected(${s.displayName || s.name || "Anonymous"})`, o;
91
+ return r[H] = !0, r._bindings = o, r._innerComponent = n, e && (r._lifecycle = e), r.displayName = `Connected(${n.displayName || n.name || "Anonymous"})`, r;
92
92
  };
93
93
  }
94
- class ct {
95
- constructor(e, n) {
96
- b(this, "connectedFn");
97
- b(this, "props");
98
- b(this, "prevSelected");
99
- b(this, "unsubscribers");
100
- b(this, "lastVTree");
101
- b(this, "parentDom");
102
- b(this, "_renderCallback");
103
- b(this, "_mountCleanup");
104
- this.connectedFn = e, this.props = n, this.prevSelected = {}, this.unsubscribers = [], this.lastVTree = null, this.parentDom = null, this._renderCallback = null, this._mountCleanup = null;
94
+ class it {
95
+ constructor(e, s) {
96
+ g(this, "connectedFn");
97
+ g(this, "props");
98
+ g(this, "prevSelected");
99
+ g(this, "unsubscribers");
100
+ g(this, "lastVTree");
101
+ g(this, "parentDom");
102
+ g(this, "_renderCallback");
103
+ g(this, "_mountCleanup");
104
+ this.connectedFn = e, this.props = s, this.prevSelected = {}, this.unsubscribers = [], this.lastVTree = null, this.parentDom = null, this._renderCallback = null, this._mountCleanup = null;
105
105
  }
106
- mount(e, n) {
107
- var o;
108
- this.parentDom = e, this._renderCallback = n;
109
- const s = this.connectedFn._bindings;
110
- for (const c in s) {
111
- const { store: u, selector: i } = s[c];
112
- this.prevSelected[c] = i(u.getState());
106
+ mount(e, s) {
107
+ var r;
108
+ this.parentDom = e, this._renderCallback = s;
109
+ const n = this.connectedFn._bindings;
110
+ for (const c in n) {
111
+ const { store: a, selector: l } = n[c];
112
+ this.prevSelected[c] = l(a.getState());
113
113
  }
114
- for (const c in s) {
115
- const { store: u } = s[c], i = u.subscribe(() => {
114
+ for (const c in n) {
115
+ const { store: a } = n[c], l = a.subscribe(() => {
116
116
  this._onStoreChange();
117
117
  });
118
- this.unsubscribers.push(i);
118
+ this.unsubscribers.push(l);
119
119
  }
120
- const r = this.connectedFn._lifecycle;
121
- if (r != null && r.onMount) {
122
- const c = r.onMount({
123
- dom: (o = this.lastVTree) == null ? void 0 : o._dom,
120
+ const o = this.connectedFn._lifecycle;
121
+ if (o != null && o.onMount) {
122
+ const c = o.onMount({
123
+ dom: (r = this.lastVTree) == null ? void 0 : r._dom,
124
124
  props: this.props
125
125
  });
126
126
  typeof c == "function" && (this._mountCleanup = c);
@@ -128,465 +128,504 @@ class ct {
128
128
  }
129
129
  _onStoreChange() {
130
130
  const e = this.connectedFn._bindings;
131
- let n = !1;
132
- for (const s in e) {
133
- const { store: r, selector: o } = e[s], c = o(r.getState());
134
- if (!it(c, this.prevSelected[s])) {
135
- n = !0;
131
+ let s = !1;
132
+ for (const n in e) {
133
+ const { store: o, selector: r } = e[n], c = r(o.getState());
134
+ if (!lt(c, this.prevSelected[n])) {
135
+ s = !0;
136
136
  break;
137
137
  }
138
138
  }
139
- n && st(this._renderCallback);
139
+ s && rt(this._renderCallback);
140
140
  }
141
141
  updateSelected() {
142
142
  const e = this.connectedFn._bindings;
143
- for (const n in e) {
144
- const { store: s, selector: r } = e[n];
145
- this.prevSelected[n] = r(s.getState());
143
+ for (const s in e) {
144
+ const { store: n, selector: o } = e[s];
145
+ this.prevSelected[s] = o(n.getState());
146
146
  }
147
147
  }
148
148
  unmount() {
149
149
  this._mountCleanup && (this._mountCleanup(), this._mountCleanup = null);
150
150
  const e = this.connectedFn._lifecycle;
151
151
  e != null && e.onDestroy && e.onDestroy({ props: this.props });
152
- for (const n of this.unsubscribers)
153
- n();
152
+ for (const s of this.unsubscribers)
153
+ s();
154
154
  this.unsubscribers = [], this._renderCallback = null;
155
155
  }
156
156
  }
157
- function it(t, e) {
157
+ function lt(t, e) {
158
158
  if (Object.is(t, e)) return !0;
159
159
  if (typeof t != "object" || typeof e != "object" || t === null || e === null) return !1;
160
- const n = Object.keys(t), s = Object.keys(e);
161
- if (n.length !== s.length) return !1;
162
- for (const r of n)
163
- if (!Object.prototype.hasOwnProperty.call(e, r) || !Object.is(t[r], e[r]))
160
+ const s = Object.keys(t), n = Object.keys(e);
161
+ if (s.length !== n.length) return !1;
162
+ for (const o of s)
163
+ if (!Object.prototype.hasOwnProperty.call(e, o) || !Object.is(t[o], e[o]))
164
164
  return !1;
165
165
  return !0;
166
166
  }
167
- const f = {
167
+ const y = {
168
168
  CREATE: "CREATE",
169
169
  REMOVE: "REMOVE",
170
170
  REPLACE: "REPLACE",
171
171
  UPDATE: "UPDATE",
172
172
  TEXT: "TEXT",
173
- MOVE: "MOVE"
173
+ MOVE: "MOVE",
174
+ CHILDREN: "CHILDREN"
174
175
  };
175
176
  function k(t, e) {
176
177
  if (e == null && t == null) return [];
177
- if (e == null) return [{ type: f.REMOVE, target: t }];
178
- if (t == null) return [{ type: f.CREATE, newVNode: e }];
178
+ if (e == null) return [{ type: y.REMOVE, target: t }];
179
+ if (t == null) return [{ type: y.CREATE, newVNode: e }];
179
180
  if (t.type !== e.type)
180
- return [{ type: f.REPLACE, oldVNode: t, newVNode: e }];
181
- if (e._dom = t._dom, t.type === L)
182
- return t.props.nodeValue !== e.props.nodeValue ? [{ type: f.TEXT, oldVNode: t, newVNode: e }] : [];
183
- const n = [], s = at(t.props, e.props);
184
- s && n.push({ type: f.UPDATE, target: t, propPatches: s });
185
- const r = ut(t.children, e.children);
186
- return n.push(...r), n;
181
+ return [{ type: y.REPLACE, oldVNode: t, newVNode: e }];
182
+ if (e._dom = t._dom, t.type === j)
183
+ return t.props.nodeValue !== e.props.nodeValue ? [{ type: y.TEXT, oldVNode: t, newVNode: e }] : [];
184
+ const s = [], n = at(t.props, e.props);
185
+ n && s.push({ type: y.UPDATE, target: t, propPatches: n });
186
+ const o = ut(t.children, e.children);
187
+ return o.length && s.push({ type: y.CHILDREN, parent: t, childPatches: o }), s;
187
188
  }
188
189
  function at(t, e) {
189
- const n = {}, s = [];
190
- let r = !1;
191
- for (const o in e)
192
- o !== "children" && t[o] !== e[o] && (n[o] = e[o], r = !0);
193
- for (const o in t)
194
- o !== "children" && (o in e || (s.push(o), r = !0));
195
- return r ? { set: n, remove: s } : null;
190
+ const s = {}, n = [];
191
+ let o = !1;
192
+ for (const r in e)
193
+ r !== "children" && t[r] !== e[r] && (s[r] = e[r], o = !0);
194
+ for (const r in t)
195
+ r !== "children" && (r in e || (n.push(r), o = !0));
196
+ return o ? { set: s, remove: n } : null;
196
197
  }
197
198
  function O(t, e) {
198
199
  return t == null || e == null ? !1 : t.type === e.type && t.key === e.key;
199
200
  }
200
- function U(t, e) {
201
- const n = /* @__PURE__ */ new Set();
202
- let s = 0, r = 0;
203
- for (const o of t)
204
- o != null && (o.key != null ? (s++, n.has(o.key) && console.warn(
205
- `[pulse] Duplicate key "${String(o.key)}" in ${e} children. Keys must be unique among siblings.`
206
- ), n.add(o.key)) : r++);
207
- s > 0 && r > 0 && console.warn(
208
- `[pulse] Mixed keyed and unkeyed children in ${e} list (${s} keyed, ${r} unkeyed). Either all children should have keys or none should.`
201
+ function q(t, e) {
202
+ const s = /* @__PURE__ */ new Set();
203
+ let n = 0, o = 0;
204
+ for (const r of t)
205
+ r != null && (r.key != null ? (n++, s.has(r.key) && console.warn(
206
+ `[pulse] Duplicate key "${String(r.key)}" in ${e} children. Keys must be unique among siblings.`
207
+ ), s.add(r.key)) : o++);
208
+ n > 0 && o > 0 && console.warn(
209
+ `[pulse] Mixed keyed and unkeyed children in ${e} list (${n} keyed, ${o} unkeyed). Either all children should have keys or none should.`
209
210
  );
210
211
  }
211
212
  function ut(t, e) {
212
- var l;
213
- process.env.NODE_ENV !== "production" && (U(t, "old"), U(e, "new"));
214
- const n = [];
215
- let s = 0, r = t.length - 1, o = 0, c = e.length - 1, u = t[s], i = t[r], a = e[o], d = e[c];
216
- for (; s <= r && o <= c; ) {
217
- if (u == null) {
218
- u = t[++s];
213
+ var h;
214
+ process.env.NODE_ENV !== "production" && (q(t, "old"), q(e, "new"));
215
+ const s = [];
216
+ let n = 0, o = t.length - 1, r = 0, c = e.length - 1, a = t[n], l = t[o], i = e[r], u = e[c];
217
+ for (; n <= o && r <= c; ) {
218
+ if (a == null) {
219
+ a = t[++n];
219
220
  continue;
220
221
  }
221
- if (i == null) {
222
- i = t[--r];
222
+ if (l == null) {
223
+ l = t[--o];
223
224
  continue;
224
225
  }
225
- if (O(u, a))
226
- n.push(...k(u, a)), u = t[++s], a = e[++o];
227
- else if (O(i, d))
228
- n.push(...k(i, d)), i = t[--r], d = e[--c];
229
- else if (O(u, d))
230
- n.push({
231
- type: f.MOVE,
232
- vnode: u,
233
- anchor: t[r + 1] || null,
234
- childPatches: k(u, d)
235
- }), u = t[++s], d = e[--c];
236
- else if (O(i, a))
237
- n.push({
238
- type: f.MOVE,
239
- vnode: i,
240
- anchor: u,
241
- childPatches: k(i, a)
242
- }), i = t[--r], a = e[++o];
226
+ if (O(a, i))
227
+ s.push(...k(a, i)), a = t[++n], i = e[++r];
228
+ else if (O(l, u))
229
+ s.push(...k(l, u)), l = t[--o], u = e[--c];
230
+ else if (O(a, u))
231
+ s.push({
232
+ type: y.MOVE,
233
+ vnode: a,
234
+ anchor: t[o + 1] || null,
235
+ childPatches: k(a, u)
236
+ }), a = t[++n], u = e[--c];
237
+ else if (O(l, i))
238
+ s.push({
239
+ type: y.MOVE,
240
+ vnode: l,
241
+ anchor: a,
242
+ childPatches: k(l, i)
243
+ }), l = t[--o], i = e[++r];
243
244
  else
244
245
  break;
245
246
  }
246
- if (s <= r && o <= c) {
247
- const m = /* @__PURE__ */ new Map();
248
- for (let p = s; p <= r; p++) {
249
- const g = (l = t[p]) == null ? void 0 : l.key;
250
- g != null && m.set(g, p);
247
+ if (n <= o && r <= c) {
248
+ const p = /* @__PURE__ */ new Map();
249
+ for (let f = n; f <= o; f++) {
250
+ const m = (h = t[f]) == null ? void 0 : h.key;
251
+ m != null && p.set(m, f);
251
252
  }
252
- for (; o <= c; ) {
253
- a = e[o];
254
- const p = a.key != null ? m.get(a.key) : void 0;
255
- if (p !== void 0) {
256
- const g = t[p];
257
- n.push({
258
- type: f.MOVE,
259
- vnode: g,
260
- anchor: t[s] || null,
261
- childPatches: k(g, a)
262
- }), t[p] = null, m.delete(a.key);
253
+ for (; r <= c; ) {
254
+ i = e[r];
255
+ const f = i.key != null ? p.get(i.key) : void 0;
256
+ if (f !== void 0) {
257
+ const m = t[f];
258
+ s.push({
259
+ type: y.MOVE,
260
+ vnode: m,
261
+ anchor: t[n] || null,
262
+ childPatches: k(m, i)
263
+ }), t[f] = null, p.delete(i.key);
263
264
  } else
264
- n.push({
265
- type: f.CREATE,
266
- newVNode: a,
267
- anchor: t[s] || null
265
+ s.push({
266
+ type: y.CREATE,
267
+ newVNode: i,
268
+ anchor: t[n] || null
268
269
  });
269
- o++;
270
+ r++;
270
271
  }
271
- for (let p = s; p <= r; p++)
272
- t[p] != null && n.push({ type: f.REMOVE, target: t[p] });
272
+ for (let f = n; f <= o; f++)
273
+ t[f] != null && s.push({ type: y.REMOVE, target: t[f] });
273
274
  }
274
- if (s > r) {
275
- const m = e[c + 1] || null;
276
- for (let p = o; p <= c; p++)
277
- n.push({ type: f.CREATE, newVNode: e[p], anchor: m });
278
- } else if (o > c)
279
- for (let m = s; m <= r; m++)
280
- t[m] != null && n.push({ type: f.REMOVE, target: t[m] });
281
- return n;
275
+ if (n > o) {
276
+ const p = e[c + 1] || null;
277
+ for (let f = r; f <= c; f++)
278
+ s.push({ type: y.CREATE, newVNode: e[f], anchor: p });
279
+ } else if (r > c)
280
+ for (let p = n; p <= o; p++)
281
+ t[p] != null && s.push({ type: y.REMOVE, target: t[p] });
282
+ return s;
282
283
  }
283
284
  function N(t) {
284
- if (t.type === L) {
285
- const n = document.createTextNode(t.props.nodeValue);
286
- return t._dom = n, n;
285
+ if (t.type === j) {
286
+ const s = document.createTextNode(t.props.nodeValue);
287
+ return t._dom = s, s;
287
288
  }
288
- if (t.type === tt) {
289
- const n = document.createDocumentFragment();
290
- for (const s of t.children)
291
- n.appendChild(N(s));
292
- return t._dom = n, n;
289
+ if (t.type === et) {
290
+ const s = document.createDocumentFragment();
291
+ for (const n of t.children)
292
+ s.appendChild(N(n));
293
+ return t._dom = s, s;
293
294
  }
294
295
  const e = document.createElement(t.type);
295
- lt(e, {}, t.props);
296
- for (const n of t.children)
297
- e.appendChild(N(n));
296
+ ft(e, {}, t.props);
297
+ for (const s of t.children)
298
+ e.appendChild(N(s));
298
299
  return t._dom = e, e;
299
300
  }
300
- function lt(t, e, n) {
301
- for (const s in e)
302
- s === "children" || s === "key" || s in n || K(t, s, e[s]);
303
- for (const s in n)
304
- s === "children" || s === "key" || e[s] !== n[s] && z(t, s, n[s], e[s]);
301
+ function ft(t, e, s) {
302
+ for (const n in e)
303
+ n === "children" || n === "key" || n in s || B(t, n, e[n]);
304
+ for (const n in s)
305
+ n === "children" || n === "key" || e[n] !== s[n] && K(t, n, s[n], e[n]);
305
306
  }
306
- function z(t, e, n, s) {
307
+ function K(t, e, s, n) {
307
308
  if (e.startsWith("on")) {
308
- const r = e.slice(2).toLowerCase();
309
- s && t.removeEventListener(r, s), n && t.addEventListener(r, n);
309
+ const o = e.slice(2).toLowerCase();
310
+ n && t.removeEventListener(o, n), s && t.addEventListener(o, s);
310
311
  } else if (e === "className")
311
- t.className = n || "";
312
- else if (e === "style" && typeof n == "object") {
313
- if (typeof s == "object" && s)
314
- for (const r in s)
315
- r in n || (t.style[r] = "");
316
- Object.assign(t.style, n);
317
- } else e === "ref" ? typeof n == "function" && n(t) : n === !0 ? t.setAttribute(e, "") : n === !1 || n == null ? t.removeAttribute(e) : t.setAttribute(e, n);
312
+ t.className = s || "";
313
+ else if (e === "style" && typeof s == "object") {
314
+ if (typeof n == "object" && n)
315
+ for (const o in n)
316
+ o in s || (t.style[o] = "");
317
+ Object.assign(t.style, s);
318
+ } else e === "ref" ? typeof s == "function" && s(t) : s === !0 ? t.setAttribute(e, "") : s === !1 || s == null ? t.removeAttribute(e) : t.setAttribute(e, s);
318
319
  }
319
- function K(t, e, n) {
320
- e.startsWith("on") ? t.removeEventListener(e.slice(2).toLowerCase(), n) : e === "className" ? t.className = "" : t.removeAttribute(e);
320
+ function B(t, e, s) {
321
+ e.startsWith("on") ? t.removeEventListener(e.slice(2).toLowerCase(), s) : e === "className" ? t.className = "" : t.removeAttribute(e);
321
322
  }
322
- function C(t, e) {
323
- var n, s, r;
324
- for (const o of e)
325
- switch (o.type) {
326
- case f.CREATE: {
327
- const c = N(o.newVNode);
328
- (n = o.anchor) != null && n._dom ? t.insertBefore(c, o.anchor._dom) : t.appendChild(c);
323
+ function R(t, e) {
324
+ var s, n, o;
325
+ for (const r of e)
326
+ switch (r.type) {
327
+ case y.CREATE: {
328
+ const c = N(r.newVNode);
329
+ (s = r.anchor) != null && s._dom ? t.insertBefore(c, r.anchor._dom) : t.appendChild(c);
329
330
  break;
330
331
  }
331
- case f.REMOVE: {
332
- const c = o.target._dom;
332
+ case y.REMOVE: {
333
+ const c = r.target._dom;
333
334
  c != null && c.parentNode && c.parentNode.removeChild(c);
334
335
  break;
335
336
  }
336
- case f.REPLACE: {
337
- const c = N(o.newVNode), u = o.oldVNode._dom;
338
- u != null && u.parentNode && u.parentNode.replaceChild(c, u);
337
+ case y.REPLACE: {
338
+ const c = N(r.newVNode), a = r.oldVNode._dom;
339
+ a != null && a.parentNode && a.parentNode.replaceChild(c, a);
339
340
  break;
340
341
  }
341
- case f.UPDATE: {
342
- const c = o.target._dom, { set: u, remove: i } = o.propPatches;
343
- for (const a of i)
344
- K(c, a, o.target.props[a]);
345
- for (const a in u)
346
- z(c, a, u[a], o.target.props[a]);
342
+ case y.UPDATE: {
343
+ const c = r.target._dom, { set: a, remove: l } = r.propPatches;
344
+ for (const i of l)
345
+ B(c, i, r.target.props[i]);
346
+ for (const i in a)
347
+ K(c, i, a[i], r.target.props[i]);
347
348
  break;
348
349
  }
349
- case f.TEXT: {
350
- const c = o.oldVNode._dom;
351
- c && (c.nodeValue = o.newVNode.props.nodeValue);
350
+ case y.TEXT: {
351
+ const c = r.oldVNode._dom;
352
+ c && (c.nodeValue = r.newVNode.props.nodeValue);
352
353
  break;
353
354
  }
354
- case f.MOVE: {
355
- const c = o.vnode._dom;
356
- c && ((s = o.anchor) != null && s._dom ? t.insertBefore(c, o.anchor._dom) : t.appendChild(c)), (r = o.childPatches) != null && r.length && c && C(c, o.childPatches);
355
+ case y.MOVE: {
356
+ const c = r.vnode._dom;
357
+ c && ((n = r.anchor) != null && n._dom ? t.insertBefore(c, r.anchor._dom) : t.appendChild(c)), (o = r.childPatches) != null && o.length && c && R(c, r.childPatches);
358
+ break;
359
+ }
360
+ case y.CHILDREN: {
361
+ const c = r.parent._dom;
362
+ c && r.childPatches.length && R(c, r.childPatches);
357
363
  break;
358
364
  }
359
365
  }
360
366
  }
361
367
  const M = /* @__PURE__ */ new WeakMap();
362
- function ht(t, e) {
363
- const n = M.get(e);
364
- if (n) {
365
- const s = T(t, e), r = [];
366
- A(n.vTree, r);
367
- const o = k(n.vTree, s);
368
- C(e, o);
368
+ function dt(t, e) {
369
+ const s = M.get(e);
370
+ if (s) {
371
+ const n = T(t, e), o = [];
372
+ C(s.vTree, o);
373
+ const r = k(s.vTree, n);
374
+ R(e, r);
369
375
  const c = [];
370
- s && A(s, c);
371
- const u = new Set(c);
372
- for (const a of r)
373
- u.has(a) || a.unmount();
374
- const i = new Set(r);
375
- for (const a of c)
376
- i.has(a) || a.mount(e, () => D(a, e));
377
- M.set(e, { vTree: s });
376
+ n && C(n, c);
377
+ const a = new Set(c);
378
+ for (const i of o)
379
+ a.has(i) || i.unmount();
380
+ const l = new Set(o);
381
+ for (const i of c)
382
+ l.has(i) || i.mount(e, () => L(i, e));
383
+ M.set(e, { vTree: n });
378
384
  } else {
379
- const s = T(t, e);
380
- if (!s) return;
381
- const r = N(s);
382
- e.appendChild(r);
383
- const o = [];
384
- A(s, o);
385
- for (const c of o)
386
- c.mount(e, () => D(c, e));
387
- M.set(e, { vTree: s });
385
+ const n = T(t, e);
386
+ if (!n) return;
387
+ const o = N(n);
388
+ e.appendChild(o);
389
+ const r = [];
390
+ C(n, r);
391
+ for (const c of r)
392
+ c.mount(e, () => L(c, e));
393
+ M.set(e, { vTree: n });
388
394
  }
389
395
  }
390
396
  function T(t, e) {
391
- var n;
397
+ var s;
392
398
  if (t == null) return null;
393
399
  if (typeof t.type == "function") {
394
- if (t.type[X]) {
395
- const r = t.type._lifecycle;
400
+ if (t.type[H]) {
401
+ const o = t.type._lifecycle;
396
402
  try {
397
- const o = new ct(t.type, t.props), c = t.type(t.props), i = T(c, e) ?? F("");
398
- return i._instance = o, o.lastVTree = i, i;
399
- } catch (o) {
400
- if (r != null && r.onError) {
401
- const c = r.onError({ error: o, props: t.props });
403
+ const r = new it(t.type, t.props), c = t.type(t.props), l = T(c, e) ?? D("");
404
+ if (l._instance) {
405
+ const i = {
406
+ type: "div",
407
+ props: { style: { display: "contents" } },
408
+ children: [l],
409
+ key: t.key
410
+ };
411
+ return i._instance = r, r.lastVTree = i, i;
412
+ }
413
+ return l._instance = r, r.lastVTree = l, l;
414
+ } catch (r) {
415
+ if (o != null && o.onError) {
416
+ const c = o.onError({ error: r, props: t.props });
402
417
  return T(c, e);
403
418
  }
404
- throw o;
419
+ throw r;
405
420
  }
406
421
  }
407
- const s = t.type({ ...t.props, children: t.children });
408
- return T(s, e);
422
+ const n = t.type({ ...t.props, children: t.children });
423
+ return T(n, e);
409
424
  }
410
- return (n = t.children) != null && n.length && (t.children = t.children.map((s) => T(s, e)).filter((s) => s != null)), t;
425
+ return (s = t.children) != null && s.length && (t.children = t.children.map((n) => T(n, e)).filter((n) => n != null)), t;
411
426
  }
412
- function D(t, e) {
413
- var r, o;
414
- const n = t.connectedFn, s = n._lifecycle;
427
+ function L(t, e) {
428
+ var o, r;
429
+ if (!t._renderCallback) return;
430
+ const s = t.connectedFn, n = s._lifecycle;
415
431
  try {
416
- const c = n(t.props), i = T(c, e) ?? F("");
417
- if (t.lastVTree) {
418
- const a = k(t.lastVTree, i), d = ((r = t.lastVTree._dom) == null ? void 0 : r.parentNode) || e;
419
- C(d, a);
420
- for (const l of a)
421
- l.type === f.REMOVE ? V(l.target, t) : l.type === f.REPLACE && V(l.oldVNode, t);
422
- i._dom || (i._dom = t.lastVTree._dom);
432
+ const c = s(t.props);
433
+ let l = T(c, e) ?? D(""), i;
434
+ if (l._instance && l._instance !== t ? (i = {
435
+ type: "div",
436
+ props: { style: { display: "contents" } },
437
+ children: [l],
438
+ key: null
439
+ }, i._instance = t) : (l._instance = t, i = l), t.lastVTree) {
440
+ F(t.lastVTree, t);
441
+ const m = k(t.lastVTree, i), x = ((o = t.lastVTree._dom) == null ? void 0 : o.parentNode) || e;
442
+ R(x, m), i._dom || (i._dom = t.lastVTree._dom);
423
443
  }
424
- i._instance = t, t.lastVTree = i, s != null && s.onUpdate && s.onUpdate({
444
+ const u = [];
445
+ A(t.lastVTree, u, t);
446
+ const h = [];
447
+ A(i, h, t);
448
+ const p = new Set(h);
449
+ for (const m of u)
450
+ p.has(m) || m.unmount();
451
+ t.lastVTree = i;
452
+ const f = new Set(u);
453
+ for (const m of h)
454
+ f.has(m) || m.mount(e, () => L(m, e));
455
+ n != null && n.onUpdate && n.onUpdate({
425
456
  dom: i == null ? void 0 : i._dom,
426
457
  props: t.props
427
458
  }), t.updateSelected();
428
459
  } catch (c) {
429
- if (s != null && s.onError) {
430
- const u = s.onError({ error: c, props: t.props }), i = T(u, e);
431
- if (t.lastVTree && i) {
432
- const a = k(t.lastVTree, i), d = ((o = t.lastVTree._dom) == null ? void 0 : o.parentNode) || e;
433
- C(d, a);
434
- for (const l of a)
435
- l.type === f.REMOVE ? V(l.target, t) : l.type === f.REPLACE && V(l.oldVNode, t);
436
- i._dom || (i._dom = t.lastVTree._dom);
460
+ if (n != null && n.onError) {
461
+ const a = n.onError({ error: c, props: t.props }), l = T(a, e);
462
+ if (t.lastVTree && l) {
463
+ F(t.lastVTree, t);
464
+ const u = k(t.lastVTree, l), h = ((r = t.lastVTree._dom) == null ? void 0 : r.parentNode) || e;
465
+ R(h, u), l._dom || (l._dom = t.lastVTree._dom);
437
466
  }
438
- t.lastVTree = i, t.updateSelected();
467
+ const i = [];
468
+ A(t.lastVTree, i, t);
469
+ for (const u of i) u.unmount();
470
+ t.lastVTree = l, t.updateSelected();
439
471
  } else
440
472
  throw c;
441
473
  }
442
474
  }
443
- function V(t, e) {
444
- if (t && (t._instance && t._instance !== e && t._instance.unmount(), t.children))
445
- for (const n of t.children)
446
- V(n, e);
475
+ function F(t, e) {
476
+ if (!(!t || !t.children))
477
+ for (let s = 0; s < t.children.length; s++) {
478
+ const n = t.children[s];
479
+ n._instance && n._instance !== e && n._instance.lastVTree && n._instance.lastVTree !== n && (t.children[s] = n._instance.lastVTree), F(t.children[s], e);
480
+ }
447
481
  }
448
- function A(t, e) {
482
+ function C(t, e) {
449
483
  if (t && (t._instance && e.push(t._instance), t.children))
484
+ for (const s of t.children)
485
+ C(s, e);
486
+ }
487
+ function A(t, e, s) {
488
+ if (t && (t._instance && t._instance !== s && e.push(t._instance), t.children))
450
489
  for (const n of t.children)
451
- A(n, e);
490
+ A(n, e, s);
452
491
  }
453
- function x(t) {
492
+ function P(t) {
454
493
  return t.length > 1 && t.endsWith("/") ? t.slice(0, -1) : t || "/";
455
494
  }
456
- function W(t) {
495
+ function $(t) {
457
496
  const e = {};
458
497
  if (!t) return e;
459
- const n = t.startsWith("?") ? t.slice(1) : t;
460
- return n && new URLSearchParams(n).forEach((r, o) => {
461
- e[o] = r;
498
+ const s = t.startsWith("?") ? t.slice(1) : t;
499
+ return s && new URLSearchParams(s).forEach((o, r) => {
500
+ e[r] = o;
462
501
  }), e;
463
502
  }
464
- function B(t, e) {
465
- const n = x(t), s = x(e);
466
- if (s === "*")
467
- return { params: { "*": n } };
468
- const r = n === "/" ? [""] : n.split("/").slice(1), o = s === "/" ? [""] : s.split("/").slice(1);
469
- if (o.length > 0 && o[o.length - 1] === "*") {
470
- const i = o.slice(0, -1);
471
- if (r.length < i.length) return null;
472
- const a = {};
473
- for (let l = 0; l < i.length; l++) {
474
- const m = i[l];
475
- if (m.startsWith(":"))
476
- a[m.slice(1)] = r[l];
477
- else if (m !== r[l])
503
+ function G(t, e) {
504
+ const s = P(t), n = P(e);
505
+ if (n === "*")
506
+ return { params: { "*": s } };
507
+ const o = s === "/" ? [""] : s.split("/").slice(1), r = n === "/" ? [""] : n.split("/").slice(1);
508
+ if (r.length > 0 && r[r.length - 1] === "*") {
509
+ const l = r.slice(0, -1);
510
+ if (o.length < l.length) return null;
511
+ const i = {};
512
+ for (let h = 0; h < l.length; h++) {
513
+ const p = l[h];
514
+ if (p.startsWith(":"))
515
+ i[p.slice(1)] = o[h];
516
+ else if (p !== o[h])
478
517
  return null;
479
518
  }
480
- const d = r.slice(i.length).join("/");
481
- return a["*"] = d, { params: a };
519
+ const u = o.slice(l.length).join("/");
520
+ return i["*"] = u, { params: i };
482
521
  }
483
- if (r.length !== o.length) return null;
484
- const u = {};
485
- for (let i = 0; i < o.length; i++) {
486
- const a = o[i];
487
- if (a.startsWith(":"))
488
- u[a.slice(1)] = r[i];
489
- else if (a !== r[i])
522
+ if (o.length !== r.length) return null;
523
+ const a = {};
524
+ for (let l = 0; l < r.length; l++) {
525
+ const i = r[l];
526
+ if (i.startsWith(":"))
527
+ a[i.slice(1)] = o[l];
528
+ else if (i !== o[l])
490
529
  return null;
491
530
  }
492
- return { params: u };
531
+ return { params: a };
493
532
  }
494
- function q(t, e) {
495
- for (const n of e) {
496
- const s = B(t, n.path);
497
- if (s)
498
- return { pattern: n.path, params: s.params };
533
+ function X(t, e) {
534
+ for (const s of e) {
535
+ const n = G(t, s.path);
536
+ if (n)
537
+ return { pattern: s.path, params: n.params };
499
538
  }
500
539
  return null;
501
540
  }
502
- function dt(t) {
503
- const { routes: e, initialPath: n } = t, s = n ?? window.location.pathname, r = n ? "" : window.location.search, o = x(s), c = W(r), u = q(o, e), i = nt({
541
+ function yt(t) {
542
+ const { routes: e, initialPath: s } = t, n = s ?? window.location.pathname, o = s ? "" : window.location.search, r = P(n), c = $(o), a = X(r, e), l = st({
504
543
  state: {
505
- path: o,
506
- params: (u == null ? void 0 : u.params) ?? {},
544
+ path: r,
545
+ params: (a == null ? void 0 : a.params) ?? {},
507
546
  query: c,
508
- matched: (u == null ? void 0 : u.pattern) ?? null
547
+ matched: (a == null ? void 0 : a.pattern) ?? null
509
548
  },
510
549
  actions: {
511
- _sync: (h, y) => y
550
+ _sync: (d, E) => E
512
551
  }
513
552
  });
514
- function a(h) {
515
- const y = h.indexOf("?"), S = x(y >= 0 ? h.slice(0, y) : h), w = y >= 0 ? h.slice(y + 1) : "", E = W(w), _ = q(S, e);
553
+ function i(d) {
554
+ const E = d.indexOf("?"), S = P(E >= 0 ? d.slice(0, E) : d), w = E >= 0 ? d.slice(E + 1) : "", _ = $(w), b = X(S, e);
516
555
  return {
517
556
  path: S,
518
- params: (_ == null ? void 0 : _.params) ?? {},
519
- query: E,
520
- matched: (_ == null ? void 0 : _.pattern) ?? null
557
+ params: (b == null ? void 0 : b.params) ?? {},
558
+ query: _,
559
+ matched: (b == null ? void 0 : b.pattern) ?? null
521
560
  };
522
561
  }
523
- function d(h) {
524
- const y = a(h);
525
- window.history.pushState(null, "", h), i.dispatch("_sync", y);
562
+ function u(d) {
563
+ const E = i(d);
564
+ window.history.pushState(null, "", d), l.dispatch("_sync", E);
526
565
  }
527
- function l(h) {
528
- const y = a(h);
529
- window.history.replaceState(null, "", h), i.dispatch("_sync", y);
566
+ function h(d) {
567
+ const E = i(d);
568
+ window.history.replaceState(null, "", d), l.dispatch("_sync", E);
530
569
  }
531
- function m() {
570
+ function p() {
532
571
  window.history.back();
533
572
  }
534
- function p() {
573
+ function f() {
535
574
  window.history.forward();
536
575
  }
537
- function g() {
538
- const h = a(
576
+ function m() {
577
+ const d = i(
539
578
  window.location.pathname + window.location.search
540
579
  );
541
- i.dispatch("_sync", h);
580
+ l.dispatch("_sync", d);
542
581
  }
543
- window.addEventListener("popstate", g);
544
- function G() {
545
- window.removeEventListener("popstate", g);
582
+ window.addEventListener("popstate", m);
583
+ function x() {
584
+ window.removeEventListener("popstate", m);
546
585
  }
547
- const Q = rt({
548
- _path: i.select((h) => h.path)
549
- })(function(y) {
550
- const { _path: S, path: w, component: E, children: _, ...Y } = y, j = B(S, w);
551
- return j ? E ? I(E, { ...Y, params: j.params }) : (_ == null ? void 0 : _[0]) ?? null : null;
586
+ const Q = ct({
587
+ _path: l.select((d) => d.path)
588
+ })(function(E) {
589
+ const { _path: S, path: w, component: _, children: b, ...Z } = E, U = G(S, w);
590
+ return U ? _ ? W(_, { ...Z, params: U.params }) : (b == null ? void 0 : b[0]) ?? null : null;
552
591
  });
553
- function H(h) {
554
- const { to: y, children: S, ...w } = h;
555
- return I(
592
+ function J(d) {
593
+ const { to: E, children: S, ...w } = d;
594
+ return W(
556
595
  "a",
557
596
  {
558
597
  ...w,
559
- href: y,
560
- onClick: (E) => {
561
- E.metaKey || E.ctrlKey || E.shiftKey || E.button !== 0 || (E.preventDefault(), d(y));
598
+ href: E,
599
+ onClick: (_) => {
600
+ _.metaKey || _.ctrlKey || _.shiftKey || _.button !== 0 || (_.preventDefault(), u(E));
562
601
  }
563
602
  },
564
603
  ...S || []
565
604
  );
566
605
  }
567
- function J(h) {
568
- return l(h.to), null;
606
+ function Y(d) {
607
+ return h(d.to), null;
569
608
  }
570
609
  return {
571
- store: i,
572
- navigate: d,
573
- redirect: l,
574
- back: m,
575
- forward: p,
576
- destroy: G,
610
+ store: l,
611
+ navigate: u,
612
+ redirect: h,
613
+ back: p,
614
+ forward: f,
615
+ destroy: x,
577
616
  Route: Q,
578
- Link: H,
579
- Redirect: J
617
+ Link: J,
618
+ Redirect: Y
580
619
  };
581
620
  }
582
621
  export {
583
- tt as Fragment,
584
- rt as connect,
585
- I as createElement,
586
- dt as createRouter,
587
- nt as createStore,
588
- pt as flushSync,
589
- I as h,
590
- ht as render
622
+ et as Fragment,
623
+ ct as connect,
624
+ W as createElement,
625
+ yt as createRouter,
626
+ st as createStore,
627
+ ht as flushSync,
628
+ W as h,
629
+ dt as render
591
630
  };
592
631
  //# sourceMappingURL=pulse.js.map