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