@dcloudio/uni-mp-vue 3.0.0-alpha-3030820220114005 → 3.0.0-alpha-3030820220114007

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.
@@ -1,4 +1,4 @@
1
- import { extend, isSymbol, isObject, toRawType, def, hasChanged, isArray, isString, isFunction, isPromise, remove, EMPTY_OBJ, toHandlerKey, hasOwn, camelize, hyphenate, isReservedProp, capitalize, normalizeClass, normalizeStyle, isOn, NOOP, toTypeString, isMap, isIntegerKey, isSet, isPlainObject, makeMap, invokeArrayFns, NO, toNumber, EMPTY_ARR, stringifyStyle as stringifyStyle$1, toDisplayString } from '@vue/shared';
1
+ import { extend, isSymbol, isObject, toRawType, def, hasChanged, isArray, isString, isFunction, isPromise, remove, EMPTY_OBJ, toHandlerKey, hasOwn, camelize, hyphenate, isReservedProp, capitalize, normalizeClass, normalizeStyle, isOn, NOOP, toTypeString, isMap, isIntegerKey, isSet, isPlainObject, makeMap, invokeArrayFns, isBuiltInDirective, NO, toNumber, EMPTY_ARR, stringifyStyle as stringifyStyle$1, toDisplayString } from '@vue/shared';
2
2
  export { EMPTY_OBJ, camelize, normalizeClass, normalizeProps, normalizeStyle, toDisplayString, toHandlerKey } from '@vue/shared';
3
3
  import { isRootHook, getValueByDataPath, ON_ERROR, UniLifecycleHooks, dynamicSlotName } from '@dcloudio/uni-shared';
4
4
 
@@ -7,7 +7,6 @@ function warn(msg, ...args) {
7
7
  }
8
8
 
9
9
  let activeEffectScope;
10
- const effectScopeStack = [];
11
10
  class EffectScope {
12
11
  constructor(detached = false) {
13
12
  this.active = true;
@@ -22,11 +21,11 @@ class EffectScope {
22
21
  run(fn) {
23
22
  if (this.active) {
24
23
  try {
25
- this.on();
24
+ activeEffectScope = this;
26
25
  return fn();
27
26
  }
28
27
  finally {
29
- this.off();
28
+ activeEffectScope = this.parent;
30
29
  }
31
30
  }
32
31
  else if ((process.env.NODE_ENV !== 'production')) {
@@ -34,23 +33,24 @@ class EffectScope {
34
33
  }
35
34
  }
36
35
  on() {
37
- if (this.active) {
38
- effectScopeStack.push(this);
39
- activeEffectScope = this;
40
- }
36
+ activeEffectScope = this;
41
37
  }
42
38
  off() {
43
- if (this.active) {
44
- effectScopeStack.pop();
45
- activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
46
- }
39
+ activeEffectScope = this.parent;
47
40
  }
48
41
  stop(fromParent) {
49
42
  if (this.active) {
50
- this.effects.forEach(e => e.stop());
51
- this.cleanups.forEach(cleanup => cleanup());
43
+ let i, l;
44
+ for (i = 0, l = this.effects.length; i < l; i++) {
45
+ this.effects[i].stop();
46
+ }
47
+ for (i = 0, l = this.cleanups.length; i < l; i++) {
48
+ this.cleanups[i]();
49
+ }
52
50
  if (this.scopes) {
53
- this.scopes.forEach(e => e.stop(true));
51
+ for (i = 0, l = this.scopes.length; i < l; i++) {
52
+ this.scopes[i].stop(true);
53
+ }
54
54
  }
55
55
  // nested scope, dereference from parent to avoid memory leaks
56
56
  if (this.parent && !fromParent) {
@@ -68,8 +68,7 @@ class EffectScope {
68
68
  function effectScope(detached) {
69
69
  return new EffectScope(detached);
70
70
  }
71
- function recordEffectScope(effect, scope) {
72
- scope = scope || activeEffectScope;
71
+ function recordEffectScope(effect, scope = activeEffectScope) {
73
72
  if (scope && scope.active) {
74
73
  scope.effects.push(effect);
75
74
  }
@@ -132,7 +131,6 @@ let trackOpBit = 1;
132
131
  * When recursion depth is greater, fall back to using a full cleanup.
133
132
  */
134
133
  const maxMarkerBits = 30;
135
- const effectStack = [];
136
134
  let activeEffect;
137
135
  const ITERATE_KEY = Symbol((process.env.NODE_ENV !== 'production') ? 'iterate' : '');
138
136
  const MAP_KEY_ITERATE_KEY = Symbol((process.env.NODE_ENV !== 'production') ? 'Map key iterate' : '');
@@ -142,35 +140,42 @@ class ReactiveEffect {
142
140
  this.scheduler = scheduler;
143
141
  this.active = true;
144
142
  this.deps = [];
143
+ this.parent = undefined;
145
144
  recordEffectScope(this, scope);
146
145
  }
147
146
  run() {
148
147
  if (!this.active) {
149
148
  return this.fn();
150
149
  }
151
- if (!effectStack.includes(this)) {
152
- try {
153
- effectStack.push((activeEffect = this));
154
- enableTracking();
155
- trackOpBit = 1 << ++effectTrackDepth;
156
- if (effectTrackDepth <= maxMarkerBits) {
157
- initDepMarkers(this);
158
- }
159
- else {
160
- cleanupEffect(this);
161
- }
162
- return this.fn();
150
+ let parent = activeEffect;
151
+ let lastShouldTrack = shouldTrack;
152
+ while (parent) {
153
+ if (parent === this) {
154
+ return;
163
155
  }
164
- finally {
165
- if (effectTrackDepth <= maxMarkerBits) {
166
- finalizeDepMarkers(this);
167
- }
168
- trackOpBit = 1 << --effectTrackDepth;
169
- resetTracking();
170
- effectStack.pop();
171
- const n = effectStack.length;
172
- activeEffect = n > 0 ? effectStack[n - 1] : undefined;
156
+ parent = parent.parent;
157
+ }
158
+ try {
159
+ this.parent = activeEffect;
160
+ activeEffect = this;
161
+ shouldTrack = true;
162
+ trackOpBit = 1 << ++effectTrackDepth;
163
+ if (effectTrackDepth <= maxMarkerBits) {
164
+ initDepMarkers(this);
165
+ }
166
+ else {
167
+ cleanupEffect(this);
168
+ }
169
+ return this.fn();
170
+ }
171
+ finally {
172
+ if (effectTrackDepth <= maxMarkerBits) {
173
+ finalizeDepMarkers(this);
173
174
  }
175
+ trackOpBit = 1 << --effectTrackDepth;
176
+ activeEffect = this.parent;
177
+ shouldTrack = lastShouldTrack;
178
+ this.parent = undefined;
174
179
  }
175
180
  }
176
181
  stop() {
@@ -218,33 +223,25 @@ function pauseTracking() {
218
223
  trackStack.push(shouldTrack);
219
224
  shouldTrack = false;
220
225
  }
221
- function enableTracking() {
222
- trackStack.push(shouldTrack);
223
- shouldTrack = true;
224
- }
225
226
  function resetTracking() {
226
227
  const last = trackStack.pop();
227
228
  shouldTrack = last === undefined ? true : last;
228
229
  }
229
230
  function track(target, type, key) {
230
- if (!isTracking()) {
231
- return;
232
- }
233
- let depsMap = targetMap.get(target);
234
- if (!depsMap) {
235
- targetMap.set(target, (depsMap = new Map()));
236
- }
237
- let dep = depsMap.get(key);
238
- if (!dep) {
239
- depsMap.set(key, (dep = createDep()));
231
+ if (shouldTrack && activeEffect) {
232
+ let depsMap = targetMap.get(target);
233
+ if (!depsMap) {
234
+ targetMap.set(target, (depsMap = new Map()));
235
+ }
236
+ let dep = depsMap.get(key);
237
+ if (!dep) {
238
+ depsMap.set(key, (dep = createDep()));
239
+ }
240
+ const eventInfo = (process.env.NODE_ENV !== 'production')
241
+ ? { effect: activeEffect, target, type, key }
242
+ : undefined;
243
+ trackEffects(dep, eventInfo);
240
244
  }
241
- const eventInfo = (process.env.NODE_ENV !== 'production')
242
- ? { effect: activeEffect, target, type, key }
243
- : undefined;
244
- trackEffects(dep, eventInfo);
245
- }
246
- function isTracking() {
247
- return shouldTrack && activeEffect !== undefined;
248
245
  }
249
246
  function trackEffects(dep, debuggerEventExtraInfo) {
250
247
  let shouldTrack = false;
@@ -459,6 +456,9 @@ const shallowSet = /*#__PURE__*/ createSetter(true);
459
456
  function createSetter(shallow = false) {
460
457
  return function set(target, key, value, receiver) {
461
458
  let oldValue = target[key];
459
+ if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
460
+ return false;
461
+ }
462
462
  if (!shallow && !isReadonly(value)) {
463
463
  if (!isShallow(value)) {
464
464
  value = toRaw(value);
@@ -934,20 +934,17 @@ const toReactive = (value) => isObject(value) ? reactive(value) : value;
934
934
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
935
935
 
936
936
  function trackRefValue(ref) {
937
- if (isTracking()) {
937
+ if (shouldTrack && activeEffect) {
938
938
  ref = toRaw(ref);
939
- if (!ref.dep) {
940
- ref.dep = createDep();
941
- }
942
939
  if ((process.env.NODE_ENV !== 'production')) {
943
- trackEffects(ref.dep, {
940
+ trackEffects(ref.dep || (ref.dep = createDep()), {
944
941
  target: ref,
945
942
  type: "get" /* GET */,
946
943
  key: 'value'
947
944
  });
948
945
  }
949
946
  else {
950
- trackEffects(ref.dep);
947
+ trackEffects(ref.dep || (ref.dep = createDep()));
951
948
  }
952
949
  }
953
950
  }
@@ -968,7 +965,7 @@ function triggerRefValue(ref, newVal) {
968
965
  }
969
966
  }
970
967
  function isRef(r) {
971
- return Boolean(r && r.__v_isRef === true);
968
+ return !!(r && r.__v_isRef === true);
972
969
  }
973
970
  function ref(value) {
974
971
  return createRef(value, false);
@@ -1081,22 +1078,23 @@ class ComputedRefImpl {
1081
1078
  constructor(getter, _setter, isReadonly, isSSR) {
1082
1079
  this._setter = _setter;
1083
1080
  this.dep = undefined;
1084
- this._dirty = true;
1085
1081
  this.__v_isRef = true;
1082
+ this._dirty = true;
1086
1083
  this.effect = new ReactiveEffect(getter, () => {
1087
1084
  if (!this._dirty) {
1088
1085
  this._dirty = true;
1089
1086
  triggerRefValue(this);
1090
1087
  }
1091
1088
  });
1092
- this.effect.active = !isSSR;
1089
+ this.effect.computed = this;
1090
+ this.effect.active = this._cacheable = !isSSR;
1093
1091
  this["__v_isReadonly" /* IS_READONLY */] = isReadonly;
1094
1092
  }
1095
1093
  get value() {
1096
1094
  // the computed ref may get wrapped by other proxies e.g. readonly() #3376
1097
1095
  const self = toRaw(this);
1098
1096
  trackRefValue(self);
1099
- if (self._dirty) {
1097
+ if (self._dirty || !self._cacheable) {
1100
1098
  self._dirty = false;
1101
1099
  self._value = self.effect.run();
1102
1100
  }
@@ -1274,7 +1272,7 @@ const ErrorTypeStrings = {
1274
1272
  [12 /* FUNCTION_REF */]: 'ref function',
1275
1273
  [13 /* ASYNC_COMPONENT_LOADER */]: 'async component loader',
1276
1274
  [14 /* SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
1277
- 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next'
1275
+ 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core'
1278
1276
  };
1279
1277
  function callWithErrorHandling(fn, instance, type, args) {
1280
1278
  let res;
@@ -1409,10 +1407,17 @@ function queueJob(job) {
1409
1407
  queueFlush();
1410
1408
  }
1411
1409
  }
1410
+ // fixed by xxxxxx
1411
+ function sleep(ms) {
1412
+ return () => {
1413
+ return new Promise(resolve => setTimeout(() => resolve(void 0), ms));
1414
+ };
1415
+ }
1412
1416
  function queueFlush() {
1413
1417
  if (!isFlushing && !isFlushPending) {
1414
1418
  isFlushPending = true;
1415
- currentFlushPromise = resolvedPromise.then(flushJobs);
1419
+ // fixed by xxxxxx 延迟执行,避免同一批次的事件执行时机不正确,对性能可能有略微影响 https://github.com/dcloudio/uni-app/issues/3228
1420
+ currentFlushPromise = resolvedPromise.then(sleep(0)).then(flushJobs);
1416
1421
  }
1417
1422
  }
1418
1423
  function invalidateJob(job) {
@@ -1804,7 +1809,7 @@ function inject(key, defaultValue, treatDefaultAsFactory = false) {
1804
1809
  if (instance) {
1805
1810
  // #2400
1806
1811
  // to support `app.use` plugins,
1807
- // fallback to appContext's `provides` if the intance is at root
1812
+ // fallback to appContext's `provides` if the instance is at root
1808
1813
  const provides = instance.parent == null
1809
1814
  ? instance.vnode.appContext && instance.vnode.appContext.provides
1810
1815
  : instance.parent.provides;
@@ -2323,7 +2328,7 @@ function applyOptions$1(instance) {
2323
2328
  warn$1(`Write operation failed: computed property "${key}" is readonly.`);
2324
2329
  }
2325
2330
  : NOOP;
2326
- const c = computed({
2331
+ const c = computed$1({
2327
2332
  get,
2328
2333
  set
2329
2334
  });
@@ -2741,7 +2746,9 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
2741
2746
  // attrs point to the same object so it should already have been updated.
2742
2747
  if (attrs !== rawCurrentProps) {
2743
2748
  for (const key in attrs) {
2744
- if (!rawProps || !hasOwn(rawProps, key)) {
2749
+ if (!rawProps ||
2750
+ (!hasOwn(rawProps, key) &&
2751
+ (!false ))) {
2745
2752
  delete attrs[key];
2746
2753
  hasAttrsChanged = true;
2747
2754
  }
@@ -3073,7 +3080,6 @@ return withDirectives(h(comp), [
3073
3080
  [bar, this.y]
3074
3081
  ])
3075
3082
  */
3076
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
3077
3083
  function validateDirectiveName(name) {
3078
3084
  if (isBuiltInDirective(name)) {
3079
3085
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -3510,7 +3516,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
3510
3516
  shapeFlag: vnode.shapeFlag,
3511
3517
  // if the vnode is cloned with extra props, we can no longer assume its
3512
3518
  // existing patch flag to be reliable and need to add the FULL_PROPS flag.
3513
- // note: perserve flag for fragments since they use the flag for children
3519
+ // note: preserve flag for fragments since they use the flag for children
3514
3520
  // fast paths only.
3515
3521
  patchFlag: extraProps && vnode.type !== Fragment
3516
3522
  ? patchFlag === -1 // hoisted node
@@ -3626,7 +3632,8 @@ function mergeProps(...args) {
3626
3632
  else if (isOn(key)) {
3627
3633
  const existing = ret[key];
3628
3634
  const incoming = toMerge[key];
3629
- if (existing !== incoming &&
3635
+ if (incoming &&
3636
+ existing !== incoming &&
3630
3637
  !(isArray(existing) && existing.includes(incoming))) {
3631
3638
  ret[key] = existing
3632
3639
  ? [].concat(existing, incoming)
@@ -4283,7 +4290,7 @@ function defineEmits() {
4283
4290
  * instance properties when it is accessed by a parent component via template
4284
4291
  * refs.
4285
4292
  *
4286
- * `<script setup>` components are closed by default - i.e. varaibles inside
4293
+ * `<script setup>` components are closed by default - i.e. variables inside
4287
4294
  * the `<script setup>` scope is not exposed to parent unless explicitly exposed
4288
4295
  * via `defineExpose`.
4289
4296
  *
@@ -4408,7 +4415,7 @@ const useSSRContext = () => {
4408
4415
  };
4409
4416
 
4410
4417
  // Core API ------------------------------------------------------------------
4411
- const version = "3.2.27";
4418
+ const version = "3.2.30";
4412
4419
  /**
4413
4420
  * @internal only exposed in compat builds
4414
4421
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-mp-vue",
3
- "version": "3.0.0-alpha-3030820220114005",
3
+ "version": "3.0.0-alpha-3030820220114007",
4
4
  "description": "@dcloudio/uni-mp-vue",
5
5
  "main": "dist/vue.runtime.esm.js",
6
6
  "module": "dist/vue.runtime.esm.js",
@@ -19,6 +19,6 @@
19
19
  },
20
20
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
21
21
  "devDependencies": {
22
- "@dcloudio/uni-mp-vue": "3.0.0-alpha-3030820220114005"
22
+ "@dcloudio/uni-mp-vue": "3.0.0-alpha-3030820220114007"
23
23
  }
24
24
  }