@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/README.md +2 -2
- package/dist/connect.d.ts +5 -1
- package/dist/devtools.cjs +1 -1
- package/dist/devtools.cjs.map +1 -1
- package/dist/devtools.js +367 -337
- package/dist/devtools.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/pulse.cjs +1 -1
- package/dist/pulse.cjs.map +1 -1
- package/dist/pulse.js +305 -275
- package/dist/pulse.js.map +1 -1
- package/dist/vnode.d.ts +7 -0
- package/package.json +1 -1
package/dist/pulse.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
const
|
|
5
|
-
function
|
|
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:
|
|
7
|
+
type: K,
|
|
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 it(t) {
|
|
14
|
+
return t == null || typeof t == "boolean" ? null : typeof t == "string" || typeof t == "number" ? W(t) : t;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function Y(t) {
|
|
17
17
|
const e = [];
|
|
18
18
|
for (const s of t)
|
|
19
19
|
if (Array.isArray(s))
|
|
20
|
-
e.push(...
|
|
20
|
+
e.push(...Y(s));
|
|
21
21
|
else {
|
|
22
|
-
const n =
|
|
22
|
+
const n = it(s);
|
|
23
23
|
n !== null && e.push(n);
|
|
24
24
|
}
|
|
25
25
|
return e;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
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 =
|
|
31
|
+
const r = Y(s);
|
|
32
32
|
return { type: t, props: e, children: r, key: n };
|
|
33
33
|
}
|
|
34
|
-
function
|
|
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
|
|
45
|
-
const
|
|
46
|
-
if (!
|
|
44
|
+
function a(u, _) {
|
|
45
|
+
const w = s[u];
|
|
46
|
+
if (!w)
|
|
47
47
|
throw new Error(`[pulse] Unknown action: "${u}"`);
|
|
48
|
-
const
|
|
49
|
-
|
|
48
|
+
const y = w(e, _);
|
|
49
|
+
y !== e && (e = y, c());
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function i(u, _) {
|
|
52
52
|
if (u === "__devtools_replace__") {
|
|
53
|
-
e =
|
|
53
|
+
e = _, c();
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
const
|
|
57
|
-
if (!
|
|
56
|
+
const w = s[u];
|
|
57
|
+
if (!w)
|
|
58
58
|
throw new Error(`[pulse] Unknown action: "${u}"`);
|
|
59
|
-
const
|
|
60
|
-
store:
|
|
59
|
+
const y = {
|
|
60
|
+
store: d,
|
|
61
61
|
actionName: u,
|
|
62
|
-
payload:
|
|
62
|
+
payload: _,
|
|
63
63
|
prevState: e,
|
|
64
64
|
nextState: void 0
|
|
65
65
|
};
|
|
66
|
-
let
|
|
67
|
-
function
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
|
|
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
|
|
73
|
-
|
|
72
|
+
const h = w(y.prevState, y.payload);
|
|
73
|
+
y.nextState = h, h !== e && (e = h, c());
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
R();
|
|
77
77
|
}
|
|
78
|
-
const
|
|
79
|
-
function
|
|
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
|
|
85
|
-
return { store:
|
|
84
|
+
function p(u) {
|
|
85
|
+
return { store: d, selector: u };
|
|
86
86
|
}
|
|
87
|
-
const
|
|
87
|
+
const d = {
|
|
88
88
|
getState: o,
|
|
89
|
-
dispatch:
|
|
90
|
-
subscribe:
|
|
91
|
-
select:
|
|
89
|
+
dispatch: l,
|
|
90
|
+
subscribe: f,
|
|
91
|
+
select: p
|
|
92
92
|
};
|
|
93
|
-
return t.name && (
|
|
93
|
+
return t.name && (d.name = t.name), d;
|
|
94
94
|
}
|
|
95
95
|
let U = !1;
|
|
96
|
-
const
|
|
97
|
-
function
|
|
98
|
-
|
|
96
|
+
const L = /* @__PURE__ */ new Set();
|
|
97
|
+
function X(t) {
|
|
98
|
+
L.add(t), U || (U = !0, queueMicrotask(at));
|
|
99
99
|
}
|
|
100
|
-
function
|
|
101
|
-
const t = [...
|
|
102
|
-
|
|
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 = [...
|
|
108
|
-
|
|
107
|
+
const t = [...L];
|
|
108
|
+
L.clear(), U = !1;
|
|
109
109
|
for (const e of t)
|
|
110
110
|
e();
|
|
111
111
|
}
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
const
|
|
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
|
|
120
|
-
for (const
|
|
121
|
-
const { store:
|
|
122
|
-
|
|
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({ ...
|
|
124
|
+
return n({ ...a, ...c });
|
|
125
125
|
}
|
|
126
|
-
return 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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
this
|
|
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:
|
|
147
|
-
this.prevSelected[c] = a
|
|
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:
|
|
180
|
+
const { store: a } = n[c], i = a.subscribe(() => {
|
|
151
181
|
this._onStoreChange();
|
|
152
182
|
});
|
|
153
|
-
this.unsubscribers.push(
|
|
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
|
-
|
|
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 &&
|
|
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
|
-
|
|
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
|
|
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 ===
|
|
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
|
|
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
|
|
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
|
|
250
|
-
process.env.NODE_ENV !== "production" && (
|
|
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,
|
|
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 (
|
|
255
|
-
|
|
284
|
+
if (a == null) {
|
|
285
|
+
a = t[++n];
|
|
256
286
|
continue;
|
|
257
287
|
}
|
|
258
|
-
if (
|
|
259
|
-
|
|
288
|
+
if (i == null) {
|
|
289
|
+
i = t[--r];
|
|
260
290
|
continue;
|
|
261
291
|
}
|
|
262
|
-
if (
|
|
263
|
-
s.push(...
|
|
264
|
-
else if (
|
|
265
|
-
s.push(...
|
|
266
|
-
else if (
|
|
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:
|
|
299
|
+
vnode: a,
|
|
270
300
|
anchor: t[r + 1] || null,
|
|
271
|
-
childPatches:
|
|
272
|
-
}),
|
|
273
|
-
else if (
|
|
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:
|
|
277
|
-
anchor:
|
|
278
|
-
childPatches:
|
|
279
|
-
}),
|
|
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
|
|
314
|
+
const d = /* @__PURE__ */ new Map();
|
|
285
315
|
for (let u = n; u <= r; u++) {
|
|
286
|
-
const
|
|
287
|
-
|
|
316
|
+
const _ = (p = t[u]) == null ? void 0 : p.key;
|
|
317
|
+
_ != null && d.set(_, u);
|
|
288
318
|
}
|
|
289
319
|
for (; o <= c; ) {
|
|
290
|
-
|
|
291
|
-
const u =
|
|
320
|
+
l = e[o];
|
|
321
|
+
const u = l.key != null ? d.get(l.key) : void 0;
|
|
292
322
|
if (u !== void 0) {
|
|
293
|
-
const
|
|
323
|
+
const _ = t[u];
|
|
294
324
|
s.push({
|
|
295
325
|
type: m.MOVE,
|
|
296
|
-
vnode:
|
|
326
|
+
vnode: _,
|
|
297
327
|
anchor: t[n] || null,
|
|
298
|
-
childPatches:
|
|
299
|
-
}), t[u] = null,
|
|
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:
|
|
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
|
|
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:
|
|
344
|
+
s.push({ type: m.CREATE, newVNode: e[u], anchor: d });
|
|
315
345
|
} else if (o > c)
|
|
316
|
-
for (let
|
|
317
|
-
t[
|
|
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
|
|
321
|
-
function
|
|
322
|
-
if (t.type ===
|
|
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 ===
|
|
356
|
+
if (t.type === ct) {
|
|
327
357
|
const n = document.createDocumentFragment();
|
|
328
358
|
for (const r of t.children)
|
|
329
|
-
n.appendChild(
|
|
359
|
+
n.appendChild(N(r, e));
|
|
330
360
|
return t._dom = n, n;
|
|
331
361
|
}
|
|
332
|
-
t.type === "svg" ? e =
|
|
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(
|
|
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 ||
|
|
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] &&
|
|
373
|
+
n === "children" || n === "key" || e[n] !== s[n] && tt(t, n, s[n], e[n]);
|
|
344
374
|
}
|
|
345
|
-
function
|
|
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
|
|
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
|
|
385
|
-
return t instanceof SVGElement ?
|
|
414
|
+
function B(t) {
|
|
415
|
+
return t instanceof SVGElement ? v : void 0;
|
|
386
416
|
}
|
|
387
|
-
function
|
|
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 =
|
|
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,
|
|
432
|
+
const c = o.oldVNode._dom, a = c == null ? void 0 : c.parentNode, i = N(
|
|
403
433
|
o.newVNode,
|
|
404
|
-
|
|
434
|
+
a ? B(a) : void 0
|
|
405
435
|
);
|
|
406
|
-
|
|
436
|
+
a && a.replaceChild(i, c);
|
|
407
437
|
break;
|
|
408
438
|
}
|
|
409
439
|
case m.UPDATE: {
|
|
410
|
-
const c = o.target._dom, { set:
|
|
411
|
-
for (const
|
|
412
|
-
|
|
413
|
-
for (const
|
|
414
|
-
|
|
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 &&
|
|
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 &&
|
|
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
|
-
|
|
440
|
-
const o =
|
|
441
|
-
|
|
469
|
+
I(s.vTree, r);
|
|
470
|
+
const o = T(s.vTree, n);
|
|
471
|
+
P(e, o);
|
|
442
472
|
const c = [];
|
|
443
|
-
n &&
|
|
444
|
-
const
|
|
445
|
-
for (const
|
|
446
|
-
|
|
447
|
-
const
|
|
448
|
-
for (const
|
|
449
|
-
|
|
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 =
|
|
484
|
+
const r = N(n);
|
|
455
485
|
e.appendChild(r);
|
|
456
486
|
const o = [];
|
|
457
|
-
|
|
487
|
+
I(n, o);
|
|
458
488
|
for (const c of o)
|
|
459
|
-
c.mount(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[
|
|
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 =
|
|
471
|
-
if (
|
|
472
|
-
const
|
|
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: [
|
|
505
|
+
children: [f],
|
|
476
506
|
key: t.key
|
|
477
507
|
};
|
|
478
|
-
return
|
|
508
|
+
return p._instance = o, o.lastVTree = p, p;
|
|
479
509
|
}
|
|
480
|
-
return
|
|
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
|
|
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 =
|
|
503
|
-
let
|
|
504
|
-
if (
|
|
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: [
|
|
537
|
+
children: [f],
|
|
508
538
|
key: null
|
|
509
|
-
},
|
|
510
|
-
|
|
511
|
-
const
|
|
512
|
-
|
|
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
|
|
515
|
-
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
const
|
|
519
|
-
for (const
|
|
520
|
-
|
|
521
|
-
t.lastVTree =
|
|
522
|
-
const
|
|
523
|
-
for (const
|
|
524
|
-
|
|
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:
|
|
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
|
|
532
|
-
if (t.lastVTree &&
|
|
533
|
-
|
|
534
|
-
const
|
|
535
|
-
|
|
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
|
|
538
|
-
|
|
539
|
-
for (const
|
|
540
|
-
t.lastVTree =
|
|
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
|
|
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),
|
|
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
|
|
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
|
-
|
|
585
|
+
I(s, e);
|
|
556
586
|
}
|
|
557
|
-
function
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
580
|
-
if (r.length <
|
|
581
|
-
const
|
|
582
|
-
for (let
|
|
583
|
-
const
|
|
584
|
-
if (
|
|
585
|
-
|
|
586
|
-
else if (
|
|
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
|
|
590
|
-
return
|
|
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
|
|
594
|
-
for (let
|
|
595
|
-
const
|
|
596
|
-
if (
|
|
597
|
-
l
|
|
598
|
-
else if (
|
|
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:
|
|
631
|
+
return { params: a };
|
|
602
632
|
}
|
|
603
|
-
function
|
|
633
|
+
function J(t, e) {
|
|
604
634
|
for (const s of e) {
|
|
605
|
-
const n =
|
|
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 =
|
|
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: (
|
|
645
|
+
params: (a == null ? void 0 : a.params) ?? {},
|
|
616
646
|
query: c,
|
|
617
|
-
matched: (
|
|
647
|
+
matched: (a == null ? void 0 : a.pattern) ?? null
|
|
618
648
|
},
|
|
619
649
|
actions: {
|
|
620
|
-
_sync: (
|
|
650
|
+
_sync: (h, E) => E
|
|
621
651
|
}
|
|
622
652
|
});
|
|
623
|
-
function
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
), O =
|
|
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:
|
|
629
|
-
params: (
|
|
630
|
-
query:
|
|
631
|
-
matched: (
|
|
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
|
|
635
|
-
const
|
|
636
|
-
window.history.pushState(null, "",
|
|
664
|
+
function f(h) {
|
|
665
|
+
const E = l(h);
|
|
666
|
+
window.history.pushState(null, "", h), i.dispatch("_sync", E);
|
|
637
667
|
}
|
|
638
|
-
function
|
|
639
|
-
const
|
|
640
|
-
window.history.replaceState(null, "",
|
|
668
|
+
function p(h) {
|
|
669
|
+
const E = l(h);
|
|
670
|
+
window.history.replaceState(null, "", h), i.dispatch("_sync", E);
|
|
641
671
|
}
|
|
642
|
-
function
|
|
672
|
+
function d() {
|
|
643
673
|
window.history.back();
|
|
644
674
|
}
|
|
645
675
|
function u() {
|
|
646
676
|
window.history.forward();
|
|
647
677
|
}
|
|
648
|
-
function
|
|
649
|
-
const
|
|
650
|
-
|
|
651
|
-
}
|
|
652
|
-
window.addEventListener("popstate",
|
|
653
|
-
function
|
|
654
|
-
window.removeEventListener("popstate",
|
|
655
|
-
}
|
|
656
|
-
const
|
|
657
|
-
_path:
|
|
658
|
-
})(function(
|
|
659
|
-
const { _path:
|
|
660
|
-
return
|
|
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
|
|
663
|
-
const { to:
|
|
664
|
-
return
|
|
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: (
|
|
670
|
-
|
|
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
|
-
...
|
|
703
|
+
...A || []
|
|
674
704
|
);
|
|
675
705
|
}
|
|
676
|
-
function
|
|
677
|
-
return
|
|
706
|
+
function R(h) {
|
|
707
|
+
return p(h.to), null;
|
|
678
708
|
}
|
|
679
709
|
return {
|
|
680
|
-
store:
|
|
681
|
-
navigate:
|
|
682
|
-
redirect:
|
|
683
|
-
back:
|
|
710
|
+
store: i,
|
|
711
|
+
navigate: f,
|
|
712
|
+
redirect: p,
|
|
713
|
+
back: d,
|
|
684
714
|
forward: u,
|
|
685
|
-
destroy:
|
|
686
|
-
Route:
|
|
687
|
-
Link:
|
|
688
|
-
Redirect:
|
|
715
|
+
destroy: w,
|
|
716
|
+
Route: y,
|
|
717
|
+
Link: V,
|
|
718
|
+
Redirect: R
|
|
689
719
|
};
|
|
690
720
|
}
|
|
691
|
-
function
|
|
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
|
|
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
|
|
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
|
-
|
|
726
|
-
|
|
755
|
+
ct as Fragment,
|
|
756
|
+
wt as actionHistory,
|
|
727
757
|
ut as connect,
|
|
728
|
-
|
|
729
|
-
|
|
758
|
+
gt as createAsyncAction,
|
|
759
|
+
q as createElement,
|
|
730
760
|
St as createRouter,
|
|
731
|
-
|
|
761
|
+
lt as createStore,
|
|
732
762
|
_t as flushSync,
|
|
733
|
-
|
|
734
|
-
|
|
763
|
+
q as h,
|
|
764
|
+
bt as logger,
|
|
735
765
|
Et as render
|
|
736
766
|
};
|
|
737
767
|
//# sourceMappingURL=pulse.js.map
|