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