@shane_il/pulse 0.3.0 → 0.4.0

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,37 +1,37 @@
1
- var st = Object.defineProperty;
2
- var ot = (t, e, s) => e in t ? st(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
- var T = (t, e, s) => ot(t, typeof e != "symbol" ? e + "" : e, s);
4
- const G = Symbol("TEXT_NODE"), rt = Symbol("FRAGMENT");
5
- function $(t) {
1
+ var ot = Object.defineProperty;
2
+ var rt = (t, e, s) => e in t ? ot(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
+ var S = (t, e, s) => rt(t, typeof e != "symbol" ? e + "" : e, s);
4
+ const K = Symbol("TEXT_NODE"), ct = Symbol("FRAGMENT");
5
+ function W(t) {
6
6
  return {
7
- type: G,
7
+ type: K,
8
8
  props: { nodeValue: String(t) },
9
9
  children: [],
10
10
  key: null
11
11
  };
12
12
  }
13
- function ct(t) {
14
- return t == null || typeof t == "boolean" ? null : typeof t == "string" || typeof t == "number" ? $(t) : t;
13
+ function it(t) {
14
+ return t == null || typeof t == "boolean" ? null : typeof t == "string" || typeof t == "number" ? W(t) : t;
15
15
  }
16
- function J(t) {
16
+ function Y(t) {
17
17
  const e = [];
18
18
  for (const s of t)
19
19
  if (Array.isArray(s))
20
- e.push(...J(s));
20
+ e.push(...Y(s));
21
21
  else {
22
- const n = ct(s);
22
+ const n = it(s);
23
23
  n !== null && e.push(n);
24
24
  }
25
25
  return e;
26
26
  }
27
- function K(t, e, ...s) {
27
+ function q(t, e, ...s) {
28
28
  e = e || {};
29
29
  const n = e.key ?? null;
30
30
  e.key !== void 0 && (e = { ...e }, delete e.key);
31
- const r = J(s);
31
+ const r = Y(s);
32
32
  return { type: t, props: e, children: r, key: n };
33
33
  }
34
- function it(t) {
34
+ function lt(t) {
35
35
  let e = t.state;
36
36
  const s = t.actions, n = /* @__PURE__ */ new Set(), r = t.middleware;
37
37
  function o() {
@@ -41,116 +41,146 @@ function it(t) {
41
41
  for (const u of n)
42
42
  u(e);
43
43
  }
44
- function l(u, d) {
45
- const g = s[u];
46
- if (!g)
44
+ function a(u, _) {
45
+ const w = s[u];
46
+ if (!w)
47
47
  throw new Error(`[pulse] Unknown action: "${u}"`);
48
- const b = g(e, d);
49
- b !== e && (e = b, c());
48
+ const y = w(e, _);
49
+ y !== e && (e = y, c());
50
50
  }
51
- function a(u, d) {
51
+ function i(u, _) {
52
52
  if (u === "__devtools_replace__") {
53
- e = d, c();
53
+ e = _, c();
54
54
  return;
55
55
  }
56
- const g = s[u];
57
- if (!g)
56
+ const w = s[u];
57
+ if (!w)
58
58
  throw new Error(`[pulse] Unknown action: "${u}"`);
59
- const b = {
60
- store: h,
59
+ const y = {
60
+ store: d,
61
61
  actionName: u,
62
- payload: d,
62
+ payload: _,
63
63
  prevState: e,
64
64
  nextState: void 0
65
65
  };
66
- let I = 0;
67
- function x() {
68
- if (I < r.length) {
69
- const f = r[I++];
70
- f(b, x);
66
+ let V = 0;
67
+ function R() {
68
+ if (V < r.length) {
69
+ const h = r[V++];
70
+ h(y, R);
71
71
  } else {
72
- const f = g(b.prevState, b.payload);
73
- b.nextState = f, f !== e && (e = f, c());
72
+ const h = w(y.prevState, y.payload);
73
+ y.nextState = h, h !== e && (e = h, c());
74
74
  }
75
75
  }
76
- x();
76
+ R();
77
77
  }
78
- const i = r && r.length > 0 ? a : l;
79
- function p(u) {
78
+ const l = r && r.length > 0 ? i : a;
79
+ function f(u) {
80
80
  return n.add(u), () => {
81
81
  n.delete(u);
82
82
  };
83
83
  }
84
- function y(u) {
85
- return { store: h, selector: u };
84
+ function p(u) {
85
+ return { store: d, selector: u };
86
86
  }
87
- const h = {
87
+ const d = {
88
88
  getState: o,
89
- dispatch: i,
90
- subscribe: p,
91
- select: y
89
+ dispatch: l,
90
+ subscribe: f,
91
+ select: p
92
92
  };
93
- return t.name && (h.name = t.name), h;
93
+ return t.name && (d.name = t.name), d;
94
94
  }
95
95
  let U = !1;
96
- const N = /* @__PURE__ */ new Set();
97
- function at(t) {
98
- N.add(t), U || (U = !0, queueMicrotask(lt));
96
+ const L = /* @__PURE__ */ new Set();
97
+ function X(t) {
98
+ L.add(t), U || (U = !0, queueMicrotask(at));
99
99
  }
100
- function lt() {
101
- const t = [...N];
102
- N.clear(), U = !1;
100
+ function at() {
101
+ const t = [...L];
102
+ L.clear(), U = !1;
103
103
  for (const e of t)
104
104
  e();
105
105
  }
106
106
  function _t() {
107
- const t = [...N];
108
- N.clear(), U = !1;
107
+ const t = [...L];
108
+ L.clear(), U = !1;
109
109
  for (const e of t)
110
110
  e();
111
111
  }
112
- const Y = Symbol("PULSE_CONNECTED"), H = globalThis;
113
- H.__PULSE_HOOKS__ || (H.__PULSE_HOOKS__ = { onMount: null, onUnmount: null });
114
- const M = H.__PULSE_HOOKS__;
112
+ const Z = Symbol("PULSE_CONNECTED"), $ = globalThis;
113
+ $.__PULSE_HOOKS__ || ($.__PULSE_HOOKS__ = { onMount: null, onUnmount: null });
114
+ const x = $.__PULSE_HOOKS__;
115
115
  function ut(t, e) {
116
116
  return function(n) {
117
117
  const r = t || {};
118
118
  function o(c) {
119
- const l = {};
120
- for (const a in r) {
121
- const { store: i, selector: p } = r[a];
122
- l[a] = p(i.getState());
119
+ const a = {};
120
+ for (const i in r) {
121
+ const { store: l, selector: f } = r[i];
122
+ a[i] = f(l.getState());
123
123
  }
124
- return n({ ...l, ...c });
124
+ return n({ ...a, ...c });
125
125
  }
126
- return o[Y] = !0, o._bindings = r, o._innerComponent = n, e && (o._lifecycle = e), o.displayName = `Connected(${n.displayName || n.name || "Anonymous"})`, o;
126
+ return o[Z] = !0, o._bindings = r, o._innerComponent = n, e && (o._lifecycle = e), o.displayName = `Connected(${n.displayName || n.name || "Anonymous"})`, o;
127
127
  };
128
128
  }
129
129
  class ft {
130
130
  constructor(e, s) {
131
- T(this, "connectedFn");
132
- T(this, "props");
133
- T(this, "prevSelected");
134
- T(this, "unsubscribers");
135
- T(this, "lastVTree");
136
- T(this, "parentDom");
137
- T(this, "_renderCallback");
138
- T(this, "_mountCleanup");
139
- this.connectedFn = e, this.props = s, this.prevSelected = {}, this.unsubscribers = [], this.lastVTree = null, this.parentDom = null, this._renderCallback = null, this._mountCleanup = null;
131
+ S(this, "connectedFn");
132
+ S(this, "props");
133
+ S(this, "prevSelected");
134
+ S(this, "unsubscribers");
135
+ S(this, "lastVTree");
136
+ S(this, "parentDom");
137
+ S(this, "_renderCallback");
138
+ S(this, "_mountCleanup");
139
+ S(this, "_localState");
140
+ S(this, "_localActions");
141
+ this.connectedFn = e, this.props = s, this.prevSelected = {}, this.unsubscribers = [], this.lastVTree = null, this.parentDom = null, this._renderCallback = null, this._mountCleanup = null, this._localState = null, this._localActions = null;
142
+ const n = e._lifecycle;
143
+ n != null && n.store && this._initLocalStore(n.store);
144
+ }
145
+ _initLocalStore(e) {
146
+ this._localState = { ...e.state }, this._localActions = e.actions;
147
+ const s = this.connectedFn._bindings, n = this.connectedFn.displayName || "component", r = Object.keys(this._localState), o = Object.keys(this._localActions);
148
+ for (const c of r)
149
+ c in s && console.warn(
150
+ `[pulse] Local store state "${c}" shadows global binding in ${n}. Local value will be used.`
151
+ );
152
+ for (const c of o)
153
+ c in s && console.warn(
154
+ `[pulse] Local store action "${c}" shadows global binding in ${n}. Local value will be used.`
155
+ ), c in this._localState && console.warn(
156
+ `[pulse] Local store action "${c}" shadows state key with same name in ${n}.`
157
+ );
158
+ }
159
+ getLocalProps() {
160
+ if (!this._localState) return null;
161
+ const e = { ...this._localState };
162
+ for (const s in this._localActions) {
163
+ const n = this._localActions[s];
164
+ e[s] = (r) => {
165
+ const o = n(this._localState, r);
166
+ o !== this._localState && (this._localState = o, this._renderCallback && X(this._renderCallback));
167
+ };
168
+ }
169
+ return e;
140
170
  }
141
171
  mount(e, s) {
142
172
  var o;
143
173
  this.parentDom = e, this._renderCallback = s;
144
174
  const n = this.connectedFn._bindings;
145
175
  for (const c in n) {
146
- const { store: l, selector: a } = n[c];
147
- this.prevSelected[c] = a(l.getState());
176
+ const { store: a, selector: i } = n[c];
177
+ this.prevSelected[c] = i(a.getState());
148
178
  }
149
179
  for (const c in n) {
150
- const { store: l } = n[c], a = l.subscribe(() => {
180
+ const { store: a } = n[c], i = a.subscribe(() => {
151
181
  this._onStoreChange();
152
182
  });
153
- this.unsubscribers.push(a);
183
+ this.unsubscribers.push(i);
154
184
  }
155
185
  const r = this.connectedFn._lifecycle;
156
186
  if (r != null && r.onMount) {
@@ -160,7 +190,7 @@ class ft {
160
190
  });
161
191
  typeof c == "function" && (this._mountCleanup = c);
162
192
  }
163
- M.onMount && M.onMount(this);
193
+ x.onMount && x.onMount(this);
164
194
  }
165
195
  _onStoreChange() {
166
196
  const e = this.connectedFn._bindings;
@@ -172,7 +202,7 @@ class ft {
172
202
  break;
173
203
  }
174
204
  }
175
- s && at(this._renderCallback);
205
+ s && X(this._renderCallback);
176
206
  }
177
207
  updateSelected() {
178
208
  const e = this.connectedFn._bindings;
@@ -182,7 +212,7 @@ class ft {
182
212
  }
183
213
  }
184
214
  unmount() {
185
- M.onUnmount && M.onUnmount(this), this._mountCleanup && (this._mountCleanup(), this._mountCleanup = null);
215
+ x.onUnmount && x.onUnmount(this), this._mountCleanup && (this._mountCleanup(), this._mountCleanup = null);
186
216
  const e = this.connectedFn._lifecycle;
187
217
  e != null && e.onDestroy && e.onDestroy({ props: this.props });
188
218
  for (const s of this.unsubscribers)
@@ -209,13 +239,13 @@ const m = {
209
239
  MOVE: "MOVE",
210
240
  CHILDREN: "CHILDREN"
211
241
  };
212
- function w(t, e) {
242
+ function T(t, e) {
213
243
  if (e == null && t == null) return [];
214
244
  if (e == null) return [{ type: m.REMOVE, target: t }];
215
245
  if (t == null) return [{ type: m.CREATE, newVNode: e }];
216
246
  if (t.type !== e.type)
217
247
  return [{ type: m.REPLACE, oldVNode: t, newVNode: e }];
218
- if (e._dom = t._dom, t.type === G)
248
+ if (e._dom = t._dom, t.type === K)
219
249
  return t.props.nodeValue !== e.props.nodeValue ? [{ type: m.TEXT, oldVNode: t, newVNode: e }] : [];
220
250
  const s = [], n = ht(t.props, e.props);
221
251
  n && s.push({ type: m.UPDATE, target: t, propPatches: n });
@@ -231,10 +261,10 @@ function ht(t, e) {
231
261
  o !== "children" && (o in e || (n.push(o), r = !0));
232
262
  return r ? { set: s, remove: n } : null;
233
263
  }
234
- function P(t, e) {
264
+ function C(t, e) {
235
265
  return t == null || e == null ? !1 : t.type === e.type && t.key === e.key;
236
266
  }
237
- function X(t, e) {
267
+ function z(t, e) {
238
268
  const s = /* @__PURE__ */ new Set();
239
269
  let n = 0, r = 0;
240
270
  for (const o of t)
@@ -246,61 +276,61 @@ function X(t, e) {
246
276
  );
247
277
  }
248
278
  function dt(t, e) {
249
- var y;
250
- process.env.NODE_ENV !== "production" && (X(t, "old"), X(e, "new"));
279
+ var p;
280
+ process.env.NODE_ENV !== "production" && (z(t, "old"), z(e, "new"));
251
281
  const s = [];
252
- let n = 0, r = t.length - 1, o = 0, c = e.length - 1, l = t[n], a = t[r], i = e[o], p = e[c];
282
+ let n = 0, r = t.length - 1, o = 0, c = e.length - 1, a = t[n], i = t[r], l = e[o], f = e[c];
253
283
  for (; n <= r && o <= c; ) {
254
- if (l == null) {
255
- l = t[++n];
284
+ if (a == null) {
285
+ a = t[++n];
256
286
  continue;
257
287
  }
258
- if (a == null) {
259
- a = t[--r];
288
+ if (i == null) {
289
+ i = t[--r];
260
290
  continue;
261
291
  }
262
- if (P(l, i))
263
- s.push(...w(l, i)), l = t[++n], i = e[++o];
264
- else if (P(a, p))
265
- s.push(...w(a, p)), a = t[--r], p = e[--c];
266
- else if (P(l, p))
292
+ if (C(a, l))
293
+ s.push(...T(a, l)), a = t[++n], l = e[++o];
294
+ else if (C(i, f))
295
+ s.push(...T(i, f)), i = t[--r], f = e[--c];
296
+ else if (C(a, f))
267
297
  s.push({
268
298
  type: m.MOVE,
269
- vnode: l,
299
+ vnode: a,
270
300
  anchor: t[r + 1] || null,
271
- childPatches: w(l, p)
272
- }), l = t[++n], p = e[--c];
273
- else if (P(a, i))
301
+ childPatches: T(a, f)
302
+ }), a = t[++n], f = e[--c];
303
+ else if (C(i, l))
274
304
  s.push({
275
305
  type: m.MOVE,
276
- vnode: a,
277
- anchor: l,
278
- childPatches: w(a, i)
279
- }), a = t[--r], i = e[++o];
306
+ vnode: i,
307
+ anchor: a,
308
+ childPatches: T(i, l)
309
+ }), i = t[--r], l = e[++o];
280
310
  else
281
311
  break;
282
312
  }
283
313
  if (n <= r && o <= c) {
284
- const h = /* @__PURE__ */ new Map();
314
+ const d = /* @__PURE__ */ new Map();
285
315
  for (let u = n; u <= r; u++) {
286
- const d = (y = t[u]) == null ? void 0 : y.key;
287
- d != null && h.set(d, u);
316
+ const _ = (p = t[u]) == null ? void 0 : p.key;
317
+ _ != null && d.set(_, u);
288
318
  }
289
319
  for (; o <= c; ) {
290
- i = e[o];
291
- const u = i.key != null ? h.get(i.key) : void 0;
320
+ l = e[o];
321
+ const u = l.key != null ? d.get(l.key) : void 0;
292
322
  if (u !== void 0) {
293
- const d = t[u];
323
+ const _ = t[u];
294
324
  s.push({
295
325
  type: m.MOVE,
296
- vnode: d,
326
+ vnode: _,
297
327
  anchor: t[n] || null,
298
- childPatches: w(d, i)
299
- }), t[u] = null, h.delete(i.key);
328
+ childPatches: T(_, l)
329
+ }), t[u] = null, d.delete(l.key);
300
330
  } else
301
331
  s.push({
302
332
  type: m.CREATE,
303
- newVNode: i,
333
+ newVNode: l,
304
334
  anchor: t[n] || null
305
335
  });
306
336
  o++;
@@ -309,40 +339,40 @@ function dt(t, e) {
309
339
  t[u] != null && s.push({ type: m.REMOVE, target: t[u] });
310
340
  }
311
341
  if (n > r) {
312
- const h = e[c + 1] || null;
342
+ const d = e[c + 1] || null;
313
343
  for (let u = o; u <= c; u++)
314
- s.push({ type: m.CREATE, newVNode: e[u], anchor: h });
344
+ s.push({ type: m.CREATE, newVNode: e[u], anchor: d });
315
345
  } else if (o > c)
316
- for (let h = n; h <= r; h++)
317
- t[h] != null && s.push({ type: m.REMOVE, target: t[h] });
346
+ for (let d = n; d <= r; d++)
347
+ t[d] != null && s.push({ type: m.REMOVE, target: t[d] });
318
348
  return s;
319
349
  }
320
- const Z = "http://www.w3.org/2000/svg";
321
- function A(t, e) {
322
- if (t.type === G) {
350
+ const v = "http://www.w3.org/2000/svg";
351
+ function N(t, e) {
352
+ if (t.type === K) {
323
353
  const n = document.createTextNode(t.props.nodeValue);
324
354
  return t._dom = n, n;
325
355
  }
326
- if (t.type === rt) {
356
+ if (t.type === ct) {
327
357
  const n = document.createDocumentFragment();
328
358
  for (const r of t.children)
329
- n.appendChild(A(r, e));
359
+ n.appendChild(N(r, e));
330
360
  return t._dom = n, n;
331
361
  }
332
- t.type === "svg" ? e = Z : t.type === "foreignObject" && (e = void 0);
362
+ t.type === "svg" ? e = v : t.type === "foreignObject" && (e = void 0);
333
363
  const s = e ? document.createElementNS(e, t.type) : document.createElement(t.type);
334
364
  mt(s, {}, t.props);
335
365
  for (const n of t.children)
336
- s.appendChild(A(n, e));
366
+ s.appendChild(N(n, e));
337
367
  return t._dom = s, s;
338
368
  }
339
369
  function mt(t, e, s) {
340
370
  for (const n in e)
341
- n === "children" || n === "key" || n in s || tt(t, n, e[n]);
371
+ n === "children" || n === "key" || n in s || et(t, n, e[n]);
342
372
  for (const n in s)
343
- n === "children" || n === "key" || e[n] !== s[n] && v(t, n, s[n], e[n]);
373
+ n === "children" || n === "key" || e[n] !== s[n] && tt(t, n, s[n], e[n]);
344
374
  }
345
- function v(t, e, s, n) {
375
+ function tt(t, e, s, n) {
346
376
  if (e.startsWith("on")) {
347
377
  const r = e.slice(2).toLowerCase();
348
378
  n && t.removeEventListener(r, n), s && t.addEventListener(r, s);
@@ -365,7 +395,7 @@ function v(t, e, s, n) {
365
395
  }
366
396
  else s === !0 ? t.setAttribute(e, "") : s === !1 || s == null ? t.removeAttribute(e) : t.setAttribute(e, s);
367
397
  }
368
- function tt(t, e, s) {
398
+ function et(t, e, s) {
369
399
  if (e.startsWith("on"))
370
400
  t.removeEventListener(e.slice(2).toLowerCase(), s);
371
401
  else if (e === "dangerouslySetInnerHTML")
@@ -381,15 +411,15 @@ function tt(t, e, s) {
381
411
  else
382
412
  t.removeAttribute(e);
383
413
  }
384
- function z(t) {
385
- return t instanceof SVGElement ? Z : void 0;
414
+ function B(t) {
415
+ return t instanceof SVGElement ? v : void 0;
386
416
  }
387
- function R(t, e) {
417
+ function P(t, e) {
388
418
  var s, n, r;
389
419
  for (const o of e)
390
420
  switch (o.type) {
391
421
  case m.CREATE: {
392
- const c = A(o.newVNode, z(t));
422
+ const c = N(o.newVNode, B(t));
393
423
  (s = o.anchor) != null && s._dom ? t.insertBefore(c, o.anchor._dom) : t.appendChild(c);
394
424
  break;
395
425
  }
@@ -399,19 +429,19 @@ function R(t, e) {
399
429
  break;
400
430
  }
401
431
  case m.REPLACE: {
402
- const c = o.oldVNode._dom, l = c == null ? void 0 : c.parentNode, a = A(
432
+ const c = o.oldVNode._dom, a = c == null ? void 0 : c.parentNode, i = N(
403
433
  o.newVNode,
404
- l ? z(l) : void 0
434
+ a ? B(a) : void 0
405
435
  );
406
- l && l.replaceChild(a, c);
436
+ a && a.replaceChild(i, c);
407
437
  break;
408
438
  }
409
439
  case m.UPDATE: {
410
- const c = o.target._dom, { set: l, remove: a } = o.propPatches;
411
- for (const i of a)
412
- tt(c, i, o.target.props[i]);
413
- for (const i in l)
414
- v(c, i, l[i], o.target.props[i]);
440
+ const c = o.target._dom, { set: a, remove: i } = o.propPatches;
441
+ for (const l of i)
442
+ et(c, l, o.target.props[l]);
443
+ for (const l in a)
444
+ tt(c, l, a[l], o.target.props[l]);
415
445
  break;
416
446
  }
417
447
  case m.TEXT: {
@@ -421,12 +451,12 @@ function R(t, e) {
421
451
  }
422
452
  case m.MOVE: {
423
453
  const c = o.vnode._dom;
424
- c && ((n = o.anchor) != null && n._dom ? t.insertBefore(c, o.anchor._dom) : t.appendChild(c)), (r = o.childPatches) != null && r.length && c && R(c, o.childPatches);
454
+ c && ((n = o.anchor) != null && n._dom ? t.insertBefore(c, o.anchor._dom) : t.appendChild(c)), (r = o.childPatches) != null && r.length && c && P(c, o.childPatches);
425
455
  break;
426
456
  }
427
457
  case m.CHILDREN: {
428
458
  const c = o.parent._dom;
429
- c && o.childPatches.length && R(c, o.childPatches);
459
+ c && o.childPatches.length && P(c, o.childPatches);
430
460
  break;
431
461
  }
432
462
  }
@@ -436,27 +466,27 @@ function Et(t, e) {
436
466
  const s = F.get(e);
437
467
  if (s) {
438
468
  const n = k(t, e), r = [];
439
- C(s.vTree, r);
440
- const o = w(s.vTree, n);
441
- R(e, o);
469
+ I(s.vTree, r);
470
+ const o = T(s.vTree, n);
471
+ P(e, o);
442
472
  const c = [];
443
- n && C(n, c);
444
- const l = new Set(c);
445
- for (const i of r)
446
- l.has(i) || i.unmount();
447
- const a = new Set(r);
448
- for (const i of c)
449
- a.has(i) || i.mount(e, () => D(i, e));
473
+ n && I(n, c);
474
+ const a = new Set(c);
475
+ for (const l of r)
476
+ a.has(l) || l.unmount();
477
+ const i = new Set(r);
478
+ for (const l of c)
479
+ i.has(l) || l.mount(e, () => H(l, e));
450
480
  F.set(e, { vTree: n });
451
481
  } else {
452
482
  const n = k(t, e);
453
483
  if (!n) return;
454
- const r = A(n);
484
+ const r = N(n);
455
485
  e.appendChild(r);
456
486
  const o = [];
457
- C(n, o);
487
+ I(n, o);
458
488
  for (const c of o)
459
- c.mount(e, () => D(c, e));
489
+ c.mount(e, () => H(c, e));
460
490
  F.set(e, { vTree: n });
461
491
  }
462
492
  }
@@ -464,20 +494,20 @@ function k(t, e) {
464
494
  var s;
465
495
  if (t == null) return null;
466
496
  if (typeof t.type == "function") {
467
- if (t.type[Y]) {
497
+ if (t.type[Z]) {
468
498
  const r = t.type._lifecycle;
469
499
  try {
470
- const o = new ft(t.type, t.props), c = t.type(t.props), a = k(c, e) ?? $("");
471
- if (a._instance) {
472
- const i = {
500
+ const o = new ft(t.type, t.props), c = o.getLocalProps(), a = c ? { ...t.props, ...c } : t.props, i = t.type(a), f = k(i, e) ?? W("");
501
+ if (f._instance) {
502
+ const p = {
473
503
  type: "div",
474
504
  props: { style: { display: "contents" } },
475
- children: [a],
505
+ children: [f],
476
506
  key: t.key
477
507
  };
478
- return i._instance = o, o.lastVTree = i, i;
508
+ return p._instance = o, o.lastVTree = p, p;
479
509
  }
480
- return a._instance = o, o.lastVTree = a, a;
510
+ return f._instance = o, o.lastVTree = f, f;
481
511
  } catch (o) {
482
512
  if (r != null && r.onError) {
483
513
  const c = r.onError({
@@ -494,75 +524,75 @@ function k(t, e) {
494
524
  }
495
525
  return (s = t.children) != null && s.length && (t.children = t.children.map((n) => k(n, e)).filter((n) => n != null)), t;
496
526
  }
497
- function D(t, e) {
527
+ function H(t, e) {
498
528
  var r, o;
499
529
  if (!t._renderCallback) return;
500
530
  const s = t.connectedFn, n = s._lifecycle;
501
531
  try {
502
- const c = s(t.props), a = k(c, e) ?? $("");
503
- let i;
504
- if (a._instance && a._instance !== t ? (i = {
532
+ const c = t.getLocalProps(), a = c ? { ...t.props, ...c } : t.props, i = s(a), f = k(i, e) ?? W("");
533
+ let p;
534
+ if (f._instance && f._instance !== t ? (p = {
505
535
  type: "div",
506
536
  props: { style: { display: "contents" } },
507
- children: [a],
537
+ children: [f],
508
538
  key: null
509
- }, i._instance = t) : (a._instance = t, i = a), t.lastVTree) {
510
- W(t.lastVTree, t);
511
- const d = w(t.lastVTree, i), g = ((r = t.lastVTree._dom) == null ? void 0 : r.parentNode) || e;
512
- R(g, d), i._dom || (i._dom = t.lastVTree._dom);
539
+ }, p._instance = t) : (f._instance = t, p = f), t.lastVTree) {
540
+ D(t.lastVTree, t);
541
+ const y = T(t.lastVTree, p), V = ((r = t.lastVTree._dom) == null ? void 0 : r.parentNode) || e;
542
+ P(V, y), p._dom || (p._dom = t.lastVTree._dom);
513
543
  }
514
- const p = [];
515
- L(t.lastVTree, p, t);
516
- const y = [];
517
- L(i, y, t);
518
- const h = new Set(y);
519
- for (const d of p)
520
- h.has(d) || d.unmount();
521
- t.lastVTree = i;
522
- const u = new Set(p);
523
- for (const d of y)
524
- u.has(d) || d.mount(e, () => D(d, e));
544
+ const d = [];
545
+ M(t.lastVTree, d, t);
546
+ const u = [];
547
+ M(p, u, t);
548
+ const _ = new Set(u);
549
+ for (const y of d)
550
+ _.has(y) || y.unmount();
551
+ t.lastVTree = p;
552
+ const w = new Set(d);
553
+ for (const y of u)
554
+ w.has(y) || y.mount(e, () => H(y, e));
525
555
  n != null && n.onUpdate && n.onUpdate({
526
- dom: i == null ? void 0 : i._dom,
556
+ dom: p == null ? void 0 : p._dom,
527
557
  props: t.props
528
558
  }), t.updateSelected();
529
559
  } catch (c) {
530
560
  if (n != null && n.onError) {
531
- const l = n.onError({ error: c, props: t.props }), a = k(l, e);
532
- if (t.lastVTree && a) {
533
- W(t.lastVTree, t);
534
- const p = w(t.lastVTree, a), y = ((o = t.lastVTree._dom) == null ? void 0 : o.parentNode) || e;
535
- R(y, p), a._dom || (a._dom = t.lastVTree._dom);
561
+ const a = n.onError({ error: c, props: t.props }), i = k(a, e);
562
+ if (t.lastVTree && i) {
563
+ D(t.lastVTree, t);
564
+ const f = T(t.lastVTree, i), p = ((o = t.lastVTree._dom) == null ? void 0 : o.parentNode) || e;
565
+ P(p, f), i._dom || (i._dom = t.lastVTree._dom);
536
566
  }
537
- const i = [];
538
- L(t.lastVTree, i, t);
539
- for (const p of i) p.unmount();
540
- t.lastVTree = a, t.updateSelected();
567
+ const l = [];
568
+ M(t.lastVTree, l, t);
569
+ for (const f of l) f.unmount();
570
+ t.lastVTree = i, t.updateSelected();
541
571
  } else
542
572
  throw c;
543
573
  }
544
574
  }
545
- function W(t, e) {
575
+ function D(t, e) {
546
576
  if (!(!t || !t.children))
547
577
  for (let s = 0; s < t.children.length; s++) {
548
578
  const n = t.children[s];
549
- n._instance && n._instance !== e && n._instance.lastVTree && n._instance.lastVTree !== n && (t.children[s] = n._instance.lastVTree), W(t.children[s], e);
579
+ n._instance && n._instance !== e && n._instance.lastVTree && n._instance.lastVTree !== n && (t.children[s] = n._instance.lastVTree), D(t.children[s], e);
550
580
  }
551
581
  }
552
- function C(t, e) {
582
+ function I(t, e) {
553
583
  if (t && (t._instance && e.push(t._instance), t.children))
554
584
  for (const s of t.children)
555
- C(s, e);
585
+ I(s, e);
556
586
  }
557
- function L(t, e, s) {
587
+ function M(t, e, s) {
558
588
  if (t && (t._instance && t._instance !== s && e.push(t._instance), t.children))
559
589
  for (const n of t.children)
560
- L(n, e, s);
590
+ M(n, e, s);
561
591
  }
562
592
  function j(t) {
563
593
  return t.length > 1 && t.endsWith("/") ? t.slice(0, -1) : t || "/";
564
594
  }
565
- function B(t) {
595
+ function Q(t) {
566
596
  const e = {};
567
597
  if (!t) return e;
568
598
  const s = t.startsWith("?") ? t.slice(1) : t;
@@ -570,131 +600,131 @@ function B(t) {
570
600
  e[o] = r;
571
601
  }), e;
572
602
  }
573
- function et(t, e) {
603
+ function nt(t, e) {
574
604
  const s = j(t), n = j(e);
575
605
  if (n === "*")
576
606
  return { params: { "*": s } };
577
607
  const r = s === "/" ? [""] : s.split("/").slice(1), o = n === "/" ? [""] : n.split("/").slice(1);
578
608
  if (o.length > 0 && o[o.length - 1] === "*") {
579
- const a = o.slice(0, -1);
580
- if (r.length < a.length) return null;
581
- const i = {};
582
- for (let y = 0; y < a.length; y++) {
583
- const h = a[y];
584
- if (h.startsWith(":"))
585
- i[h.slice(1)] = r[y];
586
- else if (h !== r[y])
609
+ const i = o.slice(0, -1);
610
+ if (r.length < i.length) return null;
611
+ const l = {};
612
+ for (let p = 0; p < i.length; p++) {
613
+ const d = i[p];
614
+ if (d.startsWith(":"))
615
+ l[d.slice(1)] = r[p];
616
+ else if (d !== r[p])
587
617
  return null;
588
618
  }
589
- const p = r.slice(a.length).join("/");
590
- return i["*"] = p, { params: i };
619
+ const f = r.slice(i.length).join("/");
620
+ return l["*"] = f, { params: l };
591
621
  }
592
622
  if (r.length !== o.length) return null;
593
- const l = {};
594
- for (let a = 0; a < o.length; a++) {
595
- const i = o[a];
596
- if (i.startsWith(":"))
597
- l[i.slice(1)] = r[a];
598
- else if (i !== r[a])
623
+ const a = {};
624
+ for (let i = 0; i < o.length; i++) {
625
+ const l = o[i];
626
+ if (l.startsWith(":"))
627
+ a[l.slice(1)] = r[i];
628
+ else if (l !== r[i])
599
629
  return null;
600
630
  }
601
- return { params: l };
631
+ return { params: a };
602
632
  }
603
- function Q(t, e) {
633
+ function J(t, e) {
604
634
  for (const s of e) {
605
- const n = et(t, s.path);
635
+ const n = nt(t, s.path);
606
636
  if (n)
607
637
  return { pattern: s.path, params: n.params };
608
638
  }
609
639
  return null;
610
640
  }
611
641
  function St(t) {
612
- const { routes: e, initialPath: s } = t, n = s ?? window.location.pathname, r = s ? "" : window.location.search, o = j(n), c = B(r), l = Q(o, e), a = it({
642
+ const { routes: e, initialPath: s } = t, n = s ?? window.location.pathname, r = s ? "" : window.location.search, o = j(n), c = Q(r), a = J(o, e), i = lt({
613
643
  state: {
614
644
  path: o,
615
- params: (l == null ? void 0 : l.params) ?? {},
645
+ params: (a == null ? void 0 : a.params) ?? {},
616
646
  query: c,
617
- matched: (l == null ? void 0 : l.pattern) ?? null
647
+ matched: (a == null ? void 0 : a.pattern) ?? null
618
648
  },
619
649
  actions: {
620
- _sync: (f, _) => _
650
+ _sync: (h, E) => E
621
651
  }
622
652
  });
623
- function i(f) {
624
- const _ = f.indexOf("?"), V = j(
625
- _ >= 0 ? f.slice(0, _) : f
626
- ), O = _ >= 0 ? f.slice(_ + 1) : "", E = B(O), S = Q(V, e);
653
+ function l(h) {
654
+ const E = h.indexOf("?"), A = j(
655
+ E >= 0 ? h.slice(0, E) : h
656
+ ), O = E >= 0 ? h.slice(E + 1) : "", b = Q(O), g = J(A, e);
627
657
  return {
628
- path: V,
629
- params: (S == null ? void 0 : S.params) ?? {},
630
- query: E,
631
- matched: (S == null ? void 0 : S.pattern) ?? null
658
+ path: A,
659
+ params: (g == null ? void 0 : g.params) ?? {},
660
+ query: b,
661
+ matched: (g == null ? void 0 : g.pattern) ?? null
632
662
  };
633
663
  }
634
- function p(f) {
635
- const _ = i(f);
636
- window.history.pushState(null, "", f), a.dispatch("_sync", _);
664
+ function f(h) {
665
+ const E = l(h);
666
+ window.history.pushState(null, "", h), i.dispatch("_sync", E);
637
667
  }
638
- function y(f) {
639
- const _ = i(f);
640
- window.history.replaceState(null, "", f), a.dispatch("_sync", _);
668
+ function p(h) {
669
+ const E = l(h);
670
+ window.history.replaceState(null, "", h), i.dispatch("_sync", E);
641
671
  }
642
- function h() {
672
+ function d() {
643
673
  window.history.back();
644
674
  }
645
675
  function u() {
646
676
  window.history.forward();
647
677
  }
648
- function d() {
649
- const f = i(window.location.pathname + window.location.search);
650
- a.dispatch("_sync", f);
651
- }
652
- window.addEventListener("popstate", d);
653
- function g() {
654
- window.removeEventListener("popstate", d);
655
- }
656
- const b = ut({
657
- _path: a.select((f) => f.path)
658
- })(function(_) {
659
- const { _path: V, path: O, component: E, children: S, ...nt } = _, q = et(V, O);
660
- return q ? E ? K(E, { ...nt, params: q.params }) : (S == null ? void 0 : S[0]) ?? null : null;
678
+ function _() {
679
+ const h = l(window.location.pathname + window.location.search);
680
+ i.dispatch("_sync", h);
681
+ }
682
+ window.addEventListener("popstate", _);
683
+ function w() {
684
+ window.removeEventListener("popstate", _);
685
+ }
686
+ const y = ut({
687
+ _path: i.select((h) => h.path)
688
+ })(function(E) {
689
+ const { _path: A, path: O, component: b, children: g, ...st } = E, G = nt(A, O);
690
+ return G ? b ? q(b, { ...st, params: G.params }) : (g == null ? void 0 : g[0]) ?? null : null;
661
691
  });
662
- function I(f) {
663
- const { to: _, children: V, ...O } = f;
664
- return K(
692
+ function V(h) {
693
+ const { to: E, children: A, ...O } = h;
694
+ return q(
665
695
  "a",
666
696
  {
667
697
  ...O,
668
- href: _,
669
- onClick: (E) => {
670
- E.metaKey || E.ctrlKey || E.shiftKey || E.button !== 0 || (E.preventDefault(), p(_));
698
+ href: E,
699
+ onClick: (b) => {
700
+ b.metaKey || b.ctrlKey || b.shiftKey || b.button !== 0 || (b.preventDefault(), f(E));
671
701
  }
672
702
  },
673
- ...V || []
703
+ ...A || []
674
704
  );
675
705
  }
676
- function x(f) {
677
- return y(f.to), null;
706
+ function R(h) {
707
+ return p(h.to), null;
678
708
  }
679
709
  return {
680
- store: a,
681
- navigate: p,
682
- redirect: y,
683
- back: h,
710
+ store: i,
711
+ navigate: f,
712
+ redirect: p,
713
+ back: d,
684
714
  forward: u,
685
- destroy: g,
686
- Route: b,
687
- Link: I,
688
- Redirect: x
715
+ destroy: w,
716
+ Route: y,
717
+ Link: V,
718
+ Redirect: R
689
719
  };
690
720
  }
691
- function gt() {
721
+ function bt() {
692
722
  return (t, e) => {
693
723
  const s = `[pulse] ${t.actionName}`;
694
724
  console.group(s), console.log("prev state", t.prevState), console.log("payload", t.payload), e(), console.log("next state", t.nextState), console.groupEnd();
695
725
  };
696
726
  }
697
- function bt(t, e) {
727
+ function gt(t, e) {
698
728
  return async (...s) => {
699
729
  e.start && t.dispatch(e.start);
700
730
  try {
@@ -709,7 +739,7 @@ function bt(t, e) {
709
739
  }
710
740
  };
711
741
  }
712
- function Tt(t, e) {
742
+ function wt(t, e) {
713
743
  const s = (e == null ? void 0 : e.maxEntries) ?? 1 / 0;
714
744
  return (n, r) => {
715
745
  r(), t.push({
@@ -722,16 +752,16 @@ function Tt(t, e) {
722
752
  };
723
753
  }
724
754
  export {
725
- rt as Fragment,
726
- Tt as actionHistory,
755
+ ct as Fragment,
756
+ wt as actionHistory,
727
757
  ut as connect,
728
- bt as createAsyncAction,
729
- K as createElement,
758
+ gt as createAsyncAction,
759
+ q as createElement,
730
760
  St as createRouter,
731
- it as createStore,
761
+ lt as createStore,
732
762
  _t as flushSync,
733
- K as h,
734
- gt as logger,
763
+ q as h,
764
+ bt as logger,
735
765
  Et as render
736
766
  };
737
767
  //# sourceMappingURL=pulse.js.map