From 2afaf4507127b8190c2e1aee8e35bdce3a29235b Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 10 Dec 2021 15:41:34 +0800 Subject: [PATCH 1/4] =?UTF-8?q?KERNEL-9882=20=E5=9F=BA=E7=A1=80=E8=89=B2?= =?UTF-8?q?=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/less/lib/colors.less | 53 -------------------- src/less/lib/constant.less | 99 ++++++++++++++++++++++++++++++++------ 2 files changed, 84 insertions(+), 68 deletions(-) diff --git a/src/less/lib/colors.less b/src/less/lib/colors.less index 81f9e5197..6ce390b70 100644 --- a/src/less/lib/colors.less +++ b/src/less/lib/colors.less @@ -126,56 +126,3 @@ @color-bi-border-warning: @border-color-warning; //边框提亮 @color-bi-border-highlight: @border-color-highlight; - -//颜色百分比 -//green -@color-bi-green-80: fade(@font-color-success, 80); -@color-bi-green-60: fade(@font-color-success, 60); -@color-bi-green-40: fade(@font-color-success, 40); -@color-bi-green-30: fade(@font-color-success, 30); -@color-bi-green-20: fade(@font-color-success, 20); -@color-bi-green-10: fade(@font-color-success, 10); -@color-bi-green-5: fade(@font-color-success, 5); - -//blue -@color-bi-blue-80: fade(@font-color-highlight, 80); -@color-bi-blue-60: fade(@font-color-highlight, 60); -@color-bi-blue-40: fade(@font-color-highlight, 40); -@color-bi-blue-30: fade(@font-color-highlight, 30); -@color-bi-blue-20: fade(@font-color-highlight, 20); -@color-bi-blue-10: fade(@font-color-highlight, 10); -@color-bi-blue-5: fade(@font-color-highlight, 5); - -//light-blue -@color-bi-light-blue-80: fade(@font-color-light-highlight, 80); -@color-bi-light-blue-60: fade(@font-color-light-highlight, 60); -@color-bi-light-blue-40: fade(@font-color-light-highlight, 40); -@color-bi-light-blue-30: fade(@font-color-light-highlight, 30); -@color-bi-light-blue-20: fade(@font-color-light-highlight, 20); -@color-bi-light-blue-10: fade(@font-color-light-highlight, 10); -@color-bi-light-blue-5: fade(@font-color-light-highlight, 5); - -// orange -@color-bi-orange-80: fade(@font-color-warning, 80); -@color-bi-orange-60: fade(@font-color-warning, 60); -@color-bi-orange-40: fade(@font-color-warning, 40); -@color-bi-orange-30: fade(@font-color-warning, 30); -@color-bi-orange-20: fade(@font-color-warning, 20); -@color-bi-orange-10: fade(@font-color-warning, 10); -@color-bi-orange-5: fade(@font-color-warning, 5); - -// red -@color-bi-red-80: fade(@font-color-negative, 80); -@color-bi-red-60: fade(@font-color-negative, 60); -@color-bi-red-40: fade(@font-color-negative, 40); -@color-bi-red-30: fade(@font-color-negative, 30); -@color-bi-red-20: fade(@font-color-negative, 20); -@color-bi-red-10: fade(@font-color-negative, 10); -@color-bi-red-5: fade(@font-color-negative, 5); - -// yellow -@color-bi-yellow-80: fade(@font-color-yellow, 90); -@color-bi-yellow-60: fade(@font-color-yellow, 60); -@color-bi-yellow-40: fade(@font-color-yellow, 40); -@color-bi-yellow-20: fade(@font-color-yellow, 20); -@color-bi-yellow-5: fade(@font-color-yellow, 5); diff --git a/src/less/lib/constant.less b/src/less/lib/constant.less index 4d99501bf..ecea10f85 100644 --- a/src/less/lib/constant.less +++ b/src/less/lib/constant.less @@ -20,6 +20,75 @@ @opacity-15: 0.15; @opacity-20: 0.2; +//色板 +//green +@color-bi-green-100: #13cd66; +@color-bi-green-80: fade(@color-bi-green-100, 80); +@color-bi-green-60: fade(@color-bi-green-100, 60); +@color-bi-green-40: fade(@color-bi-green-100, 40); +@color-bi-green-30: fade(@color-bi-green-100, 30); +@color-bi-green-20: fade(@color-bi-green-100, 20); +@color-bi-green-10: fade(@color-bi-green-100, 10); +@color-bi-green-5: fade(@color-bi-green-100, 5); + +//cyan +@color-bi-green-100: #13cd66; +@color-bi-green-80: fade(@color-bi-green-100, 80); +@color-bi-green-60: fade(@color-bi-green-100, 60); +@color-bi-green-40: fade(@color-bi-green-100, 40); +@color-bi-green-30: fade(@color-bi-green-100, 30); +@color-bi-green-20: fade(@color-bi-green-100, 20); +@color-bi-green-10: fade(@color-bi-green-100, 10); +@color-bi-green-5: fade(@color-bi-green-100, 5); + +//blue +@color-bi-blue-100: #3685f2; +@color-bi-blue-80: fade(@color-bi-blue-100, 80); +@color-bi-blue-60: fade(@color-bi-blue-100, 60); +@color-bi-blue-40: fade(@color-bi-blue-100, 40); +@color-bi-blue-30: fade(@color-bi-blue-100, 30); +@color-bi-blue-20: fade(@color-bi-blue-100, 20); +@color-bi-blue-10: fade(@color-bi-blue-100, 10); +@color-bi-blue-5: fade(@color-bi-blue-100, 5); + +//light-blue +@color-bi-light-blue-100: #eaf2fd; +@color-bi-light-blue-80: fade(@color-bi-light-blue-100, 80); +@color-bi-light-blue-60: fade(@color-bi-light-blue-100, 60); +@color-bi-light-blue-40: fade(@color-bi-light-blue-100, 40); +@color-bi-light-blue-30: fade(@color-bi-light-blue-100, 30); +@color-bi-light-blue-20: fade(@color-bi-light-blue-100, 20); +@color-bi-light-blue-10: fade(@color-bi-light-blue-100, 10); +@color-bi-light-blue-5: fade(@color-bi-light-blue-100, 5); + +// orange +@color-bi-orange-100: #faaa39; +@color-bi-orange-80: fade(@color-bi-orange-100, 80); +@color-bi-orange-60: fade(@color-bi-orange-100, 60); +@color-bi-orange-40: fade(@color-bi-orange-100, 40); +@color-bi-orange-30: fade(@color-bi-orange-100, 30); +@color-bi-orange-20: fade(@color-bi-orange-100, 20); +@color-bi-orange-10: fade(@color-bi-orange-100, 10); +@color-bi-orange-5: fade(@color-bi-orange-100, 5); + +// red +@color-bi-red-100: #e65251; +@color-bi-red-80: fade(@color-bi-red-100, 80); +@color-bi-red-60: fade(@color-bi-red-100, 60); +@color-bi-red-40: fade(@color-bi-red-100, 40); +@color-bi-red-30: fade(@color-bi-red-100, 30); +@color-bi-red-20: fade(@color-bi-red-100, 20); +@color-bi-red-10: fade(@color-bi-red-100, 10); +@color-bi-red-5: fade(@color-bi-red-100, 5); + +// yellow +@font-color-yellow-100: #ffc101; +@color-bi-yellow-80: fade(@font-color-yellow-100, 90); +@color-bi-yellow-60: fade(@font-color-yellow-100, 60); +@color-bi-yellow-40: fade(@font-color-yellow-100, 40); +@color-bi-yellow-20: fade(@font-color-yellow-100, 20); +@color-bi-yellow-5: fade(@font-color-yellow-100, 5); + //font color @font-color-black: #232e40; @font-color-normal: #3d4d66; @@ -35,15 +104,15 @@ @font-color-gray: #999999; @font-color-white: #ffffff; @font-color-white-theme-dark: #20263b; -@font-color-light-highlight: #eaf2fd; +@font-color-light-highlight: @color-bi-light-blue-100; @font-color-medium-highlight: #d7e7fc; -@font-color-highlight: #3685f2; +@font-color-highlight: @color-bi-blue-100; @font-color-blue: #23beef; @font-color-light-blue: #e9f8fd; -@font-color-success: #13cd66; -@font-color-warning: #faaa39; -@font-color-negative: #e65251; -@font-color-yellow: #ffc101; +@font-color-success: @color-bi-green-100; +@font-color-warning: @color-bi-orange-100; +@font-color-negative: @color-bi-red-100; +@font-color-yellow: @font-color-yellow-100; //background color @background-color-black: #232E40; @@ -54,9 +123,9 @@ @background-color-default-theme-dark: #20263b; @background-color-normal: #f7f8fa; @background-color-normal-theme-dark: #191b2b; -@background-color-light-highlight: #eaf2fd; +@background-color-light-highlight: @color-bi-light-blue-100; @background-color-medium-highlight: #d7e7fc; -@background-color-highlight: #3685f2; +@background-color-highlight: @color-bi-blue-100; @background-color-blue: #23beef; @background-color-light-blue: #e9f8fd; @background-color-dark: #d4dadd; @@ -70,15 +139,15 @@ @background-color-disabled-theme-dark: #292f45; @background-color-light-disabled: #9ea6b2; @background-color-light-disabled-theme-dark: #878d9f; -@background-color-yellow: #ffc101; +@background-color-yellow: @font-color-yellow-100; -@background-color-negative: #e65251; +@background-color-negative: @color-bi-red-100; @background-color-light-negative: #ffecec; @background-color-dark-negative: #3A2940; @background-color-light-warning: #feeed7; -@background-color-warning: #faaa39; +@background-color-warning: @color-bi-orange-100; -@background-color-dark-success: #13cd66; +@background-color-dark-success: @color-bi-green-100; @background-color-light-success: #e1f4e7; @background-color-normal-success: #647185; @@ -93,11 +162,11 @@ @border-color-dark-gray-line-theme-dark: #606479; @border-color-dark-line: #9ea6b2; @border-color-dark-line-theme-dark: #878d9f; -@border-color-highlight: #3685f2; +@border-color-highlight: @color-bi-blue-100; -@border-color-success: #13cd66; +@border-color-success: @color-bi-green-100; @border-color-warning: #fbb03b; -@border-color-negative: #e65251; +@border-color-negative: @color-bi-red-100; @border-color-light-negative: #f4cbcb; @border-color-normal-success: #647185; From 3e0ec8eed0b8eb8c90f21c31f276cfeb4239c31f Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 10 Dec 2021 16:47:21 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0proxy.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/fix/fix.proxy.js | 3619 +++++++++++++++++++++-------------------- 1 file changed, 1813 insertions(+), 1806 deletions(-) diff --git a/dist/fix/fix.proxy.js b/dist/fix/fix.proxy.js index 513db8d93..78a241383 100644 --- a/dist/fix/fix.proxy.js +++ b/dist/fix/fix.proxy.js @@ -1,2035 +1,2042 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Fix = {})); + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Fix = {})); }(this, (function (exports) { 'use strict'; - function _typeof(obj) { - "@babel/helpers - typeof"; - - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof = function (obj) { - return typeof obj; - }; - } else { - _typeof = function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }; - } - - return _typeof(obj); - } - - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - } - - function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - - function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - return Constructor; - } - - function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; - } - - var EMPTY_OBJ = Object.freeze({}); - Object.freeze([]); - var extend = Object.assign; - var hasOwnProperty = Object.prototype.hasOwnProperty; - - var hasOwn = function hasOwn(val, key) { - return hasOwnProperty.call(val, key); + function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; + } + + var EMPTY_OBJ = Object.freeze({}); + Object.freeze([]); + var extend = Object.assign; + var hasOwnProperty = Object.prototype.hasOwnProperty; + + var hasOwn = function hasOwn(val, key) { + return hasOwnProperty.call(val, key); + }; + + var isArray = Array.isArray; + + var isMap$1 = function isMap(val) { + return toTypeString$1(val) === "[object Map]"; + }; + + var isFunction = function isFunction(val) { + return typeof val === "function"; + }; + + var isString = function isString(val) { + return typeof val === "string"; + }; + + var isSymbol = function isSymbol(val) { + return _typeof(val) === "symbol"; + }; + + var isObject = function isObject(val) { + return val !== null && _typeof(val) === "object"; + }; + + var objectToString$1 = Object.prototype.toString; + + var toTypeString$1 = function toTypeString(value) { + return objectToString$1.call(value); + }; + + var toRawType = function toRawType(value) { + return (// extract "RawType" from strings like "[object RawType]" + toTypeString$1(value).slice(8, -1) + ); + }; + + var isIntegerKey = function isIntegerKey(key) { + return isString(key) && key !== "NaN" && key[0] !== "-" && "".concat(parseInt(key, 10)) === key; + }; + + var cacheStringFunction = function cacheStringFunction(fn) { + var cache = Object.create(null); + return function (str) { + var hit = cache[str]; + return hit || (cache[str] = fn(str)); }; + }; + /** + * @private + */ - var isArray = Array.isArray; - var isMap$1 = function isMap(val) { - return toTypeString$1(val) === "[object Map]"; - }; - - var isFunction = function isFunction(val) { - return typeof val === "function"; - }; + var capitalize = cacheStringFunction(function (str) { + return str.charAt(0).toUpperCase() + str.slice(1); + }); // compare whether a value has changed, accounting for NaN. - var isString = function isString(val) { - return typeof val === "string"; - }; + var hasChanged$1 = function hasChanged(value, oldValue) { + return value !== oldValue && (value === value || oldValue === oldValue); + }; - var isSymbol = function isSymbol(val) { - return _typeof(val) === "symbol"; - }; + var targetMap = new WeakMap(); + var effectStack = []; + var activeEffect; + var ITERATE_KEY = Symbol("iterate"); + var MAP_KEY_ITERATE_KEY = Symbol("Map key iterate"); - var isObject = function isObject(val) { - return val !== null && _typeof(val) === "object"; - }; + function isEffect(fn) { + return fn && fn._isEffect === true; + } - var objectToString$1 = Object.prototype.toString; + function effect(fn) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : EMPTY_OBJ; - var toTypeString$1 = function toTypeString(value) { - return objectToString$1.call(value); - }; - - var toRawType = function toRawType(value) { - return (// extract "RawType" from strings like "[object RawType]" - toTypeString$1(value).slice(8, -1) - ); - }; + if (isEffect(fn)) { + fn = fn.raw; + } - var isIntegerKey = function isIntegerKey(key) { - return isString(key) && key !== "NaN" && key[0] !== "-" && "".concat(parseInt(key, 10)) === key; - }; - - var cacheStringFunction = function cacheStringFunction(fn) { - var cache = Object.create(null); - return function (str) { - var hit = cache[str]; - return hit || (cache[str] = fn(str)); - }; - }; - /** - * @private - */ + var effect = createReactiveEffect(fn, options); + if (!options.lazy) { + effect(); + } - var capitalize = cacheStringFunction(function (str) { - return str.charAt(0).toUpperCase() + str.slice(1); - }); // compare whether a value has changed, accounting for NaN. + return effect; + } - var hasChanged$1 = function hasChanged(value, oldValue) { - return value !== oldValue && (value === value || oldValue === oldValue); - }; + function stop(effect) { + if (effect.active) { + cleanup(effect); - var targetMap = new WeakMap(); - var effectStack = []; - var activeEffect; - var ITERATE_KEY = Symbol("iterate"); - var MAP_KEY_ITERATE_KEY = Symbol("Map key iterate"); + if (effect.options.onStop) { + effect.options.onStop(); + } - function isEffect(fn) { - return fn && fn._isEffect === true; + effect.active = false; } + } - function effect(fn) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : EMPTY_OBJ; + var uid$1 = 0; - if (isEffect(fn)) { - fn = fn.raw; - } + function createReactiveEffect(fn, options) { + var effect = function reactiveEffect() { + if (!effect.active) { + return options.scheduler ? undefined : fn(); + } - var effect = createReactiveEffect(fn, options); + if (!effectStack.includes(effect)) { + cleanup(effect); - if (!options.lazy) { - effect(); + try { + enableTracking(); + effectStack.push(effect); + activeEffect = effect; + return fn(); + } finally { + effectStack.pop(); + resetTracking(); + activeEffect = effectStack[effectStack.length - 1]; } + } + }; - return effect; - } + effect.id = uid$1++; + effect.allowRecurse = !!options.allowRecurse; + effect._isEffect = true; + effect.active = true; + effect.raw = fn; + effect.deps = []; + effect.options = options; + return effect; + } - function stop(effect) { - if (effect.active) { - cleanup(effect); + function cleanup(effect) { + var deps = effect.deps; - if (effect.options.onStop) { - effect.options.onStop(); - } + if (deps.length) { + for (var i = 0; i < deps.length; i++) { + deps[i].delete(effect); + } - effect.active = false; - } + deps.length = 0; } + } - var uid$1 = 0; + var shouldTrack = true; + var trackStack = []; - function createReactiveEffect(fn, options) { - var effect = function reactiveEffect() { - if (!effect.active) { - return options.scheduler ? undefined : fn(); - } + function pauseTracking() { + trackStack.push(shouldTrack); + shouldTrack = false; + } - if (!effectStack.includes(effect)) { - cleanup(effect); - - try { - enableTracking(); - effectStack.push(effect); - activeEffect = effect; - return fn(); - } finally { - effectStack.pop(); - resetTracking(); - activeEffect = effectStack[effectStack.length - 1]; - } - } - }; + function enableTracking() { + trackStack.push(shouldTrack); + shouldTrack = true; + } - effect.id = uid$1++; - effect.allowRecurse = !!options.allowRecurse; - effect._isEffect = true; - effect.active = true; - effect.raw = fn; - effect.deps = []; - effect.options = options; - return effect; - } + function resetTracking() { + var last = trackStack.pop(); + shouldTrack = last === undefined ? true : last; + } - function cleanup(effect) { - var deps = effect.deps; - - if (deps.length) { - for (var i = 0; i < deps.length; i++) { - deps[i].delete(effect); - } - - deps.length = 0; - } + function track(target, type, key) { + if (!shouldTrack || activeEffect === undefined) { + return; } - var shouldTrack = true; - var trackStack = []; + var depsMap = targetMap.get(target); - function pauseTracking() { - trackStack.push(shouldTrack); - shouldTrack = false; + if (!depsMap) { + targetMap.set(target, depsMap = new Map()); } - function enableTracking() { - trackStack.push(shouldTrack); - shouldTrack = true; - } + var dep = depsMap.get(key); - function resetTracking() { - var last = trackStack.pop(); - shouldTrack = last === undefined ? true : last; + if (!dep) { + depsMap.set(key, dep = new Set()); } - function track(target, type, key) { - if (!shouldTrack || activeEffect === undefined) { - return; - } - - var depsMap = targetMap.get(target); - - if (!depsMap) { - targetMap.set(target, depsMap = new Map()); - } - - var dep = depsMap.get(key); - - if (!dep) { - depsMap.set(key, dep = new Set()); - } + if (!dep.has(activeEffect)) { + dep.add(activeEffect); + activeEffect.deps.push(dep); - if (!dep.has(activeEffect)) { - dep.add(activeEffect); - activeEffect.deps.push(dep); - - if (activeEffect.options.onTrack) { - activeEffect.options.onTrack({ - effect: activeEffect, - target: target, - type: type, - key: key - }); - } - } + if (activeEffect.options.onTrack) { + activeEffect.options.onTrack({ + effect: activeEffect, + target: target, + type: type, + key: key + }); + } } + } - function trigger(target, type, key, newValue, oldValue, oldTarget) { - var depsMap = targetMap.get(target); - - if (!depsMap) { - // never been tracked - return; - } - - var effects = new Set(); - - var add = function add(effectsToAdd) { - if (effectsToAdd) { - effectsToAdd.forEach(function (effect) { - if (effect !== activeEffect || effect.allowRecurse) { - effects.add(effect); - } - }); - } - }; - - if (type === "clear" - /* CLEAR */ - ) { - // collection being cleared - // trigger all effects for target - depsMap.forEach(add); - } else if (key === "length" && isArray(target)) { - depsMap.forEach(function (dep, key) { - if (key === "length" || key >= newValue) { - add(dep); - } - }); - } else { - // schedule runs for SET | ADD | DELETE - if (key !== void 0) { - add(depsMap.get(key)); - } // also run for iteration key on ADD | DELETE | Map.SET - - - switch (type) { - case "add" - /* ADD */ - : - if (!isArray(target)) { - add(depsMap.get(ITERATE_KEY)); - - if (isMap$1(target)) { - add(depsMap.get(MAP_KEY_ITERATE_KEY)); - } - } else if (isIntegerKey(key)) { - // new index added to array -> length changes - add(depsMap.get("length")); - } - - break; - - case "delete" - /* DELETE */ - : - if (!isArray(target)) { - add(depsMap.get(ITERATE_KEY)); - - if (isMap$1(target)) { - add(depsMap.get(MAP_KEY_ITERATE_KEY)); - } - } - - break; - - case "set" - /* SET */ - : - if (isMap$1(target)) { - add(depsMap.get(ITERATE_KEY)); - } - - break; - } - } - - var run = function run(effect) { - if (effect.options.onTrigger) { - effect.options.onTrigger({ - effect: effect, - target: target, - key: key, - type: type, - newValue: newValue, - oldValue: oldValue, - oldTarget: oldTarget - }); - } - - if (effect.options.scheduler) { - effect.options.scheduler(effect); - } else { - effect(); - } - }; + function trigger(target, type, key, newValue, oldValue, oldTarget) { + var depsMap = targetMap.get(target); - effects.forEach(run); + if (!depsMap) { + // never been tracked + return; } - var builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol).map(function (key) { - return Symbol[key]; - }).filter(isSymbol)); - var get = /* #__PURE__*/createGetter(); - var shallowGet = /* #__PURE__*/createGetter(false, true); - var readonlyGet = /* #__PURE__*/createGetter(true); - var shallowReadonlyGet = /* #__PURE__*/createGetter(true, true); - var arrayInstrumentations = {}; - ["includes", "indexOf", "lastIndexOf"].forEach(function (key) { - var method = Array.prototype[key]; - - arrayInstrumentations[key] = function () { - var arr = toRaw(this); - - for (var i = 0, l = this.length; i < l; i++) { - track(arr, "get" - /* GET */ - , "".concat(i)); - } // we run the method using the original args first (which may be reactive) - - - for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) { - args[_key2] = arguments[_key2]; - } - - var res = method.apply(arr, args); - - if (res === -1 || res === false) { - // if that didn't work, run it again using raw values. - return method.apply(arr, args.map(toRaw)); - } else { - return res; - } - }; - }); - ["push", "pop", "shift", "unshift", "splice"].forEach(function (key) { - var method = Array.prototype[key]; - - arrayInstrumentations[key] = function () { - pauseTracking(); - - for (var _len2 = arguments.length, args = new Array(_len2), _key3 = 0; _key3 < _len2; _key3++) { - args[_key3] = arguments[_key3]; - } + var effects = new Set(); - var res = method.apply(this, args); - resetTracking(); - return res; - }; - }); - - function createGetter() { - var isReadonly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - var shallow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - return function get(target, key, receiver) { - if (key === "__v_isReactive" - /* IS_REACTIVE */ - ) { - return !isReadonly; - } else if (key === "__v_isReadonly" - /* IS_READONLY */ - ) { - return isReadonly; - } else if (key === "__v_raw" - /* RAW */ - && receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) { - return target; - } - - var targetIsArray = isArray(target); + var add = function add(effectsToAdd) { + if (effectsToAdd) { + effectsToAdd.forEach(function (effect) { + if (effect !== activeEffect || effect.allowRecurse) { + effects.add(effect); + } + }); + } + }; - if (targetIsArray && hasOwn(arrayInstrumentations, key)) { - return Reflect.get(arrayInstrumentations, key, receiver); + if (type === "clear" + /* CLEAR */ + ) { + // collection being cleared + // trigger all effects for target + depsMap.forEach(add); + } else if (key === "length" && isArray(target)) { + depsMap.forEach(function (dep, key) { + if (key === "length" || key >= newValue) { + add(dep); + } + }); + } else { + // schedule runs for SET | ADD | DELETE + if (key !== void 0) { + add(depsMap.get(key)); + } // also run for iteration key on ADD | DELETE | Map.SET + + + switch (type) { + case "add" + /* ADD */ + : + if (!isArray(target)) { + add(depsMap.get(ITERATE_KEY)); + + if (isMap$1(target)) { + add(depsMap.get(MAP_KEY_ITERATE_KEY)); } + } else if (isIntegerKey(key)) { + // new index added to array -> length changes + add(depsMap.get("length")); + } - var res = Reflect.get(target, key, receiver); + break; - if (isSymbol(key) ? builtInSymbols.has(key) : key === "__proto__" || key === "__v_isRef") { - return res; - } - - if (!isReadonly) { - track(target, "get" - /* GET */ - , key); - } + case "delete" + /* DELETE */ + : + if (!isArray(target)) { + add(depsMap.get(ITERATE_KEY)); - if (shallow) { - return res; + if (isMap$1(target)) { + add(depsMap.get(MAP_KEY_ITERATE_KEY)); } + } + + break; + + case "set" + /* SET */ + : + if (isMap$1(target)) { + add(depsMap.get(ITERATE_KEY)); + } + + break; + } + } + + var run = function run(effect) { + if (effect.options.onTrigger) { + effect.options.onTrigger({ + effect: effect, + target: target, + key: key, + type: type, + newValue: newValue, + oldValue: oldValue, + oldTarget: oldTarget + }); + } - if (isRef(res)) { - // ref unwrapping - does not apply for Array + integer key. - var shouldUnwrap = !targetIsArray || !isIntegerKey(key); - return shouldUnwrap ? res.value : res; - } + if (effect.options.scheduler) { + effect.options.scheduler(effect); + } else { + effect(); + } + }; - if (isObject(res)) { - // Convert returned value into a proxy as well. we do the isObject check - // here to avoid invalid value warning. Also need to lazy access readonly - // and reactive here to avoid circular dependency. - return isReadonly ? readonly(res) : reactive(res); - } + effects.forEach(run); + } + + var builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol).map(function (key) { + return Symbol[key]; + }).filter(isSymbol)); + var get = /* #__PURE__*/createGetter(); + var shallowGet = /* #__PURE__*/createGetter(false, true); + var readonlyGet = /* #__PURE__*/createGetter(true); + var shallowReadonlyGet = /* #__PURE__*/createGetter(true, true); + var arrayInstrumentations = {}; + ["includes", "indexOf", "lastIndexOf"].forEach(function (key) { + var method = Array.prototype[key]; + + arrayInstrumentations[key] = function () { + var arr = toRaw(this); + + for (var i = 0, l = this.length; i < l; i++) { + track(arr, "get" + /* GET */ + , "".concat(i)); + } // we run the method using the original args first (which may be reactive) + + + for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) { + args[_key2] = arguments[_key2]; + } + + var res = method.apply(arr, args); + + if (res === -1 || res === false) { + // if that didn't work, run it again using raw values. + return method.apply(arr, args.map(toRaw)); + } else { + return res; + } + }; + }); + ["push", "pop", "shift", "unshift", "splice"].forEach(function (key) { + var method = Array.prototype[key]; - return res; - }; - } + arrayInstrumentations[key] = function () { + pauseTracking(); - var set$1 = /* #__PURE__*/createSetter(); - var shallowSet = /* #__PURE__*/createSetter(true); + for (var _len2 = arguments.length, args = new Array(_len2), _key3 = 0; _key3 < _len2; _key3++) { + args[_key3] = arguments[_key3]; + } - function createSetter() { - var shallow = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - return function set(target, key, value, receiver) { - var oldValue = target[key]; + var res = method.apply(this, args); + resetTracking(); + return res; + }; + }); + + function createGetter() { + var isReadonly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + var shallow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + return function get(target, key, receiver) { + if (key === "__v_isReactive" + /* IS_REACTIVE */ + ) { + return !isReadonly; + } else if (key === "__v_isReadonly" + /* IS_READONLY */ + ) { + return isReadonly; + } else if (key === "__v_raw" + /* RAW */ + && receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) { + return target; + } + + var targetIsArray = isArray(target); + + if (targetIsArray && hasOwn(arrayInstrumentations, key)) { + return Reflect.get(arrayInstrumentations, key, receiver); + } + + var res = Reflect.get(target, key, receiver); + + if (isSymbol(key) ? builtInSymbols.has(key) : key === "__proto__" || key === "__v_isRef") { + return res; + } + + if (!isReadonly) { + track(target, "get" + /* GET */ + , key); + } + + if (shallow) { + return res; + } + + if (isRef(res)) { + // ref unwrapping - does not apply for Array + integer key. + var shouldUnwrap = !targetIsArray || !isIntegerKey(key); + return shouldUnwrap ? res.value : res; + } + + if (isObject(res)) { + // Convert returned value into a proxy as well. we do the isObject check + // here to avoid invalid value warning. Also need to lazy access readonly + // and reactive here to avoid circular dependency. + return isReadonly ? readonly(res) : reactive(res); + } + + return res; + }; + } - if (!shallow) { - value = toRaw(value); + var set$1 = /* #__PURE__*/createSetter(); + var shallowSet = /* #__PURE__*/createSetter(true); - if (!isArray(target) && isRef(oldValue) && !isRef(value)) { - oldValue.value = value; - return true; - } - } + function createSetter() { + var shallow = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + return function set(target, key, value, receiver) { + var oldValue = target[key]; - var hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key); - var result = Reflect.set(target, key, value, receiver); // don't trigger if target is something up in the prototype chain of original - - if (target === toRaw(receiver)) { - if (!hadKey) { - trigger(target, "add" - /* ADD */ - , key, value); - } else if (hasChanged$1(value, oldValue) || key === "length") { - trigger(target, "set" - /* SET */ - , key, value, oldValue); - } - } + if (!shallow) { + value = toRaw(value); - return result; - }; - } + if (!isArray(target) && isRef(oldValue) && !isRef(value)) { + oldValue.value = value; + return true; + } + } - function deleteProperty(target, key) { - var hadKey = hasOwn(target, key); - var oldValue = target[key]; - var result = Reflect.deleteProperty(target, key); + var hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key); + var result = Reflect.set(target, key, value, receiver); // don't trigger if target is something up in the prototype chain of original - if (result && hadKey) { - trigger(target, "delete" - /* DELETE */ - , key, undefined, oldValue); + if (target === toRaw(receiver)) { + if (!hadKey) { + trigger(target, "add" + /* ADD */ + , key, value); + } else if (hasChanged$1(value, oldValue) || key === "length") { + trigger(target, "set" + /* SET */ + , key, value, oldValue); } + } - return result; + return result; + }; + } + + function deleteProperty(target, key) { + var hadKey = hasOwn(target, key); + var oldValue = target[key]; + var result = Reflect.deleteProperty(target, key); + + if (result && hadKey) { + trigger(target, "delete" + /* DELETE */ + , key, undefined, oldValue); + } + + return result; + } + + function has$1(target, key) { + var result = Reflect.has(target, key); + + if (!isSymbol(key) || !builtInSymbols.has(key)) { + track(target, "has" + /* HAS */ + , key); + } + + return result; + } + + function ownKeys(target) { + track(target, "iterate" + /* ITERATE */ + , isArray(target) ? "length" : ITERATE_KEY); + return Reflect.ownKeys(target); + } + + var mutableHandlers = { + get: get, + set: set$1, + deleteProperty: deleteProperty, + has: has$1, + ownKeys: ownKeys + }; + var readonlyHandlers = { + get: readonlyGet, + set: function set(target, key) { + { + console.warn("Set operation on key \"".concat(String(key), "\" failed: target is readonly."), target); + } + return true; + }, + deleteProperty: function deleteProperty(target, key) { + { + console.warn("Delete operation on key \"".concat(String(key), "\" failed: target is readonly."), target); + } + return true; + } + }; + extend({}, mutableHandlers, { + get: shallowGet, + set: shallowSet + }); // Props handlers are special in the sense that it should not unwrap top-level + // refs (in order to allow refs to be explicitly passed down), but should + // retain the reactivity of the normal readonly object. + + extend({}, readonlyHandlers, { + get: shallowReadonlyGet + }); + + var toReactive = function toReactive(value) { + return isObject(value) ? reactive(value) : value; + }; + + var toReadonly = function toReadonly(value) { + return isObject(value) ? readonly(value) : value; + }; + + var toShallow = function toShallow(value) { + return value; + }; + + var getProto = function getProto(v) { + return Reflect.getPrototypeOf(v); + }; + + function get$1(target, key) { + var isReadonly = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + var isShallow = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + // #1772: readonly(reactive(Map)) should return readonly + reactive version + // of the value + target = target["__v_raw" + /* RAW */ + ]; + var rawTarget = toRaw(target); + var rawKey = toRaw(key); + + if (key !== rawKey) { + !isReadonly && track(rawTarget, "get" + /* GET */ + , key); + } + + !isReadonly && track(rawTarget, "get" + /* GET */ + , rawKey); + + var _getProto = getProto(rawTarget), + has = _getProto.has; + + var wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; + + if (has.call(rawTarget, key)) { + return wrap(target.get(key)); + } else if (has.call(rawTarget, rawKey)) { + return wrap(target.get(rawKey)); + } + } + + function has$1$1(key) { + var isReadonly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + var target = this["__v_raw" + /* RAW */ + ]; + var rawTarget = toRaw(target); + var rawKey = toRaw(key); + + if (key !== rawKey) { + !isReadonly && track(rawTarget, "has" + /* HAS */ + , key); + } + + !isReadonly && track(rawTarget, "has" + /* HAS */ + , rawKey); + return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey); + } + + function size(target) { + var isReadonly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + target = target["__v_raw" + /* RAW */ + ]; + !isReadonly && track(toRaw(target), "iterate" + /* ITERATE */ + , ITERATE_KEY); + return Reflect.get(target, "size", target); + } + + function add(value) { + value = toRaw(value); + var target = toRaw(this); + var proto = getProto(target); + var hadKey = proto.has.call(target, value); + var result = target.add(value); + + if (!hadKey) { + trigger(target, "add" + /* ADD */ + , value, value); + } + + return result; + } + + function set$1$1(key, value) { + value = toRaw(value); + var target = toRaw(this); + + var _getProto2 = getProto(target), + has = _getProto2.has, + get = _getProto2.get; + + var hadKey = has.call(target, key); + + if (!hadKey) { + key = toRaw(key); + hadKey = has.call(target, key); + } else { + checkIdentityKeys(target, has, key); + } + + var oldValue = get.call(target, key); + var result = target.set(key, value); + + if (!hadKey) { + trigger(target, "add" + /* ADD */ + , key, value); + } else if (hasChanged$1(value, oldValue) || key === "length") { + trigger(target, "set" + /* SET */ + , key, value, oldValue); } - function has$1(target, key) { - var result = Reflect.has(target, key); + return result; + } - if (!isSymbol(key) || !builtInSymbols.has(key)) { - track(target, "has" - /* HAS */ - , key); - } + function deleteEntry(key) { + var target = toRaw(this); - return result; - } + var _getProto3 = getProto(target), + has = _getProto3.has, + get = _getProto3.get; - function ownKeys(target) { - track(target, "iterate" - /* ITERATE */ - , isArray(target) ? "length" : ITERATE_KEY); - return Reflect.ownKeys(target); - } + var hadKey = has.call(target, key); + + if (!hadKey) { + key = toRaw(key); + hadKey = has.call(target, key); + } else { + checkIdentityKeys(target, has, key); + } + + var oldValue = get ? get.call(target, key) : undefined; // forward the operation before queueing reactions + + var result = target.delete(key); + + if (hadKey) { + trigger(target, "delete" + /* DELETE */ + , key, undefined, oldValue); + } + + return result; + } + + function clear() { + var target = toRaw(this); + var hadItems = target.size !== 0; + var oldTarget = isMap$1(target) ? new Map(target) : new Set(target); // forward the operation before queueing reactions + + var result = target.clear(); + + if (hadItems) { + trigger(target, "clear" + /* CLEAR */ + , undefined, undefined, oldTarget); + } + + return result; + } - var mutableHandlers = { - get: get, - set: set$1, - deleteProperty: deleteProperty, - has: has$1, - ownKeys: ownKeys - }; - var readonlyHandlers = { - get: readonlyGet, - set: function set(target, key) { - { - console.warn("Set operation on key \"".concat(String(key), "\" failed: target is readonly."), target); - } - return true; - }, - deleteProperty: function deleteProperty(target, key) { - { - console.warn("Delete operation on key \"".concat(String(key), "\" failed: target is readonly."), target); - } - return true; - } + function createForEach(isReadonly, isShallow) { + return function forEach(callback, thisArg) { + var observed = this; + var target = observed["__v_raw" + /* RAW */ + ]; + var rawTarget = toRaw(target); + var wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; + !isReadonly && track(rawTarget, "iterate" + /* ITERATE */ + , ITERATE_KEY); + return target.forEach(function (value, key) { + return (// important: make sure the callback is + // 1. invoked with the reactive map as `this` and 3rd arg + // 2. the value received should be a corresponding reactive/readonly. + callback.call(thisArg, wrap(value), wrap(key), observed) + ); + }); }; - extend({}, mutableHandlers, { - get: shallowGet, - set: shallowSet - }); // Props handlers are special in the sense that it should not unwrap top-level - // refs (in order to allow refs to be explicitly passed down), but should - // retain the reactivity of the normal readonly object. - - extend({}, readonlyHandlers, { - get: shallowReadonlyGet - }); - - var toReactive = function toReactive(value) { - return isObject(value) ? reactive(value) : value; + } + + function createIterableMethod(method, isReadonly, isShallow) { + return function () { + var target = this["__v_raw" + /* RAW */ + ]; + var rawTarget = toRaw(target); + var targetIsMap = isMap$1(rawTarget); + var isPair = method === "entries" || method === Symbol.iterator && targetIsMap; + var isKeyOnly = method === "keys" && targetIsMap; + var innerIterator = target[method].apply(target, arguments); + var wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; + !isReadonly && track(rawTarget, "iterate" + /* ITERATE */ + , isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); // return a wrapped iterator which returns observed versions of the + // values emitted from the real iterator + + return _defineProperty({ + // iterator protocol + next: function next() { + var _innerIterator$next = innerIterator.next(), + value = _innerIterator$next.value, + done = _innerIterator$next.done; + + return done ? { + value: value, + done: done + } : { + value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value), + done: done + }; + } + }, Symbol.iterator, function () { + return this; + }); }; - - var toReadonly = function toReadonly(value) { - return isObject(value) ? readonly(value) : value; + } + + function createReadonlyMethod(type) { + return function () { + { + var key = (arguments.length <= 0 ? undefined : arguments[0]) ? "on key \"".concat(arguments.length <= 0 ? undefined : arguments[0], "\" ") : ""; + console.warn("".concat(capitalize(type), " operation ").concat(key, "failed: target is readonly."), toRaw(this)); + } + return type === "delete" + /* DELETE */ + ? false : this; }; - - var toShallow = function toShallow(value) { - return value; + } + + var mutableInstrumentations = { + get: function get(key) { + return get$1(this, key); + }, + + get size() { + return size(this); + }, + + has: has$1$1, + add: add, + set: set$1$1, + delete: deleteEntry, + clear: clear, + forEach: createForEach(false, false) + }; + var shallowInstrumentations = { + get: function get(key) { + return get$1(this, key, false, true); + }, + + get size() { + return size(this); + }, + + has: has$1$1, + add: add, + set: set$1$1, + delete: deleteEntry, + clear: clear, + forEach: createForEach(false, true) + }; + var readonlyInstrumentations = { + get: function get(key) { + return get$1(this, key, true); + }, + + get size() { + return size(this, true); + }, + + has: function has(key) { + return has$1$1.call(this, key, true); + }, + add: createReadonlyMethod("add" + /* ADD */ + ), + set: createReadonlyMethod("set" + /* SET */ + ), + delete: createReadonlyMethod("delete" + /* DELETE */ + ), + clear: createReadonlyMethod("clear" + /* CLEAR */ + ), + forEach: createForEach(true, false) + }; + var iteratorMethods = ["keys", "values", "entries", Symbol.iterator]; + iteratorMethods.forEach(function (method) { + mutableInstrumentations[method] = createIterableMethod(method, false, false); + readonlyInstrumentations[method] = createIterableMethod(method, true, false); + shallowInstrumentations[method] = createIterableMethod(method, false, true); + }); + + function createInstrumentationGetter(isReadonly, shallow) { + var instrumentations = shallow ? shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations; + return function (target, key, receiver) { + if (key === "__v_isReactive" + /* IS_REACTIVE */ + ) { + return !isReadonly; + } else if (key === "__v_isReadonly" + /* IS_READONLY */ + ) { + return isReadonly; + } else if (key === "__v_raw" + /* RAW */ + ) { + return target; + } + + return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver); }; - - var getProto = function getProto(v) { - return Reflect.getPrototypeOf(v); + } + + var mutableCollectionHandlers = { + get: createInstrumentationGetter(false, false) + }; + var readonlyCollectionHandlers = { + get: createInstrumentationGetter(true, false) + }; + + function checkIdentityKeys(target, has, key) { + var rawKey = toRaw(key); + + if (rawKey !== key && has.call(target, rawKey)) { + var type = toRawType(target); + console.warn("Reactive ".concat(type, " contains both the raw and reactive ") + "versions of the same object".concat(type === "Map" ? " as keys" : "", ", ") + "which can lead to inconsistencies. " + "Avoid differentiating between the raw and reactive versions " + "of an object and only use the reactive version if possible."); + } + } + + var reactiveMap = new WeakMap(); + var readonlyMap = new WeakMap(); + + function targetTypeMap(rawType) { + switch (rawType) { + case "Object": + case "Array": + return 1; + + case "Map": + case "Set": + case "WeakMap": + case "WeakSet": + return 2; + + default: + return 0; + } + } + + function getTargetType(value) { + return value["__v_skip" + /* SKIP */ + ] || !Object.isExtensible(value) ? 0 + /* INVALID */ + : targetTypeMap(toRawType(value)); + } + + function reactive(target) { + // if trying to observe a readonly proxy, return the readonly version. + if (target && target["__v_isReadonly" + /* IS_READONLY */ + ]) { + return target; + } + + return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers); + } // Return a reactive-copy of the original object, where only the root level + + function readonly(target) { + return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers); + } // Return a reactive-copy of the original object, where only the root level + + function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) { + if (!isObject(target)) { + { + console.warn("value cannot be made reactive: ".concat(String(target))); + } + return target; + } // target is already a Proxy, return it. + // exception: calling readonly() on a reactive object + + + if (target["__v_raw" + /* RAW */ + ] && !(isReadonly && target["__v_isReactive" + /* IS_REACTIVE */ + ])) { + return target; + } // target already has corresponding Proxy + + + var proxyMap = isReadonly ? readonlyMap : reactiveMap; + var existingProxy = proxyMap.get(target); + + if (existingProxy) { + return existingProxy; + } // only a whitelist of value types can be observed. + + + var targetType = getTargetType(target); + + if (targetType === 0 + /* INVALID */ + ) { + return target; + } + + var proxy = new Proxy(target, targetType === 2 + /* COLLECTION */ + ? collectionHandlers : baseHandlers); + proxyMap.set(target, proxy); + return proxy; + } + + function isReactive(value) { + if (isReadonly(value)) { + return isReactive(value["__v_raw" + /* RAW */ + ]); + } + + return !!(value && value["__v_isReactive" + /* IS_REACTIVE */ + ]); + } + + function isReadonly(value) { + return !!(value && value["__v_isReadonly" + /* IS_READONLY */ + ]); + } + + function toRaw(observed) { + return observed && toRaw(observed["__v_raw" + /* RAW */ + ]) || observed; + } + + function isRef(r) { + return Boolean(r && r.__v_isRef === true); + } + + var ComputedRefImpl = /*#__PURE__*/function () { + function ComputedRefImpl(getter, _setter, isReadonly) { + var _this2 = this; + + _classCallCheck(this, ComputedRefImpl); + + this._setter = _setter; + this._dirty = true; + this.__v_isRef = true; + this.effect = effect(getter, { + lazy: true, + scheduler: function scheduler() { + if (!_this2._dirty) { + _this2._dirty = true; + trigger(toRaw(_this2), "set" + /* SET */ + , "value"); + } + } + }); + this["__v_isReadonly" + /* IS_READONLY */ + ] = isReadonly; + } + + _createClass(ComputedRefImpl, [{ + key: "value", + get: function get() { + if (this._dirty) { + this._value = this.effect(); + this._dirty = false; + } + + track(toRaw(this), "get" + /* GET */ + , "value"); + return this._value; + }, + set: function set(newValue) { + this._setter(newValue); + } + }]); + + return ComputedRefImpl; + }(); + + function computed(getterOrOptions) { + var getter; + var setter; + + if (isFunction(getterOrOptions)) { + getter = getterOrOptions; + + setter = function setter() { + console.warn("Write operation failed: computed value is readonly"); + }; + } else { + getter = getterOrOptions.get; + setter = getterOrOptions.set; + } + + return new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set); + } + + function noop() {} + function isNative(Ctor) { + return typeof Ctor === "function" && /native code/.test(Ctor.toString()); + } + var isIE = function isIE() { + if (typeof navigator === "undefined") { + return false; + } + + return /(msie|trident)/i.test(navigator.userAgent.toLowerCase()); + }; + var getIEVersion = function getIEVersion() { + var version = 0; + + if (typeof navigator === "undefined") { + return false; + } + + var agent = navigator.userAgent.toLowerCase(); + var v1 = agent.match(/(?:msie\s([\w.]+))/); + var v2 = agent.match(/(?:trident.*rv:([\w.]+))/); + + if (v1 && v2 && v1[1] && v2[1]) { + version = Math.max(v1[1] * 1, v2[1] * 1); + } else if (v1 && v1[1]) { + version = v1[1] * 1; + } else if (v2 && v2[1]) { + version = v2[1] * 1; + } else { + version = 0; + } + + return version; + }; + isIE() && getIEVersion() < 9; + var _toString = Object.prototype.toString; + function isPlainObject(obj) { + return _toString.call(obj) === "[object Object]"; + } + var bailRE = /[^\w.$]/; + function parsePath(path) { + if (bailRE.test(path)) { + return; + } + + var segments = path.split("."); + return function (obj) { + for (var i = 0; i < segments.length; i++) { + if (!obj) return; + obj = obj[segments[i]]; + } + + return obj; }; - - function get$1(target, key) { - var isReadonly = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - var isShallow = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; - // #1772: readonly(reactive(Map)) should return readonly + reactive version - // of the value - target = target["__v_raw" - /* RAW */ - ]; - var rawTarget = toRaw(target); - var rawKey = toRaw(key); - - if (key !== rawKey) { - !isReadonly && track(rawTarget, "get" - /* GET */ - , key); + } + var nextTick = function () { + var callbacks = []; + var pending = false; + var timerFunc; + + function nextTickHandler() { + pending = false; + var copies = callbacks.slice(0); + callbacks.length = 0; + + for (var i = 0; i < copies.length; i++) { + copies[i](); + } + } // An asynchronous deferring mechanism. + // In pre 2.4, we used to use microtasks (Promise/MutationObserver) + // but microtasks actually has too high a priority and fires in between + // supposedly sequential events (e.g. #4521, #6690) or even between + // bubbling of the same event (#6566). Technically setImmediate should be + // the ideal choice, but it's not available everywhere; and the only polyfill + // that consistently queues the callback after all DOM events triggered in the + // same loop is by using MessageChannel. + + /* istanbul ignore if */ + + + if (typeof setImmediate !== "undefined" && isNative(setImmediate)) { + timerFunc = function timerFunc() { + setImmediate(nextTickHandler); + }; + } else if (typeof MessageChannel !== "undefined" && (isNative(MessageChannel) || // PhantomJS + MessageChannel.toString() === "[object MessageChannelConstructor]")) { + var channel = new MessageChannel(); + var port = channel.port2; + channel.port1.onmessage = nextTickHandler; + + timerFunc = function timerFunc() { + port.postMessage(1); + }; + } else if (typeof Promise !== "undefined" && isNative(Promise)) { + /* istanbul ignore next */ + // use microtask in non-DOM environments, e.g. Weex + var p = Promise.resolve(); + + timerFunc = function timerFunc() { + p.then(nextTickHandler); + }; + } else { + // fallback to setTimeout + timerFunc = function timerFunc() { + setTimeout(nextTickHandler, 0); + }; + } + + return function queueNextTick(cb, ctx) { + var _resolve; + + callbacks.push(function () { + if (cb) { + try { + cb.call(ctx); + } catch (e) { + console.error(e); + } + } else if (_resolve) { + _resolve(ctx); } + }); - !isReadonly && track(rawTarget, "get" - /* GET */ - , rawKey); + if (!pending) { + pending = true; + timerFunc(); + } // $flow-disable-line - var _getProto = getProto(rawTarget), - has = _getProto.has; - var wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; + if (!cb && typeof Promise !== "undefined") { + return new Promise(function (resolve) { + _resolve = resolve; + }); + } + }; + }(); + + var mixinInjection = {}; + function getMixins(type) { + return mixinInjection[type]; + } + function mixin(xtype, cls) { + mixinInjection[xtype] = _.cloneDeep(cls); + } + + var queue = []; + var has = {}; + var waiting = false; + var flushing = false; + var index = 0; + + function resetSchedulerState() { + index = queue.length = 0; + has = {}; + waiting = flushing = false; + } + + function flushSchedulerQueue() { + flushing = true; + var watcher; + var id; + var options; // Sort queue before flush. + // This ensures that: + // 1. Components are updated from parent to child. (because parent is always + // created before the child) + // 2. A component's user watchers are run before its render watcher (because + // user watchers are created before the render watcher) + // 3. If a component is destroyed during a parent component's watcher run, + // its watchers can be skipped. + + queue.sort(function (a, b) { + return a.id - b.id; + }); // do not cache length because more watchers might be pushed + // as we run existing watchers + + for (index = 0; index < queue.length; index++) { + watcher = queue[index].watcher; + options = queue[index].options; + id = watcher.id; + has[id] = null; + watcher(options); + } + + resetSchedulerState(); + } + + function queueWatcher(watcher, options) { + var id = watcher.id; + + if (has[id] == null) { + has[id] = true; + + if (!flushing) { + queue.push({ + watcher: watcher, + options: options + }); + } else { + // if already flushing, splice the watcher based on its id + // if already past its id, it will be run next immediately. + var i = queue.length - 1; - if (has.call(rawTarget, key)) { - return wrap(target.get(key)); - } else if (has.call(rawTarget, rawKey)) { - return wrap(target.get(rawKey)); + while (i > index && queue[i].watcher.id > watcher.id) { + i--; } - } - function has$1$1(key) { - var isReadonly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - var target = this["__v_raw" - /* RAW */ - ]; - var rawTarget = toRaw(target); - var rawKey = toRaw(key); + queue.splice(i + 1, 0, { + watcher: watcher, + options: options + }); + } // queue the flush - if (key !== rawKey) { - !isReadonly && track(rawTarget, "has" - /* HAS */ - , key); - } - !isReadonly && track(rawTarget, "has" - /* HAS */ - , rawKey); - return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey); + if (!waiting) { + waiting = true; + nextTick(flushSchedulerQueue); + } } + } - function size(target) { - var isReadonly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - target = target["__v_raw" - /* RAW */ - ]; - !isReadonly && track(toRaw(target), "iterate" - /* ITERATE */ - , ITERATE_KEY); - return Reflect.get(target, "size", target); + function innerWatch(source, cb, options) { + if (!_.isFunction(cb)) { + console.warn("`watch(fn, options?)` signature has been moved to a separate API. " + "Use `watchEffect(fn, options?)` instead. `watch` now only " + "supports `watch(source, cb, options?) signature."); } - function add(value) { - value = toRaw(value); - var target = toRaw(this); - var proto = getProto(target); - var hadKey = proto.has.call(target, value); - var result = target.add(value); + return doWatch(source, cb, options); + } + var INITIAL_WATCHER_VALUE = {}; + var objectToString = Object.prototype.toString; - if (!hadKey) { - trigger(target, "add" - /* ADD */ - , value, value); - } + var toTypeString = function toTypeString(value) { + return objectToString.call(value); + }; - return result; - } + var isMap = function isMap(val) { + return toTypeString(val) === "[object Map]"; + }; - function set$1$1(key, value) { - value = toRaw(value); - var target = toRaw(this); + var isSet = function isSet(val) { + return toTypeString(val) === "[object Set]"; + }; - var _getProto2 = getProto(target), - has = _getProto2.has, - get = _getProto2.get; + var hasChanged = function hasChanged(value, oldValue) { + return value !== oldValue && (value === value || oldValue === oldValue); + }; - var hadKey = has.call(target, key); + var uid = 0; - if (!hadKey) { - key = toRaw(key); - hadKey = has.call(target, key); - } else { - checkIdentityKeys(target, has, key); - } + function doWatch(source, cb, options, instance) { + options = options || {}; + var _options = options, + immediate = _options.immediate, + deep = _options.deep, + sync = _options.sync, + onTrack = _options.onTrack, + onTrigger = _options.onTrigger; - var oldValue = get.call(target, key); - var result = target.set(key, value); + if (!cb) { + if (immediate !== undefined) { + console.warn("watch() \"immediate\" option is only respected when using the " + "watch(source, callback, options?) signature."); + } - if (!hadKey) { - trigger(target, "add" - /* ADD */ - , key, value); - } else if (hasChanged$1(value, oldValue) || key === "length") { - trigger(target, "set" - /* SET */ - , key, value, oldValue); - } - - return result; - } - - function deleteEntry(key) { - var target = toRaw(this); - - var _getProto3 = getProto(target), - has = _getProto3.has, - get = _getProto3.get; - - var hadKey = has.call(target, key); - - if (!hadKey) { - key = toRaw(key); - hadKey = has.call(target, key); - } else { - checkIdentityKeys(target, has, key); - } - - var oldValue = get ? get.call(target, key) : undefined; // forward the operation before queueing reactions - - var result = target.delete(key); - - if (hadKey) { - trigger(target, "delete" - /* DELETE */ - , key, undefined, oldValue); - } - - return result; + if (deep !== undefined) { + console.warn("watch() \"deep\" option is only respected when using the " + "watch(source, callback, options?) signature."); + } } - function clear() { - var target = toRaw(this); - var hadItems = target.size !== 0; - var oldTarget = isMap$1(target) ? new Map(target) : new Set(target); // forward the operation before queueing reactions - - var result = target.clear(); - - if (hadItems) { - trigger(target, "clear" - /* CLEAR */ - , undefined, undefined, oldTarget); - } + var warnInvalidSource = function warnInvalidSource(s) { + console.warn("Invalid watch source: ", s, "A watch source can only be a getter/effect function, a ref, " + "a reactive object, or an array of these types."); + }; - return result; - } - - function createForEach(isReadonly, isShallow) { - return function forEach(callback, thisArg) { - var observed = this; - var target = observed["__v_raw" - /* RAW */ - ]; - var rawTarget = toRaw(target); - var wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; - !isReadonly && track(rawTarget, "iterate" - /* ITERATE */ - , ITERATE_KEY); - return target.forEach(function (value, key) { - return (// important: make sure the callback is - // 1. invoked with the reactive map as `this` and 3rd arg - // 2. the value received should be a corresponding reactive/readonly. - callback.call(thisArg, wrap(value), wrap(key), observed) - ); - }); + var getter; + var forceTrigger = false; + + if (isRef(source)) { + getter = function getter() { + return source.value; + }; + + forceTrigger = !!source._shallow; + } else if (isReactive(source)) { + getter = function getter() { + return source; + }; + + deep = true; + } else if (_.isArray(source)) { + getter = function getter() { + return source.map(function (s) { + if (isRef(s)) { + return s.value; + } else if (isReactive(s)) { + return traverse(s); + } else if (_.isFunction(s)) { + return s.call(instance); + } else { + warnInvalidSource(s); + } + }); + }; + } else if (_.isFunction(source)) { + if (cb) { + // getter with cb + getter = function getter() { + return source.call(instance); }; - } + } else { + // no cb -> simple effect + getter = function getter() { + if (instance && instance.isUnmounted) { + return; + } - function createIterableMethod(method, isReadonly, isShallow) { - return function () { - var target = this["__v_raw" - /* RAW */ - ]; - var rawTarget = toRaw(target); - var targetIsMap = isMap$1(rawTarget); - var isPair = method === "entries" || method === Symbol.iterator && targetIsMap; - var isKeyOnly = method === "keys" && targetIsMap; - var innerIterator = target[method].apply(target, arguments); - var wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; - !isReadonly && track(rawTarget, "iterate" - /* ITERATE */ - , isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); // return a wrapped iterator which returns observed versions of the - // values emitted from the real iterator - - return _defineProperty({ - // iterator protocol - next: function next() { - var _innerIterator$next = innerIterator.next(), - value = _innerIterator$next.value, - done = _innerIterator$next.done; - - return done ? { - value: value, - done: done - } : { - value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value), - done: done - }; - } - }, Symbol.iterator, function () { - return this; - }); - }; - } + if (cleanup) { + cleanup(); + } - function createReadonlyMethod(type) { - return function () { - { - var key = (arguments.length <= 0 ? undefined : arguments[0]) ? "on key \"".concat(arguments.length <= 0 ? undefined : arguments[0], "\" ") : ""; - console.warn("".concat(capitalize(type), " operation ").concat(key, "failed: target is readonly."), toRaw(this)); - } - return type === "delete" - /* DELETE */ - ? false : this; + return source.call(instance, onInvalidate); }; + } + } else { + getter = function getter() {}; + + warnInvalidSource(source); } - var mutableInstrumentations = { - get: function get(key) { - return get$1(this, key); - }, + if (cb && deep) { + var baseGetter = getter; - get size() { - return size(this); - }, - - has: has$1$1, - add: add, - set: set$1$1, - delete: deleteEntry, - clear: clear, - forEach: createForEach(false, false) - }; - var shallowInstrumentations = { - get: function get(key) { - return get$1(this, key, false, true); - }, + getter = function getter() { + return traverse(baseGetter()); + }; + } - get size() { - return size(this); - }, + var cleanup; - has: has$1$1, - add: add, - set: set$1$1, - delete: deleteEntry, - clear: clear, - forEach: createForEach(false, true) + var onInvalidate = function onInvalidate(fn) { + cleanup = runner.options.onStop = function () { + fn.call(instance); + }; }; - var readonlyInstrumentations = { - get: function get(key) { - return get$1(this, key, true); - }, - get size() { - return size(this, true); - }, - - has: function has(key) { - return has$1$1.call(this, key, true); - }, - add: createReadonlyMethod("add" - /* ADD */ - ), - set: createReadonlyMethod("set" - /* SET */ - ), - delete: createReadonlyMethod("delete" - /* DELETE */ - ), - clear: createReadonlyMethod("clear" - /* CLEAR */ - ), - forEach: createForEach(true, false) + var oldValue = _.isArray(source) ? [] : INITIAL_WATCHER_VALUE; + + var job = function job() { + if (!runner.active) { + return; + } + + if (cb) { + // watch(source, cb) + var newValue = runner(); + + if (deep || forceTrigger || hasChanged(newValue, oldValue)) { + // cleanup before running cb again + if (cleanup) { + cleanup(); + } + + cb.apply(instance, [newValue, // pass undefined as the old value when it's changed for the first time + oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue, onInvalidate]); + oldValue = newValue; + } + } else { + // watchEffect + runner(); + } + }; // important: mark the job as a watcher callback so that scheduler knows + // it is allowed to self-trigger (#1727) + + + job.allowRecurse = !!cb; + job.id = ++uid; + var scheduler; + + if (sync === true) { + scheduler = job; + } else { + scheduler = function scheduler() { + return queueWatcher(job); + }; + } + + var runner = effect(function () { + try { + return getter(); + } catch (e) {// 吞掉异常 + } + }, { + lazy: true, + onTrack: onTrack, + onTrigger: onTrigger, + scheduler: scheduler + }); // initial run + + if (cb) { + if (immediate) { + job(); + } else { + oldValue = runner(); + } + } else { + runner(); + } + + return function () { + stop(runner); }; - var iteratorMethods = ["keys", "values", "entries", Symbol.iterator]; - iteratorMethods.forEach(function (method) { - mutableInstrumentations[method] = createIterableMethod(method, false, false); - readonlyInstrumentations[method] = createIterableMethod(method, true, false); - shallowInstrumentations[method] = createIterableMethod(method, false, true); - }); + } - function createInstrumentationGetter(isReadonly, shallow) { - var instrumentations = shallow ? shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations; - return function (target, key, receiver) { - if (key === "__v_isReactive" - /* IS_REACTIVE */ - ) { - return !isReadonly; - } else if (key === "__v_isReadonly" - /* IS_READONLY */ - ) { - return isReadonly; - } else if (key === "__v_raw" - /* RAW */ - ) { - return target; - } + function traverse(value) { + var seen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set(); - return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver); - }; + if (!_.isObject(value) || seen.has(value)) { + return value; } - var mutableCollectionHandlers = { - get: createInstrumentationGetter(false, false) - }; - var readonlyCollectionHandlers = { - get: createInstrumentationGetter(true, false) - }; - - function checkIdentityKeys(target, has, key) { - var rawKey = toRaw(key); + seen.add(value); - if (rawKey !== key && has.call(target, rawKey)) { - var type = toRawType(target); - console.warn("Reactive ".concat(type, " contains both the raw and reactive ") + "versions of the same object".concat(type === "Map" ? " as keys" : "", ", ") + "which can lead to inconsistencies. " + "Avoid differentiating between the raw and reactive versions " + "of an object and only use the reactive version if possible."); - } + if (isRef(value)) { + traverse(value.value, seen); + } else if (_.isArray(value)) { + for (var i = 0; i < value.length; i++) { + traverse(value[i], seen); + } + } else if (isSet(value) || isMap(value)) { + value.forEach(function (v) { + traverse(v, seen); + }); + } else { + for (var key in value) { + traverse(value[key], seen); + } } - var reactiveMap = new WeakMap(); - var readonlyMap = new WeakMap(); - - function targetTypeMap(rawType) { - switch (rawType) { - case "Object": - case "Array": - return 1; + return value; + } - case "Map": - case "Set": - case "WeakMap": - case "WeakSet": - return 2; + var falsy; + var operators = { + "||": falsy, + "&&": falsy, + "(": falsy, + ")": falsy + }; - default: - return 0; - } - } + function runBinaryFunction(binarys) { + var expr = ""; - function getTargetType(value) { - return value["__v_skip" - /* SKIP */ - ] || !Object.isExtensible(value) ? 0 - /* INVALID */ - : targetTypeMap(toRawType(value)); + for (var i = 0, len = binarys.length; i < len; i++) { + if (_.isBoolean(binarys[i]) || _.has(operators, binarys[i])) { + expr += binarys[i]; + } else { + expr += "false"; + } } - function reactive(target) { - // if trying to observe a readonly proxy, return the readonly version. - if (target && target["__v_isReadonly" - /* IS_READONLY */ - ]) { - return target; - } - - return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers); - } // Return a reactive-copy of the original object, where only the root level + return new Function("return " + expr)(); + } - function readonly(target) { - return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers); - } // Return a reactive-copy of the original object, where only the root level + function watchExp(model, exp) { + var getter = parsePath(exp); + var result = getter.call(model, model); - function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) { - if (!isObject(target)) { - { - console.warn("value cannot be made reactive: ".concat(String(target))); - } - return target; - } // target is already a Proxy, return it. - // exception: calling readonly() on a reactive object - - - if (target["__v_raw" - /* RAW */ - ] && !(isReadonly && target["__v_isReactive" - /* IS_REACTIVE */ - ])) { - return target; - } // target already has corresponding Proxy - - - var proxyMap = isReadonly ? readonlyMap : reactiveMap; - var existingProxy = proxyMap.get(target); - - if (existingProxy) { - return existingProxy; - } // only a whitelist of value types can be observed. - - - var targetType = getTargetType(target); - - if (targetType === 0 - /* INVALID */ - ) { - return target; - } - - var proxy = new Proxy(target, targetType === 2 - /* COLLECTION */ - ? collectionHandlers : baseHandlers); - proxyMap.set(target, proxy); - return proxy; + if (_.isArray(result)) { + return result.concat(); } - function isReactive(value) { - if (isReadonly(value)) { - return isReactive(value["__v_raw" - /* RAW */ - ]); - } + return result; + } - return !!(value && value["__v_isReactive" - /* IS_REACTIVE */ - ]); + function watch(model, expOrFn, cb, options) { + if (isPlainObject(cb)) { + options = cb; + cb = cb.handler; } - function isReadonly(value) { - return !!(value && value["__v_isReadonly" - /* IS_READONLY */ - ]); + if (typeof cb === "string") { + cb = model[cb]; } - function toRaw(observed) { - return observed && toRaw(observed["__v_raw" - /* RAW */ - ]) || observed; - } + options = options || {}; + options.user = true; + var exps; - function isRef(r) { - return Boolean(r && r.__v_isRef === true); + if (_.isFunction(expOrFn) || !(exps = expOrFn.match(/[a-zA-Z0-9_.*]+|[|][|]|[&][&]|[(]|[)]/g)) || exps.length === 1 && !/\*/.test(expOrFn)) { + var watcher = innerWatch(_.isFunction(expOrFn) ? expOrFn : function () { + return watchExp(model, expOrFn); + }, cb, options); + return function unwatchFn() { + watcher(); + }; } - var ComputedRefImpl = /*#__PURE__*/function () { - function ComputedRefImpl(getter, _setter, isReadonly) { - var _this2 = this; + var watchers = []; + var fns = exps.slice(); + var complete = false, + running = false; - _classCallCheck(this, ComputedRefImpl); + var callback = function callback(index, newValue, oldValue, attrs) { + if (complete === true) { + return; + } - this._setter = _setter; - this._dirty = true; - this.__v_isRef = true; - this.effect = effect(getter, { - lazy: true, - scheduler: function scheduler() { - if (!_this2._dirty) { - _this2._dirty = true; - trigger(toRaw(_this2), "set" - /* SET */ - , "value"); - } - } - }); - this["__v_isReadonly" - /* IS_READONLY */ - ] = isReadonly; - } - - _createClass(ComputedRefImpl, [{ - key: "value", - get: function get() { - if (this._dirty) { - this._value = this.effect(); - this._dirty = false; - } - - track(toRaw(this), "get" - /* GET */ - , "value"); - return this._value; - }, - set: function set(newValue) { - this._setter(newValue); - } - }]); - - return ComputedRefImpl; - }(); + fns[index] = true; - function computed(getterOrOptions) { - var getter; - var setter; + if (runBinaryFunction(fns)) { + complete = true; + cb(newValue, oldValue, attrs); + } - if (isFunction(getterOrOptions)) { - getter = getterOrOptions; - - setter = function setter() { - console.warn("Write operation failed: computed value is readonly"); - }; - } else { - getter = getterOrOptions.get; - setter = getterOrOptions.set; - } - - return new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set); - } - - function noop() {} - function isNative(Ctor) { - return typeof Ctor === "function" && /native code/.test(Ctor.toString()); - } - var isIE = function isIE() { - if (typeof navigator === "undefined") { - return false; + if (options && options.sync) { + complete = false; + running = false; + fns = exps.slice(); + } else { + if (!running) { + running = true; + nextTick(function () { + complete = false; + running = false; + fns = exps.slice(); + }); } - - return /(msie|trident)/i.test(navigator.userAgent.toLowerCase()); + } }; - var getIEVersion = function getIEVersion() { - var version = 0; - if (typeof navigator === "undefined") { - return false; - } - - var agent = navigator.userAgent.toLowerCase(); - var v1 = agent.match(/(?:msie\s([\w.]+))/); - var v2 = agent.match(/(?:trident.*rv:([\w.]+))/); - - if (v1 && v2 && v1[1] && v2[1]) { - version = Math.max(v1[1] * 1, v2[1] * 1); - } else if (v1 && v1[1]) { - version = v1[1] * 1; - } else if (v2 && v2[1]) { - version = v2[1] * 1; - } else { - version = 0; - } - - return version; - }; - isIE() && getIEVersion() < 9; - var _toString = Object.prototype.toString; - function isPlainObject(obj) { - return _toString.call(obj) === "[object Object]"; - } - var bailRE = /[^\w.$]/; - function parsePath(path) { - if (bailRE.test(path)) { + _.each(exps, function (exp, i) { + if (_.has(operators, exp)) { + return; + } //a.**形式 + + + if (/^[1-9a-zA-Z.]+\*\*$/.test(exp) || exp === "**") { + exp = exp.replace(".**", ""); + var getter = exp === "**" ? function (m) { + return m; + } : parsePath(exp); + watchers.push(innerWatch(function () { + return getter.call(model, model); + }, function (newValue, oldValue) { + callback(i, newValue, oldValue, _.extend({ + index: i + })); + }, _.extend({ + deep: true + }, options))); + return; + } + + if (/^(\*\*\.)+[1-9a-zA-Z]+(\.\*\*$)/.test(exp)) { + throw new Error("not support"); + } //含有*的情况,如a.*,如*.a,*.*.a,a.*.a + + + if (/\*/.test(exp)) { + // eslint-disable-next-line no-inner-declarations + var travers = function travers(root, deps, parent, key, res) { + if (deps.length === paths.length) { + root !== undefined && res.push({ + parent: parent, + k: key + }); return; - } - - var segments = path.split("."); - return function (obj) { - for (var i = 0; i < segments.length; i++) { - if (!obj) return; - obj = obj[segments[i]]; + } + + if (root) { + if (paths[deps.length] === "*") { + // 遍历所有节点 + for (var k in root) { + travers(root[k], deps.concat([k]), root, k, res); + } + } else { + var nextKey = paths[deps.length]; + travers(root[nextKey], deps.concat([nextKey]), root, nextKey, res); } - - return obj; + } }; - } - var nextTick = function () { - var callbacks = []; - var pending = false; - var timerFunc; - function nextTickHandler() { - pending = false; - var copies = callbacks.slice(0); - callbacks.length = 0; - - for (var i = 0; i < copies.length; i++) { - copies[i](); - } - } // An asynchronous deferring mechanism. - // In pre 2.4, we used to use microtasks (Promise/MutationObserver) - // but microtasks actually has too high a priority and fires in between - // supposedly sequential events (e.g. #4521, #6690) or even between - // bubbling of the same event (#6566). Technically setImmediate should be - // the ideal choice, but it's not available everywhere; and the only polyfill - // that consistently queues the callback after all DOM events triggered in the - // same loop is by using MessageChannel. - - /* istanbul ignore if */ - - - if (typeof setImmediate !== "undefined" && isNative(setImmediate)) { - timerFunc = function timerFunc() { - setImmediate(nextTickHandler); - }; - } else if (typeof MessageChannel !== "undefined" && (isNative(MessageChannel) || // PhantomJS - MessageChannel.toString() === "[object MessageChannelConstructor]")) { - var channel = new MessageChannel(); - var port = channel.port2; - channel.port1.onmessage = nextTickHandler; - - timerFunc = function timerFunc() { - port.postMessage(1); - }; - } else if (typeof Promise !== "undefined" && isNative(Promise)) { - /* istanbul ignore next */ - // use microtask in non-DOM environments, e.g. Weex - var p = Promise.resolve(); - - timerFunc = function timerFunc() { - p.then(nextTickHandler); - }; - } else { - // fallback to setTimeout - timerFunc = function timerFunc() { - setTimeout(nextTickHandler, 0); - }; - } - - return function queueNextTick(cb, ctx) { - var _resolve; - - callbacks.push(function () { - if (cb) { - try { - cb.call(ctx); - } catch (e) { - console.error(e); - } - } else if (_resolve) { - _resolve(ctx); - } - }); - - if (!pending) { - pending = true; - timerFunc(); - } // $flow-disable-line + //先获取到能获取到的对象 + var paths = exp.split("."); + var prePaths = []; + for (var _i = 0, len = paths.length; _i < len; _i++) { + if (paths[_i] === "*") { + break; + } - if (!cb && typeof Promise !== "undefined") { - return new Promise(function (resolve) { - _resolve = resolve; - }); - } - }; - }(); - - var mixinInjection = {}; - function getMixins(type) { - return mixinInjection[type]; - } - function mixin(xtype, cls) { - mixinInjection[xtype] = _.cloneDeep(cls); - } - - var queue = []; - var activatedChildren = []; - var has = {}; - var waiting = false; - var flushing = false; - var index = 0; - - function resetSchedulerState() { - index = queue.length = activatedChildren.length = 0; - has = {}; - waiting = flushing = false; - } - - function flushSchedulerQueue() { - flushing = true; - var watcher; - var id; - var options; // Sort queue before flush. - // This ensures that: - // 1. Components are updated from parent to child. (because parent is always - // created before the child) - // 2. A component's user watchers are run before its render watcher (because - // user watchers are created before the render watcher) - // 3. If a component is destroyed during a parent component's watcher run, - // its watchers can be skipped. - - queue.sort(function (a, b) { - return a.id - b.id; - }); // do not cache length because more watchers might be pushed - // as we run existing watchers - - for (index = 0; index < queue.length; index++) { - watcher = queue[index].watcher; - options = queue[index].options; - id = watcher.id; - has[id] = null; - watcher(options); + prePaths[_i] = paths[_i]; } - resetSchedulerState(); - } - - function queueWatcher(watcher, options) { - var id = watcher.id; - - if (has[id] == null) { - has[id] = true; + var v; - if (!flushing) { - queue.push({ - watcher: watcher, - options: options - }); - } else { - // if already flushing, splice the watcher based on its id - // if already past its id, it will be run next immediately. - var i = queue.length - 1; + if (prePaths.length > 0) { + var _getter = parsePath(prePaths.join(".")); - while (i > index && queue[i].watcher.id > watcher.id) { - i--; - } - - queue.splice(i + 1, 0, { - watcher: watcher, - options: options - }); - } // queue the flush - - - if (!waiting) { - waiting = true; - nextTick(flushSchedulerQueue); - } - } - } - - function innerWatch(source, cb, options) { - if (!_.isFunction(cb)) { - console.warn("`watch(fn, options?)` signature has been moved to a separate API. " + "Use `watchEffect(fn, options?)` instead. `watch` now only " + "supports `watch(source, cb, options?) signature."); - } - - return doWatch(source, cb, options); - } - var INITIAL_WATCHER_VALUE = {}; - var objectToString = Object.prototype.toString; - - var toTypeString = function toTypeString(value) { - return objectToString.call(value); - }; - - var isMap = function isMap(val) { - return toTypeString(val) === "[object Map]"; - }; - - var isSet = function isSet(val) { - return toTypeString(val) === "[object Set]"; - }; - - var hasChanged = function hasChanged(value, oldValue) { - return value !== oldValue && (value === value || oldValue === oldValue); - }; - - var uid = 0; - - function doWatch(source, cb, options, instance) { - options = options || {}; - var _options = options, - immediate = _options.immediate, - deep = _options.deep, - sync = _options.sync, - onTrack = _options.onTrack, - onTrigger = _options.onTrigger; - - if (!cb) { - if (immediate !== undefined) { - console.warn("watch() \"immediate\" option is only respected when using the " + "watch(source, callback, options?) signature."); - } - - if (deep !== undefined) { - console.warn("watch() \"deep\" option is only respected when using the " + "watch(source, callback, options?) signature."); - } - } - - var warnInvalidSource = function warnInvalidSource(s) { - console.warn("Invalid watch source: ", s, "A watch source can only be a getter/effect function, a ref, " + "a reactive object, or an array of these types."); - }; - - var getter; - var forceTrigger = false; - - if (isRef(source)) { - getter = function getter() { - return source.value; - }; - - forceTrigger = !!source._shallow; - } else if (isReactive(source)) { - getter = function getter() { - return source; - }; - - deep = true; - } else if (_.isArray(source)) { - getter = function getter() { - return source.map(function (s) { - if (isRef(s)) { - return s.value; - } else if (isReactive(s)) { - return traverse(s); - } else if (_.isFunction(s)) { - return s.call(instance); - } else { - warnInvalidSource(s); - } - }); - }; - } else if (_.isFunction(source)) { - if (cb) { - // getter with cb - getter = function getter() { - return source.call(instance); - }; - } else { - // no cb -> simple effect - getter = function getter() { - if (instance && instance.isUnmounted) { - return; - } - - if (cleanup) { - cleanup(); - } - - return source.call(instance, onInvalidate); - }; - } + v = _getter.call(model, model); } else { - getter = function getter() {}; - - warnInvalidSource(source); + v = model; } - if (cb && deep) { - var baseGetter = getter; - - getter = function getter() { - return traverse(baseGetter()); - }; - } - - var cleanup; - - var onInvalidate = function onInvalidate(fn) { - cleanup = runner.options.onStop = function () { - fn.call(instance); - }; - }; - - var oldValue = _.isArray(source) ? [] : INITIAL_WATCHER_VALUE; - - var job = function job() { - if (!runner.active) { - return; - } + paths = paths.slice(prePaths.length); + var changes = []; + watchers.push(innerWatch(function () { + var routes = []; + travers(v, [], v, null, routes); - if (cb) { - // watch(source, cb) - var newValue = runner(); + for (var _i2 = 0, _len = routes.length; _i2 < _len; _i2++) { + var _routes$_i = routes[_i2], + parent = _routes$_i.parent, + k = _routes$_i.k; - if (deep || forceTrigger || hasChanged(newValue, oldValue)) { - // cleanup before running cb again - if (cleanup) { - cleanup(); - } + for (var j = 0, l = changes.length; j < l; j++) { + var _changes$j = changes[j], + target = _changes$j.target, + key = _changes$j.key; - cb.apply(instance, [newValue, // pass undefined as the old value when it's changed for the first time - oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue, onInvalidate]); - oldValue = newValue; - } - } else { - // watchEffect - runner(); + if (target === toRaw(parent) && key === k) { + return true; + } } - }; // important: mark the job as a watcher callback so that scheduler knows - // it is allowed to self-trigger (#1727) + } + }, function (newValue) { + changes = []; + if (newValue === true) { + callback(i, undefined, undefined, _.extend({ + index: i + })); + } + }, BI.extend({}, options, { + deep: true, + onTrigger: function onTrigger(_ref) { + var target = _ref.target, + key = _ref.key; + changes.push({ + target: target, + key: key + }); + } + }))); + return; + } + + watchers.push(innerWatch(function () { + return watchExp(model, exp); + }, function (newValue, oldValue) { + callback(i, newValue, oldValue, _.extend({ + index: i + })); + }, options)); + }); - job.allowRecurse = !!cb; - job.id = ++uid; - var scheduler; + return watchers; + } - if (sync === true) { - scheduler = job; - } else { - scheduler = function scheduler() { - return queueWatcher(job); - }; - } + var REACTIVE = true; - var runner = effect(getter, { - lazy: true, - onTrack: onTrack, - onTrigger: onTrigger, - scheduler: scheduler - }); // initial run + function initState(vm, state) { + if (state) { + vm.$$state = REACTIVE ? reactive(state) : state; + } + } - if (cb) { - if (immediate) { - job(); - } else { - oldValue = runner(); - } - } else { - runner(); - } + function initComputed(vm, c) { + var $$computed = vm.$$computed = {}; - return function () { - stop(runner); - }; + for (var key in c) { + $$computed[key] = computed(_.bind(c[key], vm)); } + } - function traverse(value) { - var seen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set(); - - if (!_.isObject(value) || seen.has(value)) { - return value; - } + function initWatch(vm, watch) { + vm._watchers || (vm._watchers = []); - seen.add(value); + for (var key in watch) { + var handler = watch[key]; - if (isRef(value)) { - traverse(value.value, seen); - } else if (_.isArray(value)) { - for (var i = 0; i < value.length; i++) { - traverse(value[i], seen); - } - } else if (isSet(value) || isMap(value)) { - value.forEach(function (v) { - traverse(v, seen); - }); - } else { - for (var key in value) { - traverse(value[key], seen); - } + if (_.isArray(handler)) { + for (var i = 0; i < handler.length; i++) { + vm._watchers.push(createWatcher(vm, key, handler[i])); } - - return value; + } else { + vm._watchers.push(createWatcher(vm, key, handler)); + } } + } - var falsy; - var operators = { - "||": falsy, - "&&": falsy, - "(": falsy, - ")": falsy - }; + function createWatcher(vm, keyOrFn, cb, options) { + if (isPlainObject(cb)) { + options = cb; + cb = cb.handler; + } - function runBinaryFunction(binarys) { - var expr = ""; + if (typeof cb === "string") { + cb = vm[cb]; + } - for (var i = 0, len = binarys.length; i < len; i++) { - if (_.isBoolean(binarys[i]) || _.has(operators, binarys[i])) { - expr += binarys[i]; - } else { - expr += "false"; - } - } + return watch(vm.model, keyOrFn, _.bind(cb, vm), options); + } - return new Function("return " + expr)(); + function initMethods(vm, methods) { + for (var key in methods) { + vm[key] = methods[key] == null ? noop : _.bind(methods[key], vm); } + } - function watchExp(model, exp) { - var getter = parsePath(exp); - var result = getter.call(model, model); + function initMixins(vm, mixins) { + mixins = (mixins || []).slice(0); - if (_.isArray(result)) { - return result.concat(); - } + _.each(mixins.reverse(), function (mixinType) { + var mixin = getMixins(mixinType); - return result; - } + for (var key in mixin) { + if (typeof mixin[key] !== "function") continue; + if (_.has(vm, key)) continue; + vm[key] = _.bind(mixin[key], vm); + } + }); + } - function watch(model, expOrFn, cb, options) { - if (isPlainObject(cb)) { - options = cb; - cb = cb.handler; - } + function defineProps(vm) { + vm.model = new Proxy({}, { + get: function get(target, key) { + if (vm.$$computed && key in vm.$$computed) { + try { + return vm.$$computed[key].value; + } catch (e) {// 吞掉异常 + } - if (typeof cb === "string") { - cb = model[cb]; + return; } - options = options || {}; - options.user = true; - var exps; - - if (_.isFunction(expOrFn) || !(exps = expOrFn.match(/[a-zA-Z0-9_.*]+|[|][|]|[&][&]|[(]|[)]/g)) || exps.length === 1 && !/\*/.test(expOrFn)) { - var watcher = innerWatch(_.isFunction(expOrFn) ? expOrFn : function () { - return watchExp(model, expOrFn); - }, cb, options); - return function unwatchFn() { - watcher(); - }; + if (vm.$$state && key in vm.$$state) { + return vm.$$state[key]; } - var watchers = []; - var fns = exps.slice(); - var complete = false, - running = false; - - var callback = function callback(index, newValue, oldValue, attrs) { - if (complete === true) { - return; - } - - fns[index] = true; - - if (runBinaryFunction(fns)) { - complete = true; - cb(newValue, oldValue, attrs); - } - - if (options && options.sync) { - complete = false; - running = false; - fns = exps.slice(); - } else { - if (!running) { - running = true; - nextTick(function () { - complete = false; - running = false; - fns = exps.slice(); - }); - } - } - }; - - _.each(exps, function (exp, i) { - if (_.has(operators, exp)) { - return; - } //a.**形式 - - - if (/^[1-9a-zA-Z.]+\*\*$/.test(exp) || exp === "**") { - exp = exp.replace(".**", ""); - var getter = exp === "**" ? function (m) { - return m; - } : parsePath(exp); - var v = getter.call(model, model); - watchers.push(innerWatch(v, function (newValue, oldValue) { - callback(i, newValue, oldValue, _.extend({ - index: i - })); - })); - return; - } - - if (/^(\*\*\.)+[1-9a-zA-Z]+(\.\*\*$)/.test(exp)) { - throw new Error("not support"); - } //含有*的情况,如a.*,如*.a,*.*.a,a.*.a - - - if (/\*/.test(exp)) { - // eslint-disable-next-line no-inner-declarations - var travers = function travers(root, deps, parent, key, res) { - if (deps.length === paths.length) { - root !== undefined && res.push({ - parent: parent, - k: key - }); - return; - } - - if (root) { - if (paths[deps.length] === "*") { - // 遍历所有节点 - for (var k in root) { - travers(root[k], deps.concat([k]), root, k, res); - } - } else { - var nextKey = paths[deps.length]; - travers(root[nextKey], deps.concat([nextKey]), root, nextKey, res); - } - } - }; - - //先获取到能获取到的对象 - var paths = exp.split("."); - var prePaths = []; - - for (var _i = 0, len = paths.length; _i < len; _i++) { - if (paths[_i] === "*") { - break; - } - - prePaths[_i] = paths[_i]; - } - - var _v; - - if (prePaths.length > 0) { - var _getter = parsePath(prePaths.join(".")); - - _v = _getter.call(model, model); - } else { - _v = model; - } - - paths = paths.slice(prePaths.length); - var changes = []; - watchers.push(innerWatch(function () { - var routes = []; - travers(_v, [], _v, null, routes); - - for (var _i2 = 0, _len = routes.length; _i2 < _len; _i2++) { - var _routes$_i = routes[_i2], - parent = _routes$_i.parent, - k = _routes$_i.k; - - for (var j = 0, l = changes.length; j < l; j++) { - var _changes$j = changes[j], - target = _changes$j.target, - key = _changes$j.key; - - if (target === toRaw(parent) && key === k) { - return true; - } - } - } - }, function (newValue) { - changes = []; - - if (newValue === true) { - callback(i, undefined, undefined, _.extend({ - index: i - })); - } - }, { - deep: true, - onTrigger: function onTrigger(_ref) { - var target = _ref.target, - key = _ref.key; - changes.push({ - target: target, - key: key - }); - } - })); - return; - } - - watchers.push(innerWatch(function () { - return watchExp(model, exp); - }, function (newValue, oldValue) { - callback(i, newValue, oldValue, _.extend({ - index: i - })); - })); - }); - - return watchers; - } + var p = vm._parent; - var REACTIVE = true; + while (p) { + if (p.$$context && key in p.$$context) { + return p.$$context[key]; + } - function initState(vm, state) { - if (state) { - vm.$$state = REACTIVE ? reactive(state) : state; + p = p._parent; } - } - - function initComputed(vm, c) { - var $$computed = vm.$$computed = {}; - - for (var key in c) { - $$computed[key] = computed(_.bind(c[key], vm)); + }, + set: function set(target, key, value) { + if (vm.$$state && key in vm.$$state) { + vm.$$state[key] = value; + return true; } - } - function initWatch(vm, watch) { - vm._watchers || (vm._watchers = []); - - for (var key in watch) { - var handler = watch[key]; + var p = vm._parent; - if (_.isArray(handler)) { - for (var i = 0; i < handler.length; i++) { - vm._watchers.push(createWatcher(vm, key, handler[i])); - } - } else { - vm._watchers.push(createWatcher(vm, key, handler)); - } - } - } + while (p) { + if (p.$$context && key in p.$$context) { + p.$$context[key] = value; + return true; + } - function createWatcher(vm, keyOrFn, cb, options) { - if (isPlainObject(cb)) { - options = cb; - cb = cb.handler; + p = p._parent; } - if (typeof cb === "string") { - cb = vm[cb]; + return true; + } + }); + } + + function defineContext(vm, keys) { + var props = {}; + + var _loop = function _loop(i, len) { + var key = keys[i]; + props[key] = { + enumerable: true, + configurable: true, + get: function get() { + return vm.model[key]; + }, + set: function set(val) { + return vm.model[key] = val; } + }; + }; - return watch(vm.model, keyOrFn, _.bind(cb, vm), options); + for (var i = 0, len = keys.length; i < len; i++) { + _loop(i); } - function initMethods(vm, methods) { - for (var key in methods) { - vm[key] = methods[key] == null ? noop : _.bind(methods[key], vm); - } - } + vm.$$context = Object.defineProperties({}, props); + } - function initMixins(vm, mixins) { - mixins = (mixins || []).slice(0); + function getInjectValue(vm, key) { + var p = vm._parent; - _.each(mixins.reverse(), function (mixinType) { - var mixin = getMixins(mixinType); + while (p) { + if (p.$$context && key in p.$$context) { + return p.$$context[key]; + } - for (var key in mixin) { - if (typeof mixin[key] !== "function") continue; - if (_.has(vm, key)) continue; - vm[key] = _.bind(mixin[key], vm); - } - }); + p = p._parent; } + } - function defineProps(vm) { - vm.model = new Proxy({}, { - get: function get(target, key) { - if (vm.$$computed && key in vm.$$computed) { - try { - return vm.$$computed[key].value; - } catch (e) {// 吞掉异常 - } - - return; - } - - if (vm.$$state && key in vm.$$state) { - return vm.$$state[key]; - } - - var p = vm._parent; - - while (p) { - if (p.$$context && key in p.$$context) { - return p.$$context[key]; - } - - p = p._parent; - } - }, - set: function set(target, key, value) { - if (vm.$$state && key in vm.$$state) { - vm.$$state[key] = value; - return true; - } - - var p = vm._parent; - - while (p) { - if (p.$$context && key in p.$$context) { - p.$$context[key] = value; - return true; - } + function getInjectValues(vm) { + var inject = vm.inject || []; + var result = {}; - p = p._parent; - } + _.each(inject, function (key) { + result[key] = getInjectValue(vm, key); + }); - return true; - } + return result; + } + + var Model = /*#__PURE__*/function () { + function Model() { + _classCallCheck(this, Model); + } + + _createClass(Model, [{ + key: "_constructor", + value: function _constructor(options, destroyHandler) { + this.options = options || {}; + this._parent = Model.target; + var state = _.isFunction(this.state) ? this.state() : this.state; + var computed = this.computed; + var context = this.context; + var inject = this.inject; + var childContext = this.childContext; + var watch = this.watch; + var actions = this.actions; + + _.keys(state).concat(_.keys(computed)).concat(inject || []).concat(context || []); + + var mixins = this.mixins; + defineProps(this); + childContext && defineContext(this, childContext); + initMixins(this, mixins); + this.init(); + initState(this, _.extend(getInjectValues(this), state)); + initComputed(this, computed); + REACTIVE && initWatch(this, watch); + initMethods(this, actions); + this.created && this.created(); + this._destroyHandler = destroyHandler; + } + }, { + key: "_init", + value: function _init() {} + }, { + key: "init", + value: function init() { + this._init(); + } + }, { + key: "destroy", + value: function destroy() { + _.each(this._watchers, function (unwatches) { + unwatches = _.isArray(unwatches) ? unwatches : [unwatches]; + + _.each(unwatches, function (unwatch) { + unwatch(); + }); }); - } - function defineContext(vm, keys) { - var props = {}; - - var _loop = function _loop(i, len) { - var key = keys[i]; - props[key] = { - enumerable: true, - configurable: true, - get: function get() { - return vm.model[key]; - }, - set: function set(val) { - return vm.model[key] = val; - } - }; - }; - - for (var i = 0, len = keys.length; i < len; i++) { - _loop(i); - } - - vm.$$context = Object.defineProperties({}, props); - } - - function getInjectValue(vm, key) { - var p = vm._parent; - - while (p) { - if (p.$$context && key in p.$$context) { - return p.$$context[key]; - } + this._watchers && (this._watchers = []); + this.destroyed && this.destroyed(); + this.$$computed = null; + this.$$state = null; + this._destroyHandler && this._destroyHandler(); + } + }]); - p = p._parent; - } + return Model; + }(); + function set(target, key, val) { + if (_.isArray(target)) { + target.length = Math.max(target.length, key); + target.splice(key, 1, val); + return val; } - function getInjectValues(vm) { - var inject = vm.inject || []; - var result = {}; - - _.each(inject, function (key) { - result[key] = getInjectValue(vm, key); - }); - - return result; + target[key] = val; + } + function del(target, key) { + if (_.isArray(target)) { + target.splice(key, 1); + return; } - var Model = /*#__PURE__*/function () { - function Model() { - _classCallCheck(this, Model); - } - - _createClass(Model, [{ - key: "_constructor", - value: function _constructor(options, destroyHandler) { - this.options = options || {}; - this._parent = Model.target; - var state = _.isFunction(this.state) ? this.state() : this.state; - var computed = this.computed; - var context = this.context; - var inject = this.inject; - var childContext = this.childContext; - var watch = this.watch; - var actions = this.actions; - - _.keys(state).concat(_.keys(computed)).concat(inject || []).concat(context || []); - - var mixins = this.mixins; - defineProps(this); - childContext && defineContext(this, childContext); - initMixins(this, mixins); - this.init(); - initState(this, _.extend(getInjectValues(this), state)); - initComputed(this, computed); - REACTIVE && initWatch(this, watch); - initMethods(this, actions); - this.created && this.created(); - this._destroyHandler = destroyHandler; - } - }, { - key: "_init", - value: function _init() {} - }, { - key: "init", - value: function init() { - this._init(); - } - }, { - key: "destroy", - value: function destroy() { - _.each(this._watchers, function (unwatches) { - unwatches = _.isArray(unwatches) ? unwatches : [unwatches]; - - _.each(unwatches, function (unwatch) { - unwatch(); - }); - }); - - this._watchers && (this._watchers = []); - this.destroyed && this.destroyed(); - this.$$computed = null; - this.$$state = null; - this._destroyHandler && this._destroyHandler(); - } - }]); - - return Model; - }(); - function set(target, key, val) { - if (_.isArray(target)) { - target.length = Math.max(target.length, key); - target.splice(key, 1, val); - return val; - } - - target[key] = val; + if (!_.has(target, key)) { + return; } - function del(target, key) { - if (_.isArray(target)) { - target.splice(key, 1); - return; - } - if (!_.has(target, key)) { - return; - } + delete target[key]; + } + function define(model) { + return REACTIVE ? reactive(model) : model; + } + function config(options) { + options || (options = {}); - delete target[key]; - } - function define(model) { - return REACTIVE ? reactive(model) : model; + if ("reactive" in options) { + REACTIVE = options.reactive; } - function config(options) { - options || (options = {}); + } - if ("reactive" in options) { - REACTIVE = options.reactive; - } - } + function toJSON(model) { + var result; - function toJSON(model) { - var result; + if (_.isArray(model)) { + result = []; - if (_.isArray(model)) { - result = []; + for (var i = 0, len = model.length; i < len; i++) { + result[i] = toJSON(model[i]); + } + } else if (model && isPlainObject(model)) { + result = {}; - for (var i = 0, len = model.length; i < len; i++) { - result[i] = toJSON(model[i]); - } - } else if (model && isPlainObject(model)) { - result = {}; - - for (var key in model) { - result[key] = toJSON(model[key]); - } - } else { - result = model; - } - - return result; + for (var key in model) { + result[key] = toJSON(model[key]); + } + } else { + result = model; } - var version = "3.0"; + return result; + } + + var version = "3.0"; - exports.Model = Model; - exports.config = config; - exports.define = define; - exports.del = del; - exports.mixin = mixin; - exports.set = set; - exports.toJSON = toJSON; - exports.version = version; - exports.watch = watch; + exports.Model = Model; + exports.config = config; + exports.define = define; + exports.del = del; + exports.mixin = mixin; + exports.set = set; + exports.toJSON = toJSON; + exports.version = version; + exports.watch = watch; - Object.defineProperty(exports, '__esModule', { value: true }); + Object.defineProperty(exports, '__esModule', { value: true }); }))); From 41d2d5015bd666e1d0f77ba269e88f41f47909e6 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 13 Dec 2021 14:50:11 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0fix.proxy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/fix/fix.proxy.js | 1125 ++++++++++++++++++++++++++++------------- 1 file changed, 775 insertions(+), 350 deletions(-) diff --git a/dist/fix/fix.proxy.js b/dist/fix/fix.proxy.js index 78a241383..ad14e65ab 100644 --- a/dist/fix/fix.proxy.js +++ b/dist/fix/fix.proxy.js @@ -57,7 +57,161 @@ return obj; } - var EMPTY_OBJ = Object.freeze({}); + function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + } + + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); + } + + function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; + } + + function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); + } + + function _iterableToArrayLimit(arr, i) { + var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; + + if (_i == null) return; + var _arr = []; + var _n = true; + var _d = false; + + var _s, _e; + + try { + for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + } + + function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; + } + + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _createForOfIteratorHelper(o, allowArrayLike) { + var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; + + if (!it) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = it.call(o); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; + } + + /** + * Make a map and return a function for checking if a key + * is in that map. + * IMPORTANT: all calls of this function must be prefixed with + * \/\*#\_\_PURE\_\_\*\/ + * So that rollup can tree-shake them if necessary. + */ + function makeMap(str, expectsLowerCase) { + var map = Object.create(null); + var list = str.split(','); + + for (var i = 0; i < list.length; i++) { + map[list[i]] = true; + } + + return expectsLowerCase ? function (val) { + return !!map[val.toLowerCase()]; + } : function (val) { + return !!map[val]; + }; + } + + Object.freeze({}); Object.freeze([]); var extend = Object.assign; var hasOwnProperty = Object.prototype.hasOwnProperty; @@ -69,23 +223,23 @@ var isArray = Array.isArray; var isMap$1 = function isMap(val) { - return toTypeString$1(val) === "[object Map]"; + return toTypeString$1(val) === '[object Map]'; }; var isFunction = function isFunction(val) { - return typeof val === "function"; + return typeof val === 'function'; }; var isString = function isString(val) { - return typeof val === "string"; + return typeof val === 'string'; }; var isSymbol = function isSymbol(val) { - return _typeof(val) === "symbol"; + return _typeof(val) === 'symbol'; }; var isObject = function isObject(val) { - return val !== null && _typeof(val) === "object"; + return val !== null && _typeof(val) === 'object'; }; var objectToString$1 = Object.prototype.toString; @@ -95,13 +249,12 @@ }; var toRawType = function toRawType(value) { - return (// extract "RawType" from strings like "[object RawType]" - toTypeString$1(value).slice(8, -1) - ); + // extract "RawType" from strings like "[object RawType]" + return toTypeString$1(value).slice(8, -1); }; var isIntegerKey = function isIntegerKey(key) { - return isString(key) && key !== "NaN" && key[0] !== "-" && "".concat(parseInt(key, 10)) === key; + return isString(key) && key !== 'NaN' && key[0] !== '-' && '' + parseInt(key, 10) === key; }; var cacheStringFunction = function cacheStringFunction(fn) { @@ -121,82 +274,150 @@ }); // compare whether a value has changed, accounting for NaN. var hasChanged$1 = function hasChanged(value, oldValue) { - return value !== oldValue && (value === value || oldValue === oldValue); + return !Object.is(value, oldValue); }; - var targetMap = new WeakMap(); - var effectStack = []; - var activeEffect; - var ITERATE_KEY = Symbol("iterate"); - var MAP_KEY_ITERATE_KEY = Symbol("Map key iterate"); + var activeEffectScope; + + function recordEffectScope(effect, scope) { + scope = scope || activeEffectScope; - function isEffect(fn) { - return fn && fn._isEffect === true; + if (scope && scope.active) { + scope.effects.push(effect); + } } - function effect(fn) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : EMPTY_OBJ; + var createDep = function createDep(effects) { + var dep = new Set(effects); + dep.w = 0; + dep.n = 0; + return dep; + }; - if (isEffect(fn)) { - fn = fn.raw; - } + var wasTracked = function wasTracked(dep) { + return (dep.w & trackOpBit) > 0; + }; + + var newTracked = function newTracked(dep) { + return (dep.n & trackOpBit) > 0; + }; - var effect = createReactiveEffect(fn, options); + var initDepMarkers = function initDepMarkers(_ref) { + var deps = _ref.deps; - if (!options.lazy) { - effect(); + if (deps.length) { + for (var i = 0; i < deps.length; i++) { + deps[i].w |= trackOpBit; // set was tracked + } } + }; - return effect; - } + var finalizeDepMarkers = function finalizeDepMarkers(effect) { + var deps = effect.deps; - function stop(effect) { - if (effect.active) { - cleanup(effect); + if (deps.length) { + var ptr = 0; + + for (var i = 0; i < deps.length; i++) { + var dep = deps[i]; + + if (wasTracked(dep) && !newTracked(dep)) { + dep.delete(effect); + } else { + deps[ptr++] = dep; + } // clear bits - if (effect.options.onStop) { - effect.options.onStop(); + + dep.w &= ~trackOpBit; + dep.n &= ~trackOpBit; } - effect.active = false; + deps.length = ptr; } - } + }; + + var targetMap = new WeakMap(); // The number of effects currently being tracked recursively. + + var effectTrackDepth = 0; + var trackOpBit = 1; + /** + * The bitwise track markers support at most 30 levels of recursion. + * This value is chosen to enable modern JS engines to use a SMI on all platforms. + * When recursion depth is greater, fall back to using a full cleanup. + */ + + var maxMarkerBits = 30; + var effectStack = []; + var activeEffect; + var ITERATE_KEY = Symbol('iterate'); + var MAP_KEY_ITERATE_KEY = Symbol('Map key iterate'); - var uid$1 = 0; + var ReactiveEffect = /*#__PURE__*/function () { + function ReactiveEffect(fn) { + var scheduler = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + var scope = arguments.length > 2 ? arguments[2] : undefined; + + _classCallCheck(this, ReactiveEffect); + + this.fn = fn; + this.scheduler = scheduler; + this.active = true; + this.deps = []; + recordEffectScope(this, scope); + } + + _createClass(ReactiveEffect, [{ + key: "run", + value: function run() { + if (!this.active) { + return this.fn(); + } + + if (!effectStack.includes(this)) { + try { + effectStack.push(activeEffect = this); + enableTracking(); + trackOpBit = 1 << ++effectTrackDepth; + + if (effectTrackDepth <= maxMarkerBits) { + initDepMarkers(this); + } else { + cleanupEffect(this); + } - function createReactiveEffect(fn, options) { - var effect = function reactiveEffect() { - if (!effect.active) { - return options.scheduler ? undefined : fn(); + return this.fn(); + } finally { + if (effectTrackDepth <= maxMarkerBits) { + finalizeDepMarkers(this); + } + + trackOpBit = 1 << --effectTrackDepth; + resetTracking(); + effectStack.pop(); + var n = effectStack.length; + activeEffect = n > 0 ? effectStack[n - 1] : undefined; + } + } } + }, { + key: "stop", + value: function stop() { + if (this.active) { + cleanupEffect(this); - if (!effectStack.includes(effect)) { - cleanup(effect); + if (this.onStop) { + this.onStop(); + } - try { - enableTracking(); - effectStack.push(effect); - activeEffect = effect; - return fn(); - } finally { - effectStack.pop(); - resetTracking(); - activeEffect = effectStack[effectStack.length - 1]; + this.active = false; } } - }; + }]); - effect.id = uid$1++; - effect.allowRecurse = !!options.allowRecurse; - effect._isEffect = true; - effect.active = true; - effect.raw = fn; - effect.deps = []; - effect.options = options; - return effect; - } + return ReactiveEffect; + }(); - function cleanup(effect) { + function cleanupEffect(effect) { var deps = effect.deps; if (deps.length) { @@ -208,6 +429,32 @@ } } + function effect(fn, options) { + if (fn.effect) { + fn = fn.effect.fn; + } + + var _effect = new ReactiveEffect(fn); + + if (options) { + extend(_effect, options); + if (options.scope) recordEffectScope(_effect, options.scope); + } + + if (!options || !options.lazy) { + _effect.run(); + } + + var runner = _effect.run.bind(_effect); + + runner.effect = _effect; + return runner; + } + + function stop(runner) { + runner.effect.stop(); + } + var shouldTrack = true; var trackStack = []; @@ -227,7 +474,7 @@ } function track(target, type, key) { - if (!shouldTrack || activeEffect === undefined) { + if (!isTracking()) { return; } @@ -240,20 +487,44 @@ var dep = depsMap.get(key); if (!dep) { - depsMap.set(key, dep = new Set()); + depsMap.set(key, dep = createDep()); } - if (!dep.has(activeEffect)) { + var eventInfo = { + effect: activeEffect, + target: target, + type: type, + key: key + }; + trackEffects(dep, eventInfo); + } + + function isTracking() { + return shouldTrack && activeEffect !== undefined; + } + + function trackEffects(dep, debuggerEventExtraInfo) { + var shouldTrack = false; + + if (effectTrackDepth <= maxMarkerBits) { + if (!newTracked(dep)) { + dep.n |= trackOpBit; // set newly tracked + + shouldTrack = !wasTracked(dep); + } + } else { + // Full cleanup mode. + shouldTrack = !dep.has(activeEffect); + } + + if (shouldTrack) { dep.add(activeEffect); activeEffect.deps.push(dep); - if (activeEffect.options.onTrack) { - activeEffect.options.onTrack({ - effect: activeEffect, - target: target, - type: type, - key: key - }); + if (activeEffect.onTrack) { + activeEffect.onTrack(Object.assign({ + effect: activeEffect + }, debuggerEventExtraInfo)); } } } @@ -266,34 +537,24 @@ return; } - var effects = new Set(); - - var add = function add(effectsToAdd) { - if (effectsToAdd) { - effectsToAdd.forEach(function (effect) { - if (effect !== activeEffect || effect.allowRecurse) { - effects.add(effect); - } - }); - } - }; + var deps = []; if (type === "clear" /* CLEAR */ ) { // collection being cleared // trigger all effects for target - depsMap.forEach(add); - } else if (key === "length" && isArray(target)) { + deps = _toConsumableArray(depsMap.values()); + } else if (key === 'length' && isArray(target)) { depsMap.forEach(function (dep, key) { - if (key === "length" || key >= newValue) { - add(dep); + if (key === 'length' || key >= newValue) { + deps.push(dep); } }); } else { // schedule runs for SET | ADD | DELETE if (key !== void 0) { - add(depsMap.get(key)); + deps.push(depsMap.get(key)); } // also run for iteration key on ADD | DELETE | Map.SET @@ -302,14 +563,14 @@ /* ADD */ : if (!isArray(target)) { - add(depsMap.get(ITERATE_KEY)); + deps.push(depsMap.get(ITERATE_KEY)); if (isMap$1(target)) { - add(depsMap.get(MAP_KEY_ITERATE_KEY)); + deps.push(depsMap.get(MAP_KEY_ITERATE_KEY)); } } else if (isIntegerKey(key)) { // new index added to array -> length changes - add(depsMap.get("length")); + deps.push(depsMap.get('length')); } break; @@ -318,10 +579,10 @@ /* DELETE */ : if (!isArray(target)) { - add(depsMap.get(ITERATE_KEY)); + deps.push(depsMap.get(ITERATE_KEY)); if (isMap$1(target)) { - add(depsMap.get(MAP_KEY_ITERATE_KEY)); + deps.push(depsMap.get(MAP_KEY_ITERATE_KEY)); } } @@ -331,86 +592,134 @@ /* SET */ : if (isMap$1(target)) { - add(depsMap.get(ITERATE_KEY)); + deps.push(depsMap.get(ITERATE_KEY)); } break; } } - var run = function run(effect) { - if (effect.options.onTrigger) { - effect.options.onTrigger({ - effect: effect, - target: target, - key: key, - type: type, - newValue: newValue, - oldValue: oldValue, - oldTarget: oldTarget - }); + var eventInfo = { + target: target, + type: type, + key: key, + newValue: newValue, + oldValue: oldValue, + oldTarget: oldTarget + }; + + if (deps.length === 1) { + if (deps[0]) { + { + triggerEffects(deps[0], eventInfo); + } } + } else { + var effects = []; - if (effect.options.scheduler) { - effect.options.scheduler(effect); - } else { - effect(); + var _iterator = _createForOfIteratorHelper(deps), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var dep = _step.value; + + if (dep) { + effects.push.apply(effects, _toConsumableArray(dep)); + } + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); } - }; - effects.forEach(run); + { + triggerEffects(createDep(effects), eventInfo); + } + } + } + + function triggerEffects(dep, debuggerEventExtraInfo) { + // spread into array for stabilization + var _iterator2 = _createForOfIteratorHelper(isArray(dep) ? dep : _toConsumableArray(dep)), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var _effect2 = _step2.value; + + if (_effect2 !== activeEffect || _effect2.allowRecurse) { + if (_effect2.onTrigger) { + _effect2.onTrigger(extend({ + effect: _effect2 + }, debuggerEventExtraInfo)); + } + + if (_effect2.scheduler) { + _effect2.scheduler(); + } else { + _effect2.run(); + } + } + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } } + var isNonTrackableKeys = /*#__PURE__*/makeMap("__proto__,__v_isRef,__isVue"); var builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol).map(function (key) { return Symbol[key]; }).filter(isSymbol)); - var get = /* #__PURE__*/createGetter(); - var shallowGet = /* #__PURE__*/createGetter(false, true); - var readonlyGet = /* #__PURE__*/createGetter(true); - var shallowReadonlyGet = /* #__PURE__*/createGetter(true, true); - var arrayInstrumentations = {}; - ["includes", "indexOf", "lastIndexOf"].forEach(function (key) { - var method = Array.prototype[key]; - - arrayInstrumentations[key] = function () { - var arr = toRaw(this); - - for (var i = 0, l = this.length; i < l; i++) { - track(arr, "get" - /* GET */ - , "".concat(i)); - } // we run the method using the original args first (which may be reactive) + var get = /*#__PURE__*/createGetter(); + var readonlyGet = /*#__PURE__*/createGetter(true); + var arrayInstrumentations = /*#__PURE__*/createArrayInstrumentations(); + function createArrayInstrumentations() { + var instrumentations = {}; + ['includes', 'indexOf', 'lastIndexOf'].forEach(function (key) { + instrumentations[key] = function () { + var arr = toRaw(this); - for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) { - args[_key2] = arguments[_key2]; - } + for (var i = 0, l = this.length; i < l; i++) { + track(arr, "get" + /* GET */ + , i + ''); + } // we run the method using the original args first (which may be reactive) - var res = method.apply(arr, args); - if (res === -1 || res === false) { - // if that didn't work, run it again using raw values. - return method.apply(arr, args.map(toRaw)); - } else { - return res; - } - }; - }); - ["push", "pop", "shift", "unshift", "splice"].forEach(function (key) { - var method = Array.prototype[key]; + for (var _len2 = arguments.length, args = new Array(_len2), _key3 = 0; _key3 < _len2; _key3++) { + args[_key3] = arguments[_key3]; + } - arrayInstrumentations[key] = function () { - pauseTracking(); + var res = arr[key].apply(arr, args); - for (var _len2 = arguments.length, args = new Array(_len2), _key3 = 0; _key3 < _len2; _key3++) { - args[_key3] = arguments[_key3]; - } + if (res === -1 || res === false) { + // if that didn't work, run it again using raw values. + return arr[key].apply(arr, _toConsumableArray(args.map(toRaw))); + } else { + return res; + } + }; + }); + ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(function (key) { + instrumentations[key] = function () { + pauseTracking(); - var res = method.apply(this, args); - resetTracking(); - return res; - }; - }); + for (var _len3 = arguments.length, args = new Array(_len3), _key4 = 0; _key4 < _len3; _key4++) { + args[_key4] = arguments[_key4]; + } + + var res = toRaw(this)[key].apply(this, args); + resetTracking(); + return res; + }; + }); + return instrumentations; + } function createGetter() { var isReadonly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; @@ -426,19 +735,19 @@ return isReadonly; } else if (key === "__v_raw" /* RAW */ - && receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) { + && receiver === (isReadonly ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) { return target; } var targetIsArray = isArray(target); - if (targetIsArray && hasOwn(arrayInstrumentations, key)) { + if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) { return Reflect.get(arrayInstrumentations, key, receiver); } var res = Reflect.get(target, key, receiver); - if (isSymbol(key) ? builtInSymbols.has(key) : key === "__proto__" || key === "__v_isRef") { + if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) { return res; } @@ -469,16 +778,16 @@ }; } - var set$1 = /* #__PURE__*/createSetter(); - var shallowSet = /* #__PURE__*/createSetter(true); + var set$1 = /*#__PURE__*/createSetter(); function createSetter() { var shallow = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; return function set(target, key, value, receiver) { var oldValue = target[key]; - if (!shallow) { + if (!shallow && !isReadonly(value)) { value = toRaw(value); + oldValue = toRaw(oldValue); if (!isArray(target) && isRef(oldValue) && !isRef(value)) { oldValue.value = value; @@ -494,7 +803,7 @@ trigger(target, "add" /* ADD */ , key, value); - } else if (hasChanged$1(value, oldValue) || key === "length") { + } else if (hasChanged$1(value, oldValue)) { trigger(target, "set" /* SET */ , key, value, oldValue); @@ -534,7 +843,7 @@ function ownKeys(target) { track(target, "iterate" /* ITERATE */ - , isArray(target) ? "length" : ITERATE_KEY); + , isArray(target) ? 'length' : ITERATE_KEY); return Reflect.ownKeys(target); } @@ -560,24 +869,6 @@ return true; } }; - extend({}, mutableHandlers, { - get: shallowGet, - set: shallowSet - }); // Props handlers are special in the sense that it should not unwrap top-level - // refs (in order to allow refs to be explicitly passed down), but should - // retain the reactivity of the normal readonly object. - - extend({}, readonlyHandlers, { - get: shallowReadonlyGet - }); - - var toReactive = function toReactive(value) { - return isObject(value) ? reactive(value) : value; - }; - - var toReadonly = function toReadonly(value) { - return isObject(value) ? readonly(value) : value; - }; var toShallow = function toShallow(value) { return value; @@ -611,12 +902,16 @@ var _getProto = getProto(rawTarget), has = _getProto.has; - var wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; + var wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; if (has.call(rawTarget, key)) { return wrap(target.get(key)); } else if (has.call(rawTarget, rawKey)) { return wrap(target.get(rawKey)); + } else if (target !== rawTarget) { + // #3602 readonly(reactive(Map)) + // ensure that the nested reactive `Map` can do tracking for itself + target.get(key); } } @@ -648,7 +943,7 @@ !isReadonly && track(toRaw(target), "iterate" /* ITERATE */ , ITERATE_KEY); - return Reflect.get(target, "size", target); + return Reflect.get(target, 'size', target); } function add(value) { @@ -656,15 +951,15 @@ var target = toRaw(this); var proto = getProto(target); var hadKey = proto.has.call(target, value); - var result = target.add(value); if (!hadKey) { + target.add(value); trigger(target, "add" /* ADD */ , value, value); } - return result; + return this; } function set$1$1(key, value) { @@ -685,19 +980,19 @@ } var oldValue = get.call(target, key); - var result = target.set(key, value); + target.set(key, value); if (!hadKey) { trigger(target, "add" /* ADD */ , key, value); - } else if (hasChanged$1(value, oldValue) || key === "length") { + } else if (hasChanged$1(value, oldValue)) { trigger(target, "set" /* SET */ , key, value, oldValue); } - return result; + return this; } function deleteEntry(key) { @@ -752,16 +1047,15 @@ /* RAW */ ]; var rawTarget = toRaw(target); - var wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; + var wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; !isReadonly && track(rawTarget, "iterate" /* ITERATE */ , ITERATE_KEY); return target.forEach(function (value, key) { - return (// important: make sure the callback is - // 1. invoked with the reactive map as `this` and 3rd arg - // 2. the value received should be a corresponding reactive/readonly. - callback.call(thisArg, wrap(value), wrap(key), observed) - ); + // important: make sure the callback is + // 1. invoked with the reactive map as `this` and 3rd arg + // 2. the value received should be a corresponding reactive/readonly. + return callback.call(thisArg, wrap(value), wrap(key), observed); }); }; } @@ -773,10 +1067,10 @@ ]; var rawTarget = toRaw(target); var targetIsMap = isMap$1(rawTarget); - var isPair = method === "entries" || method === Symbol.iterator && targetIsMap; - var isKeyOnly = method === "keys" && targetIsMap; + var isPair = method === 'entries' || method === Symbol.iterator && targetIsMap; + var isKeyOnly = method === 'keys' && targetIsMap; var innerIterator = target[method].apply(target, arguments); - var wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; + var wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; !isReadonly && track(rawTarget, "iterate" /* ITERATE */ , isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); // return a wrapped iterator which returns observed versions of the @@ -815,73 +1109,110 @@ }; } - var mutableInstrumentations = { - get: function get(key) { - return get$1(this, key); - }, + function createInstrumentations() { + var mutableInstrumentations = { + get: function get(key) { + return get$1(this, key); + }, - get size() { - return size(this); - }, + get size() { + return size(this); + }, - has: has$1$1, - add: add, - set: set$1$1, - delete: deleteEntry, - clear: clear, - forEach: createForEach(false, false) - }; - var shallowInstrumentations = { - get: function get(key) { - return get$1(this, key, false, true); - }, + has: has$1$1, + add: add, + set: set$1$1, + delete: deleteEntry, + clear: clear, + forEach: createForEach(false, false) + }; + var shallowInstrumentations = { + get: function get(key) { + return get$1(this, key, false, true); + }, - get size() { - return size(this); - }, + get size() { + return size(this); + }, - has: has$1$1, - add: add, - set: set$1$1, - delete: deleteEntry, - clear: clear, - forEach: createForEach(false, true) - }; - var readonlyInstrumentations = { - get: function get(key) { - return get$1(this, key, true); - }, + has: has$1$1, + add: add, + set: set$1$1, + delete: deleteEntry, + clear: clear, + forEach: createForEach(false, true) + }; + var readonlyInstrumentations = { + get: function get(key) { + return get$1(this, key, true); + }, - get size() { - return size(this, true); - }, + get size() { + return size(this, true); + }, - has: function has(key) { - return has$1$1.call(this, key, true); - }, - add: createReadonlyMethod("add" - /* ADD */ - ), - set: createReadonlyMethod("set" - /* SET */ - ), - delete: createReadonlyMethod("delete" - /* DELETE */ - ), - clear: createReadonlyMethod("clear" - /* CLEAR */ - ), - forEach: createForEach(true, false) - }; - var iteratorMethods = ["keys", "values", "entries", Symbol.iterator]; - iteratorMethods.forEach(function (method) { - mutableInstrumentations[method] = createIterableMethod(method, false, false); - readonlyInstrumentations[method] = createIterableMethod(method, true, false); - shallowInstrumentations[method] = createIterableMethod(method, false, true); - }); + has: function has(key) { + return has$1$1.call(this, key, true); + }, + add: createReadonlyMethod("add" + /* ADD */ + ), + set: createReadonlyMethod("set" + /* SET */ + ), + delete: createReadonlyMethod("delete" + /* DELETE */ + ), + clear: createReadonlyMethod("clear" + /* CLEAR */ + ), + forEach: createForEach(true, false) + }; + var shallowReadonlyInstrumentations = { + get: function get(key) { + return get$1(this, key, true, true); + }, + + get size() { + return size(this, true); + }, + + has: function has(key) { + return has$1$1.call(this, key, true); + }, + add: createReadonlyMethod("add" + /* ADD */ + ), + set: createReadonlyMethod("set" + /* SET */ + ), + delete: createReadonlyMethod("delete" + /* DELETE */ + ), + clear: createReadonlyMethod("clear" + /* CLEAR */ + ), + forEach: createForEach(true, true) + }; + var iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator]; + iteratorMethods.forEach(function (method) { + mutableInstrumentations[method] = createIterableMethod(method, false, false); + readonlyInstrumentations[method] = createIterableMethod(method, true, false); + shallowInstrumentations[method] = createIterableMethod(method, false, true); + shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true); + }); + return [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations]; + } + + var _createInstrumentatio = /* #__PURE__*/createInstrumentations(), + _createInstrumentatio2 = _slicedToArray(_createInstrumentatio, 4), + mutableInstrumentations = _createInstrumentatio2[0], + readonlyInstrumentations = _createInstrumentatio2[1], + shallowInstrumentations = _createInstrumentatio2[2], + shallowReadonlyInstrumentations = _createInstrumentatio2[3]; function createInstrumentationGetter(isReadonly, shallow) { - var instrumentations = shallow ? shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations; + var instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations; return function (target, key, receiver) { if (key === "__v_isReactive" /* IS_REACTIVE */ @@ -902,10 +1233,10 @@ } var mutableCollectionHandlers = { - get: createInstrumentationGetter(false, false) + get: /*#__PURE__*/createInstrumentationGetter(false, false) }; var readonlyCollectionHandlers = { - get: createInstrumentationGetter(true, false) + get: /*#__PURE__*/createInstrumentationGetter(true, false) }; function checkIdentityKeys(target, has, key) { @@ -918,22 +1249,30 @@ } var reactiveMap = new WeakMap(); + var shallowReactiveMap = new WeakMap(); var readonlyMap = new WeakMap(); + var shallowReadonlyMap = new WeakMap(); function targetTypeMap(rawType) { switch (rawType) { - case "Object": - case "Array": - return 1; - - case "Map": - case "Set": - case "WeakMap": - case "WeakSet": - return 2; + case 'Object': + case 'Array': + return 1 + /* COMMON */ + ; + + case 'Map': + case 'Set': + case 'WeakMap': + case 'WeakSet': + return 2 + /* COLLECTION */ + ; default: - return 0; + return 0 + /* INVALID */ + ; } } @@ -953,14 +1292,19 @@ return target; } - return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers); - } // Return a reactive-copy of the original object, where only the root level + return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap); + } + /** + * Creates a readonly copy of the original object. Note the returned copy is not + * made reactive, but `readonly` can be called on an already reactive object. + */ + function readonly(target) { - return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers); - } // Return a reactive-copy of the original object, where only the root level + return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap); + } - function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) { + function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) { if (!isObject(target)) { { console.warn("value cannot be made reactive: ".concat(String(target))); @@ -979,7 +1323,6 @@ } // target already has corresponding Proxy - var proxyMap = isReadonly ? readonlyMap : reactiveMap; var existingProxy = proxyMap.get(target); if (existingProxy) { @@ -1021,9 +1364,55 @@ } function toRaw(observed) { - return observed && toRaw(observed["__v_raw" + var raw = observed && observed["__v_raw" /* RAW */ - ]) || observed; + ]; + return raw ? toRaw(raw) : observed; + } + + var toReactive = function toReactive(value) { + return isObject(value) ? reactive(value) : value; + }; + + var toReadonly = function toReadonly(value) { + return isObject(value) ? readonly(value) : value; + }; + + function trackRefValue(ref) { + if (isTracking()) { + ref = toRaw(ref); + + if (!ref.dep) { + ref.dep = createDep(); + } + + { + trackEffects(ref.dep, { + target: ref, + type: "get" + /* GET */ + , + key: 'value' + }); + } + } + } + + function triggerRefValue(ref, newVal) { + ref = toRaw(ref); + + if (ref.dep) { + { + triggerEffects(ref.dep, { + target: ref, + type: "set" + /* SET */ + , + key: 'value', + newValue: newVal + }); + } + } } function isRef(r) { @@ -1037,17 +1426,13 @@ _classCallCheck(this, ComputedRefImpl); this._setter = _setter; + this.dep = undefined; this._dirty = true; this.__v_isRef = true; - this.effect = effect(getter, { - lazy: true, - scheduler: function scheduler() { - if (!_this2._dirty) { - _this2._dirty = true; - trigger(toRaw(_this2), "set" - /* SET */ - , "value"); - } + this.effect = new ReactiveEffect(getter, function () { + if (!_this2._dirty) { + _this2._dirty = true; + triggerRefValue(_this2); } }); this["__v_isReadonly" @@ -1058,15 +1443,16 @@ _createClass(ComputedRefImpl, [{ key: "value", get: function get() { - if (this._dirty) { - this._value = this.effect(); - this._dirty = false; + // the computed ref may get wrapped by other proxies e.g. readonly() #3376 + var self = toRaw(this); + trackRefValue(self); + + if (self._dirty) { + self._dirty = false; + self._value = self.effect.run(); } - track(toRaw(this), "get" - /* GET */ - , "value"); - return this._value; + return self._value; }, set: function set(newValue) { this._setter(newValue); @@ -1076,24 +1462,34 @@ return ComputedRefImpl; }(); - function computed(getterOrOptions) { + function computed(getterOrOptions, debugOptions) { var getter; var setter; + var onlyGetter = isFunction(getterOrOptions); - if (isFunction(getterOrOptions)) { + if (onlyGetter) { getter = getterOrOptions; setter = function setter() { - console.warn("Write operation failed: computed value is readonly"); + console.warn('Write operation failed: computed value is readonly'); }; } else { getter = getterOrOptions.get; setter = getterOrOptions.set; } - return new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set); + var cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter); + + if (debugOptions) { + cRef.effect.onTrack = debugOptions.onTrack; + cRef.effect.onTrigger = debugOptions.onTrigger; + } + + return cRef; } + Promise.resolve(); + function noop() {} function isNative(Ctor) { return typeof Ctor === "function" && /native code/.test(Ctor.toString()); @@ -1133,13 +1529,12 @@ function isPlainObject(obj) { return _toString.call(obj) === "[object Object]"; } - var bailRE = /[^\w.$]/; - function parsePath(path) { - if (bailRE.test(path)) { - return; - } - var segments = path.split("."); + function parsePath(path) { + // if (bailRE.test(path)) { + // return; + // } + var segments = path.length > 0 ? path.split(".") : []; return function (obj) { for (var i = 0; i < segments.length; i++) { if (!obj) return; @@ -1439,10 +1834,10 @@ var oldValue = _.isArray(source) ? [] : INITIAL_WATCHER_VALUE; var job = function job() { - if (!runner.active) { - return; - } - + // 这里去掉的原因是,新增属性没有生效也会触发变化监听 + // if (!runner.active) { + // return; + // } if (cb) { // watch(source, cb) var newValue = runner(); @@ -1554,8 +1949,7 @@ return new Function("return " + expr)(); } - function watchExp(model, exp) { - var getter = parsePath(exp); + function watchExp(model, getter) { var result = getter.call(model, model); if (_.isArray(result)) { @@ -1579,15 +1973,29 @@ options.user = true; var exps; - if (_.isFunction(expOrFn) || !(exps = expOrFn.match(/[a-zA-Z0-9_.*]+|[|][|]|[&][&]|[(]|[)]/g)) || exps.length === 1 && !/\*/.test(expOrFn)) { - var watcher = innerWatch(_.isFunction(expOrFn) ? expOrFn : function () { - return watchExp(model, expOrFn); - }, cb, options); + if (_.isFunction(expOrFn)) { + var watcher = innerWatch(expOrFn, cb, options); return function unwatchFn() { watcher(); }; } + if (!(exps = expOrFn.match(/[a-zA-Z0-9_.*]+|[|][|]|[&][&]|[(]|[)]/g)) || exps.length === 1 && !/\*/.test(expOrFn)) { + var paths = expOrFn.split("."); + var prePaths = paths.slice(0, paths.length - 1); + var preGetter = parsePath(prePaths.join(".")); + var v = preGetter.call(model, model); + var getter = parsePath(paths[paths.length - 1]); + + var _watcher = innerWatch(function () { + return watchExp(v, getter); + }, cb, options); + + return function unwatchFn() { + _watcher(); + }; + } + var watchers = []; var fns = exps.slice(); var complete = false, @@ -1624,35 +2032,12 @@ _.each(exps, function (exp, i) { if (_.has(operators, exp)) { return; - } //a.**形式 - - - if (/^[1-9a-zA-Z.]+\*\*$/.test(exp) || exp === "**") { - exp = exp.replace(".**", ""); - var getter = exp === "**" ? function (m) { - return m; - } : parsePath(exp); - watchers.push(innerWatch(function () { - return getter.call(model, model); - }, function (newValue, oldValue) { - callback(i, newValue, oldValue, _.extend({ - index: i - })); - }, _.extend({ - deep: true - }, options))); - return; } - if (/^(\*\*\.)+[1-9a-zA-Z]+(\.\*\*$)/.test(exp)) { - throw new Error("not support"); - } //含有*的情况,如a.*,如*.a,*.*.a,a.*.a - - - if (/\*/.test(exp)) { + if (exp.indexOf("*") >= 0) { // eslint-disable-next-line no-inner-declarations var travers = function travers(root, deps, parent, key, res) { - if (deps.length === paths.length) { + if (deps.length === _paths.length) { root !== undefined && res.push({ parent: parent, k: key @@ -1661,45 +2046,84 @@ } if (root) { - if (paths[deps.length] === "*") { + if (_paths[deps.length] === "*") { // 遍历所有节点 for (var k in root) { travers(root[k], deps.concat([k]), root, k, res); } } else { - var nextKey = paths[deps.length]; + var nextKey = _paths[deps.length]; travers(root[nextKey], deps.concat([nextKey]), root, nextKey, res); } } }; + //a.**形式 + if (/^[1-9a-zA-Z.]+\*\*$/.test(exp) || exp === "**") { + exp = exp.replace(".**", ""); + + var _paths2 = exp.split("."); + + var _prePaths2 = _paths2.slice(0, _paths2.length - 1); + + var _preGetter = parsePath(_prePaths2.join(".")); + + var _v2 = _preGetter.call(model, model); + + var _getter = exp === "**" ? function (m) { + return m; + } : parsePath(_paths2[_paths2.length - 1]); + + watchers.push(innerWatch(function () { + return watchExp(_v2, _getter); + }, function (newValue, oldValue) { + // a.** 在a变化的时候不会触发change + if (!_.isArray(newValue) && oldValue !== newValue) { + return; + } + + callback(i, NaN, NaN, _.extend({ + index: i + })); + }, _.extend({ + deep: true + }, options))); + return; + } + + if (/^(\*\*\.)+[1-9a-zA-Z]+(\.\*\*$)/.test(exp)) { + throw new Error("not support"); + } //含有*的情况,如a.*,如*.a,*.*.a,a.*.a //先获取到能获取到的对象 - var paths = exp.split("."); - var prePaths = []; - for (var _i = 0, len = paths.length; _i < len; _i++) { - if (paths[_i] === "*") { + + var _paths = exp.split("."); + + var _prePaths = []; + + for (var _i = 0, len = _paths.length; _i < len; _i++) { + if (_paths[_i] === "*") { break; } - prePaths[_i] = paths[_i]; + _prePaths[_i] = _paths[_i]; } - var v; + var _v; - if (prePaths.length > 0) { - var _getter = parsePath(prePaths.join(".")); + if (_prePaths.length > 0) { + var _getter2 = parsePath(_prePaths.join(".")); - v = _getter.call(model, model); + _v = _getter2.call(model, model); } else { - v = model; + _v = model; } - paths = paths.slice(prePaths.length); + _paths = _paths.slice(_prePaths.length); var changes = []; watchers.push(innerWatch(function () { var routes = []; - travers(v, [], v, null, routes); + travers(_v, [], _v, null, routes); for (var _i2 = 0, _len = routes.length; _i2 < _len; _i2++) { var _routes$_i = routes[_i2], @@ -1720,11 +2144,11 @@ changes = []; if (newValue === true) { - callback(i, undefined, undefined, _.extend({ + callback(i, NaN, NaN, _.extend({ index: i })); } - }, BI.extend({}, options, { + }, _.extend({}, options, { deep: true, onTrigger: function onTrigger(_ref) { var target = _ref.target, @@ -1738,8 +2162,9 @@ return; } + var getter = parsePath(exp); watchers.push(innerWatch(function () { - return watchExp(model, exp); + return watchExp(model, getter); }, function (newValue, oldValue) { callback(i, newValue, oldValue, _.extend({ index: i From 02ab7cf85f48721492f9e423b3feb6c13190250b Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 13 Dec 2021 19:15:34 +0800 Subject: [PATCH 4/4] =?UTF-8?q?BI-98494=20=E7=B2=98=E8=B4=B4=E6=9C=AB?= =?UTF-8?q?=E5=B0=BE=E5=80=BC=E5=B8=A6=E5=88=86=E9=9A=94=E7=AC=A6=E5=A4=9A?= =?UTF-8?q?=E8=AE=A1=E6=95=B0=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/multiselect/multiselect.insert.combo.js | 2 +- src/widget/multiselect/multiselect.insert.combo.nobar.js | 2 +- src/widget/multiselectlist/multiselectlist.insert.js | 2 +- src/widget/multiselectlist/multiselectlist.insert.nobar.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/widget/multiselect/multiselect.insert.combo.js b/src/widget/multiselect/multiselect.insert.combo.js index c77953401..f0435f6f7 100644 --- a/src/widget/multiselect/multiselect.insert.combo.js +++ b/src/widget/multiselect/multiselect.insert.combo.js @@ -81,7 +81,7 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, { var last = BI.last(keywords); keywords = BI.initial(keywords || []); if (keywords.length > 0) { - self._joinKeywords(keywords.slice(0, 2000), function () { + self._joinKeywords(keywords.slice(0, last === BI.BlankSplitChar ? 1999 : 2000), function () { if (BI.endWith(last, BI.BlankSplitChar)) { self.combo.setValue(self.storeValue); assertShowValue(); diff --git a/src/widget/multiselect/multiselect.insert.combo.nobar.js b/src/widget/multiselect/multiselect.insert.combo.nobar.js index 28065441e..18bfc8a82 100644 --- a/src/widget/multiselect/multiselect.insert.combo.nobar.js +++ b/src/widget/multiselect/multiselect.insert.combo.nobar.js @@ -76,7 +76,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, { var last = BI.last(keywords); keywords = BI.initial(keywords || []); if (keywords.length > 0) { - self._joinKeywords(keywords.slice(0, 2000), function () { + self._joinKeywords(keywords.slice(0, last === BI.BlankSplitChar ? 1999 : 2000), function () { if (BI.endWith(last, BI.BlankSplitChar)) { self.combo.setValue(self.storeValue); assertShowValue(); diff --git a/src/widget/multiselectlist/multiselectlist.insert.js b/src/widget/multiselectlist/multiselectlist.insert.js index b27d1271b..e4a6a004b 100644 --- a/src/widget/multiselectlist/multiselectlist.insert.js +++ b/src/widget/multiselectlist/multiselectlist.insert.js @@ -126,7 +126,7 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, { var last = BI.last(keywords); keywords = BI.initial(keywords || []); if (keywords.length > 0) { - self._joinKeywords(keywords.slice(0, 2000), function () { + self._joinKeywords(keywords.slice(0, last === BI.BlankSplitChar ? 1999 : 2000), function () { if (BI.endWith(last, BI.BlankSplitChar)) { self.adapter.setValue(self.storeValue); assertShowValue(); diff --git a/src/widget/multiselectlist/multiselectlist.insert.nobar.js b/src/widget/multiselectlist/multiselectlist.insert.nobar.js index 6e5f1d65b..f4f1adff4 100644 --- a/src/widget/multiselectlist/multiselectlist.insert.nobar.js +++ b/src/widget/multiselectlist/multiselectlist.insert.nobar.js @@ -129,7 +129,7 @@ BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, { var last = BI.last(keywords); keywords = BI.initial(keywords || []); if (keywords.length > 0) { - self._joinKeywords(keywords.slice(0, 2000), function () { + self._joinKeywords(keywords.slice(0, last === BI.BlankSplitChar ? 1999 : 2000), function () { if (BI.endWith(last, BI.BlankSplitChar)) { self.adapter.setValue(self.storeValue); assertShowValue();