essor 0.0.12 → 0.0.13-beta.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/dist/essor.cjs.js +32 -40
- package/dist/essor.cjs.js.map +1 -1
- package/dist/essor.d.cts +1 -1
- package/dist/essor.d.ts +1 -1
- package/dist/essor.dev.cjs.js +863 -1169
- package/dist/essor.dev.esm.js +846 -1149
- package/dist/essor.esm.js +6 -11
- package/dist/essor.esm.js.map +1 -1
- package/package.json +4 -4
package/dist/essor.dev.cjs.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* essor v0.0.
|
|
4
|
+
* essor v0.0.13-beta.2
|
|
5
5
|
* (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
**/
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var essor_version = "0.0.
|
|
10
|
+
var essor_version = "0.0.13-beta.2";
|
|
11
11
|
|
|
12
12
|
// ../shared/dist/shared.js
|
|
13
13
|
var isObject = (val) => val !== null && typeof val === "object";
|
|
@@ -18,16 +18,40 @@ function isString(val) {
|
|
|
18
18
|
function isSymbol(val) {
|
|
19
19
|
return typeof val === "symbol";
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
21
|
+
function isSet(val) {
|
|
22
|
+
return _toString.call(val) === "[object Set]";
|
|
23
|
+
}
|
|
24
|
+
function isWeakMap(val) {
|
|
25
|
+
return _toString.call(val) === "[object WeakMap]";
|
|
26
|
+
}
|
|
27
|
+
function isWeakSet(val) {
|
|
28
|
+
return _toString.call(val) === "[object WeakSet]";
|
|
29
|
+
}
|
|
30
|
+
function isMap(val) {
|
|
31
|
+
return _toString.call(val) === "[object Map]";
|
|
32
|
+
}
|
|
33
|
+
function isNil(x2) {
|
|
34
|
+
return x2 === null || x2 === void 0;
|
|
23
35
|
}
|
|
24
36
|
var isFunction = (val) => typeof val === "function";
|
|
25
|
-
function isFalsy(
|
|
26
|
-
return
|
|
37
|
+
function isFalsy(x2) {
|
|
38
|
+
return x2 === false || x2 === null || x2 === void 0;
|
|
39
|
+
}
|
|
40
|
+
var isPlainObject = (val) => _toString.call(val) === "[object Object]";
|
|
41
|
+
function isStringNumber(val) {
|
|
42
|
+
if (!isString(val)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return !Number.isNaN(Number(val));
|
|
27
46
|
}
|
|
47
|
+
var _toString = Object.prototype.toString;
|
|
48
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
49
|
+
var hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
28
50
|
function coerceArray(data) {
|
|
29
|
-
return
|
|
51
|
+
return isArray(data) ? data.flat() : [data];
|
|
30
52
|
}
|
|
53
|
+
var hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue);
|
|
54
|
+
var noop = Function.prototype;
|
|
31
55
|
function startsWith(str, searchString) {
|
|
32
56
|
if (!isString(str)) {
|
|
33
57
|
return false;
|
|
@@ -52,6 +76,9 @@ function escape(str) {
|
|
|
52
76
|
}
|
|
53
77
|
});
|
|
54
78
|
}
|
|
79
|
+
function isExclude(key, exclude) {
|
|
80
|
+
return isArray(exclude) ? exclude.includes(key) : isFunction(exclude) ? exclude(key) : false;
|
|
81
|
+
}
|
|
55
82
|
var kebabCase = (string) => {
|
|
56
83
|
return string.replaceAll(/[A-Z]+/g, (match, offset) => {
|
|
57
84
|
return `${offset > 0 ? "-" : ""}${match.toLocaleLowerCase()}`;
|
|
@@ -60,827 +87,404 @@ var kebabCase = (string) => {
|
|
|
60
87
|
var capitalizeFirstLetter = (inputString) => {
|
|
61
88
|
return inputString.charAt(0).toUpperCase() + inputString.slice(1);
|
|
62
89
|
};
|
|
90
|
+
function warn(msg, ...args) {
|
|
91
|
+
console.warn.apply(console, [`[Essor warn]: ${msg}`].concat(args));
|
|
92
|
+
}
|
|
63
93
|
|
|
64
|
-
// ../signal/dist/signal.
|
|
65
|
-
var
|
|
66
|
-
var
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
-
var
|
|
70
|
-
var
|
|
71
|
-
for (var
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (__getOwnPropSymbols)
|
|
75
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
76
|
-
if (__propIsEnum.call(b, prop))
|
|
77
|
-
__defNormalProp(a, prop, b[prop]);
|
|
78
|
-
}
|
|
79
|
-
return a;
|
|
94
|
+
// ../signal/dist/signal.esm.js
|
|
95
|
+
var ye = Object.defineProperty;
|
|
96
|
+
var U = Object.getOwnPropertySymbols;
|
|
97
|
+
var Se = Object.prototype.hasOwnProperty;
|
|
98
|
+
var me = Object.prototype.propertyIsEnumerable;
|
|
99
|
+
var Q = (e, t, n) => t in e ? ye(e, t, { enumerable: true, configurable: true, writable: true, value: n }) : e[t] = n;
|
|
100
|
+
var y = (e, t) => {
|
|
101
|
+
for (var n in t || (t = {})) Se.call(t, n) && Q(e, n, t[n]);
|
|
102
|
+
if (U) for (var n of U(t)) me.call(t, n) && Q(e, n, t[n]);
|
|
103
|
+
return e;
|
|
80
104
|
};
|
|
81
|
-
var
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return _toString.call(val) === "[object Set]";
|
|
88
|
-
}
|
|
89
|
-
function isWeakMap(val) {
|
|
90
|
-
return _toString.call(val) === "[object WeakMap]";
|
|
105
|
+
var M = [];
|
|
106
|
+
var F = [];
|
|
107
|
+
var X = Promise.resolve();
|
|
108
|
+
var K = false;
|
|
109
|
+
function C(e) {
|
|
110
|
+
return e ? X.then(e) : X;
|
|
91
111
|
}
|
|
92
|
-
function
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
function isMap(val) {
|
|
96
|
-
return _toString.call(val) === "[object Map]";
|
|
112
|
+
function ge(e) {
|
|
113
|
+
M.includes(e) || (M.push(e), Y());
|
|
97
114
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
function isStringNumber(val) {
|
|
101
|
-
if (!isString2(val)) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
return !Number.isNaN(Number(val));
|
|
115
|
+
function Y() {
|
|
116
|
+
K || (K = true, C(ve));
|
|
105
117
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
var hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
109
|
-
var hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue);
|
|
110
|
-
var noop2 = Function.prototype;
|
|
111
|
-
function isExclude(key, exclude) {
|
|
112
|
-
return Array.isArray(exclude) ? exclude.includes(key) : isFunction2(exclude) ? exclude(key) : false;
|
|
118
|
+
function _e(e) {
|
|
119
|
+
xe(e, F);
|
|
113
120
|
}
|
|
114
|
-
function
|
|
115
|
-
|
|
121
|
+
function xe(e, t) {
|
|
122
|
+
t.includes(e) || (t.push(e), Y());
|
|
116
123
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
function nextTick(fn) {
|
|
122
|
-
return fn ? p.then(fn) : p;
|
|
124
|
+
function ve() {
|
|
125
|
+
K = false, we();
|
|
126
|
+
let e;
|
|
127
|
+
for (; e = M.shift(); ) e && e();
|
|
123
128
|
}
|
|
124
|
-
function
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
129
|
+
function we() {
|
|
130
|
+
for (; F.length > 0; ) {
|
|
131
|
+
let e = F.shift();
|
|
132
|
+
e && e();
|
|
128
133
|
}
|
|
129
134
|
}
|
|
130
|
-
function
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
isFlushPending = true;
|
|
135
|
-
nextTick(flushJobs);
|
|
136
|
-
}
|
|
137
|
-
function queuePreFlushCb(cb) {
|
|
138
|
-
queueCb(cb, activePreFlushCbs);
|
|
139
|
-
}
|
|
140
|
-
function queueCb(cb, activeQueue) {
|
|
141
|
-
if (!activeQueue.includes(cb)) {
|
|
142
|
-
activeQueue.push(cb);
|
|
143
|
-
queueFlush();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function flushJobs() {
|
|
147
|
-
isFlushPending = false;
|
|
148
|
-
flushPreFlushCbs();
|
|
149
|
-
let job;
|
|
150
|
-
while (job = queue.shift()) {
|
|
151
|
-
if (job) {
|
|
152
|
-
job();
|
|
153
|
-
}
|
|
154
|
-
}
|
|
135
|
+
function Z(e, t) {
|
|
136
|
+
return t === "sync" ? () => e() : t === "pre" ? () => _e(e) : () => {
|
|
137
|
+
C(() => ge(e));
|
|
138
|
+
};
|
|
155
139
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
140
|
+
var T = null;
|
|
141
|
+
var G = /* @__PURE__ */ new WeakMap();
|
|
142
|
+
var H = /* @__PURE__ */ new WeakMap();
|
|
143
|
+
var _ = Symbol("");
|
|
144
|
+
var x = Symbol("");
|
|
145
|
+
var te = Symbol("");
|
|
146
|
+
var ne = Symbol("");
|
|
147
|
+
var $ = Symbol("");
|
|
148
|
+
var f = Symbol("");
|
|
149
|
+
var S = Symbol("");
|
|
150
|
+
var D = false;
|
|
151
|
+
var E = /* @__PURE__ */ new Set();
|
|
152
|
+
function u(e, t) {
|
|
153
|
+
if (!T) return;
|
|
154
|
+
let n = G.get(e);
|
|
155
|
+
n || (n = /* @__PURE__ */ new Map(), G.set(e, n));
|
|
156
|
+
let o = n.get(t);
|
|
157
|
+
o || (o = /* @__PURE__ */ new Set(), n.set(t, o)), T && o.add(T);
|
|
158
|
+
}
|
|
159
|
+
function p(e, t) {
|
|
160
|
+
let n = G.get(e);
|
|
161
|
+
if (!n) return;
|
|
162
|
+
let o = n.get(t);
|
|
163
|
+
o && o.forEach((r) => {
|
|
164
|
+
if (hasOwn(r, "active") && !r.active) {
|
|
165
|
+
o.delete(r);
|
|
166
|
+
return;
|
|
161
167
|
}
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
var activeEffect = null;
|
|
165
|
-
var activeComputed = null;
|
|
166
|
-
var triggerMap = /* @__PURE__ */ new WeakMap();
|
|
167
|
-
var reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
168
|
-
var ReactiveSymbol = Symbol("ReactiveSymbol");
|
|
169
|
-
var ReactivePeekSymbol = Symbol("__raw");
|
|
170
|
-
var SignalValueKey = Symbol("SignalValueKey");
|
|
171
|
-
var ComputedValueKey = Symbol("ComputedValueKey");
|
|
172
|
-
var reactiveArrayKey = Symbol("ReactiveArrayKey");
|
|
173
|
-
var ReactiveCollectionKey = Symbol("ReactiveCollectionKey");
|
|
174
|
-
var ReactiveWeakCollectionKey = Symbol("ReactiveWeakCollectionKey");
|
|
175
|
-
var inBatch = false;
|
|
176
|
-
var batchQueue = /* @__PURE__ */ new Set();
|
|
177
|
-
function track(target, key) {
|
|
178
|
-
if (!activeEffect && !activeComputed) return;
|
|
179
|
-
let depsMap = triggerMap.get(target);
|
|
180
|
-
if (!depsMap) {
|
|
181
|
-
depsMap = /* @__PURE__ */ new Map();
|
|
182
|
-
triggerMap.set(target, depsMap);
|
|
183
|
-
}
|
|
184
|
-
let dep = depsMap.get(key);
|
|
185
|
-
if (!dep) {
|
|
186
|
-
dep = /* @__PURE__ */ new Set();
|
|
187
|
-
depsMap.set(key, dep);
|
|
188
|
-
}
|
|
189
|
-
if (activeEffect) dep.add(activeEffect);
|
|
190
|
-
}
|
|
191
|
-
function trigger(target, key) {
|
|
192
|
-
const depsMap = triggerMap.get(target);
|
|
193
|
-
if (!depsMap) return;
|
|
194
|
-
const dep = depsMap.get(key);
|
|
195
|
-
if (dep) {
|
|
196
|
-
dep.forEach((effect) => {
|
|
197
|
-
if (hasOwn(effect, "active") && !effect.active) {
|
|
198
|
-
dep.delete(effect);
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
if (inBatch) {
|
|
202
|
-
batchQueue.add(effect);
|
|
203
|
-
} else {
|
|
204
|
-
effect();
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}
|
|
168
|
+
D ? E.add(r) : r();
|
|
169
|
+
});
|
|
208
170
|
}
|
|
209
|
-
var
|
|
210
|
-
|
|
211
|
-
* Creates a new Signal instance.
|
|
212
|
-
* @param {T} value - The initial value of the Signal.
|
|
213
|
-
* @param {boolean} [shallow] - Whether to create a shallow Signal.
|
|
214
|
-
*/
|
|
215
|
-
constructor(value, shallow = false) {
|
|
171
|
+
var j = class {
|
|
172
|
+
constructor(t, n = false) {
|
|
216
173
|
this.__signal = true;
|
|
217
|
-
this.
|
|
218
|
-
this._value = value;
|
|
174
|
+
this.__shallow = n, this.__value = t;
|
|
219
175
|
}
|
|
220
|
-
/**
|
|
221
|
-
* Gets the current value of the Signal.
|
|
222
|
-
* @returns {T} The current value.
|
|
223
|
-
*/
|
|
224
176
|
get value() {
|
|
225
|
-
|
|
226
|
-
if (isObject2(this._value) && !this._shallow) {
|
|
227
|
-
return useReactive(this._value);
|
|
228
|
-
}
|
|
229
|
-
return this._value;
|
|
177
|
+
return u(this, te), isObject(this.__value) && !this.__shallow ? v(this.__value) : this.__value;
|
|
230
178
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
* @param {T} newValue - The new value to set.
|
|
234
|
-
*/
|
|
235
|
-
set value(newValue) {
|
|
236
|
-
if (isSignal(newValue)) {
|
|
237
|
-
newValue = newValue.peek();
|
|
238
|
-
}
|
|
239
|
-
if (hasChanged(newValue, this._value)) {
|
|
240
|
-
this._value = newValue;
|
|
241
|
-
trigger(this, SignalValueKey);
|
|
242
|
-
}
|
|
179
|
+
set value(t) {
|
|
180
|
+
h(t) && (t = t.peek()), hasChanged(t, this.__value) && (this.__value = t, p(this, te));
|
|
243
181
|
}
|
|
244
|
-
/**
|
|
245
|
-
* Returns the current value without triggering reactivity.
|
|
246
|
-
* @returns {T} The current value.
|
|
247
|
-
*/
|
|
248
182
|
peek() {
|
|
249
|
-
return this.
|
|
183
|
+
return this.__value;
|
|
250
184
|
}
|
|
251
185
|
};
|
|
252
|
-
function
|
|
253
|
-
|
|
254
|
-
return value;
|
|
255
|
-
}
|
|
256
|
-
return new Signal(value);
|
|
186
|
+
function le(e) {
|
|
187
|
+
return h(e) ? e : new j(e);
|
|
257
188
|
}
|
|
258
|
-
function
|
|
259
|
-
return new
|
|
189
|
+
function Re(e) {
|
|
190
|
+
return new j(e, true);
|
|
260
191
|
}
|
|
261
|
-
function
|
|
262
|
-
return !!(
|
|
192
|
+
function h(e) {
|
|
193
|
+
return !!(e && (e != null && e.__signal));
|
|
263
194
|
}
|
|
264
|
-
var
|
|
265
|
-
constructor(
|
|
266
|
-
this.fn =
|
|
195
|
+
var V = class {
|
|
196
|
+
constructor(t) {
|
|
197
|
+
this.fn = t;
|
|
267
198
|
this.__computed = true;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
this._value = this.fn();
|
|
271
|
-
activeEffect = prev;
|
|
199
|
+
let n = T;
|
|
200
|
+
T = this.run.bind(this), this.__value = this.fn(), T = n;
|
|
272
201
|
}
|
|
273
|
-
/**
|
|
274
|
-
* Get the current computed value without tracking it.
|
|
275
|
-
*/
|
|
276
202
|
peek() {
|
|
277
|
-
return this.
|
|
203
|
+
return this.__value;
|
|
278
204
|
}
|
|
279
|
-
/**
|
|
280
|
-
* Run the computed function and update the value if it has changed.
|
|
281
|
-
*/
|
|
282
205
|
run() {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
this._value = newValue;
|
|
286
|
-
trigger(this, ComputedValueKey);
|
|
287
|
-
}
|
|
206
|
+
let t = this.fn();
|
|
207
|
+
hasChanged(t, this.__value) && (this.__value = t, p(this, ne));
|
|
288
208
|
}
|
|
289
|
-
/**
|
|
290
|
-
* Get the current computed value and track its usage.
|
|
291
|
-
*/
|
|
292
209
|
get value() {
|
|
293
|
-
|
|
294
|
-
return this._value;
|
|
210
|
+
return u(this, ne), this.__value;
|
|
295
211
|
}
|
|
296
212
|
};
|
|
297
|
-
function
|
|
298
|
-
return new
|
|
213
|
+
function z(e) {
|
|
214
|
+
return new V(e);
|
|
299
215
|
}
|
|
300
|
-
function
|
|
301
|
-
return !!(
|
|
216
|
+
function I(e) {
|
|
217
|
+
return !!(e && e.__computed);
|
|
302
218
|
}
|
|
303
|
-
function
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
} else {
|
|
309
|
-
return () => {
|
|
310
|
-
nextTick(() => queueJob(effect));
|
|
311
|
-
};
|
|
219
|
+
function B(e, t = {}) {
|
|
220
|
+
let { flush: n = "pre", onTrack: o, onTrigger: r } = t;
|
|
221
|
+
function s() {
|
|
222
|
+
let d = T;
|
|
223
|
+
T = s.init ? s : s.scheduler, e(), r && r(), T = d;
|
|
312
224
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
function effectFn() {
|
|
317
|
-
const prev = activeEffect;
|
|
318
|
-
activeEffect = effectFn.init ? effectFn : effectFn.scheduler;
|
|
319
|
-
fn();
|
|
320
|
-
onTrigger && onTrigger();
|
|
321
|
-
activeEffect = prev;
|
|
322
|
-
}
|
|
323
|
-
const scheduler = createScheduler(effectFn, flush);
|
|
324
|
-
effectFn.scheduler = scheduler;
|
|
325
|
-
effectFn.init = true;
|
|
326
|
-
effectFn.active = true;
|
|
327
|
-
onTrack && onTrack();
|
|
328
|
-
effectFn();
|
|
329
|
-
return () => {
|
|
330
|
-
effectFn.active = false;
|
|
331
|
-
activeEffect = null;
|
|
225
|
+
let i = Z(s, n);
|
|
226
|
+
return s.scheduler = i, s.init = true, s.active = true, o && o(), s(), () => {
|
|
227
|
+
s.active = false, T = null;
|
|
332
228
|
};
|
|
333
229
|
}
|
|
334
|
-
function
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
if (
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
function shallowReactive(initialValue, exclude) {
|
|
374
|
-
return reactive(initialValue, true, exclude);
|
|
375
|
-
}
|
|
376
|
-
function unReactive(target) {
|
|
377
|
-
if (!isObject2(target)) {
|
|
378
|
-
return target;
|
|
379
|
-
}
|
|
380
|
-
if (!isReactive(target)) {
|
|
381
|
-
return target;
|
|
382
|
-
}
|
|
383
|
-
return target[ReactivePeekSymbol];
|
|
384
|
-
}
|
|
385
|
-
var basicHandler = (shallow, exclude) => {
|
|
386
|
-
return {
|
|
387
|
-
get(target, key, receiver) {
|
|
388
|
-
if (key === ReactiveSymbol) return true;
|
|
389
|
-
if (key === ReactivePeekSymbol) return target;
|
|
390
|
-
const getValue = Reflect.get(target, key, receiver);
|
|
391
|
-
const value = isSignal(getValue) ? getValue.value : getValue;
|
|
392
|
-
if (isExclude(key, exclude)) {
|
|
393
|
-
return value;
|
|
394
|
-
}
|
|
395
|
-
track(target, key);
|
|
396
|
-
if (isObject2(value) && !shallow) {
|
|
397
|
-
return useReactive(value);
|
|
398
|
-
}
|
|
399
|
-
return value;
|
|
400
|
-
},
|
|
401
|
-
set(target, key, value, receiver) {
|
|
402
|
-
if (isExclude(key, exclude)) {
|
|
403
|
-
Reflect.set(target, key, value, receiver);
|
|
404
|
-
return true;
|
|
405
|
-
}
|
|
406
|
-
let oldValue = Reflect.get(target, key, receiver);
|
|
407
|
-
if (isSignal(oldValue)) {
|
|
408
|
-
oldValue = oldValue.value;
|
|
409
|
-
}
|
|
410
|
-
if (isSignal(value)) {
|
|
411
|
-
value = value.value;
|
|
412
|
-
}
|
|
413
|
-
const obj = Reflect.set(target, key, value, receiver);
|
|
414
|
-
if (hasChanged(value, oldValue)) {
|
|
415
|
-
trigger(target, key);
|
|
416
|
-
}
|
|
417
|
-
return obj;
|
|
418
|
-
},
|
|
419
|
-
// handle delete
|
|
420
|
-
deleteProperty(target, key) {
|
|
421
|
-
const oldValue = Reflect.get(target, key);
|
|
422
|
-
const result = Reflect.deleteProperty(target, key);
|
|
423
|
-
if (oldValue !== void 0) {
|
|
424
|
-
trigger(target, key);
|
|
425
|
-
}
|
|
426
|
-
return result;
|
|
427
|
-
}
|
|
428
|
-
};
|
|
429
|
-
};
|
|
430
|
-
var arrayInstrumentations = createArrayInstrumentations();
|
|
431
|
-
function createArrayInstrumentations() {
|
|
432
|
-
const instrumentations2 = {};
|
|
433
|
-
["includes", "indexOf", "lastIndexOf"].forEach((key) => {
|
|
434
|
-
instrumentations2[key] = function(...args) {
|
|
435
|
-
const arr = this;
|
|
436
|
-
for (let i = 0, l = this.length; i < l; i++) {
|
|
437
|
-
track(arr, `${i}`);
|
|
438
|
-
}
|
|
439
|
-
const res = arr[key](...args);
|
|
440
|
-
if (res === -1 || res === false) {
|
|
441
|
-
return arr[key](...args);
|
|
442
|
-
}
|
|
443
|
-
return res;
|
|
230
|
+
function We(e, t) {
|
|
231
|
+
return !e || !isObject(e) ? e : Object.entries(e).reduce((o, [r, s]) => (o[r] = isExclude(r, t) || h(s) ? s : le(s), o), {});
|
|
232
|
+
}
|
|
233
|
+
function c(e) {
|
|
234
|
+
return e && (b(e) ? e[x] : h(e) ? e.peek() : isArray(e) ? e.map((t) => c(t)) : isPlainObject(e) ? Object.fromEntries(Object.entries(e).map(([t, n]) => [t, c(n)])) : e);
|
|
235
|
+
}
|
|
236
|
+
function b(e) {
|
|
237
|
+
return !!(e && typeof e == "object" && e[_]);
|
|
238
|
+
}
|
|
239
|
+
function L(e, t) {
|
|
240
|
+
return v(e, false, t);
|
|
241
|
+
}
|
|
242
|
+
function Ce(e, t) {
|
|
243
|
+
return v(e, true, t);
|
|
244
|
+
}
|
|
245
|
+
var Ee = (e, t) => ({ get(n, o, r) {
|
|
246
|
+
if (o === _) return true;
|
|
247
|
+
if (o === x) return n;
|
|
248
|
+
let s = Reflect.get(n, o, r), i = h(s) ? s.value : s;
|
|
249
|
+
return isExclude(o, t) ? i : (u(n, o), isObject(i) && !e ? v(i) : i);
|
|
250
|
+
}, set(n, o, r, s) {
|
|
251
|
+
if (isExclude(o, t)) return Reflect.set(n, o, r, s), true;
|
|
252
|
+
let i = Reflect.get(n, o, s);
|
|
253
|
+
h(i) && (i = i.value), h(r) && (r = r.value);
|
|
254
|
+
let d = Reflect.set(n, o, r, s);
|
|
255
|
+
return hasChanged(r, i) && p(n, o), d;
|
|
256
|
+
}, deleteProperty(n, o) {
|
|
257
|
+
let r = Reflect.get(n, o), s = Reflect.deleteProperty(n, o);
|
|
258
|
+
return r !== void 0 && p(n, o), s;
|
|
259
|
+
} });
|
|
260
|
+
var oe = Pe();
|
|
261
|
+
function Pe() {
|
|
262
|
+
let e = {};
|
|
263
|
+
return ["includes", "indexOf", "lastIndexOf"].forEach((t) => {
|
|
264
|
+
e[t] = function(...n) {
|
|
265
|
+
let o = c(this);
|
|
266
|
+
for (let s = 0, i = this.length; s < i; s++) u(o, `${s}`);
|
|
267
|
+
let r = o[t](...n);
|
|
268
|
+
return r === -1 || r === false ? o[t](...n) : r;
|
|
444
269
|
};
|
|
445
|
-
})
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}
|
|
455
|
-
);
|
|
456
|
-
[
|
|
457
|
-
"forEach",
|
|
458
|
-
"map",
|
|
459
|
-
"filter",
|
|
460
|
-
"reduce",
|
|
461
|
-
"reduceRight",
|
|
462
|
-
"some",
|
|
463
|
-
"every",
|
|
464
|
-
"find",
|
|
465
|
-
"findIndex",
|
|
466
|
-
"findLast",
|
|
467
|
-
"findLastIndex",
|
|
468
|
-
"entries",
|
|
469
|
-
"keys",
|
|
470
|
-
"values"
|
|
471
|
-
].forEach((key) => {
|
|
472
|
-
instrumentations2[key] = function(...args) {
|
|
473
|
-
const arr = unReactive(this);
|
|
474
|
-
track(arr, reactiveArrayKey);
|
|
475
|
-
return arr[key].apply(this, args);
|
|
270
|
+
}), ["push", "pop", "shift", "unshift", "splice", "sort", "reverse"].forEach((t) => {
|
|
271
|
+
e[t] = function(...n) {
|
|
272
|
+
let o = c(this), r = o[t].apply(this, n);
|
|
273
|
+
return p(o, $), r;
|
|
274
|
+
};
|
|
275
|
+
}), ["forEach", "map", "filter", "reduce", "reduceRight", "some", "every", "find", "findIndex", "findLast", "findLastIndex", "entries", "keys", "values"].forEach((t) => {
|
|
276
|
+
e[t] = function(...n) {
|
|
277
|
+
let o = c(this);
|
|
278
|
+
return u(o, $), o[t].apply(this, n);
|
|
476
279
|
};
|
|
280
|
+
}), e;
|
|
281
|
+
}
|
|
282
|
+
var je = (e, t) => ({ get(n, o, r) {
|
|
283
|
+
if (o === _) return true;
|
|
284
|
+
if (o === x) return n;
|
|
285
|
+
if (oe.hasOwnProperty(o)) return Reflect.get(oe, o, r);
|
|
286
|
+
let s = Reflect.get(n, o, r);
|
|
287
|
+
return isExclude(o, t) ? s : (isStringNumber(o) && u(n, o), u(n, "length"), isObject(s) && !e ? v(s) : s);
|
|
288
|
+
}, set(n, o, r, s) {
|
|
289
|
+
let i = Reflect.get(n, o, s), d = Reflect.set(n, o, r, s);
|
|
290
|
+
return hasChanged(r, i) && (isStringNumber(o) && p(n, o), (o === "length" || !i) && p(n, "length")), d;
|
|
291
|
+
} });
|
|
292
|
+
var Ae = { get(e, t) {
|
|
293
|
+
return t === _ ? true : t === x ? e : ((t === Symbol.iterator || t === "size") && u(e, f), Reflect.get(hasOwn(re, t) && t in e ? re : e, t, e));
|
|
294
|
+
} };
|
|
295
|
+
var Ie = { get(e, t) {
|
|
296
|
+
return t === _ ? true : t === x ? e : Reflect.get(hasOwn(se, t) && t in e ? se : e, t, e);
|
|
297
|
+
} };
|
|
298
|
+
var re = { get(e) {
|
|
299
|
+
let t = c(this);
|
|
300
|
+
return u(t, f), t.get(e);
|
|
301
|
+
}, set(e, t) {
|
|
302
|
+
let n = c(this), o = n.set(e, t);
|
|
303
|
+
return p(n, f), o;
|
|
304
|
+
}, add(e) {
|
|
305
|
+
let t = c(this), n = t.add(e);
|
|
306
|
+
return p(t, f), n;
|
|
307
|
+
}, has(e) {
|
|
308
|
+
let t = c(this);
|
|
309
|
+
return u(t, f), t.has(e);
|
|
310
|
+
}, delete(e) {
|
|
311
|
+
let t = c(this), n = t.has(e), o = t.delete(e);
|
|
312
|
+
return n && p(t, f), o;
|
|
313
|
+
}, clear() {
|
|
314
|
+
let e = c(this), t = e.size > 0, n = e.clear();
|
|
315
|
+
return t && p(e, f), n;
|
|
316
|
+
}, forEach(e, t) {
|
|
317
|
+
let n = c(this);
|
|
318
|
+
u(n, f), n.forEach((o, r) => {
|
|
319
|
+
e.call(t, o, r, n);
|
|
477
320
|
});
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
321
|
+
}, get size() {
|
|
322
|
+
let e = c(this);
|
|
323
|
+
return u(e, f), e.size;
|
|
324
|
+
}, keys() {
|
|
325
|
+
let e = c(this);
|
|
326
|
+
return u(e, f), e.keys();
|
|
327
|
+
}, values() {
|
|
328
|
+
let e = c(this);
|
|
329
|
+
return u(e, f), e.values();
|
|
330
|
+
}, entries() {
|
|
331
|
+
let e = c(this);
|
|
332
|
+
return u(e, f), e.entries();
|
|
333
|
+
}, [Symbol.iterator]() {
|
|
334
|
+
let e = c(this);
|
|
335
|
+
return u(e, f), e[Symbol.iterator]();
|
|
336
|
+
} };
|
|
337
|
+
var se = { get(e) {
|
|
338
|
+
let t = c(this);
|
|
339
|
+
return u(t, S), t.get(e);
|
|
340
|
+
}, set(e, t) {
|
|
341
|
+
let n = c(this), o = n.set(e, t);
|
|
342
|
+
return p(n, S), o;
|
|
343
|
+
}, add(e) {
|
|
344
|
+
let t = c(this), n = t.add(e);
|
|
345
|
+
return p(t, S), n;
|
|
346
|
+
}, has(e) {
|
|
347
|
+
let t = c(this);
|
|
348
|
+
return u(t, S), t.has(e);
|
|
349
|
+
}, delete(e) {
|
|
350
|
+
let t = c(this), n = t.delete(e);
|
|
351
|
+
return p(t, S), n;
|
|
352
|
+
} };
|
|
353
|
+
function v(e, t = false, n) {
|
|
354
|
+
if (!isObject(e) || b(e)) return e;
|
|
355
|
+
if (H.has(e)) return H.get(e);
|
|
356
|
+
let o;
|
|
357
|
+
isArray(e) ? (u(e, $), o = je(t, n)) : isSet(e) || isMap(e) ? (u(e, f), o = Ae) : isWeakSet(e) || isWeakMap(e) ? (u(e, S), o = Ie) : o = Ee(t, n);
|
|
358
|
+
let r = new Proxy(e, o);
|
|
359
|
+
return H.set(e, r), r;
|
|
360
|
+
}
|
|
361
|
+
function Oe(e) {
|
|
362
|
+
b(e) && (isWeakMap(e) || isWeakSet(e) || fe(() => {
|
|
363
|
+
isArray(e) ? e.length = 0 : isSet(e) || isMap(e) ? e.clear() : isObject(e) && Object.keys(e).forEach((t) => {
|
|
364
|
+
delete e[t];
|
|
365
|
+
});
|
|
366
|
+
}));
|
|
367
|
+
}
|
|
368
|
+
function fe(e) {
|
|
369
|
+
try {
|
|
370
|
+
D = true, e();
|
|
371
|
+
} finally {
|
|
372
|
+
D = false, Me();
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function Me() {
|
|
376
|
+
E.size > 0 && (E.forEach((e) => e()), E.clear());
|
|
377
|
+
}
|
|
378
|
+
function De(e, t, n) {
|
|
379
|
+
return Je(e, t, n);
|
|
380
|
+
}
|
|
381
|
+
var pe = void 0;
|
|
382
|
+
var w;
|
|
383
|
+
var N = false;
|
|
384
|
+
function Ve(e) {
|
|
385
|
+
w = e, N || (N = true, C(qe));
|
|
386
|
+
}
|
|
387
|
+
function qe() {
|
|
388
|
+
w == null || w(), w = null, N = false;
|
|
389
|
+
}
|
|
390
|
+
function Je(e, t, { deep: n, immediate: o } = {}) {
|
|
391
|
+
let r, s = isArray(e);
|
|
392
|
+
if (h(e) || I(e)) r = () => e.value;
|
|
393
|
+
else if (b(e)) r = () => y({}, e);
|
|
394
|
+
else if (s) r = () => e.map((a) => ze(a));
|
|
395
|
+
else if (isFunction(e)) r = e;
|
|
396
|
+
else return warn("Invalid source type", e), noop;
|
|
397
|
+
if (t && n) {
|
|
398
|
+
let a = r, l = n === true ? 1 / 0 : n;
|
|
399
|
+
r = () => k(a(), l);
|
|
400
|
+
}
|
|
401
|
+
let i = s ? Array.from({ length: e.length }).fill(pe) : pe, d = false, O = () => {
|
|
402
|
+
let a = r();
|
|
403
|
+
hasChanged(a, i) && (o && t && (t(a, i), i = a), d && t && Ve(() => {
|
|
404
|
+
t(a, i), i = a;
|
|
405
|
+
}), !d && (i = a));
|
|
406
|
+
}, g = B(O, { flush: "sync" });
|
|
407
|
+
return d = true, o && O(), g;
|
|
408
|
+
}
|
|
409
|
+
function ze(e) {
|
|
410
|
+
return h(e) || I(e) ? e.value : b(e) ? y({}, e) : isFunction(e) ? e() : (warn("Invalid source", e), noop);
|
|
411
|
+
}
|
|
412
|
+
function k(e, t = 1 / 0, n) {
|
|
413
|
+
if (t <= 0 || !isObject(e) || (n = n || /* @__PURE__ */ new Set(), n.has(e))) return e;
|
|
414
|
+
if (n.add(e), t--, h(e)) k(e.value, t, n);
|
|
415
|
+
else if (isArray(e)) for (let o of e) k(o, t, n);
|
|
416
|
+
else if (isSet(e) || isMap(e)) e.forEach((o) => {
|
|
417
|
+
k(o, t, n);
|
|
418
|
+
});
|
|
419
|
+
else if (isPlainObject(e)) for (let o in e) k(e[o], t, n);
|
|
420
|
+
return e;
|
|
421
|
+
}
|
|
422
|
+
function Be(e) {
|
|
423
|
+
let { state: t, getters: n, actions: o } = e, r = y({}, t != null ? t : {}), s = L(t != null ? t : {}), i = [], d = [], g = y({ state: s }, { patch$(a) {
|
|
424
|
+
Object.assign(s, a), i.forEach((l) => l(s)), d.forEach((l) => l(s));
|
|
425
|
+
}, subscribe$(a) {
|
|
426
|
+
i.push(a);
|
|
427
|
+
}, unsubscribe$(a) {
|
|
428
|
+
let l = i.indexOf(a);
|
|
429
|
+
l !== -1 && i.splice(l, 1);
|
|
430
|
+
}, onAction$(a) {
|
|
431
|
+
d.push(a);
|
|
432
|
+
}, reset$() {
|
|
433
|
+
Object.assign(s, r);
|
|
434
|
+
} });
|
|
435
|
+
for (let a in n) {
|
|
436
|
+
let l = n[a];
|
|
437
|
+
l && Object.defineProperty(g, a, { get() {
|
|
438
|
+
return z(l.bind(s, s)).value;
|
|
439
|
+
}, enumerable: true, configurable: true });
|
|
440
|
+
}
|
|
441
|
+
for (let a in o) {
|
|
442
|
+
let l = o[a];
|
|
443
|
+
l && (g[a] = l.bind(s));
|
|
444
|
+
}
|
|
445
|
+
return g;
|
|
446
|
+
}
|
|
447
|
+
function Le(e) {
|
|
448
|
+
return function() {
|
|
449
|
+
return Be(e);
|
|
514
450
|
};
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
}
|
|
523
|
-
return Reflect.get(
|
|
524
|
-
hasOwn(instrumentations, key) && key in target ? instrumentations : target,
|
|
525
|
-
key,
|
|
526
|
-
target
|
|
527
|
-
);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// ../template/dist/template.dev.esm.js
|
|
454
|
+
var componentMap = /* @__PURE__ */ new Map();
|
|
455
|
+
var RenderContext = class {
|
|
456
|
+
constructor() {
|
|
457
|
+
this.renderMode = 0;
|
|
528
458
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
get(target, key) {
|
|
532
|
-
if (key === ReactiveSymbol) return true;
|
|
533
|
-
if (key === ReactivePeekSymbol) return target;
|
|
534
|
-
return Reflect.get(
|
|
535
|
-
hasOwn(weakInstrumentations, key) && key in target ? weakInstrumentations : target,
|
|
536
|
-
key,
|
|
537
|
-
target
|
|
538
|
-
);
|
|
459
|
+
get isSSG() {
|
|
460
|
+
return this.renderMode === 1;
|
|
539
461
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
get(key) {
|
|
543
|
-
const target = unReactive(this);
|
|
544
|
-
track(target, ReactiveCollectionKey);
|
|
545
|
-
return target.get(key);
|
|
546
|
-
},
|
|
547
|
-
set(key, value) {
|
|
548
|
-
const target = unReactive(this);
|
|
549
|
-
const result = target.set(key, value);
|
|
550
|
-
trigger(target, ReactiveCollectionKey);
|
|
551
|
-
return result;
|
|
552
|
-
},
|
|
553
|
-
add(value) {
|
|
554
|
-
const target = unReactive(this);
|
|
555
|
-
const result = target.add(value);
|
|
556
|
-
trigger(target, ReactiveCollectionKey);
|
|
557
|
-
return result;
|
|
558
|
-
},
|
|
559
|
-
has(key) {
|
|
560
|
-
const target = unReactive(this);
|
|
561
|
-
track(target, ReactiveCollectionKey);
|
|
562
|
-
return target.has(key);
|
|
563
|
-
},
|
|
564
|
-
delete(key) {
|
|
565
|
-
const target = unReactive(this);
|
|
566
|
-
const hadKey = target.has(key);
|
|
567
|
-
const result = target.delete(key);
|
|
568
|
-
if (hadKey) {
|
|
569
|
-
trigger(target, ReactiveCollectionKey);
|
|
570
|
-
}
|
|
571
|
-
return result;
|
|
572
|
-
},
|
|
573
|
-
clear() {
|
|
574
|
-
const target = unReactive(this);
|
|
575
|
-
const hadItems = target.size > 0;
|
|
576
|
-
const result = target.clear();
|
|
577
|
-
if (hadItems) {
|
|
578
|
-
trigger(target, ReactiveCollectionKey);
|
|
579
|
-
}
|
|
580
|
-
return result;
|
|
581
|
-
},
|
|
582
|
-
forEach(callback, thisArg) {
|
|
583
|
-
const target = unReactive(this);
|
|
584
|
-
track(target, ReactiveCollectionKey);
|
|
585
|
-
target.forEach((value, key) => {
|
|
586
|
-
callback.call(thisArg, value, key, target);
|
|
587
|
-
});
|
|
588
|
-
},
|
|
589
|
-
get size() {
|
|
590
|
-
const target = unReactive(this);
|
|
591
|
-
track(target, ReactiveCollectionKey);
|
|
592
|
-
return target.size;
|
|
593
|
-
},
|
|
594
|
-
keys() {
|
|
595
|
-
const target = unReactive(this);
|
|
596
|
-
track(target, ReactiveCollectionKey);
|
|
597
|
-
return target.keys();
|
|
598
|
-
},
|
|
599
|
-
values() {
|
|
600
|
-
const target = unReactive(this);
|
|
601
|
-
track(target, ReactiveCollectionKey);
|
|
602
|
-
return target.values();
|
|
603
|
-
},
|
|
604
|
-
entries() {
|
|
605
|
-
const target = unReactive(this);
|
|
606
|
-
track(target, ReactiveCollectionKey);
|
|
607
|
-
return target.entries();
|
|
608
|
-
},
|
|
609
|
-
[Symbol.iterator]() {
|
|
610
|
-
const target = unReactive(this);
|
|
611
|
-
track(target, ReactiveCollectionKey);
|
|
612
|
-
return target[Symbol.iterator]();
|
|
462
|
+
get isSSR() {
|
|
463
|
+
return this.renderMode === 2;
|
|
613
464
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
get(key) {
|
|
617
|
-
const target = unReactive(this);
|
|
618
|
-
track(target, ReactiveWeakCollectionKey);
|
|
619
|
-
return target.get(key);
|
|
620
|
-
},
|
|
621
|
-
set(key, value) {
|
|
622
|
-
const target = unReactive(this);
|
|
623
|
-
const result = target.set(key, value);
|
|
624
|
-
trigger(target, ReactiveWeakCollectionKey);
|
|
625
|
-
return result;
|
|
626
|
-
},
|
|
627
|
-
add(value) {
|
|
628
|
-
const target = unReactive(this);
|
|
629
|
-
const result = target.add(value);
|
|
630
|
-
trigger(target, ReactiveWeakCollectionKey);
|
|
631
|
-
return result;
|
|
632
|
-
},
|
|
633
|
-
has(key) {
|
|
634
|
-
const target = unReactive(this);
|
|
635
|
-
track(target, ReactiveWeakCollectionKey);
|
|
636
|
-
return target.has(key);
|
|
637
|
-
},
|
|
638
|
-
delete(key) {
|
|
639
|
-
const target = unReactive(this);
|
|
640
|
-
const result = target.delete(key);
|
|
641
|
-
trigger(target, ReactiveWeakCollectionKey);
|
|
642
|
-
return result;
|
|
465
|
+
get isClient() {
|
|
466
|
+
return this.renderMode === 0;
|
|
643
467
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
if (!isObject2(initialValue)) {
|
|
647
|
-
return initialValue;
|
|
648
|
-
}
|
|
649
|
-
if (isReactive(initialValue)) {
|
|
650
|
-
return initialValue;
|
|
651
|
-
}
|
|
652
|
-
if (reactiveMap.has(initialValue)) {
|
|
653
|
-
return reactiveMap.get(initialValue);
|
|
654
|
-
}
|
|
655
|
-
let handler;
|
|
656
|
-
if (isArray2(initialValue)) {
|
|
657
|
-
track(initialValue, reactiveArrayKey);
|
|
658
|
-
handler = ArrayHandler(shallow, exclude);
|
|
659
|
-
} else if (isSet(initialValue) || isMap(initialValue)) {
|
|
660
|
-
track(initialValue, ReactiveCollectionKey);
|
|
661
|
-
handler = collectionHandlers;
|
|
662
|
-
} else if (isWeakSet(initialValue) || isWeakMap(initialValue)) {
|
|
663
|
-
track(initialValue, ReactiveWeakCollectionKey);
|
|
664
|
-
handler = weakCollectionHandlers;
|
|
665
|
-
} else {
|
|
666
|
-
handler = basicHandler(shallow, exclude);
|
|
468
|
+
setSSR() {
|
|
469
|
+
this.renderMode = 2;
|
|
667
470
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
return proxy;
|
|
671
|
-
}
|
|
672
|
-
function clearReactive(reactiveObj) {
|
|
673
|
-
if (!isReactive(reactiveObj)) {
|
|
674
|
-
{
|
|
675
|
-
warn("clearReactive: argument must be a reactive object");
|
|
676
|
-
}
|
|
677
|
-
return;
|
|
471
|
+
setSSG() {
|
|
472
|
+
this.renderMode = 1;
|
|
678
473
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
warn("clearReactive: WeakMap and WeakSet are not clearable");
|
|
682
|
-
}
|
|
683
|
-
return;
|
|
474
|
+
setClient() {
|
|
475
|
+
this.renderMode = 0;
|
|
684
476
|
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
} else if (isObject2(reactiveObj)) {
|
|
691
|
-
Object.keys(reactiveObj).forEach((key) => {
|
|
692
|
-
delete reactiveObj[key];
|
|
693
|
-
});
|
|
694
|
-
}
|
|
477
|
+
};
|
|
478
|
+
var renderContext = new RenderContext();
|
|
479
|
+
function enterComponent(temp, index) {
|
|
480
|
+
componentMap.set(temp, {
|
|
481
|
+
index
|
|
695
482
|
});
|
|
696
483
|
}
|
|
697
|
-
function
|
|
698
|
-
|
|
699
|
-
inBatch = true;
|
|
700
|
-
fn();
|
|
701
|
-
} finally {
|
|
702
|
-
inBatch = false;
|
|
703
|
-
runBatch();
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
function runBatch() {
|
|
707
|
-
if (batchQueue.size > 0) {
|
|
708
|
-
batchQueue.forEach((effect) => effect());
|
|
709
|
-
batchQueue.clear();
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
function useWatch(source, cb, options) {
|
|
713
|
-
return doWatch(source, cb, options);
|
|
714
|
-
}
|
|
715
|
-
var INITIAL_WATCHER_VALUE = void 0;
|
|
716
|
-
var watcher;
|
|
717
|
-
var flushing = false;
|
|
718
|
-
function queueWatcher(fn) {
|
|
719
|
-
watcher = fn;
|
|
720
|
-
if (!flushing) {
|
|
721
|
-
flushing = true;
|
|
722
|
-
nextTick(flushWatchers);
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
function flushWatchers() {
|
|
726
|
-
watcher == null ? void 0 : watcher();
|
|
727
|
-
watcher = null;
|
|
728
|
-
flushing = false;
|
|
729
|
-
}
|
|
730
|
-
function doWatch(source, cb, { deep, immediate } = {}) {
|
|
731
|
-
let getter;
|
|
732
|
-
const isMultiSource = isArray2(source);
|
|
733
|
-
if (isSignal(source) || isComputed(source)) {
|
|
734
|
-
getter = () => source.value;
|
|
735
|
-
} else if (isReactive(source)) {
|
|
736
|
-
getter = () => __spreadValues({}, source);
|
|
737
|
-
} else if (isMultiSource) {
|
|
738
|
-
getter = () => source.map((s) => resolveSource(s));
|
|
739
|
-
} else if (isFunction2(source)) {
|
|
740
|
-
getter = source;
|
|
741
|
-
} else {
|
|
742
|
-
warn("Invalid source type", source);
|
|
743
|
-
return noop2;
|
|
744
|
-
}
|
|
745
|
-
if (cb && deep) {
|
|
746
|
-
const baseGetter = getter;
|
|
747
|
-
const depth = deep === true ? Infinity : deep;
|
|
748
|
-
getter = () => traverse(baseGetter(), depth);
|
|
749
|
-
}
|
|
750
|
-
let oldValue = isMultiSource ? Array.from({ length: source.length }).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
|
751
|
-
let runCb = false;
|
|
752
|
-
const effectFn = () => {
|
|
753
|
-
const newValue = getter();
|
|
754
|
-
if (hasChanged(newValue, oldValue)) {
|
|
755
|
-
if (immediate && cb) {
|
|
756
|
-
cb(newValue, oldValue);
|
|
757
|
-
oldValue = newValue;
|
|
758
|
-
}
|
|
759
|
-
if (runCb && cb) {
|
|
760
|
-
queueWatcher(() => {
|
|
761
|
-
cb(newValue, oldValue);
|
|
762
|
-
oldValue = newValue;
|
|
763
|
-
});
|
|
764
|
-
}
|
|
765
|
-
!runCb && (oldValue = newValue);
|
|
766
|
-
}
|
|
767
|
-
};
|
|
768
|
-
const stop = useEffect(effectFn, { flush: "sync" });
|
|
769
|
-
runCb = true;
|
|
770
|
-
if (immediate) {
|
|
771
|
-
effectFn();
|
|
772
|
-
}
|
|
773
|
-
return stop;
|
|
774
|
-
}
|
|
775
|
-
function resolveSource(s) {
|
|
776
|
-
if (isSignal(s) || isComputed(s)) return s.value;
|
|
777
|
-
if (isReactive(s)) return __spreadValues({}, s);
|
|
778
|
-
if (isFunction2(s)) return s();
|
|
779
|
-
warn("Invalid source", s);
|
|
780
|
-
return noop2;
|
|
781
|
-
}
|
|
782
|
-
function traverse(value, depth = Infinity, seen) {
|
|
783
|
-
if (depth <= 0 || !isObject2(value)) {
|
|
784
|
-
return value;
|
|
785
|
-
}
|
|
786
|
-
seen = seen || /* @__PURE__ */ new Set();
|
|
787
|
-
if (seen.has(value)) {
|
|
788
|
-
return value;
|
|
789
|
-
}
|
|
790
|
-
seen.add(value);
|
|
791
|
-
depth--;
|
|
792
|
-
if (isSignal(value)) {
|
|
793
|
-
traverse(value.value, depth, seen);
|
|
794
|
-
} else if (isArray2(value)) {
|
|
795
|
-
for (const element of value) {
|
|
796
|
-
traverse(element, depth, seen);
|
|
797
|
-
}
|
|
798
|
-
} else if (isSet(value) || isMap(value)) {
|
|
799
|
-
value.forEach((v) => {
|
|
800
|
-
traverse(v, depth, seen);
|
|
801
|
-
});
|
|
802
|
-
} else if (isPlainObject(value)) {
|
|
803
|
-
for (const key in value) {
|
|
804
|
-
traverse(value[key], depth, seen);
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
return value;
|
|
808
|
-
}
|
|
809
|
-
function createOptionsStore(options) {
|
|
810
|
-
const { state, getters, actions } = options;
|
|
811
|
-
const initState = __spreadValues({}, state != null ? state : {});
|
|
812
|
-
const reactiveState = useReactive(state != null ? state : {});
|
|
813
|
-
const subscriptions = [];
|
|
814
|
-
const actionCallbacks = [];
|
|
815
|
-
const default_actions = {
|
|
816
|
-
patch$(payload) {
|
|
817
|
-
Object.assign(reactiveState, payload);
|
|
818
|
-
subscriptions.forEach((callback) => callback(reactiveState));
|
|
819
|
-
actionCallbacks.forEach((callback) => callback(reactiveState));
|
|
820
|
-
},
|
|
821
|
-
subscribe$(callback) {
|
|
822
|
-
subscriptions.push(callback);
|
|
823
|
-
},
|
|
824
|
-
unsubscribe$(callback) {
|
|
825
|
-
const index = subscriptions.indexOf(callback);
|
|
826
|
-
if (index !== -1) {
|
|
827
|
-
subscriptions.splice(index, 1);
|
|
828
|
-
}
|
|
829
|
-
},
|
|
830
|
-
onAction$(callback) {
|
|
831
|
-
actionCallbacks.push(callback);
|
|
832
|
-
},
|
|
833
|
-
reset$() {
|
|
834
|
-
Object.assign(reactiveState, initState);
|
|
835
|
-
}
|
|
836
|
-
};
|
|
837
|
-
const store = __spreadValues({
|
|
838
|
-
state: reactiveState
|
|
839
|
-
}, default_actions);
|
|
840
|
-
for (const key in getters) {
|
|
841
|
-
const getter = getters[key];
|
|
842
|
-
if (getter) {
|
|
843
|
-
Object.defineProperty(store, key, {
|
|
844
|
-
get() {
|
|
845
|
-
return useComputed(getter.bind(reactiveState, reactiveState)).value;
|
|
846
|
-
},
|
|
847
|
-
enumerable: true,
|
|
848
|
-
configurable: true
|
|
849
|
-
});
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
for (const key in actions) {
|
|
853
|
-
const action = actions[key];
|
|
854
|
-
if (action) {
|
|
855
|
-
store[key] = action.bind(reactiveState);
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
return store;
|
|
484
|
+
function getComponentIndex(temp) {
|
|
485
|
+
return componentMap.get(temp).index;
|
|
859
486
|
}
|
|
860
|
-
|
|
861
|
-
return function() {
|
|
862
|
-
return createOptionsStore(options);
|
|
863
|
-
};
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
// ../template/dist/template.dev.esm.js
|
|
867
|
-
var __defProp2 = Object.defineProperty;
|
|
868
|
-
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
869
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
870
|
-
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
871
|
-
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
872
|
-
var __spreadValues2 = (a, b) => {
|
|
873
|
-
for (var prop in b || (b = {}))
|
|
874
|
-
if (__hasOwnProp2.call(b, prop))
|
|
875
|
-
__defNormalProp2(a, prop, b[prop]);
|
|
876
|
-
if (__getOwnPropSymbols2)
|
|
877
|
-
for (var prop of __getOwnPropSymbols2(b)) {
|
|
878
|
-
if (__propIsEnum2.call(b, prop))
|
|
879
|
-
__defNormalProp2(a, prop, b[prop]);
|
|
880
|
-
}
|
|
881
|
-
return a;
|
|
882
|
-
};
|
|
883
|
-
var _Hooks = class _Hooks2 {
|
|
487
|
+
var _LifecycleContext = class _LifecycleContext2 {
|
|
884
488
|
constructor() {
|
|
885
489
|
this.hooks = {
|
|
886
490
|
mounted: /* @__PURE__ */ new Set(),
|
|
@@ -896,154 +500,120 @@ var _Hooks = class _Hooks2 {
|
|
|
896
500
|
(_a = this.hooks[hook]) == null ? void 0 : _a.add(cb);
|
|
897
501
|
}
|
|
898
502
|
getContext(context) {
|
|
899
|
-
return
|
|
503
|
+
return _LifecycleContext2.context[context];
|
|
900
504
|
}
|
|
901
505
|
setContext(context, value) {
|
|
902
|
-
|
|
506
|
+
_LifecycleContext2.context[context] = value;
|
|
903
507
|
}
|
|
904
508
|
initRef() {
|
|
905
|
-
|
|
509
|
+
_LifecycleContext2.ref = this;
|
|
906
510
|
}
|
|
907
511
|
removeRef() {
|
|
908
|
-
|
|
512
|
+
_LifecycleContext2.ref = null;
|
|
513
|
+
}
|
|
514
|
+
clearHooks() {
|
|
515
|
+
Object.values(this.hooks).forEach((set) => set.clear());
|
|
909
516
|
}
|
|
910
517
|
};
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
var
|
|
914
|
-
|
|
915
|
-
|
|
518
|
+
_LifecycleContext.ref = null;
|
|
519
|
+
_LifecycleContext.context = {};
|
|
520
|
+
var LifecycleContext = _LifecycleContext;
|
|
521
|
+
function isSSGNode(node) {
|
|
522
|
+
return node instanceof SSGNode;
|
|
523
|
+
}
|
|
524
|
+
var componentIndex = 1;
|
|
525
|
+
var SSGNode = class extends LifecycleContext {
|
|
526
|
+
constructor(template, props = {}, key) {
|
|
916
527
|
super();
|
|
917
|
-
this.template =
|
|
528
|
+
this.template = template;
|
|
918
529
|
this.props = props;
|
|
919
530
|
this.key = key;
|
|
920
|
-
|
|
921
|
-
this.
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
get isConnected() {
|
|
937
|
-
var _a, _b;
|
|
938
|
-
return (_b = (_a = this.rootNode) == null ? void 0 : _a.isConnected) != null ? _b : false;
|
|
939
|
-
}
|
|
940
|
-
inheritNode(node) {
|
|
941
|
-
this.context = node.context;
|
|
942
|
-
this.hooks = node.hooks;
|
|
943
|
-
Object.assign(this.proxyProps, node.proxyProps);
|
|
944
|
-
this.rootNode = node.rootNode;
|
|
945
|
-
this.trackMap = node.trackMap;
|
|
946
|
-
const props = this.props;
|
|
947
|
-
this.props = node.props;
|
|
948
|
-
this.patchProps(props);
|
|
949
|
-
}
|
|
950
|
-
mount(parent, before) {
|
|
951
|
-
var _a, _b, _c, _d;
|
|
952
|
-
if (!isFunction(this.template)) {
|
|
953
|
-
throw new Error("Template must be a function");
|
|
954
|
-
}
|
|
955
|
-
if (this.isConnected) {
|
|
956
|
-
return (_b = (_a = this.rootNode) == null ? void 0 : _a.mount(parent, before)) != null ? _b : [];
|
|
531
|
+
enterComponent(template, componentIndex);
|
|
532
|
+
if (isArray(this.template)) {
|
|
533
|
+
const PLACEHOLDER = " __PLACEHOLDER__ ";
|
|
534
|
+
const htmlString = this.template.join(PLACEHOLDER);
|
|
535
|
+
const processedString = htmlString.replaceAll(/(<[^>]+>)|([^<]+)/g, (match, p1, p2) => {
|
|
536
|
+
if (p1) {
|
|
537
|
+
if (p1.includes("data-ci")) return match;
|
|
538
|
+
return p1.replace(/<\s*([\da-z]+)(\s[^>]*)?>/i, (_2, tagName, attrs) => {
|
|
539
|
+
return `<${tagName} data-ci="${componentIndex}"${attrs || ""}>`;
|
|
540
|
+
});
|
|
541
|
+
} else if (p2 && p2.replace(PLACEHOLDER, "").trim()) {
|
|
542
|
+
return `<!--${0}-${componentIndex}-->${p2}<!$>`;
|
|
543
|
+
}
|
|
544
|
+
return match;
|
|
545
|
+
});
|
|
546
|
+
this.template = processedString.split(PLACEHOLDER);
|
|
957
547
|
}
|
|
548
|
+
}
|
|
549
|
+
mount() {
|
|
958
550
|
this.initRef();
|
|
959
|
-
|
|
551
|
+
const output = this.render();
|
|
960
552
|
this.removeRef();
|
|
961
|
-
|
|
962
|
-
const mountedNode = (_d = (_c = this.rootNode) == null ? void 0 : _c.mount(parent, before)) != null ? _d : [];
|
|
963
|
-
this.hooks.mounted.forEach((handler) => handler());
|
|
964
|
-
this.patchProps(this.props);
|
|
965
|
-
return mountedNode;
|
|
966
|
-
}
|
|
967
|
-
unmount() {
|
|
968
|
-
var _a;
|
|
969
|
-
this.hooks.destroy.forEach((handler) => handler());
|
|
970
|
-
Object.values(this.hooks).forEach((set) => set.clear());
|
|
971
|
-
(_a = this.rootNode) == null ? void 0 : _a.unmount();
|
|
972
|
-
this.rootNode = null;
|
|
973
|
-
this.proxyProps = {};
|
|
974
|
-
this.mounted = false;
|
|
975
|
-
this.emitter.forEach((emitter) => emitter());
|
|
553
|
+
return output;
|
|
976
554
|
}
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
track2.cleanup();
|
|
555
|
+
render() {
|
|
556
|
+
if (isFunction(this.template)) {
|
|
557
|
+
const root = this.template(this.props);
|
|
558
|
+
if (isSSGNode(root)) {
|
|
559
|
+
return root.mount();
|
|
560
|
+
} else {
|
|
561
|
+
return String(root);
|
|
562
|
+
}
|
|
986
563
|
}
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
props[key].value = (_b = this.rootNode) == null ? void 0 : _b.nodes[0];
|
|
999
|
-
} else if (startsWith(key, "update")) {
|
|
1000
|
-
props[key] = isSignal(prop) ? prop.value : prop;
|
|
1001
|
-
} else if (key !== "children") {
|
|
1002
|
-
const newValue = (_d = (_c = this.proxyProps)[key]) != null ? _d : _c[key] = useSignal(prop);
|
|
1003
|
-
const track2 = this.getNodeTrack(key);
|
|
1004
|
-
track2.cleanup = useEffect(() => {
|
|
1005
|
-
newValue.value = isFunction(prop) ? prop() : prop;
|
|
564
|
+
const template = this.template;
|
|
565
|
+
Object.keys(this.props).forEach((key) => {
|
|
566
|
+
const cur = this.props[key];
|
|
567
|
+
const childrens = cur.children;
|
|
568
|
+
normalizeProp(cur);
|
|
569
|
+
const findIndex = template.findIndex((t) => t.includes(`data-hk="${key}"`));
|
|
570
|
+
if (childrens) {
|
|
571
|
+
childrens.forEach(([child]) => {
|
|
572
|
+
componentIndex++;
|
|
573
|
+
const children = renderChildren(child, cur);
|
|
574
|
+
this.template[findIndex] += children;
|
|
1006
575
|
});
|
|
1007
576
|
}
|
|
1008
|
-
|
|
1009
|
-
|
|
577
|
+
this.template[findIndex].replaceAll(
|
|
578
|
+
`data-hk="${key}"`,
|
|
579
|
+
`data-hk="${key}" ${generateAttributes(cur)}`
|
|
580
|
+
);
|
|
581
|
+
});
|
|
582
|
+
return template.join("");
|
|
1010
583
|
}
|
|
1011
584
|
};
|
|
1012
|
-
function
|
|
1013
|
-
|
|
1014
|
-
if (
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
if (_template === "") {
|
|
1021
|
-
props = {
|
|
1022
|
-
0: props
|
|
1023
|
-
};
|
|
585
|
+
function normalizeProp(props) {
|
|
586
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
587
|
+
if (key === "children") {
|
|
588
|
+
delete props[key];
|
|
589
|
+
} else if (isFunction(value)) {
|
|
590
|
+
delete props[key];
|
|
591
|
+
} else if (h(value)) {
|
|
592
|
+
props[key] = value.value;
|
|
1024
593
|
}
|
|
1025
|
-
|
|
1026
|
-
}
|
|
1027
|
-
return isFunction(_template) ? new ComponentNode(_template, props, key) : new TemplateNode(_template, props, key);
|
|
1028
|
-
}
|
|
1029
|
-
function isComponent(node) {
|
|
1030
|
-
return node instanceof ComponentNode;
|
|
1031
|
-
}
|
|
1032
|
-
function isJsxElement(node) {
|
|
1033
|
-
return node instanceof ComponentNode || node instanceof TemplateNode;
|
|
1034
|
-
}
|
|
1035
|
-
function template(html) {
|
|
1036
|
-
const template2 = document.createElement("template");
|
|
1037
|
-
template2.innerHTML = closeHtmlTags(html);
|
|
1038
|
-
return template2;
|
|
1039
|
-
}
|
|
1040
|
-
function Fragment(props) {
|
|
1041
|
-
return props.children;
|
|
594
|
+
});
|
|
1042
595
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
596
|
+
function generateAttributes(props) {
|
|
597
|
+
return Object.entries(props).filter(([key, value]) => key !== "children" && !isFunction(value)).map(([key, value]) => `${key}="${escape(String(value))}"`).join(" ");
|
|
598
|
+
}
|
|
599
|
+
function renderChildren(children, prop) {
|
|
600
|
+
if (isFunction(children)) {
|
|
601
|
+
return renderChildren(children(prop), prop);
|
|
602
|
+
} else if (h(children)) {
|
|
603
|
+
return `<!--${1}-${componentIndex}-->${children.value}<!$>`;
|
|
604
|
+
} else if (isSSGNode(children)) {
|
|
605
|
+
const childResult = children.mount();
|
|
606
|
+
return isFunction(childResult) ? childResult(prop) : extractSignal(childResult);
|
|
607
|
+
} else {
|
|
608
|
+
return `<!--${1}-${componentIndex}-->${children}<!$>`;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
var selfClosingTags = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr".split(",");
|
|
612
|
+
var htmlTags = "a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,command,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,menu,menuitem,meta,meter,nav,nobr,noframes,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,pre,progress,q,rb,rp,rt,rtc,ruby,s,samp,script,section,select,shadow,small,source,spacer,span,strike,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,xmp".split(
|
|
613
|
+
","
|
|
614
|
+
);
|
|
1045
615
|
function coerceNode(data) {
|
|
1046
|
-
if (isJsxElement(data) || data instanceof Node) {
|
|
616
|
+
if (isJsxElement(data) || data instanceof Node || isSSGNode(data)) {
|
|
1047
617
|
return data;
|
|
1048
618
|
}
|
|
1049
619
|
const text = isFalsy(data) ? "" : String(data);
|
|
@@ -1051,11 +621,12 @@ function coerceNode(data) {
|
|
|
1051
621
|
}
|
|
1052
622
|
function insertChild(parent, child, before = null) {
|
|
1053
623
|
const beforeNode = isJsxElement(before) ? before.firstChild : before;
|
|
624
|
+
const ssr = renderContext.isSSR;
|
|
1054
625
|
if (isJsxElement(child)) {
|
|
1055
626
|
child.mount(parent, beforeNode);
|
|
1056
|
-
} else if (beforeNode) {
|
|
627
|
+
} else if (beforeNode && !ssr) {
|
|
1057
628
|
beforeNode.before(child);
|
|
1058
|
-
} else {
|
|
629
|
+
} else if (!ssr) {
|
|
1059
630
|
parent.append(child);
|
|
1060
631
|
}
|
|
1061
632
|
}
|
|
@@ -1077,7 +648,7 @@ function setAttribute(element, attr, value) {
|
|
|
1077
648
|
if (attr === "class") {
|
|
1078
649
|
if (typeof value === "string") {
|
|
1079
650
|
element.className = value;
|
|
1080
|
-
} else if (
|
|
651
|
+
} else if (isArray(value)) {
|
|
1081
652
|
element.className = value.join(" ");
|
|
1082
653
|
} else if (value && typeof value === "object") {
|
|
1083
654
|
element.className = Object.entries(value).reduce((acc, [key, value2]) => acc + (value2 ? ` ${key}` : ""), "").trim();
|
|
@@ -1100,14 +671,14 @@ function setAttribute(element, attr, value) {
|
|
|
1100
671
|
} else if (value === true) {
|
|
1101
672
|
element.setAttribute(attr, "");
|
|
1102
673
|
} else {
|
|
1103
|
-
if (element instanceof HTMLInputElement) {
|
|
674
|
+
if (element instanceof HTMLInputElement && attr === "value") {
|
|
1104
675
|
element.value = String(value);
|
|
1105
676
|
} else {
|
|
1106
677
|
element.setAttribute(attr, String(value));
|
|
1107
678
|
}
|
|
1108
679
|
}
|
|
1109
680
|
}
|
|
1110
|
-
function
|
|
681
|
+
function bindNode(node, setter) {
|
|
1111
682
|
if (node instanceof HTMLInputElement) {
|
|
1112
683
|
switch (node.type) {
|
|
1113
684
|
case "checkbox":
|
|
@@ -1150,16 +721,12 @@ function binNode(node, setter) {
|
|
|
1150
721
|
});
|
|
1151
722
|
}
|
|
1152
723
|
}
|
|
1153
|
-
|
|
1154
|
-
function nextTick2(fn) {
|
|
1155
|
-
return fn ? p2.then(fn) : p2;
|
|
1156
|
-
}
|
|
724
|
+
Promise.resolve();
|
|
1157
725
|
function addEventListener(node, eventName, handler) {
|
|
1158
726
|
node.addEventListener(eventName, handler);
|
|
1159
727
|
return () => node.removeEventListener(eventName, handler);
|
|
1160
728
|
}
|
|
1161
729
|
function closeHtmlTags(input) {
|
|
1162
|
-
const selfClosingTagList = selfClosingTags.split(",");
|
|
1163
730
|
const tagStack = [];
|
|
1164
731
|
const output = [];
|
|
1165
732
|
const tagPattern = /<\/?([\da-z-]+)([^>]*)>/gi;
|
|
@@ -1181,7 +748,7 @@ function closeHtmlTags(input) {
|
|
|
1181
748
|
if (tagStack.length > 0) {
|
|
1182
749
|
tagStack.pop();
|
|
1183
750
|
}
|
|
1184
|
-
} else if (!
|
|
751
|
+
} else if (!selfClosingTags.includes(tagName)) {
|
|
1185
752
|
tagStack.push(tagName);
|
|
1186
753
|
}
|
|
1187
754
|
output.push(fullMatch);
|
|
@@ -1196,44 +763,145 @@ function closeHtmlTags(input) {
|
|
|
1196
763
|
return output.join("");
|
|
1197
764
|
}
|
|
1198
765
|
function isHtmlTagName(tagName) {
|
|
1199
|
-
|
|
1200
|
-
return htmlTagsList.includes(tagName);
|
|
766
|
+
return htmlTags.includes(tagName);
|
|
1201
767
|
}
|
|
1202
768
|
function convertToHtmlTag(tagName) {
|
|
1203
|
-
|
|
1204
|
-
if (selfClosingTagList.includes(tagName)) {
|
|
769
|
+
if (selfClosingTags.includes(tagName)) {
|
|
1205
770
|
return `<${tagName}/>`;
|
|
1206
771
|
} else {
|
|
1207
772
|
return `<${tagName}></${tagName}>`;
|
|
1208
773
|
}
|
|
1209
774
|
}
|
|
775
|
+
function extractSignal(signal) {
|
|
776
|
+
if (h(signal)) {
|
|
777
|
+
return signal.value;
|
|
778
|
+
} else {
|
|
779
|
+
return signal;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
var ComponentNode = class extends LifecycleContext {
|
|
783
|
+
constructor(template, props, key) {
|
|
784
|
+
super();
|
|
785
|
+
this.template = template;
|
|
786
|
+
this.props = props;
|
|
787
|
+
this.key = key;
|
|
788
|
+
this.emitter = /* @__PURE__ */ new Set();
|
|
789
|
+
this.rootNode = null;
|
|
790
|
+
this.trackMap = /* @__PURE__ */ new Map();
|
|
791
|
+
this.proxyProps = props ? L(
|
|
792
|
+
props,
|
|
793
|
+
(key2) => startsWith(key2, "on") || startsWith(key2, "update") || key2 === "children"
|
|
794
|
+
) : {};
|
|
795
|
+
}
|
|
796
|
+
get firstChild() {
|
|
797
|
+
var _a, _b;
|
|
798
|
+
return (_b = (_a = this.rootNode) == null ? void 0 : _a.firstChild) != null ? _b : null;
|
|
799
|
+
}
|
|
800
|
+
get isConnected() {
|
|
801
|
+
var _a, _b;
|
|
802
|
+
return (_b = (_a = this.rootNode) == null ? void 0 : _a.isConnected) != null ? _b : false;
|
|
803
|
+
}
|
|
804
|
+
mount(parent, before) {
|
|
805
|
+
var _a, _b, _c, _d;
|
|
806
|
+
if (!isFunction(this.template)) {
|
|
807
|
+
throw new Error("Template must be a function");
|
|
808
|
+
}
|
|
809
|
+
if (this.isConnected) {
|
|
810
|
+
return (_b = (_a = this.rootNode) == null ? void 0 : _a.mount(parent, before)) != null ? _b : [];
|
|
811
|
+
}
|
|
812
|
+
this.initRef();
|
|
813
|
+
this.rootNode = this.template(this.proxyProps);
|
|
814
|
+
const mountedNode = (_d = (_c = this.rootNode) == null ? void 0 : _c.mount(parent, before)) != null ? _d : [];
|
|
815
|
+
this.hooks.mounted.forEach((handler) => handler());
|
|
816
|
+
this.patchProps(this.props);
|
|
817
|
+
this.removeRef();
|
|
818
|
+
return mountedNode;
|
|
819
|
+
}
|
|
820
|
+
unmount() {
|
|
821
|
+
var _a;
|
|
822
|
+
this.hooks.destroy.forEach((handler) => handler());
|
|
823
|
+
this.clearHooks();
|
|
824
|
+
(_a = this.rootNode) == null ? void 0 : _a.unmount();
|
|
825
|
+
this.rootNode = null;
|
|
826
|
+
this.proxyProps = {};
|
|
827
|
+
for (const cleanup of this.emitter) {
|
|
828
|
+
cleanup();
|
|
829
|
+
}
|
|
830
|
+
this.emitter.clear();
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Inherit props and state from another ComponentNode.
|
|
834
|
+
* It will:
|
|
835
|
+
* 1. Copy props from the node to this proxyProps.
|
|
836
|
+
* 2. Copy the rootNode, trackMap and hooks from the node.
|
|
837
|
+
* 3. Copy the props from the node to this.
|
|
838
|
+
* 4. Patch props from the props passed in the constructor.
|
|
839
|
+
* @param node The node to inherit from.
|
|
840
|
+
*/
|
|
841
|
+
inheritNode(node) {
|
|
842
|
+
Object.assign(this.proxyProps, node.proxyProps);
|
|
843
|
+
this.rootNode = node.rootNode;
|
|
844
|
+
this.trackMap = node.trackMap;
|
|
845
|
+
this.hooks = node.hooks;
|
|
846
|
+
const props = this.props;
|
|
847
|
+
this.props = node.props;
|
|
848
|
+
this.patchProps(props);
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Get a NodeTrack from the trackMap. If the track is not in the trackMap, create a new one.
|
|
852
|
+
* Then, call the cleanup function to remove any previously registered hooks.
|
|
853
|
+
* @param trackKey the key of the node track to get.
|
|
854
|
+
* @returns the NodeTrack, cleaned up and ready to use.
|
|
855
|
+
*/
|
|
856
|
+
getNodeTrack(trackKey) {
|
|
857
|
+
let track = this.trackMap.get(trackKey);
|
|
858
|
+
if (!track) {
|
|
859
|
+
track = { cleanup: () => {
|
|
860
|
+
} };
|
|
861
|
+
this.trackMap.set(trackKey, track);
|
|
862
|
+
}
|
|
863
|
+
track.cleanup();
|
|
864
|
+
return track;
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Patch the props of this node.
|
|
868
|
+
* It will:
|
|
869
|
+
* 1. Iterate the props and patch it.
|
|
870
|
+
* 2. If the prop is a event handler, add a event listener to the first child of the node.
|
|
871
|
+
* 3. If the prop is a ref, set the first child of the node to the ref.
|
|
872
|
+
* 4. If the prop is a update handler, update the prop in the node's props.
|
|
873
|
+
* 5. If the prop is a normal prop, create a signal for it and then patch it.
|
|
874
|
+
* @param props The props to patch.
|
|
875
|
+
*/
|
|
876
|
+
patchProps(props) {
|
|
877
|
+
var _a, _b;
|
|
878
|
+
if (!props) {
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
for (const [key, prop] of Object.entries(props)) {
|
|
882
|
+
if (startsWith(key, "on") && ((_a = this.rootNode) == null ? void 0 : _a.firstChild)) {
|
|
883
|
+
const event = key.slice(2).toLowerCase();
|
|
884
|
+
const cleanup = addEventListener(this.rootNode.nodes[0], event, prop);
|
|
885
|
+
this.emitter.add(cleanup);
|
|
886
|
+
} else if (key === "ref") {
|
|
887
|
+
prop.value = (_b = this.rootNode) == null ? void 0 : _b.firstChild;
|
|
888
|
+
} else if (startsWith(key, "update")) {
|
|
889
|
+
this.props[key] = extractSignal(prop);
|
|
890
|
+
} else if (key !== "children") {
|
|
891
|
+
const track = this.getNodeTrack(key);
|
|
892
|
+
track.cleanup = B(() => {
|
|
893
|
+
this.proxyProps[key] = isFunction(prop) ? prop() : prop;
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
this.props = props;
|
|
898
|
+
}
|
|
899
|
+
};
|
|
1210
900
|
function patchChildren(parent, childrenMap, nextChildren, before) {
|
|
1211
901
|
const result = /* @__PURE__ */ new Map();
|
|
1212
902
|
const children = Array.from(childrenMap.values());
|
|
1213
|
-
const childrenLength = children.length;
|
|
1214
903
|
if (childrenMap.size > 0 && nextChildren.length === 0) {
|
|
1215
|
-
|
|
1216
|
-
parent.innerHTML = "";
|
|
1217
|
-
if (before) {
|
|
1218
|
-
insertChild(parent, before);
|
|
1219
|
-
}
|
|
1220
|
-
} else {
|
|
1221
|
-
const range = document.createRange();
|
|
1222
|
-
const child = children[0];
|
|
1223
|
-
const start = isJsxElement(child) ? child.firstChild : child;
|
|
1224
|
-
range.setStartBefore(start);
|
|
1225
|
-
if (before) {
|
|
1226
|
-
range.setEndBefore(before);
|
|
1227
|
-
} else {
|
|
1228
|
-
range.setEndAfter(parent);
|
|
1229
|
-
}
|
|
1230
|
-
range.deleteContents();
|
|
1231
|
-
}
|
|
1232
|
-
children.forEach((node) => {
|
|
1233
|
-
if (isJsxElement(node)) {
|
|
1234
|
-
node.unmount();
|
|
1235
|
-
}
|
|
1236
|
-
});
|
|
904
|
+
clearChildren(parent, children, before);
|
|
1237
905
|
return result;
|
|
1238
906
|
}
|
|
1239
907
|
const replaces = [];
|
|
@@ -1274,6 +942,30 @@ function patchChildren(parent, childrenMap, nextChildren, before) {
|
|
|
1274
942
|
});
|
|
1275
943
|
return result;
|
|
1276
944
|
}
|
|
945
|
+
function clearChildren(parent, children, before) {
|
|
946
|
+
if (parent.childNodes.length === children.length + (before ? 1 : 0)) {
|
|
947
|
+
parent.innerHTML = "";
|
|
948
|
+
if (before) {
|
|
949
|
+
insertChild(parent, before);
|
|
950
|
+
}
|
|
951
|
+
} else {
|
|
952
|
+
const range = document.createRange();
|
|
953
|
+
const child = children[0];
|
|
954
|
+
const start = isJsxElement(child) ? child.firstChild : child;
|
|
955
|
+
range.setStartBefore(start);
|
|
956
|
+
if (before) {
|
|
957
|
+
range.setEndBefore(before);
|
|
958
|
+
} else {
|
|
959
|
+
range.setEndAfter(parent);
|
|
960
|
+
}
|
|
961
|
+
range.deleteContents();
|
|
962
|
+
}
|
|
963
|
+
children.forEach((node) => {
|
|
964
|
+
if (isJsxElement(node)) {
|
|
965
|
+
node.unmount();
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
}
|
|
1277
969
|
function patch(parent, node, next) {
|
|
1278
970
|
if (node === next) {
|
|
1279
971
|
return node;
|
|
@@ -1308,30 +1000,34 @@ function getKey(node, index) {
|
|
|
1308
1000
|
}
|
|
1309
1001
|
return `_$${index}$`;
|
|
1310
1002
|
}
|
|
1311
|
-
var TemplateNode = class
|
|
1312
|
-
constructor(
|
|
1313
|
-
this.template =
|
|
1003
|
+
var TemplateNode = class {
|
|
1004
|
+
constructor(template, props, key) {
|
|
1005
|
+
this.template = template;
|
|
1314
1006
|
this.props = props;
|
|
1315
1007
|
this.key = key;
|
|
1316
1008
|
this.treeMap = /* @__PURE__ */ new Map();
|
|
1317
1009
|
this.mounted = false;
|
|
1318
1010
|
this.nodes = [];
|
|
1319
|
-
this.provides = {};
|
|
1320
1011
|
this.trackMap = /* @__PURE__ */ new Map();
|
|
1012
|
+
this.bindValueKeys = [];
|
|
1321
1013
|
this.parent = null;
|
|
1322
|
-
this.key
|
|
1014
|
+
this.key || (this.key = props == null ? void 0 : props.key);
|
|
1015
|
+
if (renderContext.isSSR) {
|
|
1016
|
+
this.componentIndex = getComponentIndex(this.template);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
addEventListener() {
|
|
1020
|
+
}
|
|
1021
|
+
removeEventListener() {
|
|
1323
1022
|
}
|
|
1324
1023
|
get firstChild() {
|
|
1325
1024
|
var _a;
|
|
1326
1025
|
return (_a = this.nodes[0]) != null ? _a : null;
|
|
1327
1026
|
}
|
|
1027
|
+
// is mounted
|
|
1328
1028
|
get isConnected() {
|
|
1329
1029
|
return this.mounted;
|
|
1330
1030
|
}
|
|
1331
|
-
addEventListener() {
|
|
1332
|
-
}
|
|
1333
|
-
removeEventListener() {
|
|
1334
|
-
}
|
|
1335
1031
|
mount(parent, before) {
|
|
1336
1032
|
var _a;
|
|
1337
1033
|
this.parent = parent;
|
|
@@ -1339,6 +1035,9 @@ var TemplateNode = class _TemplateNode {
|
|
|
1339
1035
|
this.nodes.forEach((node) => insertChild(parent, node, before));
|
|
1340
1036
|
return this.nodes;
|
|
1341
1037
|
}
|
|
1038
|
+
if (isArray(this.template)) {
|
|
1039
|
+
this.template = createTemplate(this.template.join(""));
|
|
1040
|
+
}
|
|
1342
1041
|
const cloneNode = this.template.content.cloneNode(true);
|
|
1343
1042
|
const firstChild = cloneNode.firstChild;
|
|
1344
1043
|
if ((_a = firstChild == null ? void 0 : firstChild.hasAttribute) == null ? void 0 : _a.call(firstChild, "_svg_")) {
|
|
@@ -1348,23 +1047,20 @@ var TemplateNode = class _TemplateNode {
|
|
|
1348
1047
|
});
|
|
1349
1048
|
}
|
|
1350
1049
|
this.nodes = Array.from(cloneNode.childNodes);
|
|
1351
|
-
|
|
1050
|
+
if (renderContext.isSSR) {
|
|
1051
|
+
this.mapSSGNodeTree(parent);
|
|
1052
|
+
} else {
|
|
1053
|
+
this.mapNodeTree(parent, cloneNode);
|
|
1054
|
+
}
|
|
1352
1055
|
insertChild(parent, cloneNode, before);
|
|
1353
|
-
this.
|
|
1056
|
+
this.patchProps(this.props);
|
|
1354
1057
|
this.mounted = true;
|
|
1355
1058
|
return this.nodes;
|
|
1356
1059
|
}
|
|
1357
1060
|
unmount() {
|
|
1358
|
-
this.trackMap.forEach((
|
|
1359
|
-
var _a
|
|
1360
|
-
(_a =
|
|
1361
|
-
(_b = track2.lastNodes) == null ? void 0 : _b.forEach((node) => {
|
|
1362
|
-
if (track2.isRoot) {
|
|
1363
|
-
removeChild(node);
|
|
1364
|
-
} else if (node instanceof _TemplateNode) {
|
|
1365
|
-
node.unmount();
|
|
1366
|
-
}
|
|
1367
|
-
});
|
|
1061
|
+
this.trackMap.forEach((track) => {
|
|
1062
|
+
var _a;
|
|
1063
|
+
(_a = track.cleanup) == null ? void 0 : _a.call(track);
|
|
1368
1064
|
});
|
|
1369
1065
|
this.trackMap.clear();
|
|
1370
1066
|
this.treeMap.clear();
|
|
@@ -1372,6 +1068,52 @@ var TemplateNode = class _TemplateNode {
|
|
|
1372
1068
|
this.nodes = [];
|
|
1373
1069
|
this.mounted = false;
|
|
1374
1070
|
}
|
|
1071
|
+
patchProps(props) {
|
|
1072
|
+
if (!props) return;
|
|
1073
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
1074
|
+
const index = Number(key);
|
|
1075
|
+
const node = this.treeMap.get(index);
|
|
1076
|
+
if (node) {
|
|
1077
|
+
this.patchProp(key, node, value, index === 0);
|
|
1078
|
+
}
|
|
1079
|
+
});
|
|
1080
|
+
this.props = props;
|
|
1081
|
+
}
|
|
1082
|
+
inheritNode(node) {
|
|
1083
|
+
this.mounted = node.mounted;
|
|
1084
|
+
this.nodes = node.nodes;
|
|
1085
|
+
this.trackMap = node.trackMap;
|
|
1086
|
+
this.treeMap = node.treeMap;
|
|
1087
|
+
const props = this.props;
|
|
1088
|
+
this.props = node.props;
|
|
1089
|
+
this.patchProps(props);
|
|
1090
|
+
}
|
|
1091
|
+
mapSSGNodeTree(parent) {
|
|
1092
|
+
this.treeMap.set(0, parent);
|
|
1093
|
+
const walk = (node) => {
|
|
1094
|
+
var _a;
|
|
1095
|
+
if (node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) {
|
|
1096
|
+
if (node.nodeType === Node.COMMENT_NODE) {
|
|
1097
|
+
const [type, index] = ((_a = node.textContent) == null ? void 0 : _a.split("-")) || "";
|
|
1098
|
+
if (0 === +type && +index === this.componentIndex) {
|
|
1099
|
+
const textNode = node.nextSibling;
|
|
1100
|
+
this.treeMap.set(+index, textNode);
|
|
1101
|
+
}
|
|
1102
|
+
} else if (node.nodeType !== Node.TEXT_NODE) {
|
|
1103
|
+
const { ci = "-1", hk } = (node == null ? void 0 : node.dataset) || {};
|
|
1104
|
+
if (hk && +ci === this.componentIndex) {
|
|
1105
|
+
this.treeMap.set(+hk, node);
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
let child = node.firstChild;
|
|
1110
|
+
while (child) {
|
|
1111
|
+
walk(child);
|
|
1112
|
+
child = child.nextSibling;
|
|
1113
|
+
}
|
|
1114
|
+
};
|
|
1115
|
+
walk(parent);
|
|
1116
|
+
}
|
|
1375
1117
|
mapNodeTree(parent, tree) {
|
|
1376
1118
|
let index = 1;
|
|
1377
1119
|
this.treeMap.set(0, parent);
|
|
@@ -1387,84 +1129,78 @@ var TemplateNode = class _TemplateNode {
|
|
|
1387
1129
|
};
|
|
1388
1130
|
walk(tree);
|
|
1389
1131
|
}
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
}
|
|
1399
|
-
this.props = props;
|
|
1400
|
-
}
|
|
1132
|
+
/**
|
|
1133
|
+
* Get a NodeTrack from the trackMap. If the track is not in the trackMap, create a new one.
|
|
1134
|
+
* Then, call the cleanup function to remove any previously registered hooks.
|
|
1135
|
+
* @param trackKey the key of the node track to get.
|
|
1136
|
+
* @param trackLastNodes if true, the track will record the last nodes it has rendered.
|
|
1137
|
+
* @param isRoot if true, the track will be treated as a root track.
|
|
1138
|
+
* @returns the NodeTrack, cleaned up and ready to use.
|
|
1139
|
+
*/
|
|
1401
1140
|
getNodeTrack(trackKey, trackLastNodes, isRoot) {
|
|
1402
1141
|
var _a;
|
|
1403
|
-
let
|
|
1404
|
-
if (!
|
|
1405
|
-
|
|
1142
|
+
let track = this.trackMap.get(trackKey);
|
|
1143
|
+
if (!track) {
|
|
1144
|
+
track = { cleanup: () => {
|
|
1406
1145
|
} };
|
|
1407
1146
|
if (trackLastNodes) {
|
|
1408
|
-
|
|
1147
|
+
track.lastNodes = /* @__PURE__ */ new Map();
|
|
1409
1148
|
}
|
|
1410
1149
|
if (isRoot) {
|
|
1411
|
-
|
|
1150
|
+
track.isRoot = true;
|
|
1412
1151
|
}
|
|
1413
|
-
this.trackMap.set(trackKey,
|
|
1152
|
+
this.trackMap.set(trackKey, track);
|
|
1414
1153
|
}
|
|
1415
|
-
(_a =
|
|
1416
|
-
return
|
|
1417
|
-
}
|
|
1418
|
-
inheritNode(node) {
|
|
1419
|
-
this.mounted = node.mounted;
|
|
1420
|
-
this.nodes = node.nodes;
|
|
1421
|
-
this.trackMap = node.trackMap;
|
|
1422
|
-
this.treeMap = node.treeMap;
|
|
1423
|
-
const props = this.props;
|
|
1424
|
-
this.props = node.props;
|
|
1425
|
-
this.patchNodes(props);
|
|
1154
|
+
(_a = track.cleanup) == null ? void 0 : _a.call(track);
|
|
1155
|
+
return track;
|
|
1426
1156
|
}
|
|
1427
|
-
|
|
1157
|
+
patchProp(key, node, props, isRoot) {
|
|
1428
1158
|
for (const attr in props) {
|
|
1429
1159
|
if (attr === "children" && props.children) {
|
|
1430
1160
|
if (!isArray(props.children)) {
|
|
1431
1161
|
const trackKey = `${key}:${attr}:${0}`;
|
|
1432
|
-
const
|
|
1433
|
-
patchChild(
|
|
1162
|
+
const track = this.getNodeTrack(trackKey, true, isRoot);
|
|
1163
|
+
patchChild(track, node, props.children, null);
|
|
1434
1164
|
} else {
|
|
1435
1165
|
props.children.filter(Boolean).forEach((item, index) => {
|
|
1436
1166
|
var _a;
|
|
1437
1167
|
const [child, path] = isArray(item) ? item : [item, null];
|
|
1438
1168
|
const before = isNil(path) ? null : (_a = this.treeMap.get(path)) != null ? _a : null;
|
|
1439
1169
|
const trackKey = `${key}:${attr}:${index}`;
|
|
1440
|
-
const
|
|
1441
|
-
patchChild(
|
|
1170
|
+
const track = this.getNodeTrack(trackKey, true, isRoot);
|
|
1171
|
+
patchChild(track, node, child, before);
|
|
1442
1172
|
});
|
|
1443
1173
|
}
|
|
1444
1174
|
} else if (attr === "ref") {
|
|
1445
1175
|
props[attr].value = node;
|
|
1446
1176
|
} else if (startsWith(attr, "on")) {
|
|
1447
1177
|
const eventName = attr.slice(2).toLocaleLowerCase();
|
|
1448
|
-
const
|
|
1178
|
+
const track = this.getNodeTrack(`${key}:${attr}`);
|
|
1449
1179
|
const listener = props[attr];
|
|
1450
|
-
|
|
1451
|
-
} else
|
|
1452
|
-
const
|
|
1180
|
+
track.cleanup = addEventListener(node, eventName, listener);
|
|
1181
|
+
} else {
|
|
1182
|
+
const updateKey = `update${capitalizeFirstLetter(attr)}`;
|
|
1183
|
+
if (this.bindValueKeys.includes(attr)) {
|
|
1184
|
+
break;
|
|
1185
|
+
}
|
|
1186
|
+
if (props[updateKey]) {
|
|
1187
|
+
this.bindValueKeys.push(updateKey);
|
|
1188
|
+
}
|
|
1189
|
+
const track = this.getNodeTrack(`${key}:${attr}`);
|
|
1453
1190
|
const val = props[attr];
|
|
1454
|
-
const triggerValue =
|
|
1455
|
-
patchAttribute(
|
|
1456
|
-
const cleanup =
|
|
1457
|
-
triggerValue.value =
|
|
1458
|
-
patchAttribute(
|
|
1191
|
+
const triggerValue = h(val) ? val : le(val);
|
|
1192
|
+
patchAttribute(track, node, attr, triggerValue.value);
|
|
1193
|
+
const cleanup = B(() => {
|
|
1194
|
+
triggerValue.value = h(val) ? val.value : val;
|
|
1195
|
+
patchAttribute(track, node, attr, triggerValue.value);
|
|
1459
1196
|
});
|
|
1460
1197
|
let cleanupBind;
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
cleanupBind = binNode(node, (value) => {
|
|
1198
|
+
if (props[updateKey] && !isComponent(attr)) {
|
|
1199
|
+
cleanupBind = bindNode(node, (value) => {
|
|
1464
1200
|
props[updateKey](value);
|
|
1465
1201
|
});
|
|
1466
1202
|
}
|
|
1467
|
-
|
|
1203
|
+
track.cleanup = () => {
|
|
1468
1204
|
cleanup && cleanup();
|
|
1469
1205
|
cleanupBind && cleanupBind();
|
|
1470
1206
|
};
|
|
@@ -1472,178 +1208,144 @@ var TemplateNode = class _TemplateNode {
|
|
|
1472
1208
|
}
|
|
1473
1209
|
}
|
|
1474
1210
|
};
|
|
1475
|
-
function
|
|
1211
|
+
function patchChild(track, parent, child, before) {
|
|
1212
|
+
if (isFunction(child)) {
|
|
1213
|
+
track.cleanup = B(() => {
|
|
1214
|
+
const nextNodes = coerceArray(child()).map(coerceNode);
|
|
1215
|
+
if (renderContext.isSSR) {
|
|
1216
|
+
track.lastNodes = reconcileChildren(parent, nextNodes, before);
|
|
1217
|
+
} else {
|
|
1218
|
+
track.lastNodes = patchChildren(parent, track.lastNodes, nextNodes, before);
|
|
1219
|
+
}
|
|
1220
|
+
});
|
|
1221
|
+
} else {
|
|
1222
|
+
coerceArray(child).forEach((node, index) => {
|
|
1223
|
+
const newNode = coerceNode(node);
|
|
1224
|
+
const key = getKey(newNode, index);
|
|
1225
|
+
if (renderContext.isSSR) {
|
|
1226
|
+
track.lastNodes = reconcileChildren(parent, [newNode], before);
|
|
1227
|
+
} else {
|
|
1228
|
+
track.lastNodes.set(key, newNode);
|
|
1229
|
+
insertChild(parent, newNode, before);
|
|
1230
|
+
}
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
function reconcileChildren(parent, nextNodes, before) {
|
|
1235
|
+
const result = /* @__PURE__ */ new Map();
|
|
1236
|
+
const textNodes = Array.from(parent.childNodes).filter(
|
|
1237
|
+
(node) => {
|
|
1238
|
+
var _a, _b;
|
|
1239
|
+
return node.nodeType === Node.TEXT_NODE && ((_a = node.previousSibling) == null ? void 0 : _a.nodeType) === Node.COMMENT_NODE && ((_b = node.nextSibling) == null ? void 0 : _b.nodeType) === Node.COMMENT_NODE;
|
|
1240
|
+
}
|
|
1241
|
+
);
|
|
1242
|
+
nextNodes.forEach((node, index) => {
|
|
1243
|
+
const key = getKey(node, index);
|
|
1244
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
1245
|
+
textNodes.forEach((ne2) => {
|
|
1246
|
+
if (node.textContent === ne2.textContent) {
|
|
1247
|
+
parent.replaceChild(node, ne2);
|
|
1248
|
+
}
|
|
1249
|
+
});
|
|
1250
|
+
} else {
|
|
1251
|
+
insertChild(parent, node, before);
|
|
1252
|
+
}
|
|
1253
|
+
result.set(key, node);
|
|
1254
|
+
});
|
|
1255
|
+
return result;
|
|
1256
|
+
}
|
|
1257
|
+
function patchAttribute(track, node, attr, data) {
|
|
1476
1258
|
const element = node;
|
|
1477
1259
|
if (!element.setAttribute) {
|
|
1478
1260
|
return;
|
|
1479
1261
|
}
|
|
1480
1262
|
if (isFunction(data)) {
|
|
1481
|
-
|
|
1263
|
+
track.cleanup = B(() => {
|
|
1482
1264
|
setAttribute(element, attr, data());
|
|
1483
1265
|
});
|
|
1484
1266
|
} else {
|
|
1485
1267
|
setAttribute(element, attr, data);
|
|
1486
1268
|
}
|
|
1487
1269
|
}
|
|
1488
|
-
function
|
|
1489
|
-
if (
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
})
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
track2.lastNodes.set(String(i), newNode);
|
|
1498
|
-
insertChild(parent, newNode, before);
|
|
1499
|
-
});
|
|
1270
|
+
function h2(template, props, key) {
|
|
1271
|
+
if (isString(template)) {
|
|
1272
|
+
if (isHtmlTagName(template)) {
|
|
1273
|
+
template = convertToHtmlTag(template);
|
|
1274
|
+
props = { "1": props };
|
|
1275
|
+
} else if (template === "") {
|
|
1276
|
+
props = { "0": props };
|
|
1277
|
+
}
|
|
1278
|
+
template = createTemplate(template);
|
|
1500
1279
|
}
|
|
1280
|
+
return isFunction(template) ? new ComponentNode(template, props, key) : new TemplateNode(template, props, key);
|
|
1281
|
+
}
|
|
1282
|
+
function isComponent(node) {
|
|
1283
|
+
return node instanceof ComponentNode;
|
|
1284
|
+
}
|
|
1285
|
+
function isJsxElement(node) {
|
|
1286
|
+
return node instanceof ComponentNode || node instanceof TemplateNode;
|
|
1287
|
+
}
|
|
1288
|
+
function createTemplate(html) {
|
|
1289
|
+
const template = document.createElement("template");
|
|
1290
|
+
template.innerHTML = closeHtmlTags(html);
|
|
1291
|
+
return template;
|
|
1292
|
+
}
|
|
1293
|
+
function Fragment(props) {
|
|
1294
|
+
return props.children;
|
|
1501
1295
|
}
|
|
1502
1296
|
function onMount(cb) {
|
|
1503
1297
|
var _a;
|
|
1504
|
-
|
|
1505
|
-
(_a =
|
|
1298
|
+
assertInsideComponent("onMounted");
|
|
1299
|
+
(_a = LifecycleContext.ref) == null ? void 0 : _a.addHook("mounted", cb);
|
|
1506
1300
|
}
|
|
1507
1301
|
function onDestroy(cb) {
|
|
1508
1302
|
var _a;
|
|
1509
|
-
|
|
1510
|
-
(_a =
|
|
1303
|
+
assertInsideComponent("onDestroy");
|
|
1304
|
+
(_a = LifecycleContext.ref) == null ? void 0 : _a.addHook("destroy", cb);
|
|
1511
1305
|
}
|
|
1512
|
-
function
|
|
1513
|
-
if (!
|
|
1306
|
+
function assertInsideComponent(hookName, key) {
|
|
1307
|
+
if (!LifecycleContext.ref && true) {
|
|
1514
1308
|
console.error(
|
|
1515
|
-
`"${
|
|
1309
|
+
`"${hookName}"(key: ${isSymbol(key) ? key.toString() : key}) can only be called within the component function body
|
|
1516
1310
|
and cannot be used in asynchronous or deferred calls.`
|
|
1517
1311
|
);
|
|
1518
1312
|
}
|
|
1519
1313
|
}
|
|
1520
1314
|
function useProvide(key, value) {
|
|
1521
1315
|
var _a;
|
|
1522
|
-
|
|
1523
|
-
(_a =
|
|
1316
|
+
assertInsideComponent("useProvide", key);
|
|
1317
|
+
(_a = LifecycleContext.ref) == null ? void 0 : _a.setContext(key, value);
|
|
1524
1318
|
}
|
|
1525
1319
|
function useInject(key, defaultValue) {
|
|
1526
1320
|
var _a;
|
|
1527
|
-
|
|
1528
|
-
return ((_a =
|
|
1321
|
+
assertInsideComponent("useInject", key);
|
|
1322
|
+
return ((_a = LifecycleContext.ref) == null ? void 0 : _a.getContext(key)) || defaultValue;
|
|
1529
1323
|
}
|
|
1530
1324
|
function useRef() {
|
|
1531
|
-
const ref =
|
|
1325
|
+
const ref = Re(null);
|
|
1532
1326
|
return ref;
|
|
1533
1327
|
}
|
|
1534
|
-
function
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
function normalizeProps(props) {
|
|
1541
|
-
Object.keys(props).forEach((propKey) => {
|
|
1542
|
-
if (isFunction(props[propKey])) {
|
|
1543
|
-
delete props[propKey];
|
|
1544
|
-
}
|
|
1545
|
-
if (isSignal(props[propKey])) {
|
|
1546
|
-
props[propKey] = props[propKey].value;
|
|
1547
|
-
}
|
|
1548
|
-
});
|
|
1328
|
+
function renderToString(component, props) {
|
|
1329
|
+
renderContext.setSSG();
|
|
1330
|
+
const ssrNode = new SSGNode(component, props || {});
|
|
1331
|
+
const html = ssrNode.mount();
|
|
1332
|
+
renderContext.setClient();
|
|
1333
|
+
return html;
|
|
1549
1334
|
}
|
|
1550
|
-
function
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
const mapKey = path ? String(path) : `${key}`;
|
|
1555
|
-
if (!childNodesMap[mapKey]) childNodesMap[mapKey] = [];
|
|
1556
|
-
const childResult = result.mount();
|
|
1557
|
-
childNodesMap[mapKey].push(
|
|
1558
|
-
isFunction(childResult) ? childResult(prop) : isSignal(childResult) ? childResult.value : childResult
|
|
1559
|
-
);
|
|
1560
|
-
} else {
|
|
1561
|
-
tmpl.template += isFunction(result) ? result(prop) : String(result);
|
|
1335
|
+
function hydrate(component, container) {
|
|
1336
|
+
const rootElement = typeof container === "string" ? document.querySelector(container) : container;
|
|
1337
|
+
if (!rootElement) {
|
|
1338
|
+
throw new Error(`Could not find container: ${container}`);
|
|
1562
1339
|
}
|
|
1340
|
+
renderContext.setSSR();
|
|
1341
|
+
h2(component).mount(rootElement);
|
|
1342
|
+
renderContext.setClient();
|
|
1563
1343
|
}
|
|
1564
|
-
var ServerNode = class _ServerNode extends Hooks {
|
|
1565
|
-
constructor(template2, props = {}, key) {
|
|
1566
|
-
super();
|
|
1567
|
-
this.template = template2;
|
|
1568
|
-
this.props = props;
|
|
1569
|
-
this.key = key;
|
|
1570
|
-
this.childNodesMap = {};
|
|
1571
|
-
this.processedTemplates = {};
|
|
1572
|
-
}
|
|
1573
|
-
/**
|
|
1574
|
-
* Mount and render the component
|
|
1575
|
-
*/
|
|
1576
|
-
mount() {
|
|
1577
|
-
this.initRef();
|
|
1578
|
-
const output = this.render();
|
|
1579
|
-
this.removeRef();
|
|
1580
|
-
return output;
|
|
1581
|
-
}
|
|
1582
|
-
/**
|
|
1583
|
-
* Initialize template entries and props
|
|
1584
|
-
*/
|
|
1585
|
-
initTemplates() {
|
|
1586
|
-
const templateCollection = Array.isArray(this.template) ? this.template.reduce((acc, tmpl, index) => {
|
|
1587
|
-
acc[index + 1] = { template: tmpl };
|
|
1588
|
-
return acc;
|
|
1589
|
-
}, {}) : this.template;
|
|
1590
|
-
if (isObject(templateCollection)) {
|
|
1591
|
-
Object.entries(templateCollection).forEach(([key, tmpl]) => {
|
|
1592
|
-
const prop = __spreadValues2({}, this.props[key]);
|
|
1593
|
-
normalizeProps(prop);
|
|
1594
|
-
if (prop.children) {
|
|
1595
|
-
prop.children.forEach((item) => {
|
|
1596
|
-
const [child, path] = isArray(item) ? item : [item, null];
|
|
1597
|
-
if (isFunction(child)) {
|
|
1598
|
-
const result = child(prop);
|
|
1599
|
-
handleChildResult(result, prop, key, tmpl, this.childNodesMap, path);
|
|
1600
|
-
} else {
|
|
1601
|
-
tmpl.template += isSignal(child) ? child.value : String(child);
|
|
1602
|
-
}
|
|
1603
|
-
});
|
|
1604
|
-
}
|
|
1605
|
-
this.processedTemplates[key] = {
|
|
1606
|
-
template: tmpl.template,
|
|
1607
|
-
props: prop
|
|
1608
|
-
};
|
|
1609
|
-
});
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
/**
|
|
1613
|
-
* Render component and its children into a string
|
|
1614
|
-
*/
|
|
1615
|
-
render() {
|
|
1616
|
-
if (isFunction(this.template)) {
|
|
1617
|
-
const root = this.template(this.props);
|
|
1618
|
-
return root instanceof _ServerNode ? root.mount() : String(root);
|
|
1619
|
-
}
|
|
1620
|
-
if (this.template instanceof _ServerNode) {
|
|
1621
|
-
return this.template.mount();
|
|
1622
|
-
}
|
|
1623
|
-
this.initTemplates();
|
|
1624
|
-
return Object.entries(this.processedTemplates).map(([key, { template: template2, props }]) => {
|
|
1625
|
-
let content = template2;
|
|
1626
|
-
if (props && Object.keys(props).length > 0) {
|
|
1627
|
-
content += ` ${generateAttributes(props)}`;
|
|
1628
|
-
}
|
|
1629
|
-
if (this.childNodesMap[key]) {
|
|
1630
|
-
content = content.replace("<!>", this.renderChildren(this.childNodesMap[key]));
|
|
1631
|
-
}
|
|
1632
|
-
return content;
|
|
1633
|
-
}).join("");
|
|
1634
|
-
}
|
|
1635
|
-
/**
|
|
1636
|
-
* Render child nodes into a string
|
|
1637
|
-
*/
|
|
1638
|
-
renderChildren(children) {
|
|
1639
|
-
return coerceArray(children).map(String).join("");
|
|
1640
|
-
}
|
|
1641
|
-
};
|
|
1642
1344
|
function ssg(component, props) {
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
return
|
|
1345
|
+
if (renderContext.isSSG) {
|
|
1346
|
+
return new SSGNode(component, props);
|
|
1347
|
+
}
|
|
1348
|
+
return h2(component, props);
|
|
1647
1349
|
}
|
|
1648
1350
|
|
|
1649
1351
|
// src/index.ts
|
|
@@ -1651,50 +1353,42 @@ if (globalThis) {
|
|
|
1651
1353
|
globalThis.__essor_version__ = essor_version;
|
|
1652
1354
|
}
|
|
1653
1355
|
/**
|
|
1654
|
-
* @estjs/
|
|
1655
|
-
* (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
|
|
1656
|
-
* @license MIT
|
|
1657
|
-
**/
|
|
1658
|
-
/**
|
|
1659
|
-
* @estjs/signal v0.0.12
|
|
1356
|
+
* @estjs/signal v0.0.13-beta.2
|
|
1660
1357
|
* (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
|
|
1661
1358
|
* @license MIT
|
|
1662
1359
|
**/
|
|
1663
1360
|
/**
|
|
1664
|
-
* @estjs/template v0.0.
|
|
1361
|
+
* @estjs/template v0.0.13-beta.2
|
|
1665
1362
|
* (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
|
|
1666
1363
|
* @license MIT
|
|
1667
1364
|
**/
|
|
1668
1365
|
|
|
1669
|
-
exports.ComponentNode = ComponentNode;
|
|
1670
1366
|
exports.Fragment = Fragment;
|
|
1671
|
-
exports.
|
|
1672
|
-
exports.
|
|
1673
|
-
exports.createStore = createStore;
|
|
1367
|
+
exports.clearReactive = Oe;
|
|
1368
|
+
exports.createStore = Le;
|
|
1674
1369
|
exports.essor_version = essor_version;
|
|
1675
|
-
exports.h =
|
|
1370
|
+
exports.h = h2;
|
|
1371
|
+
exports.hydrate = hydrate;
|
|
1676
1372
|
exports.isComponent = isComponent;
|
|
1677
|
-
exports.isComputed =
|
|
1373
|
+
exports.isComputed = I;
|
|
1678
1374
|
exports.isJsxElement = isJsxElement;
|
|
1679
|
-
exports.isReactive =
|
|
1680
|
-
exports.isSignal =
|
|
1681
|
-
exports.nextTick = nextTick2;
|
|
1375
|
+
exports.isReactive = b;
|
|
1376
|
+
exports.isSignal = h;
|
|
1682
1377
|
exports.onDestroy = onDestroy;
|
|
1683
1378
|
exports.onMount = onMount;
|
|
1684
1379
|
exports.renderToString = renderToString;
|
|
1685
|
-
exports.shallowReactive =
|
|
1686
|
-
exports.shallowSignal =
|
|
1687
|
-
exports.signalObject =
|
|
1380
|
+
exports.shallowReactive = Ce;
|
|
1381
|
+
exports.shallowSignal = Re;
|
|
1382
|
+
exports.signalObject = We;
|
|
1688
1383
|
exports.ssg = ssg;
|
|
1689
|
-
exports.template =
|
|
1690
|
-
exports.
|
|
1691
|
-
exports.
|
|
1692
|
-
exports.
|
|
1693
|
-
exports.
|
|
1694
|
-
exports.useEffect = useEffect;
|
|
1384
|
+
exports.template = createTemplate;
|
|
1385
|
+
exports.toRaw = c;
|
|
1386
|
+
exports.useBatch = fe;
|
|
1387
|
+
exports.useComputed = z;
|
|
1388
|
+
exports.useEffect = B;
|
|
1695
1389
|
exports.useInject = useInject;
|
|
1696
1390
|
exports.useProvide = useProvide;
|
|
1697
|
-
exports.useReactive =
|
|
1391
|
+
exports.useReactive = L;
|
|
1698
1392
|
exports.useRef = useRef;
|
|
1699
|
-
exports.useSignal =
|
|
1700
|
-
exports.useWatch =
|
|
1393
|
+
exports.useSignal = le;
|
|
1394
|
+
exports.useWatch = De;
|