@vue/compat 3.5.0-beta.2 → 3.5.0-beta.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/vue.cjs.js +361 -250
- package/dist/vue.cjs.prod.js +341 -236
- package/dist/vue.esm-browser.js +308 -251
- package/dist/vue.esm-browser.prod.js +6 -6
- package/dist/vue.esm-bundler.js +308 -251
- package/dist/vue.global.js +296 -230
- package/dist/vue.global.prod.js +6 -6
- package/dist/vue.runtime.esm-browser.js +295 -251
- package/dist/vue.runtime.esm-browser.prod.js +2 -2
- package/dist/vue.runtime.esm-bundler.js +295 -251
- package/dist/vue.runtime.global.js +283 -230
- package/dist/vue.runtime.global.prod.js +2 -2
- package/package.json +2 -2
package/dist/vue.cjs.prod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compat v3.5.0-beta.
|
|
2
|
+
* @vue/compat v3.5.0-beta.3
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -1061,14 +1061,14 @@ function iterator(self, method, wrapValue) {
|
|
|
1061
1061
|
const arrayProto = Array.prototype;
|
|
1062
1062
|
function apply(self, method, fn, thisArg, wrappedRetFn, args) {
|
|
1063
1063
|
const arr = shallowReadArray(self);
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1064
|
+
const needsWrap = arr !== self && !isShallow(self);
|
|
1065
|
+
const methodFn = arr[method];
|
|
1066
|
+
if (methodFn !== arrayProto[method]) {
|
|
1067
|
+
const result2 = methodFn.apply(arr, args);
|
|
1068
|
+
return needsWrap ? toReactive(result2) : result2;
|
|
1067
1069
|
}
|
|
1068
|
-
let needsWrap = false;
|
|
1069
1070
|
let wrappedFn = fn;
|
|
1070
1071
|
if (arr !== self) {
|
|
1071
|
-
needsWrap = !isShallow(self);
|
|
1072
1072
|
if (needsWrap) {
|
|
1073
1073
|
wrappedFn = function(item, index) {
|
|
1074
1074
|
return fn.call(this, toReactive(item), index, self);
|
|
@@ -1862,6 +1862,202 @@ const TriggerOpTypes = {
|
|
|
1862
1862
|
"CLEAR": "clear"
|
|
1863
1863
|
};
|
|
1864
1864
|
|
|
1865
|
+
const INITIAL_WATCHER_VALUE = {};
|
|
1866
|
+
const cleanupMap = /* @__PURE__ */ new WeakMap();
|
|
1867
|
+
let activeWatcher = void 0;
|
|
1868
|
+
function getCurrentWatcher() {
|
|
1869
|
+
return activeWatcher;
|
|
1870
|
+
}
|
|
1871
|
+
function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
|
|
1872
|
+
if (owner) {
|
|
1873
|
+
let cleanups = cleanupMap.get(owner);
|
|
1874
|
+
if (!cleanups) cleanupMap.set(owner, cleanups = []);
|
|
1875
|
+
cleanups.push(cleanupFn);
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
function watch$1(source, cb, options = EMPTY_OBJ) {
|
|
1879
|
+
const { immediate, deep, once, scheduler, augmentJob, call } = options;
|
|
1880
|
+
const reactiveGetter = (source2) => {
|
|
1881
|
+
if (deep) return source2;
|
|
1882
|
+
if (isShallow(source2) || deep === false || deep === 0)
|
|
1883
|
+
return traverse(source2, 1);
|
|
1884
|
+
return traverse(source2);
|
|
1885
|
+
};
|
|
1886
|
+
let effect;
|
|
1887
|
+
let getter;
|
|
1888
|
+
let cleanup;
|
|
1889
|
+
let boundCleanup;
|
|
1890
|
+
let forceTrigger = false;
|
|
1891
|
+
let isMultiSource = false;
|
|
1892
|
+
if (isRef(source)) {
|
|
1893
|
+
getter = () => source.value;
|
|
1894
|
+
forceTrigger = isShallow(source);
|
|
1895
|
+
} else if (isReactive(source)) {
|
|
1896
|
+
getter = () => reactiveGetter(source);
|
|
1897
|
+
forceTrigger = true;
|
|
1898
|
+
} else if (isArray(source)) {
|
|
1899
|
+
isMultiSource = true;
|
|
1900
|
+
forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
|
|
1901
|
+
getter = () => source.map((s) => {
|
|
1902
|
+
if (isRef(s)) {
|
|
1903
|
+
return s.value;
|
|
1904
|
+
} else if (isReactive(s)) {
|
|
1905
|
+
return reactiveGetter(s);
|
|
1906
|
+
} else if (isFunction(s)) {
|
|
1907
|
+
return call ? call(s, 2) : s();
|
|
1908
|
+
} else ;
|
|
1909
|
+
});
|
|
1910
|
+
} else if (isFunction(source)) {
|
|
1911
|
+
if (cb) {
|
|
1912
|
+
getter = call ? () => call(source, 2) : source;
|
|
1913
|
+
} else {
|
|
1914
|
+
getter = () => {
|
|
1915
|
+
if (cleanup) {
|
|
1916
|
+
pauseTracking();
|
|
1917
|
+
try {
|
|
1918
|
+
cleanup();
|
|
1919
|
+
} finally {
|
|
1920
|
+
resetTracking();
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
const currentEffect = activeWatcher;
|
|
1924
|
+
activeWatcher = effect;
|
|
1925
|
+
try {
|
|
1926
|
+
return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
|
|
1927
|
+
} finally {
|
|
1928
|
+
activeWatcher = currentEffect;
|
|
1929
|
+
}
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1932
|
+
} else {
|
|
1933
|
+
getter = NOOP;
|
|
1934
|
+
}
|
|
1935
|
+
if (cb && deep) {
|
|
1936
|
+
const baseGetter = getter;
|
|
1937
|
+
const depth = deep === true ? Infinity : deep;
|
|
1938
|
+
getter = () => traverse(baseGetter(), depth);
|
|
1939
|
+
}
|
|
1940
|
+
if (once) {
|
|
1941
|
+
if (cb) {
|
|
1942
|
+
const _cb = cb;
|
|
1943
|
+
cb = (...args) => {
|
|
1944
|
+
_cb(...args);
|
|
1945
|
+
effect.stop();
|
|
1946
|
+
};
|
|
1947
|
+
} else {
|
|
1948
|
+
const _getter = getter;
|
|
1949
|
+
getter = () => {
|
|
1950
|
+
_getter();
|
|
1951
|
+
effect.stop();
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
|
1956
|
+
const job = (immediateFirstRun) => {
|
|
1957
|
+
if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
|
|
1958
|
+
return;
|
|
1959
|
+
}
|
|
1960
|
+
if (cb) {
|
|
1961
|
+
const newValue = effect.run();
|
|
1962
|
+
if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
|
|
1963
|
+
if (cleanup) {
|
|
1964
|
+
cleanup();
|
|
1965
|
+
}
|
|
1966
|
+
const currentWatcher = activeWatcher;
|
|
1967
|
+
activeWatcher = effect;
|
|
1968
|
+
try {
|
|
1969
|
+
const args = [
|
|
1970
|
+
newValue,
|
|
1971
|
+
// pass undefined as the old value when it's changed for the first time
|
|
1972
|
+
oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
|
1973
|
+
boundCleanup
|
|
1974
|
+
];
|
|
1975
|
+
call ? call(cb, 3, args) : (
|
|
1976
|
+
// @ts-expect-error
|
|
1977
|
+
cb(...args)
|
|
1978
|
+
);
|
|
1979
|
+
oldValue = newValue;
|
|
1980
|
+
} finally {
|
|
1981
|
+
activeWatcher = currentWatcher;
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
} else {
|
|
1985
|
+
effect.run();
|
|
1986
|
+
}
|
|
1987
|
+
};
|
|
1988
|
+
if (augmentJob) {
|
|
1989
|
+
augmentJob(job);
|
|
1990
|
+
}
|
|
1991
|
+
effect = new ReactiveEffect(getter);
|
|
1992
|
+
effect.scheduler = scheduler ? () => scheduler(job, false) : job;
|
|
1993
|
+
boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
|
|
1994
|
+
cleanup = effect.onStop = () => {
|
|
1995
|
+
const cleanups = cleanupMap.get(effect);
|
|
1996
|
+
if (cleanups) {
|
|
1997
|
+
if (call) {
|
|
1998
|
+
call(cleanups, 4);
|
|
1999
|
+
} else {
|
|
2000
|
+
for (const cleanup2 of cleanups) cleanup2();
|
|
2001
|
+
}
|
|
2002
|
+
cleanupMap.delete(effect);
|
|
2003
|
+
}
|
|
2004
|
+
};
|
|
2005
|
+
if (cb) {
|
|
2006
|
+
if (immediate) {
|
|
2007
|
+
job(true);
|
|
2008
|
+
} else {
|
|
2009
|
+
oldValue = effect.run();
|
|
2010
|
+
}
|
|
2011
|
+
} else if (scheduler) {
|
|
2012
|
+
scheduler(job.bind(null, true), true);
|
|
2013
|
+
} else {
|
|
2014
|
+
effect.run();
|
|
2015
|
+
}
|
|
2016
|
+
const scope = getCurrentScope();
|
|
2017
|
+
const watchHandle = () => {
|
|
2018
|
+
effect.stop();
|
|
2019
|
+
if (scope) {
|
|
2020
|
+
remove(scope.effects, effect);
|
|
2021
|
+
}
|
|
2022
|
+
};
|
|
2023
|
+
watchHandle.pause = effect.pause.bind(effect);
|
|
2024
|
+
watchHandle.resume = effect.resume.bind(effect);
|
|
2025
|
+
watchHandle.stop = watchHandle;
|
|
2026
|
+
return watchHandle;
|
|
2027
|
+
}
|
|
2028
|
+
function traverse(value, depth = Infinity, seen) {
|
|
2029
|
+
if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
|
|
2030
|
+
return value;
|
|
2031
|
+
}
|
|
2032
|
+
seen = seen || /* @__PURE__ */ new Set();
|
|
2033
|
+
if (seen.has(value)) {
|
|
2034
|
+
return value;
|
|
2035
|
+
}
|
|
2036
|
+
seen.add(value);
|
|
2037
|
+
depth--;
|
|
2038
|
+
if (isRef(value)) {
|
|
2039
|
+
traverse(value.value, depth, seen);
|
|
2040
|
+
} else if (isArray(value)) {
|
|
2041
|
+
for (let i = 0; i < value.length; i++) {
|
|
2042
|
+
traverse(value[i], depth, seen);
|
|
2043
|
+
}
|
|
2044
|
+
} else if (isSet(value) || isMap(value)) {
|
|
2045
|
+
value.forEach((v) => {
|
|
2046
|
+
traverse(v, depth, seen);
|
|
2047
|
+
});
|
|
2048
|
+
} else if (isPlainObject(value)) {
|
|
2049
|
+
for (const key in value) {
|
|
2050
|
+
traverse(value[key], depth, seen);
|
|
2051
|
+
}
|
|
2052
|
+
for (const key of Object.getOwnPropertySymbols(value)) {
|
|
2053
|
+
if (Object.prototype.propertyIsEnumerable.call(value, key)) {
|
|
2054
|
+
traverse(value[key], depth, seen);
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
return value;
|
|
2059
|
+
}
|
|
2060
|
+
|
|
1865
2061
|
function assertNumber(val, type) {
|
|
1866
2062
|
return;
|
|
1867
2063
|
}
|
|
@@ -1871,12 +2067,6 @@ const ErrorCodes = {
|
|
|
1871
2067
|
"0": "SETUP_FUNCTION",
|
|
1872
2068
|
"RENDER_FUNCTION": 1,
|
|
1873
2069
|
"1": "RENDER_FUNCTION",
|
|
1874
|
-
"WATCH_GETTER": 2,
|
|
1875
|
-
"2": "WATCH_GETTER",
|
|
1876
|
-
"WATCH_CALLBACK": 3,
|
|
1877
|
-
"3": "WATCH_CALLBACK",
|
|
1878
|
-
"WATCH_CLEANUP": 4,
|
|
1879
|
-
"4": "WATCH_CLEANUP",
|
|
1880
2070
|
"NATIVE_EVENT_HANDLER": 5,
|
|
1881
2071
|
"5": "NATIVE_EVENT_HANDLER",
|
|
1882
2072
|
"COMPONENT_EVENT_HANDLER": 6,
|
|
@@ -2013,7 +2203,7 @@ function nextTick(fn) {
|
|
|
2013
2203
|
return fn ? p.then(this ? fn.bind(this) : fn) : p;
|
|
2014
2204
|
}
|
|
2015
2205
|
function findInsertionIndex(id) {
|
|
2016
|
-
let start = flushIndex + 1;
|
|
2206
|
+
let start = isFlushing ? flushIndex + 1 : 0;
|
|
2017
2207
|
let end = queue.length;
|
|
2018
2208
|
while (start < end) {
|
|
2019
2209
|
const middle = start + end >>> 1;
|
|
@@ -2029,15 +2219,13 @@ function findInsertionIndex(id) {
|
|
|
2029
2219
|
}
|
|
2030
2220
|
function queueJob(job) {
|
|
2031
2221
|
if (!(job.flags & 1)) {
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
!(job.flags & 2) && job.id >= (queue[queue.length - 1] && queue[queue.length - 1].id || 0)
|
|
2037
|
-
) {
|
|
2222
|
+
const jobId = getId(job);
|
|
2223
|
+
const lastJob = queue[queue.length - 1];
|
|
2224
|
+
if (!lastJob || // fast path when the job id is larger than the tail
|
|
2225
|
+
!(job.flags & 2) && jobId >= getId(lastJob)) {
|
|
2038
2226
|
queue.push(job);
|
|
2039
2227
|
} else {
|
|
2040
|
-
queue.splice(findInsertionIndex(
|
|
2228
|
+
queue.splice(findInsertionIndex(jobId), 0, job);
|
|
2041
2229
|
}
|
|
2042
2230
|
if (!(job.flags & 4)) {
|
|
2043
2231
|
job.flags |= 1;
|
|
@@ -2051,12 +2239,6 @@ function queueFlush() {
|
|
|
2051
2239
|
currentFlushPromise = resolvedPromise.then(flushJobs);
|
|
2052
2240
|
}
|
|
2053
2241
|
}
|
|
2054
|
-
function invalidateJob(job) {
|
|
2055
|
-
const i = queue.indexOf(job);
|
|
2056
|
-
if (i > flushIndex) {
|
|
2057
|
-
queue.splice(i, 1);
|
|
2058
|
-
}
|
|
2059
|
-
}
|
|
2060
2242
|
function queuePostFlushCb(cb) {
|
|
2061
2243
|
if (!isArray(cb)) {
|
|
2062
2244
|
if (activePostFlushCbs && cb.id === -1) {
|
|
@@ -2106,21 +2288,10 @@ function flushPostFlushCbs(seen) {
|
|
|
2106
2288
|
postFlushIndex = 0;
|
|
2107
2289
|
}
|
|
2108
2290
|
}
|
|
2109
|
-
const getId = (job) => job.id == null ? Infinity : job.id;
|
|
2110
|
-
const comparator = (a, b) => {
|
|
2111
|
-
const diff = getId(a) - getId(b);
|
|
2112
|
-
if (diff === 0) {
|
|
2113
|
-
const isAPre = a.flags & 2;
|
|
2114
|
-
const isBPre = b.flags & 2;
|
|
2115
|
-
if (isAPre && !isBPre) return -1;
|
|
2116
|
-
if (isBPre && !isAPre) return 1;
|
|
2117
|
-
}
|
|
2118
|
-
return diff;
|
|
2119
|
-
};
|
|
2291
|
+
const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
|
|
2120
2292
|
function flushJobs(seen) {
|
|
2121
2293
|
isFlushPending = false;
|
|
2122
2294
|
isFlushing = true;
|
|
2123
|
-
queue.sort(comparator);
|
|
2124
2295
|
try {
|
|
2125
2296
|
for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
|
2126
2297
|
const job = queue[flushIndex];
|
|
@@ -2263,7 +2434,7 @@ function on(instance, event, fn) {
|
|
|
2263
2434
|
function once(instance, event, fn) {
|
|
2264
2435
|
const wrapped = (...args) => {
|
|
2265
2436
|
off(instance, event, wrapped);
|
|
2266
|
-
fn.
|
|
2437
|
+
fn.apply(instance.proxy, args);
|
|
2267
2438
|
};
|
|
2268
2439
|
wrapped.fn = fn;
|
|
2269
2440
|
on(instance, event, wrapped);
|
|
@@ -5301,21 +5472,41 @@ function callHook$1(hook, instance, type) {
|
|
|
5301
5472
|
);
|
|
5302
5473
|
}
|
|
5303
5474
|
function createWatcher(raw, ctx, publicThis, key) {
|
|
5304
|
-
|
|
5475
|
+
let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
|
|
5476
|
+
const options = {};
|
|
5477
|
+
{
|
|
5478
|
+
const instance = currentInstance && getCurrentScope() === currentInstance.scope ? currentInstance : null;
|
|
5479
|
+
const newValue = getter();
|
|
5480
|
+
if (isArray(newValue) && isCompatEnabled$1("WATCH_ARRAY", instance)) {
|
|
5481
|
+
options.deep = true;
|
|
5482
|
+
}
|
|
5483
|
+
const baseGetter = getter;
|
|
5484
|
+
getter = () => {
|
|
5485
|
+
const val = baseGetter();
|
|
5486
|
+
if (isArray(val) && checkCompatEnabled$1("WATCH_ARRAY", instance)) {
|
|
5487
|
+
traverse(val);
|
|
5488
|
+
}
|
|
5489
|
+
return val;
|
|
5490
|
+
};
|
|
5491
|
+
}
|
|
5305
5492
|
if (isString(raw)) {
|
|
5306
5493
|
const handler = ctx[raw];
|
|
5307
5494
|
if (isFunction(handler)) {
|
|
5308
|
-
|
|
5495
|
+
{
|
|
5496
|
+
watch(getter, handler, options);
|
|
5497
|
+
}
|
|
5309
5498
|
}
|
|
5310
5499
|
} else if (isFunction(raw)) {
|
|
5311
|
-
|
|
5500
|
+
{
|
|
5501
|
+
watch(getter, raw.bind(publicThis), options);
|
|
5502
|
+
}
|
|
5312
5503
|
} else if (isObject(raw)) {
|
|
5313
5504
|
if (isArray(raw)) {
|
|
5314
5505
|
raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
|
|
5315
5506
|
} else {
|
|
5316
5507
|
const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
|
|
5317
5508
|
if (isFunction(handler)) {
|
|
5318
|
-
watch(getter, handler, raw);
|
|
5509
|
+
watch(getter, handler, extend$1(raw, options) );
|
|
5319
5510
|
}
|
|
5320
5511
|
}
|
|
5321
5512
|
} else ;
|
|
@@ -5506,7 +5697,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
|
|
|
5506
5697
|
return vm;
|
|
5507
5698
|
}
|
|
5508
5699
|
}
|
|
5509
|
-
Vue.version = `2.6.14-compat:${"3.5.0-beta.
|
|
5700
|
+
Vue.version = `2.6.14-compat:${"3.5.0-beta.3"}`;
|
|
5510
5701
|
Vue.config = singletonApp.config;
|
|
5511
5702
|
Vue.use = (plugin, ...options) => {
|
|
5512
5703
|
if (plugin && isFunction(plugin.install)) {
|
|
@@ -5800,7 +5991,7 @@ function defineReactive(obj, key, val) {
|
|
|
5800
5991
|
if (isArray(val)) {
|
|
5801
5992
|
methodsToPatch.forEach((m) => {
|
|
5802
5993
|
val[m] = (...args) => {
|
|
5803
|
-
Array.prototype[m].
|
|
5994
|
+
Array.prototype[m].apply(reactiveVal, args);
|
|
5804
5995
|
};
|
|
5805
5996
|
});
|
|
5806
5997
|
} else {
|
|
@@ -6698,7 +6889,7 @@ function baseCreateRenderer(options, createHydrationFns) {
|
|
|
6698
6889
|
}
|
|
6699
6890
|
if (parentComponent) {
|
|
6700
6891
|
let subTree = parentComponent.subTree;
|
|
6701
|
-
if (vnode === subTree) {
|
|
6892
|
+
if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
|
|
6702
6893
|
const parentVNode = parentComponent.vnode;
|
|
6703
6894
|
setScopeId(
|
|
6704
6895
|
el,
|
|
@@ -6997,7 +7188,6 @@ function baseCreateRenderer(options, createHydrationFns) {
|
|
|
6997
7188
|
return;
|
|
6998
7189
|
} else {
|
|
6999
7190
|
instance.next = n2;
|
|
7000
|
-
invalidateJob(instance.update);
|
|
7001
7191
|
instance.update();
|
|
7002
7192
|
}
|
|
7003
7193
|
} else {
|
|
@@ -7840,178 +8030,57 @@ function watchSyncEffect(effect, options) {
|
|
|
7840
8030
|
{ flush: "sync" }
|
|
7841
8031
|
);
|
|
7842
8032
|
}
|
|
7843
|
-
const INITIAL_WATCHER_VALUE = {};
|
|
7844
8033
|
function watch(source, cb, options) {
|
|
7845
8034
|
return doWatch(source, cb, options);
|
|
7846
8035
|
}
|
|
7847
|
-
function doWatch(source, cb, {
|
|
7848
|
-
immediate,
|
|
7849
|
-
|
|
7850
|
-
flush,
|
|
7851
|
-
once,
|
|
7852
|
-
onTrack,
|
|
7853
|
-
onTrigger
|
|
7854
|
-
} = EMPTY_OBJ) {
|
|
7855
|
-
if (cb && once) {
|
|
7856
|
-
const _cb = cb;
|
|
7857
|
-
cb = (...args) => {
|
|
7858
|
-
_cb(...args);
|
|
7859
|
-
watchHandle();
|
|
7860
|
-
};
|
|
7861
|
-
}
|
|
7862
|
-
const instance = currentInstance;
|
|
7863
|
-
const reactiveGetter = (source2) => {
|
|
7864
|
-
if (deep) return source2;
|
|
7865
|
-
if (isShallow(source2) || deep === false || deep === 0)
|
|
7866
|
-
return traverse(source2, 1);
|
|
7867
|
-
return traverse(source2);
|
|
7868
|
-
};
|
|
7869
|
-
let getter;
|
|
7870
|
-
let forceTrigger = false;
|
|
7871
|
-
let isMultiSource = false;
|
|
7872
|
-
if (isRef(source)) {
|
|
7873
|
-
getter = () => source.value;
|
|
7874
|
-
forceTrigger = isShallow(source);
|
|
7875
|
-
} else if (isReactive(source)) {
|
|
7876
|
-
getter = () => reactiveGetter(source);
|
|
7877
|
-
forceTrigger = true;
|
|
7878
|
-
} else if (isArray(source)) {
|
|
7879
|
-
isMultiSource = true;
|
|
7880
|
-
forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
|
|
7881
|
-
getter = () => source.map((s) => {
|
|
7882
|
-
if (isRef(s)) {
|
|
7883
|
-
return s.value;
|
|
7884
|
-
} else if (isReactive(s)) {
|
|
7885
|
-
return reactiveGetter(s);
|
|
7886
|
-
} else if (isFunction(s)) {
|
|
7887
|
-
return callWithErrorHandling(s, instance, 2);
|
|
7888
|
-
} else ;
|
|
7889
|
-
});
|
|
7890
|
-
} else if (isFunction(source)) {
|
|
7891
|
-
if (cb) {
|
|
7892
|
-
getter = () => callWithErrorHandling(source, instance, 2);
|
|
7893
|
-
} else {
|
|
7894
|
-
getter = () => {
|
|
7895
|
-
if (cleanup) {
|
|
7896
|
-
cleanup();
|
|
7897
|
-
}
|
|
7898
|
-
return callWithAsyncErrorHandling(
|
|
7899
|
-
source,
|
|
7900
|
-
instance,
|
|
7901
|
-
3,
|
|
7902
|
-
[onCleanup]
|
|
7903
|
-
);
|
|
7904
|
-
};
|
|
7905
|
-
}
|
|
7906
|
-
} else {
|
|
7907
|
-
getter = NOOP;
|
|
7908
|
-
}
|
|
7909
|
-
if (cb && !deep) {
|
|
7910
|
-
const baseGetter = getter;
|
|
7911
|
-
getter = () => {
|
|
7912
|
-
const val = baseGetter();
|
|
7913
|
-
if (isArray(val) && checkCompatEnabled$1("WATCH_ARRAY", instance)) {
|
|
7914
|
-
traverse(val);
|
|
7915
|
-
}
|
|
7916
|
-
return val;
|
|
7917
|
-
};
|
|
7918
|
-
}
|
|
7919
|
-
if (cb && deep) {
|
|
7920
|
-
const baseGetter = getter;
|
|
7921
|
-
const depth = deep === true ? Infinity : deep;
|
|
7922
|
-
getter = () => traverse(baseGetter(), depth);
|
|
7923
|
-
}
|
|
7924
|
-
let cleanup;
|
|
7925
|
-
let onCleanup = (fn) => {
|
|
7926
|
-
cleanup = effect.onStop = () => {
|
|
7927
|
-
callWithErrorHandling(fn, instance, 4);
|
|
7928
|
-
cleanup = effect.onStop = void 0;
|
|
7929
|
-
};
|
|
7930
|
-
};
|
|
8036
|
+
function doWatch(source, cb, options = EMPTY_OBJ) {
|
|
8037
|
+
const { immediate, deep, flush, once } = options;
|
|
8038
|
+
const baseWatchOptions = extend$1({}, options);
|
|
7931
8039
|
let ssrCleanup;
|
|
7932
8040
|
if (isInSSRComponentSetup) {
|
|
7933
|
-
onCleanup = NOOP;
|
|
7934
|
-
if (!cb) {
|
|
7935
|
-
getter();
|
|
7936
|
-
} else if (immediate) {
|
|
7937
|
-
callWithAsyncErrorHandling(cb, instance, 3, [
|
|
7938
|
-
getter(),
|
|
7939
|
-
isMultiSource ? [] : void 0,
|
|
7940
|
-
onCleanup
|
|
7941
|
-
]);
|
|
7942
|
-
}
|
|
7943
8041
|
if (flush === "sync") {
|
|
7944
8042
|
const ctx = useSSRContext();
|
|
7945
8043
|
ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
|
|
8044
|
+
} else if (!cb || immediate) {
|
|
8045
|
+
baseWatchOptions.once = true;
|
|
7946
8046
|
} else {
|
|
7947
|
-
|
|
8047
|
+
return {
|
|
8048
|
+
stop: NOOP,
|
|
8049
|
+
resume: NOOP,
|
|
8050
|
+
pause: NOOP
|
|
7948
8051
|
};
|
|
7949
|
-
watchHandle2.stop = NOOP;
|
|
7950
|
-
watchHandle2.resume = NOOP;
|
|
7951
|
-
watchHandle2.pause = NOOP;
|
|
7952
|
-
return watchHandle2;
|
|
7953
8052
|
}
|
|
7954
8053
|
}
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
|
|
7962
|
-
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
|
7970
|
-
onCleanup
|
|
7971
|
-
]);
|
|
7972
|
-
oldValue = newValue;
|
|
8054
|
+
const instance = currentInstance;
|
|
8055
|
+
baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
|
|
8056
|
+
let isPre = false;
|
|
8057
|
+
if (flush === "post") {
|
|
8058
|
+
baseWatchOptions.scheduler = (job) => {
|
|
8059
|
+
queuePostRenderEffect(job, instance && instance.suspense);
|
|
8060
|
+
};
|
|
8061
|
+
} else if (flush !== "sync") {
|
|
8062
|
+
isPre = true;
|
|
8063
|
+
baseWatchOptions.scheduler = (job, isFirstRun) => {
|
|
8064
|
+
if (isFirstRun) {
|
|
8065
|
+
job();
|
|
8066
|
+
} else {
|
|
8067
|
+
queueJob(job);
|
|
7973
8068
|
}
|
|
7974
|
-
}
|
|
7975
|
-
effect.run();
|
|
7976
|
-
}
|
|
7977
|
-
};
|
|
7978
|
-
if (cb) job.flags |= 4;
|
|
7979
|
-
const effect = new ReactiveEffect(getter);
|
|
7980
|
-
let scheduler;
|
|
7981
|
-
if (flush === "sync") {
|
|
7982
|
-
scheduler = job;
|
|
7983
|
-
} else if (flush === "post") {
|
|
7984
|
-
scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
|
|
7985
|
-
} else {
|
|
7986
|
-
job.flags |= 2;
|
|
7987
|
-
if (instance) job.id = instance.uid;
|
|
7988
|
-
scheduler = () => queueJob(job);
|
|
8069
|
+
};
|
|
7989
8070
|
}
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
effect.stop();
|
|
7994
|
-
if (scope) {
|
|
7995
|
-
remove(scope.effects, effect);
|
|
8071
|
+
baseWatchOptions.augmentJob = (job) => {
|
|
8072
|
+
if (cb) {
|
|
8073
|
+
job.flags |= 4;
|
|
7996
8074
|
}
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
job(true);
|
|
8004
|
-
} else {
|
|
8005
|
-
oldValue = effect.run();
|
|
8075
|
+
if (isPre) {
|
|
8076
|
+
job.flags |= 2;
|
|
8077
|
+
if (instance) {
|
|
8078
|
+
job.id = instance.uid;
|
|
8079
|
+
job.i = instance;
|
|
8080
|
+
}
|
|
8006
8081
|
}
|
|
8007
|
-
}
|
|
8008
|
-
|
|
8009
|
-
effect.run.bind(effect),
|
|
8010
|
-
instance && instance.suspense
|
|
8011
|
-
);
|
|
8012
|
-
} else {
|
|
8013
|
-
effect.run();
|
|
8014
|
-
}
|
|
8082
|
+
};
|
|
8083
|
+
const watchHandle = watch$1(source, cb, baseWatchOptions);
|
|
8015
8084
|
if (ssrCleanup) ssrCleanup.push(watchHandle);
|
|
8016
8085
|
return watchHandle;
|
|
8017
8086
|
}
|
|
@@ -8040,38 +8109,6 @@ function createPathGetter(ctx, path) {
|
|
|
8040
8109
|
return cur;
|
|
8041
8110
|
};
|
|
8042
8111
|
}
|
|
8043
|
-
function traverse(value, depth = Infinity, seen) {
|
|
8044
|
-
if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
|
|
8045
|
-
return value;
|
|
8046
|
-
}
|
|
8047
|
-
seen = seen || /* @__PURE__ */ new Set();
|
|
8048
|
-
if (seen.has(value)) {
|
|
8049
|
-
return value;
|
|
8050
|
-
}
|
|
8051
|
-
seen.add(value);
|
|
8052
|
-
depth--;
|
|
8053
|
-
if (isRef(value)) {
|
|
8054
|
-
traverse(value.value, depth, seen);
|
|
8055
|
-
} else if (isArray(value)) {
|
|
8056
|
-
for (let i = 0; i < value.length; i++) {
|
|
8057
|
-
traverse(value[i], depth, seen);
|
|
8058
|
-
}
|
|
8059
|
-
} else if (isSet(value) || isMap(value)) {
|
|
8060
|
-
value.forEach((v) => {
|
|
8061
|
-
traverse(v, depth, seen);
|
|
8062
|
-
});
|
|
8063
|
-
} else if (isPlainObject(value)) {
|
|
8064
|
-
for (const key in value) {
|
|
8065
|
-
traverse(value[key], depth, seen);
|
|
8066
|
-
}
|
|
8067
|
-
for (const key of Object.getOwnPropertySymbols(value)) {
|
|
8068
|
-
if (Object.prototype.propertyIsEnumerable.call(value, key)) {
|
|
8069
|
-
traverse(value[key], depth, seen);
|
|
8070
|
-
}
|
|
8071
|
-
}
|
|
8072
|
-
}
|
|
8073
|
-
return value;
|
|
8074
|
-
}
|
|
8075
8112
|
|
|
8076
8113
|
function useModel(props, name, options = EMPTY_OBJ) {
|
|
8077
8114
|
const i = getCurrentInstance();
|
|
@@ -9796,7 +9833,7 @@ function isMemoSame(cached, memo) {
|
|
|
9796
9833
|
return true;
|
|
9797
9834
|
}
|
|
9798
9835
|
|
|
9799
|
-
const version = "3.5.0-beta.
|
|
9836
|
+
const version = "3.5.0-beta.3";
|
|
9800
9837
|
const warn$1 = NOOP;
|
|
9801
9838
|
const ErrorTypeStrings = ErrorTypeStrings$1 ;
|
|
9802
9839
|
const devtools = void 0;
|
|
@@ -11598,6 +11635,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
|
|
|
11598
11635
|
effectScope: effectScope,
|
|
11599
11636
|
getCurrentInstance: getCurrentInstance,
|
|
11600
11637
|
getCurrentScope: getCurrentScope,
|
|
11638
|
+
getCurrentWatcher: getCurrentWatcher,
|
|
11601
11639
|
getTransitionRawChildren: getTransitionRawChildren,
|
|
11602
11640
|
guardReactiveProps: guardReactiveProps,
|
|
11603
11641
|
h: h,
|
|
@@ -11640,6 +11678,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
|
|
|
11640
11678
|
onServerPrefetch: onServerPrefetch,
|
|
11641
11679
|
onUnmounted: onUnmounted,
|
|
11642
11680
|
onUpdated: onUpdated,
|
|
11681
|
+
onWatcherCleanup: onWatcherCleanup,
|
|
11643
11682
|
openBlock: openBlock,
|
|
11644
11683
|
popScopeId: popScopeId,
|
|
11645
11684
|
provide: provide,
|
|
@@ -13153,6 +13192,9 @@ const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || no
|
|
|
13153
13192
|
const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
|
|
13154
13193
|
function isReferenced(node, parent, grandparent) {
|
|
13155
13194
|
switch (parent.type) {
|
|
13195
|
+
// yes: PARENT[NODE]
|
|
13196
|
+
// yes: NODE.child
|
|
13197
|
+
// no: parent.NODE
|
|
13156
13198
|
case "MemberExpression":
|
|
13157
13199
|
case "OptionalMemberExpression":
|
|
13158
13200
|
if (parent.property === node) {
|
|
@@ -13161,12 +13203,23 @@ function isReferenced(node, parent, grandparent) {
|
|
|
13161
13203
|
return parent.object === node;
|
|
13162
13204
|
case "JSXMemberExpression":
|
|
13163
13205
|
return parent.object === node;
|
|
13206
|
+
// no: let NODE = init;
|
|
13207
|
+
// yes: let id = NODE;
|
|
13164
13208
|
case "VariableDeclarator":
|
|
13165
13209
|
return parent.init === node;
|
|
13210
|
+
// yes: () => NODE
|
|
13211
|
+
// no: (NODE) => {}
|
|
13166
13212
|
case "ArrowFunctionExpression":
|
|
13167
13213
|
return parent.body === node;
|
|
13214
|
+
// no: class { #NODE; }
|
|
13215
|
+
// no: class { get #NODE() {} }
|
|
13216
|
+
// no: class { #NODE() {} }
|
|
13217
|
+
// no: class { fn() { return this.#NODE; } }
|
|
13168
13218
|
case "PrivateName":
|
|
13169
13219
|
return false;
|
|
13220
|
+
// no: class { NODE() {} }
|
|
13221
|
+
// yes: class { [NODE]() {} }
|
|
13222
|
+
// no: class { foo(NODE) {} }
|
|
13170
13223
|
case "ClassMethod":
|
|
13171
13224
|
case "ClassPrivateMethod":
|
|
13172
13225
|
case "ObjectMethod":
|
|
@@ -13174,11 +13227,18 @@ function isReferenced(node, parent, grandparent) {
|
|
|
13174
13227
|
return !!parent.computed;
|
|
13175
13228
|
}
|
|
13176
13229
|
return false;
|
|
13230
|
+
// yes: { [NODE]: "" }
|
|
13231
|
+
// no: { NODE: "" }
|
|
13232
|
+
// depends: { NODE }
|
|
13233
|
+
// depends: { key: NODE }
|
|
13177
13234
|
case "ObjectProperty":
|
|
13178
13235
|
if (parent.key === node) {
|
|
13179
13236
|
return !!parent.computed;
|
|
13180
13237
|
}
|
|
13181
13238
|
return !grandparent;
|
|
13239
|
+
// no: class { NODE = value; }
|
|
13240
|
+
// yes: class { [NODE] = value; }
|
|
13241
|
+
// yes: class { key = NODE; }
|
|
13182
13242
|
case "ClassProperty":
|
|
13183
13243
|
if (parent.key === node) {
|
|
13184
13244
|
return !!parent.computed;
|
|
@@ -13186,47 +13246,80 @@ function isReferenced(node, parent, grandparent) {
|
|
|
13186
13246
|
return true;
|
|
13187
13247
|
case "ClassPrivateProperty":
|
|
13188
13248
|
return parent.key !== node;
|
|
13249
|
+
// no: class NODE {}
|
|
13250
|
+
// yes: class Foo extends NODE {}
|
|
13189
13251
|
case "ClassDeclaration":
|
|
13190
13252
|
case "ClassExpression":
|
|
13191
13253
|
return parent.superClass === node;
|
|
13254
|
+
// yes: left = NODE;
|
|
13255
|
+
// no: NODE = right;
|
|
13192
13256
|
case "AssignmentExpression":
|
|
13193
13257
|
return parent.right === node;
|
|
13258
|
+
// no: [NODE = foo] = [];
|
|
13259
|
+
// yes: [foo = NODE] = [];
|
|
13194
13260
|
case "AssignmentPattern":
|
|
13195
13261
|
return parent.right === node;
|
|
13262
|
+
// no: NODE: for (;;) {}
|
|
13196
13263
|
case "LabeledStatement":
|
|
13197
13264
|
return false;
|
|
13265
|
+
// no: try {} catch (NODE) {}
|
|
13198
13266
|
case "CatchClause":
|
|
13199
13267
|
return false;
|
|
13268
|
+
// no: function foo(...NODE) {}
|
|
13200
13269
|
case "RestElement":
|
|
13201
13270
|
return false;
|
|
13202
13271
|
case "BreakStatement":
|
|
13203
13272
|
case "ContinueStatement":
|
|
13204
13273
|
return false;
|
|
13274
|
+
// no: function NODE() {}
|
|
13275
|
+
// no: function foo(NODE) {}
|
|
13205
13276
|
case "FunctionDeclaration":
|
|
13206
13277
|
case "FunctionExpression":
|
|
13207
13278
|
return false;
|
|
13279
|
+
// no: export NODE from "foo";
|
|
13280
|
+
// no: export * as NODE from "foo";
|
|
13208
13281
|
case "ExportNamespaceSpecifier":
|
|
13209
13282
|
case "ExportDefaultSpecifier":
|
|
13210
13283
|
return false;
|
|
13284
|
+
// no: export { foo as NODE };
|
|
13285
|
+
// yes: export { NODE as foo };
|
|
13286
|
+
// no: export { NODE as foo } from "foo";
|
|
13211
13287
|
case "ExportSpecifier":
|
|
13212
13288
|
return parent.local === node;
|
|
13289
|
+
// no: import NODE from "foo";
|
|
13290
|
+
// no: import * as NODE from "foo";
|
|
13291
|
+
// no: import { NODE as foo } from "foo";
|
|
13292
|
+
// no: import { foo as NODE } from "foo";
|
|
13293
|
+
// no: import NODE from "bar";
|
|
13213
13294
|
case "ImportDefaultSpecifier":
|
|
13214
13295
|
case "ImportNamespaceSpecifier":
|
|
13215
13296
|
case "ImportSpecifier":
|
|
13216
13297
|
return false;
|
|
13298
|
+
// no: import "foo" assert { NODE: "json" }
|
|
13217
13299
|
case "ImportAttribute":
|
|
13218
13300
|
return false;
|
|
13301
|
+
// no: <div NODE="foo" />
|
|
13219
13302
|
case "JSXAttribute":
|
|
13220
13303
|
return false;
|
|
13304
|
+
// no: [NODE] = [];
|
|
13305
|
+
// no: ({ NODE }) = [];
|
|
13221
13306
|
case "ObjectPattern":
|
|
13222
13307
|
case "ArrayPattern":
|
|
13223
13308
|
return false;
|
|
13309
|
+
// no: new.NODE
|
|
13310
|
+
// no: NODE.target
|
|
13224
13311
|
case "MetaProperty":
|
|
13225
13312
|
return false;
|
|
13313
|
+
// yes: type X = { someProperty: NODE }
|
|
13314
|
+
// no: type X = { NODE: OtherType }
|
|
13226
13315
|
case "ObjectTypeProperty":
|
|
13227
13316
|
return parent.key !== node;
|
|
13317
|
+
// yes: enum X { Foo = NODE }
|
|
13318
|
+
// no: enum X { NODE }
|
|
13228
13319
|
case "TSEnumMember":
|
|
13229
13320
|
return parent.id !== node;
|
|
13321
|
+
// yes: { [NODE]: value }
|
|
13322
|
+
// no: { NODE: value }
|
|
13230
13323
|
case "TSPropertySignature":
|
|
13231
13324
|
if (parent.key === node) {
|
|
13232
13325
|
return !!parent.computed;
|
|
@@ -13814,7 +13907,9 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
13814
13907
|
case 17:
|
|
13815
13908
|
case 18:
|
|
13816
13909
|
case 19:
|
|
13910
|
+
// "
|
|
13817
13911
|
case 20:
|
|
13912
|
+
// '
|
|
13818
13913
|
case 21:
|
|
13819
13914
|
emitError(9, end);
|
|
13820
13915
|
break;
|
|
@@ -14784,6 +14879,7 @@ function traverseNode(node, context) {
|
|
|
14784
14879
|
context.helper(TO_DISPLAY_STRING);
|
|
14785
14880
|
}
|
|
14786
14881
|
break;
|
|
14882
|
+
// for container types, further traverse downwards
|
|
14787
14883
|
case 9:
|
|
14788
14884
|
for (let i2 = 0; i2 < node.branches.length; i2++) {
|
|
14789
14885
|
traverseNode(node.branches[i2], context);
|
|
@@ -15260,6 +15356,7 @@ function genNode(node, context) {
|
|
|
15260
15356
|
case 21:
|
|
15261
15357
|
genNodeList(node.body, context, true, false);
|
|
15262
15358
|
break;
|
|
15359
|
+
// SSR only types
|
|
15263
15360
|
case 22:
|
|
15264
15361
|
genTemplateLiteral(node, context);
|
|
15265
15362
|
break;
|
|
@@ -17633,27 +17730,35 @@ function parseFilter(node, context) {
|
|
|
17633
17730
|
case 34:
|
|
17634
17731
|
inDouble = true;
|
|
17635
17732
|
break;
|
|
17733
|
+
// "
|
|
17636
17734
|
case 39:
|
|
17637
17735
|
inSingle = true;
|
|
17638
17736
|
break;
|
|
17737
|
+
// '
|
|
17639
17738
|
case 96:
|
|
17640
17739
|
inTemplateString = true;
|
|
17641
17740
|
break;
|
|
17741
|
+
// `
|
|
17642
17742
|
case 40:
|
|
17643
17743
|
paren++;
|
|
17644
17744
|
break;
|
|
17745
|
+
// (
|
|
17645
17746
|
case 41:
|
|
17646
17747
|
paren--;
|
|
17647
17748
|
break;
|
|
17749
|
+
// )
|
|
17648
17750
|
case 91:
|
|
17649
17751
|
square++;
|
|
17650
17752
|
break;
|
|
17753
|
+
// [
|
|
17651
17754
|
case 93:
|
|
17652
17755
|
square--;
|
|
17653
17756
|
break;
|
|
17757
|
+
// ]
|
|
17654
17758
|
case 123:
|
|
17655
17759
|
curly++;
|
|
17656
17760
|
break;
|
|
17761
|
+
// {
|
|
17657
17762
|
case 125:
|
|
17658
17763
|
curly--;
|
|
17659
17764
|
break;
|