wevu 6.7.2 → 6.7.4
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/api.d.mts +1 -0
- package/dist/api.mjs +2 -0
- package/dist/compiler.mjs +2 -3
- package/dist/defineProperty-JH0tR899.mjs +39 -0
- package/dist/fetch.d.mts +26 -0
- package/dist/fetch.mjs +345 -0
- package/dist/index-Ciz2Ye1L.d.mts +246 -0
- package/dist/index.d.mts +238 -410
- package/dist/index.mjs +1609 -2560
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/ref-BeA_Is-2.mjs +804 -0
- package/dist/router-5qgy8oOS.mjs +329 -0
- package/dist/router-BxV0btOX.d.mts +46 -0
- package/dist/router.d.mts +192 -0
- package/dist/router.mjs +1412 -0
- package/dist/store-DFP_p2kt.mjs +504 -0
- package/dist/store.d.mts +2 -0
- package/dist/store.mjs +2 -0
- package/package.json +31 -2
- /package/dist/{weappIntrinsicElements-CihhL3Md.d.mts → weappIntrinsicElements-BKiRK0cC.d.mts} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,932 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
let isFlushing = false;
|
|
5
|
-
let isFlushPending = false;
|
|
6
|
-
function flushJobs() {
|
|
7
|
-
isFlushPending = false;
|
|
8
|
-
isFlushing = true;
|
|
9
|
-
try {
|
|
10
|
-
jobQueue.forEach((job) => job());
|
|
11
|
-
} finally {
|
|
12
|
-
jobQueue.clear();
|
|
13
|
-
isFlushing = false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function queueJob(job) {
|
|
17
|
-
jobQueue.add(job);
|
|
18
|
-
if (!isFlushing && !isFlushPending) {
|
|
19
|
-
isFlushPending = true;
|
|
20
|
-
resolvedPromise.then(flushJobs);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function nextTick(fn) {
|
|
24
|
-
return fn ? resolvedPromise.then(fn) : resolvedPromise;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/typeof.js
|
|
29
|
-
function _typeof(o) {
|
|
30
|
-
"@babel/helpers - typeof";
|
|
31
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
32
|
-
return typeof o;
|
|
33
|
-
} : function(o) {
|
|
34
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
35
|
-
}, _typeof(o);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/toPrimitive.js
|
|
40
|
-
function toPrimitive(t, r) {
|
|
41
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
42
|
-
var e = t[Symbol.toPrimitive];
|
|
43
|
-
if (void 0 !== e) {
|
|
44
|
-
var i = e.call(t, r || "default");
|
|
45
|
-
if ("object" != _typeof(i)) return i;
|
|
46
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
47
|
-
}
|
|
48
|
-
return ("string" === r ? String : Number)(t);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/toPropertyKey.js
|
|
53
|
-
function toPropertyKey(t) {
|
|
54
|
-
var i = toPrimitive(t, "string");
|
|
55
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/defineProperty.js
|
|
60
|
-
function _defineProperty(e, r, t) {
|
|
61
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
62
|
-
value: t,
|
|
63
|
-
enumerable: !0,
|
|
64
|
-
configurable: !0,
|
|
65
|
-
writable: !0
|
|
66
|
-
}) : e[r] = t, e;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/reactivity/core.ts
|
|
71
|
-
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
72
|
-
let activeEffect = null;
|
|
73
|
-
const effectStack = [];
|
|
74
|
-
let batchDepth = 0;
|
|
75
|
-
const batchedEffects = /* @__PURE__ */ new Set();
|
|
76
|
-
function startBatch() {
|
|
77
|
-
batchDepth++;
|
|
78
|
-
}
|
|
79
|
-
function flushBatchedEffects() {
|
|
80
|
-
while (batchedEffects.size) {
|
|
81
|
-
const effects = Array.from(batchedEffects);
|
|
82
|
-
batchedEffects.clear();
|
|
83
|
-
for (const ef of effects) ef();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function endBatch() {
|
|
87
|
-
if (batchDepth === 0) return;
|
|
88
|
-
batchDepth--;
|
|
89
|
-
if (batchDepth === 0) flushBatchedEffects();
|
|
90
|
-
}
|
|
91
|
-
function batch(fn) {
|
|
92
|
-
startBatch();
|
|
93
|
-
try {
|
|
94
|
-
return fn();
|
|
95
|
-
} finally {
|
|
96
|
-
endBatch();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function cleanupEffect(effect) {
|
|
100
|
-
const { deps } = effect;
|
|
101
|
-
for (let i = 0; i < deps.length; i++) deps[i].delete(effect);
|
|
102
|
-
deps.length = 0;
|
|
103
|
-
}
|
|
104
|
-
function stop(runner) {
|
|
105
|
-
var _runner$onStop;
|
|
106
|
-
if (!runner.active) return;
|
|
107
|
-
runner.active = false;
|
|
108
|
-
cleanupEffect(runner);
|
|
109
|
-
(_runner$onStop = runner.onStop) === null || _runner$onStop === void 0 || _runner$onStop.call(runner);
|
|
110
|
-
}
|
|
111
|
-
let activeEffectScope;
|
|
112
|
-
var EffectScopeImpl = class {
|
|
113
|
-
constructor(detached = false) {
|
|
114
|
-
this.detached = detached;
|
|
115
|
-
_defineProperty(this, "active", true);
|
|
116
|
-
_defineProperty(this, "effects", []);
|
|
117
|
-
_defineProperty(this, "cleanups", []);
|
|
118
|
-
_defineProperty(this, "parent", void 0);
|
|
119
|
-
_defineProperty(this, "scopes", void 0);
|
|
120
|
-
if (!detached && activeEffectScope) {
|
|
121
|
-
var _activeEffectScope;
|
|
122
|
-
this.parent = activeEffectScope;
|
|
123
|
-
((_activeEffectScope = activeEffectScope).scopes || (_activeEffectScope.scopes = [])).push(this);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
run(fn) {
|
|
127
|
-
if (!this.active) return;
|
|
128
|
-
const prev = activeEffectScope;
|
|
129
|
-
activeEffectScope = this;
|
|
130
|
-
try {
|
|
131
|
-
return fn();
|
|
132
|
-
} finally {
|
|
133
|
-
activeEffectScope = prev;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
stop() {
|
|
137
|
-
var _this$parent;
|
|
138
|
-
if (!this.active) return;
|
|
139
|
-
this.active = false;
|
|
140
|
-
for (const effect of this.effects) stop(effect);
|
|
141
|
-
this.effects.length = 0;
|
|
142
|
-
for (const cleanup of this.cleanups) cleanup();
|
|
143
|
-
this.cleanups.length = 0;
|
|
144
|
-
if (this.scopes) {
|
|
145
|
-
for (const scope of this.scopes) scope.stop();
|
|
146
|
-
this.scopes.length = 0;
|
|
147
|
-
}
|
|
148
|
-
if ((_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.scopes) {
|
|
149
|
-
const index = this.parent.scopes.indexOf(this);
|
|
150
|
-
if (index >= 0) this.parent.scopes.splice(index, 1);
|
|
151
|
-
}
|
|
152
|
-
this.parent = void 0;
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
function effectScope(detached = false) {
|
|
156
|
-
return new EffectScopeImpl(detached);
|
|
157
|
-
}
|
|
158
|
-
function getCurrentScope() {
|
|
159
|
-
return activeEffectScope;
|
|
160
|
-
}
|
|
161
|
-
function onScopeDispose(fn) {
|
|
162
|
-
if (activeEffectScope === null || activeEffectScope === void 0 ? void 0 : activeEffectScope.active) activeEffectScope.cleanups.push(fn);
|
|
163
|
-
}
|
|
164
|
-
function recordEffectScope(effect) {
|
|
165
|
-
if (activeEffectScope === null || activeEffectScope === void 0 ? void 0 : activeEffectScope.active) activeEffectScope.effects.push(effect);
|
|
166
|
-
}
|
|
167
|
-
function createReactiveEffect(fn, options = {}) {
|
|
168
|
-
const effect = function reactiveEffect() {
|
|
169
|
-
if (!effect.active) return fn();
|
|
170
|
-
if (effect._running) return fn();
|
|
171
|
-
cleanupEffect(effect);
|
|
172
|
-
try {
|
|
173
|
-
effect._running = true;
|
|
174
|
-
effectStack.push(effect);
|
|
175
|
-
activeEffect = effect;
|
|
176
|
-
return fn();
|
|
177
|
-
} finally {
|
|
178
|
-
var _effectStack;
|
|
179
|
-
effectStack.pop();
|
|
180
|
-
activeEffect = (_effectStack = effectStack[effectStack.length - 1]) !== null && _effectStack !== void 0 ? _effectStack : null;
|
|
181
|
-
effect._running = false;
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
effect.deps = [];
|
|
185
|
-
effect.scheduler = options.scheduler;
|
|
186
|
-
effect.onStop = options.onStop;
|
|
187
|
-
effect.active = true;
|
|
188
|
-
effect._running = false;
|
|
189
|
-
effect._fn = fn;
|
|
190
|
-
return effect;
|
|
191
|
-
}
|
|
192
|
-
function effect(fn, options = {}) {
|
|
193
|
-
const _effect = createReactiveEffect(fn, options);
|
|
194
|
-
recordEffectScope(_effect);
|
|
195
|
-
if (!options.lazy) _effect();
|
|
196
|
-
return _effect;
|
|
197
|
-
}
|
|
198
|
-
function track(target, key) {
|
|
199
|
-
if (!activeEffect) return;
|
|
200
|
-
let depsMap = targetMap.get(target);
|
|
201
|
-
if (!depsMap) {
|
|
202
|
-
depsMap = /* @__PURE__ */ new Map();
|
|
203
|
-
targetMap.set(target, depsMap);
|
|
204
|
-
}
|
|
205
|
-
let dep = depsMap.get(key);
|
|
206
|
-
if (!dep) {
|
|
207
|
-
dep = /* @__PURE__ */ new Set();
|
|
208
|
-
depsMap.set(key, dep);
|
|
209
|
-
}
|
|
210
|
-
if (!dep.has(activeEffect)) {
|
|
211
|
-
dep.add(activeEffect);
|
|
212
|
-
activeEffect.deps.push(dep);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
function scheduleEffect(ef) {
|
|
216
|
-
if (ef.scheduler) {
|
|
217
|
-
ef.scheduler();
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
if (batchDepth > 0) {
|
|
221
|
-
batchedEffects.add(ef);
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
ef();
|
|
225
|
-
}
|
|
226
|
-
function trigger(target, key) {
|
|
227
|
-
const depsMap = targetMap.get(target);
|
|
228
|
-
if (!depsMap) return;
|
|
229
|
-
const effects = depsMap.get(key);
|
|
230
|
-
if (!effects) return;
|
|
231
|
-
const effectsToRun = /* @__PURE__ */ new Set();
|
|
232
|
-
effects.forEach((ef) => {
|
|
233
|
-
if (ef !== activeEffect) effectsToRun.add(ef);
|
|
234
|
-
});
|
|
235
|
-
effectsToRun.forEach(scheduleEffect);
|
|
236
|
-
}
|
|
237
|
-
function trackEffects(dep) {
|
|
238
|
-
if (!activeEffect) return;
|
|
239
|
-
if (!dep.has(activeEffect)) {
|
|
240
|
-
dep.add(activeEffect);
|
|
241
|
-
activeEffect.deps.push(dep);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
function triggerEffects(dep) {
|
|
245
|
-
new Set(dep).forEach(scheduleEffect);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
//#endregion
|
|
249
|
-
//#region src/reactivity/reactive/mutation.ts
|
|
250
|
-
const mutationRecorders = /* @__PURE__ */ new Set();
|
|
251
|
-
function addMutationRecorder(recorder) {
|
|
252
|
-
mutationRecorders.add(recorder);
|
|
253
|
-
}
|
|
254
|
-
function removeMutationRecorder(recorder) {
|
|
255
|
-
mutationRecorders.delete(recorder);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
//#endregion
|
|
259
|
-
//#region src/reactivity/reactive/patchState.ts
|
|
260
|
-
const rawRootMap = /* @__PURE__ */ new WeakMap();
|
|
261
|
-
const rawVersionMap = /* @__PURE__ */ new WeakMap();
|
|
262
|
-
const rawParentMap = /* @__PURE__ */ new WeakMap();
|
|
263
|
-
const rawParentsMap = /* @__PURE__ */ new WeakMap();
|
|
264
|
-
const rawMultiParentSet = /* @__PURE__ */ new WeakSet();
|
|
265
|
-
const rawPathMap = /* @__PURE__ */ new WeakMap();
|
|
266
|
-
const rootPatchNodesMap = /* @__PURE__ */ new WeakMap();
|
|
267
|
-
function getRootPatchNodes(root) {
|
|
268
|
-
let nodes = rootPatchNodesMap.get(root);
|
|
269
|
-
if (!nodes) {
|
|
270
|
-
nodes = /* @__PURE__ */ new Set();
|
|
271
|
-
rootPatchNodesMap.set(root, nodes);
|
|
272
|
-
}
|
|
273
|
-
return nodes;
|
|
274
|
-
}
|
|
275
|
-
function indexPatchNode(root, node) {
|
|
276
|
-
getRootPatchNodes(root).add(node);
|
|
277
|
-
}
|
|
278
|
-
function bumpRawVersion(target) {
|
|
279
|
-
var _rawVersionMap$get;
|
|
280
|
-
rawVersionMap.set(target, ((_rawVersionMap$get = rawVersionMap.get(target)) !== null && _rawVersionMap$get !== void 0 ? _rawVersionMap$get : 0) + 1);
|
|
281
|
-
}
|
|
282
|
-
function getRawVersion(target) {
|
|
283
|
-
var _rawVersionMap$get2;
|
|
284
|
-
return (_rawVersionMap$get2 = rawVersionMap.get(target)) !== null && _rawVersionMap$get2 !== void 0 ? _rawVersionMap$get2 : 0;
|
|
285
|
-
}
|
|
286
|
-
function bumpAncestorVersions(target) {
|
|
287
|
-
const visited = /* @__PURE__ */ new Set();
|
|
288
|
-
const stack = [target];
|
|
289
|
-
for (let i = 0; i < 2e3 && stack.length; i++) {
|
|
290
|
-
const current = stack.pop();
|
|
291
|
-
const parents = rawParentsMap.get(current);
|
|
292
|
-
if (!parents) continue;
|
|
293
|
-
for (const parent of parents.keys()) {
|
|
294
|
-
if (visited.has(parent)) continue;
|
|
295
|
-
visited.add(parent);
|
|
296
|
-
bumpRawVersion(parent);
|
|
297
|
-
stack.push(parent);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
function refreshPathUniqueness(child) {
|
|
302
|
-
const parents = rawParentsMap.get(child);
|
|
303
|
-
if (!parents) {
|
|
304
|
-
rawMultiParentSet.delete(child);
|
|
305
|
-
rawParentMap.delete(child);
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
let uniqueParent;
|
|
309
|
-
let uniqueKey;
|
|
310
|
-
let total = 0;
|
|
311
|
-
for (const [parent, keys] of parents) {
|
|
312
|
-
for (const k of keys) {
|
|
313
|
-
total += 1;
|
|
314
|
-
if (total > 1) break;
|
|
315
|
-
uniqueParent = parent;
|
|
316
|
-
uniqueKey = k;
|
|
317
|
-
}
|
|
318
|
-
if (total > 1) break;
|
|
319
|
-
}
|
|
320
|
-
if (total === 1 && uniqueParent && uniqueKey) {
|
|
321
|
-
rawMultiParentSet.delete(child);
|
|
322
|
-
rawParentMap.set(child, {
|
|
323
|
-
parent: uniqueParent,
|
|
324
|
-
key: uniqueKey
|
|
325
|
-
});
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
rawMultiParentSet.add(child);
|
|
329
|
-
rawParentMap.delete(child);
|
|
330
|
-
}
|
|
331
|
-
function recordParentLink(child, parent, key) {
|
|
332
|
-
if (typeof key !== "string") {
|
|
333
|
-
rawMultiParentSet.add(child);
|
|
334
|
-
rawParentMap.delete(child);
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
if (mutationRecorders.size) {
|
|
338
|
-
var _rawRootMap$get;
|
|
339
|
-
const root = (_rawRootMap$get = rawRootMap.get(parent)) !== null && _rawRootMap$get !== void 0 ? _rawRootMap$get : parent;
|
|
340
|
-
indexPatchNode(root, parent);
|
|
341
|
-
indexPatchNode(root, child);
|
|
342
|
-
}
|
|
343
|
-
let parents = rawParentsMap.get(child);
|
|
344
|
-
if (!parents) {
|
|
345
|
-
parents = /* @__PURE__ */ new Map();
|
|
346
|
-
rawParentsMap.set(child, parents);
|
|
347
|
-
}
|
|
348
|
-
let keys = parents.get(parent);
|
|
349
|
-
if (!keys) {
|
|
350
|
-
keys = /* @__PURE__ */ new Set();
|
|
351
|
-
parents.set(parent, keys);
|
|
352
|
-
}
|
|
353
|
-
keys.add(key);
|
|
354
|
-
refreshPathUniqueness(child);
|
|
355
|
-
}
|
|
356
|
-
function removeParentLink(child, parent, key) {
|
|
357
|
-
const parents = rawParentsMap.get(child);
|
|
358
|
-
if (!parents) return;
|
|
359
|
-
const keys = parents.get(parent);
|
|
360
|
-
if (!keys) return;
|
|
361
|
-
keys.delete(key);
|
|
362
|
-
if (!keys.size) parents.delete(parent);
|
|
363
|
-
if (!parents.size) rawParentsMap.delete(child);
|
|
364
|
-
refreshPathUniqueness(child);
|
|
365
|
-
}
|
|
366
|
-
function resolvePathToTarget(root, target) {
|
|
367
|
-
if (target === root) return [];
|
|
368
|
-
if (rawMultiParentSet.has(target)) return;
|
|
369
|
-
const segments = [];
|
|
370
|
-
let current = target;
|
|
371
|
-
for (let i = 0; i < 2e3; i++) {
|
|
372
|
-
if (current === root) return segments.reverse();
|
|
373
|
-
if (rawMultiParentSet.has(current)) return;
|
|
374
|
-
const info = rawParentMap.get(current);
|
|
375
|
-
if (!info) return;
|
|
376
|
-
if (typeof info.key !== "string") return;
|
|
377
|
-
segments.push(info.key);
|
|
378
|
-
current = info.parent;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
//#endregion
|
|
383
|
-
//#region src/reactivity/reactive/shared.ts
|
|
384
|
-
let ReactiveFlags = /* @__PURE__ */ function(ReactiveFlags) {
|
|
385
|
-
ReactiveFlags["IS_REACTIVE"] = "__r_isReactive";
|
|
386
|
-
ReactiveFlags["RAW"] = "__r_raw";
|
|
387
|
-
ReactiveFlags["SKIP"] = "__r_skip";
|
|
388
|
-
return ReactiveFlags;
|
|
389
|
-
}({});
|
|
390
|
-
function isObject$1(value) {
|
|
391
|
-
return typeof value === "object" && value !== null;
|
|
392
|
-
}
|
|
393
|
-
const VERSION_KEY = Symbol("wevu.version");
|
|
394
|
-
function isArrayIndexKey(key) {
|
|
395
|
-
if (!key) return false;
|
|
396
|
-
const code0 = key.charCodeAt(0);
|
|
397
|
-
if (code0 < 48 || code0 > 57) return false;
|
|
398
|
-
const n = Number(key);
|
|
399
|
-
return Number.isInteger(n) && n >= 0 && String(n) === key;
|
|
400
|
-
}
|
|
401
|
-
function toRaw(observed) {
|
|
402
|
-
var _ReactiveFlags$RAW;
|
|
403
|
-
return (_ReactiveFlags$RAW = observed === null || observed === void 0 ? void 0 : observed[ReactiveFlags.RAW]) !== null && _ReactiveFlags$RAW !== void 0 ? _ReactiveFlags$RAW : observed;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
//#endregion
|
|
407
|
-
//#region src/reactivity/reactive/state.ts
|
|
408
|
-
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
409
|
-
const rawMap = /* @__PURE__ */ new WeakMap();
|
|
410
|
-
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
411
|
-
|
|
412
|
-
//#endregion
|
|
413
|
-
//#region src/reactivity/reactive/patch.ts
|
|
414
|
-
/**
|
|
415
|
-
* 预链接响应式树结构,供运行时差量路径追踪使用。
|
|
416
|
-
* @internal
|
|
417
|
-
*/
|
|
418
|
-
function prelinkReactiveTree(root, options) {
|
|
419
|
-
const rootRaw = toRaw(root);
|
|
420
|
-
rawPathMap.set(rootRaw, "");
|
|
421
|
-
indexPatchNode(rootRaw, rootRaw);
|
|
422
|
-
const shouldIncludeTopKey = options === null || options === void 0 ? void 0 : options.shouldIncludeTopKey;
|
|
423
|
-
const maxDepth = typeof (options === null || options === void 0 ? void 0 : options.maxDepth) === "number" ? Math.max(0, Math.floor(options.maxDepth)) : Number.POSITIVE_INFINITY;
|
|
424
|
-
const maxKeys = typeof (options === null || options === void 0 ? void 0 : options.maxKeys) === "number" ? Math.max(0, Math.floor(options.maxKeys)) : Number.POSITIVE_INFINITY;
|
|
425
|
-
const visited = /* @__PURE__ */ new WeakSet();
|
|
426
|
-
const stack = [{
|
|
427
|
-
current: rootRaw,
|
|
428
|
-
path: "",
|
|
429
|
-
depth: 0
|
|
430
|
-
}];
|
|
431
|
-
let indexed = 0;
|
|
432
|
-
while (stack.length) {
|
|
433
|
-
const node = stack.pop();
|
|
434
|
-
if (visited.has(node.current)) continue;
|
|
435
|
-
visited.add(node.current);
|
|
436
|
-
rawPathMap.set(node.current, node.path);
|
|
437
|
-
indexPatchNode(rootRaw, node.current);
|
|
438
|
-
indexed += 1;
|
|
439
|
-
if (indexed >= maxKeys) continue;
|
|
440
|
-
if (node.depth >= maxDepth) continue;
|
|
441
|
-
if (Array.isArray(node.current)) continue;
|
|
442
|
-
const entries = Object.entries(node.current);
|
|
443
|
-
for (const [key, value] of entries) {
|
|
444
|
-
if (node.path === "" && shouldIncludeTopKey && !shouldIncludeTopKey(key)) continue;
|
|
445
|
-
if (!isObject$1(value)) continue;
|
|
446
|
-
if (value[ReactiveFlags.SKIP]) continue;
|
|
447
|
-
const childRaw = toRaw(value);
|
|
448
|
-
if (!rawRootMap.has(childRaw)) rawRootMap.set(childRaw, rootRaw);
|
|
449
|
-
recordParentLink(childRaw, node.current, key);
|
|
450
|
-
if (!rawMultiParentSet.has(childRaw)) {
|
|
451
|
-
const childPath = node.path ? `${node.path}.${key}` : key;
|
|
452
|
-
rawPathMap.set(childRaw, childPath);
|
|
453
|
-
}
|
|
454
|
-
indexPatchNode(rootRaw, childRaw);
|
|
455
|
-
stack.push({
|
|
456
|
-
current: childRaw,
|
|
457
|
-
path: node.path ? `${node.path}.${key}` : key,
|
|
458
|
-
depth: node.depth + 1
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* 清理预链接阶段建立的路径与父子索引。
|
|
465
|
-
* @internal
|
|
466
|
-
*/
|
|
467
|
-
function clearPatchIndices(root) {
|
|
468
|
-
const rootRaw = toRaw(root);
|
|
469
|
-
const nodes = rootPatchNodesMap.get(rootRaw);
|
|
470
|
-
if (!nodes) {
|
|
471
|
-
rawPathMap.delete(rootRaw);
|
|
472
|
-
return;
|
|
473
|
-
}
|
|
474
|
-
for (const node of nodes) {
|
|
475
|
-
rawParentMap.delete(node);
|
|
476
|
-
rawParentsMap.delete(node);
|
|
477
|
-
rawPathMap.delete(node);
|
|
478
|
-
rawMultiParentSet.delete(node);
|
|
479
|
-
rawRootMap.delete(node);
|
|
480
|
-
rawVersionMap.delete(node);
|
|
481
|
-
}
|
|
482
|
-
rootPatchNodesMap.delete(rootRaw);
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* 让 effect 订阅整个对象的“版本号”,无需深度遍历即可对任何字段变化做出响应。
|
|
486
|
-
* @internal
|
|
487
|
-
*/
|
|
488
|
-
function touchReactive(target) {
|
|
489
|
-
track(toRaw(target), VERSION_KEY);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
//#endregion
|
|
493
|
-
//#region src/reactivity/reactive/shallow.ts
|
|
494
|
-
const shallowHandlers = {
|
|
495
|
-
get(target, key, receiver) {
|
|
496
|
-
if (key === ReactiveFlags.IS_REACTIVE) return true;
|
|
497
|
-
if (key === ReactiveFlags.RAW) return target;
|
|
498
|
-
const res = Reflect.get(target, key, receiver);
|
|
499
|
-
track(target, key);
|
|
500
|
-
return res;
|
|
501
|
-
},
|
|
502
|
-
set(target, key, value, receiver) {
|
|
503
|
-
const oldValue = Reflect.get(target, key, receiver);
|
|
504
|
-
const result = Reflect.set(target, key, value, receiver);
|
|
505
|
-
if (!Object.is(oldValue, value)) {
|
|
506
|
-
trigger(target, key);
|
|
507
|
-
trigger(target, VERSION_KEY);
|
|
508
|
-
bumpRawVersion(target);
|
|
509
|
-
}
|
|
510
|
-
return result;
|
|
511
|
-
},
|
|
512
|
-
deleteProperty(target, key) {
|
|
513
|
-
const hadKey = Object.prototype.hasOwnProperty.call(target, key);
|
|
514
|
-
const result = Reflect.deleteProperty(target, key);
|
|
515
|
-
if (hadKey && result) {
|
|
516
|
-
trigger(target, key);
|
|
517
|
-
trigger(target, VERSION_KEY);
|
|
518
|
-
bumpRawVersion(target);
|
|
519
|
-
}
|
|
520
|
-
return result;
|
|
521
|
-
},
|
|
522
|
-
ownKeys(target) {
|
|
523
|
-
track(target, Symbol.iterator);
|
|
524
|
-
track(target, VERSION_KEY);
|
|
525
|
-
return Reflect.ownKeys(target);
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
/**
|
|
529
|
-
* 创建一个浅层响应式代理:仅跟踪第一层属性变更,不深度递归嵌套对象。
|
|
530
|
-
*
|
|
531
|
-
* @param target 待转换的对象
|
|
532
|
-
* @returns 浅层响应式代理
|
|
533
|
-
*
|
|
534
|
-
* @example
|
|
535
|
-
* ```ts
|
|
536
|
-
* const state = shallowReactive({ nested: { count: 0 } })
|
|
537
|
-
*
|
|
538
|
-
* state.nested.count++ // 不会触发 effect(嵌套对象未深度代理)
|
|
539
|
-
* state.nested = { count: 1 } // 会触发 effect(顶层属性变更)
|
|
540
|
-
* ```
|
|
541
|
-
*/
|
|
542
|
-
function shallowReactive(target) {
|
|
543
|
-
if (!isObject$1(target)) return target;
|
|
544
|
-
const existingProxy = shallowReactiveMap.get(target);
|
|
545
|
-
if (existingProxy) return existingProxy;
|
|
546
|
-
if (target[ReactiveFlags.IS_REACTIVE]) return target;
|
|
547
|
-
const proxy = new Proxy(target, shallowHandlers);
|
|
548
|
-
shallowReactiveMap.set(target, proxy);
|
|
549
|
-
rawMap.set(proxy, target);
|
|
550
|
-
if (!rawVersionMap.has(target)) rawVersionMap.set(target, 0);
|
|
551
|
-
return proxy;
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* 判断一个值是否为 shallowReactive 创建的浅层响应式对象
|
|
555
|
-
*/
|
|
556
|
-
function isShallowReactive(value) {
|
|
557
|
-
const raw = toRaw(value);
|
|
558
|
-
return shallowReactiveMap.has(raw);
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
//#endregion
|
|
562
|
-
//#region src/reactivity/reactive.ts
|
|
563
|
-
/**
|
|
564
|
-
* 读取响应式版本号(框架内部调试能力)。
|
|
565
|
-
* @internal
|
|
566
|
-
*/
|
|
567
|
-
function getReactiveVersion(target) {
|
|
568
|
-
return getRawVersion(toRaw(target));
|
|
569
|
-
}
|
|
570
|
-
function emitMutation(target, key, op) {
|
|
571
|
-
var _rawRootMap$get;
|
|
572
|
-
if (!mutationRecorders.size) return;
|
|
573
|
-
if (typeof key !== "string") return;
|
|
574
|
-
if (key.startsWith("__r_")) return;
|
|
575
|
-
const root = (_rawRootMap$get = rawRootMap.get(target)) !== null && _rawRootMap$get !== void 0 ? _rawRootMap$get : target;
|
|
576
|
-
const kind = Array.isArray(target) && (key === "length" || isArrayIndexKey(key)) ? "array" : "property";
|
|
577
|
-
const baseSegments = resolvePathToTarget(root, target);
|
|
578
|
-
if (!baseSegments) {
|
|
579
|
-
const fallback = /* @__PURE__ */ new Set();
|
|
580
|
-
const parents = rawParentsMap.get(target);
|
|
581
|
-
if (parents) for (const [parent, keys] of parents) {
|
|
582
|
-
var _resolvePathToTarget;
|
|
583
|
-
const parentPath = rawPathMap.get(parent);
|
|
584
|
-
const topFromParentPath = parentPath ? parentPath.split(".", 1)[0] : void 0;
|
|
585
|
-
const topFromResolve = !topFromParentPath ? (_resolvePathToTarget = resolvePathToTarget(root, parent)) === null || _resolvePathToTarget === void 0 ? void 0 : _resolvePathToTarget[0] : void 0;
|
|
586
|
-
for (const k of keys) {
|
|
587
|
-
var _ref;
|
|
588
|
-
if (typeof k !== "string") continue;
|
|
589
|
-
fallback.add((_ref = topFromParentPath !== null && topFromParentPath !== void 0 ? topFromParentPath : topFromResolve) !== null && _ref !== void 0 ? _ref : k);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
else fallback.add(key);
|
|
593
|
-
for (const recorder of mutationRecorders) recorder({
|
|
594
|
-
root,
|
|
595
|
-
kind,
|
|
596
|
-
op,
|
|
597
|
-
path: void 0,
|
|
598
|
-
fallbackTopKeys: fallback.size ? Array.from(fallback) : void 0
|
|
599
|
-
});
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
const arrayIndexPos = baseSegments.findIndex((seg) => isArrayIndexKey(seg));
|
|
603
|
-
if (arrayIndexPos !== -1) {
|
|
604
|
-
const path = baseSegments.slice(0, arrayIndexPos).join(".") || void 0;
|
|
605
|
-
for (const recorder of mutationRecorders) recorder({
|
|
606
|
-
root,
|
|
607
|
-
kind: "array",
|
|
608
|
-
op,
|
|
609
|
-
path
|
|
610
|
-
});
|
|
611
|
-
return;
|
|
612
|
-
}
|
|
613
|
-
const basePath = baseSegments.length ? baseSegments.join(".") : "";
|
|
614
|
-
const path = kind === "array" ? basePath || void 0 : basePath ? `${basePath}.${key}` : key;
|
|
615
|
-
for (const recorder of mutationRecorders) recorder({
|
|
616
|
-
root,
|
|
617
|
-
kind,
|
|
618
|
-
op,
|
|
619
|
-
path
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
const mutableHandlers = {
|
|
623
|
-
get(target, key, receiver) {
|
|
624
|
-
if (key === ReactiveFlags.IS_REACTIVE) return true;
|
|
625
|
-
if (key === ReactiveFlags.RAW) return target;
|
|
626
|
-
const res = Reflect.get(target, key, receiver);
|
|
627
|
-
track(target, key);
|
|
628
|
-
if (isObject$1(res)) {
|
|
629
|
-
var _rawRootMap$get2, _ReactiveFlags$RAW;
|
|
630
|
-
if (res[ReactiveFlags.SKIP]) return res;
|
|
631
|
-
const parentRoot = (_rawRootMap$get2 = rawRootMap.get(target)) !== null && _rawRootMap$get2 !== void 0 ? _rawRootMap$get2 : target;
|
|
632
|
-
const childRaw = (_ReactiveFlags$RAW = res === null || res === void 0 ? void 0 : res[ReactiveFlags.RAW]) !== null && _ReactiveFlags$RAW !== void 0 ? _ReactiveFlags$RAW : res;
|
|
633
|
-
if (!rawRootMap.has(childRaw)) rawRootMap.set(childRaw, parentRoot);
|
|
634
|
-
recordParentLink(childRaw, target, key);
|
|
635
|
-
const parentPath = rawPathMap.get(target);
|
|
636
|
-
if (mutationRecorders.size && typeof key === "string" && parentPath != null && !rawMultiParentSet.has(childRaw)) {
|
|
637
|
-
const nextPath = parentPath ? `${parentPath}.${key}` : key;
|
|
638
|
-
rawPathMap.set(childRaw, nextPath);
|
|
639
|
-
}
|
|
640
|
-
return reactive(res);
|
|
641
|
-
}
|
|
642
|
-
return res;
|
|
643
|
-
},
|
|
644
|
-
set(target, key, value, receiver) {
|
|
645
|
-
const isArr = Array.isArray(target);
|
|
646
|
-
const oldLength = isArr ? target.length : 0;
|
|
647
|
-
const oldValue = Reflect.get(target, key, receiver);
|
|
648
|
-
const result = Reflect.set(target, key, value, receiver);
|
|
649
|
-
if (!Object.is(oldValue, value)) {
|
|
650
|
-
var _ReactiveFlags$RAW2;
|
|
651
|
-
const oldRaw = isObject$1(oldValue) ? (_ReactiveFlags$RAW2 = oldValue === null || oldValue === void 0 ? void 0 : oldValue[ReactiveFlags.RAW]) !== null && _ReactiveFlags$RAW2 !== void 0 ? _ReactiveFlags$RAW2 : oldValue : void 0;
|
|
652
|
-
if (oldRaw) removeParentLink(oldRaw, target, key);
|
|
653
|
-
if (isObject$1(value) && !value[ReactiveFlags.SKIP]) {
|
|
654
|
-
var _rawRootMap$get3, _ReactiveFlags$RAW3;
|
|
655
|
-
const root = (_rawRootMap$get3 = rawRootMap.get(target)) !== null && _rawRootMap$get3 !== void 0 ? _rawRootMap$get3 : target;
|
|
656
|
-
const childRaw = (_ReactiveFlags$RAW3 = value === null || value === void 0 ? void 0 : value[ReactiveFlags.RAW]) !== null && _ReactiveFlags$RAW3 !== void 0 ? _ReactiveFlags$RAW3 : value;
|
|
657
|
-
if (!rawRootMap.has(childRaw)) rawRootMap.set(childRaw, root);
|
|
658
|
-
recordParentLink(childRaw, target, key);
|
|
659
|
-
const parentPath = rawPathMap.get(target);
|
|
660
|
-
if (mutationRecorders.size && typeof key === "string" && parentPath != null && !rawMultiParentSet.has(childRaw)) {
|
|
661
|
-
const nextPath = parentPath ? `${parentPath}.${key}` : key;
|
|
662
|
-
rawPathMap.set(childRaw, nextPath);
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
trigger(target, key);
|
|
666
|
-
if (isArr && typeof key === "string" && isArrayIndexKey(key) && Number(key) >= oldLength) trigger(target, "length");
|
|
667
|
-
trigger(target, VERSION_KEY);
|
|
668
|
-
bumpRawVersion(target);
|
|
669
|
-
bumpAncestorVersions(target);
|
|
670
|
-
const root = rawRootMap.get(target);
|
|
671
|
-
if (root && root !== target) {
|
|
672
|
-
trigger(root, VERSION_KEY);
|
|
673
|
-
bumpRawVersion(root);
|
|
674
|
-
}
|
|
675
|
-
emitMutation(target, key, "set");
|
|
676
|
-
}
|
|
677
|
-
return result;
|
|
678
|
-
},
|
|
679
|
-
deleteProperty(target, key) {
|
|
680
|
-
const hadKey = Object.prototype.hasOwnProperty.call(target, key);
|
|
681
|
-
const oldValue = hadKey ? target[key] : void 0;
|
|
682
|
-
const result = Reflect.deleteProperty(target, key);
|
|
683
|
-
if (hadKey && result) {
|
|
684
|
-
var _ReactiveFlags$RAW4;
|
|
685
|
-
const oldRaw = isObject$1(oldValue) ? (_ReactiveFlags$RAW4 = oldValue === null || oldValue === void 0 ? void 0 : oldValue[ReactiveFlags.RAW]) !== null && _ReactiveFlags$RAW4 !== void 0 ? _ReactiveFlags$RAW4 : oldValue : void 0;
|
|
686
|
-
if (oldRaw) removeParentLink(oldRaw, target, key);
|
|
687
|
-
trigger(target, key);
|
|
688
|
-
trigger(target, VERSION_KEY);
|
|
689
|
-
bumpRawVersion(target);
|
|
690
|
-
bumpAncestorVersions(target);
|
|
691
|
-
const root = rawRootMap.get(target);
|
|
692
|
-
if (root && root !== target) {
|
|
693
|
-
trigger(root, VERSION_KEY);
|
|
694
|
-
bumpRawVersion(root);
|
|
695
|
-
}
|
|
696
|
-
emitMutation(target, key, "delete");
|
|
697
|
-
}
|
|
698
|
-
return result;
|
|
699
|
-
},
|
|
700
|
-
ownKeys(target) {
|
|
701
|
-
track(target, Symbol.iterator);
|
|
702
|
-
track(target, VERSION_KEY);
|
|
703
|
-
return Reflect.ownKeys(target);
|
|
704
|
-
}
|
|
705
|
-
};
|
|
706
|
-
function reactive(target) {
|
|
707
|
-
if (!isObject$1(target)) return target;
|
|
708
|
-
const existingProxy = reactiveMap.get(target);
|
|
709
|
-
if (existingProxy) return existingProxy;
|
|
710
|
-
if (target[ReactiveFlags.IS_REACTIVE]) return target;
|
|
711
|
-
const proxy = new Proxy(target, mutableHandlers);
|
|
712
|
-
reactiveMap.set(target, proxy);
|
|
713
|
-
rawMap.set(proxy, target);
|
|
714
|
-
if (!rawVersionMap.has(target)) rawVersionMap.set(target, 0);
|
|
715
|
-
if (!rawRootMap.has(target)) rawRootMap.set(target, target);
|
|
716
|
-
return proxy;
|
|
717
|
-
}
|
|
718
|
-
function isReactive(value) {
|
|
719
|
-
return Boolean(value && value[ReactiveFlags.IS_REACTIVE]);
|
|
720
|
-
}
|
|
721
|
-
function convertToReactive(value) {
|
|
722
|
-
return isObject$1(value) ? reactive(value) : value;
|
|
723
|
-
}
|
|
724
|
-
/**
|
|
725
|
-
* 标记对象为“原始”状态,后续不会被转换为响应式,返回原对象本身。
|
|
726
|
-
*
|
|
727
|
-
* @param value 需要标记的对象
|
|
728
|
-
* @returns 带有跳过标记的原对象
|
|
729
|
-
*
|
|
730
|
-
* @example
|
|
731
|
-
* ```ts
|
|
732
|
-
* const foo = markRaw({
|
|
733
|
-
* nested: {}
|
|
734
|
-
* })
|
|
735
|
-
*
|
|
736
|
-
* const state = reactive({
|
|
737
|
-
* foo
|
|
738
|
-
* })
|
|
739
|
-
*
|
|
740
|
-
* state.foo // 不是响应式对象
|
|
741
|
-
* ```
|
|
742
|
-
*/
|
|
743
|
-
function markRaw(value) {
|
|
744
|
-
if (!isObject$1(value)) return value;
|
|
745
|
-
Object.defineProperty(value, ReactiveFlags.SKIP, {
|
|
746
|
-
value: true,
|
|
747
|
-
configurable: true,
|
|
748
|
-
enumerable: false,
|
|
749
|
-
writable: true
|
|
750
|
-
});
|
|
751
|
-
return value;
|
|
752
|
-
}
|
|
753
|
-
/**
|
|
754
|
-
* 判断某个值是否被标记为原始(即不应转换为响应式)。
|
|
755
|
-
*
|
|
756
|
-
* @param value 待检测的值
|
|
757
|
-
* @returns 若含有跳过标记则返回 true
|
|
758
|
-
*/
|
|
759
|
-
function isRaw(value) {
|
|
760
|
-
return isObject$1(value) && ReactiveFlags.SKIP in value;
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
//#endregion
|
|
764
|
-
//#region src/reactivity/ref.ts
|
|
765
|
-
const RefFlag = "__v_isRef";
|
|
766
|
-
function markAsRef(target) {
|
|
767
|
-
try {
|
|
768
|
-
Object.defineProperty(target, RefFlag, {
|
|
769
|
-
value: true,
|
|
770
|
-
configurable: true
|
|
771
|
-
});
|
|
772
|
-
} catch (_unused) {
|
|
773
|
-
target[RefFlag] = true;
|
|
774
|
-
}
|
|
775
|
-
return target;
|
|
776
|
-
}
|
|
777
|
-
function isRef(value) {
|
|
778
|
-
return Boolean(value && typeof value === "object" && value[RefFlag] === true);
|
|
779
|
-
}
|
|
780
|
-
var RefImpl = class {
|
|
781
|
-
constructor(value) {
|
|
782
|
-
_defineProperty(this, "_value", void 0);
|
|
783
|
-
_defineProperty(this, "_rawValue", void 0);
|
|
784
|
-
_defineProperty(this, "dep", void 0);
|
|
785
|
-
markAsRef(this);
|
|
786
|
-
this._rawValue = value;
|
|
787
|
-
this._value = convertToReactive(value);
|
|
788
|
-
}
|
|
789
|
-
get value() {
|
|
790
|
-
if (!this.dep) this.dep = /* @__PURE__ */ new Set();
|
|
791
|
-
trackEffects(this.dep);
|
|
792
|
-
return this._value;
|
|
793
|
-
}
|
|
794
|
-
set value(newValue) {
|
|
795
|
-
if (!Object.is(newValue, this._rawValue)) {
|
|
796
|
-
this._rawValue = newValue;
|
|
797
|
-
this._value = convertToReactive(newValue);
|
|
798
|
-
if (this.dep) triggerEffects(this.dep);
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
};
|
|
802
|
-
function ref(value) {
|
|
803
|
-
if (isRef(value)) return value;
|
|
804
|
-
return markRaw(new RefImpl(value));
|
|
805
|
-
}
|
|
806
|
-
function unref(value) {
|
|
807
|
-
return isRef(value) ? value.value : value;
|
|
808
|
-
}
|
|
809
|
-
function toValue(source) {
|
|
810
|
-
return typeof source === "function" ? source() : unref(source);
|
|
811
|
-
}
|
|
812
|
-
var CustomRefImpl = class {
|
|
813
|
-
constructor(factory, defaultValue) {
|
|
814
|
-
_defineProperty(this, "_getValue", void 0);
|
|
815
|
-
_defineProperty(this, "_setValue", void 0);
|
|
816
|
-
_defineProperty(this, "dep", void 0);
|
|
817
|
-
markAsRef(this);
|
|
818
|
-
const fallbackValue = defaultValue;
|
|
819
|
-
const track = () => {
|
|
820
|
-
if (!this.dep) this.dep = /* @__PURE__ */ new Set();
|
|
821
|
-
trackEffects(this.dep);
|
|
822
|
-
};
|
|
823
|
-
const trigger = () => {
|
|
824
|
-
if (this.dep) triggerEffects(this.dep);
|
|
825
|
-
};
|
|
826
|
-
const withFallback = (value) => value === void 0 && fallbackValue !== void 0 ? fallbackValue : value;
|
|
827
|
-
if (typeof factory === "function") {
|
|
828
|
-
const handlers = factory(track, trigger);
|
|
829
|
-
this._getValue = () => withFallback(handlers.get());
|
|
830
|
-
this._setValue = (value) => handlers.set(value);
|
|
831
|
-
return;
|
|
832
|
-
}
|
|
833
|
-
const handlers = factory;
|
|
834
|
-
this._getValue = () => {
|
|
835
|
-
track();
|
|
836
|
-
return withFallback(handlers.get());
|
|
837
|
-
};
|
|
838
|
-
this._setValue = (value) => {
|
|
839
|
-
handlers.set(value);
|
|
840
|
-
trigger();
|
|
841
|
-
};
|
|
842
|
-
}
|
|
843
|
-
get value() {
|
|
844
|
-
return this._getValue();
|
|
845
|
-
}
|
|
846
|
-
set value(newValue) {
|
|
847
|
-
this._setValue(newValue);
|
|
848
|
-
}
|
|
849
|
-
};
|
|
850
|
-
function customRef(factory, defaultValue) {
|
|
851
|
-
return markRaw(new CustomRefImpl(factory, defaultValue));
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
//#endregion
|
|
855
|
-
//#region src/reactivity/computed.ts
|
|
856
|
-
function computed(getterOrOptions) {
|
|
857
|
-
let getter;
|
|
858
|
-
let setter;
|
|
859
|
-
const onlyGetter = typeof getterOrOptions === "function";
|
|
860
|
-
if (onlyGetter) {
|
|
861
|
-
getter = getterOrOptions;
|
|
862
|
-
setter = () => {
|
|
863
|
-
throw new Error("计算属性是只读的");
|
|
864
|
-
};
|
|
865
|
-
} else {
|
|
866
|
-
getter = getterOrOptions.get;
|
|
867
|
-
setter = getterOrOptions.set;
|
|
868
|
-
}
|
|
869
|
-
let value;
|
|
870
|
-
let dirty = true;
|
|
871
|
-
let runner;
|
|
872
|
-
const obj = {
|
|
873
|
-
get value() {
|
|
874
|
-
if (dirty) {
|
|
875
|
-
value = runner();
|
|
876
|
-
dirty = false;
|
|
877
|
-
}
|
|
878
|
-
track(obj, "value");
|
|
879
|
-
return value;
|
|
880
|
-
},
|
|
881
|
-
set value(newValue) {
|
|
882
|
-
setter(newValue);
|
|
883
|
-
}
|
|
884
|
-
};
|
|
885
|
-
markAsRef(obj);
|
|
886
|
-
runner = effect(getter, {
|
|
887
|
-
lazy: true,
|
|
888
|
-
scheduler: () => {
|
|
889
|
-
if (!dirty) {
|
|
890
|
-
dirty = true;
|
|
891
|
-
trigger(obj, "value");
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
});
|
|
895
|
-
return onlyGetter ? obj : obj;
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
//#endregion
|
|
899
|
-
//#region src/reactivity/readonly.ts
|
|
900
|
-
function readonly(target) {
|
|
901
|
-
if (isRef(target)) {
|
|
902
|
-
const source = target;
|
|
903
|
-
return markAsRef({
|
|
904
|
-
get value() {
|
|
905
|
-
return source.value;
|
|
906
|
-
},
|
|
907
|
-
set value(_v) {
|
|
908
|
-
throw new Error("无法给只读 ref 赋值");
|
|
909
|
-
}
|
|
910
|
-
});
|
|
911
|
-
}
|
|
912
|
-
if (!isObject$1(target)) return target;
|
|
913
|
-
return new Proxy(target, {
|
|
914
|
-
set() {
|
|
915
|
-
throw new Error("无法在只读对象上设置属性");
|
|
916
|
-
},
|
|
917
|
-
deleteProperty() {
|
|
918
|
-
throw new Error("无法在只读对象上删除属性");
|
|
919
|
-
},
|
|
920
|
-
defineProperty() {
|
|
921
|
-
throw new Error("无法在只读对象上定义属性");
|
|
922
|
-
},
|
|
923
|
-
get(target, key, receiver) {
|
|
924
|
-
return Reflect.get(target, key, receiver);
|
|
925
|
-
}
|
|
926
|
-
});
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
//#endregion
|
|
1
|
+
import { A as track, C as effect, D as onScopeDispose, E as getCurrentScope, M as triggerEffects, N as nextTick, O as startBatch, P as queueJob, S as batch, T as endBatch, _ as ReactiveFlags, a as toValue, b as addMutationRecorder, c as isRaw, d as reactive, f as isShallowReactive, g as touchReactive, h as prelinkReactiveTree, i as ref, j as trigger, k as stop, l as isReactive, m as clearPatchIndices, n as isRef, o as unref, p as shallowReactive, r as markAsRef, s as getReactiveVersion, t as customRef, u as markRaw, v as isObject$1, w as effectScope, x as removeMutationRecorder, y as toRaw } from "./ref-BeA_Is-2.mjs";
|
|
2
|
+
import { i as computed, n as defineStore, r as createStore, t as storeToRefs } from "./store-DFP_p2kt.mjs";
|
|
3
|
+
import { A as getCurrentInstance, C as onTabItemTap, D as assertInSetup, E as onUnload, F as getMiniProgramGlobalObject, I as getScopedSlotHostGlobalObject, L as readonly, M as pushHook, N as setCurrentInstance, O as callHookList, P as setCurrentSetupContext, S as onShow, T as onUnhandledRejection, _ as onResize, a as onDetached, b as onShareAppMessage, c as onLaunch, d as onMoved, f as onPageNotFound, g as onReady, h as onReachBottom, i as onAttached, j as getCurrentSetupContext, k as callHookReturn, l as onLoad, m as onPullDownRefresh, n as useNativeRouter, o as onError, p as onPageScroll, r as onAddToFavorites, s as onHide, t as useNativePageRouter, u as onMemoryWarning, v as onRouteDone, w as onThemeChange, x as onShareTimeline, y as onSaveExitState } from "./router-5qgy8oOS.mjs";
|
|
930
4
|
//#region src/reactivity/shallowRef.ts
|
|
931
5
|
/**
|
|
932
6
|
* 创建一个“浅层” ref:它只在 .value 被整体替换时触发依赖,不会对内部对象做深层响应式处理。
|
|
@@ -979,7 +53,6 @@ function triggerRef(ref) {
|
|
|
979
53
|
ref.value = ref.value;
|
|
980
54
|
}
|
|
981
55
|
}
|
|
982
|
-
|
|
983
56
|
//#endregion
|
|
984
57
|
//#region src/reactivity/toRefs.ts
|
|
985
58
|
function toRef(object, key, defaultValue) {
|
|
@@ -1017,7 +90,6 @@ function toRefs(object) {
|
|
|
1017
90
|
for (const key in object) result[key] = toRef(object, key);
|
|
1018
91
|
return result;
|
|
1019
92
|
}
|
|
1020
|
-
|
|
1021
93
|
//#endregion
|
|
1022
94
|
//#region src/reactivity/traverse.ts
|
|
1023
95
|
/**
|
|
@@ -1051,9 +123,8 @@ function traverse(value, depth = Infinity, seen = /* @__PURE__ */ new Map()) {
|
|
|
1051
123
|
for (const key in target) traverse(value[key], nextDepth, seen);
|
|
1052
124
|
return value;
|
|
1053
125
|
}
|
|
1054
|
-
|
|
1055
126
|
//#endregion
|
|
1056
|
-
//#region src/reactivity/watch.ts
|
|
127
|
+
//#region src/reactivity/watch/types.ts
|
|
1057
128
|
let __deepWatchStrategy = "version";
|
|
1058
129
|
/**
|
|
1059
130
|
* 设置深度 watch 内部策略(测试/框架内部使用)。
|
|
@@ -1069,46 +140,75 @@ function setDeepWatchStrategy(strategy) {
|
|
|
1069
140
|
function getDeepWatchStrategy() {
|
|
1070
141
|
return __deepWatchStrategy;
|
|
1071
142
|
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/reactivity/watch/helpers.ts
|
|
145
|
+
function resolveWatchSource(item) {
|
|
146
|
+
if (typeof item === "function") return item();
|
|
147
|
+
if (isRef(item)) return item.value;
|
|
148
|
+
if (isReactive(item)) return item;
|
|
149
|
+
throw new Error("无效的 watch 源");
|
|
150
|
+
}
|
|
151
|
+
function createWatchGetter(source) {
|
|
1075
152
|
const isReactiveSource = isReactive(source);
|
|
1076
153
|
const isMultiSource = Array.isArray(source) && !isReactiveSource;
|
|
1077
|
-
|
|
1078
|
-
if (typeof item === "function") return item();
|
|
1079
|
-
if (isRef(item)) return item.value;
|
|
1080
|
-
if (isReactive(item)) return item;
|
|
1081
|
-
throw new Error("无效的 watch 源");
|
|
1082
|
-
};
|
|
154
|
+
let getter;
|
|
1083
155
|
if (isMultiSource) {
|
|
1084
156
|
const sources = source;
|
|
1085
|
-
getter = () => sources.map((item) =>
|
|
157
|
+
getter = () => sources.map((item) => resolveWatchSource(item));
|
|
1086
158
|
} else if (typeof source === "function") getter = source;
|
|
1087
159
|
else if (isRef(source)) getter = () => source.value;
|
|
1088
160
|
else if (isReactiveSource) getter = () => source;
|
|
1089
161
|
else throw new Error("无效的 watch 源");
|
|
162
|
+
return {
|
|
163
|
+
getter,
|
|
164
|
+
isMultiSource,
|
|
165
|
+
isReactiveSource
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function applyDeepWatchGetter(getter, source, isMultiSource, isReactiveSource, deepOption) {
|
|
1090
169
|
const deepDefault = isMultiSource ? source.some((item) => isReactive(item)) : isReactiveSource;
|
|
1091
|
-
const deep =
|
|
1092
|
-
|
|
170
|
+
const deep = deepOption !== null && deepOption !== void 0 ? deepOption : deepDefault;
|
|
171
|
+
if (!(deep === true || typeof deep === "number")) return getter;
|
|
1093
172
|
const depth = typeof deep === "number" ? deep : deep ? Infinity : 0;
|
|
1094
|
-
|
|
1095
|
-
const
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
if (
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
return item;
|
|
1102
|
-
}
|
|
1103
|
-
return traverse(item, depth);
|
|
1104
|
-
});
|
|
1105
|
-
if (__deepWatchStrategy === "version" && isReactive(val)) {
|
|
1106
|
-
touchReactive(val);
|
|
1107
|
-
return val;
|
|
173
|
+
return () => {
|
|
174
|
+
const value = getter();
|
|
175
|
+
const strategy = getDeepWatchStrategy();
|
|
176
|
+
if (isMultiSource && Array.isArray(value)) return value.map((item) => {
|
|
177
|
+
if (strategy === "version" && isReactive(item)) {
|
|
178
|
+
touchReactive(item);
|
|
179
|
+
return item;
|
|
1108
180
|
}
|
|
1109
|
-
return traverse(
|
|
1110
|
-
};
|
|
181
|
+
return traverse(item, depth);
|
|
182
|
+
});
|
|
183
|
+
if (strategy === "version" && isReactive(value)) {
|
|
184
|
+
touchReactive(value);
|
|
185
|
+
return value;
|
|
186
|
+
}
|
|
187
|
+
return traverse(value, depth);
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function dispatchScheduledJob(job, flush, isFirstRun, scheduler) {
|
|
191
|
+
if (scheduler) {
|
|
192
|
+
scheduler(job, isFirstRun);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (flush === "sync") {
|
|
196
|
+
job();
|
|
197
|
+
return;
|
|
1111
198
|
}
|
|
199
|
+
if (flush === "post") {
|
|
200
|
+
nextTick(() => queueJob(job));
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (isFirstRun) job();
|
|
204
|
+
else queueJob(job);
|
|
205
|
+
}
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/reactivity/watch.ts
|
|
208
|
+
function watch(source, cb, options = {}) {
|
|
209
|
+
var _options$flush;
|
|
210
|
+
const watchGetterContext = createWatchGetter(source);
|
|
211
|
+
const getter = applyDeepWatchGetter(watchGetterContext.getter, source, watchGetterContext.isMultiSource, watchGetterContext.isReactiveSource, options.deep);
|
|
1112
212
|
let cleanup;
|
|
1113
213
|
const onCleanup = (fn) => {
|
|
1114
214
|
cleanup = fn;
|
|
@@ -1117,43 +217,29 @@ function watch(source, cb, options = {}) {
|
|
|
1117
217
|
let runner;
|
|
1118
218
|
let paused = false;
|
|
1119
219
|
let pauseToken = 0;
|
|
220
|
+
let scheduledToken = pauseToken;
|
|
1120
221
|
let stopHandle;
|
|
1121
|
-
const cbWithOnce = options.once ? (value,
|
|
1122
|
-
cb(value,
|
|
222
|
+
const cbWithOnce = options.once ? (value, oldVal, cleanupRegister) => {
|
|
223
|
+
cb(value, oldVal, cleanupRegister);
|
|
1123
224
|
stopHandle();
|
|
1124
225
|
} : cb;
|
|
1125
226
|
const flush = (_options$flush = options.flush) !== null && _options$flush !== void 0 ? _options$flush : "pre";
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
if (!runner.active || paused || scheduledToken !== pauseToken) return;
|
|
227
|
+
const runJob = (token) => {
|
|
228
|
+
if (!runner.active || paused || token !== pauseToken) return;
|
|
1129
229
|
const newValue = runner();
|
|
1130
230
|
cleanup === null || cleanup === void 0 || cleanup();
|
|
1131
231
|
cbWithOnce(newValue, oldValue, onCleanup);
|
|
1132
232
|
oldValue = newValue;
|
|
1133
233
|
};
|
|
1134
|
-
const scheduledJob = () =>
|
|
1135
|
-
const scheduleJob = (
|
|
234
|
+
const scheduledJob = () => runJob(scheduledToken);
|
|
235
|
+
const scheduleJob = (isFirstRun) => {
|
|
1136
236
|
scheduledToken = pauseToken;
|
|
1137
|
-
|
|
1138
|
-
const token = scheduledToken;
|
|
1139
|
-
options.scheduler(() => jobRunner(token), isFirstRun);
|
|
1140
|
-
return;
|
|
1141
|
-
}
|
|
1142
|
-
if (flush === "sync") {
|
|
1143
|
-
scheduledJob();
|
|
1144
|
-
return;
|
|
1145
|
-
}
|
|
1146
|
-
if (flush === "post") {
|
|
1147
|
-
nextTick(() => queueJob(scheduledJob));
|
|
1148
|
-
return;
|
|
1149
|
-
}
|
|
1150
|
-
if (isFirstRun) scheduledJob();
|
|
1151
|
-
else queueJob(scheduledJob);
|
|
237
|
+
dispatchScheduledJob(scheduledJob, flush, isFirstRun, options.scheduler);
|
|
1152
238
|
};
|
|
1153
239
|
runner = effect(() => getter(), {
|
|
1154
240
|
scheduler: () => {
|
|
1155
241
|
if (paused) return;
|
|
1156
|
-
scheduleJob(
|
|
242
|
+
scheduleJob(false);
|
|
1157
243
|
},
|
|
1158
244
|
lazy: true
|
|
1159
245
|
});
|
|
@@ -1175,7 +261,7 @@ function watch(source, cb, options = {}) {
|
|
|
1175
261
|
paused = false;
|
|
1176
262
|
oldValue = runner();
|
|
1177
263
|
};
|
|
1178
|
-
if (options.immediate)
|
|
264
|
+
if (options.immediate) runJob(pauseToken);
|
|
1179
265
|
else oldValue = runner();
|
|
1180
266
|
onScopeDispose(stopHandle);
|
|
1181
267
|
return stopHandle;
|
|
@@ -1193,25 +279,16 @@ function watchEffect(effectFn, options = {}) {
|
|
|
1193
279
|
let runner;
|
|
1194
280
|
let paused = false;
|
|
1195
281
|
let pauseToken = 0;
|
|
1196
|
-
const flush = (_options$flush2 = options.flush) !== null && _options$flush2 !== void 0 ? _options$flush2 : "pre";
|
|
1197
282
|
let scheduledToken = pauseToken;
|
|
1198
|
-
const
|
|
1199
|
-
|
|
283
|
+
const flush = (_options$flush2 = options.flush) !== null && _options$flush2 !== void 0 ? _options$flush2 : "pre";
|
|
284
|
+
const runJob = (token) => {
|
|
285
|
+
if (!runner.active || paused || token !== pauseToken) return;
|
|
1200
286
|
runner();
|
|
1201
287
|
};
|
|
1202
|
-
const scheduledJob = () =>
|
|
288
|
+
const scheduledJob = () => runJob(scheduledToken);
|
|
1203
289
|
const scheduleJob = (isFirstRun) => {
|
|
1204
290
|
scheduledToken = pauseToken;
|
|
1205
|
-
|
|
1206
|
-
scheduledJob();
|
|
1207
|
-
return;
|
|
1208
|
-
}
|
|
1209
|
-
if (flush === "post") {
|
|
1210
|
-
nextTick(() => queueJob(scheduledJob));
|
|
1211
|
-
return;
|
|
1212
|
-
}
|
|
1213
|
-
if (isFirstRun) scheduledJob();
|
|
1214
|
-
else queueJob(scheduledJob);
|
|
291
|
+
dispatchScheduledJob(scheduledJob, flush, isFirstRun);
|
|
1215
292
|
};
|
|
1216
293
|
runner = effect(() => {
|
|
1217
294
|
cleanup === null || cleanup === void 0 || cleanup();
|
|
@@ -1243,26 +320,116 @@ function watchEffect(effectFn, options = {}) {
|
|
|
1243
320
|
paused = false;
|
|
1244
321
|
scheduleJob(true);
|
|
1245
322
|
};
|
|
1246
|
-
onScopeDispose(stopHandle);
|
|
1247
|
-
return stopHandle;
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
//#
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
323
|
+
onScopeDispose(stopHandle);
|
|
324
|
+
return stopHandle;
|
|
325
|
+
}
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region src/utils.ts
|
|
328
|
+
function capitalize(str) {
|
|
329
|
+
if (!str) return "";
|
|
330
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
331
|
+
}
|
|
332
|
+
function toPathSegments(path) {
|
|
333
|
+
if (!path) return [];
|
|
334
|
+
return path.split(".").map((segment) => segment.trim()).filter(Boolean);
|
|
335
|
+
}
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/runtime/internal.ts
|
|
338
|
+
function setComputedValue(setters, key, value) {
|
|
339
|
+
const setter = setters[key];
|
|
340
|
+
if (!setter) throw new Error(`计算属性 "${key}" 是只读的`);
|
|
341
|
+
setter(value);
|
|
342
|
+
}
|
|
343
|
+
function parseModelEventValue(event) {
|
|
344
|
+
if (event == null) return event;
|
|
345
|
+
if (typeof event === "object") {
|
|
346
|
+
if ("detail" in event && event.detail && "value" in event.detail) return event.detail.value;
|
|
347
|
+
if ("target" in event && event.target && "value" in event.target) return event.target.value;
|
|
348
|
+
}
|
|
349
|
+
return event;
|
|
350
|
+
}
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region src/runtime/bindModel.ts
|
|
353
|
+
function setWithSegments(target, segments, value) {
|
|
354
|
+
let current = target;
|
|
355
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
356
|
+
const key = segments[i];
|
|
357
|
+
if (current[key] == null || typeof current[key] !== "object") current[key] = {};
|
|
358
|
+
current = current[key];
|
|
359
|
+
}
|
|
360
|
+
current[segments[segments.length - 1]] = value;
|
|
361
|
+
}
|
|
362
|
+
function setByPath(state, computedRefs, computedSetters, segments, value) {
|
|
363
|
+
if (!segments.length) return;
|
|
364
|
+
const [head, ...rest] = segments;
|
|
365
|
+
if (!rest.length) {
|
|
366
|
+
if (computedRefs[head]) setComputedValue(computedSetters, head, value);
|
|
367
|
+
else {
|
|
368
|
+
const current = state[head];
|
|
369
|
+
if (isRef(current)) current.value = value;
|
|
370
|
+
else state[head] = value;
|
|
371
|
+
}
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (computedRefs[head]) {
|
|
375
|
+
setComputedValue(computedSetters, head, value);
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (state[head] == null || typeof state[head] !== "object") state[head] = {};
|
|
379
|
+
setWithSegments(state[head], rest, value);
|
|
380
|
+
}
|
|
381
|
+
function getFromPath(target, segments) {
|
|
382
|
+
return segments.reduce((acc, segment) => {
|
|
383
|
+
if (acc == null) return acc;
|
|
384
|
+
return acc[segment];
|
|
385
|
+
}, target);
|
|
386
|
+
}
|
|
387
|
+
function defaultParser(event) {
|
|
388
|
+
return parseModelEventValue(event);
|
|
389
|
+
}
|
|
390
|
+
function createBindModel(publicInstance, state, computedRefs, computedSetters) {
|
|
391
|
+
const bindModel = (path, bindingOptions) => {
|
|
392
|
+
const segments = toPathSegments(path);
|
|
393
|
+
if (!segments.length) throw new Error("bindModel 需要非空路径");
|
|
394
|
+
const resolveValue = () => getFromPath(publicInstance, segments);
|
|
395
|
+
const assignValue = (value) => {
|
|
396
|
+
setByPath(state, computedRefs, computedSetters, segments, value);
|
|
397
|
+
};
|
|
398
|
+
const defaultOptions = {
|
|
399
|
+
event: "input",
|
|
400
|
+
valueProp: "value",
|
|
401
|
+
parser: defaultParser,
|
|
402
|
+
formatter: (value) => value,
|
|
403
|
+
...bindingOptions
|
|
404
|
+
};
|
|
405
|
+
return {
|
|
406
|
+
get value() {
|
|
407
|
+
return resolveValue();
|
|
408
|
+
},
|
|
409
|
+
set value(nextValue) {
|
|
410
|
+
assignValue(nextValue);
|
|
411
|
+
},
|
|
412
|
+
update(nextValue) {
|
|
413
|
+
assignValue(nextValue);
|
|
414
|
+
},
|
|
415
|
+
model(modelOptions) {
|
|
416
|
+
const merged = {
|
|
417
|
+
...defaultOptions,
|
|
418
|
+
...modelOptions
|
|
419
|
+
};
|
|
420
|
+
const handlerKey = `on${capitalize(merged.event)}`;
|
|
421
|
+
const handler = (event) => {
|
|
422
|
+
assignValue(merged.parser(event));
|
|
423
|
+
};
|
|
424
|
+
return {
|
|
425
|
+
[merged.valueProp]: merged.formatter(resolveValue()),
|
|
426
|
+
[handlerKey]: handler
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
};
|
|
431
|
+
return bindModel;
|
|
1264
432
|
}
|
|
1265
|
-
|
|
1266
433
|
//#endregion
|
|
1267
434
|
//#region src/runtime/nativeBridge.ts
|
|
1268
435
|
const NATIVE_BRIDGE_MARKER = "__wevu_native_bridge__";
|
|
@@ -1281,7 +448,6 @@ function markNativeBridgeMethod(method) {
|
|
|
1281
448
|
function isNativeBridgeMethod(method) {
|
|
1282
449
|
return typeof method === "function" && Boolean(method[NATIVE_BRIDGE_MARKER]);
|
|
1283
450
|
}
|
|
1284
|
-
|
|
1285
451
|
//#endregion
|
|
1286
452
|
//#region src/runtime/app/computed.ts
|
|
1287
453
|
function createComputedAccessors(options) {
|
|
@@ -1344,7 +510,6 @@ function createComputedAccessors(options) {
|
|
|
1344
510
|
})
|
|
1345
511
|
};
|
|
1346
512
|
}
|
|
1347
|
-
|
|
1348
513
|
//#endregion
|
|
1349
514
|
//#region src/runtime/app/context.ts
|
|
1350
515
|
function createRuntimeContext(options) {
|
|
@@ -1366,7 +531,7 @@ function createRuntimeContext(options) {
|
|
|
1366
531
|
const isValidNativeCandidate = (candidate) => {
|
|
1367
532
|
if (!candidate || typeof candidate !== "object") return false;
|
|
1368
533
|
if (candidate === target || candidate === receiver || candidate === runtimeProxy) return false;
|
|
1369
|
-
if (isBridgeMethod(candidate, "triggerEvent") || isBridgeMethod(candidate, "createSelectorQuery") || isBridgeMethod(candidate, "setData")) return false;
|
|
534
|
+
if (isBridgeMethod(candidate, "triggerEvent") || isBridgeMethod(candidate, "createSelectorQuery") || isBridgeMethod(candidate, "createIntersectionObserver") || isBridgeMethod(candidate, "setData")) return false;
|
|
1370
535
|
return true;
|
|
1371
536
|
};
|
|
1372
537
|
const directNative = rawTarget.__wevuNativeInstance;
|
|
@@ -1470,6 +635,7 @@ function createRuntimeContext(options) {
|
|
|
1470
635
|
});
|
|
1471
636
|
installNativeMethodBridge("triggerEvent");
|
|
1472
637
|
installNativeMethodBridge("createSelectorQuery");
|
|
638
|
+
installNativeMethodBridge("createIntersectionObserver");
|
|
1473
639
|
installNativeMethodBridge("setData");
|
|
1474
640
|
Object.keys(computedDefs).forEach((key) => {
|
|
1475
641
|
const definition = computedDefs[key];
|
|
@@ -1497,7 +663,34 @@ function createRuntimeContext(options) {
|
|
|
1497
663
|
}
|
|
1498
664
|
};
|
|
1499
665
|
}
|
|
1500
|
-
|
|
666
|
+
//#endregion
|
|
667
|
+
//#region src/runtime/app/diagnostics.ts
|
|
668
|
+
function isFallbackReason(reason) {
|
|
669
|
+
return reason !== "patch" && reason !== "diff";
|
|
670
|
+
}
|
|
671
|
+
function createDiagnosticsLogger(mode) {
|
|
672
|
+
if (mode === "off") return;
|
|
673
|
+
return (info) => {
|
|
674
|
+
if (mode === "fallback" && !isFallbackReason(info.reason)) return;
|
|
675
|
+
const bytes = typeof info.bytes === "number" ? info.bytes : info.estimatedBytes;
|
|
676
|
+
const bytesText = typeof bytes === "number" ? `${bytes}B` : "unknown";
|
|
677
|
+
const parts = [
|
|
678
|
+
`mode=${info.mode}`,
|
|
679
|
+
`reason=${info.reason}`,
|
|
680
|
+
`pending=${info.pendingPatchKeys}`,
|
|
681
|
+
`keys=${info.payloadKeys}`,
|
|
682
|
+
`bytes=${bytesText}`
|
|
683
|
+
];
|
|
684
|
+
if (typeof info.mergedSiblingParents === "number") parts.push(`mergedParents=${info.mergedSiblingParents}`);
|
|
685
|
+
if (typeof info.computedDirtyKeys === "number") parts.push(`computedDirty=${info.computedDirtyKeys}`);
|
|
686
|
+
const message = `[wevu:setData] ${parts.join(" ")}`;
|
|
687
|
+
if (isFallbackReason(info.reason)) {
|
|
688
|
+
console.warn(message);
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
console.info(message);
|
|
692
|
+
};
|
|
693
|
+
}
|
|
1501
694
|
//#endregion
|
|
1502
695
|
//#region src/runtime/noSetData.ts
|
|
1503
696
|
const NO_SETDATA = Symbol("wevu.noSetData");
|
|
@@ -1513,10 +706,9 @@ function markNoSetData(value) {
|
|
|
1513
706
|
function isNoSetData(value) {
|
|
1514
707
|
return typeof value === "object" && value !== null && value[NO_SETDATA] === true;
|
|
1515
708
|
}
|
|
1516
|
-
|
|
1517
709
|
//#endregion
|
|
1518
710
|
//#region src/runtime/diff.ts
|
|
1519
|
-
function isPlainObject$
|
|
711
|
+
function isPlainObject$1(value) {
|
|
1520
712
|
if (Object.prototype.toString.call(value) !== "[object Object]") return false;
|
|
1521
713
|
const proto = Object.getPrototypeOf(value);
|
|
1522
714
|
return proto === null || proto === Object.prototype;
|
|
@@ -1632,7 +824,7 @@ function isPlainObjectEqual(a, b, compare) {
|
|
|
1632
824
|
function isDeepEqual(a, b) {
|
|
1633
825
|
if (Object.is(a, b)) return true;
|
|
1634
826
|
if (Array.isArray(a) && Array.isArray(b)) return isArrayEqual(a, b, isDeepEqual);
|
|
1635
|
-
if (isPlainObject$
|
|
827
|
+
if (isPlainObject$1(a) && isPlainObject$1(b)) return isPlainObjectEqual(a, b, isDeepEqual);
|
|
1636
828
|
return false;
|
|
1637
829
|
}
|
|
1638
830
|
function normalizeSetDataValue$1(value) {
|
|
@@ -1640,7 +832,7 @@ function normalizeSetDataValue$1(value) {
|
|
|
1640
832
|
}
|
|
1641
833
|
function assignNestedDiff(prev, next, path, output) {
|
|
1642
834
|
if (isDeepEqual(prev, next)) return;
|
|
1643
|
-
if (isPlainObject$
|
|
835
|
+
if (isPlainObject$1(prev) && isPlainObject$1(next)) {
|
|
1644
836
|
for (const key of Object.keys(next)) {
|
|
1645
837
|
if (!Object.prototype.hasOwnProperty.call(prev, key)) {
|
|
1646
838
|
output[`${path}.${key}`] = normalizeSetDataValue$1(next[key]);
|
|
@@ -1663,7 +855,6 @@ function diffSnapshots(prev, next) {
|
|
|
1663
855
|
for (const key of Object.keys(prev)) if (!Object.prototype.hasOwnProperty.call(next, key)) diff[key] = null;
|
|
1664
856
|
return diff;
|
|
1665
857
|
}
|
|
1666
|
-
|
|
1667
858
|
//#endregion
|
|
1668
859
|
//#region src/runtime/app/setData/payload.ts
|
|
1669
860
|
function collapsePayload(input) {
|
|
@@ -1820,7 +1011,6 @@ function mergeSiblingPayload(options) {
|
|
|
1820
1011
|
merged
|
|
1821
1012
|
};
|
|
1822
1013
|
}
|
|
1823
|
-
|
|
1824
1014
|
//#endregion
|
|
1825
1015
|
//#region src/runtime/app/setData/snapshot.ts
|
|
1826
1016
|
function normalizeSetDataValue(value) {
|
|
@@ -1918,7 +1108,6 @@ function collectSnapshot(options) {
|
|
|
1918
1108
|
}
|
|
1919
1109
|
return out;
|
|
1920
1110
|
}
|
|
1921
|
-
|
|
1922
1111
|
//#endregion
|
|
1923
1112
|
//#region src/runtime/app/setData/patchScheduler.ts
|
|
1924
1113
|
function runPatchUpdate(options) {
|
|
@@ -2064,7 +1253,6 @@ function runPatchUpdate(options) {
|
|
|
2064
1253
|
payloadKeys: Object.keys(collapsedPayload).length
|
|
2065
1254
|
});
|
|
2066
1255
|
}
|
|
2067
|
-
|
|
2068
1256
|
//#endregion
|
|
2069
1257
|
//#region src/runtime/app/setData/scheduler.ts
|
|
2070
1258
|
function createSetDataScheduler(options) {
|
|
@@ -2195,12 +1383,12 @@ function createSetDataScheduler(options) {
|
|
|
2195
1383
|
getLatestSnapshot: () => latestSnapshot
|
|
2196
1384
|
};
|
|
2197
1385
|
}
|
|
2198
|
-
|
|
2199
1386
|
//#endregion
|
|
2200
1387
|
//#region src/runtime/app/setDataOptions.ts
|
|
2201
1388
|
function resolveSetDataOptions(setDataOptions) {
|
|
2202
|
-
var _setDataOptions$inclu, _setDataOptions$strat, _setDataOptions$merge, _setDataOptions$compu, _setDataOptions$debug;
|
|
1389
|
+
var _setDataOptions$inclu, _setDataOptions$suspe, _setDataOptions$strat, _setDataOptions$merge, _setDataOptions$compu, _setDataOptions$diagn, _setDataOptions$debug;
|
|
2203
1390
|
const includeComputed = (_setDataOptions$inclu = setDataOptions === null || setDataOptions === void 0 ? void 0 : setDataOptions.includeComputed) !== null && _setDataOptions$inclu !== void 0 ? _setDataOptions$inclu : true;
|
|
1391
|
+
const suspendWhenHidden = (_setDataOptions$suspe = setDataOptions === null || setDataOptions === void 0 ? void 0 : setDataOptions.suspendWhenHidden) !== null && _setDataOptions$suspe !== void 0 ? _setDataOptions$suspe : false;
|
|
2204
1392
|
const setDataStrategy = (_setDataOptions$strat = setDataOptions === null || setDataOptions === void 0 ? void 0 : setDataOptions.strategy) !== null && _setDataOptions$strat !== void 0 ? _setDataOptions$strat : "diff";
|
|
2205
1393
|
const maxPatchKeys = typeof (setDataOptions === null || setDataOptions === void 0 ? void 0 : setDataOptions.maxPatchKeys) === "number" ? Math.max(0, setDataOptions.maxPatchKeys) : Number.POSITIVE_INFINITY;
|
|
2206
1394
|
const maxPayloadBytes = typeof (setDataOptions === null || setDataOptions === void 0 ? void 0 : setDataOptions.maxPayloadBytes) === "number" ? Math.max(0, setDataOptions.maxPayloadBytes) : Number.POSITIVE_INFINITY;
|
|
@@ -2214,6 +1402,7 @@ function resolveSetDataOptions(setDataOptions) {
|
|
|
2214
1402
|
const prelinkMaxDepth = setDataOptions === null || setDataOptions === void 0 ? void 0 : setDataOptions.prelinkMaxDepth;
|
|
2215
1403
|
const prelinkMaxKeys = setDataOptions === null || setDataOptions === void 0 ? void 0 : setDataOptions.prelinkMaxKeys;
|
|
2216
1404
|
const debug = setDataOptions === null || setDataOptions === void 0 ? void 0 : setDataOptions.debug;
|
|
1405
|
+
const diagnostics = (_setDataOptions$diagn = setDataOptions === null || setDataOptions === void 0 ? void 0 : setDataOptions.diagnostics) !== null && _setDataOptions$diagn !== void 0 ? _setDataOptions$diagn : "off";
|
|
2217
1406
|
const debugWhen = (_setDataOptions$debug = setDataOptions === null || setDataOptions === void 0 ? void 0 : setDataOptions.debugWhen) !== null && _setDataOptions$debug !== void 0 ? _setDataOptions$debug : "fallback";
|
|
2218
1407
|
const debugSampleRate = typeof (setDataOptions === null || setDataOptions === void 0 ? void 0 : setDataOptions.debugSampleRate) === "number" ? Math.min(1, Math.max(0, setDataOptions.debugSampleRate)) : 1;
|
|
2219
1408
|
const elevateTopKeyThreshold = typeof (setDataOptions === null || setDataOptions === void 0 ? void 0 : setDataOptions.elevateTopKeyThreshold) === "number" ? Math.max(0, Math.floor(setDataOptions.elevateTopKeyThreshold)) : Number.POSITIVE_INFINITY;
|
|
@@ -2228,6 +1417,7 @@ function resolveSetDataOptions(setDataOptions) {
|
|
|
2228
1417
|
};
|
|
2229
1418
|
return {
|
|
2230
1419
|
includeComputed,
|
|
1420
|
+
suspendWhenHidden,
|
|
2231
1421
|
setDataStrategy,
|
|
2232
1422
|
maxPatchKeys,
|
|
2233
1423
|
maxPayloadBytes,
|
|
@@ -2241,6 +1431,7 @@ function resolveSetDataOptions(setDataOptions) {
|
|
|
2241
1431
|
prelinkMaxDepth,
|
|
2242
1432
|
prelinkMaxKeys,
|
|
2243
1433
|
debug,
|
|
1434
|
+
diagnostics,
|
|
2244
1435
|
debugWhen,
|
|
2245
1436
|
debugSampleRate,
|
|
2246
1437
|
elevateTopKeyThreshold,
|
|
@@ -2251,101 +1442,169 @@ function resolveSetDataOptions(setDataOptions) {
|
|
|
2251
1442
|
shouldIncludeKey
|
|
2252
1443
|
};
|
|
2253
1444
|
}
|
|
2254
|
-
|
|
2255
|
-
//#endregion
|
|
2256
|
-
//#region src/utils.ts
|
|
2257
|
-
function capitalize(str) {
|
|
2258
|
-
if (!str) return "";
|
|
2259
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
2260
|
-
}
|
|
2261
|
-
function toPathSegments(path) {
|
|
2262
|
-
if (!path) return [];
|
|
2263
|
-
return path.split(".").map((segment) => segment.trim()).filter(Boolean);
|
|
2264
|
-
}
|
|
2265
|
-
|
|
2266
1445
|
//#endregion
|
|
2267
|
-
//#region src/runtime/
|
|
2268
|
-
function
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
1446
|
+
//#region src/runtime/app/mount.ts
|
|
1447
|
+
function createWatchStopHandle(cleanup, baseHandle) {
|
|
1448
|
+
const stopHandle = (() => {
|
|
1449
|
+
cleanup();
|
|
1450
|
+
});
|
|
1451
|
+
stopHandle.stop = () => stopHandle();
|
|
1452
|
+
stopHandle.pause = () => {
|
|
1453
|
+
var _baseHandle$pause;
|
|
1454
|
+
baseHandle === null || baseHandle === void 0 || (_baseHandle$pause = baseHandle.pause) === null || _baseHandle$pause === void 0 || _baseHandle$pause.call(baseHandle);
|
|
1455
|
+
};
|
|
1456
|
+
stopHandle.resume = () => {
|
|
1457
|
+
var _baseHandle$resume;
|
|
1458
|
+
baseHandle === null || baseHandle === void 0 || (_baseHandle$resume = baseHandle.resume) === null || _baseHandle$resume === void 0 || _baseHandle$resume.call(baseHandle);
|
|
1459
|
+
};
|
|
1460
|
+
return stopHandle;
|
|
2276
1461
|
}
|
|
2277
|
-
function
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
if (
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
1462
|
+
function createRuntimeMount(options) {
|
|
1463
|
+
const { data, resolvedComputed, resolvedMethods, appConfig, setDataOptions } = options;
|
|
1464
|
+
return (adapter) => {
|
|
1465
|
+
const rawState = (data !== null && data !== void 0 ? data : (() => ({})))();
|
|
1466
|
+
if (rawState && typeof rawState === "object" && !Object.prototype.hasOwnProperty.call(rawState, "__wevuProps")) try {
|
|
1467
|
+
Object.defineProperty(rawState, "__wevuProps", {
|
|
1468
|
+
value: shallowReactive(Object.create(null)),
|
|
1469
|
+
configurable: true,
|
|
1470
|
+
enumerable: false,
|
|
1471
|
+
writable: false
|
|
1472
|
+
});
|
|
1473
|
+
} catch (_unused) {}
|
|
1474
|
+
const state = reactive(rawState);
|
|
1475
|
+
const computedDefs = resolvedComputed;
|
|
1476
|
+
const methodDefs = resolvedMethods;
|
|
1477
|
+
let mounted = true;
|
|
1478
|
+
const stopHandles = [];
|
|
1479
|
+
const { includeComputed, setDataStrategy, maxPatchKeys, maxPayloadBytes, mergeSiblingThreshold, mergeSiblingMaxInflationRatio, mergeSiblingMaxParentBytes, mergeSiblingSkipArray, computedCompare, computedCompareMaxDepth, computedCompareMaxKeys, prelinkMaxDepth, prelinkMaxKeys, debug, diagnostics, debugWhen, debugSampleRate, elevateTopKeyThreshold, toPlainMaxDepth, toPlainMaxKeys, shouldIncludeKey } = resolveSetDataOptions(setDataOptions);
|
|
1480
|
+
const diagnosticsLogger = createDiagnosticsLogger(diagnostics);
|
|
1481
|
+
const mergedDebug = debug || diagnosticsLogger ? (info) => {
|
|
1482
|
+
if (typeof debug === "function") debug(info);
|
|
1483
|
+
diagnosticsLogger === null || diagnosticsLogger === void 0 || diagnosticsLogger(info);
|
|
1484
|
+
} : void 0;
|
|
1485
|
+
const mergedDebugWhen = diagnostics === "always" ? "always" : debugWhen;
|
|
1486
|
+
const { boundMethods, computedRefs, computedSetters, dirtyComputedKeys, computedProxy, publicInstance, touchSetupMethodsVersion } = createRuntimeContext({
|
|
1487
|
+
state,
|
|
1488
|
+
computedDefs,
|
|
1489
|
+
methodDefs,
|
|
1490
|
+
appConfig,
|
|
1491
|
+
includeComputed,
|
|
1492
|
+
setDataStrategy
|
|
1493
|
+
});
|
|
1494
|
+
const currentAdapter = adapter !== null && adapter !== void 0 ? adapter : { setData: () => {} };
|
|
1495
|
+
const stateRootRaw = toRaw(state);
|
|
1496
|
+
let tracker;
|
|
1497
|
+
const scheduler = createSetDataScheduler({
|
|
1498
|
+
state,
|
|
1499
|
+
computedRefs,
|
|
1500
|
+
dirtyComputedKeys,
|
|
1501
|
+
includeComputed,
|
|
1502
|
+
setDataStrategy,
|
|
1503
|
+
computedCompare,
|
|
1504
|
+
computedCompareMaxDepth,
|
|
1505
|
+
computedCompareMaxKeys,
|
|
1506
|
+
currentAdapter,
|
|
1507
|
+
shouldIncludeKey,
|
|
1508
|
+
maxPatchKeys,
|
|
1509
|
+
maxPayloadBytes,
|
|
1510
|
+
mergeSiblingThreshold,
|
|
1511
|
+
mergeSiblingMaxInflationRatio,
|
|
1512
|
+
mergeSiblingMaxParentBytes,
|
|
1513
|
+
mergeSiblingSkipArray,
|
|
1514
|
+
elevateTopKeyThreshold,
|
|
1515
|
+
toPlainMaxDepth,
|
|
1516
|
+
toPlainMaxKeys,
|
|
1517
|
+
debug: mergedDebug,
|
|
1518
|
+
debugWhen: mergedDebugWhen,
|
|
1519
|
+
debugSampleRate,
|
|
1520
|
+
runTracker: () => tracker === null || tracker === void 0 ? void 0 : tracker(),
|
|
1521
|
+
isMounted: () => mounted
|
|
1522
|
+
});
|
|
1523
|
+
const job = () => scheduler.job(stateRootRaw);
|
|
1524
|
+
const mutationRecorder = (record) => scheduler.mutationRecorder(record, stateRootRaw);
|
|
1525
|
+
tracker = effect(() => {
|
|
1526
|
+
touchReactive(state);
|
|
1527
|
+
const runtimeProps = state.__wevuProps;
|
|
1528
|
+
if (isReactive(runtimeProps)) touchReactive(runtimeProps);
|
|
1529
|
+
const runtimeAttrs = state.__wevuAttrs;
|
|
1530
|
+
if (isReactive(runtimeAttrs)) touchReactive(runtimeAttrs);
|
|
1531
|
+
Object.keys(state).forEach((key) => {
|
|
1532
|
+
const v = state[key];
|
|
1533
|
+
if (isRef(v)) {
|
|
1534
|
+
const inner = v.value;
|
|
1535
|
+
if (isReactive(inner)) touchReactive(inner);
|
|
1536
|
+
} else if (isReactive(v)) touchReactive(v);
|
|
1537
|
+
});
|
|
1538
|
+
}, {
|
|
1539
|
+
lazy: true,
|
|
1540
|
+
scheduler: () => queueJob(job)
|
|
1541
|
+
});
|
|
1542
|
+
job();
|
|
1543
|
+
stopHandles.push(createWatchStopHandle(() => stop(tracker)));
|
|
1544
|
+
if (setDataStrategy === "patch") {
|
|
1545
|
+
prelinkReactiveTree(state, {
|
|
1546
|
+
shouldIncludeTopKey: shouldIncludeKey,
|
|
1547
|
+
maxDepth: prelinkMaxDepth,
|
|
1548
|
+
maxKeys: prelinkMaxKeys
|
|
1549
|
+
});
|
|
1550
|
+
addMutationRecorder(mutationRecorder);
|
|
1551
|
+
stopHandles.push(createWatchStopHandle(() => removeMutationRecorder(mutationRecorder)));
|
|
1552
|
+
stopHandles.push(createWatchStopHandle(() => clearPatchIndices(state)));
|
|
2286
1553
|
}
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
}
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
}
|
|
2305
|
-
|
|
2306
|
-
const bindModel = (path, bindingOptions) => {
|
|
2307
|
-
const segments = toPathSegments(path);
|
|
2308
|
-
if (!segments.length) throw new Error("bindModel 需要非空路径");
|
|
2309
|
-
const resolveValue = () => getFromPath(publicInstance, segments);
|
|
2310
|
-
const assignValue = (value) => {
|
|
2311
|
-
setByPath(state, computedRefs, computedSetters, segments, value);
|
|
2312
|
-
};
|
|
2313
|
-
const defaultOptions = {
|
|
2314
|
-
event: "input",
|
|
2315
|
-
valueProp: "value",
|
|
2316
|
-
parser: defaultParser,
|
|
2317
|
-
formatter: (value) => value,
|
|
2318
|
-
...bindingOptions
|
|
1554
|
+
function registerWatch(source, cb, watchOptions) {
|
|
1555
|
+
const stopHandle = watch(source, (value, oldValue) => cb(value, oldValue), watchOptions);
|
|
1556
|
+
stopHandles.push(stopHandle);
|
|
1557
|
+
return createWatchStopHandle(() => {
|
|
1558
|
+
stopHandle();
|
|
1559
|
+
const index = stopHandles.indexOf(stopHandle);
|
|
1560
|
+
if (index >= 0) stopHandles.splice(index, 1);
|
|
1561
|
+
}, stopHandle);
|
|
1562
|
+
}
|
|
1563
|
+
const bindModel = createBindModel(publicInstance, state, computedRefs, computedSetters);
|
|
1564
|
+
const unmount = () => {
|
|
1565
|
+
if (!mounted) return;
|
|
1566
|
+
mounted = false;
|
|
1567
|
+
stopHandles.forEach((handle) => {
|
|
1568
|
+
try {
|
|
1569
|
+
handle();
|
|
1570
|
+
} catch (_unused2) {}
|
|
1571
|
+
});
|
|
1572
|
+
stopHandles.length = 0;
|
|
2319
1573
|
};
|
|
2320
|
-
|
|
2321
|
-
get
|
|
2322
|
-
return
|
|
1574
|
+
const runtimeInstance = {
|
|
1575
|
+
get state() {
|
|
1576
|
+
return state;
|
|
2323
1577
|
},
|
|
2324
|
-
|
|
2325
|
-
|
|
1578
|
+
get proxy() {
|
|
1579
|
+
return publicInstance;
|
|
2326
1580
|
},
|
|
2327
|
-
|
|
2328
|
-
|
|
1581
|
+
get methods() {
|
|
1582
|
+
return boundMethods;
|
|
2329
1583
|
},
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
[merged.valueProp]: merged.formatter(resolveValue()),
|
|
2341
|
-
[handlerKey]: handler
|
|
2342
|
-
};
|
|
2343
|
-
}
|
|
1584
|
+
get computed() {
|
|
1585
|
+
return computedProxy;
|
|
1586
|
+
},
|
|
1587
|
+
get adapter() {
|
|
1588
|
+
return currentAdapter;
|
|
1589
|
+
},
|
|
1590
|
+
bindModel,
|
|
1591
|
+
watch: registerWatch,
|
|
1592
|
+
snapshot: () => scheduler.snapshot(),
|
|
1593
|
+
unmount
|
|
2344
1594
|
};
|
|
1595
|
+
try {
|
|
1596
|
+
Object.defineProperty(runtimeInstance, "__wevu_touchSetupMethodsVersion", {
|
|
1597
|
+
value: touchSetupMethodsVersion,
|
|
1598
|
+
configurable: true,
|
|
1599
|
+
enumerable: false,
|
|
1600
|
+
writable: false
|
|
1601
|
+
});
|
|
1602
|
+
} catch (_unused3) {
|
|
1603
|
+
runtimeInstance.__wevu_touchSetupMethodsVersion = touchSetupMethodsVersion;
|
|
1604
|
+
}
|
|
1605
|
+
return runtimeInstance;
|
|
2345
1606
|
};
|
|
2346
|
-
return bindModel;
|
|
2347
1607
|
}
|
|
2348
|
-
|
|
2349
1608
|
//#endregion
|
|
2350
1609
|
//#region src/runtime/defaults.ts
|
|
2351
1610
|
const INTERNAL_DEFAULTS_SCOPE_KEY = "__wevuDefaultsScope";
|
|
@@ -2375,262 +1634,37 @@ function mergeDefaults(defaults, options) {
|
|
|
2375
1634
|
};
|
|
2376
1635
|
return merged;
|
|
2377
1636
|
}
|
|
2378
|
-
function mergeWithDefaults(defaults, options) {
|
|
2379
|
-
return mergeDefaults(defaults, options);
|
|
2380
|
-
}
|
|
2381
|
-
function mergeWevuDefaults(base, next) {
|
|
2382
|
-
return {
|
|
2383
|
-
app: mergeDefaults(base.app, next.app),
|
|
2384
|
-
component: mergeDefaults(base.component, next.component)
|
|
2385
|
-
};
|
|
2386
|
-
}
|
|
2387
|
-
function setWevuDefaults(next) {
|
|
2388
|
-
currentDefaults = mergeWevuDefaults(currentDefaults, next);
|
|
2389
|
-
}
|
|
2390
|
-
function resetWevuDefaults() {
|
|
2391
|
-
currentDefaults = {};
|
|
2392
|
-
}
|
|
2393
|
-
/**
|
|
2394
|
-
* 将默认配置应用到 App 选项(框架内部使用)。
|
|
2395
|
-
* @internal
|
|
2396
|
-
*/
|
|
2397
|
-
function applyWevuAppDefaults(options) {
|
|
2398
|
-
return mergeWithDefaults(currentDefaults.app, options);
|
|
2399
|
-
}
|
|
2400
|
-
/**
|
|
2401
|
-
* 将默认配置应用到组件选项(框架内部使用)。
|
|
2402
|
-
* @internal
|
|
2403
|
-
*/
|
|
2404
|
-
function applyWevuComponentDefaults(options) {
|
|
2405
|
-
return mergeWithDefaults(currentDefaults.component, options);
|
|
2406
|
-
}
|
|
2407
|
-
|
|
2408
|
-
//#endregion
|
|
2409
|
-
//#region src/runtime/platform.ts
|
|
2410
|
-
function getGlobalRuntime() {
|
|
2411
|
-
if (typeof globalThis === "undefined") return;
|
|
2412
|
-
return globalThis;
|
|
2413
|
-
}
|
|
2414
|
-
function getMiniProgramGlobalObject() {
|
|
2415
|
-
var _env;
|
|
2416
|
-
const globalRuntime = getGlobalRuntime();
|
|
2417
|
-
const compiledPlatform = (_env = import.meta.env) === null || _env === void 0 ? void 0 : _env.PLATFORM;
|
|
2418
|
-
if (compiledPlatform === "tt") return globalRuntime === null || globalRuntime === void 0 ? void 0 : globalRuntime.tt;
|
|
2419
|
-
if (compiledPlatform === "alipay" || compiledPlatform === "my") return globalRuntime === null || globalRuntime === void 0 ? void 0 : globalRuntime.my;
|
|
2420
|
-
if (compiledPlatform === "weapp" || compiledPlatform === "wx") return globalRuntime === null || globalRuntime === void 0 ? void 0 : globalRuntime.wx;
|
|
2421
|
-
if (globalRuntime === null || globalRuntime === void 0 ? void 0 : globalRuntime.wx) return globalRuntime.wx;
|
|
2422
|
-
if (globalRuntime === null || globalRuntime === void 0 ? void 0 : globalRuntime.my) return globalRuntime.my;
|
|
2423
|
-
if (globalRuntime === null || globalRuntime === void 0 ? void 0 : globalRuntime.tt) return globalRuntime.tt;
|
|
2424
|
-
}
|
|
2425
|
-
function getScopedSlotHostGlobalObject() {
|
|
2426
|
-
var _getMiniProgramGlobal;
|
|
2427
|
-
return (_getMiniProgramGlobal = getMiniProgramGlobalObject()) !== null && _getMiniProgramGlobal !== void 0 ? _getMiniProgramGlobal : getGlobalRuntime();
|
|
2428
|
-
}
|
|
2429
|
-
|
|
2430
|
-
//#endregion
|
|
2431
|
-
//#region src/runtime/hooks.ts
|
|
2432
|
-
let __currentInstance;
|
|
2433
|
-
let __currentSetupContext;
|
|
2434
|
-
function getCurrentInstance() {
|
|
2435
|
-
return __currentInstance;
|
|
2436
|
-
}
|
|
2437
|
-
/**
|
|
2438
|
-
* 设置当前运行时实例(框架内部使用)。
|
|
2439
|
-
* @internal
|
|
2440
|
-
*/
|
|
2441
|
-
function setCurrentInstance(inst) {
|
|
2442
|
-
__currentInstance = inst;
|
|
2443
|
-
}
|
|
2444
|
-
function getCurrentSetupContext() {
|
|
2445
|
-
return __currentSetupContext;
|
|
2446
|
-
}
|
|
2447
|
-
/**
|
|
2448
|
-
* 设置当前 setup 上下文(框架内部使用)。
|
|
2449
|
-
* @internal
|
|
2450
|
-
*/
|
|
2451
|
-
function setCurrentSetupContext(ctx) {
|
|
2452
|
-
__currentSetupContext = ctx;
|
|
2453
|
-
}
|
|
2454
|
-
function assertInSetup(name) {
|
|
2455
|
-
if (!__currentInstance) throw new Error(`${name}() 必须在 setup() 的同步阶段调用`);
|
|
2456
|
-
return __currentInstance;
|
|
2457
|
-
}
|
|
2458
|
-
function ensureHookBucket(target) {
|
|
2459
|
-
if (!target.__wevuHooks) target.__wevuHooks = Object.create(null);
|
|
2460
|
-
return target.__wevuHooks;
|
|
2461
|
-
}
|
|
2462
|
-
function pushHook(target, name, handler, { single = false } = {}) {
|
|
2463
|
-
const bucket = ensureHookBucket(target);
|
|
2464
|
-
if (single) bucket[name] = handler;
|
|
2465
|
-
else {
|
|
2466
|
-
var _bucket$name;
|
|
2467
|
-
((_bucket$name = bucket[name]) !== null && _bucket$name !== void 0 ? _bucket$name : bucket[name] = []).push(handler);
|
|
2468
|
-
}
|
|
2469
|
-
}
|
|
2470
|
-
function ensureSinglePageHookOnInstance(target, name) {
|
|
2471
|
-
var _ref, _ref$__wevuShareHookB;
|
|
2472
|
-
const bridges = (_ref$__wevuShareHookB = (_ref = target).__wevuShareHookBridges) !== null && _ref$__wevuShareHookB !== void 0 ? _ref$__wevuShareHookB : _ref.__wevuShareHookBridges = Object.create(null);
|
|
2473
|
-
if (typeof bridges[name] === "function") return;
|
|
2474
|
-
const original = target[name];
|
|
2475
|
-
const bridge = function onWevuShareHookBridge(...args) {
|
|
2476
|
-
var _runtime$proxy;
|
|
2477
|
-
const hooks = this.__wevuHooks;
|
|
2478
|
-
const entry = hooks === null || hooks === void 0 ? void 0 : hooks[name];
|
|
2479
|
-
const runtime = this.__wevu;
|
|
2480
|
-
const ctx = (_runtime$proxy = runtime === null || runtime === void 0 ? void 0 : runtime.proxy) !== null && _runtime$proxy !== void 0 ? _runtime$proxy : this;
|
|
2481
|
-
let ret;
|
|
2482
|
-
if (typeof entry === "function") try {
|
|
2483
|
-
ret = entry.apply(ctx, args);
|
|
2484
|
-
} catch (_unused) {
|
|
2485
|
-
ret = void 0;
|
|
2486
|
-
}
|
|
2487
|
-
else if (Array.isArray(entry)) for (const fn of entry) try {
|
|
2488
|
-
ret = fn.apply(ctx, args);
|
|
2489
|
-
} catch (_unused2) {}
|
|
2490
|
-
if (ret !== void 0) return ret;
|
|
2491
|
-
if (typeof original === "function") return original.apply(this, args);
|
|
2492
|
-
};
|
|
2493
|
-
bridges[name] = bridge;
|
|
2494
|
-
target[name] = bridge;
|
|
2495
|
-
}
|
|
2496
|
-
function ensurePageShareMenusOnSetup(target) {
|
|
2497
|
-
var _target$__wevuHooks;
|
|
2498
|
-
const wxGlobal = getMiniProgramGlobalObject();
|
|
2499
|
-
if (!wxGlobal || typeof wxGlobal.showShareMenu !== "function") return;
|
|
2500
|
-
const hooks = (_target$__wevuHooks = target.__wevuHooks) !== null && _target$__wevuHooks !== void 0 ? _target$__wevuHooks : {};
|
|
2501
|
-
const hasShareAppMessage = typeof hooks.onShareAppMessage === "function";
|
|
2502
|
-
const hasShareTimeline = typeof hooks.onShareTimeline === "function";
|
|
2503
|
-
if (!hasShareAppMessage && !hasShareTimeline) return;
|
|
2504
|
-
const menus = ["shareAppMessage"];
|
|
2505
|
-
if (hasShareTimeline) menus.push("shareTimeline");
|
|
2506
|
-
try {
|
|
2507
|
-
wxGlobal.showShareMenu({
|
|
2508
|
-
withShareTicket: true,
|
|
2509
|
-
menus
|
|
2510
|
-
});
|
|
2511
|
-
} catch (_unused3) {}
|
|
2512
|
-
}
|
|
2513
|
-
/**
|
|
2514
|
-
* 调用批量 hook(框架内部调度入口)。
|
|
2515
|
-
* @internal
|
|
2516
|
-
*/
|
|
2517
|
-
function callHookList(target, name, args = []) {
|
|
2518
|
-
var _runtime$proxy2;
|
|
2519
|
-
const hooks = target.__wevuHooks;
|
|
2520
|
-
if (!hooks) return;
|
|
2521
|
-
const list = hooks[name];
|
|
2522
|
-
if (!list) return;
|
|
2523
|
-
const runtime = target.__wevu;
|
|
2524
|
-
const ctx = (_runtime$proxy2 = runtime === null || runtime === void 0 ? void 0 : runtime.proxy) !== null && _runtime$proxy2 !== void 0 ? _runtime$proxy2 : target;
|
|
2525
|
-
if (Array.isArray(list)) for (const fn of list) try {
|
|
2526
|
-
fn.apply(ctx, args);
|
|
2527
|
-
} catch (_unused4) {}
|
|
2528
|
-
else if (typeof list === "function") try {
|
|
2529
|
-
list.apply(ctx, args);
|
|
2530
|
-
} catch (_unused5) {}
|
|
2531
|
-
}
|
|
2532
|
-
/**
|
|
2533
|
-
* 调用返回值型 hook(框架内部调度入口)。
|
|
2534
|
-
* @internal
|
|
2535
|
-
*/
|
|
2536
|
-
function callHookReturn(target, name, args = []) {
|
|
2537
|
-
var _runtime$proxy3;
|
|
2538
|
-
const hooks = target.__wevuHooks;
|
|
2539
|
-
if (!hooks) return;
|
|
2540
|
-
const entry = hooks[name];
|
|
2541
|
-
if (!entry) return;
|
|
2542
|
-
const runtime = target.__wevu;
|
|
2543
|
-
const ctx = (_runtime$proxy3 = runtime === null || runtime === void 0 ? void 0 : runtime.proxy) !== null && _runtime$proxy3 !== void 0 ? _runtime$proxy3 : target;
|
|
2544
|
-
if (typeof entry === "function") try {
|
|
2545
|
-
return entry.apply(ctx, args);
|
|
2546
|
-
} catch (_unused6) {
|
|
2547
|
-
return;
|
|
2548
|
-
}
|
|
2549
|
-
if (Array.isArray(entry)) {
|
|
2550
|
-
let out;
|
|
2551
|
-
for (const fn of entry) try {
|
|
2552
|
-
out = fn.apply(ctx, args);
|
|
2553
|
-
} catch (_unused7) {}
|
|
2554
|
-
return out;
|
|
2555
|
-
}
|
|
2556
|
-
}
|
|
2557
|
-
function onLaunch(handler) {
|
|
2558
|
-
pushHook(assertInSetup("onLaunch"), "onLaunch", handler);
|
|
2559
|
-
}
|
|
2560
|
-
function onPageNotFound(handler) {
|
|
2561
|
-
pushHook(assertInSetup("onPageNotFound"), "onPageNotFound", handler);
|
|
2562
|
-
}
|
|
2563
|
-
function onUnhandledRejection(handler) {
|
|
2564
|
-
pushHook(assertInSetup("onUnhandledRejection"), "onUnhandledRejection", handler);
|
|
2565
|
-
}
|
|
2566
|
-
function onThemeChange(handler) {
|
|
2567
|
-
pushHook(assertInSetup("onThemeChange"), "onThemeChange", handler);
|
|
2568
|
-
}
|
|
2569
|
-
function onShow(handler) {
|
|
2570
|
-
pushHook(assertInSetup("onShow"), "onShow", handler);
|
|
2571
|
-
}
|
|
2572
|
-
function onLoad(handler) {
|
|
2573
|
-
pushHook(assertInSetup("onLoad"), "onLoad", handler);
|
|
2574
|
-
}
|
|
2575
|
-
function onHide(handler) {
|
|
2576
|
-
pushHook(assertInSetup("onHide"), "onHide", handler);
|
|
2577
|
-
}
|
|
2578
|
-
function onUnload(handler) {
|
|
2579
|
-
pushHook(assertInSetup("onUnload"), "onUnload", handler);
|
|
2580
|
-
}
|
|
2581
|
-
function onReady(handler) {
|
|
2582
|
-
pushHook(assertInSetup("onReady"), "onReady", handler);
|
|
2583
|
-
}
|
|
2584
|
-
function onPullDownRefresh(handler) {
|
|
2585
|
-
pushHook(assertInSetup("onPullDownRefresh"), "onPullDownRefresh", handler);
|
|
2586
|
-
}
|
|
2587
|
-
function onReachBottom(handler) {
|
|
2588
|
-
pushHook(assertInSetup("onReachBottom"), "onReachBottom", handler);
|
|
2589
|
-
}
|
|
2590
|
-
function onPageScroll(handler) {
|
|
2591
|
-
pushHook(assertInSetup("onPageScroll"), "onPageScroll", handler);
|
|
2592
|
-
}
|
|
2593
|
-
function onRouteDone(handler) {
|
|
2594
|
-
pushHook(assertInSetup("onRouteDone"), "onRouteDone", handler);
|
|
2595
|
-
}
|
|
2596
|
-
function onTabItemTap(handler) {
|
|
2597
|
-
pushHook(assertInSetup("onTabItemTap"), "onTabItemTap", handler);
|
|
2598
|
-
}
|
|
2599
|
-
function onResize(handler) {
|
|
2600
|
-
pushHook(assertInSetup("onResize"), "onResize", handler);
|
|
2601
|
-
}
|
|
2602
|
-
function onMoved(handler) {
|
|
2603
|
-
pushHook(assertInSetup("onMoved"), "onMoved", handler);
|
|
2604
|
-
}
|
|
2605
|
-
function onAttached(handler) {
|
|
2606
|
-
pushHook(assertInSetup("onAttached"), "onAttached", handler);
|
|
2607
|
-
}
|
|
2608
|
-
function onDetached(handler) {
|
|
2609
|
-
pushHook(assertInSetup("onDetached"), "onDetached", handler);
|
|
1637
|
+
function mergeWithDefaults(defaults, options) {
|
|
1638
|
+
return mergeDefaults(defaults, options);
|
|
2610
1639
|
}
|
|
2611
|
-
function
|
|
2612
|
-
|
|
1640
|
+
function mergeWevuDefaults(base, next) {
|
|
1641
|
+
return {
|
|
1642
|
+
app: mergeDefaults(base.app, next.app),
|
|
1643
|
+
component: mergeDefaults(base.component, next.component)
|
|
1644
|
+
};
|
|
2613
1645
|
}
|
|
2614
|
-
function
|
|
2615
|
-
|
|
1646
|
+
function setWevuDefaults(next) {
|
|
1647
|
+
currentDefaults = mergeWevuDefaults(currentDefaults, next);
|
|
2616
1648
|
}
|
|
2617
|
-
function
|
|
2618
|
-
|
|
2619
|
-
pushHook(instance, "onShareAppMessage", handler, { single: true });
|
|
2620
|
-
ensureSinglePageHookOnInstance(instance, "onShareAppMessage");
|
|
2621
|
-
ensurePageShareMenusOnSetup(instance);
|
|
1649
|
+
function resetWevuDefaults() {
|
|
1650
|
+
currentDefaults = {};
|
|
2622
1651
|
}
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
1652
|
+
/**
|
|
1653
|
+
* 将默认配置应用到 App 选项(框架内部使用)。
|
|
1654
|
+
* @internal
|
|
1655
|
+
*/
|
|
1656
|
+
function applyWevuAppDefaults(options) {
|
|
1657
|
+
return mergeWithDefaults(currentDefaults.app, options);
|
|
2628
1658
|
}
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
1659
|
+
/**
|
|
1660
|
+
* 将默认配置应用到组件选项(框架内部使用)。
|
|
1661
|
+
* @internal
|
|
1662
|
+
*/
|
|
1663
|
+
function applyWevuComponentDefaults(options) {
|
|
1664
|
+
return mergeWithDefaults(currentDefaults.component, options);
|
|
2633
1665
|
}
|
|
1666
|
+
//#endregion
|
|
1667
|
+
//#region src/runtime/hooks/vue.ts
|
|
2634
1668
|
/**
|
|
2635
1669
|
* Vue 3 对齐:组件/页面已挂载,映射小程序 onReady
|
|
2636
1670
|
*/
|
|
@@ -2704,7 +1738,6 @@ function onServerPrefetch(_handler) {
|
|
|
2704
1738
|
function callUpdateHooks(target, phase) {
|
|
2705
1739
|
callHookList(target, phase === "before" ? "__wevuOnBeforeUpdate" : "__wevuOnUpdated");
|
|
2706
1740
|
}
|
|
2707
|
-
|
|
2708
1741
|
//#endregion
|
|
2709
1742
|
//#region src/runtime/register/inline.ts
|
|
2710
1743
|
function decodeWxmlEntities$1(value) {
|
|
@@ -2822,7 +1855,6 @@ function runInlineExpression(ctx, expr, event, inlineMap) {
|
|
|
2822
1855
|
const handler = ctx === null || ctx === void 0 ? void 0 : ctx[handlerName];
|
|
2823
1856
|
if (typeof handler === "function") return handler.apply(ctx, resolvedArgs);
|
|
2824
1857
|
}
|
|
2825
|
-
|
|
2826
1858
|
//#endregion
|
|
2827
1859
|
//#region src/runtime/scopedSlots.ts
|
|
2828
1860
|
const ownerStore = /* @__PURE__ */ new Map();
|
|
@@ -2884,9 +1916,8 @@ function attachOwnerSnapshot(target, runtime, ownerId) {
|
|
|
2884
1916
|
if (propsSource && typeof propsSource === "object") for (const [key, value] of Object.entries(propsSource)) snapshot[key] = value;
|
|
2885
1917
|
updateOwnerSnapshot(ownerId, snapshot, runtime.proxy);
|
|
2886
1918
|
}
|
|
2887
|
-
|
|
2888
1919
|
//#endregion
|
|
2889
|
-
//#region src/runtime/templateRefs.ts
|
|
1920
|
+
//#region src/runtime/templateRefs/helpers.ts
|
|
2890
1921
|
function isComponentRef(binding) {
|
|
2891
1922
|
return binding.kind === "component";
|
|
2892
1923
|
}
|
|
@@ -3090,6 +2121,8 @@ function buildTemplateRefValue(target, binding, result) {
|
|
|
3090
2121
|
if (!result) return null;
|
|
3091
2122
|
return createTemplateRefWrapper(target, binding.selector, { multiple: false });
|
|
3092
2123
|
}
|
|
2124
|
+
//#endregion
|
|
2125
|
+
//#region src/runtime/templateRefs.ts
|
|
3093
2126
|
function updateTemplateRefs(target, onResolved) {
|
|
3094
2127
|
const bindings = target.__wevuTemplateRefs;
|
|
3095
2128
|
if (!bindings || !bindings.length) {
|
|
@@ -3111,11 +2144,11 @@ function updateTemplateRefs(target, onResolved) {
|
|
|
3111
2144
|
value: resolveComponentRefValue(target, binding)
|
|
3112
2145
|
}));
|
|
3113
2146
|
const applyEntries = (entries) => {
|
|
3114
|
-
var _target$__wevu$
|
|
2147
|
+
var _target$__wevu$proxy, _target$__wevu;
|
|
3115
2148
|
const refsContainer = ensureRefsContainer(target);
|
|
3116
2149
|
const nameEntries = /* @__PURE__ */ new Map();
|
|
3117
2150
|
const nextNames = /* @__PURE__ */ new Set();
|
|
3118
|
-
const proxy = (_target$__wevu$
|
|
2151
|
+
const proxy = (_target$__wevu$proxy = (_target$__wevu = target.__wevu) === null || _target$__wevu === void 0 ? void 0 : _target$__wevu.proxy) !== null && _target$__wevu$proxy !== void 0 ? _target$__wevu$proxy : target;
|
|
3119
2152
|
entries.forEach((entry) => {
|
|
3120
2153
|
const binding = entry.binding;
|
|
3121
2154
|
const value = entry.value;
|
|
@@ -3209,18 +2242,18 @@ function scheduleTemplateRefUpdate(target, onResolved) {
|
|
|
3209
2242
|
callbacks.splice(0).forEach((cb) => {
|
|
3210
2243
|
try {
|
|
3211
2244
|
cb();
|
|
3212
|
-
} catch (
|
|
2245
|
+
} catch (_unused) {}
|
|
3213
2246
|
});
|
|
3214
2247
|
};
|
|
3215
2248
|
updateTemplateRefs(target, flushCallbacks);
|
|
3216
2249
|
});
|
|
3217
2250
|
}
|
|
3218
2251
|
function clearTemplateRefs(target) {
|
|
3219
|
-
var _target$__wevu$
|
|
2252
|
+
var _target$__wevu$proxy2, _target$__wevu2;
|
|
3220
2253
|
const bindings = target.__wevuTemplateRefs;
|
|
3221
2254
|
if (!bindings || !bindings.length) return;
|
|
3222
2255
|
const refsContainer = ensureRefsContainer(target);
|
|
3223
|
-
const proxy = (_target$__wevu$
|
|
2256
|
+
const proxy = (_target$__wevu$proxy2 = (_target$__wevu2 = target.__wevu) === null || _target$__wevu2 === void 0 ? void 0 : _target$__wevu2.proxy) !== null && _target$__wevu$proxy2 !== void 0 ? _target$__wevu$proxy2 : target;
|
|
3224
2257
|
const nextNames = /* @__PURE__ */ new Set();
|
|
3225
2258
|
const templateRefMap = getTemplateRefMap(target);
|
|
3226
2259
|
for (const binding of bindings) {
|
|
@@ -3242,80 +2275,16 @@ function clearTemplateRefs(target) {
|
|
|
3242
2275
|
}
|
|
3243
2276
|
for (const key of Object.keys(refsContainer)) if (!nextNames.has(key)) delete refsContainer[key];
|
|
3244
2277
|
}
|
|
3245
|
-
|
|
3246
|
-
//#endregion
|
|
3247
|
-
//#region src/runtime/register/setup.ts
|
|
3248
|
-
function runSetupFunction(setup, props, context) {
|
|
3249
|
-
var _context$runtime;
|
|
3250
|
-
if (typeof setup !== "function") return;
|
|
3251
|
-
const runtimeContext = (_context$runtime = context === null || context === void 0 ? void 0 : context.runtime) !== null && _context$runtime !== void 0 ? _context$runtime : {
|
|
3252
|
-
methods: Object.create(null),
|
|
3253
|
-
state: {},
|
|
3254
|
-
proxy: {},
|
|
3255
|
-
watch: () => () => {},
|
|
3256
|
-
bindModel: () => {}
|
|
3257
|
-
};
|
|
3258
|
-
if (context) context.runtime = runtimeContext;
|
|
3259
|
-
return setup(props, {
|
|
3260
|
-
...context !== null && context !== void 0 ? context : {},
|
|
3261
|
-
runtime: runtimeContext
|
|
3262
|
-
});
|
|
3263
|
-
}
|
|
3264
|
-
|
|
3265
|
-
//#endregion
|
|
3266
|
-
//#region src/runtime/register/watch.ts
|
|
3267
|
-
function normalizeWatchDescriptor(descriptor, runtime, instance) {
|
|
3268
|
-
if (typeof descriptor === "function") return {
|
|
3269
|
-
handler: descriptor.bind(runtime.proxy),
|
|
3270
|
-
options: {}
|
|
3271
|
-
};
|
|
3272
|
-
if (typeof descriptor === "string") {
|
|
3273
|
-
var _descriptor, _runtime$methods;
|
|
3274
|
-
const method = (_descriptor = (_runtime$methods = runtime.methods) === null || _runtime$methods === void 0 ? void 0 : _runtime$methods[descriptor]) !== null && _descriptor !== void 0 ? _descriptor : instance[descriptor];
|
|
3275
|
-
if (typeof method === "function") return {
|
|
3276
|
-
handler: method.bind(runtime.proxy),
|
|
3277
|
-
options: {}
|
|
3278
|
-
};
|
|
3279
|
-
return;
|
|
3280
|
-
}
|
|
3281
|
-
if (!descriptor || typeof descriptor !== "object") return;
|
|
3282
|
-
const base = normalizeWatchDescriptor(descriptor.handler, runtime, instance);
|
|
3283
|
-
if (!base) return;
|
|
3284
|
-
const options = { ...base.options };
|
|
3285
|
-
if (descriptor.immediate !== void 0) options.immediate = descriptor.immediate;
|
|
3286
|
-
if (descriptor.deep !== void 0) options.deep = descriptor.deep;
|
|
3287
|
-
return {
|
|
3288
|
-
handler: base.handler,
|
|
3289
|
-
options
|
|
3290
|
-
};
|
|
3291
|
-
}
|
|
3292
|
-
function createPathGetter(target, path) {
|
|
3293
|
-
const segments = path.split(".").map((segment) => segment.trim()).filter(Boolean);
|
|
3294
|
-
if (!segments.length) return () => target;
|
|
3295
|
-
return () => {
|
|
3296
|
-
let current = target;
|
|
3297
|
-
for (const segment of segments) {
|
|
3298
|
-
if (current == null) return current;
|
|
3299
|
-
current = current[segment];
|
|
3300
|
-
}
|
|
3301
|
-
return current;
|
|
3302
|
-
};
|
|
3303
|
-
}
|
|
3304
|
-
function registerWatches(runtime, watchMap, instance) {
|
|
3305
|
-
const stops = [];
|
|
3306
|
-
const proxy = runtime.proxy;
|
|
3307
|
-
for (const [expression, descriptor] of Object.entries(watchMap)) {
|
|
3308
|
-
const normalized = normalizeWatchDescriptor(descriptor, runtime, instance);
|
|
3309
|
-
if (!normalized) continue;
|
|
3310
|
-
const getter = createPathGetter(proxy, expression);
|
|
3311
|
-
const stopHandle = runtime.watch(getter, normalized.handler, normalized.options);
|
|
3312
|
-
stops.push(stopHandle);
|
|
3313
|
-
}
|
|
3314
|
-
return stops;
|
|
3315
|
-
}
|
|
3316
|
-
|
|
3317
2278
|
//#endregion
|
|
3318
|
-
//#region src/runtime/register/runtimeInstance.ts
|
|
2279
|
+
//#region src/runtime/register/runtimeInstance/setupContext.ts
|
|
2280
|
+
const setupInstanceMethodNames = [
|
|
2281
|
+
"triggerEvent",
|
|
2282
|
+
"createSelectorQuery",
|
|
2283
|
+
"createIntersectionObserver",
|
|
2284
|
+
"setData",
|
|
2285
|
+
"setUpdatePerformanceListener"
|
|
2286
|
+
];
|
|
2287
|
+
const SETUP_CONTEXT_INSTANCE_KEY$1 = "__wevuSetupContextInstance";
|
|
3319
2288
|
function createSetupSlotsFallback() {
|
|
3320
2289
|
return Object.freeze(Object.create(null));
|
|
3321
2290
|
}
|
|
@@ -3359,12 +2328,6 @@ function normalizeEmitPayload(args) {
|
|
|
3359
2328
|
options: void 0
|
|
3360
2329
|
};
|
|
3361
2330
|
}
|
|
3362
|
-
const setupInstanceMethodNames = [
|
|
3363
|
-
"triggerEvent",
|
|
3364
|
-
"createSelectorQuery",
|
|
3365
|
-
"setData"
|
|
3366
|
-
];
|
|
3367
|
-
const SETUP_CONTEXT_INSTANCE_KEY = "__wevuSetupContextInstance";
|
|
3368
2331
|
function resolveRuntimeNativeMethodOwner(runtime, target, methodName) {
|
|
3369
2332
|
const runtimeState = runtime === null || runtime === void 0 ? void 0 : runtime.state;
|
|
3370
2333
|
const runtimeRawState = runtimeState && typeof runtimeState === "object" ? toRaw(runtimeState) : void 0;
|
|
@@ -3401,7 +2364,7 @@ function defineSetupInstanceMethod(target, methodName, handler) {
|
|
|
3401
2364
|
}
|
|
3402
2365
|
}
|
|
3403
2366
|
function ensureSetupContextInstance(target, runtime) {
|
|
3404
|
-
const maybeCached = target[SETUP_CONTEXT_INSTANCE_KEY];
|
|
2367
|
+
const maybeCached = target[SETUP_CONTEXT_INSTANCE_KEY$1];
|
|
3405
2368
|
if (maybeCached && typeof maybeCached === "object") return maybeCached;
|
|
3406
2369
|
const setupInstanceBridge = Object.create(null);
|
|
3407
2370
|
const resolveSetupBridgeOwner = (methodName) => {
|
|
@@ -3427,6 +2390,15 @@ function ensureSetupContextInstance(target, runtime) {
|
|
|
3427
2390
|
const scopedOwner = (_resolveRuntimeNative = resolveRuntimeNativeMethodOwner(runtime, target, "setData")) !== null && _resolveRuntimeNative !== void 0 ? _resolveRuntimeNative : target;
|
|
3428
2391
|
return query.in(scopedOwner);
|
|
3429
2392
|
});
|
|
2393
|
+
defineSetupInstanceMethod(setupInstanceBridge, "createIntersectionObserver", (options) => {
|
|
2394
|
+
var _resolveRuntimeNative2;
|
|
2395
|
+
const nativeOwner = resolveSetupBridgeOwner("createIntersectionObserver");
|
|
2396
|
+
if (nativeOwner && typeof nativeOwner.createIntersectionObserver === "function") return nativeOwner.createIntersectionObserver(options !== null && options !== void 0 ? options : {});
|
|
2397
|
+
const miniProgramGlobal = getMiniProgramGlobalObject();
|
|
2398
|
+
if (!miniProgramGlobal || typeof miniProgramGlobal.createIntersectionObserver !== "function") return;
|
|
2399
|
+
const scopedOwner = (_resolveRuntimeNative2 = resolveRuntimeNativeMethodOwner(runtime, target, "setData")) !== null && _resolveRuntimeNative2 !== void 0 ? _resolveRuntimeNative2 : target;
|
|
2400
|
+
return miniProgramGlobal.createIntersectionObserver(scopedOwner, options !== null && options !== void 0 ? options : {});
|
|
2401
|
+
});
|
|
3430
2402
|
defineSetupInstanceMethod(setupInstanceBridge, "setData", (payload, callback) => {
|
|
3431
2403
|
const nativeOwner = resolveSetupBridgeOwner("setData");
|
|
3432
2404
|
if (nativeOwner && typeof nativeOwner.setData === "function") return nativeOwner.setData(payload, callback);
|
|
@@ -3435,6 +2407,10 @@ function ensureSetupContextInstance(target, runtime) {
|
|
|
3435
2407
|
if (typeof callback === "function") callback();
|
|
3436
2408
|
return result;
|
|
3437
2409
|
});
|
|
2410
|
+
defineSetupInstanceMethod(setupInstanceBridge, "setUpdatePerformanceListener", (listener) => {
|
|
2411
|
+
const nativeOwner = resolveSetupBridgeOwner("setUpdatePerformanceListener");
|
|
2412
|
+
if (nativeOwner && typeof nativeOwner.setUpdatePerformanceListener === "function") return nativeOwner.setUpdatePerformanceListener(listener);
|
|
2413
|
+
});
|
|
3438
2414
|
const setupInstance = safeMarkNoSetData(new Proxy(setupInstanceBridge, {
|
|
3439
2415
|
get(bridgeTarget, key, receiver) {
|
|
3440
2416
|
if (Reflect.has(bridgeTarget, key)) return Reflect.get(bridgeTarget, key, receiver);
|
|
@@ -3455,17 +2431,167 @@ function ensureSetupContextInstance(target, runtime) {
|
|
|
3455
2431
|
}
|
|
3456
2432
|
}));
|
|
3457
2433
|
try {
|
|
3458
|
-
Object.defineProperty(target, SETUP_CONTEXT_INSTANCE_KEY, {
|
|
2434
|
+
Object.defineProperty(target, SETUP_CONTEXT_INSTANCE_KEY$1, {
|
|
3459
2435
|
value: setupInstance,
|
|
3460
2436
|
configurable: true,
|
|
3461
2437
|
enumerable: false,
|
|
3462
2438
|
writable: true
|
|
3463
2439
|
});
|
|
3464
2440
|
} catch (_unused3) {
|
|
3465
|
-
target[SETUP_CONTEXT_INSTANCE_KEY] = setupInstance;
|
|
2441
|
+
target[SETUP_CONTEXT_INSTANCE_KEY$1] = setupInstance;
|
|
3466
2442
|
}
|
|
3467
2443
|
return setupInstance;
|
|
3468
2444
|
}
|
|
2445
|
+
//#endregion
|
|
2446
|
+
//#region src/runtime/register/runtimeInstance/methodBridge.ts
|
|
2447
|
+
function bridgeRuntimeMethodsToTarget(target, runtime) {
|
|
2448
|
+
try {
|
|
2449
|
+
const methods = runtime.methods;
|
|
2450
|
+
for (const name of Object.keys(methods)) {
|
|
2451
|
+
if (setupInstanceMethodNames.includes(name)) continue;
|
|
2452
|
+
if (typeof target[name] !== "function") target[name] = function bridged(...args) {
|
|
2453
|
+
var _this$$wevu;
|
|
2454
|
+
const bound = (_this$$wevu = this.$wevu) === null || _this$$wevu === void 0 || (_this$$wevu = _this$$wevu.methods) === null || _this$$wevu === void 0 ? void 0 : _this$$wevu[name];
|
|
2455
|
+
if (typeof bound === "function") return bound.apply(this.$wevu.proxy, args);
|
|
2456
|
+
};
|
|
2457
|
+
}
|
|
2458
|
+
} catch (_unused) {}
|
|
2459
|
+
}
|
|
2460
|
+
//#endregion
|
|
2461
|
+
//#region src/runtime/register/setup.ts
|
|
2462
|
+
function runSetupFunction(setup, props, context) {
|
|
2463
|
+
var _context$runtime;
|
|
2464
|
+
if (typeof setup !== "function") return;
|
|
2465
|
+
const runtimeContext = (_context$runtime = context === null || context === void 0 ? void 0 : context.runtime) !== null && _context$runtime !== void 0 ? _context$runtime : {
|
|
2466
|
+
methods: Object.create(null),
|
|
2467
|
+
state: {},
|
|
2468
|
+
proxy: {},
|
|
2469
|
+
watch: () => () => {},
|
|
2470
|
+
bindModel: () => {}
|
|
2471
|
+
};
|
|
2472
|
+
if (context) context.runtime = runtimeContext;
|
|
2473
|
+
return setup(props, {
|
|
2474
|
+
...context !== null && context !== void 0 ? context : {},
|
|
2475
|
+
runtime: runtimeContext
|
|
2476
|
+
});
|
|
2477
|
+
}
|
|
2478
|
+
//#endregion
|
|
2479
|
+
//#region src/runtime/register/runtimeInstance/setupPhase.ts
|
|
2480
|
+
function runRuntimeSetupPhase(options) {
|
|
2481
|
+
const { target, runtime, runtimeWithDefaults, runtimeState, runtimeProxy, setup, syncRuntimeProps, attachRuntimeProxyProps } = options;
|
|
2482
|
+
const mpProperties = target.properties || {};
|
|
2483
|
+
const runtimeProps = runtimeState && typeof runtimeState === "object" ? runtimeState.__wevuProps : void 0;
|
|
2484
|
+
const props = runtimeProps && typeof runtimeProps === "object" ? runtimeProps : shallowReactive({});
|
|
2485
|
+
syncRuntimeProps(props, mpProperties);
|
|
2486
|
+
if (runtimeState && typeof runtimeState === "object") attachRuntimeProxyProps(runtimeState, props);
|
|
2487
|
+
try {
|
|
2488
|
+
Object.defineProperty(target, "__wevuProps", {
|
|
2489
|
+
value: props,
|
|
2490
|
+
configurable: true,
|
|
2491
|
+
enumerable: false,
|
|
2492
|
+
writable: false
|
|
2493
|
+
});
|
|
2494
|
+
} catch (_unused) {
|
|
2495
|
+
target.__wevuProps = props;
|
|
2496
|
+
}
|
|
2497
|
+
const attrs = shallowReactive(Object.create(null));
|
|
2498
|
+
const declaredPropKeys = new Set(Array.isArray(target.__wevuPropKeys) ? target.__wevuPropKeys : []);
|
|
2499
|
+
const hasRuntimeStateKey = (key) => {
|
|
2500
|
+
return runtimeState != null && typeof runtimeState === "object" && Object.prototype.hasOwnProperty.call(runtimeState, key);
|
|
2501
|
+
};
|
|
2502
|
+
const syncAttrsFromProperties = () => {
|
|
2503
|
+
const next = target.properties && typeof target.properties === "object" ? target.properties : void 0;
|
|
2504
|
+
for (const existingKey of Object.keys(attrs)) if (!next || !Object.prototype.hasOwnProperty.call(next, existingKey) || declaredPropKeys.has(existingKey) || hasRuntimeStateKey(existingKey)) delete attrs[existingKey];
|
|
2505
|
+
if (!next) return;
|
|
2506
|
+
for (const [key, value] of Object.entries(next)) {
|
|
2507
|
+
if (declaredPropKeys.has(key) || hasRuntimeStateKey(key)) continue;
|
|
2508
|
+
attrs[key] = value;
|
|
2509
|
+
}
|
|
2510
|
+
};
|
|
2511
|
+
syncAttrsFromProperties();
|
|
2512
|
+
try {
|
|
2513
|
+
Object.defineProperty(target, "__wevuAttrs", {
|
|
2514
|
+
value: attrs,
|
|
2515
|
+
configurable: true,
|
|
2516
|
+
enumerable: false,
|
|
2517
|
+
writable: false
|
|
2518
|
+
});
|
|
2519
|
+
} catch (_unused2) {
|
|
2520
|
+
target.__wevuAttrs = attrs;
|
|
2521
|
+
}
|
|
2522
|
+
const setupInstance = ensureSetupContextInstance(target, runtimeWithDefaults);
|
|
2523
|
+
const context = safeMarkNoSetData({
|
|
2524
|
+
props,
|
|
2525
|
+
runtime: runtimeWithDefaults,
|
|
2526
|
+
state: runtimeState,
|
|
2527
|
+
proxy: runtimeProxy,
|
|
2528
|
+
bindModel: runtime.bindModel.bind(runtimeWithDefaults),
|
|
2529
|
+
watch: runtime.watch.bind(runtimeWithDefaults),
|
|
2530
|
+
instance: setupInstance,
|
|
2531
|
+
emit: (event, ...args) => {
|
|
2532
|
+
const { detail, options } = normalizeEmitPayload(args);
|
|
2533
|
+
setupInstance.triggerEvent(event, detail, options);
|
|
2534
|
+
},
|
|
2535
|
+
expose: (exposed) => {
|
|
2536
|
+
target.__wevuExposed = exposed;
|
|
2537
|
+
},
|
|
2538
|
+
attrs,
|
|
2539
|
+
slots: createSetupSlotsFallback()
|
|
2540
|
+
});
|
|
2541
|
+
setCurrentInstance(target);
|
|
2542
|
+
setCurrentSetupContext(context);
|
|
2543
|
+
try {
|
|
2544
|
+
const result = runSetupFunction(setup, props, context);
|
|
2545
|
+
let methodsChanged = false;
|
|
2546
|
+
if (result && typeof result === "object") {
|
|
2547
|
+
const runtimeRawState = isReactive(runtime.state) ? toRaw(runtime.state) : runtime.state;
|
|
2548
|
+
Object.keys(result).forEach((key) => {
|
|
2549
|
+
const val = result[key];
|
|
2550
|
+
if (typeof val === "function") {
|
|
2551
|
+
runtime.methods[key] = (...args) => val.apply(runtime.proxy, args);
|
|
2552
|
+
methodsChanged = true;
|
|
2553
|
+
} else {
|
|
2554
|
+
if (declaredPropKeys.has(key)) {
|
|
2555
|
+
let fallbackValue = val;
|
|
2556
|
+
try {
|
|
2557
|
+
Object.defineProperty(runtimeRawState, key, {
|
|
2558
|
+
configurable: true,
|
|
2559
|
+
enumerable: false,
|
|
2560
|
+
get() {
|
|
2561
|
+
const propsSource = runtimeRawState.__wevuProps;
|
|
2562
|
+
if (propsSource && typeof propsSource === "object" && Object.prototype.hasOwnProperty.call(propsSource, key)) return propsSource[key];
|
|
2563
|
+
return fallbackValue;
|
|
2564
|
+
},
|
|
2565
|
+
set(next) {
|
|
2566
|
+
fallbackValue = next;
|
|
2567
|
+
const propsSource = runtimeRawState.__wevuProps;
|
|
2568
|
+
if (!propsSource || typeof propsSource !== "object") return;
|
|
2569
|
+
try {
|
|
2570
|
+
propsSource[key] = next;
|
|
2571
|
+
} catch (_unused3) {}
|
|
2572
|
+
}
|
|
2573
|
+
});
|
|
2574
|
+
} catch (_unused4) {
|
|
2575
|
+
runtime.state[key] = val;
|
|
2576
|
+
}
|
|
2577
|
+
return;
|
|
2578
|
+
}
|
|
2579
|
+
runtime.state[key] = val;
|
|
2580
|
+
}
|
|
2581
|
+
});
|
|
2582
|
+
}
|
|
2583
|
+
if (methodsChanged) {
|
|
2584
|
+
var _wevu_touchSetupMetho;
|
|
2585
|
+
(_wevu_touchSetupMetho = runtime.__wevu_touchSetupMethodsVersion) === null || _wevu_touchSetupMetho === void 0 || _wevu_touchSetupMetho.call(runtime);
|
|
2586
|
+
}
|
|
2587
|
+
} finally {
|
|
2588
|
+
setCurrentSetupContext(void 0);
|
|
2589
|
+
setCurrentInstance(void 0);
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
//#endregion
|
|
2593
|
+
//#region src/runtime/register/runtimeInstance/utils.ts
|
|
2594
|
+
const SETUP_CONTEXT_INSTANCE_KEY = "__wevuSetupContextInstance";
|
|
3469
2595
|
function attachRuntimeProxyProps(state, props) {
|
|
3470
2596
|
try {
|
|
3471
2597
|
Object.defineProperty(state, "__wevuProps", {
|
|
@@ -3474,7 +2600,7 @@ function attachRuntimeProxyProps(state, props) {
|
|
|
3474
2600
|
enumerable: false,
|
|
3475
2601
|
writable: false
|
|
3476
2602
|
});
|
|
3477
|
-
} catch (
|
|
2603
|
+
} catch (_unused) {
|
|
3478
2604
|
state.__wevuProps = props;
|
|
3479
2605
|
}
|
|
3480
2606
|
}
|
|
@@ -3486,7 +2612,7 @@ function attachNativeInstanceRef(state, instance) {
|
|
|
3486
2612
|
enumerable: false,
|
|
3487
2613
|
writable: true
|
|
3488
2614
|
});
|
|
3489
|
-
} catch (
|
|
2615
|
+
} catch (_unused2) {
|
|
3490
2616
|
state.__wevuNativeInstance = instance;
|
|
3491
2617
|
}
|
|
3492
2618
|
}
|
|
@@ -3498,7 +2624,7 @@ function attachRuntimeRef(state, runtime) {
|
|
|
3498
2624
|
enumerable: false,
|
|
3499
2625
|
writable: true
|
|
3500
2626
|
});
|
|
3501
|
-
} catch (
|
|
2627
|
+
} catch (_unused3) {
|
|
3502
2628
|
state.__wevuRuntime = runtime;
|
|
3503
2629
|
}
|
|
3504
2630
|
}
|
|
@@ -3510,52 +2636,206 @@ function attachRuntimeInstance(runtime, instance) {
|
|
|
3510
2636
|
enumerable: false,
|
|
3511
2637
|
writable: true
|
|
3512
2638
|
});
|
|
3513
|
-
} catch (
|
|
2639
|
+
} catch (_unused4) {
|
|
3514
2640
|
try {
|
|
3515
2641
|
runtime.instance = instance;
|
|
3516
|
-
} catch (
|
|
2642
|
+
} catch (_unused5) {}
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
function resolveNativeSetData(instance) {
|
|
2646
|
+
const setupInstance = instance[SETUP_CONTEXT_INSTANCE_KEY];
|
|
2647
|
+
const setupOverride = setupInstance && typeof setupInstance.setData === "function" ? setupInstance.setData : void 0;
|
|
2648
|
+
if (typeof setupOverride === "function" && !isNativeBridgeMethod(setupOverride)) return setupOverride;
|
|
2649
|
+
const candidate = instance.setData;
|
|
2650
|
+
if (typeof candidate !== "function") return;
|
|
2651
|
+
if (isNativeBridgeMethod(candidate)) return;
|
|
2652
|
+
return candidate;
|
|
2653
|
+
}
|
|
2654
|
+
function getRuntimeOwnerLabel$1(instance) {
|
|
2655
|
+
const route = instance.route;
|
|
2656
|
+
if (typeof route === "string" && route) return route;
|
|
2657
|
+
const is = instance.is;
|
|
2658
|
+
if (typeof is === "string" && is) return is;
|
|
2659
|
+
return "unknown";
|
|
2660
|
+
}
|
|
2661
|
+
function callNativeSetData(instance, setData, payload) {
|
|
2662
|
+
try {
|
|
2663
|
+
return setData.call(instance, payload);
|
|
2664
|
+
} catch (error) {
|
|
2665
|
+
const owner = getRuntimeOwnerLabel$1(instance);
|
|
2666
|
+
throw new Error(`[wevu] setData failed (${owner}): ${error instanceof Error ? error.message : String(error)}`);
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
function syncRuntimeProps(props, mpProperties) {
|
|
2670
|
+
const currentKeys = Object.keys(props);
|
|
2671
|
+
for (const key of currentKeys) if (!Object.prototype.hasOwnProperty.call(mpProperties, key)) try {
|
|
2672
|
+
delete props[key];
|
|
2673
|
+
} catch (_unused6) {}
|
|
2674
|
+
for (const [key, value] of Object.entries(mpProperties)) props[key] = value;
|
|
2675
|
+
}
|
|
2676
|
+
//#endregion
|
|
2677
|
+
//#region src/runtime/register/setDataFrequencyWarning.ts
|
|
2678
|
+
function isObject(value) {
|
|
2679
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
2680
|
+
}
|
|
2681
|
+
/**
|
|
2682
|
+
* 解析 setData 高频告警配置。
|
|
2683
|
+
*/
|
|
2684
|
+
function resolveHighFrequencyWarningOptions(option) {
|
|
2685
|
+
var _option$enabled, _option$devOnly, _option$warnOnPageScr;
|
|
2686
|
+
const defaults = {
|
|
2687
|
+
devOnly: true,
|
|
2688
|
+
sampleWindowMs: 1e3,
|
|
2689
|
+
maxCalls: 30,
|
|
2690
|
+
coolDownMs: 5e3,
|
|
2691
|
+
warnOnPageScroll: true,
|
|
2692
|
+
pageScrollCoolDownMs: 2e3
|
|
2693
|
+
};
|
|
2694
|
+
if (option === void 0 || option === false) return {
|
|
2695
|
+
...defaults,
|
|
2696
|
+
enabled: false
|
|
2697
|
+
};
|
|
2698
|
+
if (option === true) return {
|
|
2699
|
+
...defaults,
|
|
2700
|
+
enabled: true
|
|
2701
|
+
};
|
|
2702
|
+
if (!isObject(option)) return {
|
|
2703
|
+
...defaults,
|
|
2704
|
+
enabled: false
|
|
2705
|
+
};
|
|
2706
|
+
return {
|
|
2707
|
+
enabled: (_option$enabled = option.enabled) !== null && _option$enabled !== void 0 ? _option$enabled : true,
|
|
2708
|
+
devOnly: (_option$devOnly = option.devOnly) !== null && _option$devOnly !== void 0 ? _option$devOnly : defaults.devOnly,
|
|
2709
|
+
sampleWindowMs: typeof option.sampleWindowMs === "number" ? Math.max(100, Math.floor(option.sampleWindowMs)) : defaults.sampleWindowMs,
|
|
2710
|
+
maxCalls: typeof option.maxCalls === "number" ? Math.max(1, Math.floor(option.maxCalls)) : defaults.maxCalls,
|
|
2711
|
+
coolDownMs: typeof option.coolDownMs === "number" ? Math.max(0, Math.floor(option.coolDownMs)) : defaults.coolDownMs,
|
|
2712
|
+
warnOnPageScroll: (_option$warnOnPageScr = option.warnOnPageScroll) !== null && _option$warnOnPageScr !== void 0 ? _option$warnOnPageScr : defaults.warnOnPageScroll,
|
|
2713
|
+
pageScrollCoolDownMs: typeof option.pageScrollCoolDownMs === "number" ? Math.max(0, Math.floor(option.pageScrollCoolDownMs)) : defaults.pageScrollCoolDownMs
|
|
2714
|
+
};
|
|
2715
|
+
}
|
|
2716
|
+
/**
|
|
2717
|
+
* 判断当前是否为开发态运行环境。
|
|
2718
|
+
*/
|
|
2719
|
+
function isDevelopmentRuntime() {
|
|
2720
|
+
const globalRuntime = globalThis;
|
|
2721
|
+
const wxConfig = globalRuntime === null || globalRuntime === void 0 ? void 0 : globalRuntime.__wxConfig;
|
|
2722
|
+
if ((wxConfig === null || wxConfig === void 0 ? void 0 : wxConfig.debug) === true || (wxConfig === null || wxConfig === void 0 ? void 0 : wxConfig.envVersion) === "develop") return true;
|
|
2723
|
+
const miniProgramGlobal = getMiniProgramGlobalObject();
|
|
2724
|
+
try {
|
|
2725
|
+
var _miniProgramGlobal$ge;
|
|
2726
|
+
if ((miniProgramGlobal === null || miniProgramGlobal === void 0 || (_miniProgramGlobal$ge = miniProgramGlobal.getAccountInfoSync) === null || _miniProgramGlobal$ge === void 0 || (_miniProgramGlobal$ge = _miniProgramGlobal$ge.call(miniProgramGlobal)) === null || _miniProgramGlobal$ge === void 0 || (_miniProgramGlobal$ge = _miniProgramGlobal$ge.miniProgram) === null || _miniProgramGlobal$ge === void 0 ? void 0 : _miniProgramGlobal$ge.envVersion) === "develop") return true;
|
|
2727
|
+
} catch (_unused) {}
|
|
2728
|
+
return false;
|
|
2729
|
+
}
|
|
2730
|
+
/**
|
|
2731
|
+
* 创建 setData 高频调用告警监视器。
|
|
2732
|
+
*/
|
|
2733
|
+
function createSetDataHighFrequencyWarningMonitor(options) {
|
|
2734
|
+
var _options$now, _options$logger;
|
|
2735
|
+
const resolved = resolveHighFrequencyWarningOptions(options.option);
|
|
2736
|
+
if (!resolved.enabled) return;
|
|
2737
|
+
const isDev = isDevelopmentRuntime();
|
|
2738
|
+
if (resolved.devOnly && !isDev) return;
|
|
2739
|
+
const now = (_options$now = options.now) !== null && _options$now !== void 0 ? _options$now : (() => Date.now());
|
|
2740
|
+
const logger = (_options$logger = options.logger) !== null && _options$logger !== void 0 ? _options$logger : ((message) => {
|
|
2741
|
+
var _globalThis;
|
|
2742
|
+
const runtimeConsoleWarn = (_globalThis = globalThis) === null || _globalThis === void 0 || (_globalThis = _globalThis.console) === null || _globalThis === void 0 ? void 0 : _globalThis.warn;
|
|
2743
|
+
if (typeof runtimeConsoleWarn === "function") runtimeConsoleWarn(message);
|
|
2744
|
+
});
|
|
2745
|
+
const callTimes = [];
|
|
2746
|
+
let lastWarnAt = Number.NEGATIVE_INFINITY;
|
|
2747
|
+
let lastPageScrollWarnAt = Number.NEGATIVE_INFINITY;
|
|
2748
|
+
return () => {
|
|
2749
|
+
var _options$isInPageScro, _options$isInPageScro2;
|
|
2750
|
+
const current = now();
|
|
2751
|
+
callTimes.push(current);
|
|
2752
|
+
const windowStart = current - resolved.sampleWindowMs;
|
|
2753
|
+
while (callTimes.length > 0 && callTimes[0] < windowStart) callTimes.shift();
|
|
2754
|
+
const inPageScrollHook = (_options$isInPageScro = (_options$isInPageScro2 = options.isInPageScrollHook) === null || _options$isInPageScro2 === void 0 ? void 0 : _options$isInPageScro2.call(options)) !== null && _options$isInPageScro !== void 0 ? _options$isInPageScro : false;
|
|
2755
|
+
if (resolved.warnOnPageScroll && inPageScrollHook) {
|
|
2756
|
+
if (resolved.pageScrollCoolDownMs <= 0 || current - lastPageScrollWarnAt >= resolved.pageScrollCoolDownMs) {
|
|
2757
|
+
lastPageScrollWarnAt = current;
|
|
2758
|
+
logger(`[wevu:setData] 检测到 onPageScroll 回调内调用 setData(${options.targetLabel})。建议改用 IntersectionObserver 监听可见性,或对滚动更新做节流。`);
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
if (callTimes.length <= resolved.maxCalls) return;
|
|
2762
|
+
if (resolved.coolDownMs > 0 && current - lastWarnAt < resolved.coolDownMs) return;
|
|
2763
|
+
lastWarnAt = current;
|
|
2764
|
+
logger(`[wevu:setData] 检测到高频 setData 调用:${callTimes.length} 次/${resolved.sampleWindowMs}ms(${options.targetLabel})。建议合并更新或降低调用频率。`);
|
|
2765
|
+
};
|
|
2766
|
+
}
|
|
2767
|
+
//#endregion
|
|
2768
|
+
//#region src/runtime/register/watch.ts
|
|
2769
|
+
function normalizeWatchDescriptor(descriptor, runtime, instance) {
|
|
2770
|
+
if (typeof descriptor === "function") return {
|
|
2771
|
+
handler: descriptor.bind(runtime.proxy),
|
|
2772
|
+
options: {}
|
|
2773
|
+
};
|
|
2774
|
+
if (typeof descriptor === "string") {
|
|
2775
|
+
var _descriptor, _runtime$methods;
|
|
2776
|
+
const method = (_descriptor = (_runtime$methods = runtime.methods) === null || _runtime$methods === void 0 ? void 0 : _runtime$methods[descriptor]) !== null && _descriptor !== void 0 ? _descriptor : instance[descriptor];
|
|
2777
|
+
if (typeof method === "function") return {
|
|
2778
|
+
handler: method.bind(runtime.proxy),
|
|
2779
|
+
options: {}
|
|
2780
|
+
};
|
|
2781
|
+
return;
|
|
3517
2782
|
}
|
|
2783
|
+
if (!descriptor || typeof descriptor !== "object") return;
|
|
2784
|
+
const base = normalizeWatchDescriptor(descriptor.handler, runtime, instance);
|
|
2785
|
+
if (!base) return;
|
|
2786
|
+
const options = { ...base.options };
|
|
2787
|
+
if (descriptor.immediate !== void 0) options.immediate = descriptor.immediate;
|
|
2788
|
+
if (descriptor.deep !== void 0) options.deep = descriptor.deep;
|
|
2789
|
+
return {
|
|
2790
|
+
handler: base.handler,
|
|
2791
|
+
options
|
|
2792
|
+
};
|
|
3518
2793
|
}
|
|
3519
|
-
function
|
|
3520
|
-
const
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
}
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
if (typeof route === "string" && route) return route;
|
|
3531
|
-
const is = instance.is;
|
|
3532
|
-
if (typeof is === "string" && is) return is;
|
|
3533
|
-
return "unknown";
|
|
2794
|
+
function createPathGetter(target, path) {
|
|
2795
|
+
const segments = path.split(".").map((segment) => segment.trim()).filter(Boolean);
|
|
2796
|
+
if (!segments.length) return () => target;
|
|
2797
|
+
return () => {
|
|
2798
|
+
let current = target;
|
|
2799
|
+
for (const segment of segments) {
|
|
2800
|
+
if (current == null) return current;
|
|
2801
|
+
current = current[segment];
|
|
2802
|
+
}
|
|
2803
|
+
return current;
|
|
2804
|
+
};
|
|
3534
2805
|
}
|
|
3535
|
-
function
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
const
|
|
3540
|
-
|
|
2806
|
+
function registerWatches(runtime, watchMap, instance) {
|
|
2807
|
+
const stops = [];
|
|
2808
|
+
const proxy = runtime.proxy;
|
|
2809
|
+
for (const [expression, descriptor] of Object.entries(watchMap)) {
|
|
2810
|
+
const normalized = normalizeWatchDescriptor(descriptor, runtime, instance);
|
|
2811
|
+
if (!normalized) continue;
|
|
2812
|
+
const getter = createPathGetter(proxy, expression);
|
|
2813
|
+
const stopHandle = runtime.watch(getter, normalized.handler, normalized.options);
|
|
2814
|
+
stops.push(stopHandle);
|
|
3541
2815
|
}
|
|
2816
|
+
return stops;
|
|
3542
2817
|
}
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
for (const key of currentKeys) if (!Object.prototype.hasOwnProperty.call(mpProperties, key)) try {
|
|
3546
|
-
delete props[key];
|
|
3547
|
-
} catch (_unused9) {}
|
|
3548
|
-
for (const [key, value] of Object.entries(mpProperties)) props[key] = value;
|
|
3549
|
-
}
|
|
2818
|
+
//#endregion
|
|
2819
|
+
//#region src/runtime/register/runtimeInstance.ts
|
|
3550
2820
|
/**
|
|
3551
2821
|
* 挂载运行时实例(框架内部注册流程使用)。
|
|
3552
2822
|
* @internal
|
|
3553
2823
|
*/
|
|
3554
2824
|
function mountRuntimeInstance(target, runtimeApp, watchMap, setup, options) {
|
|
3555
|
-
var _runtime$proxy, _runtime$state, _computed, _runtime$methods, _watch, _bindModel, _snapshot, _unmount;
|
|
2825
|
+
var _wevuSetDataOptions, _wevuSetDataOptions2, _runtime$proxy, _runtime$state, _computed, _runtime$methods, _watch, _bindModel, _snapshot, _unmount;
|
|
3556
2826
|
if (target.__wevu) return target.__wevu;
|
|
3557
2827
|
safeMarkNoSetData(target);
|
|
3558
2828
|
const ownerId = allocateOwnerId();
|
|
2829
|
+
const suspendWhenHidden = Boolean(runtimeApp === null || runtimeApp === void 0 || (_wevuSetDataOptions = runtimeApp.__wevuSetDataOptions) === null || _wevuSetDataOptions === void 0 ? void 0 : _wevuSetDataOptions.suspendWhenHidden);
|
|
2830
|
+
const targetLabel = typeof target.route === "string" && target.route ? `page:${target.route}` : typeof target.is === "string" && target.is ? `component:${target.is}` : "unknown-target";
|
|
2831
|
+
const highFrequencyWarning = createSetDataHighFrequencyWarningMonitor({
|
|
2832
|
+
option: runtimeApp === null || runtimeApp === void 0 || (_wevuSetDataOptions2 = runtimeApp.__wevuSetDataOptions) === null || _wevuSetDataOptions2 === void 0 ? void 0 : _wevuSetDataOptions2.highFrequencyWarning,
|
|
2833
|
+
targetLabel,
|
|
2834
|
+
isInPageScrollHook: () => {
|
|
2835
|
+
var _wevuPageScrollHookDe;
|
|
2836
|
+
return Number((_wevuPageScrollHookDe = target.__wevuPageScrollHookDepth) !== null && _wevuPageScrollHookDe !== void 0 ? _wevuPageScrollHookDe : 0) > 0;
|
|
2837
|
+
}
|
|
2838
|
+
});
|
|
3559
2839
|
const createDeferredAdapter = (instance) => {
|
|
3560
2840
|
let pending;
|
|
3561
2841
|
let enabled = false;
|
|
@@ -3587,6 +2867,12 @@ function mountRuntimeInstance(target, runtimeApp, watchMap, setup, options) {
|
|
|
3587
2867
|
if (setData) return callNativeSetData(target, setData, payload);
|
|
3588
2868
|
} };
|
|
3589
2869
|
let runtimeRef;
|
|
2870
|
+
let visible = true;
|
|
2871
|
+
let hiddenPendingPayload;
|
|
2872
|
+
const mergePendingPayload = (pending, payload) => ({
|
|
2873
|
+
...pending !== null && pending !== void 0 ? pending : {},
|
|
2874
|
+
...payload
|
|
2875
|
+
});
|
|
3590
2876
|
const refreshOwnerSnapshot = () => {
|
|
3591
2877
|
var _wevuProps;
|
|
3592
2878
|
if (!runtimeRef) return;
|
|
@@ -3599,6 +2885,23 @@ function mountRuntimeInstance(target, runtimeApp, watchMap, setup, options) {
|
|
|
3599
2885
|
const adapter = {
|
|
3600
2886
|
...baseAdapter,
|
|
3601
2887
|
setData(payload) {
|
|
2888
|
+
highFrequencyWarning === null || highFrequencyWarning === void 0 || highFrequencyWarning();
|
|
2889
|
+
if (suspendWhenHidden && !visible) {
|
|
2890
|
+
hiddenPendingPayload = mergePendingPayload(hiddenPendingPayload, payload);
|
|
2891
|
+
refreshOwnerSnapshot();
|
|
2892
|
+
scheduleTemplateRefUpdate(target);
|
|
2893
|
+
return;
|
|
2894
|
+
}
|
|
2895
|
+
const result = baseAdapter.setData(payload);
|
|
2896
|
+
refreshOwnerSnapshot();
|
|
2897
|
+
scheduleTemplateRefUpdate(target);
|
|
2898
|
+
return result;
|
|
2899
|
+
},
|
|
2900
|
+
__wevu_setVisibility(nextVisible) {
|
|
2901
|
+
visible = nextVisible;
|
|
2902
|
+
if (!visible || !hiddenPendingPayload) return;
|
|
2903
|
+
const payload = hiddenPendingPayload;
|
|
2904
|
+
hiddenPendingPayload = void 0;
|
|
3602
2905
|
const result = baseAdapter.setData(payload);
|
|
3603
2906
|
refreshOwnerSnapshot();
|
|
3604
2907
|
scheduleTemplateRefUpdate(target);
|
|
@@ -3617,7 +2920,7 @@ function mountRuntimeInstance(target, runtimeApp, watchMap, setup, options) {
|
|
|
3617
2920
|
const runtimeComputed = (_computed = runtime === null || runtime === void 0 ? void 0 : runtime.computed) !== null && _computed !== void 0 ? _computed : Object.create(null);
|
|
3618
2921
|
if (!(runtime === null || runtime === void 0 ? void 0 : runtime.methods)) try {
|
|
3619
2922
|
runtime.methods = Object.create(null);
|
|
3620
|
-
} catch (
|
|
2923
|
+
} catch (_unused) {}
|
|
3621
2924
|
const runtimeMethods = (_runtime$methods = runtime === null || runtime === void 0 ? void 0 : runtime.methods) !== null && _runtime$methods !== void 0 ? _runtime$methods : Object.create(null);
|
|
3622
2925
|
const runtimeWatch = (_watch = runtime === null || runtime === void 0 ? void 0 : runtime.watch) !== null && _watch !== void 0 ? _watch : (() => createNoopWatchStopHandle());
|
|
3623
2926
|
const runtimeBindModel = (_bindModel = runtime === null || runtime === void 0 ? void 0 : runtime.bindModel) !== null && _bindModel !== void 0 ? _bindModel : (() => {});
|
|
@@ -3644,128 +2947,17 @@ function mountRuntimeInstance(target, runtimeApp, watchMap, setup, options) {
|
|
|
3644
2947
|
const stops = registerWatches(runtimeWithDefaults, watchMap, target);
|
|
3645
2948
|
if (stops.length) target.__wevuWatchStops = stops;
|
|
3646
2949
|
}
|
|
3647
|
-
if (setup) {
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
writable: false
|
|
3659
|
-
});
|
|
3660
|
-
} catch (_unused11) {
|
|
3661
|
-
target.__wevuProps = props;
|
|
3662
|
-
}
|
|
3663
|
-
const attrs = shallowReactive(Object.create(null));
|
|
3664
|
-
const declaredPropKeys = new Set(Array.isArray(target.__wevuPropKeys) ? target.__wevuPropKeys : []);
|
|
3665
|
-
const hasRuntimeStateKey = (key) => {
|
|
3666
|
-
return runtimeState != null && typeof runtimeState === "object" && Object.prototype.hasOwnProperty.call(runtimeState, key);
|
|
3667
|
-
};
|
|
3668
|
-
const syncAttrsFromProperties = () => {
|
|
3669
|
-
const next = target.properties && typeof target.properties === "object" ? target.properties : void 0;
|
|
3670
|
-
for (const existingKey of Object.keys(attrs)) if (!next || !Object.prototype.hasOwnProperty.call(next, existingKey) || declaredPropKeys.has(existingKey) || hasRuntimeStateKey(existingKey)) delete attrs[existingKey];
|
|
3671
|
-
if (!next) return;
|
|
3672
|
-
for (const [key, value] of Object.entries(next)) {
|
|
3673
|
-
if (declaredPropKeys.has(key) || hasRuntimeStateKey(key)) continue;
|
|
3674
|
-
attrs[key] = value;
|
|
3675
|
-
}
|
|
3676
|
-
};
|
|
3677
|
-
syncAttrsFromProperties();
|
|
3678
|
-
try {
|
|
3679
|
-
Object.defineProperty(target, "__wevuAttrs", {
|
|
3680
|
-
value: attrs,
|
|
3681
|
-
configurable: true,
|
|
3682
|
-
enumerable: false,
|
|
3683
|
-
writable: false
|
|
3684
|
-
});
|
|
3685
|
-
} catch (_unused12) {
|
|
3686
|
-
target.__wevuAttrs = attrs;
|
|
3687
|
-
}
|
|
3688
|
-
const setupInstance = ensureSetupContextInstance(target, runtimeWithDefaults);
|
|
3689
|
-
const context = safeMarkNoSetData({
|
|
3690
|
-
props,
|
|
3691
|
-
runtime: runtimeWithDefaults,
|
|
3692
|
-
state: runtimeState,
|
|
3693
|
-
proxy: runtimeProxy,
|
|
3694
|
-
bindModel: runtimeBindModel.bind(runtimeWithDefaults),
|
|
3695
|
-
watch: runtimeWatch.bind(runtimeWithDefaults),
|
|
3696
|
-
instance: setupInstance,
|
|
3697
|
-
emit: (event, ...args) => {
|
|
3698
|
-
const { detail, options } = normalizeEmitPayload(args);
|
|
3699
|
-
setupInstance.triggerEvent(event, detail, options);
|
|
3700
|
-
},
|
|
3701
|
-
expose: (exposed) => {
|
|
3702
|
-
target.__wevuExposed = exposed;
|
|
3703
|
-
},
|
|
3704
|
-
attrs,
|
|
3705
|
-
slots: createSetupSlotsFallback()
|
|
3706
|
-
});
|
|
3707
|
-
setCurrentInstance(target);
|
|
3708
|
-
setCurrentSetupContext(context);
|
|
3709
|
-
try {
|
|
3710
|
-
const result = runSetupFunction(setup, props, context);
|
|
3711
|
-
let methodsChanged = false;
|
|
3712
|
-
if (result && typeof result === "object") {
|
|
3713
|
-
const runtimeRawState = isReactive(runtime.state) ? toRaw(runtime.state) : runtime.state;
|
|
3714
|
-
Object.keys(result).forEach((key) => {
|
|
3715
|
-
const val = result[key];
|
|
3716
|
-
if (typeof val === "function") {
|
|
3717
|
-
runtime.methods[key] = (...args) => val.apply(runtime.proxy, args);
|
|
3718
|
-
methodsChanged = true;
|
|
3719
|
-
} else {
|
|
3720
|
-
if (declaredPropKeys.has(key)) {
|
|
3721
|
-
let fallbackValue = val;
|
|
3722
|
-
try {
|
|
3723
|
-
Object.defineProperty(runtimeRawState, key, {
|
|
3724
|
-
configurable: true,
|
|
3725
|
-
enumerable: false,
|
|
3726
|
-
get() {
|
|
3727
|
-
const propsSource = runtimeRawState.__wevuProps;
|
|
3728
|
-
if (propsSource && typeof propsSource === "object" && Object.prototype.hasOwnProperty.call(propsSource, key)) return propsSource[key];
|
|
3729
|
-
return fallbackValue;
|
|
3730
|
-
},
|
|
3731
|
-
set(next) {
|
|
3732
|
-
fallbackValue = next;
|
|
3733
|
-
const propsSource = runtimeRawState.__wevuProps;
|
|
3734
|
-
if (!propsSource || typeof propsSource !== "object") return;
|
|
3735
|
-
try {
|
|
3736
|
-
propsSource[key] = next;
|
|
3737
|
-
} catch (_unused13) {}
|
|
3738
|
-
}
|
|
3739
|
-
});
|
|
3740
|
-
} catch (_unused14) {
|
|
3741
|
-
runtime.state[key] = val;
|
|
3742
|
-
}
|
|
3743
|
-
return;
|
|
3744
|
-
}
|
|
3745
|
-
runtime.state[key] = val;
|
|
3746
|
-
}
|
|
3747
|
-
});
|
|
3748
|
-
}
|
|
3749
|
-
if (methodsChanged) {
|
|
3750
|
-
var _wevu_touchSetupMetho;
|
|
3751
|
-
(_wevu_touchSetupMetho = runtime.__wevu_touchSetupMethodsVersion) === null || _wevu_touchSetupMetho === void 0 || _wevu_touchSetupMetho.call(runtime);
|
|
3752
|
-
}
|
|
3753
|
-
} finally {
|
|
3754
|
-
setCurrentSetupContext(void 0);
|
|
3755
|
-
setCurrentInstance(void 0);
|
|
3756
|
-
}
|
|
3757
|
-
}
|
|
3758
|
-
try {
|
|
3759
|
-
const methods = runtime.methods;
|
|
3760
|
-
for (const name of Object.keys(methods)) {
|
|
3761
|
-
if (setupInstanceMethodNames.includes(name)) continue;
|
|
3762
|
-
if (typeof target[name] !== "function") target[name] = function bridged(...args) {
|
|
3763
|
-
var _this$$wevu;
|
|
3764
|
-
const bound = (_this$$wevu = this.$wevu) === null || _this$$wevu === void 0 || (_this$$wevu = _this$$wevu.methods) === null || _this$$wevu === void 0 ? void 0 : _this$$wevu[name];
|
|
3765
|
-
if (typeof bound === "function") return bound.apply(this.$wevu.proxy, args);
|
|
3766
|
-
};
|
|
3767
|
-
}
|
|
3768
|
-
} catch (_unused15) {}
|
|
2950
|
+
if (setup) runRuntimeSetupPhase({
|
|
2951
|
+
target,
|
|
2952
|
+
runtime,
|
|
2953
|
+
runtimeWithDefaults,
|
|
2954
|
+
runtimeState,
|
|
2955
|
+
runtimeProxy,
|
|
2956
|
+
setup,
|
|
2957
|
+
syncRuntimeProps,
|
|
2958
|
+
attachRuntimeProxyProps
|
|
2959
|
+
});
|
|
2960
|
+
bridgeRuntimeMethodsToTarget(target, runtime);
|
|
3769
2961
|
return runtime;
|
|
3770
2962
|
}
|
|
3771
2963
|
function enableDeferredSetData(target) {
|
|
@@ -3773,6 +2965,11 @@ function enableDeferredSetData(target) {
|
|
|
3773
2965
|
const adapter = (_wevu = target.__wevu) === null || _wevu === void 0 ? void 0 : _wevu.adapter;
|
|
3774
2966
|
if (adapter && typeof adapter.__wevu_enableSetData === "function") adapter.__wevu_enableSetData();
|
|
3775
2967
|
}
|
|
2968
|
+
function setRuntimeSetDataVisibility(target, visible) {
|
|
2969
|
+
var _wevu2;
|
|
2970
|
+
const adapter = (_wevu2 = target.__wevu) === null || _wevu2 === void 0 ? void 0 : _wevu2.adapter;
|
|
2971
|
+
if (adapter && typeof adapter.__wevu_setVisibility === "function") adapter.__wevu_setVisibility(visible);
|
|
2972
|
+
}
|
|
3776
2973
|
/**
|
|
3777
2974
|
* 卸载运行时实例(框架内部注册流程使用)。
|
|
3778
2975
|
* @internal
|
|
@@ -3787,15 +2984,36 @@ function teardownRuntimeInstance(target) {
|
|
|
3787
2984
|
const stops = target.__wevuWatchStops;
|
|
3788
2985
|
if (Array.isArray(stops)) for (const stop of stops) try {
|
|
3789
2986
|
stop();
|
|
3790
|
-
} catch (
|
|
2987
|
+
} catch (_unused2) {}
|
|
3791
2988
|
target.__wevuWatchStops = void 0;
|
|
3792
2989
|
if (runtime) runtime.unmount();
|
|
3793
2990
|
delete target.__wevu;
|
|
3794
2991
|
if ("$wevu" in target) delete target.$wevu;
|
|
3795
2992
|
}
|
|
3796
|
-
|
|
3797
2993
|
//#endregion
|
|
3798
2994
|
//#region src/runtime/register/app.ts
|
|
2995
|
+
const MEMORY_WARNING_LISTENER_KEY = "__wevuOnMemoryWarningListener";
|
|
2996
|
+
function bindMemoryWarningListener(target) {
|
|
2997
|
+
const hooks = target.__wevuHooks;
|
|
2998
|
+
const hasMemoryWarningHook = Boolean(hooks === null || hooks === void 0 ? void 0 : hooks.onMemoryWarning);
|
|
2999
|
+
const wxGlobal = getMiniProgramGlobalObject();
|
|
3000
|
+
const onMemoryWarning = wxGlobal === null || wxGlobal === void 0 ? void 0 : wxGlobal.onMemoryWarning;
|
|
3001
|
+
const offMemoryWarning = wxGlobal === null || wxGlobal === void 0 ? void 0 : wxGlobal.offMemoryWarning;
|
|
3002
|
+
if (typeof onMemoryWarning !== "function") return;
|
|
3003
|
+
const existing = target[MEMORY_WARNING_LISTENER_KEY];
|
|
3004
|
+
if (typeof existing === "function" && typeof offMemoryWarning === "function") try {
|
|
3005
|
+
offMemoryWarning(existing);
|
|
3006
|
+
} catch (_unused) {}
|
|
3007
|
+
if (!hasMemoryWarningHook) {
|
|
3008
|
+
delete target[MEMORY_WARNING_LISTENER_KEY];
|
|
3009
|
+
return;
|
|
3010
|
+
}
|
|
3011
|
+
const listener = (result) => {
|
|
3012
|
+
callHookList(target, "onMemoryWarning", [result]);
|
|
3013
|
+
};
|
|
3014
|
+
target[MEMORY_WARNING_LISTENER_KEY] = listener;
|
|
3015
|
+
onMemoryWarning(listener);
|
|
3016
|
+
}
|
|
3799
3017
|
/**
|
|
3800
3018
|
* 注册 App 入口(框架内部使用)。
|
|
3801
3019
|
* @internal
|
|
@@ -3814,6 +3032,7 @@ function registerApp(runtimeApp, methods, watch, setup, mpOptions) {
|
|
|
3814
3032
|
const userOnLaunch = appOptions.onLaunch;
|
|
3815
3033
|
appOptions.onLaunch = function onLaunch(...args) {
|
|
3816
3034
|
mountRuntimeInstance(this, runtimeApp, watch, setup);
|
|
3035
|
+
bindMemoryWarningListener(this);
|
|
3817
3036
|
callHookList(this, "onLaunch", args);
|
|
3818
3037
|
if (typeof userOnLaunch === "function") userOnLaunch.apply(this, args);
|
|
3819
3038
|
};
|
|
@@ -3861,7 +3080,6 @@ function registerApp(runtimeApp, methods, watch, setup, mpOptions) {
|
|
|
3861
3080
|
}
|
|
3862
3081
|
App(appOptions);
|
|
3863
3082
|
}
|
|
3864
|
-
|
|
3865
3083
|
//#endregion
|
|
3866
3084
|
//#region src/runtime/register/component/features.ts
|
|
3867
3085
|
function resolveComponentFeatures(options) {
|
|
@@ -3902,11 +3120,29 @@ function resolveComponentFeatures(options) {
|
|
|
3902
3120
|
effectiveOnAddToFavorites: typeof userOnAddToFavorites === "function" ? userOnAddToFavorites : (() => ({}))
|
|
3903
3121
|
};
|
|
3904
3122
|
}
|
|
3905
|
-
|
|
3906
3123
|
//#endregion
|
|
3907
|
-
//#region src/runtime/register/component/lifecycle.ts
|
|
3124
|
+
//#region src/runtime/register/component/lifecycle/platform.ts
|
|
3908
3125
|
let wxPatched = false;
|
|
3909
3126
|
let currentPageInstance;
|
|
3127
|
+
const PAGE_SCROLL_HOOK_DEPTH_KEY = "__wevuPageScrollHookDepth";
|
|
3128
|
+
function bindCurrentPageInstance(target) {
|
|
3129
|
+
currentPageInstance = target;
|
|
3130
|
+
}
|
|
3131
|
+
function releaseCurrentPageInstance(target) {
|
|
3132
|
+
if (currentPageInstance === target) currentPageInstance = void 0;
|
|
3133
|
+
}
|
|
3134
|
+
function runInPageScrollHook(target, task) {
|
|
3135
|
+
var _PAGE_SCROLL_HOOK_DEP;
|
|
3136
|
+
target[PAGE_SCROLL_HOOK_DEPTH_KEY] = Number((_PAGE_SCROLL_HOOK_DEP = target[PAGE_SCROLL_HOOK_DEPTH_KEY]) !== null && _PAGE_SCROLL_HOOK_DEP !== void 0 ? _PAGE_SCROLL_HOOK_DEP : 0) + 1;
|
|
3137
|
+
try {
|
|
3138
|
+
return task();
|
|
3139
|
+
} finally {
|
|
3140
|
+
var _PAGE_SCROLL_HOOK_DEP2;
|
|
3141
|
+
const nextDepth = Number((_PAGE_SCROLL_HOOK_DEP2 = target[PAGE_SCROLL_HOOK_DEPTH_KEY]) !== null && _PAGE_SCROLL_HOOK_DEP2 !== void 0 ? _PAGE_SCROLL_HOOK_DEP2 : 1) - 1;
|
|
3142
|
+
if (nextDepth <= 0) delete target[PAGE_SCROLL_HOOK_DEPTH_KEY];
|
|
3143
|
+
else target[PAGE_SCROLL_HOOK_DEPTH_KEY] = nextDepth;
|
|
3144
|
+
}
|
|
3145
|
+
}
|
|
3910
3146
|
function resolvePageOptions(target) {
|
|
3911
3147
|
const direct = target.options;
|
|
3912
3148
|
if (direct && typeof direct === "object") return direct;
|
|
@@ -3932,7 +3168,12 @@ function ensureWxPatched() {
|
|
|
3932
3168
|
const rawPageScrollTo = wxGlobal.pageScrollTo;
|
|
3933
3169
|
if (typeof rawPageScrollTo === "function") wxGlobal.pageScrollTo = function pageScrollToPatched(options, ...rest) {
|
|
3934
3170
|
const result = rawPageScrollTo.apply(this, [options, ...rest]);
|
|
3935
|
-
if (currentPageInstance)
|
|
3171
|
+
if (currentPageInstance) {
|
|
3172
|
+
const pageInstance = currentPageInstance;
|
|
3173
|
+
runInPageScrollHook(pageInstance, () => {
|
|
3174
|
+
callHookList(pageInstance, "onPageScroll", [options !== null && options !== void 0 ? options : {}]);
|
|
3175
|
+
});
|
|
3176
|
+
}
|
|
3936
3177
|
return result;
|
|
3937
3178
|
};
|
|
3938
3179
|
}
|
|
@@ -3954,6 +3195,65 @@ function ensurePageShareMenus(options) {
|
|
|
3954
3195
|
menus
|
|
3955
3196
|
});
|
|
3956
3197
|
}
|
|
3198
|
+
//#endregion
|
|
3199
|
+
//#region src/runtime/register/component/lifecycle/optionalHooks.ts
|
|
3200
|
+
function attachOptionalPageLifecycleHooks(pageLifecycleHooks, options) {
|
|
3201
|
+
const { enableOnSaveExitState, enableOnPullDownRefresh, enableOnReachBottom, enableOnPageScroll, enableOnRouteDone, enableOnTabItemTap, enableOnResize, enableOnShareAppMessage, enableOnShareTimeline, enableOnAddToFavorites, effectiveOnSaveExitState, effectiveOnPullDownRefresh, effectiveOnReachBottom, effectiveOnPageScroll, effectiveOnRouteDone, effectiveOnTabItemTap, effectiveOnResize, effectiveOnShareAppMessage, effectiveOnShareTimeline, effectiveOnAddToFavorites, hasHook } = options;
|
|
3202
|
+
if (enableOnSaveExitState) pageLifecycleHooks.onSaveExitState = function onSaveExitState(...args) {
|
|
3203
|
+
const ret = callHookReturn(this, "onSaveExitState", args);
|
|
3204
|
+
if (ret !== void 0) return ret;
|
|
3205
|
+
return effectiveOnSaveExitState.apply(this, args);
|
|
3206
|
+
};
|
|
3207
|
+
if (enableOnPullDownRefresh) pageLifecycleHooks.onPullDownRefresh = function onPullDownRefresh(...args) {
|
|
3208
|
+
callHookList(this, "onPullDownRefresh", args);
|
|
3209
|
+
if (!hasHook(this, "onPullDownRefresh")) return effectiveOnPullDownRefresh.apply(this, args);
|
|
3210
|
+
};
|
|
3211
|
+
if (enableOnReachBottom) pageLifecycleHooks.onReachBottom = function onReachBottom(...args) {
|
|
3212
|
+
callHookList(this, "onReachBottom", args);
|
|
3213
|
+
if (!hasHook(this, "onReachBottom")) return effectiveOnReachBottom.apply(this, args);
|
|
3214
|
+
};
|
|
3215
|
+
if (enableOnPageScroll) pageLifecycleHooks.onPageScroll = function onPageScroll(...args) {
|
|
3216
|
+
return runInPageScrollHook(this, () => {
|
|
3217
|
+
callHookList(this, "onPageScroll", args);
|
|
3218
|
+
if (!hasHook(this, "onPageScroll")) return effectiveOnPageScroll.apply(this, args);
|
|
3219
|
+
});
|
|
3220
|
+
};
|
|
3221
|
+
if (enableOnRouteDone) pageLifecycleHooks.onRouteDone = function onRouteDone(...args) {
|
|
3222
|
+
if (this.__wevuRouteDoneInTick) return;
|
|
3223
|
+
this.__wevuRouteDoneInTick = true;
|
|
3224
|
+
Promise.resolve().then(() => {
|
|
3225
|
+
this.__wevuRouteDoneInTick = false;
|
|
3226
|
+
});
|
|
3227
|
+
this.__wevuRouteDoneCalled = true;
|
|
3228
|
+
callHookList(this, "onRouteDone", args);
|
|
3229
|
+
if (!hasHook(this, "onRouteDone")) return effectiveOnRouteDone.apply(this, args);
|
|
3230
|
+
};
|
|
3231
|
+
if (enableOnTabItemTap) pageLifecycleHooks.onTabItemTap = function onTabItemTap(...args) {
|
|
3232
|
+
callHookList(this, "onTabItemTap", args);
|
|
3233
|
+
if (!hasHook(this, "onTabItemTap")) return effectiveOnTabItemTap.apply(this, args);
|
|
3234
|
+
};
|
|
3235
|
+
if (enableOnResize) pageLifecycleHooks.onResize = function onResize(...args) {
|
|
3236
|
+
callHookList(this, "onResize", args);
|
|
3237
|
+
if (!hasHook(this, "onResize")) return effectiveOnResize.apply(this, args);
|
|
3238
|
+
};
|
|
3239
|
+
if (enableOnShareAppMessage) pageLifecycleHooks.onShareAppMessage = function onShareAppMessage(...args) {
|
|
3240
|
+
const ret = callHookReturn(this, "onShareAppMessage", args);
|
|
3241
|
+
if (ret !== void 0) return ret;
|
|
3242
|
+
return effectiveOnShareAppMessage.apply(this, args);
|
|
3243
|
+
};
|
|
3244
|
+
if (enableOnShareTimeline) pageLifecycleHooks.onShareTimeline = function onShareTimeline(...args) {
|
|
3245
|
+
const ret = callHookReturn(this, "onShareTimeline", args);
|
|
3246
|
+
if (ret !== void 0) return ret;
|
|
3247
|
+
return effectiveOnShareTimeline.apply(this, args);
|
|
3248
|
+
};
|
|
3249
|
+
if (enableOnAddToFavorites) pageLifecycleHooks.onAddToFavorites = function onAddToFavorites(...args) {
|
|
3250
|
+
const ret = callHookReturn(this, "onAddToFavorites", args);
|
|
3251
|
+
if (ret !== void 0) return ret;
|
|
3252
|
+
return effectiveOnAddToFavorites.apply(this, args);
|
|
3253
|
+
};
|
|
3254
|
+
}
|
|
3255
|
+
//#endregion
|
|
3256
|
+
//#region src/runtime/register/component/lifecycle.ts
|
|
3957
3257
|
function createPageLifecycleHooks(options) {
|
|
3958
3258
|
const { runtimeApp, watch, setup, userOnLoad, userOnUnload, userOnShow, userOnHide, userOnReady, isPage, enableOnSaveExitState, enableOnPullDownRefresh, enableOnReachBottom, enableOnPageScroll, enableOnRouteDone, enableOnRouteDoneFallback, enableOnTabItemTap, enableOnResize, enableOnShareAppMessage, enableOnShareTimeline, enableOnAddToFavorites, effectiveOnSaveExitState, effectiveOnPullDownRefresh, effectiveOnReachBottom, effectiveOnPageScroll, effectiveOnRouteDone, effectiveOnTabItemTap, effectiveOnResize, effectiveOnShareAppMessage, effectiveOnShareTimeline, effectiveOnAddToFavorites, hasHook } = options;
|
|
3959
3259
|
const pageLifecycleHooks = {
|
|
@@ -3970,14 +3270,14 @@ function createPageLifecycleHooks(options) {
|
|
|
3970
3270
|
if (typeof userOnLoad === "function") return userOnLoad.apply(this, args);
|
|
3971
3271
|
},
|
|
3972
3272
|
onUnload(...args) {
|
|
3973
|
-
if (isPage
|
|
3273
|
+
if (isPage) releaseCurrentPageInstance(this);
|
|
3974
3274
|
teardownRuntimeInstance(this);
|
|
3975
3275
|
if (typeof userOnUnload === "function") return userOnUnload.apply(this, args);
|
|
3976
3276
|
},
|
|
3977
3277
|
onShow(...args) {
|
|
3978
3278
|
if (isPage) {
|
|
3979
3279
|
ensureWxPatched();
|
|
3980
|
-
|
|
3280
|
+
bindCurrentPageInstance(this);
|
|
3981
3281
|
if (!this.__wevuOnLoadCalled) pageLifecycleHooks.onLoad.call(this, resolvePageOptions(this));
|
|
3982
3282
|
ensurePageShareMenus({
|
|
3983
3283
|
enableOnShareAppMessage,
|
|
@@ -3985,11 +3285,13 @@ function createPageLifecycleHooks(options) {
|
|
|
3985
3285
|
});
|
|
3986
3286
|
this.__wevuRouteDoneCalled = false;
|
|
3987
3287
|
}
|
|
3288
|
+
setRuntimeSetDataVisibility(this, true);
|
|
3988
3289
|
callHookList(this, "onShow", args);
|
|
3989
3290
|
if (typeof userOnShow === "function") return userOnShow.apply(this, args);
|
|
3990
3291
|
},
|
|
3991
3292
|
onHide(...args) {
|
|
3992
|
-
if (isPage
|
|
3293
|
+
if (isPage) releaseCurrentPageInstance(this);
|
|
3294
|
+
setRuntimeSetDataVisibility(this, false);
|
|
3993
3295
|
callHookList(this, "onHide", args);
|
|
3994
3296
|
if (typeof userOnHide === "function") return userOnHide.apply(this, args);
|
|
3995
3297
|
},
|
|
@@ -4021,59 +3323,31 @@ function createPageLifecycleHooks(options) {
|
|
|
4021
3323
|
if (typeof userOnReady === "function") return userOnReady.apply(this, args);
|
|
4022
3324
|
}
|
|
4023
3325
|
};
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
this.__wevuRouteDoneCalled = true;
|
|
4048
|
-
callHookList(this, "onRouteDone", args);
|
|
4049
|
-
if (!hasHook(this, "onRouteDone")) return effectiveOnRouteDone.apply(this, args);
|
|
4050
|
-
};
|
|
4051
|
-
if (enableOnTabItemTap) pageLifecycleHooks.onTabItemTap = function onTabItemTap(...args) {
|
|
4052
|
-
callHookList(this, "onTabItemTap", args);
|
|
4053
|
-
if (!hasHook(this, "onTabItemTap")) return effectiveOnTabItemTap.apply(this, args);
|
|
4054
|
-
};
|
|
4055
|
-
if (enableOnResize) pageLifecycleHooks.onResize = function onResize(...args) {
|
|
4056
|
-
callHookList(this, "onResize", args);
|
|
4057
|
-
if (!hasHook(this, "onResize")) return effectiveOnResize.apply(this, args);
|
|
4058
|
-
};
|
|
4059
|
-
if (enableOnShareAppMessage) pageLifecycleHooks.onShareAppMessage = function onShareAppMessage(...args) {
|
|
4060
|
-
const ret = callHookReturn(this, "onShareAppMessage", args);
|
|
4061
|
-
if (ret !== void 0) return ret;
|
|
4062
|
-
return effectiveOnShareAppMessage.apply(this, args);
|
|
4063
|
-
};
|
|
4064
|
-
if (enableOnShareTimeline) pageLifecycleHooks.onShareTimeline = function onShareTimeline(...args) {
|
|
4065
|
-
const ret = callHookReturn(this, "onShareTimeline", args);
|
|
4066
|
-
if (ret !== void 0) return ret;
|
|
4067
|
-
return effectiveOnShareTimeline.apply(this, args);
|
|
4068
|
-
};
|
|
4069
|
-
if (enableOnAddToFavorites) pageLifecycleHooks.onAddToFavorites = function onAddToFavorites(...args) {
|
|
4070
|
-
const ret = callHookReturn(this, "onAddToFavorites", args);
|
|
4071
|
-
if (ret !== void 0) return ret;
|
|
4072
|
-
return effectiveOnAddToFavorites.apply(this, args);
|
|
4073
|
-
};
|
|
3326
|
+
attachOptionalPageLifecycleHooks(pageLifecycleHooks, {
|
|
3327
|
+
enableOnSaveExitState,
|
|
3328
|
+
enableOnPullDownRefresh,
|
|
3329
|
+
enableOnReachBottom,
|
|
3330
|
+
enableOnPageScroll,
|
|
3331
|
+
enableOnRouteDone,
|
|
3332
|
+
enableOnTabItemTap,
|
|
3333
|
+
enableOnResize,
|
|
3334
|
+
enableOnShareAppMessage,
|
|
3335
|
+
enableOnShareTimeline,
|
|
3336
|
+
enableOnAddToFavorites,
|
|
3337
|
+
effectiveOnSaveExitState,
|
|
3338
|
+
effectiveOnPullDownRefresh,
|
|
3339
|
+
effectiveOnReachBottom,
|
|
3340
|
+
effectiveOnPageScroll,
|
|
3341
|
+
effectiveOnRouteDone,
|
|
3342
|
+
effectiveOnTabItemTap,
|
|
3343
|
+
effectiveOnResize,
|
|
3344
|
+
effectiveOnShareAppMessage,
|
|
3345
|
+
effectiveOnShareTimeline,
|
|
3346
|
+
effectiveOnAddToFavorites,
|
|
3347
|
+
hasHook
|
|
3348
|
+
});
|
|
4074
3349
|
return pageLifecycleHooks;
|
|
4075
3350
|
}
|
|
4076
|
-
|
|
4077
3351
|
//#endregion
|
|
4078
3352
|
//#region src/runtime/register/component/methods.ts
|
|
4079
3353
|
function createComponentMethods(options) {
|
|
@@ -4112,8 +3386,8 @@ function createComponentMethods(options) {
|
|
|
4112
3386
|
const proxyMethod = runtimeProxy === null || runtimeProxy === void 0 ? void 0 : runtimeProxy[methodName];
|
|
4113
3387
|
return typeof proxyMethod === "function" && instanceMethod === proxyMethod;
|
|
4114
3388
|
};
|
|
4115
|
-
if (isBridgeMethod("triggerEvent") || isBridgeMethod("createSelectorQuery") || isBridgeMethod("setData")) return;
|
|
4116
|
-
if (!(typeof instance.triggerEvent === "function" || typeof instance.createSelectorQuery === "function" || typeof instance.setData === "function")) return;
|
|
3389
|
+
if (isBridgeMethod("triggerEvent") || isBridgeMethod("createSelectorQuery") || isBridgeMethod("createIntersectionObserver") || isBridgeMethod("setData")) return;
|
|
3390
|
+
if (!(typeof instance.triggerEvent === "function" || typeof instance.createSelectorQuery === "function" || typeof instance.createIntersectionObserver === "function" || typeof instance.setData === "function")) return;
|
|
4117
3391
|
const runtimeState = runtime === null || runtime === void 0 ? void 0 : runtime.state;
|
|
4118
3392
|
if (!runtimeState || typeof runtimeState !== "object") return;
|
|
4119
3393
|
if (instance.$state === runtimeState) return;
|
|
@@ -4147,157 +3421,31 @@ function createComponentMethods(options) {
|
|
|
4147
3421
|
}
|
|
4148
3422
|
return { finalMethods };
|
|
4149
3423
|
}
|
|
4150
|
-
|
|
4151
3424
|
//#endregion
|
|
4152
|
-
//#region src/runtime/register/
|
|
4153
|
-
function
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
const snapshot = runtime.snapshot();
|
|
4159
|
-
const propsSource = (_wevuProps = instance.__wevuProps) !== null && _wevuProps !== void 0 ? _wevuProps : instance.properties;
|
|
4160
|
-
if (propsSource && typeof propsSource === "object") for (const [key, value] of Object.entries(propsSource)) snapshot[key] = value;
|
|
4161
|
-
updateOwnerSnapshot(ownerId, snapshot, runtime.proxy);
|
|
4162
|
-
}
|
|
4163
|
-
|
|
4164
|
-
//#endregion
|
|
4165
|
-
//#region src/runtime/register/component/props.ts
|
|
4166
|
-
function createPropsSync(options) {
|
|
4167
|
-
const { restOptions, userObservers } = options;
|
|
4168
|
-
const PENDING_PROP_VALUES_KEY = "__wevuPendingPropValues";
|
|
4169
|
-
const propKeys = restOptions.properties && typeof restOptions.properties === "object" ? Object.keys(restOptions.properties) : [];
|
|
4170
|
-
const propKeySet = new Set(propKeys);
|
|
4171
|
-
const attachWevuPropKeys = (instance) => {
|
|
4172
|
-
try {
|
|
4173
|
-
Object.defineProperty(instance, "__wevuPropKeys", {
|
|
4174
|
-
value: propKeys,
|
|
4175
|
-
configurable: true,
|
|
4176
|
-
enumerable: false,
|
|
4177
|
-
writable: false
|
|
4178
|
-
});
|
|
4179
|
-
} catch (_unused) {
|
|
4180
|
-
instance.__wevuPropKeys = propKeys;
|
|
4181
|
-
}
|
|
4182
|
-
};
|
|
4183
|
-
const syncWevuAttrsFromInstance = (instance) => {
|
|
4184
|
-
const attrsProxy = instance.__wevuAttrs;
|
|
4185
|
-
if (!attrsProxy || typeof attrsProxy !== "object") return;
|
|
4186
|
-
const hasRuntimeStateKey = (key) => {
|
|
4187
|
-
var _wevu;
|
|
4188
|
-
const runtimeState = (_wevu = instance.__wevu) === null || _wevu === void 0 ? void 0 : _wevu.state;
|
|
4189
|
-
return runtimeState != null && typeof runtimeState === "object" && Object.prototype.hasOwnProperty.call(runtimeState, key);
|
|
4190
|
-
};
|
|
4191
|
-
const properties = instance.properties;
|
|
4192
|
-
const next = properties && typeof properties === "object" ? properties : void 0;
|
|
4193
|
-
const currentKeys = Object.keys(attrsProxy);
|
|
4194
|
-
for (const existingKey of currentKeys) if (!next || !Object.prototype.hasOwnProperty.call(next, existingKey) || propKeySet.has(existingKey) || hasRuntimeStateKey(existingKey)) try {
|
|
4195
|
-
delete attrsProxy[existingKey];
|
|
4196
|
-
} catch (_unused2) {}
|
|
4197
|
-
if (!next) {
|
|
4198
|
-
refreshOwnerSnapshotFromInstance(instance);
|
|
4199
|
-
return;
|
|
4200
|
-
}
|
|
4201
|
-
for (const [key, value] of Object.entries(next)) {
|
|
4202
|
-
if (propKeySet.has(key) || hasRuntimeStateKey(key)) continue;
|
|
4203
|
-
try {
|
|
4204
|
-
attrsProxy[key] = value;
|
|
4205
|
-
} catch (_unused3) {}
|
|
4206
|
-
}
|
|
4207
|
-
refreshOwnerSnapshotFromInstance(instance);
|
|
4208
|
-
};
|
|
4209
|
-
const syncWevuPropsFromInstance = (instance) => {
|
|
4210
|
-
const propsProxy = instance.__wevuProps;
|
|
4211
|
-
const properties = instance.properties;
|
|
4212
|
-
const pendingPropValues = instance[PENDING_PROP_VALUES_KEY];
|
|
4213
|
-
if (propsProxy && typeof propsProxy === "object" && properties && typeof properties === "object") {
|
|
4214
|
-
const next = properties;
|
|
4215
|
-
const currentKeys = Object.keys(propsProxy);
|
|
4216
|
-
for (const existingKey of currentKeys) if (!Object.prototype.hasOwnProperty.call(next, existingKey)) try {
|
|
4217
|
-
delete propsProxy[existingKey];
|
|
4218
|
-
} catch (_unused4) {}
|
|
4219
|
-
for (const [k, v] of Object.entries(next)) {
|
|
4220
|
-
const nextValue = pendingPropValues && Object.prototype.hasOwnProperty.call(pendingPropValues, k) ? pendingPropValues[k] : v;
|
|
4221
|
-
try {
|
|
4222
|
-
propsProxy[k] = nextValue;
|
|
4223
|
-
} catch (_unused5) {}
|
|
4224
|
-
}
|
|
4225
|
-
if (pendingPropValues) {
|
|
4226
|
-
for (const [k, v] of Object.entries(pendingPropValues)) if (!Object.prototype.hasOwnProperty.call(next, k)) try {
|
|
4227
|
-
propsProxy[k] = v;
|
|
4228
|
-
} catch (_unused6) {}
|
|
4229
|
-
}
|
|
4230
|
-
refreshOwnerSnapshotFromInstance(instance);
|
|
4231
|
-
}
|
|
4232
|
-
if (pendingPropValues) delete instance[PENDING_PROP_VALUES_KEY];
|
|
4233
|
-
syncWevuAttrsFromInstance(instance);
|
|
4234
|
-
};
|
|
4235
|
-
const syncWevuPropValue = (instance, key, value) => {
|
|
4236
|
-
var _ref, _ref$PENDING_PROP_VAL;
|
|
4237
|
-
const propsProxy = instance.__wevuProps;
|
|
4238
|
-
if (!propsProxy || typeof propsProxy !== "object") return;
|
|
4239
|
-
try {
|
|
4240
|
-
propsProxy[key] = value;
|
|
4241
|
-
} catch (_unused7) {}
|
|
4242
|
-
const pendingPropValues = (_ref$PENDING_PROP_VAL = (_ref = instance)[PENDING_PROP_VALUES_KEY]) !== null && _ref$PENDING_PROP_VAL !== void 0 ? _ref$PENDING_PROP_VAL : _ref[PENDING_PROP_VALUES_KEY] = Object.create(null);
|
|
4243
|
-
pendingPropValues[key] = value;
|
|
4244
|
-
refreshOwnerSnapshotFromInstance(instance);
|
|
4245
|
-
syncWevuAttrsFromInstance(instance);
|
|
4246
|
-
};
|
|
4247
|
-
const injectedObservers = {};
|
|
4248
|
-
if (propKeys.length) for (const key of propKeys) injectedObservers[key] = function __wevu_prop_observer(newValue) {
|
|
4249
|
-
syncWevuPropValue(this, key, newValue);
|
|
4250
|
-
};
|
|
4251
|
-
const finalObservers = { ...userObservers !== null && userObservers !== void 0 ? userObservers : {} };
|
|
4252
|
-
for (const [key, injected] of Object.entries(injectedObservers)) {
|
|
4253
|
-
const existing = finalObservers[key];
|
|
4254
|
-
if (typeof existing === "function") finalObservers[key] = function chainedObserver(...args) {
|
|
4255
|
-
existing.apply(this, args);
|
|
4256
|
-
injected.apply(this, args);
|
|
4257
|
-
};
|
|
4258
|
-
else finalObservers[key] = injected;
|
|
4259
|
-
}
|
|
4260
|
-
const allObserver = finalObservers["**"];
|
|
4261
|
-
finalObservers["**"] = function __wevu_observer_all(...args) {
|
|
4262
|
-
if (typeof allObserver === "function") allObserver.apply(this, args);
|
|
4263
|
-
syncWevuPropsFromInstance(this);
|
|
4264
|
-
};
|
|
4265
|
-
return {
|
|
4266
|
-
attachWevuPropKeys,
|
|
4267
|
-
syncWevuPropsFromInstance,
|
|
4268
|
-
finalObservers
|
|
4269
|
-
};
|
|
4270
|
-
}
|
|
4271
|
-
|
|
4272
|
-
//#endregion
|
|
4273
|
-
//#region src/runtime/register/component.ts
|
|
4274
|
-
/**
|
|
4275
|
-
* 注册组件入口(框架内部使用)。
|
|
4276
|
-
* @internal
|
|
4277
|
-
*/
|
|
4278
|
-
function registerComponent(runtimeApp, methods, watch, setup, mpOptions) {
|
|
4279
|
-
var _features, _multipleSlots;
|
|
4280
|
-
const cloneInstanceFieldValue = (value, cache = /* @__PURE__ */ new WeakMap()) => {
|
|
4281
|
-
if (!value || typeof value !== "object") return value;
|
|
4282
|
-
if (cache.has(value)) return cache.get(value);
|
|
4283
|
-
if (Array.isArray(value)) {
|
|
4284
|
-
const next = [];
|
|
4285
|
-
cache.set(value, next);
|
|
4286
|
-
for (const item of value) next.push(cloneInstanceFieldValue(item, cache));
|
|
4287
|
-
return next;
|
|
4288
|
-
}
|
|
4289
|
-
const next = {};
|
|
3425
|
+
//#region src/runtime/register/component/options.ts
|
|
3426
|
+
function cloneInstanceFieldValue(value, cache = /* @__PURE__ */ new WeakMap()) {
|
|
3427
|
+
if (!value || typeof value !== "object") return value;
|
|
3428
|
+
if (cache.has(value)) return cache.get(value);
|
|
3429
|
+
if (Array.isArray(value)) {
|
|
3430
|
+
const next = [];
|
|
4290
3431
|
cache.set(value, next);
|
|
4291
|
-
for (const
|
|
3432
|
+
for (const item of value) next.push(cloneInstanceFieldValue(item, cache));
|
|
4292
3433
|
return next;
|
|
4293
|
-
}
|
|
4294
|
-
const
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
3434
|
+
}
|
|
3435
|
+
const next = {};
|
|
3436
|
+
cache.set(value, next);
|
|
3437
|
+
for (const [key, child] of Object.entries(value)) next[key] = cloneInstanceFieldValue(child, cache);
|
|
3438
|
+
return next;
|
|
3439
|
+
}
|
|
3440
|
+
function getRuntimeOwnerLabel(instance) {
|
|
3441
|
+
const route = instance.route;
|
|
3442
|
+
if (typeof route === "string" && route) return route;
|
|
3443
|
+
const is = instance.is;
|
|
3444
|
+
if (typeof is === "string" && is) return is;
|
|
3445
|
+
return "unknown";
|
|
3446
|
+
}
|
|
3447
|
+
function prepareComponentOptions(mpOptions) {
|
|
3448
|
+
var _features;
|
|
4301
3449
|
const { methods: userMethods = {}, lifetimes: userLifetimes = {}, pageLifetimes: userPageLifetimes = {}, options: userOptions = {}, ...rest } = mpOptions;
|
|
4302
3450
|
const userOnLoad = rest.onLoad;
|
|
4303
3451
|
const userOnUnload = rest.onUnload;
|
|
@@ -4404,8 +3552,24 @@ function registerComponent(runtimeApp, methods, watch, setup, mpOptions) {
|
|
|
4404
3552
|
delete restOptions.onShow;
|
|
4405
3553
|
delete restOptions.onHide;
|
|
4406
3554
|
delete restOptions.onReady;
|
|
4407
|
-
|
|
3555
|
+
return {
|
|
3556
|
+
userMethods,
|
|
3557
|
+
userLifetimes,
|
|
3558
|
+
userPageLifetimes,
|
|
3559
|
+
userOptions,
|
|
3560
|
+
restOptions,
|
|
3561
|
+
topLevelMethods,
|
|
3562
|
+
templateRefs,
|
|
3563
|
+
userObservers,
|
|
3564
|
+
setupLifecycle,
|
|
3565
|
+
legacyCreated,
|
|
3566
|
+
isPage,
|
|
4408
3567
|
features,
|
|
3568
|
+
userOnLoad,
|
|
3569
|
+
userOnUnload,
|
|
3570
|
+
userOnShow,
|
|
3571
|
+
userOnHide,
|
|
3572
|
+
userOnReady,
|
|
4409
3573
|
userOnSaveExitState,
|
|
4410
3574
|
userOnPullDownRefresh,
|
|
4411
3575
|
userOnReachBottom,
|
|
@@ -4415,77 +3579,133 @@ function registerComponent(runtimeApp, methods, watch, setup, mpOptions) {
|
|
|
4415
3579
|
userOnResize,
|
|
4416
3580
|
userOnShareAppMessage,
|
|
4417
3581
|
userOnShareTimeline,
|
|
4418
|
-
userOnAddToFavorites
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
3582
|
+
userOnAddToFavorites,
|
|
3583
|
+
applyExtraInstanceFields
|
|
3584
|
+
};
|
|
3585
|
+
}
|
|
3586
|
+
//#endregion
|
|
3587
|
+
//#region src/runtime/register/snapshot.ts
|
|
3588
|
+
function refreshOwnerSnapshotFromInstance(instance) {
|
|
3589
|
+
var _wevuProps;
|
|
3590
|
+
const runtime = instance.__wevu;
|
|
3591
|
+
const ownerId = instance.__wvOwnerId;
|
|
3592
|
+
if (!runtime || !ownerId || typeof runtime.snapshot !== "function") return;
|
|
3593
|
+
const snapshot = runtime.snapshot();
|
|
3594
|
+
const propsSource = (_wevuProps = instance.__wevuProps) !== null && _wevuProps !== void 0 ? _wevuProps : instance.properties;
|
|
3595
|
+
if (propsSource && typeof propsSource === "object") for (const [key, value] of Object.entries(propsSource)) snapshot[key] = value;
|
|
3596
|
+
updateOwnerSnapshot(ownerId, snapshot, runtime.proxy);
|
|
3597
|
+
}
|
|
3598
|
+
//#endregion
|
|
3599
|
+
//#region src/runtime/register/component/props.ts
|
|
3600
|
+
function createPropsSync(options) {
|
|
3601
|
+
const { restOptions, userObservers } = options;
|
|
3602
|
+
const PENDING_PROP_VALUES_KEY = "__wevuPendingPropValues";
|
|
3603
|
+
const propKeys = restOptions.properties && typeof restOptions.properties === "object" ? Object.keys(restOptions.properties) : [];
|
|
3604
|
+
const propKeySet = new Set(propKeys);
|
|
3605
|
+
const attachWevuPropKeys = (instance) => {
|
|
3606
|
+
try {
|
|
3607
|
+
Object.defineProperty(instance, "__wevuPropKeys", {
|
|
3608
|
+
value: propKeys,
|
|
3609
|
+
configurable: true,
|
|
3610
|
+
enumerable: false,
|
|
3611
|
+
writable: false
|
|
3612
|
+
});
|
|
3613
|
+
} catch (_unused) {
|
|
3614
|
+
instance.__wevuPropKeys = propKeys;
|
|
3615
|
+
}
|
|
3616
|
+
};
|
|
3617
|
+
const syncWevuAttrsFromInstance = (instance) => {
|
|
3618
|
+
const attrsProxy = instance.__wevuAttrs;
|
|
3619
|
+
if (!attrsProxy || typeof attrsProxy !== "object") return;
|
|
3620
|
+
const hasRuntimeStateKey = (key) => {
|
|
3621
|
+
var _wevu;
|
|
3622
|
+
const runtimeState = (_wevu = instance.__wevu) === null || _wevu === void 0 ? void 0 : _wevu.state;
|
|
3623
|
+
return runtimeState != null && typeof runtimeState === "object" && Object.prototype.hasOwnProperty.call(runtimeState, key);
|
|
3624
|
+
};
|
|
3625
|
+
const properties = instance.properties;
|
|
3626
|
+
const next = properties && typeof properties === "object" ? properties : void 0;
|
|
3627
|
+
const currentKeys = Object.keys(attrsProxy);
|
|
3628
|
+
for (const existingKey of currentKeys) if (!next || !Object.prototype.hasOwnProperty.call(next, existingKey) || propKeySet.has(existingKey) || hasRuntimeStateKey(existingKey)) try {
|
|
3629
|
+
delete attrsProxy[existingKey];
|
|
3630
|
+
} catch (_unused2) {}
|
|
3631
|
+
if (!next) {
|
|
3632
|
+
refreshOwnerSnapshotFromInstance(instance);
|
|
3633
|
+
return;
|
|
3634
|
+
}
|
|
3635
|
+
for (const [key, value] of Object.entries(next)) {
|
|
3636
|
+
if (propKeySet.has(key) || hasRuntimeStateKey(key)) continue;
|
|
3637
|
+
try {
|
|
3638
|
+
attrsProxy[key] = value;
|
|
3639
|
+
} catch (_unused3) {}
|
|
3640
|
+
}
|
|
3641
|
+
refreshOwnerSnapshotFromInstance(instance);
|
|
3642
|
+
};
|
|
3643
|
+
const syncWevuPropsFromInstance = (instance) => {
|
|
3644
|
+
const propsProxy = instance.__wevuProps;
|
|
3645
|
+
const properties = instance.properties;
|
|
3646
|
+
const pendingPropValues = instance[PENDING_PROP_VALUES_KEY];
|
|
3647
|
+
if (propsProxy && typeof propsProxy === "object" && properties && typeof properties === "object") {
|
|
3648
|
+
const next = properties;
|
|
3649
|
+
const currentKeys = Object.keys(propsProxy);
|
|
3650
|
+
for (const existingKey of currentKeys) if (!Object.prototype.hasOwnProperty.call(next, existingKey)) try {
|
|
3651
|
+
delete propsProxy[existingKey];
|
|
3652
|
+
} catch (_unused4) {}
|
|
3653
|
+
for (const [k, v] of Object.entries(next)) {
|
|
3654
|
+
const nextValue = pendingPropValues && Object.prototype.hasOwnProperty.call(pendingPropValues, k) ? pendingPropValues[k] : v;
|
|
3655
|
+
try {
|
|
3656
|
+
propsProxy[k] = nextValue;
|
|
3657
|
+
} catch (_unused5) {}
|
|
3658
|
+
}
|
|
3659
|
+
if (pendingPropValues) {
|
|
3660
|
+
for (const [k, v] of Object.entries(pendingPropValues)) if (!Object.prototype.hasOwnProperty.call(next, k)) try {
|
|
3661
|
+
propsProxy[k] = v;
|
|
3662
|
+
} catch (_unused6) {}
|
|
3663
|
+
}
|
|
3664
|
+
refreshOwnerSnapshotFromInstance(instance);
|
|
3665
|
+
}
|
|
3666
|
+
if (pendingPropValues) delete instance[PENDING_PROP_VALUES_KEY];
|
|
3667
|
+
syncWevuAttrsFromInstance(instance);
|
|
3668
|
+
};
|
|
3669
|
+
const syncWevuPropValue = (instance, key, value) => {
|
|
3670
|
+
var _ref, _ref$PENDING_PROP_VAL;
|
|
3671
|
+
const propsProxy = instance.__wevuProps;
|
|
3672
|
+
if (!propsProxy || typeof propsProxy !== "object") return;
|
|
3673
|
+
try {
|
|
3674
|
+
propsProxy[key] = value;
|
|
3675
|
+
} catch (_unused7) {}
|
|
3676
|
+
const pendingPropValues = (_ref$PENDING_PROP_VAL = (_ref = instance)[PENDING_PROP_VALUES_KEY]) !== null && _ref$PENDING_PROP_VAL !== void 0 ? _ref$PENDING_PROP_VAL : _ref[PENDING_PROP_VALUES_KEY] = Object.create(null);
|
|
3677
|
+
pendingPropValues[key] = value;
|
|
3678
|
+
refreshOwnerSnapshotFromInstance(instance);
|
|
3679
|
+
syncWevuAttrsFromInstance(instance);
|
|
3680
|
+
};
|
|
3681
|
+
const injectedObservers = {};
|
|
3682
|
+
if (propKeys.length) for (const key of propKeys) injectedObservers[key] = function __wevu_prop_observer(newValue) {
|
|
3683
|
+
syncWevuPropValue(this, key, newValue);
|
|
4427
3684
|
};
|
|
4428
|
-
{
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
if (base && typeof base === "object" && !Array.isArray(base)) return {
|
|
4435
|
-
...exposed,
|
|
4436
|
-
...base
|
|
4437
|
-
};
|
|
4438
|
-
return base !== null && base !== void 0 ? base : exposed;
|
|
3685
|
+
const finalObservers = { ...userObservers !== null && userObservers !== void 0 ? userObservers : {} };
|
|
3686
|
+
for (const [key, injected] of Object.entries(injectedObservers)) {
|
|
3687
|
+
const existing = finalObservers[key];
|
|
3688
|
+
if (typeof existing === "function") finalObservers[key] = function chainedObserver(...args) {
|
|
3689
|
+
existing.apply(this, args);
|
|
3690
|
+
injected.apply(this, args);
|
|
4439
3691
|
};
|
|
3692
|
+
else finalObservers[key] = injected;
|
|
4440
3693
|
}
|
|
4441
|
-
const
|
|
4442
|
-
|
|
4443
|
-
|
|
3694
|
+
const allObserver = finalObservers["**"];
|
|
3695
|
+
finalObservers["**"] = function __wevu_observer_all(...args) {
|
|
3696
|
+
if (typeof allObserver === "function") allObserver.apply(this, args);
|
|
3697
|
+
syncWevuPropsFromInstance(this);
|
|
4444
3698
|
};
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
});
|
|
4456
|
-
const pageLifecycleHooks = createPageLifecycleHooks({
|
|
4457
|
-
runtimeApp,
|
|
4458
|
-
watch,
|
|
4459
|
-
setup,
|
|
4460
|
-
userOnLoad,
|
|
4461
|
-
userOnUnload,
|
|
4462
|
-
userOnShow,
|
|
4463
|
-
userOnHide,
|
|
4464
|
-
userOnReady,
|
|
4465
|
-
isPage,
|
|
4466
|
-
enableOnSaveExitState,
|
|
4467
|
-
enableOnPullDownRefresh,
|
|
4468
|
-
enableOnReachBottom,
|
|
4469
|
-
enableOnPageScroll,
|
|
4470
|
-
enableOnRouteDone,
|
|
4471
|
-
enableOnRouteDoneFallback,
|
|
4472
|
-
enableOnTabItemTap,
|
|
4473
|
-
enableOnResize,
|
|
4474
|
-
enableOnShareAppMessage,
|
|
4475
|
-
enableOnShareTimeline,
|
|
4476
|
-
enableOnAddToFavorites,
|
|
4477
|
-
effectiveOnSaveExitState,
|
|
4478
|
-
effectiveOnPullDownRefresh,
|
|
4479
|
-
effectiveOnReachBottom,
|
|
4480
|
-
effectiveOnPageScroll,
|
|
4481
|
-
effectiveOnRouteDone,
|
|
4482
|
-
effectiveOnTabItemTap,
|
|
4483
|
-
effectiveOnResize,
|
|
4484
|
-
effectiveOnShareAppMessage,
|
|
4485
|
-
effectiveOnShareTimeline,
|
|
4486
|
-
effectiveOnAddToFavorites,
|
|
4487
|
-
hasHook
|
|
4488
|
-
});
|
|
3699
|
+
return {
|
|
3700
|
+
attachWevuPropKeys,
|
|
3701
|
+
syncWevuPropsFromInstance,
|
|
3702
|
+
finalObservers
|
|
3703
|
+
};
|
|
3704
|
+
}
|
|
3705
|
+
//#endregion
|
|
3706
|
+
//#region src/runtime/register/component/registerDefinition.ts
|
|
3707
|
+
function registerComponentDefinition(options) {
|
|
3708
|
+
const { runtimeApp, watch, setup, restOptions, pageLifecycleHooks, finalObservers, userLifetimes, userPageLifetimes, finalMethods, finalOptions, applyExtraInstanceFields, templateRefs, attachWevuPropKeys, setupLifecycle, syncWevuPropsFromInstance, isPage, legacyCreated, getRuntimeOwnerLabel } = options;
|
|
4489
3709
|
const pageShareMethodBridges = {};
|
|
4490
3710
|
if (isPage) for (const hookName of [
|
|
4491
3711
|
"onShareAppMessage",
|
|
@@ -4591,6 +3811,7 @@ function registerComponent(runtimeApp, methods, watch, setup, mpOptions) {
|
|
|
4591
3811
|
if (typeof userPageLifetimes.show === "function") userPageLifetimes.show.apply(this, args);
|
|
4592
3812
|
return;
|
|
4593
3813
|
}
|
|
3814
|
+
setRuntimeSetDataVisibility(this, true);
|
|
4594
3815
|
callHookList(this, "onShow", args);
|
|
4595
3816
|
if (typeof userPageLifetimes.show === "function") userPageLifetimes.show.apply(this, args);
|
|
4596
3817
|
},
|
|
@@ -4600,6 +3821,7 @@ function registerComponent(runtimeApp, methods, watch, setup, mpOptions) {
|
|
|
4600
3821
|
if (typeof userPageLifetimes.hide === "function") userPageLifetimes.hide.apply(this, args);
|
|
4601
3822
|
return;
|
|
4602
3823
|
}
|
|
3824
|
+
setRuntimeSetDataVisibility(this, false);
|
|
4603
3825
|
callHookList(this, "onHide", args);
|
|
4604
3826
|
if (typeof userPageLifetimes.hide === "function") userPageLifetimes.hide.apply(this, args);
|
|
4605
3827
|
},
|
|
@@ -4629,168 +3851,133 @@ function registerComponent(runtimeApp, methods, watch, setup, mpOptions) {
|
|
|
4629
3851
|
options: finalOptions
|
|
4630
3852
|
});
|
|
4631
3853
|
}
|
|
4632
|
-
|
|
4633
3854
|
//#endregion
|
|
4634
|
-
//#region src/runtime/
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
3855
|
+
//#region src/runtime/register/component.ts
|
|
3856
|
+
/**
|
|
3857
|
+
* 注册组件入口(框架内部使用)。
|
|
3858
|
+
* @internal
|
|
3859
|
+
*/
|
|
3860
|
+
function registerComponent(runtimeApp, methods, watch, setup, mpOptions) {
|
|
3861
|
+
var _multipleSlots;
|
|
3862
|
+
const { userMethods, userLifetimes, userPageLifetimes, userOptions, restOptions, topLevelMethods, templateRefs, userObservers, setupLifecycle, legacyCreated, isPage, features, userOnLoad, userOnUnload, userOnShow, userOnHide, userOnReady, userOnSaveExitState, userOnPullDownRefresh, userOnReachBottom, userOnPageScroll, userOnRouteDone, userOnTabItemTap, userOnResize, userOnShareAppMessage, userOnShareTimeline, userOnAddToFavorites, applyExtraInstanceFields } = prepareComponentOptions(mpOptions);
|
|
3863
|
+
const { enableOnPullDownRefresh, enableOnReachBottom, enableOnPageScroll, enableOnRouteDone, enableOnRouteDoneFallback, enableOnTabItemTap, enableOnResize, enableOnShareAppMessage, enableOnShareTimeline, enableOnAddToFavorites, enableOnSaveExitState, effectiveOnSaveExitState, effectiveOnPullDownRefresh, effectiveOnReachBottom, effectiveOnPageScroll, effectiveOnRouteDone, effectiveOnTabItemTap, effectiveOnResize, effectiveOnShareAppMessage, effectiveOnShareTimeline, effectiveOnAddToFavorites } = resolveComponentFeatures({
|
|
3864
|
+
features,
|
|
3865
|
+
userOnSaveExitState,
|
|
3866
|
+
userOnPullDownRefresh,
|
|
3867
|
+
userOnReachBottom,
|
|
3868
|
+
userOnPageScroll,
|
|
3869
|
+
userOnRouteDone,
|
|
3870
|
+
userOnTabItemTap,
|
|
3871
|
+
userOnResize,
|
|
3872
|
+
userOnShareAppMessage,
|
|
3873
|
+
userOnShareTimeline,
|
|
3874
|
+
userOnAddToFavorites
|
|
4638
3875
|
});
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
3876
|
+
const hasHook = (target, name) => {
|
|
3877
|
+
const hooks = target.__wevuHooks;
|
|
3878
|
+
if (!hooks) return false;
|
|
3879
|
+
const entry = hooks[name];
|
|
3880
|
+
if (!entry) return false;
|
|
3881
|
+
if (Array.isArray(entry)) return entry.length > 0;
|
|
3882
|
+
return typeof entry === "function";
|
|
4643
3883
|
};
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
3884
|
+
{
|
|
3885
|
+
const userExport = restOptions.export;
|
|
3886
|
+
restOptions.export = function __wevu_export() {
|
|
3887
|
+
var _wevuExposed;
|
|
3888
|
+
const exposed = (_wevuExposed = this.__wevuExposed) !== null && _wevuExposed !== void 0 ? _wevuExposed : {};
|
|
3889
|
+
const base = typeof userExport === "function" ? userExport.call(this) : {};
|
|
3890
|
+
if (base && typeof base === "object" && !Array.isArray(base)) return {
|
|
3891
|
+
...exposed,
|
|
3892
|
+
...base
|
|
3893
|
+
};
|
|
3894
|
+
return base !== null && base !== void 0 ? base : exposed;
|
|
3895
|
+
};
|
|
3896
|
+
}
|
|
3897
|
+
const finalOptions = {
|
|
3898
|
+
multipleSlots: (_multipleSlots = userOptions.multipleSlots) !== null && _multipleSlots !== void 0 ? _multipleSlots : true,
|
|
3899
|
+
...userOptions
|
|
4647
3900
|
};
|
|
4648
|
-
|
|
3901
|
+
const { attachWevuPropKeys, syncWevuPropsFromInstance, finalObservers } = createPropsSync({
|
|
3902
|
+
restOptions,
|
|
3903
|
+
userObservers
|
|
3904
|
+
});
|
|
3905
|
+
const { finalMethods } = createComponentMethods({
|
|
3906
|
+
userMethods: {
|
|
3907
|
+
...topLevelMethods,
|
|
3908
|
+
...userMethods
|
|
3909
|
+
},
|
|
3910
|
+
runtimeMethods: methods
|
|
3911
|
+
});
|
|
3912
|
+
registerComponentDefinition({
|
|
3913
|
+
runtimeApp,
|
|
3914
|
+
watch,
|
|
3915
|
+
setup,
|
|
3916
|
+
restOptions,
|
|
3917
|
+
pageLifecycleHooks: createPageLifecycleHooks({
|
|
3918
|
+
runtimeApp,
|
|
3919
|
+
watch,
|
|
3920
|
+
setup,
|
|
3921
|
+
userOnLoad,
|
|
3922
|
+
userOnUnload,
|
|
3923
|
+
userOnShow,
|
|
3924
|
+
userOnHide,
|
|
3925
|
+
userOnReady,
|
|
3926
|
+
isPage,
|
|
3927
|
+
enableOnSaveExitState,
|
|
3928
|
+
enableOnPullDownRefresh,
|
|
3929
|
+
enableOnReachBottom,
|
|
3930
|
+
enableOnPageScroll,
|
|
3931
|
+
enableOnRouteDone,
|
|
3932
|
+
enableOnRouteDoneFallback,
|
|
3933
|
+
enableOnTabItemTap,
|
|
3934
|
+
enableOnResize,
|
|
3935
|
+
enableOnShareAppMessage,
|
|
3936
|
+
enableOnShareTimeline,
|
|
3937
|
+
enableOnAddToFavorites,
|
|
3938
|
+
effectiveOnSaveExitState,
|
|
3939
|
+
effectiveOnPullDownRefresh,
|
|
3940
|
+
effectiveOnReachBottom,
|
|
3941
|
+
effectiveOnPageScroll,
|
|
3942
|
+
effectiveOnRouteDone,
|
|
3943
|
+
effectiveOnTabItemTap,
|
|
3944
|
+
effectiveOnResize,
|
|
3945
|
+
effectiveOnShareAppMessage,
|
|
3946
|
+
effectiveOnShareTimeline,
|
|
3947
|
+
effectiveOnAddToFavorites,
|
|
3948
|
+
hasHook
|
|
3949
|
+
}),
|
|
3950
|
+
finalObservers,
|
|
3951
|
+
userLifetimes,
|
|
3952
|
+
userPageLifetimes,
|
|
3953
|
+
finalMethods,
|
|
3954
|
+
finalOptions,
|
|
3955
|
+
applyExtraInstanceFields,
|
|
3956
|
+
templateRefs,
|
|
3957
|
+
attachWevuPropKeys,
|
|
3958
|
+
setupLifecycle,
|
|
3959
|
+
syncWevuPropsFromInstance,
|
|
3960
|
+
isPage,
|
|
3961
|
+
legacyCreated,
|
|
3962
|
+
getRuntimeOwnerLabel
|
|
3963
|
+
});
|
|
4649
3964
|
}
|
|
3965
|
+
//#endregion
|
|
3966
|
+
//#region src/runtime/app.ts
|
|
4650
3967
|
function createApp(options) {
|
|
4651
|
-
const { [INTERNAL_DEFAULTS_SCOPE_KEY]: _ignoredDefaultsScope, data, computed: computedOptions, methods, setData: setDataOptions, watch: appWatch, setup: appSetup, ...mpOptions } = options[
|
|
3968
|
+
const { [INTERNAL_DEFAULTS_SCOPE_KEY]: _ignoredDefaultsScope, data, computed: computedOptions, methods, setData: setDataOptions, watch: appWatch, setup: appSetup, ...mpOptions } = options["__wevuDefaultsScope"] === "component" ? options : applyWevuAppDefaults(options);
|
|
4652
3969
|
const resolvedMethods = methods !== null && methods !== void 0 ? methods : {};
|
|
4653
3970
|
const resolvedComputed = computedOptions !== null && computedOptions !== void 0 ? computedOptions : {};
|
|
4654
3971
|
const installedPlugins = /* @__PURE__ */ new Set();
|
|
4655
3972
|
const appConfig = { globalProperties: {} };
|
|
4656
3973
|
const runtimeApp = {
|
|
4657
|
-
mount(
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
writable: false
|
|
4665
|
-
});
|
|
4666
|
-
} catch (_unused) {}
|
|
4667
|
-
const state = reactive(rawState);
|
|
4668
|
-
const computedDefs = resolvedComputed;
|
|
4669
|
-
const methodDefs = resolvedMethods;
|
|
4670
|
-
let mounted = true;
|
|
4671
|
-
const stopHandles = [];
|
|
4672
|
-
const { includeComputed, setDataStrategy, maxPatchKeys, maxPayloadBytes, mergeSiblingThreshold, mergeSiblingMaxInflationRatio, mergeSiblingMaxParentBytes, mergeSiblingSkipArray, computedCompare, computedCompareMaxDepth, computedCompareMaxKeys, prelinkMaxDepth, prelinkMaxKeys, debug, debugWhen, debugSampleRate, elevateTopKeyThreshold, toPlainMaxDepth, toPlainMaxKeys, shouldIncludeKey } = resolveSetDataOptions(setDataOptions);
|
|
4673
|
-
const { boundMethods, computedRefs, computedSetters, dirtyComputedKeys, computedProxy, publicInstance, touchSetupMethodsVersion } = createRuntimeContext({
|
|
4674
|
-
state,
|
|
4675
|
-
computedDefs,
|
|
4676
|
-
methodDefs,
|
|
4677
|
-
appConfig,
|
|
4678
|
-
includeComputed,
|
|
4679
|
-
setDataStrategy
|
|
4680
|
-
});
|
|
4681
|
-
const currentAdapter = adapter !== null && adapter !== void 0 ? adapter : { setData: () => {} };
|
|
4682
|
-
const stateRootRaw = toRaw(state);
|
|
4683
|
-
let tracker;
|
|
4684
|
-
const scheduler = createSetDataScheduler({
|
|
4685
|
-
state,
|
|
4686
|
-
computedRefs,
|
|
4687
|
-
dirtyComputedKeys,
|
|
4688
|
-
includeComputed,
|
|
4689
|
-
setDataStrategy,
|
|
4690
|
-
computedCompare,
|
|
4691
|
-
computedCompareMaxDepth,
|
|
4692
|
-
computedCompareMaxKeys,
|
|
4693
|
-
currentAdapter,
|
|
4694
|
-
shouldIncludeKey,
|
|
4695
|
-
maxPatchKeys,
|
|
4696
|
-
maxPayloadBytes,
|
|
4697
|
-
mergeSiblingThreshold,
|
|
4698
|
-
mergeSiblingMaxInflationRatio,
|
|
4699
|
-
mergeSiblingMaxParentBytes,
|
|
4700
|
-
mergeSiblingSkipArray,
|
|
4701
|
-
elevateTopKeyThreshold,
|
|
4702
|
-
toPlainMaxDepth,
|
|
4703
|
-
toPlainMaxKeys,
|
|
4704
|
-
debug,
|
|
4705
|
-
debugWhen,
|
|
4706
|
-
debugSampleRate,
|
|
4707
|
-
runTracker: () => tracker === null || tracker === void 0 ? void 0 : tracker(),
|
|
4708
|
-
isMounted: () => mounted
|
|
4709
|
-
});
|
|
4710
|
-
const job = () => scheduler.job(stateRootRaw);
|
|
4711
|
-
const mutationRecorder = (record) => scheduler.mutationRecorder(record, stateRootRaw);
|
|
4712
|
-
tracker = effect(() => {
|
|
4713
|
-
touchReactive(state);
|
|
4714
|
-
const runtimeProps = state.__wevuProps;
|
|
4715
|
-
if (isReactive(runtimeProps)) touchReactive(runtimeProps);
|
|
4716
|
-
const runtimeAttrs = state.__wevuAttrs;
|
|
4717
|
-
if (isReactive(runtimeAttrs)) touchReactive(runtimeAttrs);
|
|
4718
|
-
Object.keys(state).forEach((key) => {
|
|
4719
|
-
const v = state[key];
|
|
4720
|
-
if (isRef(v)) {
|
|
4721
|
-
const inner = v.value;
|
|
4722
|
-
if (isReactive(inner)) touchReactive(inner);
|
|
4723
|
-
} else if (isReactive(v)) touchReactive(v);
|
|
4724
|
-
});
|
|
4725
|
-
}, {
|
|
4726
|
-
lazy: true,
|
|
4727
|
-
scheduler: () => queueJob(job)
|
|
4728
|
-
});
|
|
4729
|
-
job();
|
|
4730
|
-
stopHandles.push(createWatchStopHandle(() => stop(tracker)));
|
|
4731
|
-
if (setDataStrategy === "patch") {
|
|
4732
|
-
prelinkReactiveTree(state, {
|
|
4733
|
-
shouldIncludeTopKey: shouldIncludeKey,
|
|
4734
|
-
maxDepth: prelinkMaxDepth,
|
|
4735
|
-
maxKeys: prelinkMaxKeys
|
|
4736
|
-
});
|
|
4737
|
-
addMutationRecorder(mutationRecorder);
|
|
4738
|
-
stopHandles.push(createWatchStopHandle(() => removeMutationRecorder(mutationRecorder)));
|
|
4739
|
-
stopHandles.push(createWatchStopHandle(() => clearPatchIndices(state)));
|
|
4740
|
-
}
|
|
4741
|
-
function registerWatch(source, cb, watchOptions) {
|
|
4742
|
-
const stopHandle = watch(source, (value, oldValue) => cb(value, oldValue), watchOptions);
|
|
4743
|
-
stopHandles.push(stopHandle);
|
|
4744
|
-
return createWatchStopHandle(() => {
|
|
4745
|
-
stopHandle();
|
|
4746
|
-
const index = stopHandles.indexOf(stopHandle);
|
|
4747
|
-
if (index >= 0) stopHandles.splice(index, 1);
|
|
4748
|
-
}, stopHandle);
|
|
4749
|
-
}
|
|
4750
|
-
const bindModel = createBindModel(publicInstance, state, computedRefs, computedSetters);
|
|
4751
|
-
const unmount = () => {
|
|
4752
|
-
if (!mounted) return;
|
|
4753
|
-
mounted = false;
|
|
4754
|
-
stopHandles.forEach((handle) => {
|
|
4755
|
-
try {
|
|
4756
|
-
handle();
|
|
4757
|
-
} catch (_unused2) {}
|
|
4758
|
-
});
|
|
4759
|
-
stopHandles.length = 0;
|
|
4760
|
-
};
|
|
4761
|
-
const runtimeInstance = {
|
|
4762
|
-
get state() {
|
|
4763
|
-
return state;
|
|
4764
|
-
},
|
|
4765
|
-
get proxy() {
|
|
4766
|
-
return publicInstance;
|
|
4767
|
-
},
|
|
4768
|
-
get methods() {
|
|
4769
|
-
return boundMethods;
|
|
4770
|
-
},
|
|
4771
|
-
get computed() {
|
|
4772
|
-
return computedProxy;
|
|
4773
|
-
},
|
|
4774
|
-
get adapter() {
|
|
4775
|
-
return currentAdapter;
|
|
4776
|
-
},
|
|
4777
|
-
bindModel,
|
|
4778
|
-
watch: registerWatch,
|
|
4779
|
-
snapshot: () => scheduler.snapshot(),
|
|
4780
|
-
unmount
|
|
4781
|
-
};
|
|
4782
|
-
try {
|
|
4783
|
-
Object.defineProperty(runtimeInstance, "__wevu_touchSetupMethodsVersion", {
|
|
4784
|
-
value: touchSetupMethodsVersion,
|
|
4785
|
-
configurable: true,
|
|
4786
|
-
enumerable: false,
|
|
4787
|
-
writable: false
|
|
4788
|
-
});
|
|
4789
|
-
} catch (_unused3) {
|
|
4790
|
-
runtimeInstance.__wevu_touchSetupMethodsVersion = touchSetupMethodsVersion;
|
|
4791
|
-
}
|
|
4792
|
-
return runtimeInstance;
|
|
4793
|
-
},
|
|
3974
|
+
mount: createRuntimeMount({
|
|
3975
|
+
data,
|
|
3976
|
+
resolvedComputed,
|
|
3977
|
+
resolvedMethods,
|
|
3978
|
+
appConfig,
|
|
3979
|
+
setDataOptions
|
|
3980
|
+
}),
|
|
4794
3981
|
use(plugin, ...options) {
|
|
4795
3982
|
if (!plugin || installedPlugins.has(plugin)) return runtimeApp;
|
|
4796
3983
|
installedPlugins.add(plugin);
|
|
@@ -4801,7 +3988,18 @@ function createApp(options) {
|
|
|
4801
3988
|
},
|
|
4802
3989
|
config: appConfig
|
|
4803
3990
|
};
|
|
4804
|
-
|
|
3991
|
+
const hasGlobalApp = typeof App === "function";
|
|
3992
|
+
try {
|
|
3993
|
+
Object.defineProperty(runtimeApp, "__wevuSetDataOptions", {
|
|
3994
|
+
value: setDataOptions,
|
|
3995
|
+
configurable: true,
|
|
3996
|
+
enumerable: false,
|
|
3997
|
+
writable: false
|
|
3998
|
+
});
|
|
3999
|
+
} catch (_unused) {
|
|
4000
|
+
runtimeApp.__wevuSetDataOptions = setDataOptions;
|
|
4001
|
+
}
|
|
4002
|
+
if (hasGlobalApp) {
|
|
4805
4003
|
const globalObject = getMiniProgramGlobalObject();
|
|
4806
4004
|
const hasWxConfig = typeof (globalObject === null || globalObject === void 0 ? void 0 : globalObject.__wxConfig) !== "undefined";
|
|
4807
4005
|
const appRegisterKey = "__wevuAppRegistered";
|
|
@@ -4812,9 +4010,50 @@ function createApp(options) {
|
|
|
4812
4010
|
}
|
|
4813
4011
|
return runtimeApp;
|
|
4814
4012
|
}
|
|
4815
|
-
|
|
4816
4013
|
//#endregion
|
|
4817
4014
|
//#region src/runtime/define/props.ts
|
|
4015
|
+
const NATIVE_PROPERTY_TYPE_MAP = new Map([
|
|
4016
|
+
[String, String],
|
|
4017
|
+
[Number, Number],
|
|
4018
|
+
[Boolean, Boolean],
|
|
4019
|
+
[Object, Object],
|
|
4020
|
+
[Array, Array],
|
|
4021
|
+
["String", String],
|
|
4022
|
+
["Number", Number],
|
|
4023
|
+
["Boolean", Boolean],
|
|
4024
|
+
["Object", Object],
|
|
4025
|
+
["Array", Array],
|
|
4026
|
+
[null, null],
|
|
4027
|
+
["null", null],
|
|
4028
|
+
["Null", null]
|
|
4029
|
+
]);
|
|
4030
|
+
function toNativePropertyType(candidate) {
|
|
4031
|
+
return NATIVE_PROPERTY_TYPE_MAP.get(candidate);
|
|
4032
|
+
}
|
|
4033
|
+
function normalizeTypeCandidates(raw) {
|
|
4034
|
+
if (raw === void 0) return [];
|
|
4035
|
+
const source = Array.isArray(raw) ? raw : [raw];
|
|
4036
|
+
const normalized = [];
|
|
4037
|
+
source.forEach((item) => {
|
|
4038
|
+
const mapped = toNativePropertyType(item);
|
|
4039
|
+
if (mapped === void 0) return;
|
|
4040
|
+
if (!normalized.includes(mapped)) normalized.push(mapped);
|
|
4041
|
+
});
|
|
4042
|
+
const requiredNativeTypes = normalized.filter((item) => item !== null);
|
|
4043
|
+
if (requiredNativeTypes.length > 0) return requiredNativeTypes;
|
|
4044
|
+
if (normalized.includes(null)) return [null];
|
|
4045
|
+
return [null];
|
|
4046
|
+
}
|
|
4047
|
+
function applyTypeOptions(target, rawType) {
|
|
4048
|
+
const candidates = normalizeTypeCandidates(rawType);
|
|
4049
|
+
if (candidates.length === 0) return;
|
|
4050
|
+
target.type = candidates[0];
|
|
4051
|
+
if (candidates.length > 1) {
|
|
4052
|
+
const optionalTypes = [];
|
|
4053
|
+
for (const candidate of candidates.slice(1)) if (!optionalTypes.includes(candidate)) optionalTypes.push(candidate);
|
|
4054
|
+
if (optionalTypes.length > 0) target.optionalTypes = optionalTypes;
|
|
4055
|
+
}
|
|
4056
|
+
}
|
|
4818
4057
|
function normalizeProps(baseOptions, props, explicitProperties) {
|
|
4819
4058
|
const baseProperties = baseOptions.properties;
|
|
4820
4059
|
const resolvedExplicit = explicitProperties !== null && explicitProperties !== void 0 ? explicitProperties : baseProperties && typeof baseProperties === "object" ? baseProperties : void 0;
|
|
@@ -4839,9 +4078,16 @@ function normalizeProps(baseOptions, props, explicitProperties) {
|
|
|
4839
4078
|
}
|
|
4840
4079
|
const properties = {};
|
|
4841
4080
|
Object.entries(props).forEach(([key, definition]) => {
|
|
4842
|
-
if (definition ===
|
|
4081
|
+
if (definition === void 0) return;
|
|
4082
|
+
if (definition === null) {
|
|
4083
|
+
properties[key] = { type: null };
|
|
4084
|
+
return;
|
|
4085
|
+
}
|
|
4843
4086
|
if (Array.isArray(definition) || typeof definition === "function") {
|
|
4844
|
-
|
|
4087
|
+
const propOptions = {};
|
|
4088
|
+
applyTypeOptions(propOptions, definition);
|
|
4089
|
+
if (!Object.prototype.hasOwnProperty.call(propOptions, "type")) propOptions.type = null;
|
|
4090
|
+
properties[key] = propOptions;
|
|
4845
4091
|
return;
|
|
4846
4092
|
}
|
|
4847
4093
|
if (typeof definition === "object") {
|
|
@@ -4853,9 +4099,22 @@ function normalizeProps(baseOptions, props, explicitProperties) {
|
|
|
4853
4099
|
return;
|
|
4854
4100
|
}
|
|
4855
4101
|
const propOptions = {};
|
|
4856
|
-
if ("type" in definition && definition.type !== void 0) propOptions
|
|
4102
|
+
if ("type" in definition && definition.type !== void 0) applyTypeOptions(propOptions, definition.type);
|
|
4103
|
+
if (Array.isArray(definition.optionalTypes)) {
|
|
4104
|
+
const optionalTypes = definition.optionalTypes.map((item) => toNativePropertyType(item)).filter((item) => item !== void 0 && item !== null);
|
|
4105
|
+
if (optionalTypes.length > 0) {
|
|
4106
|
+
const existingOptionalTypes = Array.isArray(propOptions.optionalTypes) ? propOptions.optionalTypes : [];
|
|
4107
|
+
for (const optionalType of optionalTypes) {
|
|
4108
|
+
if (optionalType === propOptions.type) continue;
|
|
4109
|
+
if (!existingOptionalTypes.includes(optionalType)) existingOptionalTypes.push(optionalType);
|
|
4110
|
+
}
|
|
4111
|
+
if (existingOptionalTypes.length > 0) propOptions.optionalTypes = existingOptionalTypes;
|
|
4112
|
+
}
|
|
4113
|
+
}
|
|
4114
|
+
if ("observer" in definition && (typeof definition.observer === "function" || typeof definition.observer === "string")) propOptions.observer = definition.observer;
|
|
4857
4115
|
const defaultValue = "default" in definition ? definition.default : definition.value;
|
|
4858
4116
|
if (defaultValue !== void 0) propOptions.value = typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
4117
|
+
if (!Object.prototype.hasOwnProperty.call(propOptions, "type")) propOptions.type = null;
|
|
4859
4118
|
properties[key] = propOptions;
|
|
4860
4119
|
}
|
|
4861
4120
|
});
|
|
@@ -4864,7 +4123,6 @@ function normalizeProps(baseOptions, props, explicitProperties) {
|
|
|
4864
4123
|
properties: attachInternalProps(properties)
|
|
4865
4124
|
};
|
|
4866
4125
|
}
|
|
4867
|
-
|
|
4868
4126
|
//#endregion
|
|
4869
4127
|
//#region src/runtime/define/scopedSlotOptions.ts
|
|
4870
4128
|
function decodeWxmlEntities(value) {
|
|
@@ -4978,10 +4236,9 @@ function createScopedSlotOptions(overrides) {
|
|
|
4978
4236
|
};
|
|
4979
4237
|
return baseOptions;
|
|
4980
4238
|
}
|
|
4981
|
-
|
|
4982
4239
|
//#endregion
|
|
4983
4240
|
//#region src/runtime/define/setupResult.ts
|
|
4984
|
-
function isPlainObject
|
|
4241
|
+
function isPlainObject(value) {
|
|
4985
4242
|
if (Object.prototype.toString.call(value) !== "[object Object]") return false;
|
|
4986
4243
|
const proto = Object.getPrototypeOf(value);
|
|
4987
4244
|
return proto === null || proto === Object.prototype;
|
|
@@ -4991,7 +4248,7 @@ function shouldExposeInSnapshot(value) {
|
|
|
4991
4248
|
if (typeof value !== "object") return true;
|
|
4992
4249
|
if (isRef(value) || isReactive(value)) return true;
|
|
4993
4250
|
if (Array.isArray(value)) return true;
|
|
4994
|
-
return isPlainObject
|
|
4251
|
+
return isPlainObject(value);
|
|
4995
4252
|
}
|
|
4996
4253
|
function applySetupResult(runtime, target, result) {
|
|
4997
4254
|
var _runtime$methods, _runtime$state;
|
|
@@ -5063,7 +4320,6 @@ function applySetupResult(runtime, target, result) {
|
|
|
5063
4320
|
}
|
|
5064
4321
|
}
|
|
5065
4322
|
}
|
|
5066
|
-
|
|
5067
4323
|
//#endregion
|
|
5068
4324
|
//#region src/runtime/define.ts
|
|
5069
4325
|
let scopedSlotCreator;
|
|
@@ -5098,33 +4354,250 @@ function defineComponent(options) {
|
|
|
5098
4354
|
setup: setupWrapper,
|
|
5099
4355
|
mpOptions: mpOptionsWithProps
|
|
5100
4356
|
};
|
|
5101
|
-
registerComponent(runtimeApp, methods !== null && methods !== void 0 ? methods : {}, watch, setupWrapper, mpOptionsWithProps);
|
|
4357
|
+
registerComponent(runtimeApp, methods !== null && methods !== void 0 ? methods : {}, watch, setupWrapper, mpOptionsWithProps);
|
|
4358
|
+
return {
|
|
4359
|
+
__wevu_runtime: runtimeApp,
|
|
4360
|
+
__wevu_options: componentOptions
|
|
4361
|
+
};
|
|
4362
|
+
}
|
|
4363
|
+
/**
|
|
4364
|
+
* 从 Vue SFC 选项创建 wevu 组件,供 weapp-vite 编译产物直接调用的兼容入口。
|
|
4365
|
+
*
|
|
4366
|
+
* @param options 组件选项,可能包含小程序特有的 properties
|
|
4367
|
+
* @internal
|
|
4368
|
+
*/
|
|
4369
|
+
function createWevuComponent(options) {
|
|
4370
|
+
ensureScopedSlotComponentGlobal();
|
|
4371
|
+
const { properties, props, ...restOptions } = options;
|
|
4372
|
+
defineComponent(normalizeProps(restOptions, props, properties));
|
|
4373
|
+
}
|
|
4374
|
+
/**
|
|
4375
|
+
* scoped slot 兼容组件入口(编译产物内部使用)。
|
|
4376
|
+
* @internal
|
|
4377
|
+
*/
|
|
4378
|
+
function createWevuScopedSlotComponent(overrides) {
|
|
4379
|
+
createWevuComponent(createScopedSlotOptions(overrides));
|
|
4380
|
+
}
|
|
4381
|
+
scopedSlotCreator = createWevuScopedSlotComponent;
|
|
4382
|
+
ensureScopedSlotComponentGlobal();
|
|
4383
|
+
//#endregion
|
|
4384
|
+
//#region src/runtime/disposables.ts
|
|
4385
|
+
const DISPOSABLE_METHODS = [
|
|
4386
|
+
"dispose",
|
|
4387
|
+
"abort",
|
|
4388
|
+
"cancel",
|
|
4389
|
+
"stop",
|
|
4390
|
+
"disconnect",
|
|
4391
|
+
"destroy",
|
|
4392
|
+
"close"
|
|
4393
|
+
];
|
|
4394
|
+
function resolveCleanup(target) {
|
|
4395
|
+
if (!target) return;
|
|
4396
|
+
if (typeof target === "function") return target;
|
|
4397
|
+
for (const methodName of DISPOSABLE_METHODS) {
|
|
4398
|
+
const candidate = target[methodName];
|
|
4399
|
+
if (typeof candidate === "function") return () => candidate.call(target);
|
|
4400
|
+
}
|
|
4401
|
+
}
|
|
4402
|
+
/**
|
|
4403
|
+
* 在 setup() 中创建一个“清理袋”,统一管理副作用释放。
|
|
4404
|
+
*
|
|
4405
|
+
* 典型用法:注册定时器、请求任务、事件监听退订函数,
|
|
4406
|
+
* 在页面/组件卸载时自动批量清理,减少内存泄漏风险。
|
|
4407
|
+
*/
|
|
4408
|
+
function useDisposables() {
|
|
4409
|
+
if (!getCurrentInstance()) throw new Error("useDisposables() 必须在 setup() 的同步阶段调用");
|
|
4410
|
+
const cleanupSet = /* @__PURE__ */ new Set();
|
|
4411
|
+
let disposed = false;
|
|
4412
|
+
const add = (target) => {
|
|
4413
|
+
const cleanup = resolveCleanup(target);
|
|
4414
|
+
if (!cleanup) return () => {};
|
|
4415
|
+
if (disposed) {
|
|
4416
|
+
try {
|
|
4417
|
+
cleanup();
|
|
4418
|
+
} catch (_unused) {}
|
|
4419
|
+
return () => {};
|
|
4420
|
+
}
|
|
4421
|
+
cleanupSet.add(cleanup);
|
|
4422
|
+
return () => {
|
|
4423
|
+
cleanupSet.delete(cleanup);
|
|
4424
|
+
};
|
|
4425
|
+
};
|
|
4426
|
+
const dispose = () => {
|
|
4427
|
+
if (disposed) return;
|
|
4428
|
+
disposed = true;
|
|
4429
|
+
const queue = Array.from(cleanupSet);
|
|
4430
|
+
cleanupSet.clear();
|
|
4431
|
+
for (const cleanup of queue) try {
|
|
4432
|
+
cleanup();
|
|
4433
|
+
} catch (_unused2) {}
|
|
4434
|
+
};
|
|
4435
|
+
const bagSetTimeout = (handler, timeout, ...args) => {
|
|
4436
|
+
const timer = setTimeout(handler, timeout, ...args);
|
|
4437
|
+
add(() => {
|
|
4438
|
+
clearTimeout(timer);
|
|
4439
|
+
});
|
|
4440
|
+
return timer;
|
|
4441
|
+
};
|
|
4442
|
+
const bagSetInterval = (handler, timeout, ...args) => {
|
|
4443
|
+
const timer = setInterval(handler, timeout, ...args);
|
|
4444
|
+
add(() => {
|
|
4445
|
+
clearInterval(timer);
|
|
4446
|
+
});
|
|
4447
|
+
return timer;
|
|
4448
|
+
};
|
|
4449
|
+
onUnload(dispose);
|
|
4450
|
+
onDetached(dispose);
|
|
5102
4451
|
return {
|
|
5103
|
-
|
|
5104
|
-
|
|
4452
|
+
add,
|
|
4453
|
+
dispose,
|
|
4454
|
+
setTimeout: bagSetTimeout,
|
|
4455
|
+
setInterval: bagSetInterval
|
|
5105
4456
|
};
|
|
5106
4457
|
}
|
|
4458
|
+
//#endregion
|
|
4459
|
+
//#region src/runtime/intersectionObserver.ts
|
|
4460
|
+
function createObserverFromInstance(instance, options) {
|
|
4461
|
+
const nativeInstance = instance;
|
|
4462
|
+
const creator = nativeInstance.createIntersectionObserver;
|
|
4463
|
+
if (typeof creator !== "function") return;
|
|
4464
|
+
return creator.call(nativeInstance, options);
|
|
4465
|
+
}
|
|
4466
|
+
function createObserverFromGlobal(instance, options) {
|
|
4467
|
+
const miniProgramGlobal = getMiniProgramGlobalObject();
|
|
4468
|
+
const creator = miniProgramGlobal === null || miniProgramGlobal === void 0 ? void 0 : miniProgramGlobal.createIntersectionObserver;
|
|
4469
|
+
if (typeof creator !== "function") return;
|
|
4470
|
+
return creator.call(miniProgramGlobal, instance, options);
|
|
4471
|
+
}
|
|
5107
4472
|
/**
|
|
5108
|
-
*
|
|
4473
|
+
* 在 setup 中创建 IntersectionObserver,并在卸载时自动断开。
|
|
5109
4474
|
*
|
|
5110
|
-
*
|
|
5111
|
-
*
|
|
4475
|
+
* - 优先使用 `ctx.instance.createIntersectionObserver(options)`。
|
|
4476
|
+
* - 不可用时回退到 `wx.createIntersectionObserver(instance, options)`。
|
|
5112
4477
|
*/
|
|
5113
|
-
function
|
|
5114
|
-
|
|
5115
|
-
const
|
|
5116
|
-
|
|
4478
|
+
function useIntersectionObserver(options = {}) {
|
|
4479
|
+
var _createObserverFromIn;
|
|
4480
|
+
const instance = getCurrentInstance();
|
|
4481
|
+
if (!instance) throw new Error("useIntersectionObserver() 必须在 setup() 的同步阶段调用");
|
|
4482
|
+
const observer = (_createObserverFromIn = createObserverFromInstance(instance, options)) !== null && _createObserverFromIn !== void 0 ? _createObserverFromIn : createObserverFromGlobal(instance, options);
|
|
4483
|
+
if (!observer || typeof observer.disconnect !== "function") throw new Error("当前运行环境不支持 IntersectionObserver,请检查基础库版本或平台能力");
|
|
4484
|
+
let disconnected = false;
|
|
4485
|
+
const disconnect = () => {
|
|
4486
|
+
if (disconnected) return;
|
|
4487
|
+
disconnected = true;
|
|
4488
|
+
try {
|
|
4489
|
+
observer.disconnect();
|
|
4490
|
+
} catch (_unused) {}
|
|
4491
|
+
};
|
|
4492
|
+
onUnload(disconnect);
|
|
4493
|
+
onDetached(disconnect);
|
|
4494
|
+
return observer;
|
|
4495
|
+
}
|
|
4496
|
+
//#endregion
|
|
4497
|
+
//#region src/runtime/pageScroll.ts
|
|
4498
|
+
function resolvePositiveInterval(interval) {
|
|
4499
|
+
if (typeof interval !== "number" || !Number.isFinite(interval)) return 80;
|
|
4500
|
+
return Math.max(0, interval);
|
|
4501
|
+
}
|
|
4502
|
+
function resolveMaxWait(maxWait) {
|
|
4503
|
+
if (typeof maxWait !== "number" || !Number.isFinite(maxWait)) return;
|
|
4504
|
+
return Math.max(0, maxWait);
|
|
5117
4505
|
}
|
|
5118
4506
|
/**
|
|
5119
|
-
*
|
|
5120
|
-
* @internal
|
|
4507
|
+
* 在 setup 中注册节流后的 onPageScroll 监听,并在卸载时自动清理。
|
|
5121
4508
|
*/
|
|
5122
|
-
function
|
|
5123
|
-
|
|
4509
|
+
function usePageScrollThrottle(handler, options = {}) {
|
|
4510
|
+
var _options$leading, _options$trailing;
|
|
4511
|
+
if (!getCurrentInstance()) throw new Error("usePageScrollThrottle() 必须在 setup() 的同步阶段调用");
|
|
4512
|
+
if (typeof handler !== "function") throw new TypeError("usePageScrollThrottle() 需要传入回调函数");
|
|
4513
|
+
const interval = resolvePositiveInterval(options.interval);
|
|
4514
|
+
const leading = (_options$leading = options.leading) !== null && _options$leading !== void 0 ? _options$leading : true;
|
|
4515
|
+
const trailing = (_options$trailing = options.trailing) !== null && _options$trailing !== void 0 ? _options$trailing : true;
|
|
4516
|
+
const maxWait = resolveMaxWait(options.maxWait);
|
|
4517
|
+
let trailingTimer;
|
|
4518
|
+
let maxWaitTimer;
|
|
4519
|
+
let stopped = false;
|
|
4520
|
+
let lastInvokeTime = 0;
|
|
4521
|
+
let trailingEvent;
|
|
4522
|
+
const clearTrailingTimer = () => {
|
|
4523
|
+
if (!trailingTimer) return;
|
|
4524
|
+
clearTimeout(trailingTimer);
|
|
4525
|
+
trailingTimer = void 0;
|
|
4526
|
+
};
|
|
4527
|
+
const clearMaxWaitTimer = () => {
|
|
4528
|
+
if (!maxWaitTimer) return;
|
|
4529
|
+
clearTimeout(maxWaitTimer);
|
|
4530
|
+
maxWaitTimer = void 0;
|
|
4531
|
+
};
|
|
4532
|
+
const invoke = (event) => {
|
|
4533
|
+
clearTrailingTimer();
|
|
4534
|
+
clearMaxWaitTimer();
|
|
4535
|
+
trailingEvent = void 0;
|
|
4536
|
+
lastInvokeTime = Date.now();
|
|
4537
|
+
handler(event);
|
|
4538
|
+
};
|
|
4539
|
+
const flushTrailing = () => {
|
|
4540
|
+
const event = trailingEvent;
|
|
4541
|
+
trailingEvent = void 0;
|
|
4542
|
+
trailingTimer = void 0;
|
|
4543
|
+
if (!event || stopped) return;
|
|
4544
|
+
invoke(event);
|
|
4545
|
+
};
|
|
4546
|
+
const flushMaxWait = () => {
|
|
4547
|
+
const event = trailingEvent;
|
|
4548
|
+
maxWaitTimer = void 0;
|
|
4549
|
+
if (!event || stopped) return;
|
|
4550
|
+
invoke(event);
|
|
4551
|
+
};
|
|
4552
|
+
const scheduleTrailing = (now) => {
|
|
4553
|
+
if (!trailing || trailingTimer) return;
|
|
4554
|
+
const base = lastInvokeTime === 0 ? now : lastInvokeTime;
|
|
4555
|
+
const remaining = Math.max(0, interval - (now - base));
|
|
4556
|
+
trailingTimer = setTimeout(flushTrailing, remaining);
|
|
4557
|
+
};
|
|
4558
|
+
const scheduleMaxWait = (now) => {
|
|
4559
|
+
if (typeof maxWait !== "number" || maxWaitTimer) return;
|
|
4560
|
+
const remaining = maxWait - (now - (lastInvokeTime === 0 ? now : lastInvokeTime));
|
|
4561
|
+
if (remaining <= 0) {
|
|
4562
|
+
flushMaxWait();
|
|
4563
|
+
return;
|
|
4564
|
+
}
|
|
4565
|
+
maxWaitTimer = setTimeout(flushMaxWait, remaining);
|
|
4566
|
+
};
|
|
4567
|
+
const register = (event) => {
|
|
4568
|
+
if (stopped) return;
|
|
4569
|
+
if (interval === 0) {
|
|
4570
|
+
invoke(event);
|
|
4571
|
+
return;
|
|
4572
|
+
}
|
|
4573
|
+
const now = Date.now();
|
|
4574
|
+
trailingEvent = event;
|
|
4575
|
+
if (leading && (lastInvokeTime === 0 || now - lastInvokeTime >= interval)) {
|
|
4576
|
+
invoke(event);
|
|
4577
|
+
return;
|
|
4578
|
+
}
|
|
4579
|
+
if (typeof maxWait === "number") {
|
|
4580
|
+
if (now - (lastInvokeTime === 0 ? now : lastInvokeTime) >= maxWait) {
|
|
4581
|
+
invoke(event);
|
|
4582
|
+
return;
|
|
4583
|
+
}
|
|
4584
|
+
}
|
|
4585
|
+
if (!trailing && typeof maxWait !== "number") return;
|
|
4586
|
+
scheduleTrailing(now);
|
|
4587
|
+
scheduleMaxWait(now);
|
|
4588
|
+
};
|
|
4589
|
+
onPageScroll(register);
|
|
4590
|
+
const stop = () => {
|
|
4591
|
+
if (stopped) return;
|
|
4592
|
+
stopped = true;
|
|
4593
|
+
trailingEvent = void 0;
|
|
4594
|
+
clearTrailingTimer();
|
|
4595
|
+
clearMaxWaitTimer();
|
|
4596
|
+
};
|
|
4597
|
+
onUnload(stop);
|
|
4598
|
+
onDetached(stop);
|
|
4599
|
+
return stop;
|
|
5124
4600
|
}
|
|
5125
|
-
scopedSlotCreator = createWevuScopedSlotComponent;
|
|
5126
|
-
ensureScopedSlotComponentGlobal();
|
|
5127
|
-
|
|
5128
4601
|
//#endregion
|
|
5129
4602
|
//#region src/runtime/provide.ts
|
|
5130
4603
|
const PROVIDE_SCOPE_KEY = Symbol("wevu.provideScope");
|
|
@@ -5206,7 +4679,6 @@ function injectGlobal(key, defaultValue) {
|
|
|
5206
4679
|
if (arguments.length >= 2) return defaultValue;
|
|
5207
4680
|
throw new Error(`injectGlobal():未找到对应 key 的 provider:${String(key)}`);
|
|
5208
4681
|
}
|
|
5209
|
-
|
|
5210
4682
|
//#endregion
|
|
5211
4683
|
//#region src/runtime/template.ts
|
|
5212
4684
|
const hyphenateRE = /\B([A-Z])/g;
|
|
@@ -5271,9 +4743,43 @@ function normalizeClass(value) {
|
|
|
5271
4743
|
}
|
|
5272
4744
|
return res;
|
|
5273
4745
|
}
|
|
5274
|
-
|
|
5275
4746
|
//#endregion
|
|
5276
|
-
//#region src/runtime/
|
|
4747
|
+
//#region src/runtime/updatePerformance.ts
|
|
4748
|
+
function resolveUpdatePerformanceSetter(instance) {
|
|
4749
|
+
const nativeInstance = instance;
|
|
4750
|
+
const candidate = nativeInstance.setUpdatePerformanceListener;
|
|
4751
|
+
if (typeof candidate !== "function") return;
|
|
4752
|
+
return (listener) => {
|
|
4753
|
+
candidate.call(nativeInstance, listener);
|
|
4754
|
+
};
|
|
4755
|
+
}
|
|
4756
|
+
/**
|
|
4757
|
+
* 在 setup 中注册更新性能监听,并在卸载时自动清理。
|
|
4758
|
+
*
|
|
4759
|
+
* - 底层能力:`instance.setUpdatePerformanceListener(listener)`。
|
|
4760
|
+
* - 清理策略:卸载时回传 `undefined` 作为监听器,平台不支持时静默降级。
|
|
4761
|
+
*/
|
|
4762
|
+
function useUpdatePerformanceListener(listener) {
|
|
4763
|
+
const instance = getCurrentInstance();
|
|
4764
|
+
if (!instance) throw new Error("useUpdatePerformanceListener() 必须在 setup() 的同步阶段调用");
|
|
4765
|
+
if (typeof listener !== "function") throw new TypeError("useUpdatePerformanceListener() 需要传入监听函数");
|
|
4766
|
+
const setListener = resolveUpdatePerformanceSetter(instance);
|
|
4767
|
+
if (!setListener) throw new Error("当前实例不支持 setUpdatePerformanceListener,请检查基础库版本或组件上下文");
|
|
4768
|
+
setListener(listener);
|
|
4769
|
+
let stopped = false;
|
|
4770
|
+
const stop = () => {
|
|
4771
|
+
if (stopped) return;
|
|
4772
|
+
stopped = true;
|
|
4773
|
+
try {
|
|
4774
|
+
setListener(void 0);
|
|
4775
|
+
} catch (_unused) {}
|
|
4776
|
+
};
|
|
4777
|
+
onUnload(stop);
|
|
4778
|
+
onDetached(stop);
|
|
4779
|
+
return stop;
|
|
4780
|
+
}
|
|
4781
|
+
//#endregion
|
|
4782
|
+
//#region src/runtime/vueCompat/context.ts
|
|
5277
4783
|
const EMPTY_SETUP_SLOTS = Object.freeze(Object.create(null));
|
|
5278
4784
|
function useAttrs() {
|
|
5279
4785
|
var _ctx$attrs;
|
|
@@ -5292,34 +4798,8 @@ function useNativeInstance() {
|
|
|
5292
4798
|
if (!(ctx === null || ctx === void 0 ? void 0 : ctx.instance)) throw new Error("useNativeInstance() 必须在 setup() 的同步阶段调用");
|
|
5293
4799
|
return ctx.instance;
|
|
5294
4800
|
}
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
if (existing) return existing;
|
|
5298
|
-
const next = /* @__PURE__ */ new Map();
|
|
5299
|
-
try {
|
|
5300
|
-
Object.defineProperty(target, "__wevuTemplateRefMap", {
|
|
5301
|
-
value: next,
|
|
5302
|
-
configurable: true,
|
|
5303
|
-
enumerable: false,
|
|
5304
|
-
writable: false
|
|
5305
|
-
});
|
|
5306
|
-
} catch (_unused) {
|
|
5307
|
-
target.__wevuTemplateRefMap = next;
|
|
5308
|
-
}
|
|
5309
|
-
return next;
|
|
5310
|
-
}
|
|
5311
|
-
function useTemplateRef(name) {
|
|
5312
|
-
const instance = getCurrentInstance();
|
|
5313
|
-
if (!instance) throw new Error("useTemplateRef() 必须在 setup() 的同步阶段调用");
|
|
5314
|
-
const normalized = typeof name === "string" ? name.trim() : "";
|
|
5315
|
-
if (!normalized) throw new Error("useTemplateRef() 需要传入有效的模板 ref 名称");
|
|
5316
|
-
const map = ensureTemplateRefMap(instance);
|
|
5317
|
-
const existing = map.get(normalized);
|
|
5318
|
-
if (existing) return existing;
|
|
5319
|
-
const target = shallowRef(null);
|
|
5320
|
-
map.set(normalized, target);
|
|
5321
|
-
return target;
|
|
5322
|
-
}
|
|
4801
|
+
//#endregion
|
|
4802
|
+
//#region src/runtime/vueCompat/model.ts
|
|
5323
4803
|
const EMPTY_MODEL_MODIFIERS = Object.freeze(Object.create(null));
|
|
5324
4804
|
function resolveModelModifiers(props, name) {
|
|
5325
4805
|
const key = name === "modelValue" ? "modelModifiers" : `${name}Modifiers`;
|
|
@@ -5356,7 +4836,7 @@ function attachModelTuple(model, getModifiers) {
|
|
|
5356
4836
|
} };
|
|
5357
4837
|
}
|
|
5358
4838
|
});
|
|
5359
|
-
} catch (
|
|
4839
|
+
} catch (_unused) {}
|
|
5360
4840
|
return tupleModel;
|
|
5361
4841
|
}
|
|
5362
4842
|
function useModel(props, name, options = {}) {
|
|
@@ -5419,466 +4899,35 @@ function mergeModels(a, b) {
|
|
|
5419
4899
|
};
|
|
5420
4900
|
return b;
|
|
5421
4901
|
}
|
|
5422
|
-
|
|
5423
|
-
//#endregion
|
|
5424
|
-
//#region src/store/actions.ts
|
|
5425
|
-
function wrapAction(store, name, action, actionSubs) {
|
|
5426
|
-
return function wrapped(...args) {
|
|
5427
|
-
const afterCbs = [];
|
|
5428
|
-
const errorCbs = [];
|
|
5429
|
-
const after = (cb) => afterCbs.push(cb);
|
|
5430
|
-
const onError = (cb) => errorCbs.push(cb);
|
|
5431
|
-
actionSubs.forEach((sub) => {
|
|
5432
|
-
try {
|
|
5433
|
-
sub({
|
|
5434
|
-
name,
|
|
5435
|
-
store,
|
|
5436
|
-
args,
|
|
5437
|
-
after,
|
|
5438
|
-
onError
|
|
5439
|
-
});
|
|
5440
|
-
} catch (_unused) {}
|
|
5441
|
-
});
|
|
5442
|
-
let res;
|
|
5443
|
-
try {
|
|
5444
|
-
res = action.apply(store, args);
|
|
5445
|
-
} catch (e) {
|
|
5446
|
-
errorCbs.forEach((cb) => cb(e));
|
|
5447
|
-
throw e;
|
|
5448
|
-
}
|
|
5449
|
-
const finalize = (r) => {
|
|
5450
|
-
afterCbs.forEach((cb) => cb(r));
|
|
5451
|
-
return r;
|
|
5452
|
-
};
|
|
5453
|
-
if (res && typeof res.then === "function") return res.then((r) => finalize(r), (e) => {
|
|
5454
|
-
errorCbs.forEach((cb) => cb(e));
|
|
5455
|
-
return Promise.reject(e);
|
|
5456
|
-
});
|
|
5457
|
-
return finalize(res);
|
|
5458
|
-
};
|
|
5459
|
-
}
|
|
5460
|
-
|
|
5461
4902
|
//#endregion
|
|
5462
|
-
//#region src/
|
|
5463
|
-
function
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
}
|
|
5474
|
-
function cloneDeep(value) {
|
|
5475
|
-
if (Array.isArray(value)) return value.map((item) => cloneDeep(item));
|
|
5476
|
-
if (isPlainObject(value)) {
|
|
5477
|
-
const result = {};
|
|
5478
|
-
for (const key in value) result[key] = cloneDeep(value[key]);
|
|
5479
|
-
return result;
|
|
5480
|
-
}
|
|
5481
|
-
return value;
|
|
5482
|
-
}
|
|
5483
|
-
function resetObject(target, snapshot) {
|
|
5484
|
-
if (Array.isArray(target) && Array.isArray(snapshot)) {
|
|
5485
|
-
target.length = 0;
|
|
5486
|
-
snapshot.forEach((item, index) => {
|
|
5487
|
-
target[index] = cloneDeep(item);
|
|
4903
|
+
//#region src/runtime/vueCompat/templateRef.ts
|
|
4904
|
+
function ensureTemplateRefMap(target) {
|
|
4905
|
+
const existing = target.__wevuTemplateRefMap;
|
|
4906
|
+
if (existing) return existing;
|
|
4907
|
+
const next = /* @__PURE__ */ new Map();
|
|
4908
|
+
try {
|
|
4909
|
+
Object.defineProperty(target, "__wevuTemplateRefMap", {
|
|
4910
|
+
value: next,
|
|
4911
|
+
configurable: true,
|
|
4912
|
+
enumerable: false,
|
|
4913
|
+
writable: false
|
|
5488
4914
|
});
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
if (!isObject(snapshot)) return;
|
|
5492
|
-
for (const key in target) if (!(key in snapshot)) delete target[key];
|
|
5493
|
-
for (const key in snapshot) {
|
|
5494
|
-
const snapValue = snapshot[key];
|
|
5495
|
-
const currentValue = target[key];
|
|
5496
|
-
if (Array.isArray(snapValue) && Array.isArray(currentValue)) {
|
|
5497
|
-
resetObject(currentValue, snapValue);
|
|
5498
|
-
continue;
|
|
5499
|
-
}
|
|
5500
|
-
if (isPlainObject(snapValue) && isPlainObject(currentValue)) {
|
|
5501
|
-
resetObject(currentValue, snapValue);
|
|
5502
|
-
continue;
|
|
5503
|
-
}
|
|
5504
|
-
target[key] = cloneDeep(snapValue);
|
|
4915
|
+
} catch (_unused) {
|
|
4916
|
+
target.__wevuTemplateRefMap = next;
|
|
5505
4917
|
}
|
|
4918
|
+
return next;
|
|
5506
4919
|
}
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
mergeShallow(stateObj, v);
|
|
5519
|
-
notify("patch object");
|
|
5520
|
-
}
|
|
5521
|
-
}
|
|
5522
|
-
});
|
|
5523
|
-
api.$patch = (patch) => {
|
|
5524
|
-
if (!stateObj) {
|
|
5525
|
-
if (typeof patch === "function") {
|
|
5526
|
-
patch(api);
|
|
5527
|
-
notify("patch function");
|
|
5528
|
-
} else {
|
|
5529
|
-
mergeShallow(api, patch);
|
|
5530
|
-
notify("patch object");
|
|
5531
|
-
}
|
|
5532
|
-
return;
|
|
5533
|
-
}
|
|
5534
|
-
if (typeof patch === "function") {
|
|
5535
|
-
patch(stateObj);
|
|
5536
|
-
notify("patch function");
|
|
5537
|
-
} else {
|
|
5538
|
-
mergeShallow(stateObj, patch);
|
|
5539
|
-
notify("patch object");
|
|
5540
|
-
}
|
|
5541
|
-
};
|
|
5542
|
-
if (resetImpl) api.$reset = () => resetImpl();
|
|
5543
|
-
const subs = /* @__PURE__ */ new Set();
|
|
5544
|
-
api.$subscribe = (cb, _opts) => {
|
|
5545
|
-
subs.add(cb);
|
|
5546
|
-
return () => subs.delete(cb);
|
|
5547
|
-
};
|
|
5548
|
-
const actionSubs = /* @__PURE__ */ new Set();
|
|
5549
|
-
api.$onAction = (cb) => {
|
|
5550
|
-
actionSubs.add(cb);
|
|
5551
|
-
return () => actionSubs.delete(cb);
|
|
5552
|
-
};
|
|
5553
|
-
return {
|
|
5554
|
-
api,
|
|
5555
|
-
subs,
|
|
5556
|
-
actionSubs
|
|
5557
|
-
};
|
|
5558
|
-
}
|
|
5559
|
-
|
|
5560
|
-
//#endregion
|
|
5561
|
-
//#region src/store/manager.ts
|
|
5562
|
-
/**
|
|
5563
|
-
* @description 创建 store 管理器(插件与共享实例入口)
|
|
5564
|
-
*/
|
|
5565
|
-
function createStore() {
|
|
5566
|
-
const manager = {
|
|
5567
|
-
_stores: /* @__PURE__ */ new Map(),
|
|
5568
|
-
_plugins: [],
|
|
5569
|
-
install(_app) {},
|
|
5570
|
-
use(plugin) {
|
|
5571
|
-
if (typeof plugin === "function") manager._plugins.push(plugin);
|
|
5572
|
-
return manager;
|
|
5573
|
-
}
|
|
5574
|
-
};
|
|
5575
|
-
createStore._instance = manager;
|
|
5576
|
-
return manager;
|
|
5577
|
-
}
|
|
5578
|
-
|
|
5579
|
-
//#endregion
|
|
5580
|
-
//#region src/store/define.ts
|
|
5581
|
-
const hasOwn = Object.prototype.hasOwnProperty;
|
|
5582
|
-
function isTrackableRef(value) {
|
|
5583
|
-
return isRef(value) && hasOwn.call(value, "dep");
|
|
5584
|
-
}
|
|
5585
|
-
function snapshotValue(value) {
|
|
5586
|
-
if (isReactive(value)) return cloneDeep(toRaw(value));
|
|
5587
|
-
if (isTrackableRef(value)) return cloneDeep(value.value);
|
|
5588
|
-
return cloneDeep(value);
|
|
5589
|
-
}
|
|
5590
|
-
function createSafeNotifier(storeId, subs, getState) {
|
|
5591
|
-
let notifying = false;
|
|
5592
|
-
return (type) => {
|
|
5593
|
-
if (notifying) return;
|
|
5594
|
-
notifying = true;
|
|
5595
|
-
try {
|
|
5596
|
-
const state = getState();
|
|
5597
|
-
subs.forEach((cb) => {
|
|
5598
|
-
try {
|
|
5599
|
-
cb({
|
|
5600
|
-
type,
|
|
5601
|
-
storeId
|
|
5602
|
-
}, state);
|
|
5603
|
-
} catch (_unused) {}
|
|
5604
|
-
});
|
|
5605
|
-
} finally {
|
|
5606
|
-
notifying = false;
|
|
5607
|
-
}
|
|
5608
|
-
};
|
|
5609
|
-
}
|
|
5610
|
-
function defineStore(id, setupOrOptions) {
|
|
5611
|
-
let instance;
|
|
5612
|
-
let created = false;
|
|
5613
|
-
const manager = createStore._instance;
|
|
5614
|
-
return function useStore() {
|
|
5615
|
-
var _options$getters, _options$actions, _manager$_plugins2;
|
|
5616
|
-
if (created && instance) return instance;
|
|
5617
|
-
created = true;
|
|
5618
|
-
if (typeof setupOrOptions === "function") {
|
|
5619
|
-
var _manager$_plugins;
|
|
5620
|
-
const result = setupOrOptions();
|
|
5621
|
-
let notify = () => {};
|
|
5622
|
-
const initialSnapshot = /* @__PURE__ */ new Map();
|
|
5623
|
-
Object.keys(result).forEach((k) => {
|
|
5624
|
-
const val = result[k];
|
|
5625
|
-
if (typeof val === "function" || k.startsWith("$")) return;
|
|
5626
|
-
if (isRef(val) && !isTrackableRef(val)) return;
|
|
5627
|
-
initialSnapshot.set(k, snapshotValue(val));
|
|
5628
|
-
});
|
|
5629
|
-
const resetImpl = () => {
|
|
5630
|
-
initialSnapshot.forEach((snapValue, key) => {
|
|
5631
|
-
const current = instance[key];
|
|
5632
|
-
if (isTrackableRef(current)) {
|
|
5633
|
-
current.value = cloneDeep(snapValue);
|
|
5634
|
-
return;
|
|
5635
|
-
}
|
|
5636
|
-
if (isReactive(current)) {
|
|
5637
|
-
resetObject(current, snapValue);
|
|
5638
|
-
return;
|
|
5639
|
-
}
|
|
5640
|
-
if (isRef(current)) return;
|
|
5641
|
-
instance[key] = cloneDeep(snapValue);
|
|
5642
|
-
});
|
|
5643
|
-
notify("patch object");
|
|
5644
|
-
};
|
|
5645
|
-
const base = createBaseApi(id, void 0, (t) => notify(t), resetImpl);
|
|
5646
|
-
let isPatching = false;
|
|
5647
|
-
const rawPatch = base.api.$patch;
|
|
5648
|
-
base.api.$patch = (patch) => {
|
|
5649
|
-
isPatching = true;
|
|
5650
|
-
try {
|
|
5651
|
-
rawPatch(patch);
|
|
5652
|
-
} finally {
|
|
5653
|
-
isPatching = false;
|
|
5654
|
-
}
|
|
5655
|
-
};
|
|
5656
|
-
if (typeof base.api.$reset === "function") {
|
|
5657
|
-
const rawReset = base.api.$reset;
|
|
5658
|
-
base.api.$reset = () => {
|
|
5659
|
-
isPatching = true;
|
|
5660
|
-
try {
|
|
5661
|
-
rawReset();
|
|
5662
|
-
} finally {
|
|
5663
|
-
isPatching = false;
|
|
5664
|
-
}
|
|
5665
|
-
};
|
|
5666
|
-
}
|
|
5667
|
-
notify = createSafeNotifier(id, base.subs, () => instance);
|
|
5668
|
-
instance = Object.assign({}, result);
|
|
5669
|
-
for (const key of Object.getOwnPropertyNames(base.api)) {
|
|
5670
|
-
const d = Object.getOwnPropertyDescriptor(base.api, key);
|
|
5671
|
-
if (d) if (key === "$state") Object.defineProperty(instance, key, {
|
|
5672
|
-
enumerable: d.enumerable,
|
|
5673
|
-
configurable: d.configurable,
|
|
5674
|
-
get() {
|
|
5675
|
-
return base.api.$state;
|
|
5676
|
-
},
|
|
5677
|
-
set(v) {
|
|
5678
|
-
isPatching = true;
|
|
5679
|
-
try {
|
|
5680
|
-
base.api.$state = v;
|
|
5681
|
-
} finally {
|
|
5682
|
-
isPatching = false;
|
|
5683
|
-
}
|
|
5684
|
-
}
|
|
5685
|
-
});
|
|
5686
|
-
else Object.defineProperty(instance, key, d);
|
|
5687
|
-
}
|
|
5688
|
-
const directSources = [];
|
|
5689
|
-
Object.keys(result).forEach((k) => {
|
|
5690
|
-
const val = result[k];
|
|
5691
|
-
if (typeof val === "function" && !k.startsWith("$")) {
|
|
5692
|
-
instance[k] = wrapAction(instance, k, val, base.actionSubs);
|
|
5693
|
-
return;
|
|
5694
|
-
}
|
|
5695
|
-
if (isTrackableRef(val)) {
|
|
5696
|
-
directSources.push(val);
|
|
5697
|
-
return;
|
|
5698
|
-
}
|
|
5699
|
-
if (isReactive(val)) {
|
|
5700
|
-
directSources.push(val);
|
|
5701
|
-
return;
|
|
5702
|
-
}
|
|
5703
|
-
if (isRef(val)) return;
|
|
5704
|
-
if (!k.startsWith("$")) {
|
|
5705
|
-
let innerValue = val;
|
|
5706
|
-
Object.defineProperty(instance, k, {
|
|
5707
|
-
enumerable: true,
|
|
5708
|
-
configurable: true,
|
|
5709
|
-
get() {
|
|
5710
|
-
return innerValue;
|
|
5711
|
-
},
|
|
5712
|
-
set(next) {
|
|
5713
|
-
innerValue = next;
|
|
5714
|
-
if (!isPatching) notify("direct");
|
|
5715
|
-
}
|
|
5716
|
-
});
|
|
5717
|
-
}
|
|
5718
|
-
});
|
|
5719
|
-
let dispatchingDirect = false;
|
|
5720
|
-
if (directSources.length > 0) {
|
|
5721
|
-
let initialized = false;
|
|
5722
|
-
effect(() => {
|
|
5723
|
-
directSources.forEach((source) => {
|
|
5724
|
-
if (isTrackableRef(source)) source.value;
|
|
5725
|
-
else touchReactive(source);
|
|
5726
|
-
});
|
|
5727
|
-
if (!initialized) {
|
|
5728
|
-
initialized = true;
|
|
5729
|
-
return;
|
|
5730
|
-
}
|
|
5731
|
-
if (isPatching) return;
|
|
5732
|
-
if (dispatchingDirect) return;
|
|
5733
|
-
dispatchingDirect = true;
|
|
5734
|
-
try {
|
|
5735
|
-
notify("direct");
|
|
5736
|
-
} finally {
|
|
5737
|
-
dispatchingDirect = false;
|
|
5738
|
-
}
|
|
5739
|
-
});
|
|
5740
|
-
}
|
|
5741
|
-
const plugins = (_manager$_plugins = manager === null || manager === void 0 ? void 0 : manager._plugins) !== null && _manager$_plugins !== void 0 ? _manager$_plugins : [];
|
|
5742
|
-
for (const plugin of plugins) try {
|
|
5743
|
-
plugin({ store: instance });
|
|
5744
|
-
} catch (_unused2) {}
|
|
5745
|
-
return instance;
|
|
5746
|
-
}
|
|
5747
|
-
const options = setupOrOptions;
|
|
5748
|
-
const rawState = options.state ? options.state() : {};
|
|
5749
|
-
const state = reactive(rawState);
|
|
5750
|
-
const initialSnapshot = cloneDeep(toRaw(rawState));
|
|
5751
|
-
let notify = () => {};
|
|
5752
|
-
const base = createBaseApi(id, state, (t) => notify(t), () => {
|
|
5753
|
-
resetObject(state, initialSnapshot);
|
|
5754
|
-
notify("patch object");
|
|
5755
|
-
});
|
|
5756
|
-
let isPatching = false;
|
|
5757
|
-
const rawPatch = base.api.$patch;
|
|
5758
|
-
base.api.$patch = (patch) => {
|
|
5759
|
-
isPatching = true;
|
|
5760
|
-
try {
|
|
5761
|
-
rawPatch(patch);
|
|
5762
|
-
} finally {
|
|
5763
|
-
isPatching = false;
|
|
5764
|
-
}
|
|
5765
|
-
};
|
|
5766
|
-
if (typeof base.api.$reset === "function") {
|
|
5767
|
-
const rawReset = base.api.$reset;
|
|
5768
|
-
base.api.$reset = () => {
|
|
5769
|
-
isPatching = true;
|
|
5770
|
-
try {
|
|
5771
|
-
rawReset();
|
|
5772
|
-
} finally {
|
|
5773
|
-
isPatching = false;
|
|
5774
|
-
}
|
|
5775
|
-
};
|
|
5776
|
-
}
|
|
5777
|
-
notify = createSafeNotifier(id, base.subs, () => state);
|
|
5778
|
-
const store = {};
|
|
5779
|
-
for (const key of Object.getOwnPropertyNames(base.api)) {
|
|
5780
|
-
const d = Object.getOwnPropertyDescriptor(base.api, key);
|
|
5781
|
-
if (d) if (key === "$state") Object.defineProperty(store, key, {
|
|
5782
|
-
enumerable: d.enumerable,
|
|
5783
|
-
configurable: d.configurable,
|
|
5784
|
-
get() {
|
|
5785
|
-
return base.api.$state;
|
|
5786
|
-
},
|
|
5787
|
-
set(v) {
|
|
5788
|
-
isPatching = true;
|
|
5789
|
-
try {
|
|
5790
|
-
base.api.$state = v;
|
|
5791
|
-
} finally {
|
|
5792
|
-
isPatching = false;
|
|
5793
|
-
}
|
|
5794
|
-
}
|
|
5795
|
-
});
|
|
5796
|
-
else Object.defineProperty(store, key, d);
|
|
5797
|
-
}
|
|
5798
|
-
const getterDefs = (_options$getters = options.getters) !== null && _options$getters !== void 0 ? _options$getters : {};
|
|
5799
|
-
const computedMap = {};
|
|
5800
|
-
Object.keys(getterDefs).forEach((key) => {
|
|
5801
|
-
const getter = getterDefs[key];
|
|
5802
|
-
if (typeof getter === "function") {
|
|
5803
|
-
const c = computed(() => getter.call(store, state));
|
|
5804
|
-
computedMap[key] = c;
|
|
5805
|
-
Object.defineProperty(store, key, {
|
|
5806
|
-
enumerable: true,
|
|
5807
|
-
configurable: true,
|
|
5808
|
-
get() {
|
|
5809
|
-
return c.value;
|
|
5810
|
-
}
|
|
5811
|
-
});
|
|
5812
|
-
}
|
|
5813
|
-
});
|
|
5814
|
-
const actionDefs = (_options$actions = options.actions) !== null && _options$actions !== void 0 ? _options$actions : {};
|
|
5815
|
-
Object.keys(actionDefs).forEach((key) => {
|
|
5816
|
-
const act = actionDefs[key];
|
|
5817
|
-
if (typeof act === "function") store[key] = wrapAction(store, key, (...args) => {
|
|
5818
|
-
return act.apply(store, args);
|
|
5819
|
-
}, base.actionSubs);
|
|
5820
|
-
});
|
|
5821
|
-
Object.keys(state).forEach((k) => {
|
|
5822
|
-
Object.defineProperty(store, k, {
|
|
5823
|
-
enumerable: true,
|
|
5824
|
-
configurable: true,
|
|
5825
|
-
get() {
|
|
5826
|
-
return state[k];
|
|
5827
|
-
},
|
|
5828
|
-
set(v) {
|
|
5829
|
-
state[k] = v;
|
|
5830
|
-
}
|
|
5831
|
-
});
|
|
5832
|
-
});
|
|
5833
|
-
let initialized = false;
|
|
5834
|
-
let dispatchingDirect = false;
|
|
5835
|
-
effect(() => {
|
|
5836
|
-
touchReactive(state);
|
|
5837
|
-
if (!initialized) {
|
|
5838
|
-
initialized = true;
|
|
5839
|
-
return;
|
|
5840
|
-
}
|
|
5841
|
-
if (isPatching) return;
|
|
5842
|
-
if (dispatchingDirect) return;
|
|
5843
|
-
dispatchingDirect = true;
|
|
5844
|
-
try {
|
|
5845
|
-
notify("direct");
|
|
5846
|
-
} finally {
|
|
5847
|
-
dispatchingDirect = false;
|
|
5848
|
-
}
|
|
5849
|
-
});
|
|
5850
|
-
instance = store;
|
|
5851
|
-
const plugins = (_manager$_plugins2 = manager === null || manager === void 0 ? void 0 : manager._plugins) !== null && _manager$_plugins2 !== void 0 ? _manager$_plugins2 : [];
|
|
5852
|
-
for (const plugin of plugins) try {
|
|
5853
|
-
plugin({ store: instance });
|
|
5854
|
-
} catch (_unused3) {}
|
|
5855
|
-
return instance;
|
|
5856
|
-
};
|
|
5857
|
-
}
|
|
5858
|
-
|
|
5859
|
-
//#endregion
|
|
5860
|
-
//#region src/store/storeToRefs.ts
|
|
5861
|
-
/**
|
|
5862
|
-
* @description 将 store 状态转换为 Ref
|
|
5863
|
-
*/
|
|
5864
|
-
function storeToRefs(store) {
|
|
5865
|
-
const result = {};
|
|
5866
|
-
for (const key in store) {
|
|
5867
|
-
const value = store[key];
|
|
5868
|
-
if (typeof value === "function") {
|
|
5869
|
-
result[key] = value;
|
|
5870
|
-
continue;
|
|
5871
|
-
}
|
|
5872
|
-
if (isRef(value)) result[key] = value;
|
|
5873
|
-
else result[key] = computed({
|
|
5874
|
-
get: () => store[key],
|
|
5875
|
-
set: (v) => {
|
|
5876
|
-
store[key] = v;
|
|
5877
|
-
}
|
|
5878
|
-
});
|
|
5879
|
-
}
|
|
5880
|
-
return result;
|
|
4920
|
+
function useTemplateRef(name) {
|
|
4921
|
+
const instance = getCurrentInstance();
|
|
4922
|
+
if (!instance) throw new Error("useTemplateRef() 必须在 setup() 的同步阶段调用");
|
|
4923
|
+
const normalized = typeof name === "string" ? name.trim() : "";
|
|
4924
|
+
if (!normalized) throw new Error("useTemplateRef() 需要传入有效的模板 ref 名称");
|
|
4925
|
+
const map = ensureTemplateRefMap(instance);
|
|
4926
|
+
const existing = map.get(normalized);
|
|
4927
|
+
if (existing) return existing;
|
|
4928
|
+
const target = shallowRef(null);
|
|
4929
|
+
map.set(normalized, target);
|
|
4930
|
+
return target;
|
|
5881
4931
|
}
|
|
5882
|
-
|
|
5883
4932
|
//#endregion
|
|
5884
|
-
export { addMutationRecorder, batch, callHookList, callHookReturn, callUpdateHooks, computed, createApp, createStore, createWevuComponent, createWevuScopedSlotComponent, customRef, defineComponent, defineStore, effect, effectScope, endBatch, getCurrentInstance, getCurrentScope, getCurrentSetupContext, getDeepWatchStrategy, getReactiveVersion, inject, injectGlobal, isNoSetData, isRaw, isReactive, isRef, isShallowReactive, isShallowRef, markNoSetData, markRaw, mergeModels, mountRuntimeInstance, nextTick, normalizeClass, normalizeStyle, onActivated, onAddToFavorites, onAttached, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onDetached, onError, onErrorCaptured, onHide, onLaunch, onLoad, onMounted, onMoved, onPageNotFound, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onResize, onRouteDone, onSaveExitState, onScopeDispose, onServerPrefetch, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onThemeChange, onUnhandledRejection, onUnload, onUnmounted, onUpdated, prelinkReactiveTree, provide, provideGlobal, reactive, readonly, ref, registerApp, registerComponent, removeMutationRecorder, resetWevuDefaults, runSetupFunction, setCurrentInstance, setCurrentSetupContext, setDeepWatchStrategy, setWevuDefaults, shallowReactive, shallowRef, startBatch, stop, storeToRefs, teardownRuntimeInstance, toRaw, toRef, toRefs, toValue, touchReactive, traverse, triggerRef, unref, useAttrs, useBindModel, useModel, useNativeInstance, useSlots, useTemplateRef, watch, watchEffect };
|
|
4933
|
+
export { addMutationRecorder, batch, callHookList, callHookReturn, callUpdateHooks, computed, createApp, createStore, createWevuComponent, createWevuScopedSlotComponent, customRef, defineComponent, defineStore, effect, effectScope, endBatch, getCurrentInstance, getCurrentScope, getCurrentSetupContext, getDeepWatchStrategy, getReactiveVersion, inject, injectGlobal, isNoSetData, isRaw, isReactive, isRef, isShallowReactive, isShallowRef, markNoSetData, markRaw, mergeModels, mountRuntimeInstance, nextTick, normalizeClass, normalizeStyle, onActivated, onAddToFavorites, onAttached, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onDetached, onError, onErrorCaptured, onHide, onLaunch, onLoad, onMemoryWarning, onMounted, onMoved, onPageNotFound, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onResize, onRouteDone, onSaveExitState, onScopeDispose, onServerPrefetch, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onThemeChange, onUnhandledRejection, onUnload, onUnmounted, onUpdated, prelinkReactiveTree, provide, provideGlobal, reactive, readonly, ref, registerApp, registerComponent, removeMutationRecorder, resetWevuDefaults, runSetupFunction, setCurrentInstance, setCurrentSetupContext, setDeepWatchStrategy, setRuntimeSetDataVisibility, setWevuDefaults, shallowReactive, shallowRef, startBatch, stop, storeToRefs, teardownRuntimeInstance, toRaw, toRef, toRefs, toValue, touchReactive, traverse, triggerRef, unref, useAttrs, useBindModel, useDisposables, useIntersectionObserver, useModel, useNativeInstance, useNativePageRouter, useNativeRouter, usePageScrollThrottle, useSlots, useTemplateRef, useUpdatePerformanceListener, watch, watchEffect };
|