wevu 6.12.0 → 6.12.3
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/index.mjs +166 -45
- package/dist/{store-DDjlcddD.mjs → store-DEQfJFrN.mjs} +4 -2
- package/dist/store.mjs +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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-B37H82Eg.mjs";
|
|
2
|
-
import { i as computed, n as defineStore, r as createStore, t as storeToRefs } from "./store-
|
|
2
|
+
import { i as computed, n as defineStore, r as createStore, t as storeToRefs } from "./store-DEQfJFrN.mjs";
|
|
3
3
|
import { A as onUnhandledRejection, B as getMiniProgramGlobalObject, C as onRouteDone, D as onShow, E as onShareTimeline, F as getCurrentInstance, H as readonly, I as getCurrentSetupContext, L as pushHook, M as assertInSetup, N as callHookList, O as onTabItemTap, P as callHookReturn, R as setCurrentInstance, S as onResize, T as onShareAppMessage, U as shallowReadonly, V as getScopedSlotHostGlobalObject, _ as onPageNotFound, a as injectGlobal, b as onReachBottom, c as onAddToFavorites, d as onError, f as onHide, g as onMoved, h as onMemoryWarning, i as inject, j as onUnload, k as onThemeChange, l as onAttached, m as onLoad, n as useNativeRouter, o as provide, p as onLaunch, r as hasInjectionContext, s as provideGlobal, t as useNativePageRouter, u as onDetached, v as onPageScroll, w as onSaveExitState, x as onReady, y as onPullDownRefresh, z as setCurrentSetupContext } from "./router-DHeyqsP-.mjs";
|
|
4
4
|
//#region src/reactivity/shallowRef.ts
|
|
5
5
|
/**
|
|
@@ -802,8 +802,7 @@ function isPlainObject$1(value) {
|
|
|
802
802
|
const proto = Object.getPrototypeOf(value);
|
|
803
803
|
return proto === null || proto === Object.prototype;
|
|
804
804
|
}
|
|
805
|
-
function
|
|
806
|
-
var _options$_depth, _options$_budget;
|
|
805
|
+
function toPlainInternal(value, seen, cache, depth, budget) {
|
|
807
806
|
const unwrapped = unref(value);
|
|
808
807
|
if (typeof unwrapped === "bigint") {
|
|
809
808
|
const asNumber = Number(unwrapped);
|
|
@@ -814,10 +813,7 @@ function toPlain(value, seen = /* @__PURE__ */ new WeakMap(), options) {
|
|
|
814
813
|
if (typeof unwrapped !== "object" || unwrapped === null) return unwrapped;
|
|
815
814
|
if (isNoSetData(unwrapped)) return;
|
|
816
815
|
const raw = isReactive(unwrapped) ? toRaw(unwrapped) : unwrapped;
|
|
817
|
-
const depth = (_options$_depth = options === null || options === void 0 ? void 0 : options._depth) !== null && _options$_depth !== void 0 ? _options$_depth : typeof (options === null || options === void 0 ? void 0 : options.maxDepth) === "number" ? Math.max(0, Math.floor(options.maxDepth)) : Number.POSITIVE_INFINITY;
|
|
818
|
-
const budget = (_options$_budget = options === null || options === void 0 ? void 0 : options._budget) !== null && _options$_budget !== void 0 ? _options$_budget : typeof (options === null || options === void 0 ? void 0 : options.maxKeys) === "number" ? { keys: Math.max(0, Math.floor(options.maxKeys)) } : { keys: Number.POSITIVE_INFINITY };
|
|
819
816
|
if (depth <= 0 || budget.keys <= 0) return raw;
|
|
820
|
-
const cache = options === null || options === void 0 ? void 0 : options.cache;
|
|
821
817
|
if (cache) {
|
|
822
818
|
const version = getReactiveVersion(raw);
|
|
823
819
|
const cached = cache.get(raw);
|
|
@@ -830,7 +826,7 @@ function toPlain(value, seen = /* @__PURE__ */ new WeakMap(), options) {
|
|
|
830
826
|
const entries = [];
|
|
831
827
|
seen.set(raw, entries);
|
|
832
828
|
raw.forEach((mapValue, mapKey) => {
|
|
833
|
-
entries.push([
|
|
829
|
+
entries.push([toPlainInternal(mapKey, seen, void 0, Number.POSITIVE_INFINITY, { keys: Number.POSITIVE_INFINITY }), toPlainInternal(mapValue, seen, void 0, Number.POSITIVE_INFINITY, { keys: Number.POSITIVE_INFINITY })]);
|
|
834
830
|
});
|
|
835
831
|
return entries;
|
|
836
832
|
}
|
|
@@ -838,7 +834,7 @@ function toPlain(value, seen = /* @__PURE__ */ new WeakMap(), options) {
|
|
|
838
834
|
const values = [];
|
|
839
835
|
seen.set(raw, values);
|
|
840
836
|
raw.forEach((setValue) => {
|
|
841
|
-
values.push(
|
|
837
|
+
values.push(toPlainInternal(setValue, seen, void 0, Number.POSITIVE_INFINITY, { keys: Number.POSITIVE_INFINITY }));
|
|
842
838
|
});
|
|
843
839
|
return values;
|
|
844
840
|
}
|
|
@@ -849,7 +845,7 @@ function toPlain(value, seen = /* @__PURE__ */ new WeakMap(), options) {
|
|
|
849
845
|
if (typeof view[Symbol.iterator] === "function") {
|
|
850
846
|
const values = [...view];
|
|
851
847
|
seen.set(raw, values);
|
|
852
|
-
return values.map((item) =>
|
|
848
|
+
return values.map((item) => toPlainInternal(item, seen, void 0, Number.POSITIVE_INFINITY, { keys: Number.POSITIVE_INFINITY }));
|
|
853
849
|
}
|
|
854
850
|
const bytes = [...new Uint8Array(view.buffer, view.byteOffset, view.byteLength)];
|
|
855
851
|
seen.set(raw, bytes);
|
|
@@ -863,14 +859,11 @@ function toPlain(value, seen = /* @__PURE__ */ new WeakMap(), options) {
|
|
|
863
859
|
if (Array.isArray(raw)) {
|
|
864
860
|
const arr = [];
|
|
865
861
|
seen.set(raw, arr);
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
_depth: depth - 1,
|
|
870
|
-
_budget: budget
|
|
871
|
-
});
|
|
862
|
+
const nextDepth = depth - 1;
|
|
863
|
+
for (let index = 0; index < raw.length; index += 1) {
|
|
864
|
+
const next = toPlainInternal(raw[index], seen, cache, nextDepth, budget);
|
|
872
865
|
arr[index] = next === void 0 ? null : next;
|
|
873
|
-
}
|
|
866
|
+
}
|
|
874
867
|
if (cache) cache.set(raw, {
|
|
875
868
|
version: getReactiveVersion(raw),
|
|
876
869
|
value: arr
|
|
@@ -879,22 +872,25 @@ function toPlain(value, seen = /* @__PURE__ */ new WeakMap(), options) {
|
|
|
879
872
|
}
|
|
880
873
|
const output = {};
|
|
881
874
|
seen.set(raw, output);
|
|
882
|
-
|
|
875
|
+
const nextDepth = depth - 1;
|
|
876
|
+
for (const key of Object.keys(raw)) {
|
|
883
877
|
budget.keys -= 1;
|
|
884
|
-
if (budget.keys <= 0)
|
|
885
|
-
const next =
|
|
886
|
-
...options,
|
|
887
|
-
_depth: depth - 1,
|
|
888
|
-
_budget: budget
|
|
889
|
-
});
|
|
878
|
+
if (budget.keys <= 0) break;
|
|
879
|
+
const next = toPlainInternal(raw[key], seen, cache, nextDepth, budget);
|
|
890
880
|
if (next !== void 0) output[key] = next;
|
|
891
|
-
}
|
|
881
|
+
}
|
|
892
882
|
if (cache) cache.set(raw, {
|
|
893
883
|
version: getReactiveVersion(raw),
|
|
894
884
|
value: output
|
|
895
885
|
});
|
|
896
886
|
return output;
|
|
897
887
|
}
|
|
888
|
+
function toPlain(value, seen = /* @__PURE__ */ new WeakMap(), options) {
|
|
889
|
+
var _options$_depth, _options$_budget;
|
|
890
|
+
const depth = (_options$_depth = options === null || options === void 0 ? void 0 : options._depth) !== null && _options$_depth !== void 0 ? _options$_depth : typeof (options === null || options === void 0 ? void 0 : options.maxDepth) === "number" ? Math.max(0, Math.floor(options.maxDepth)) : Number.POSITIVE_INFINITY;
|
|
891
|
+
const budget = (_options$_budget = options === null || options === void 0 ? void 0 : options._budget) !== null && _options$_budget !== void 0 ? _options$_budget : typeof (options === null || options === void 0 ? void 0 : options.maxKeys) === "number" ? { keys: Math.max(0, Math.floor(options.maxKeys)) } : { keys: Number.POSITIVE_INFINITY };
|
|
892
|
+
return toPlainInternal(value, seen, options === null || options === void 0 ? void 0 : options.cache, depth, budget);
|
|
893
|
+
}
|
|
898
894
|
function isArrayEqual(a, b, compare) {
|
|
899
895
|
if (a.length !== b.length) return false;
|
|
900
896
|
for (let i = 0; i < a.length; i++) if (!compare(a[i], b[i])) return false;
|
|
@@ -938,10 +934,17 @@ function assignNestedDiff(prev, next, path, output) {
|
|
|
938
934
|
}
|
|
939
935
|
output[path] = normalizeSetDataValue$1(next);
|
|
940
936
|
}
|
|
941
|
-
function diffSnapshots(prev, next) {
|
|
937
|
+
function diffSnapshots(prev, next, options) {
|
|
942
938
|
const diff = {};
|
|
943
|
-
|
|
944
|
-
for (const key of Object.keys(
|
|
939
|
+
const skipKeys = options === null || options === void 0 ? void 0 : options.skipKeys;
|
|
940
|
+
for (const key of Object.keys(next)) {
|
|
941
|
+
if (skipKeys === null || skipKeys === void 0 ? void 0 : skipKeys.has(key)) continue;
|
|
942
|
+
assignNestedDiff(prev[key], next[key], key, diff);
|
|
943
|
+
}
|
|
944
|
+
for (const key of Object.keys(prev)) {
|
|
945
|
+
if (skipKeys === null || skipKeys === void 0 ? void 0 : skipKeys.has(key)) continue;
|
|
946
|
+
if (!Object.hasOwn(next, key)) diff[key] = null;
|
|
947
|
+
}
|
|
945
948
|
return diff;
|
|
946
949
|
}
|
|
947
950
|
//#endregion
|
|
@@ -1102,6 +1105,11 @@ function mergeSiblingPayload(options) {
|
|
|
1102
1105
|
}
|
|
1103
1106
|
//#endregion
|
|
1104
1107
|
//#region src/runtime/app/setData/snapshot.ts
|
|
1108
|
+
function isPlainObjectLike(value) {
|
|
1109
|
+
if (value == null || typeof value !== "object") return false;
|
|
1110
|
+
const proto = Object.getPrototypeOf(value);
|
|
1111
|
+
return proto === Object.prototype || proto === null;
|
|
1112
|
+
}
|
|
1105
1113
|
function normalizeSetDataValue(value) {
|
|
1106
1114
|
return value === void 0 ? null : value;
|
|
1107
1115
|
}
|
|
@@ -1112,11 +1120,6 @@ function cloneSnapshotValue(value) {
|
|
|
1112
1120
|
for (const key of Object.keys(value)) out[key] = cloneSnapshotValue(value[key]);
|
|
1113
1121
|
return out;
|
|
1114
1122
|
}
|
|
1115
|
-
function isPlainObjectLike(value) {
|
|
1116
|
-
if (value == null || typeof value !== "object") return false;
|
|
1117
|
-
const proto = Object.getPrototypeOf(value);
|
|
1118
|
-
return proto === Object.prototype || proto === null;
|
|
1119
|
-
}
|
|
1120
1123
|
function isShallowEqualValue(a, b) {
|
|
1121
1124
|
if (Object.is(a, b)) return true;
|
|
1122
1125
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
@@ -1154,7 +1157,9 @@ function isDeepEqualValue(a, b, depth, budget) {
|
|
|
1154
1157
|
}
|
|
1155
1158
|
return true;
|
|
1156
1159
|
}
|
|
1157
|
-
function applySnapshotUpdate(snapshot, path, value, op) {
|
|
1160
|
+
function applySnapshotUpdate(snapshot, path, value, op, options) {
|
|
1161
|
+
var _options$cloneValue;
|
|
1162
|
+
const cloneValue = (_options$cloneValue = options === null || options === void 0 ? void 0 : options.cloneValue) !== null && _options$cloneValue !== void 0 ? _options$cloneValue : true;
|
|
1158
1163
|
const segments = path.split(".").filter(Boolean);
|
|
1159
1164
|
if (!segments.length) return;
|
|
1160
1165
|
let current = snapshot;
|
|
@@ -1169,7 +1174,7 @@ function applySnapshotUpdate(snapshot, path, value, op) {
|
|
|
1169
1174
|
} catch (_unused) {
|
|
1170
1175
|
current[leaf] = null;
|
|
1171
1176
|
}
|
|
1172
|
-
else current[leaf] = cloneSnapshotValue(value);
|
|
1177
|
+
else current[leaf] = cloneValue ? cloneSnapshotValue(value) : value;
|
|
1173
1178
|
}
|
|
1174
1179
|
function collectSnapshot(options) {
|
|
1175
1180
|
const { state, computedRefs, includeComputed, shouldIncludeKey, plainCache, toPlainMaxDepth, toPlainMaxKeys } = options;
|
|
@@ -1328,11 +1333,11 @@ function runPatchUpdate(options) {
|
|
|
1328
1333
|
if (!Object.keys(collapsedPayload).length) return;
|
|
1329
1334
|
for (const [path, value] of Object.entries(collapsedPayload)) {
|
|
1330
1335
|
const entry = entryMap.get(path);
|
|
1331
|
-
if (entry) applySnapshotUpdate(latestSnapshot, path, value, entry.kind === "array" ? "set" : entry.op);
|
|
1332
|
-
else applySnapshotUpdate(latestSnapshot, path, value, "set");
|
|
1336
|
+
if (entry) applySnapshotUpdate(latestSnapshot, path, value, entry.kind === "array" ? "set" : entry.op, { cloneValue: false });
|
|
1337
|
+
else applySnapshotUpdate(latestSnapshot, path, value, "set", { cloneValue: false });
|
|
1333
1338
|
}
|
|
1334
1339
|
if (typeof currentAdapter.setData === "function") {
|
|
1335
|
-
const result = currentAdapter.setData(
|
|
1340
|
+
const result = currentAdapter.setData(collapsedPayload);
|
|
1336
1341
|
if (result && typeof result.then === "function") result.catch(() => {});
|
|
1337
1342
|
}
|
|
1338
1343
|
emitDebug({
|
|
@@ -1349,9 +1354,25 @@ function createSetDataScheduler(options) {
|
|
|
1349
1354
|
const plainCache = /* @__PURE__ */ new WeakMap();
|
|
1350
1355
|
let latestSnapshot = {};
|
|
1351
1356
|
let latestComputedSnapshot = Object.create(null);
|
|
1357
|
+
const latestStateTokens = Object.create(null);
|
|
1358
|
+
const latestComputedTokens = Object.create(null);
|
|
1352
1359
|
const needsFullSnapshot = { value: setDataStrategy === "patch" };
|
|
1353
1360
|
const pendingPatches = /* @__PURE__ */ new Map();
|
|
1354
1361
|
const fallbackTopKeys = /* @__PURE__ */ new Set();
|
|
1362
|
+
const createValueToken = (value) => {
|
|
1363
|
+
const candidate = isRef(value) ? value.value : value;
|
|
1364
|
+
if (candidate == null || typeof candidate !== "object") return candidate;
|
|
1365
|
+
const raw = isReactive(candidate) ? toRaw(candidate) : candidate;
|
|
1366
|
+
return {
|
|
1367
|
+
raw,
|
|
1368
|
+
version: getReactiveVersion(raw)
|
|
1369
|
+
};
|
|
1370
|
+
};
|
|
1371
|
+
const isSameToken = (left, right) => {
|
|
1372
|
+
if (Object.is(left, right)) return true;
|
|
1373
|
+
if (!left || !right || typeof left !== "object" || typeof right !== "object" || !Object.hasOwn(left, "raw") || !Object.hasOwn(right, "raw")) return false;
|
|
1374
|
+
return left.raw === right.raw && left.version === right.version;
|
|
1375
|
+
};
|
|
1355
1376
|
const resolveTopKeysByRoot = (root) => {
|
|
1356
1377
|
const matches = [];
|
|
1357
1378
|
for (const key of Object.keys(state)) {
|
|
@@ -1381,10 +1402,71 @@ function createSetDataScheduler(options) {
|
|
|
1381
1402
|
toPlainMaxDepth,
|
|
1382
1403
|
toPlainMaxKeys
|
|
1383
1404
|
});
|
|
1405
|
+
const collectDiffSnapshot = () => {
|
|
1406
|
+
const rawState = isReactive(state) ? toRaw(state) : state;
|
|
1407
|
+
const nextSnapshot = { ...latestSnapshot };
|
|
1408
|
+
const seen = /* @__PURE__ */ new WeakMap();
|
|
1409
|
+
const includedStateKeys = /* @__PURE__ */ new Set();
|
|
1410
|
+
const includedComputedKeys = /* @__PURE__ */ new Set();
|
|
1411
|
+
const replacedTopLevelKeys = /* @__PURE__ */ new Set();
|
|
1412
|
+
for (const key of Object.keys(rawState)) {
|
|
1413
|
+
if (!shouldIncludeKey(key)) continue;
|
|
1414
|
+
includedStateKeys.add(key);
|
|
1415
|
+
const token = createValueToken(rawState[key]);
|
|
1416
|
+
const previousToken = latestStateTokens[key];
|
|
1417
|
+
if (previousToken && token && typeof previousToken === "object" && typeof token === "object" && Object.hasOwn(previousToken, "raw") && Object.hasOwn(token, "raw") && Array.isArray(previousToken.raw) && Array.isArray(token.raw) && previousToken.raw !== token.raw) replacedTopLevelKeys.add(key);
|
|
1418
|
+
if (!isSameToken(previousToken, token) || !Object.hasOwn(latestSnapshot, key)) nextSnapshot[key] = toPlain(rawState[key], seen, {
|
|
1419
|
+
cache: plainCache,
|
|
1420
|
+
maxDepth: toPlainMaxDepth,
|
|
1421
|
+
maxKeys: toPlainMaxKeys
|
|
1422
|
+
});
|
|
1423
|
+
latestStateTokens[key] = token;
|
|
1424
|
+
}
|
|
1425
|
+
for (const key of Object.keys(latestStateTokens)) if (!includedStateKeys.has(key)) {
|
|
1426
|
+
delete latestStateTokens[key];
|
|
1427
|
+
if (!includeComputed || !Object.hasOwn(computedRefs, key)) delete nextSnapshot[key];
|
|
1428
|
+
}
|
|
1429
|
+
if (!includeComputed) {
|
|
1430
|
+
for (const key of Object.keys(latestComputedTokens)) delete latestComputedTokens[key];
|
|
1431
|
+
return {
|
|
1432
|
+
snapshot: nextSnapshot,
|
|
1433
|
+
replacedTopLevelKeys
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1436
|
+
for (const key of Object.keys(computedRefs)) {
|
|
1437
|
+
if (!shouldIncludeKey(key)) continue;
|
|
1438
|
+
includedComputedKeys.add(key);
|
|
1439
|
+
const value = computedRefs[key].value;
|
|
1440
|
+
const token = createValueToken(value);
|
|
1441
|
+
if (!isSameToken(latestComputedTokens[key], token) || !Object.hasOwn(latestSnapshot, key)) nextSnapshot[key] = toPlain(value, seen, {
|
|
1442
|
+
cache: plainCache,
|
|
1443
|
+
maxDepth: toPlainMaxDepth,
|
|
1444
|
+
maxKeys: toPlainMaxKeys
|
|
1445
|
+
});
|
|
1446
|
+
latestComputedTokens[key] = token;
|
|
1447
|
+
}
|
|
1448
|
+
for (const key of Object.keys(latestComputedTokens)) if (!includedComputedKeys.has(key)) {
|
|
1449
|
+
delete latestComputedTokens[key];
|
|
1450
|
+
if (!Object.hasOwn(rawState, key) || !shouldIncludeKey(key)) delete nextSnapshot[key];
|
|
1451
|
+
}
|
|
1452
|
+
return {
|
|
1453
|
+
snapshot: nextSnapshot,
|
|
1454
|
+
replacedTopLevelKeys
|
|
1455
|
+
};
|
|
1456
|
+
};
|
|
1384
1457
|
const runDiffUpdate = (reason = "diff") => {
|
|
1385
|
-
|
|
1386
|
-
const
|
|
1387
|
-
|
|
1458
|
+
var _diffCollection$snaps;
|
|
1459
|
+
const diffCollection = setDataStrategy === "diff" ? collectDiffSnapshot() : void 0;
|
|
1460
|
+
const snapshot = (_diffCollection$snaps = diffCollection === null || diffCollection === void 0 ? void 0 : diffCollection.snapshot) !== null && _diffCollection$snaps !== void 0 ? _diffCollection$snaps : collect();
|
|
1461
|
+
const diff = diffCollection ? (() => {
|
|
1462
|
+
const fastDiff = {};
|
|
1463
|
+
for (const key of diffCollection.replacedTopLevelKeys) fastDiff[key] = snapshot[key];
|
|
1464
|
+
return {
|
|
1465
|
+
...diffSnapshots(latestSnapshot, snapshot, { skipKeys: diffCollection.replacedTopLevelKeys }),
|
|
1466
|
+
...fastDiff
|
|
1467
|
+
};
|
|
1468
|
+
})() : diffSnapshots(latestSnapshot, snapshot);
|
|
1469
|
+
latestSnapshot = snapshot;
|
|
1388
1470
|
needsFullSnapshot.value = false;
|
|
1389
1471
|
pendingPatches.clear();
|
|
1390
1472
|
if (setDataStrategy === "patch" && includeComputed) {
|
|
@@ -1397,7 +1479,7 @@ function createSetDataScheduler(options) {
|
|
|
1397
1479
|
}
|
|
1398
1480
|
if (!Object.keys(diff).length) return;
|
|
1399
1481
|
if (typeof currentAdapter.setData === "function") {
|
|
1400
|
-
const result = currentAdapter.setData(
|
|
1482
|
+
const result = currentAdapter.setData(diff);
|
|
1401
1483
|
if (result && typeof result.then === "function") result.catch(() => {});
|
|
1402
1484
|
}
|
|
1403
1485
|
emitDebug({
|
|
@@ -1465,10 +1547,12 @@ function createSetDataScheduler(options) {
|
|
|
1465
1547
|
} else runDiffUpdate(needsFullSnapshot.value ? "needsFullSnapshot" : "diff");
|
|
1466
1548
|
};
|
|
1467
1549
|
const snapshot = () => setDataStrategy === "patch" ? collect() : { ...latestSnapshot };
|
|
1550
|
+
const cloneLatestSnapshot = () => ({ ...latestSnapshot });
|
|
1468
1551
|
return {
|
|
1469
1552
|
job,
|
|
1470
1553
|
mutationRecorder,
|
|
1471
1554
|
snapshot,
|
|
1555
|
+
cloneLatestSnapshot,
|
|
1472
1556
|
getLatestSnapshot: () => latestSnapshot
|
|
1473
1557
|
};
|
|
1474
1558
|
}
|
|
@@ -1569,6 +1653,11 @@ function createRuntimeMount(options) {
|
|
|
1569
1653
|
const methodDefs = resolvedMethods;
|
|
1570
1654
|
let mounted = true;
|
|
1571
1655
|
const stopHandles = [];
|
|
1656
|
+
const trackedSetupReactiveKeys = /* @__PURE__ */ new Set();
|
|
1657
|
+
Object.keys(state).forEach((key) => {
|
|
1658
|
+
const value = state[key];
|
|
1659
|
+
if (isRef(value) || isReactive(value)) trackedSetupReactiveKeys.add(key);
|
|
1660
|
+
});
|
|
1572
1661
|
const { includeComputed, setDataStrategy, maxPatchKeys, maxPayloadBytes, mergeSiblingThreshold, mergeSiblingMaxInflationRatio, mergeSiblingMaxParentBytes, mergeSiblingSkipArray, computedCompare, computedCompareMaxDepth, computedCompareMaxKeys, prelinkMaxDepth, prelinkMaxKeys, debug, diagnostics, debugWhen, debugSampleRate, elevateTopKeyThreshold, toPlainMaxDepth, toPlainMaxKeys, shouldIncludeKey } = resolveSetDataOptions(setDataOptions);
|
|
1573
1662
|
const diagnosticsLogger = createDiagnosticsLogger(diagnostics);
|
|
1574
1663
|
const mergedDebug = debug || diagnosticsLogger ? (info) => {
|
|
@@ -1621,7 +1710,7 @@ function createRuntimeMount(options) {
|
|
|
1621
1710
|
if (isReactive(runtimeProps)) touchReactive(runtimeProps);
|
|
1622
1711
|
const runtimeAttrs = state.__wevuAttrs;
|
|
1623
1712
|
if (isReactive(runtimeAttrs)) touchReactive(runtimeAttrs);
|
|
1624
|
-
|
|
1713
|
+
trackedSetupReactiveKeys.forEach((key) => {
|
|
1625
1714
|
const v = state[key];
|
|
1626
1715
|
if (isRef(v)) {
|
|
1627
1716
|
const inner = v.value;
|
|
@@ -1705,6 +1794,30 @@ function createRuntimeMount(options) {
|
|
|
1705
1794
|
} catch (_unused4) {
|
|
1706
1795
|
runtimeInstance.__wevu_flushSetupSnapshotSync = job;
|
|
1707
1796
|
}
|
|
1797
|
+
try {
|
|
1798
|
+
Object.defineProperty(runtimeInstance, "__wevu_cloneLatestSnapshot", {
|
|
1799
|
+
value: scheduler.cloneLatestSnapshot,
|
|
1800
|
+
configurable: true,
|
|
1801
|
+
enumerable: false,
|
|
1802
|
+
writable: false
|
|
1803
|
+
});
|
|
1804
|
+
} catch (_unused5) {
|
|
1805
|
+
runtimeInstance.__wevu_cloneLatestSnapshot = scheduler.cloneLatestSnapshot;
|
|
1806
|
+
}
|
|
1807
|
+
try {
|
|
1808
|
+
Object.defineProperty(runtimeInstance, "__wevu_trackSetupReactiveKey", {
|
|
1809
|
+
value: (key) => {
|
|
1810
|
+
trackedSetupReactiveKeys.add(key);
|
|
1811
|
+
},
|
|
1812
|
+
configurable: true,
|
|
1813
|
+
enumerable: false,
|
|
1814
|
+
writable: false
|
|
1815
|
+
});
|
|
1816
|
+
} catch (_unused6) {
|
|
1817
|
+
runtimeInstance.__wevu_trackSetupReactiveKey = (key) => {
|
|
1818
|
+
trackedSetupReactiveKeys.add(key);
|
|
1819
|
+
};
|
|
1820
|
+
}
|
|
1708
1821
|
return runtimeInstance;
|
|
1709
1822
|
};
|
|
1710
1823
|
}
|
|
@@ -2083,6 +2196,11 @@ function getOwnerSnapshot(ownerId) {
|
|
|
2083
2196
|
var _ownerStore$get4;
|
|
2084
2197
|
return (_ownerStore$get4 = ownerStore.get(ownerId)) === null || _ownerStore$get4 === void 0 ? void 0 : _ownerStore$get4.snapshot;
|
|
2085
2198
|
}
|
|
2199
|
+
function resolveOwnerSnapshot(runtime) {
|
|
2200
|
+
const fastSnapshot = runtime.__wevu_cloneLatestSnapshot;
|
|
2201
|
+
if (typeof fastSnapshot === "function") return fastSnapshot();
|
|
2202
|
+
return typeof runtime.snapshot === "function" ? runtime.snapshot() : {};
|
|
2203
|
+
}
|
|
2086
2204
|
function attachOwnerSnapshot(target, runtime, ownerId) {
|
|
2087
2205
|
var _wevuProps;
|
|
2088
2206
|
try {
|
|
@@ -2091,7 +2209,7 @@ function attachOwnerSnapshot(target, runtime, ownerId) {
|
|
|
2091
2209
|
try {
|
|
2092
2210
|
target.__wvOwnerId = ownerId;
|
|
2093
2211
|
} catch (_unused3) {}
|
|
2094
|
-
const snapshot =
|
|
2212
|
+
const snapshot = resolveOwnerSnapshot(runtime);
|
|
2095
2213
|
const propsSource = (_wevuProps = target.__wevuProps) !== null && _wevuProps !== void 0 ? _wevuProps : target.properties;
|
|
2096
2214
|
if (propsSource && typeof propsSource === "object") for (const [key, value] of Object.entries(propsSource)) snapshot[key] = value;
|
|
2097
2215
|
updateOwnerSnapshot(ownerId, snapshot, runtime.proxy);
|
|
@@ -2737,6 +2855,10 @@ function runRuntimeSetupPhase(options) {
|
|
|
2737
2855
|
runtime.methods[key] = (...args) => val.apply(runtime.proxy, args);
|
|
2738
2856
|
methodsChanged = true;
|
|
2739
2857
|
} else {
|
|
2858
|
+
if (isRef(val) || isReactive(val)) {
|
|
2859
|
+
var _wevu_trackSetupReact;
|
|
2860
|
+
(_wevu_trackSetupReact = runtime.__wevu_trackSetupReactiveKey) === null || _wevu_trackSetupReact === void 0 || _wevu_trackSetupReact.call(runtime, key);
|
|
2861
|
+
}
|
|
2740
2862
|
if (declaredPropKeys.has(key)) {
|
|
2741
2863
|
let fallbackValue = val;
|
|
2742
2864
|
try {
|
|
@@ -3078,8 +3200,7 @@ function mountRuntimeInstance(target, runtimeApp, watchMap, setup, options) {
|
|
|
3078
3200
|
const refreshOwnerSnapshot = () => {
|
|
3079
3201
|
var _wevuProps;
|
|
3080
3202
|
if (!runtimeRef) return;
|
|
3081
|
-
|
|
3082
|
-
const snapshot = runtimeRef.snapshot();
|
|
3203
|
+
const snapshot = resolveOwnerSnapshot(runtimeRef);
|
|
3083
3204
|
const propsSource = (_wevuProps = target.__wevuProps) !== null && _wevuProps !== void 0 ? _wevuProps : target.properties;
|
|
3084
3205
|
if (propsSource && typeof propsSource === "object") for (const [key, value] of Object.entries(propsSource)) snapshot[key] = value;
|
|
3085
3206
|
updateOwnerSnapshot(ownerId, snapshot, runtimeRef.proxy);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as track, C as effect, d as reactive, g as touchReactive, j as trigger, l as isReactive, n as isRef, r as markAsRef, y as toRaw } from "./ref-B37H82Eg.mjs";
|
|
1
|
+
import { A as track, C as effect, d as reactive, g as touchReactive, j as trigger, l as isReactive, n as isRef, r as markAsRef, w as effectScope, y as toRaw } from "./ref-B37H82Eg.mjs";
|
|
2
2
|
//#region src/reactivity/computed.ts
|
|
3
3
|
function computed(getterOrOptions) {
|
|
4
4
|
let getter;
|
|
@@ -473,7 +473,9 @@ function defineStore(id, setupOrOptions) {
|
|
|
473
473
|
return function useStore() {
|
|
474
474
|
if (created && instance) return instance;
|
|
475
475
|
created = true;
|
|
476
|
-
instance =
|
|
476
|
+
instance = effectScope(true).run(() => {
|
|
477
|
+
return typeof setupOrOptions === "function" ? createSetupStyleStore(id, setupOrOptions, manager) : createOptionsStyleStore(id, setupOrOptions, manager);
|
|
478
|
+
});
|
|
477
479
|
return instance;
|
|
478
480
|
};
|
|
479
481
|
}
|
package/dist/store.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as defineStore, r as createStore, t as storeToRefs } from "./store-
|
|
1
|
+
import { n as defineStore, r as createStore, t as storeToRefs } from "./store-DEQfJFrN.mjs";
|
|
2
2
|
export { createStore, defineStore, storeToRefs };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wevu",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.12.
|
|
4
|
+
"version": "6.12.3",
|
|
5
5
|
"description": "Vue 3 风格的小程序运行时,包含响应式、diff+setData 与轻量状态管理",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"dependencies": {
|
|
97
97
|
"vue": "^3.5.31",
|
|
98
98
|
"@wevu/api": "0.2.2",
|
|
99
|
-
"@wevu/compiler": "6.12.
|
|
99
|
+
"@wevu/compiler": "6.12.3"
|
|
100
100
|
},
|
|
101
101
|
"scripts": {
|
|
102
102
|
"dev": "tsdown -w",
|