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