From ac2f30e84ae35aa1d113476c5aba094726624557 Mon Sep 17 00:00:00 2001 From: lon Date: Fri, 19 May 2017 00:21:56 +0800 Subject: [PATCH] Bump to v1.0.2 --- dist/smart-observe.js | 24 +++++++++++------------- dist/smart-observe.js.map | 2 +- dist/smart-observe.min.js | 2 +- dist/smart-observe.min.js.map | 2 +- package.json | 2 +- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/dist/smart-observe.js b/dist/smart-observe.js index 89f9783..dd08620 100644 --- a/dist/smart-observe.js +++ b/dist/smart-observe.js @@ -232,7 +232,7 @@ function noop() {} * @param {String} string */ -var warn = (typeof DEBUGGING === 'undefined' ? 'undefined' : _typeof(DEBUGGING)) !== undefined && DEBUGGING && typeof console !== 'undefined' && console && isFunction(console.warn) ? console.warn : noop; +var warn = typeof DEBUGGING !== 'undefined' && DEBUGGING && typeof console !== 'undefined' && console && isFunction(console.warn) ? console.warn : noop; var _Set = void 0; if (typeof Set !== 'undefined' && Set.toString().match(/native code/)) { @@ -920,9 +920,7 @@ Object.defineProperties(observe$$1, { */ function observe$$1(target, expression, func, options) { - if (!target.hasOwnProperty(WATCHERS_PROPERTY_NAME)) { - init(target); - } + ensure(target); return observe$$1.default(target, expression, func, options); } @@ -936,9 +934,7 @@ function observe$$1(target, expression, func, options) { function react(options, target) { if (target) { - if (!target.hasOwnProperty(WATCHERS_PROPERTY_NAME)) { - init(target); - } + ensure(target); } else { target = {}; init(target); @@ -965,9 +961,7 @@ function react(options, target) { */ function compute(target, name, getterOrAccessor, cache) { - if (!target.hasOwnProperty(WATCHERS_PROPERTY_NAME)) { - init(target); - } + ensure(target); var getter = void 0, setter = void 0; if (isFunction(getterOrAccessor)) { @@ -996,9 +990,7 @@ function compute(target, name, getterOrAccessor, cache) { function watch$$1(target, expressionOrFunction, callback) { var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : observe$$1; - if (!target.hasOwnProperty(WATCHERS_PROPERTY_NAME)) { - init(target); - } + ensure(target); return watch$1(target, expressionOrFunction, callback, options); } @@ -1013,6 +1005,12 @@ function init(target) { reactSelfProperties(target); } +function ensure(target) { + if (!Object.prototype.hasOwnProperty.call(target, WATCHERS_PROPERTY_NAME)) { + init(target); + } +} + /** * @param {Object} target * @param {Object} methods diff --git a/dist/smart-observe.js.map b/dist/smart-observe.js.map index 85266bd..c3db31d 100644 --- a/dist/smart-observe.js.map +++ b/dist/smart-observe.js.map @@ -1 +1 @@ -{"version":3,"file":"smart-observe.js","sources":["../src/dep.js","../src/constants.js","../src/util.js","../src/array.js","../src/observe.js","../src/expression.js","../node_modules/smart-next-tick/nextTick.js","../src/batcher.js","../src/watcher.js","../src/index.js"],"sourcesContent":["let uid = 0\n\n/**\n * A dep is an observable that can have multiple\n * watcher subscribing to it.\n */\n\nexport default class Dep {\n // the current target watcher being evaluated.\n // this is globally unique because there could be only one\n // watcher being evaluated at any time.\n static target = null\n\n constructor () {\n this.id = uid++\n this.subs = []\n }\n\n /**\n * Add a subscriber.\n *\n * @param {Watcher} sub\n */\n\n addSub (sub) {\n this.subs.push(sub)\n }\n\n /**\n * Remove a subscriber.\n *\n * @param {Watcher} sub\n */\n\n removeSub (sub) {\n this.subs.$remove(sub)\n }\n\n /**\n * Add self as a dependency to the target watcher.\n */\n\n depend () {\n Dep.target.addDep(this)\n }\n\n /**\n * Notify all subscribers of a new value.\n */\n\n notify () {\n const subs = this.subs\n for (let i = 0, l = subs.length; i < l; i++) {\n subs[i].update()\n }\n }\n}\n","export const OBSERVE_NAME = '__s_o__'\nexport const WATCHERS_PROPERTY_NAME = '__watchers__'\nexport const DATA_PROPTERTY_NAME = '__data__'\n\nexport const DEBUGGING = typeof process !== 'undefined'\n && process.env.NODE_ENV !== 'production'\n","import {DEBUGGING} from './constants'\n\n/**\n * Define property with value.\n *\n * @param {Object} object\n * @param {String} property\n * @param {*} value\n * @param {Boolean} [enumerable]\n */\n\nexport function defineValue (object, property, value, enumerable) {\n Object.defineProperty(object, property, {\n value,\n enumerable: !!enumerable,\n writable: true,\n configurable: true,\n })\n}\n\n/**\n * Define property with getter and setter.\n *\n * @param {Object} object\n * @param {String} property\n * @param {Function} getter\n * @param {Function} setter\n */\n\nexport function defineAccessor (object, property, getter, setter) {\n Object.defineProperty(object, property, {\n get: getter,\n set: setter,\n enumerable: true,\n configurable: true,\n })\n}\n\n/**\n * Array type check.\n *\n * @return {Boolean}\n */\n\nexport const isArray = Array.isArray\n\n/**\n * Strict object type check. Only returns true\n * for plain JavaScript objects.\n *\n * @param {*} object\n * @return {Boolean}\n */\n\nconst toString = Object.prototype.toString\nconst OBJECT_STRING = '[object Object]'\nexport function isPlainObject (object) {\n return toString.call(object) === OBJECT_STRING\n}\n\n/**\n * Quick object check - this is primarily used to tell\n * Objects from primitive values when we know the value\n * is a JSON-compliant type.\n *\n * @param {*} object\n * @return {Boolean}\n */\n\nexport function isObject (object) {\n return object !== null && typeof object === 'object'\n}\n\n/**\n * Function type check\n *\n * @param {*} func\n * @param {Boolean}\n */\n\nexport function isFunction (func) {\n return typeof func === 'function'\n}\n\n/**\n * Iterate object\n *\n * @param {Object} object\n * @param {Function} callback\n */\n\nexport function everyEntries (object, callback) {\n const keys = Object.keys(object)\n for (let i = 0, l = keys.length; i < l; i++) {\n callback(keys[i], object[keys[i]])\n }\n}\n\n/**\n * noop is function which is nothing to do.\n */\n\nexport function noop () {}\n\n/**\n * @param {String} string\n */\n\nexport const warn = typeof DEBUGGING !== undefined && DEBUGGING\n && typeof console !== 'undefined' && console\n && isFunction(console.warn)\n ? console.warn\n : noop\n\nexport let _Set\nif (typeof Set !== 'undefined' && Set.toString().match(/native code/)) {\n // use native Set when available.\n _Set = Set\n} else {\n // a non-standard Set polyfill that only works with primitive keys.\n _Set = function () {\n this.set = Object.create(null)\n }\n _Set.prototype.has = function (key) {\n return this.set[key] !== undefined\n }\n _Set.prototype.add = function (key) {\n this.set[key] = 1\n }\n _Set.prototype.clear = function () {\n this.set = Object.create(null)\n }\n}\n","import {defineValue} from './util'\nimport {OBSERVE_NAME} from './constants'\n\nconst arrayPrototype = Array.prototype\nconst arrayMethods = Object.create(arrayPrototype)\nconst arrayMutativeMethods = [\n 'push',\n 'pop',\n 'shift',\n 'unshift',\n 'splice',\n 'sort',\n 'reverse',\n]\n\n/**\n * Augment an target Array with arrayMethods\n *\n * @param {Array} array\n */\n\nexport default function amend (array) {\n Object.setPrototypeOf(array, arrayMethods)\n}\n\n/**\n * Intercept mutating methods and emit events\n */\n\nfor (\n let i = 0, l = arrayMutativeMethods.length, method;\n i < l;\n method = arrayMutativeMethods[++i]\n) {\n // cache original method\n const original = arrayPrototype[method]\n defineValue(arrayMethods, method, function mutator (...args) {\n const result = original.apply(this, args)\n const observer = this[OBSERVE_NAME]\n let inserted\n switch (method) {\n case 'push':\n inserted = args\n break\n case 'unshift':\n inserted = args\n break\n case 'splice':\n inserted = args.slice(2)\n break\n }\n if (inserted) observer.observeArray(inserted)\n observer.dep.notify() // notify change\n return result\n })\n}\n\n/**\n * Swap the element at the given index with a new value\n * and emits corresponding event.\n *\n * @param {Number} index\n * @param {*} value\n * @return {*} - replaced element\n */\n\nfunction $set (index, value) {\n if (index >= this.length) {\n this.length = Number(index) + 1\n }\n return this.splice(index, 1, value)[0]\n}\ndefineValue(arrayPrototype, '$set', $set)\n\n/**\n * Convenience method to remove the element at given index\n * or target element reference.\n *\n * @param {*} item\n * @return {*} - removed element\n */\n\nfunction $remove (item) {\n if (!this.length) return\n const index = this.indexOf(item)\n if (index > -1) {\n return this.splice(index, 1)\n }\n}\ndefineValue(arrayPrototype, '$remove', $remove)\n","import Dep from './dep'\nimport amendArray from './array'\nimport {\n defineValue,\n defineAccessor,\n isArray,\n isPlainObject,\n everyEntries,\n} from './util'\nimport {OBSERVE_NAME} from './constants'\n\n/**\n * Observer class that are attached to each observed\n * object. Once attached, the observer converts target\n * object's property keys into getter/setters that\n * collect dependencies and dispatches updates.\n *\n * @class\n * @param {Array|Object} value\n */\n\nclass Observer {\n constructor (value) {\n this.value = value\n this.dep = new Dep()\n defineValue(value, OBSERVE_NAME, this)\n if (isArray(value)) {\n amendArray(value)\n this.observeArray(value)\n } else {\n this.walk(value)\n }\n }\n\n /**\n * Walk through each property and convert them into\n * getter/setters. This method should only be called when\n * value type is Object.\n *\n * @param {Object} object\n */\n\n walk (object) {\n everyEntries(object, (key, value) => this.convert(key, value))\n }\n\n /**\n * Observe a list of Array items.\n *\n * @param {Array} items\n */\n\n observeArray (items) {\n for (let i = 0, l = items.length; i < l; i++) {\n observe(items[i])\n }\n }\n\n /**\n * Convert a property into getter/setter so we can emit\n * the events when the property is accessed/changed.\n *\n * @param {String} key\n * @param {*} value\n */\n\n convert (key, value) {\n defineReactive(this.value, key, value)\n }\n}\n\n/**\n * Attempt to create an observer instance for a value,\n * returns the new observer if successfully observed,\n * or the existing observer if the value already has one.\n *\n * @param {*} value\n * @return {Observer|undefined}\n */\n\nexport function observe (value) {\n if (!value || typeof value !== 'object') return\n let observer\n if (\n Object.prototype.hasOwnProperty.call(value, OBSERVE_NAME)\n && value[OBSERVE_NAME] instanceof Observer\n ) {\n observer = value[OBSERVE_NAME]\n } else if (\n (isArray(value) || isPlainObject(value))\n && Object.isExtensible(value)\n ) {\n observer = new Observer(value)\n }\n return observer\n}\n\n/**\n * Define a reactive property on an Object.\n *\n * @param {Object} object\n * @param {String} key\n * @param {*} value\n */\n\nexport function defineReactive (object, key, value) {\n const dep = new Dep()\n\n const desc = Object.getOwnPropertyDescriptor(object, key)\n if (desc && desc.configurable === false) return\n\n // cater for pre-defined getter/setters\n const getter = desc && desc.get\n const setter = desc && desc.set\n\n let childOb = observe(value)\n\n function reactiveGetter () {\n const currentValue = getter ? getter.call(object) : value\n if (Dep.target) {\n dep.depend()\n if (childOb) {\n childOb.dep.depend()\n }\n if (isArray(currentValue)) {\n for (let i = 0, l = currentValue.length, e; i < l; i++) {\n e = currentValue[i]\n e && e[OBSERVE_NAME] && e[OBSERVE_NAME].dep.depend()\n }\n }\n }\n return currentValue\n }\n function reactiveSetter (newValue) {\n const oldValue = getter ? getter.call(object) : value\n if (newValue === oldValue) return\n if (setter) {\n setter.call(object, newValue)\n } else {\n value = newValue\n }\n childOb = observe(newValue)\n dep.notify()\n }\n defineAccessor(object, key, reactiveGetter, reactiveSetter)\n}\n","import {warn} from './util'\n\n/**\n * Build a getter function. Requires eval.\n *\n * We isolate the try/catch so it doesn't affect the\n * optimization of the parse function when it is not called.\n *\n * @param {String} body\n * @return {Function|undefined}\n */\n\nfunction makeGetterFunction (body) {\n try {\n /* eslint-disable no-new-func */\n return new Function('scope', `return ${body};`)\n /* eslint-enable no-new-func */\n } catch (e) {\n warn('Invalid expression. Generated function body: ' + body)\n }\n}\n\n/**\n * Parse an expression to getter.\n *\n * @param {String} expression\n * @return {Function|undefined}\n */\n\nexport default function parse (expression) {\n expression = String.prototype.trim.call(expression)\n return makeGetterFunction('scope.' + expression)\n}\n","var callbacks = []\nvar pending = false\nfunction nextTickHandler () {\n pending = false\n var callbackCopies = callbacks.slice(0)\n callbacks.length = 0\n for (var i = 0; i < callbackCopies.length; i++) {\n callbackCopies[i]()\n }\n}\n\nvar callNextTick\nif (typeof process === 'object'\n && process\n && typeof process.nextTick === 'function'\n) {\n callNextTick = process.nextTick\n} else if (typeof MutationObserver !== 'undefined') {\n var counter = 0\n var textNode = document.createTextNode(counter)\n var observer = new MutationObserver(nextTickHandler)\n observer.observe(textNode, {\n characterData: true\n })\n callNextTick = function () {\n counter = counter === 0 ? 1 : 0\n textNode.data = String(counter)\n }\n} else {\n callNextTick = setTimeout\n}\n\n\nmodule.exports = function nextTick (callback, context) {\n var func = callback\n if (context) {\n var args = []\n var l = arguments.length\n while (--l > 1) {\n args.unshift(arguments[l])\n }\n func = function () {\n callback.apply(context, args)\n }\n }\n callbacks.push(func)\n if (pending) {\n return\n }\n pending = true\n callNextTick(nextTickHandler)\n}\n","import nextTick from 'smart-next-tick'\n\nlet queue = []\nlet has = {}\nlet waiting = false\nlet queueIndex\n\n/**\n * Reset the batcher's state.\n */\n\nfunction resetBatcherState () {\n queue = []\n has = {}\n waiting = false\n}\n\n/**\n * Flush queue and run the watchers.\n */\n\nfunction flushBatcherQueue () {\n runBatcherQueue(queue)\n resetBatcherState()\n}\n\n/**\n * Run the watchers in a single queue.\n *\n * @param {Array} queue\n */\n\nfunction runBatcherQueue (queue) {\n // do not cache length because more watchers might be pushed\n // as we run existing watchers\n for (queueIndex = 0; queueIndex < queue.length; queueIndex++) {\n const watcher = queue[queueIndex]\n const id = watcher.id\n has[id] = null\n watcher.run()\n }\n}\n\n/**\n * Push a watcher into the watcher queue.\n * Jobs with duplicate IDs will be skipped unless it's\n * pushed when the queue is being flushed.\n *\n * @param {Watcher} watcher\n * properties:\n * - {Number} id\n * - {Function} run\n */\n\nexport default function batch (watcher) {\n const id = watcher.id\n if (has[id] == null) {\n has[id] = queue.length\n queue.push(watcher)\n // queue the flush\n if (!waiting) {\n waiting = true\n nextTick(flushBatcherQueue)\n }\n }\n}\n","import observe from './index'\nimport Dep from './dep'\nimport parseExpression from './expression'\nimport batch from './batcher'\nimport {\n isArray,\n isObject,\n isFunction,\n _Set as Set,\n} from './util'\nimport {WATCHERS_PROPERTY_NAME} from './constants'\n\nlet uid = 0\n\nclass Watcher {\n\n /**\n * A watcher parses an expression, collects dependencies,\n * and fires callback when the expression value changes.\n *\n * @param {Object} owner\n * @param {String|Function} getter\n * @param {Function} callback\n * @param {Object} options\n * - {Boolean} deep\n * - {Boolean} sync\n * - {Boolean} lazy\n * @constructor\n */\n\n constructor (owner, getter, callback, options) {\n owner[WATCHERS_PROPERTY_NAME].push(this)\n this.owner = owner\n this.getter = getter\n this.callback = callback\n this.options = options\n // uid for batching\n this.id = ++uid\n this.active = true\n // for lazy watchers\n this.dirty = options.lazy\n this.deps = []\n this.newDeps = []\n this.depIds = new Set()\n this.newDepIds = new Set()\n this.value = options.lazy\n ? undefined\n : this.get()\n }\n\n /**\n * Evaluate the getter, and re-collect dependencies.\n */\n\n get () {\n this.beforeGet()\n const scope = this.owner\n const value = this.getter.call(scope, scope)\n if (this.options.deep) {\n traverse(value)\n }\n this.afterGet()\n return value\n }\n\n /**\n * Prepare for dependency collection.\n */\n\n beforeGet () {\n Dep.target = this\n }\n\n /**\n * Add a dependency to this directive.\n *\n * @param {Dep} dep\n */\n\n addDep (dep) {\n const id = dep.id\n if (!this.newDepIds.has(id)) {\n this.newDepIds.add(id)\n this.newDeps.push(dep)\n if (!this.depIds.has(id)) {\n dep.addSub(this)\n }\n }\n }\n\n /**\n * Clean up for dependency collection.\n */\n\n afterGet () {\n Dep.target = null\n let i = this.deps.length\n while (i--) {\n const dep = this.deps[i]\n if (!this.newDepIds.has(dep.id)) {\n dep.removeSub(this)\n }\n }\n let tmp = this.depIds\n this.depIds = this.newDepIds\n this.newDepIds = tmp\n this.newDepIds.clear()\n tmp = this.deps\n this.deps = this.newDeps\n this.newDeps = tmp\n this.newDeps.length = 0\n }\n\n /**\n * Will be called when a dependency changes.\n */\n\n update () {\n if (this.options.lazy) {\n this.dirty = true\n } else if (this.options.sync) {\n this.run()\n } else {\n batch(this)\n }\n }\n\n /**\n * Will be called by the batcher.\n */\n\n run () {\n if (this.active) {\n const value = this.get()\n if (\n value !== this.value\n // Deep watchers and watchers on Object/Arrays should fire even when\n // the value is the same, because the value may have mutated;\n || ((isObject(value) || this.options.deep))\n ) {\n const oldValue = this.value\n this.value = value\n this.callback.call(this.owner, value, oldValue)\n }\n }\n }\n\n /**\n * Evaluate the value of the watcher.\n * This only gets called for lazy watchers.\n */\n\n evaluate () {\n // avoid overwriting another watcher that is being collected.\n const current = Dep.target\n this.value = this.get()\n this.dirty = false\n Dep.target = current\n }\n\n /**\n * Depend on all deps collected by this watcher.\n */\n\n depend () {\n let i = this.deps.length\n while (i--) {\n this.deps[i].depend()\n }\n }\n\n /**\n * Remove self from all dependencies' subcriber list.\n */\n\n teardown () {\n if (this.active) {\n let i = this.deps.length\n while (i--) {\n this.deps[i].removeSub(this)\n }\n this.active = false\n this.owner = this.callback = this.value = null\n }\n }\n}\n\n/**\n * Recrusively traverse an object to evoke all converted\n * getters, so that every nested property inside the object\n * is collected as a \"deep\" dependency.\n *\n * @param {*} value\n */\n\nfunction traverse (value) {\n let i, keys\n if (isArray(value)) {\n i = value.length\n while (i--) traverse(value[i])\n } else if (isObject(value)) {\n keys = Object.keys(value)\n i = keys.length\n while (i--) traverse(value[keys[i]])\n }\n}\n\n/**\n * Create an watcher instance, returns the new watcher.\n *\n * @param {Object} owner\n * @param {String|Function} expressionOrFunction\n * @param {Function} callback\n * @param {Object} options\n * - {Boolean} deep\n * - {Boolean} sync\n * - {Boolean} lazy\n * @return {Watcher}\n */\n\nexport function watch (owner, expressionOrFunction, callback, options) {\n // parse expression for getter\n const getter = isFunction(expressionOrFunction)\n ? expressionOrFunction\n : parseExpression(expressionOrFunction)\n return new Watcher(owner, getter, callback, options)\n}\n\n/**\n * Make a computed getter, which can collect dependencies.\n *\n * @param {Object} owner\n * @param {Function} getter\n */\n\nexport function makeComputed (owner, getter) {\n const watcher = new Watcher(owner, getter, null, {\n deep: observe.deep,\n lazy: true,\n sync: observe.sync,\n })\n return function computedGetter () {\n if (watcher.options.lazy && Dep.target && !Dep.target.options.lazy) {\n watcher.options.lazy = false\n watcher.callback = function () {\n const deps = watcher.deps\n for (let i = 0, l = deps.length; i < l; i++) {\n deps[i].notify()\n }\n }\n }\n if (watcher.dirty) {\n watcher.evaluate()\n }\n if (Dep.target) {\n watcher.depend()\n }\n return watcher.value\n }\n}\n","import {\n observe as doObserve,\n defineReactive,\n} from './observe'\nimport {\n watch as doWatch,\n makeComputed,\n} from './watcher'\nimport {\n defineValue,\n defineAccessor,\n noop,\n isFunction,\n everyEntries,\n} from './util'\nimport {\n WATCHERS_PROPERTY_NAME,\n DATA_PROPTERTY_NAME,\n} from './constants'\n\nObject.defineProperties(observe, {\n 'react': {value: react},\n 'compute': {value: compute},\n 'watch': {value: watch},\n 'default': {value: watch, writable: true}, // Only could be react, compute or watch\n 'deep': {value: false, writable: true},\n 'lazy': {value: false, writable: true},\n 'sync': {value: false, writable: true},\n})\n\n/**\n * observe\n *\n * @public\n * @param {Object} target\n * @param {*} [expression]\n * @param {*} [func]\n * @param {*} [options]\n * @return {Function} observe\n */\n\nexport default function observe (target, expression, func, options) {\n if (!target.hasOwnProperty(WATCHERS_PROPERTY_NAME)) {\n init(target)\n }\n return observe.default(target, expression, func, options)\n}\n\n/**\n * React options\n *\n * @param {Object} options\n * @param {Object} [target]\n * @return {Function} observe\n */\n\nfunction react (options, target) {\n if (target) {\n if (!target.hasOwnProperty(WATCHERS_PROPERTY_NAME)) {\n init(target)\n }\n } else {\n target = {}\n init(target)\n }\n options.methods && carryMethods(target, options.methods)\n options.data && reactProperties(target, options.data)\n options.computed && computeProperties(target, options.computed)\n options.watchers && watchProperties(target, options.watchers)\n return target\n}\n\n/**\n * Compute property\n *\n * @param {Object} target\n * @param {String} name\n * @param {Function|Object} getterOrAccessor\n * - Function getter\n * - Object accessor\n * - Function [get] - getter\n * - Function [set] - setter\n * - Boolean [cache]\n * @param {Boolean} [cache]\n */\n\nfunction compute (target, name, getterOrAccessor, cache) {\n if (!target.hasOwnProperty(WATCHERS_PROPERTY_NAME)) {\n init(target)\n }\n let getter, setter\n if (isFunction(getterOrAccessor)) {\n getter = cache !== false\n ? makeComputed(target, getterOrAccessor)\n : getterOrAccessor.bind(this)\n setter = noop\n } else {\n getter = getterOrAccessor.get\n ? getterOrAccessor.cache !== false || cache !== false\n ? makeComputed(target, getterOrAccessor.get)\n : getterOrAccessor.get.bind(this)\n : noop\n setter = getterOrAccessor.set ? getterOrAccessor.set.bind(this) : noop\n }\n defineAccessor(target, name, getter, setter)\n}\n\n/**\n * Watch property\n *\n * @param {Object} target\n * @param {String|Function} expressionOrFunction\n * @param {Function} callback\n * @param {Object} [options]\n * - {Boolean} deep\n * - {Boolean} sync\n * - {Boolean} lazy\n * @return {Watcher}\n */\n\nfunction watch (target, expressionOrFunction, callback, options = observe) {\n if (!target.hasOwnProperty(WATCHERS_PROPERTY_NAME)) {\n init(target)\n }\n return doWatch(target, expressionOrFunction, callback, options)\n}\n\n/**\n * @param {Object} target\n */\n\nfunction init (target) {\n defineValue(target, WATCHERS_PROPERTY_NAME, [], false)\n defineValue(target, DATA_PROPTERTY_NAME, Object.create(null), false)\n doObserve(target[DATA_PROPTERTY_NAME])\n reactSelfProperties(target)\n}\n\n/**\n * @param {Object} target\n * @param {Object} methods\n */\n\nfunction carryMethods (target, methods) {\n everyEntries(methods, (name, method) => {\n target[name] = method.bind(target)\n })\n}\n\n/**\n * @param {Object} target\n * @param {String} key\n * @param {*} value\n */\n\nfunction reactProperty (target, key, value) {\n target[DATA_PROPTERTY_NAME][key] = value\n defineReactive(target[DATA_PROPTERTY_NAME], key, value)\n proxy(target, key)\n}\n\n/**\n * @param {Object} target\n * @param {Object} properties\n */\n\nfunction reactProperties (target, properties) {\n everyEntries(properties, (key, value) => reactProperty(target, key, value))\n}\n\n/**\n * @param {Object} target\n */\n\nfunction reactSelfProperties (target) {\n everyEntries(target, (key, value) => {\n !isFunction(value) && reactProperty(target, key, value)\n })\n}\n\n/**\n * @param {Object} target\n * @param {Object} properties\n */\n\nfunction computeProperties (target, properties) {\n everyEntries(properties, (key, value) => compute(target, key, value))\n}\n\n/**\n * @param {Object} target\n * @param {Object} properties\n */\n\nfunction watchProperties (target, properties) {\n everyEntries(properties, (expression, functionOrOption) => {\n if (isFunction(functionOrOption)) {\n watch(target, expression, functionOrOption)\n } else {\n watch(target, expression, functionOrOption.watcher, functionOrOption)\n }\n })\n}\n\n/**\n * @param {Object} target\n * @param {String} key\n */\n\nfunction proxy (target, key) {\n function getter () {\n return target[DATA_PROPTERTY_NAME][key]\n }\n function setter (value) {\n target[DATA_PROPTERTY_NAME][key] = value\n }\n defineAccessor(target, key, getter, setter)\n}\n"],"names":["uid","Dep","id","subs","sub","push","$remove","target","addDep","i","l","length","update","OBSERVE_NAME","WATCHERS_PROPERTY_NAME","DATA_PROPTERTY_NAME","DEBUGGING","process","env","NODE_ENV","defineValue","object","property","value","enumerable","defineProperty","defineAccessor","getter","setter","isArray","Array","toString","Object","prototype","OBJECT_STRING","isPlainObject","call","isObject","isFunction","func","everyEntries","callback","keys","noop","warn","undefined","console","_Set","Set","match","set","create","has","key","add","clear","arrayPrototype","arrayMethods","arrayMutativeMethods","amend","array","setPrototypeOf","method","original","mutator","args","result","apply","observer","inserted","slice","observeArray","dep","notify","$set","index","Number","splice","item","indexOf","Observer","walk","convert","items","observe","hasOwnProperty","isExtensible","defineReactive","desc","getOwnPropertyDescriptor","configurable","get","childOb","reactiveGetter","currentValue","depend","e","reactiveSetter","newValue","oldValue","makeGetterFunction","body","Function","parse","expression","String","trim","callbacks","pending","nextTickHandler","callbackCopies","callNextTick","nextTick","MutationObserver","counter","textNode","document","createTextNode","data","setTimeout","context","arguments","unshift","queue","waiting","queueIndex","resetBatcherState","flushBatcherQueue","runBatcherQueue","watcher","run","batch","Watcher","owner","options","active","dirty","lazy","deps","newDeps","depIds","newDepIds","beforeGet","scope","deep","afterGet","addSub","removeSub","tmp","sync","current","traverse","watch","expressionOrFunction","parseExpression","makeComputed","computedGetter","evaluate","defineProperties","react","compute","writable","default","methods","carryMethods","reactProperties","computed","computeProperties","watchers","watchProperties","name","getterOrAccessor","cache","bind","doWatch","init","reactProperty","properties","reactSelfProperties","functionOrOption","proxy"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAIA,MAAM,CAAV;;;;;;;IAOqBC;iBAMJ;;;SACRC,EAAL,GAAUF,KAAV;SACKG,IAAL,GAAY,EAAZ;;;;;;;;;;;;;;;;2BASMC,KAAK;WACND,IAAL,CAAUE,IAAV,CAAeD,GAAf;;;;;;;;;;;8BASSA,KAAK;WACTD,IAAL,CAAUG,OAAV,CAAkBF,GAAlB;;;;;;;;;6BAOQ;UACJG,MAAJ,CAAWC,MAAX,CAAkB,IAAlB;;;;;;;;;6BAOQ;UACFL,OAAO,KA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hB;GAAzB;;;;;;;;AAQF,SAASkJ,eAAT,CAA0BlK,MAA1B,EAAkC0K,UAAlC,EAA8C;eAC/BA,UAAb,EAAyB,UAACzE,UAAD,EAAa2E,gBAAb,EAAkC;QACrD7I,WAAW6I,gBAAX,CAAJ,EAAkC;eAC1B5K,MAAN,EAAciG,UAAd,EAA0B2E,gBAA1B;KADF,MAEO;eACC5K,MAAN,EAAciG,UAAd,EAA0B2E,iBAAiBlD,OAA3C,EAAoDkD,gBAApD;;GAJJ;;;;;;;;AAcF,SAASC,KAAT,CAAgB7K,MAAhB,EAAwB8C,GAAxB,EAA6B;WAClB1B,MAAT,GAAmB;WACVpB,OAAOQ,mBAAP,EAA4BsC,GAA5B,CAAP;;WAEOzB,MAAT,CAAiBL,KAAjB,EAAwB;WACfR,mBAAP,EAA4BsC,GAA5B,IAAmC9B,KAAnC;;iBAEahB,MAAf,EAAuB8C,GAAvB,EAA4B1B,MAA5B,EAAoCC,MAApC;;;;;"} \ No newline at end of file +{"version":3,"file":"smart-observe.js","sources":["../src/dep.js","../src/constants.js","../src/util.js","../src/array.js","../src/observe.js","../src/expression.js","../node_modules/smart-next-tick/nextTick.js","../src/batcher.js","../src/watcher.js","../src/index.js"],"sourcesContent":["let uid = 0\n\n/**\n * A dep is an observable that can have multiple\n * watcher subscribing to it.\n */\n\nexport default class Dep {\n // the current target watcher being evaluated.\n // this is globally unique because there could be only one\n // watcher being evaluated at any time.\n static target = null\n\n constructor () {\n this.id = uid++\n this.subs = []\n }\n\n /**\n * Add a subscriber.\n *\n * @param {Watcher} sub\n */\n\n addSub (sub) {\n this.subs.push(sub)\n }\n\n /**\n * Remove a subscriber.\n *\n * @param {Watcher} sub\n */\n\n removeSub (sub) {\n this.subs.$remove(sub)\n }\n\n /**\n * Add self as a dependency to the target watcher.\n */\n\n depend () {\n Dep.target.addDep(this)\n }\n\n /**\n * Notify all subscribers of a new value.\n */\n\n notify () {\n const subs = this.subs\n for (let i = 0, l = subs.length; i < l; i++) {\n subs[i].update()\n }\n }\n}\n","export const OBSERVE_NAME = '__s_o__'\nexport const WATCHERS_PROPERTY_NAME = '__watchers__'\nexport const DATA_PROPTERTY_NAME = '__data__'\n\nexport const DEBUGGING = typeof process !== 'undefined'\n && process.env.NODE_ENV !== 'production'\n","import {DEBUGGING} from './constants'\n\n/**\n * Define property with value.\n *\n * @param {Object} object\n * @param {String} property\n * @param {*} value\n * @param {Boolean} [enumerable]\n */\n\nexport function defineValue (object, property, value, enumerable) {\n Object.defineProperty(object, property, {\n value,\n enumerable: !!enumerable,\n writable: true,\n configurable: true,\n })\n}\n\n/**\n * Define property with getter and setter.\n *\n * @param {Object} object\n * @param {String} property\n * @param {Function} getter\n * @param {Function} setter\n */\n\nexport function defineAccessor (object, property, getter, setter) {\n Object.defineProperty(object, property, {\n get: getter,\n set: setter,\n enumerable: true,\n configurable: true,\n })\n}\n\n/**\n * Array type check.\n *\n * @return {Boolean}\n */\n\nexport const isArray = Array.isArray\n\n/**\n * Strict object type check. Only returns true\n * for plain JavaScript objects.\n *\n * @param {*} object\n * @return {Boolean}\n */\n\nconst toString = Object.prototype.toString\nconst OBJECT_STRING = '[object Object]'\nexport function isPlainObject (object) {\n return toString.call(object) === OBJECT_STRING\n}\n\n/**\n * Quick object check - this is primarily used to tell\n * Objects from primitive values when we know the value\n * is a JSON-compliant type.\n *\n * @param {*} object\n * @return {Boolean}\n */\n\nexport function isObject (object) {\n return object !== null && typeof object === 'object'\n}\n\n/**\n * Function type check\n *\n * @param {*} func\n * @param {Boolean}\n */\n\nexport function isFunction (func) {\n return typeof func === 'function'\n}\n\n/**\n * Iterate object\n *\n * @param {Object} object\n * @param {Function} callback\n */\n\nexport function everyEntries (object, callback) {\n const keys = Object.keys(object)\n for (let i = 0, l = keys.length; i < l; i++) {\n callback(keys[i], object[keys[i]])\n }\n}\n\n/**\n * noop is function which is nothing to do.\n */\n\nexport function noop () {}\n\n/**\n * @param {String} string\n */\n\nexport const warn = typeof DEBUGGING !== 'undefined' && DEBUGGING\n && typeof console !== 'undefined' && console\n && isFunction(console.warn)\n ? console.warn\n : noop\n\nexport let _Set\nif (typeof Set !== 'undefined' && Set.toString().match(/native code/)) {\n // use native Set when available.\n _Set = Set\n} else {\n // a non-standard Set polyfill that only works with primitive keys.\n _Set = function () {\n this.set = Object.create(null)\n }\n _Set.prototype.has = function (key) {\n return this.set[key] !== undefined\n }\n _Set.prototype.add = function (key) {\n this.set[key] = 1\n }\n _Set.prototype.clear = function () {\n this.set = Object.create(null)\n }\n}\n","import {defineValue} from './util'\nimport {OBSERVE_NAME} from './constants'\n\nconst arrayPrototype = Array.prototype\nconst arrayMethods = Object.create(arrayPrototype)\nconst arrayMutativeMethods = [\n 'push',\n 'pop',\n 'shift',\n 'unshift',\n 'splice',\n 'sort',\n 'reverse',\n]\n\n/**\n * Augment an target Array with arrayMethods\n *\n * @param {Array} array\n */\n\nexport default function amend (array) {\n Object.setPrototypeOf(array, arrayMethods)\n}\n\n/**\n * Intercept mutating methods and emit events\n */\n\nfor (\n let i = 0, l = arrayMutativeMethods.length, method;\n i < l;\n method = arrayMutativeMethods[++i]\n) {\n // cache original method\n const original = arrayPrototype[method]\n defineValue(arrayMethods, method, function mutator (...args) {\n const result = original.apply(this, args)\n const observer = this[OBSERVE_NAME]\n let inserted\n switch (method) {\n case 'push':\n inserted = args\n break\n case 'unshift':\n inserted = args\n break\n case 'splice':\n inserted = args.slice(2)\n break\n }\n if (inserted) observer.observeArray(inserted)\n observer.dep.notify() // notify change\n return result\n })\n}\n\n/**\n * Swap the element at the given index with a new value\n * and emits corresponding event.\n *\n * @param {Number} index\n * @param {*} value\n * @return {*} - replaced element\n */\n\nfunction $set (index, value) {\n if (index >= this.length) {\n this.length = Number(index) + 1\n }\n return this.splice(index, 1, value)[0]\n}\ndefineValue(arrayPrototype, '$set', $set)\n\n/**\n * Convenience method to remove the element at given index\n * or target element reference.\n *\n * @param {*} item\n * @return {*} - removed element\n */\n\nfunction $remove (item) {\n if (!this.length) return\n const index = this.indexOf(item)\n if (index > -1) {\n return this.splice(index, 1)\n }\n}\ndefineValue(arrayPrototype, '$remove', $remove)\n","import Dep from './dep'\nimport amendArray from './array'\nimport {\n defineValue,\n defineAccessor,\n isArray,\n isPlainObject,\n everyEntries,\n} from './util'\nimport {OBSERVE_NAME} from './constants'\n\n/**\n * Observer class that are attached to each observed\n * object. Once attached, the observer converts target\n * object's property keys into getter/setters that\n * collect dependencies and dispatches updates.\n *\n * @class\n * @param {Array|Object} value\n */\n\nclass Observer {\n constructor (value) {\n this.value = value\n this.dep = new Dep()\n defineValue(value, OBSERVE_NAME, this)\n if (isArray(value)) {\n amendArray(value)\n this.observeArray(value)\n } else {\n this.walk(value)\n }\n }\n\n /**\n * Walk through each property and convert them into\n * getter/setters. This method should only be called when\n * value type is Object.\n *\n * @param {Object} object\n */\n\n walk (object) {\n everyEntries(object, (key, value) => this.convert(key, value))\n }\n\n /**\n * Observe a list of Array items.\n *\n * @param {Array} items\n */\n\n observeArray (items) {\n for (let i = 0, l = items.length; i < l; i++) {\n observe(items[i])\n }\n }\n\n /**\n * Convert a property into getter/setter so we can emit\n * the events when the property is accessed/changed.\n *\n * @param {String} key\n * @param {*} value\n */\n\n convert (key, value) {\n defineReactive(this.value, key, value)\n }\n}\n\n/**\n * Attempt to create an observer instance for a value,\n * returns the new observer if successfully observed,\n * or the existing observer if the value already has one.\n *\n * @param {*} value\n * @return {Observer|undefined}\n */\n\nexport function observe (value) {\n if (!value || typeof value !== 'object') return\n let observer\n if (\n Object.prototype.hasOwnProperty.call(value, OBSERVE_NAME)\n && value[OBSERVE_NAME] instanceof Observer\n ) {\n observer = value[OBSERVE_NAME]\n } else if (\n (isArray(value) || isPlainObject(value))\n && Object.isExtensible(value)\n ) {\n observer = new Observer(value)\n }\n return observer\n}\n\n/**\n * Define a reactive property on an Object.\n *\n * @param {Object} object\n * @param {String} key\n * @param {*} value\n */\n\nexport function defineReactive (object, key, value) {\n const dep = new Dep()\n\n const desc = Object.getOwnPropertyDescriptor(object, key)\n if (desc && desc.configurable === false) return\n\n // cater for pre-defined getter/setters\n const getter = desc && desc.get\n const setter = desc && desc.set\n\n let childOb = observe(value)\n\n function reactiveGetter () {\n const currentValue = getter ? getter.call(object) : value\n if (Dep.target) {\n dep.depend()\n if (childOb) {\n childOb.dep.depend()\n }\n if (isArray(currentValue)) {\n for (let i = 0, l = currentValue.length, e; i < l; i++) {\n e = currentValue[i]\n e && e[OBSERVE_NAME] && e[OBSERVE_NAME].dep.depend()\n }\n }\n }\n return currentValue\n }\n function reactiveSetter (newValue) {\n const oldValue = getter ? getter.call(object) : value\n if (newValue === oldValue) return\n if (setter) {\n setter.call(object, newValue)\n } else {\n value = newValue\n }\n childOb = observe(newValue)\n dep.notify()\n }\n defineAccessor(object, key, reactiveGetter, reactiveSetter)\n}\n","import {warn} from './util'\n\n/**\n * Build a getter function. Requires eval.\n *\n * We isolate the try/catch so it doesn't affect the\n * optimization of the parse function when it is not called.\n *\n * @param {String} body\n * @return {Function|undefined}\n */\n\nfunction makeGetterFunction (body) {\n try {\n /* eslint-disable no-new-func */\n return new Function('scope', `return ${body};`)\n /* eslint-enable no-new-func */\n } catch (e) {\n warn('Invalid expression. Generated function body: ' + body)\n }\n}\n\n/**\n * Parse an expression to getter.\n *\n * @param {String} expression\n * @return {Function|undefined}\n */\n\nexport default function parse (expression) {\n expression = String.prototype.trim.call(expression)\n return makeGetterFunction('scope.' + expression)\n}\n","var callbacks = []\nvar pending = false\nfunction nextTickHandler () {\n pending = false\n var callbackCopies = callbacks.slice(0)\n callbacks.length = 0\n for (var i = 0; i < callbackCopies.length; i++) {\n callbackCopies[i]()\n }\n}\n\nvar callNextTick\nif (typeof process === 'object'\n && process\n && typeof process.nextTick === 'function'\n) {\n callNextTick = process.nextTick\n} else if (typeof MutationObserver !== 'undefined') {\n var counter = 0\n var textNode = document.createTextNode(counter)\n var observer = new MutationObserver(nextTickHandler)\n observer.observe(textNode, {\n characterData: true\n })\n callNextTick = function () {\n counter = counter === 0 ? 1 : 0\n textNode.data = String(counter)\n }\n} else {\n callNextTick = setTimeout\n}\n\n\nmodule.exports = function nextTick (callback, context) {\n var func = callback\n if (context) {\n var args = []\n var l = arguments.length\n while (--l > 1) {\n args.unshift(arguments[l])\n }\n func = function () {\n callback.apply(context, args)\n }\n }\n callbacks.push(func)\n if (pending) {\n return\n }\n pending = true\n callNextTick(nextTickHandler)\n}\n","import nextTick from 'smart-next-tick'\n\nlet queue = []\nlet has = {}\nlet waiting = false\nlet queueIndex\n\n/**\n * Reset the batcher's state.\n */\n\nfunction resetBatcherState () {\n queue = []\n has = {}\n waiting = false\n}\n\n/**\n * Flush queue and run the watchers.\n */\n\nfunction flushBatcherQueue () {\n runBatcherQueue(queue)\n resetBatcherState()\n}\n\n/**\n * Run the watchers in a single queue.\n *\n * @param {Array} queue\n */\n\nfunction runBatcherQueue (queue) {\n // do not cache length because more watchers might be pushed\n // as we run existing watchers\n for (queueIndex = 0; queueIndex < queue.length; queueIndex++) {\n const watcher = queue[queueIndex]\n const id = watcher.id\n has[id] = null\n watcher.run()\n }\n}\n\n/**\n * Push a watcher into the watcher queue.\n * Jobs with duplicate IDs will be skipped unless it's\n * pushed when the queue is being flushed.\n *\n * @param {Watcher} watcher\n * properties:\n * - {Number} id\n * - {Function} run\n */\n\nexport default function batch (watcher) {\n const id = watcher.id\n if (has[id] == null) {\n has[id] = queue.length\n queue.push(watcher)\n // queue the flush\n if (!waiting) {\n waiting = true\n nextTick(flushBatcherQueue)\n }\n }\n}\n","import observe from './index'\nimport Dep from './dep'\nimport parseExpression from './expression'\nimport batch from './batcher'\nimport {\n isArray,\n isObject,\n isFunction,\n _Set as Set,\n} from './util'\nimport {WATCHERS_PROPERTY_NAME} from './constants'\n\nlet uid = 0\n\nclass Watcher {\n\n /**\n * A watcher parses an expression, collects dependencies,\n * and fires callback when the expression value changes.\n *\n * @param {Object} owner\n * @param {String|Function} getter\n * @param {Function} callback\n * @param {Object} options\n * - {Boolean} deep\n * - {Boolean} sync\n * - {Boolean} lazy\n * @constructor\n */\n\n constructor (owner, getter, callback, options) {\n owner[WATCHERS_PROPERTY_NAME].push(this)\n this.owner = owner\n this.getter = getter\n this.callback = callback\n this.options = options\n // uid for batching\n this.id = ++uid\n this.active = true\n // for lazy watchers\n this.dirty = options.lazy\n this.deps = []\n this.newDeps = []\n this.depIds = new Set()\n this.newDepIds = new Set()\n this.value = options.lazy\n ? undefined\n : this.get()\n }\n\n /**\n * Evaluate the getter, and re-collect dependencies.\n */\n\n get () {\n this.beforeGet()\n const scope = this.owner\n const value = this.getter.call(scope, scope)\n if (this.options.deep) {\n traverse(value)\n }\n this.afterGet()\n return value\n }\n\n /**\n * Prepare for dependency collection.\n */\n\n beforeGet () {\n Dep.target = this\n }\n\n /**\n * Add a dependency to this directive.\n *\n * @param {Dep} dep\n */\n\n addDep (dep) {\n const id = dep.id\n if (!this.newDepIds.has(id)) {\n this.newDepIds.add(id)\n this.newDeps.push(dep)\n if (!this.depIds.has(id)) {\n dep.addSub(this)\n }\n }\n }\n\n /**\n * Clean up for dependency collection.\n */\n\n afterGet () {\n Dep.target = null\n let i = this.deps.length\n while (i--) {\n const dep = this.deps[i]\n if (!this.newDepIds.has(dep.id)) {\n dep.removeSub(this)\n }\n }\n let tmp = this.depIds\n this.depIds = this.newDepIds\n this.newDepIds = tmp\n this.newDepIds.clear()\n tmp = this.deps\n this.deps = this.newDeps\n this.newDeps = tmp\n this.newDeps.length = 0\n }\n\n /**\n * Will be called when a dependency changes.\n */\n\n update () {\n if (this.options.lazy) {\n this.dirty = true\n } else if (this.options.sync) {\n this.run()\n } else {\n batch(this)\n }\n }\n\n /**\n * Will be called by the batcher.\n */\n\n run () {\n if (this.active) {\n const value = this.get()\n if (\n value !== this.value\n // Deep watchers and watchers on Object/Arrays should fire even when\n // the value is the same, because the value may have mutated;\n || ((isObject(value) || this.options.deep))\n ) {\n const oldValue = this.value\n this.value = value\n this.callback.call(this.owner, value, oldValue)\n }\n }\n }\n\n /**\n * Evaluate the value of the watcher.\n * This only gets called for lazy watchers.\n */\n\n evaluate () {\n // avoid overwriting another watcher that is being collected.\n const current = Dep.target\n this.value = this.get()\n this.dirty = false\n Dep.target = current\n }\n\n /**\n * Depend on all deps collected by this watcher.\n */\n\n depend () {\n let i = this.deps.length\n while (i--) {\n this.deps[i].depend()\n }\n }\n\n /**\n * Remove self from all dependencies' subcriber list.\n */\n\n teardown () {\n if (this.active) {\n let i = this.deps.length\n while (i--) {\n this.deps[i].removeSub(this)\n }\n this.active = false\n this.owner = this.callback = this.value = null\n }\n }\n}\n\n/**\n * Recrusively traverse an object to evoke all converted\n * getters, so that every nested property inside the object\n * is collected as a \"deep\" dependency.\n *\n * @param {*} value\n */\n\nfunction traverse (value) {\n let i, keys\n if (isArray(value)) {\n i = value.length\n while (i--) traverse(value[i])\n } else if (isObject(value)) {\n keys = Object.keys(value)\n i = keys.length\n while (i--) traverse(value[keys[i]])\n }\n}\n\n/**\n * Create an watcher instance, returns the new watcher.\n *\n * @param {Object} owner\n * @param {String|Function} expressionOrFunction\n * @param {Function} callback\n * @param {Object} options\n * - {Boolean} deep\n * - {Boolean} sync\n * - {Boolean} lazy\n * @return {Watcher}\n */\n\nexport function watch (owner, expressionOrFunction, callback, options) {\n // parse expression for getter\n const getter = isFunction(expressionOrFunction)\n ? expressionOrFunction\n : parseExpression(expressionOrFunction)\n return new Watcher(owner, getter, callback, options)\n}\n\n/**\n * Make a computed getter, which can collect dependencies.\n *\n * @param {Object} owner\n * @param {Function} getter\n */\n\nexport function makeComputed (owner, getter) {\n const watcher = new Watcher(owner, getter, null, {\n deep: observe.deep,\n lazy: true,\n sync: observe.sync,\n })\n return function computedGetter () {\n if (watcher.options.lazy && Dep.target && !Dep.target.options.lazy) {\n watcher.options.lazy = false\n watcher.callback = function () {\n const deps = watcher.deps\n for (let i = 0, l = deps.length; i < l; i++) {\n deps[i].notify()\n }\n }\n }\n if (watcher.dirty) {\n watcher.evaluate()\n }\n if (Dep.target) {\n watcher.depend()\n }\n return watcher.value\n }\n}\n","import {\n observe as doObserve,\n defineReactive,\n} from './observe'\nimport {\n watch as doWatch,\n makeComputed,\n} from './watcher'\nimport {\n defineValue,\n defineAccessor,\n noop,\n isFunction,\n everyEntries,\n} from './util'\nimport {\n WATCHERS_PROPERTY_NAME,\n DATA_PROPTERTY_NAME,\n} from './constants'\n\nObject.defineProperties(observe, {\n 'react': {value: react},\n 'compute': {value: compute},\n 'watch': {value: watch},\n 'default': {value: watch, writable: true}, // Only could be react, compute or watch\n 'deep': {value: false, writable: true},\n 'lazy': {value: false, writable: true},\n 'sync': {value: false, writable: true},\n})\n\n/**\n * observe\n *\n * @public\n * @param {Object} target\n * @param {*} [expression]\n * @param {*} [func]\n * @param {*} [options]\n * @return {Function} observe\n */\n\nexport default function observe (target, expression, func, options) {\n ensure(target)\n return observe.default(target, expression, func, options)\n}\n\n/**\n * React options\n *\n * @param {Object} options\n * @param {Object} [target]\n * @return {Function} observe\n */\n\nfunction react (options, target) {\n if (target) {\n ensure(target)\n } else {\n target = {}\n init(target)\n }\n options.methods && carryMethods(target, options.methods)\n options.data && reactProperties(target, options.data)\n options.computed && computeProperties(target, options.computed)\n options.watchers && watchProperties(target, options.watchers)\n return target\n}\n\n/**\n * Compute property\n *\n * @param {Object} target\n * @param {String} name\n * @param {Function|Object} getterOrAccessor\n * - Function getter\n * - Object accessor\n * - Function [get] - getter\n * - Function [set] - setter\n * - Boolean [cache]\n * @param {Boolean} [cache]\n */\n\nfunction compute (target, name, getterOrAccessor, cache) {\n ensure(target)\n let getter, setter\n if (isFunction(getterOrAccessor)) {\n getter = cache !== false\n ? makeComputed(target, getterOrAccessor)\n : getterOrAccessor.bind(this)\n setter = noop\n } else {\n getter = getterOrAccessor.get\n ? getterOrAccessor.cache !== false || cache !== false\n ? makeComputed(target, getterOrAccessor.get)\n : getterOrAccessor.get.bind(this)\n : noop\n setter = getterOrAccessor.set ? getterOrAccessor.set.bind(this) : noop\n }\n defineAccessor(target, name, getter, setter)\n}\n\n/**\n * Watch property\n *\n * @param {Object} target\n * @param {String|Function} expressionOrFunction\n * @param {Function} callback\n * @param {Object} [options]\n * - {Boolean} deep\n * - {Boolean} sync\n * - {Boolean} lazy\n * @return {Watcher}\n */\n\nfunction watch (target, expressionOrFunction, callback, options = observe) {\n ensure(target)\n return doWatch(target, expressionOrFunction, callback, options)\n}\n\n/**\n * @param {Object} target\n */\n\nfunction init (target) {\n defineValue(target, WATCHERS_PROPERTY_NAME, [], false)\n defineValue(target, DATA_PROPTERTY_NAME, Object.create(null), false)\n doObserve(target[DATA_PROPTERTY_NAME])\n reactSelfProperties(target)\n}\n\nfunction ensure (target) {\n if (!Object.prototype.hasOwnProperty.call(target, WATCHERS_PROPERTY_NAME)) {\n init(target)\n }\n}\n\n/**\n * @param {Object} target\n * @param {Object} methods\n */\n\nfunction carryMethods (target, methods) {\n everyEntries(methods, (name, method) => {\n target[name] = method.bind(target)\n })\n}\n\n/**\n * @param {Object} target\n * @param {String} key\n * @param {*} value\n */\n\nfunction reactProperty (target, key, value) {\n target[DATA_PROPTERTY_NAME][key] = value\n defineReactive(target[DATA_PROPTERTY_NAME], key, value)\n proxy(target, key)\n}\n\n/**\n * @param {Object} target\n * @param {Object} properties\n */\n\nfunction reactProperties (target, properties) {\n everyEntries(properties, (key, value) => reactProperty(target, key, value))\n}\n\n/**\n * @param {Object} target\n */\n\nfunction reactSelfProperties (target) {\n everyEntries(target, (key, value) => {\n !isFunction(value) && reactProperty(target, key, value)\n })\n}\n\n/**\n * @param {Object} target\n * @param {Object} properties\n */\n\nfunction computeProperties (target, properties) {\n everyEntries(properties, (key, value) => compute(target, key, value))\n}\n\n/**\n * @param {Object} target\n * @param {Object} properties\n */\n\nfunction watchProperties (target, properties) {\n everyEntries(properties, (expression, functionOrOption) => {\n if (isFunction(functionOrOption)) {\n watch(target, expression, functionOrOption)\n } else {\n watch(target, expression, functionOrOption.watcher, functionOrOption)\n }\n })\n}\n\n/**\n * @param {Object} target\n * @param {String} key\n */\n\nfunction proxy (target, key) {\n function getter () {\n return target[DATA_PROPTERTY_NAME][key]\n }\n function setter (value) {\n target[DATA_PROPTERTY_NAME][key] = value\n }\n defineAccessor(target, key, getter, setter)\n}\n"],"names":["uid","Dep","id","subs","sub","push","$remove","target","addDep","i","l","length","update","OBSERVE_NAME","WATCHERS_PROPERTY_NAME","DATA_PROPTERTY_NAME","DEBUGGING","process","env","NODE_ENV","defineValue","object","property","value","enumerable","defineProperty","defineAccessor","getter","setter","isArray","Array","toString","Object","prototype","OBJECT_STRING","isPlainObject","call","isObject","isFunction","func","everyEntries","callback","keys","noop","warn","console","_Set","Set","match","set","create","has","key","undefined","add","clear","arrayPrototype","arrayMethods","arrayMutativeMethods","amend","array","setPrototypeOf","method","original","mutator","args","result","apply","observer","inserted","slice","observeArray","dep","notify","$set","index","Number","splice","item","indexOf","Observer","walk","convert","items","observe","hasOwnProperty","isExtensible","defineReactive","desc","getOwnPropertyDescriptor","configurable","get","childOb","reactiveGetter","currentValue","depend","e","reactiveSetter","newValue","oldValue","makeGetterFunction","body","Function","parse","expression","String","trim","callbacks","pending","nextTickHandler","callbackCopies","callNextTick","nextTick","MutationObserver","counter","textNode","document","createTextNode","data","setTimeout","context","arguments","unshift","queue","waiting","queueIndex","resetBatcherState","flushBatcherQueue","runBatcherQueue","watcher","run","batch","Watcher","owner","options","active","dirty","lazy","deps","newDeps","depIds","newDepIds","beforeGet","scope","deep","afterGet","addSub","removeSub","tmp","sync","current","traverse","watch","expressionOrFunction","parseExpression","makeComputed","computedGetter","evaluate","defineProperties","react","compute","writable","default","methods","carryMethods","reactProperties","computed","computeProperties","watchers","watchProperties","name","getterOrAccessor","cache","bind","doWatch","init","ensure","reactProperty","properties","reactSelfProperties","functionOrOption","proxy"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAIA,MAAM,CAAV;;;;;;;IAOqBC;iBAMJ;;;SACRC,EAAL,GAAU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UF,SAASgJ,iBAAT,CAA4BhK,MAA5B,EAAoC2K,UAApC,EAAgD;eACjCA,UAAb,EAAyB,UAAC9H,GAAD,EAAM7B,KAAN;WAAgByI,QAAQzJ,MAAR,EAAgB6C,GAAhB,EAAqB7B,KAArB,CAAhB;GAAzB;;;;;;;;AAQF,SAASkJ,eAAT,CAA0BlK,MAA1B,EAAkC2K,UAAlC,EAA8C;eAC/BA,UAAb,EAAyB,UAAC1E,UAAD,EAAa4E,gBAAb,EAAkC;QACrD9I,WAAW8I,gBAAX,CAAJ,EAAkC;eAC1B7K,MAAN,EAAciG,UAAd,EAA0B4E,gBAA1B;KADF,MAEO;eACC7K,MAAN,EAAciG,UAAd,EAA0B4E,iBAAiBnD,OAA3C,EAAoDmD,gBAApD;;GAJJ;;;;;;;;AAcF,SAASC,KAAT,CAAgB9K,MAAhB,EAAwB6C,GAAxB,EAA6B;WAClBzB,MAAT,GAAmB;WACVpB,OAAOQ,mBAAP,EAA4BqC,GAA5B,CAAP;;WAEOxB,MAAT,CAAiBL,KAAjB,EAAwB;WACfR,mBAAP,EAA4BqC,GAA5B,IAAmC7B,KAAnC;;iBAEahB,MAAf,EAAuB6C,GAAvB,EAA4BzB,MAA5B,EAAoCC,MAApC;;;;;"} \ No newline at end of file diff --git a/dist/smart-observe.min.js b/dist/smart-observe.min.js index d696705..1e14def 100644 --- a/dist/smart-observe.min.js +++ b/dist/smart-observe.min.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define("observe",t):e.observe=t()}(this,function(){"use strict";function e(e,t,n,i){Object.defineProperty(e,t,{value:n,enumerable:!!i,writable:!0,configurable:!0})}function t(e,t,n,i){Object.defineProperty(e,t,{get:n,set:i,enumerable:!0,configurable:!0})}function n(e){return J.call(e)===K}function i(e){return null!==e&&"object"===("undefined"==typeof e?"undefined":E(e))}function o(e){return"function"==typeof e}function r(e,t){for(var n=Object.keys(e),i=0,o=n.length;i=this.length&&(this.length=Number(e)+1),this.splice(e,1,t)[0]}function c(e){if(this.length){var t=this.indexOf(e);return t>-1?this.splice(t,1):void 0}}function f(e){if(e&&"object"===("undefined"==typeof e?"undefined":E(e))){var t=void 0;return Object.prototype.hasOwnProperty.call(e,F)&&e[F]instanceof ne?t=e[F]:(H(e)||n(e))&&Object.isExtensible(e)&&(t=new ne(e)),t}}function l(e,n,i){function o(){var t=a?a.call(e):i;if(C.target&&(s.depend(),l&&l.dep.depend(),H(t)))for(var n,o=0,r=t.length;o3&&void 0!==arguments[3]?arguments[3]:O;return e.hasOwnProperty(V)||_(e),k(e,t,n,i)}function _(t){e(t,V,[],!1),e(t,q,Object.create(null),!1),f(t[q]),z(t)}function I(e,t){r(t,function(t,n){e[t]=n.bind(e)})}function P(e,t,n){e[q][t]=n,l(e[q],t,n),T(e,t)}function x(e,t){r(t,function(t,n){return P(e,t,n)})}function z(e){r(e,function(t,n){!o(n)&&P(e,t,n)})}function A(e,t){r(t,function(t,n){return D(e,t,n)})}function G(e,t){r(t,function(t,n){o(n)?S(e,t,n):S(e,t,n.watcher,n)})}function T(e,n){function i(){return e[q][n]}function o(t){e[q][n]=t}t(e,n,i,o)}var E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},N=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},$=function(){function e(e,t){for(var n=0;n1;)i.unshift(arguments[o]);n=function(){e.apply(t,i)}}ie.push(n),oe||(oe=!0,te(p))},ce=[],fe={},le=!1,he=void 0,de=0,pe=function(){function e(t,n,i,o){N(this,e),t[V].push(this),this.owner=t,this.getter=n,this.callback=i,this.options=o,this.id=++de,this.active=!0,this.dirty=o.lazy,this.deps=[],this.newDeps=[],this.depIds=new Q,this.newDepIds=new Q,this.value=o.lazy?void 0:this.get()}return $(e,[{key:"get",value:function(){this.beforeGet();var e=this.owner,t=this.getter.call(e,e);return this.options.deep&&w(t),this.afterGet(),t}},{key:"beforeGet",value:function(){C.target=this}},{key:"addDep",value:function(e){var t=e.id;this.newDepIds.has(t)||(this.newDepIds.add(t),this.newDeps.push(e),this.depIds.has(t)||e.addSub(this))}},{key:"afterGet",value:function(){C.target=null;for(var e=this.deps.length;e--;){var t=this.deps[e];this.newDepIds.has(t.id)||t.removeSub(this)}var n=this.depIds;this.depIds=this.newDepIds,this.newDepIds=n,this.newDepIds.clear(),n=this.deps,this.deps=this.newDeps,this.newDeps=n,this.newDeps.length=0}},{key:"update",value:function(){this.options.lazy?this.dirty=!0:this.options.sync?this.run():g(this)}},{key:"run",value:function(){if(this.active){var e=this.get();if(e!==this.value||i(e)||this.options.deep){var t=this.value;this.value=e,this.callback.call(this.owner,e,t)}}}},{key:"evaluate",value:function(){var e=C.target;this.value=this.get(),this.dirty=!1,C.target=e}},{key:"depend",value:function(){for(var e=this.deps.length;e--;)this.deps[e].depend()}},{key:"teardown",value:function(){if(this.active){for(var e=this.deps.length;e--;)this.deps[e].removeSub(this);this.active=!1,this.owner=this.callback=this.value=null}}}]),e}();return Object.defineProperties(O,{react:{value:j},compute:{value:D},watch:{value:S},default:{value:S,writable:!0},deep:{value:!1,writable:!0},lazy:{value:!1,writable:!0},sync:{value:!1,writable:!0}}),O}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define("observe",t):e.observe=t()}(this,function(){"use strict";function e(e,t,n,i){Object.defineProperty(e,t,{value:n,enumerable:!!i,writable:!0,configurable:!0})}function t(e,t,n,i){Object.defineProperty(e,t,{get:n,set:i,enumerable:!0,configurable:!0})}function n(e){return K.call(e)===L}function i(e){return null!==e&&"object"===("undefined"==typeof e?"undefined":N(e))}function o(e){return"function"==typeof e}function r(e,t){for(var n=Object.keys(e),i=0,o=n.length;i=this.length&&(this.length=Number(e)+1),this.splice(e,1,t)[0]}function c(e){if(this.length){var t=this.indexOf(e);return t>-1?this.splice(t,1):void 0}}function f(e){if(e&&"object"===("undefined"==typeof e?"undefined":N(e))){var t=void 0;return Object.prototype.hasOwnProperty.call(e,V)&&e[V]instanceof ie?t=e[V]:(J(e)||n(e))&&Object.isExtensible(e)&&(t=new ie(e)),t}}function l(e,n,i){function o(){var t=a?a.call(e):i;if(F.target&&(s.depend(),l&&l.dep.depend(),J(t)))for(var n,o=0,r=t.length;o3&&void 0!==arguments[3]?arguments[3]:O;return I(e),k(e,t,n,i)}function _(t){e(t,q,[],!1),e(t,B,Object.create(null),!1),f(t[B]),A(t)}function I(e){Object.prototype.hasOwnProperty.call(e,q)||_(e)}function x(e,t){r(t,function(t,n){e[t]=n.bind(e)})}function z(e,t,n){e[B][t]=n,l(e[B],t,n),E(e,t)}function P(e,t){r(t,function(t,n){return z(e,t,n)})}function A(e){r(e,function(t,n){!o(n)&&z(e,t,n)})}function G(e,t){r(t,function(t,n){return D(e,t,n)})}function T(e,t){r(t,function(t,n){o(n)?S(e,t,n):S(e,t,n.watcher,n)})}function E(e,n){function i(){return e[B][n]}function o(t){e[B][n]=t}t(e,n,i,o)}var N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},$=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},M=function(){function e(e,t){for(var n=0;n1;)i.unshift(arguments[o]);n=function(){e.apply(t,i)}}oe.push(n),re||(re=!0,ne(p))},fe=[],le={},he=!1,de=void 0,pe=0,ve=function(){function e(t,n,i,o){$(this,e),t[q].push(this),this.owner=t,this.getter=n,this.callback=i,this.options=o,this.id=++pe,this.active=!0,this.dirty=o.lazy,this.deps=[],this.newDeps=[],this.depIds=new R,this.newDepIds=new R,this.value=o.lazy?void 0:this.get()}return M(e,[{key:"get",value:function(){this.beforeGet();var e=this.owner,t=this.getter.call(e,e);return this.options.deep&&w(t),this.afterGet(),t}},{key:"beforeGet",value:function(){F.target=this}},{key:"addDep",value:function(e){var t=e.id;this.newDepIds.has(t)||(this.newDepIds.add(t),this.newDeps.push(e),this.depIds.has(t)||e.addSub(this))}},{key:"afterGet",value:function(){F.target=null;for(var e=this.deps.length;e--;){var t=this.deps[e];this.newDepIds.has(t.id)||t.removeSub(this)}var n=this.depIds;this.depIds=this.newDepIds,this.newDepIds=n,this.newDepIds.clear(),n=this.deps,this.deps=this.newDeps,this.newDeps=n,this.newDeps.length=0}},{key:"update",value:function(){this.options.lazy?this.dirty=!0:this.options.sync?this.run():g(this)}},{key:"run",value:function(){if(this.active){var e=this.get();if(e!==this.value||i(e)||this.options.deep){var t=this.value;this.value=e,this.callback.call(this.owner,e,t)}}}},{key:"evaluate",value:function(){var e=F.target;this.value=this.get(),this.dirty=!1,F.target=e}},{key:"depend",value:function(){for(var e=this.deps.length;e--;)this.deps[e].depend()}},{key:"teardown",value:function(){if(this.active){for(var e=this.deps.length;e--;)this.deps[e].removeSub(this);this.active=!1,this.owner=this.callback=this.value=null}}}]),e}();return Object.defineProperties(O,{react:{value:j},compute:{value:D},watch:{value:S},default:{value:S,writable:!0},deep:{value:!1,writable:!0},lazy:{value:!1,writable:!0},sync:{value:!1,writable:!0}}),O}); //# sourceMappingURL=smart-observe.min.js.map diff --git a/dist/smart-observe.min.js.map b/dist/smart-observe.min.js.map index b819a4c..0a27eff 100644 --- a/dist/smart-observe.min.js.map +++ b/dist/smart-observe.min.js.map @@ -1 +1 @@ -{"version":3,"file":"smart-observe.min.js","sources":["../src/util.js","../src/array.js","../src/observe.js","../src/expression.js","../node_modules/smart-next-tick/nextTick.js","../src/batcher.js","../src/watcher.js","../src/index.js","../src/dep.js","../src/constants.js"],"sourcesContent":["import {DEBUGGING} from './constants'\n\n/**\n * Define property with value.\n *\n * @param {Object} object\n * @param {String} property\n * @param {*} value\n * @param {Boolean} [enumerable]\n */\n\nexport function defineValue (object, property, value, enumerable) {\n Object.defineProperty(object, property, {\n value,\n enumerable: !!enumerable,\n writable: true,\n configurable: true,\n })\n}\n\n/**\n * Define property with getter and setter.\n *\n * @param {Object} object\n * @param {String} property\n * @param {Function} getter\n * @param {Function} setter\n */\n\nexport function defineAccessor (object, property, getter, setter) {\n Object.defineProperty(object, property, {\n get: getter,\n set: setter,\n enumerable: true,\n configurable: true,\n })\n}\n\n/**\n * Array type check.\n *\n * @return {Boolean}\n */\n\nexport const isArray = Array.isArray\n\n/**\n * Strict object type check. Only returns true\n * for plain JavaScript objects.\n *\n * @param {*} object\n * @return {Boolean}\n */\n\nconst toString = Object.prototype.toString\nconst OBJECT_STRING = '[object Object]'\nexport function isPlainObject (object) {\n return toString.call(object) === OBJECT_STRING\n}\n\n/**\n * Quick object check - this is primarily used to tell\n * Objects from primitive values when we know the value\n * is a JSON-compliant type.\n *\n * @param {*} object\n * @return {Boolean}\n */\n\nexport function isObject (object) {\n return object !== null && typeof object === 'object'\n}\n\n/**\n * Function type check\n *\n * @param {*} func\n * @param {Boolean}\n */\n\nexport function isFunction (func) {\n return typeof func === 'function'\n}\n\n/**\n * Iterate object\n *\n * @param {Object} object\n * @param {Function} callback\n */\n\nexport function everyEntries (object, callback) {\n const keys = Object.keys(object)\n for (let i = 0, l = keys.length; i < l; i++) {\n callback(keys[i], object[keys[i]])\n }\n}\n\n/**\n * noop is function which is nothing to do.\n */\n\nexport function noop () {}\n\n/**\n * @param {String} string\n */\n\nexport const warn = typeof DEBUGGING !== undefined && DEBUGGING\n && typeof console !== 'undefined' && console\n && isFunction(console.warn)\n ? console.warn\n : noop\n\nexport let _Set\nif (typeof Set !== 'undefined' && Set.toString().match(/native code/)) {\n // use native Set when available.\n _Set = Set\n} else {\n // a non-standard Set polyfill that only works with primitive keys.\n _Set = function () {\n this.set = Object.create(null)\n }\n _Set.prototype.has = function (key) {\n return this.set[key] !== undefined\n }\n _Set.prototype.add = function (key) {\n this.set[key] = 1\n }\n _Set.prototype.clear = function () {\n this.set = Object.create(null)\n }\n}\n","import {defineValue} from './util'\nimport {OBSERVE_NAME} from './constants'\n\nconst arrayPrototype = Array.prototype\nconst arrayMethods = Object.create(arrayPrototype)\nconst arrayMutativeMethods = [\n 'push',\n 'pop',\n 'shift',\n 'unshift',\n 'splice',\n 'sort',\n 'reverse',\n]\n\n/**\n * Augment an target Array with arrayMethods\n *\n * @param {Array} array\n */\n\nexport default function amend (array) {\n Object.setPrototypeOf(array, arrayMethods)\n}\n\n/**\n * Intercept mutating methods and emit events\n */\n\nfor (\n let i = 0, l = arrayMutativeMethods.length, method;\n i < l;\n method = arrayMutativeMethods[++i]\n) {\n // cache original method\n const original = arrayPrototype[method]\n defineValue(arrayMethods, method, function mutator (...args) {\n const result = original.apply(this, args)\n const observer = this[OBSERVE_NAME]\n let inserted\n switch (method) {\n case 'push':\n inserted = args\n break\n case 'unshift':\n inserted = args\n break\n case 'splice':\n inserted = args.slice(2)\n break\n }\n if (inserted) observer.observeArray(inserted)\n observer.dep.notify() // notify change\n return result\n })\n}\n\n/**\n * Swap the element at the given index with a new value\n * and emits corresponding event.\n *\n * @param {Number} index\n * @param {*} value\n * @return {*} - replaced element\n */\n\nfunction $set (index, value) {\n if (index >= this.length) {\n this.length = Number(index) + 1\n }\n return this.splice(index, 1, value)[0]\n}\ndefineValue(arrayPrototype, '$set', $set)\n\n/**\n * Convenience method to remove the element at given index\n * or target element reference.\n *\n * @param {*} item\n * @return {*} - removed element\n */\n\nfunction $remove (item) {\n if (!this.length) return\n const index = this.indexOf(item)\n if (index > -1) {\n return this.splice(index, 1)\n }\n}\ndefineValue(arrayPrototype, '$remove', $remove)\n","import Dep from './dep'\nimport amendArray from './array'\nimport {\n defineValue,\n defineAccessor,\n isArray,\n isPlainObject,\n everyEntries,\n} from './util'\nimport {OBSERVE_NAME} from './constants'\n\n/**\n * Observer class that are attached to each observed\n * object. Once attached, the observer converts target\n * object's property keys into getter/setters that\n * collect dependencies and dispatches updates.\n *\n * @class\n * @param {Array|Object} value\n */\n\nclass Observer {\n constructor (value) {\n this.value = value\n this.dep = new Dep()\n defineValue(value, OBSERVE_NAME, this)\n if (isArray(value)) {\n amendArray(value)\n this.observeArray(value)\n } else {\n this.walk(value)\n }\n }\n\n /**\n * Walk through each property and convert them into\n * getter/setters. This method should only be called when\n * value type is Object.\n *\n * @param {Object} object\n */\n\n walk (object) {\n everyEntries(object, (key, value) => this.convert(key, value))\n }\n\n /**\n * Observe a list of Array items.\n *\n * @param {Array} items\n */\n\n observeArray (items) {\n for (let i = 0, l = items.length; i < l; i++) {\n observe(items[i])\n }\n }\n\n /**\n * Convert a property into getter/setter so we can emit\n * the events when the property is accessed/changed.\n *\n * @param {String} key\n * @param {*} value\n */\n\n convert (key, value) {\n defineReactive(this.value, key, value)\n }\n}\n\n/**\n * Attempt to create an observer instance for a value,\n * returns the new observer if successfully observed,\n * or the existing observer if the value already has one.\n *\n * @param {*} value\n * @return {Observer|undefined}\n */\n\nexport function observe (value) {\n if (!value || typeof value !== 'object') return\n let observer\n if (\n Object.prototype.hasOwnProperty.call(value, OBSERVE_NAME)\n && value[OBSERVE_NAME] instanceof Observer\n ) {\n observer = value[OBSERVE_NAME]\n } else if (\n (isArray(value) || isPlainObject(value))\n && Object.isExtensible(value)\n ) {\n observer = new Observer(value)\n }\n return observer\n}\n\n/**\n * Define a reactive property on an Object.\n *\n * @param {Object} object\n * @param {String} key\n * @param {*} value\n */\n\nexport function defineReactive (object, key, value) {\n const dep = new Dep()\n\n const desc = Object.getOwnPropertyDescriptor(object, key)\n if (desc && desc.configurable === false) return\n\n // cater for pre-defined getter/setters\n const getter = desc && desc.get\n const setter = desc && desc.set\n\n let childOb = observe(value)\n\n function reactiveGetter () {\n const currentValue = getter ? getter.call(object) : value\n if (Dep.target) {\n dep.depend()\n if (childOb) {\n childOb.dep.depend()\n }\n if (isArray(currentValue)) {\n for (let i = 0, l = currentValue.length, e; i < l; i++) {\n e = currentValue[i]\n e && e[OBSERVE_NAME] && e[OBSERVE_NAME].dep.depend()\n }\n }\n }\n return currentValue\n }\n function reactiveSetter (newValue) {\n const oldValue = getter ? getter.call(object) : value\n if (newValue === oldValue) return\n if (setter) {\n setter.call(object, newValue)\n } else {\n value = newValue\n }\n childOb = observe(newValue)\n dep.notify()\n }\n defineAccessor(object, key, reactiveGetter, reactiveSetter)\n}\n","import {warn} from './util'\n\n/**\n * Build a getter function. Requires eval.\n *\n * We isolate the try/catch so it doesn't affect the\n * optimization of the parse function when it is not called.\n *\n * @param {String} body\n * @return {Function|undefined}\n */\n\nfunction makeGetterFunction (body) {\n try {\n /* eslint-disable no-new-func */\n return new Function('scope', `return ${body};`)\n /* eslint-enable no-new-func */\n } catch (e) {\n warn('Invalid expression. Generated function body: ' + body)\n }\n}\n\n/**\n * Parse an expression to getter.\n *\n * @param {String} expression\n * @return {Function|undefined}\n */\n\nexport default function parse (expression) {\n expression = String.prototype.trim.call(expression)\n return makeGetterFunction('scope.' + expression)\n}\n","var callbacks = []\nvar pending = false\nfunction nextTickHandler () {\n pending = false\n var callbackCopies = callbacks.slice(0)\n callbacks.length = 0\n for (var i = 0; i < callbackCopies.length; i++) {\n callbackCopies[i]()\n }\n}\n\nvar callNextTick\nif (typeof process === 'object'\n && process\n && typeof process.nextTick === 'function'\n) {\n callNextTick = process.nextTick\n} else if (typeof MutationObserver !== 'undefined') {\n var counter = 0\n var textNode = document.createTextNode(counter)\n var observer = new MutationObserver(nextTickHandler)\n observer.observe(textNode, {\n characterData: true\n })\n callNextTick = function () {\n counter = counter === 0 ? 1 : 0\n textNode.data = String(counter)\n }\n} else {\n callNextTick = setTimeout\n}\n\n\nmodule.exports = function nextTick (callback, context) {\n var func = callback\n if (context) {\n var args = []\n var l = arguments.length\n while (--l > 1) {\n args.unshift(arguments[l])\n }\n func = function () {\n callback.apply(context, args)\n }\n }\n callbacks.push(func)\n if (pending) {\n return\n }\n pending = true\n callNextTick(nextTickHandler)\n}\n","import nextTick from 'smart-next-tick'\n\nlet queue = []\nlet has = {}\nlet waiting = false\nlet queueIndex\n\n/**\n * Reset the batcher's state.\n */\n\nfunction resetBatcherState () {\n queue = []\n has = {}\n waiting = false\n}\n\n/**\n * Flush queue and run the watchers.\n */\n\nfunction flushBatcherQueue () {\n runBatcherQueue(queue)\n resetBatcherState()\n}\n\n/**\n * Run the watchers in a single queue.\n *\n * @param {Array} queue\n */\n\nfunction runBatcherQueue (queue) {\n // do not cache length because more watchers might be pushed\n // as we run existing watchers\n for (queueIndex = 0; queueIndex < queue.length; queueIndex++) {\n const watcher = queue[queueIndex]\n const id = watcher.id\n has[id] = null\n watcher.run()\n }\n}\n\n/**\n * Push a watcher into the watcher queue.\n * Jobs with duplicate IDs will be skipped unless it's\n * pushed when the queue is being flushed.\n *\n * @param {Watcher} watcher\n * properties:\n * - {Number} id\n * - {Function} run\n */\n\nexport default function batch (watcher) {\n const id = watcher.id\n if (has[id] == null) {\n has[id] = queue.length\n queue.push(watcher)\n // queue the flush\n if (!waiting) {\n waiting = true\n nextTick(flushBatcherQueue)\n }\n }\n}\n","import observe from './index'\nimport Dep from './dep'\nimport parseExpression from './expression'\nimport batch from './batcher'\nimport {\n isArray,\n isObject,\n isFunction,\n _Set as Set,\n} from './util'\nimport {WATCHERS_PROPERTY_NAME} from './constants'\n\nlet uid = 0\n\nclass Watcher {\n\n /**\n * A watcher parses an expression, collects dependencies,\n * and fires callback when the expression value changes.\n *\n * @param {Object} owner\n * @param {String|Function} getter\n * @param {Function} callback\n * @param {Object} options\n * - {Boolean} deep\n * - {Boolean} sync\n * - {Boolean} lazy\n * @constructor\n */\n\n constructor (owner, getter, callback, options) {\n owner[WATCHERS_PROPERTY_NAME].push(this)\n this.owner = owner\n this.getter = getter\n this.callback = callback\n this.options = options\n // uid for batching\n this.id = ++uid\n this.active = true\n // for lazy watchers\n this.dirty = options.lazy\n this.deps = []\n this.newDeps = []\n this.depIds = new Set()\n this.newDepIds = new Set()\n this.value = options.lazy\n ? undefined\n : this.get()\n }\n\n /**\n * Evaluate the getter, and re-collect dependencies.\n */\n\n get () {\n this.beforeGet()\n const scope = this.owner\n const value = this.getter.call(scope, scope)\n if (this.options.deep) {\n traverse(value)\n }\n this.afterGet()\n return value\n }\n\n /**\n * Prepare for dependency collection.\n */\n\n beforeGet () {\n Dep.target = this\n }\n\n /**\n * Add a dependency to this directive.\n *\n * @param {Dep} dep\n */\n\n addDep (dep) {\n const id = dep.id\n if (!this.newDepIds.has(id)) {\n this.newDepIds.add(id)\n this.newDeps.push(dep)\n if (!this.depIds.has(id)) {\n dep.addSub(this)\n }\n }\n }\n\n /**\n * Clean up for dependency collection.\n */\n\n afterGet () {\n Dep.target = null\n let i = this.deps.length\n while (i--) {\n const dep = this.deps[i]\n if (!this.newDepIds.has(dep.id)) {\n dep.removeSub(this)\n }\n }\n let tmp = this.depIds\n this.depIds = this.newDepIds\n this.newDepIds = tmp\n this.newDepIds.clear()\n tmp = this.deps\n this.deps = this.newDeps\n this.newDeps = tmp\n this.newDeps.length = 0\n }\n\n /**\n * Will be called when a dependency changes.\n */\n\n update () {\n if (this.options.lazy) {\n this.dirty = true\n } else if (this.options.sync) {\n this.run()\n } else {\n batch(this)\n }\n }\n\n /**\n * Will be called by the batcher.\n */\n\n run () {\n if (this.active) {\n const value = this.get()\n if (\n value !== this.value\n // Deep watchers and watchers on Object/Arrays should fire even when\n // the value is the same, because the value may have mutated;\n || ((isObject(value) || this.options.deep))\n ) {\n const oldValue = this.value\n this.value = value\n this.callback.call(this.owner, value, oldValue)\n }\n }\n }\n\n /**\n * Evaluate the value of the watcher.\n * This only gets called for lazy watchers.\n */\n\n evaluate () {\n // avoid overwriting another watcher that is being collected.\n const current = Dep.target\n this.value = this.get()\n this.dirty = false\n Dep.target = current\n }\n\n /**\n * Depend on all deps collected by this watcher.\n */\n\n depend () {\n let i = this.deps.length\n while (i--) {\n this.deps[i].depend()\n }\n }\n\n /**\n * Remove self from all dependencies' subcriber list.\n */\n\n teardown () {\n if (this.active) {\n let i = this.deps.length\n while (i--) {\n this.deps[i].removeSub(this)\n }\n this.active = false\n this.owner = this.callback = this.value = null\n }\n }\n}\n\n/**\n * Recrusively traverse an object to evoke all converted\n * getters, so that every nested property inside the object\n * is collected as a \"deep\" dependency.\n *\n * @param {*} value\n */\n\nfunction traverse (value) {\n let i, keys\n if (isArray(value)) {\n i = value.length\n while (i--) traverse(value[i])\n } else if (isObject(value)) {\n keys = Object.keys(value)\n i = keys.length\n while (i--) traverse(value[keys[i]])\n }\n}\n\n/**\n * Create an watcher instance, returns the new watcher.\n *\n * @param {Object} owner\n * @param {String|Function} expressionOrFunction\n * @param {Function} callback\n * @param {Object} options\n * - {Boolean} deep\n * - {Boolean} sync\n * - {Boolean} lazy\n * @return {Watcher}\n */\n\nexport function watch (owner, expressionOrFunction, callback, options) {\n // parse expression for getter\n const getter = isFunction(expressionOrFunction)\n ? expressionOrFunction\n : parseExpression(expressionOrFunction)\n return new Watcher(owner, getter, callback, options)\n}\n\n/**\n * Make a computed getter, which can collect dependencies.\n *\n * @param {Object} owner\n * @param {Function} getter\n */\n\nexport function makeComputed (owner, getter) {\n const watcher = new Watcher(owner, getter, null, {\n deep: observe.deep,\n lazy: true,\n sync: observe.sync,\n })\n return function computedGetter () {\n if (watcher.options.lazy && Dep.target && !Dep.target.options.lazy) {\n watcher.options.lazy = false\n watcher.callback = function () {\n const deps = watcher.deps\n for (let i = 0, l = deps.length; i < l; i++) {\n deps[i].notify()\n }\n }\n }\n if (watcher.dirty) {\n watcher.evaluate()\n }\n if (Dep.target) {\n watcher.depend()\n }\n return watcher.value\n }\n}\n","import {\n observe as doObserve,\n defineReactive,\n} from './observe'\nimport {\n watch as doWatch,\n makeComputed,\n} from './watcher'\nimport {\n defineValue,\n defineAccessor,\n noop,\n isFunction,\n everyEntries,\n} from './util'\nimport {\n WATCHERS_PROPERTY_NAME,\n DATA_PROPTERTY_NAME,\n} from './constants'\n\nObject.defineProperties(observe, {\n 'react': {value: react},\n 'compute': {value: compute},\n 'watch': {value: watch},\n 'default': {value: watch, writable: true}, // Only could be react, compute or watch\n 'deep': {value: false, writable: true},\n 'lazy': {value: false, writable: true},\n 'sync': {value: false, writable: true},\n})\n\n/**\n * observe\n *\n * @public\n * @param {Object} target\n * @param {*} [expression]\n * @param {*} [func]\n * @param {*} [options]\n * @return {Function} observe\n */\n\nexport default function observe (target, expression, func, options) {\n if (!target.hasOwnProperty(WATCHERS_PROPERTY_NAME)) {\n init(target)\n }\n return observe.default(target, expression, func, options)\n}\n\n/**\n * React options\n *\n * @param {Object} options\n * @param {Object} [target]\n * @return {Function} observe\n */\n\nfunction react (options, target) {\n if (target) {\n if (!target.hasOwnProperty(WATCHERS_PROPERTY_NAME)) {\n init(target)\n }\n } else {\n target = {}\n init(target)\n }\n options.methods && carryMethods(target, options.methods)\n options.data && reactProperties(target, options.data)\n options.computed && computeProperties(target, options.computed)\n options.watchers && watchProperties(target, options.watchers)\n return target\n}\n\n/**\n * Compute property\n *\n * @param {Object} target\n * @param {String} name\n * @param {Function|Object} getterOrAccessor\n * - Function getter\n * - Object accessor\n * - Function [get] - getter\n * - Function [set] - setter\n * - Boolean [cache]\n * @param {Boolean} [cache]\n */\n\nfunction compute (target, name, getterOrAccessor, cache) {\n if (!target.hasOwnProperty(WATCHERS_PROPERTY_NAME)) {\n init(target)\n }\n let getter, setter\n if (isFunction(getterOrAccessor)) {\n getter = cache !== false\n ? makeComputed(target, getterOrAccessor)\n : getterOrAccessor.bind(this)\n setter = noop\n } else {\n getter = getterOrAccessor.get\n ? getterOrAccessor.cache !== false || cache !== false\n ? makeComputed(target, getterOrAccessor.get)\n : getterOrAccessor.get.bind(this)\n : noop\n setter = getterOrAccessor.set ? getterOrAccessor.set.bind(this) : noop\n }\n defineAccessor(target, name, getter, setter)\n}\n\n/**\n * Watch property\n *\n * @param {Object} target\n * @param {String|Function} expressionOrFunction\n * @param {Function} callback\n * @param {Object} [options]\n * - {Boolean} deep\n * - {Boolean} sync\n * - {Boolean} lazy\n * @return {Watcher}\n */\n\nfunction watch (target, expressionOrFunction, callback, options = observe) {\n if (!target.hasOwnProperty(WATCHERS_PROPERTY_NAME)) {\n init(target)\n }\n return doWatch(target, expressionOrFunction, callback, options)\n}\n\n/**\n * @param {Object} target\n */\n\nfunction init (target) {\n defineValue(target, WATCHERS_PROPERTY_NAME, [], false)\n defineValue(target, DATA_PROPTERTY_NAME, Object.create(null), false)\n doObserve(target[DATA_PROPTERTY_NAME])\n reactSelfProperties(target)\n}\n\n/**\n * @param {Object} target\n * @param {Object} methods\n */\n\nfunction carryMethods (target, methods) {\n everyEntries(methods, (name, method) => {\n target[name] = method.bind(target)\n })\n}\n\n/**\n * @param {Object} target\n * @param {String} key\n * @param {*} value\n */\n\nfunction reactProperty (target, key, value) {\n target[DATA_PROPTERTY_NAME][key] = value\n defineReactive(target[DATA_PROPTERTY_NAME], key, value)\n proxy(target, key)\n}\n\n/**\n * @param {Object} target\n * @param {Object} properties\n */\n\nfunction reactProperties (target, properties) {\n everyEntries(properties, (key, value) => reactProperty(target, key, value))\n}\n\n/**\n * @param {Object} target\n */\n\nfunction reactSelfProperties (target) {\n everyEntries(target, (key, value) => {\n !isFunction(value) && reactProperty(target, key, value)\n })\n}\n\n/**\n * @param {Object} target\n * @param {Object} properties\n */\n\nfunction computeProperties (target, properties) {\n everyEntries(properties, (key, value) => compute(target, key, value))\n}\n\n/**\n * @param {Object} target\n * @param {Object} properties\n */\n\nfunction watchProperties (target, properties) {\n everyEntries(properties, (expression, functionOrOption) => {\n if (isFunction(functionOrOption)) {\n watch(target, expression, functionOrOption)\n } else {\n watch(target, expression, functionOrOption.watcher, functionOrOption)\n }\n })\n}\n\n/**\n * @param {Object} target\n * @param {String} key\n */\n\nfunction proxy (target, key) {\n function getter () {\n return target[DATA_PROPTERTY_NAME][key]\n }\n function setter (value) {\n target[DATA_PROPTERTY_NAME][key] = value\n }\n defineAccessor(target, key, getter, setter)\n}\n","let uid = 0\n\n/**\n * A dep is an observable that can have multiple\n * watcher subscribing to it.\n */\n\nexport default class Dep {\n // the current target watcher being evaluated.\n // this is globally unique because there could be only one\n // watcher being evaluated at any time.\n static target = null\n\n constructor () {\n this.id = uid++\n this.subs = []\n }\n\n /**\n * Add a subscriber.\n *\n * @param {Watcher} sub\n */\n\n addSub (sub) {\n this.subs.push(sub)\n }\n\n /**\n * Remove a subscriber.\n *\n * @param {Watcher} sub\n */\n\n removeSub (sub) {\n this.subs.$remove(sub)\n }\n\n /**\n * Add self as a dependency to the target watcher.\n */\n\n depend () {\n Dep.target.addDep(this)\n }\n\n /**\n * Notify all subscribers of a new value.\n */\n\n notify () {\n const subs = this.subs\n for (let i = 0, l = subs.length; i < l; i++) {\n subs[i].update()\n }\n }\n}\n","export const OBSERVE_NAME = '__s_o__'\nexport const WATCHERS_PROPERTY_NAME = '__watchers__'\nexport const DATA_PROPTERTY_NAME = '__data__'\n\nexport const DEBUGGING = typeof process !== 'undefined'\n && process.env.NODE_ENV !== 'production'\n"],"names":["defineValue","object","property","value","enumerable","defineProperty","defineAccessor","getter","setter","isPlainObject","toString","call","OBJECT_STRING","isObject","isFunction","func","everyEntries","callback","keys","Object","i","l","length","noop","amend","array","setPrototypeOf","arrayMethods","$set","index","this","Number","splice","$remove","item","indexOf","observe","observer","prototype","hasOwnProperty","OBSERVE_NAME","Observer","isArray","isExtensible","defineReactive","key","reactiveGetter","currentValue","Dep","target","depend","childOb","dep","e","reactiveSetter","newValue","oldValue","notify","desc","getOwnPropertyDescriptor","configurable","get","set","makeGetterFunction","body","Function","parse","expression","String","trim","nextTickHandler","callbackCopies","callbacks","slice","resetBatcherState","flushBatcherQueue","queue","runBatcherQueue","queueIndex","watcher","id","run","batch","has","push","waiting","traverse","watch","owner","expressionOrFunction","options","parseExpression","Watcher","makeComputed","deep","sync","lazy","deps","dirty","evaluate","WATCHERS_PROPERTY_NAME","default","react","methods","carryMethods","data","reactProperties","computed","computeProperties","watchers","watchProperties","compute","name","getterOrAccessor","cache","bind","doWatch","init","DATA_PROPTERTY_NAME","create","method","reactProperty","properties","reactSelfProperties","functionOrOption","proxy","uid","subs","sub","addDep","update","DEBUGGING","process","env","NODE_ENV","Array","warn","undefined","console","_Set","Set","match","add","clear","arrayPrototype","arrayMutativeMethods","original","args","result","apply","inserted","observeArray","callNextTick","walk","_this","convert","items","pending","nextTick","MutationObserver","counter","textNode","document","createTextNode","setTimeout","context","arguments","unshift","active","newDeps","depIds","newDepIds","beforeGet","scope","afterGet","addSub","removeSub","tmp","current","defineProperties","writable"],"mappings":"4LAWA,SAAgBA,GAAaC,EAAQC,EAAUC,EAAOC,UAC7CC,eAAeJ,EAAQC,wBAEdE,YACJ,gBACI,IAalB,QAAgBE,GAAgBL,EAAQC,EAAUK,EAAQC,UACjDH,eAAeJ,EAAQC,OACvBK,MACAC,cACO,gBACE,IAsBlB,QAAgBC,GAAeR,SACtBS,GAASC,KAAKV,KAAYW,EAYnC,QAAgBC,GAAUZ,SACN,QAAXA,GAAqC,+BAAXA,iBAAAA,IAUnC,QAAgBa,GAAYC,SACH,kBAATA,GAUhB,QAAgBC,GAAcf,EAAQgB,OAE/B,GADCC,GAAOC,OAAOD,KAAKjB,GAChBmB,EAAI,EAAGC,EAAIH,EAAKI,OAAQF,EAAIC,EAAGD,MAC7BF,EAAKE,GAAInB,EAAOiB,EAAKE,KAQlC,QAAgBG,MCjFhB,QAAwBC,GAAOC,UACtBC,eAAeD,EAAOE,GA4C/B,QAASC,GAAMC,EAAO1B,SAChB0B,IAASC,KAAKR,cACXA,OAASS,OAAOF,GAAS,GAEzBC,KAAKE,OAAOH,EAAO,EAAG1B,GAAO,GAYtC,QAAS8B,GAASC,MACXJ,KAAKR,WACJO,GAAQC,KAAKK,QAAQD,SACvBL,IAAQ,EACHC,KAAKE,OAAOH,EAAO,WCN9B,QAAgBO,GAASjC,MAClBA,GAA0B,+BAAVA,iBAAAA,QACjBkC,gBAEFlB,QAAOmB,UAAUC,eAAe5B,KAAKR,EAAOqC,IACzCrC,EAAMqC,YAAyBC,MAEvBtC,EAAMqC,IAEhBE,EAAQvC,IAAUM,EAAcN,KAC9BgB,OAAOw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E,KAAK3E,OACXF,UACA6E,KAAK7E,GAAG8B,+CASXpB,KAAK0I,OAAQ,QACXpJ,GAAIU,KAAKmE,KAAK3E,OACXF,UACA6E,KAAK7E,GAAG4J,UAAUlJ,WAEpB0I,QAAS,OACThF,MAAQ1D,KAAKb,SAAWa,KAAK3B,MAAQ,qBClKhDgB,QAAOgK,iBAAiB/I,UACZjC,MAAOmG,YACLnG,MAAO4G,UACT5G,MAAOoF,YACLpF,MAAOoF,EAAO6F,UAAU,SAC3BjL,OAAO,EAAOiL,UAAU,SACxBjL,OAAO,EAAOiL,UAAU,SACxBjL,OAAO,EAAOiL,UAAU"} \ No newline at end of file +{"version":3,"file":"smart-observe.min.js","sources":["../src/util.js","../src/array.js","../src/observe.js","../src/expression.js","../node_modules/smart-next-tick/nextTick.js","../src/batcher.js","../src/watcher.js","../src/index.js","../src/dep.js","../src/constants.js"],"sourcesContent":["import {DEBUGGING} from './constants'\n\n/**\n * Define property with value.\n *\n * @param {Object} object\n * @param {String} property\n * @param {*} value\n * @param {Boolean} [enumerable]\n */\n\nexport function defineValue (object, property, value, enumerable) {\n Object.defineProperty(object, property, {\n value,\n enumerable: !!enumerable,\n writable: true,\n configurable: true,\n })\n}\n\n/**\n * Define property with getter and setter.\n *\n * @param {Object} object\n * @param {String} property\n * @param {Function} getter\n * @param {Function} setter\n */\n\nexport function defineAccessor (object, property, getter, setter) {\n Object.defineProperty(object, property, {\n get: getter,\n set: setter,\n enumerable: true,\n configurable: true,\n })\n}\n\n/**\n * Array type check.\n *\n * @return {Boolean}\n */\n\nexport const isArray = Array.isArray\n\n/**\n * Strict object type check. Only returns true\n * for plain JavaScript objects.\n *\n * @param {*} object\n * @return {Boolean}\n */\n\nconst toString = Object.prototype.toString\nconst OBJECT_STRING = '[object Object]'\nexport function isPlainObject (object) {\n return toString.call(object) === OBJECT_STRING\n}\n\n/**\n * Quick object check - this is primarily used to tell\n * Objects from primitive values when we know the value\n * is a JSON-compliant type.\n *\n * @param {*} object\n * @return {Boolean}\n */\n\nexport function isObject (object) {\n return object !== null && typeof object === 'object'\n}\n\n/**\n * Function type check\n *\n * @param {*} func\n * @param {Boolean}\n */\n\nexport function isFunction (func) {\n return typeof func === 'function'\n}\n\n/**\n * Iterate object\n *\n * @param {Object} object\n * @param {Function} callback\n */\n\nexport function everyEntries (object, callback) {\n const keys = Object.keys(object)\n for (let i = 0, l = keys.length; i < l; i++) {\n callback(keys[i], object[keys[i]])\n }\n}\n\n/**\n * noop is function which is nothing to do.\n */\n\nexport function noop () {}\n\n/**\n * @param {String} string\n */\n\nexport const warn = typeof DEBUGGING !== 'undefined' && DEBUGGING\n && typeof console !== 'undefined' && console\n && isFunction(console.warn)\n ? console.warn\n : noop\n\nexport let _Set\nif (typeof Set !== 'undefined' && Set.toString().match(/native code/)) {\n // use native Set when available.\n _Set = Set\n} else {\n // a non-standard Set polyfill that only works with primitive keys.\n _Set = function () {\n this.set = Object.create(null)\n }\n _Set.prototype.has = function (key) {\n return this.set[key] !== undefined\n }\n _Set.prototype.add = function (key) {\n this.set[key] = 1\n }\n _Set.prototype.clear = function () {\n this.set = Object.create(null)\n }\n}\n","import {defineValue} from './util'\nimport {OBSERVE_NAME} from './constants'\n\nconst arrayPrototype = Array.prototype\nconst arrayMethods = Object.create(arrayPrototype)\nconst arrayMutativeMethods = [\n 'push',\n 'pop',\n 'shift',\n 'unshift',\n 'splice',\n 'sort',\n 'reverse',\n]\n\n/**\n * Augment an target Array with arrayMethods\n *\n * @param {Array} array\n */\n\nexport default function amend (array) {\n Object.setPrototypeOf(array, arrayMethods)\n}\n\n/**\n * Intercept mutating methods and emit events\n */\n\nfor (\n let i = 0, l = arrayMutativeMethods.length, method;\n i < l;\n method = arrayMutativeMethods[++i]\n) {\n // cache original method\n const original = arrayPrototype[method]\n defineValue(arrayMethods, method, function mutator (...args) {\n const result = original.apply(this, args)\n const observer = this[OBSERVE_NAME]\n let inserted\n switch (method) {\n case 'push':\n inserted = args\n break\n case 'unshift':\n inserted = args\n break\n case 'splice':\n inserted = args.slice(2)\n break\n }\n if (inserted) observer.observeArray(inserted)\n observer.dep.notify() // notify change\n return result\n })\n}\n\n/**\n * Swap the element at the given index with a new value\n * and emits corresponding event.\n *\n * @param {Number} index\n * @param {*} value\n * @return {*} - replaced element\n */\n\nfunction $set (index, value) {\n if (index >= this.length) {\n this.length = Number(index) + 1\n }\n return this.splice(index, 1, value)[0]\n}\ndefineValue(arrayPrototype, '$set', $set)\n\n/**\n * Convenience method to remove the element at given index\n * or target element reference.\n *\n * @param {*} item\n * @return {*} - removed element\n */\n\nfunction $remove (item) {\n if (!this.length) return\n const index = this.indexOf(item)\n if (index > -1) {\n return this.splice(index, 1)\n }\n}\ndefineValue(arrayPrototype, '$remove', $remove)\n","import Dep from './dep'\nimport amendArray from './array'\nimport {\n defineValue,\n defineAccessor,\n isArray,\n isPlainObject,\n everyEntries,\n} from './util'\nimport {OBSERVE_NAME} from './constants'\n\n/**\n * Observer class that are attached to each observed\n * object. Once attached, the observer converts target\n * object's property keys into getter/setters that\n * collect dependencies and dispatches updates.\n *\n * @class\n * @param {Array|Object} value\n */\n\nclass Observer {\n constructor (value) {\n this.value = value\n this.dep = new Dep()\n defineValue(value, OBSERVE_NAME, this)\n if (isArray(value)) {\n amendArray(value)\n this.observeArray(value)\n } else {\n this.walk(value)\n }\n }\n\n /**\n * Walk through each property and convert them into\n * getter/setters. This method should only be called when\n * value type is Object.\n *\n * @param {Object} object\n */\n\n walk (object) {\n everyEntries(object, (key, value) => this.convert(key, value))\n }\n\n /**\n * Observe a list of Array items.\n *\n * @param {Array} items\n */\n\n observeArray (items) {\n for (let i = 0, l = items.length; i < l; i++) {\n observe(items[i])\n }\n }\n\n /**\n * Convert a property into getter/setter so we can emit\n * the events when the property is accessed/changed.\n *\n * @param {String} key\n * @param {*} value\n */\n\n convert (key, value) {\n defineReactive(this.value, key, value)\n }\n}\n\n/**\n * Attempt to create an observer instance for a value,\n * returns the new observer if successfully observed,\n * or the existing observer if the value already has one.\n *\n * @param {*} value\n * @return {Observer|undefined}\n */\n\nexport function observe (value) {\n if (!value || typeof value !== 'object') return\n let observer\n if (\n Object.prototype.hasOwnProperty.call(value, OBSERVE_NAME)\n && value[OBSERVE_NAME] instanceof Observer\n ) {\n observer = value[OBSERVE_NAME]\n } else if (\n (isArray(value) || isPlainObject(value))\n && Object.isExtensible(value)\n ) {\n observer = new Observer(value)\n }\n return observer\n}\n\n/**\n * Define a reactive property on an Object.\n *\n * @param {Object} object\n * @param {String} key\n * @param {*} value\n */\n\nexport function defineReactive (object, key, value) {\n const dep = new Dep()\n\n const desc = Object.getOwnPropertyDescriptor(object, key)\n if (desc && desc.configurable === false) return\n\n // cater for pre-defined getter/setters\n const getter = desc && desc.get\n const setter = desc && desc.set\n\n let childOb = observe(value)\n\n function reactiveGetter () {\n const currentValue = getter ? getter.call(object) : value\n if (Dep.target) {\n dep.depend()\n if (childOb) {\n childOb.dep.depend()\n }\n if (isArray(currentValue)) {\n for (let i = 0, l = currentValue.length, e; i < l; i++) {\n e = currentValue[i]\n e && e[OBSERVE_NAME] && e[OBSERVE_NAME].dep.depend()\n }\n }\n }\n return currentValue\n }\n function reactiveSetter (newValue) {\n const oldValue = getter ? getter.call(object) : value\n if (newValue === oldValue) return\n if (setter) {\n setter.call(object, newValue)\n } else {\n value = newValue\n }\n childOb = observe(newValue)\n dep.notify()\n }\n defineAccessor(object, key, reactiveGetter, reactiveSetter)\n}\n","import {warn} from './util'\n\n/**\n * Build a getter function. Requires eval.\n *\n * We isolate the try/catch so it doesn't affect the\n * optimization of the parse function when it is not called.\n *\n * @param {String} body\n * @return {Function|undefined}\n */\n\nfunction makeGetterFunction (body) {\n try {\n /* eslint-disable no-new-func */\n return new Function('scope', `return ${body};`)\n /* eslint-enable no-new-func */\n } catch (e) {\n warn('Invalid expression. Generated function body: ' + body)\n }\n}\n\n/**\n * Parse an expression to getter.\n *\n * @param {String} expression\n * @return {Function|undefined}\n */\n\nexport default function parse (expression) {\n expression = String.prototype.trim.call(expression)\n return makeGetterFunction('scope.' + expression)\n}\n","var callbacks = []\nvar pending = false\nfunction nextTickHandler () {\n pending = false\n var callbackCopies = callbacks.slice(0)\n callbacks.length = 0\n for (var i = 0; i < callbackCopies.length; i++) {\n callbackCopies[i]()\n }\n}\n\nvar callNextTick\nif (typeof process === 'object'\n && process\n && typeof process.nextTick === 'function'\n) {\n callNextTick = process.nextTick\n} else if (typeof MutationObserver !== 'undefined') {\n var counter = 0\n var textNode = document.createTextNode(counter)\n var observer = new MutationObserver(nextTickHandler)\n observer.observe(textNode, {\n characterData: true\n })\n callNextTick = function () {\n counter = counter === 0 ? 1 : 0\n textNode.data = String(counter)\n }\n} else {\n callNextTick = setTimeout\n}\n\n\nmodule.exports = function nextTick (callback, context) {\n var func = callback\n if (context) {\n var args = []\n var l = arguments.length\n while (--l > 1) {\n args.unshift(arguments[l])\n }\n func = function () {\n callback.apply(context, args)\n }\n }\n callbacks.push(func)\n if (pending) {\n return\n }\n pending = true\n callNextTick(nextTickHandler)\n}\n","import nextTick from 'smart-next-tick'\n\nlet queue = []\nlet has = {}\nlet waiting = false\nlet queueIndex\n\n/**\n * Reset the batcher's state.\n */\n\nfunction resetBatcherState () {\n queue = []\n has = {}\n waiting = false\n}\n\n/**\n * Flush queue and run the watchers.\n */\n\nfunction flushBatcherQueue () {\n runBatcherQueue(queue)\n resetBatcherState()\n}\n\n/**\n * Run the watchers in a single queue.\n *\n * @param {Array} queue\n */\n\nfunction runBatcherQueue (queue) {\n // do not cache length because more watchers might be pushed\n // as we run existing watchers\n for (queueIndex = 0; queueIndex < queue.length; queueIndex++) {\n const watcher = queue[queueIndex]\n const id = watcher.id\n has[id] = null\n watcher.run()\n }\n}\n\n/**\n * Push a watcher into the watcher queue.\n * Jobs with duplicate IDs will be skipped unless it's\n * pushed when the queue is being flushed.\n *\n * @param {Watcher} watcher\n * properties:\n * - {Number} id\n * - {Function} run\n */\n\nexport default function batch (watcher) {\n const id = watcher.id\n if (has[id] == null) {\n has[id] = queue.length\n queue.push(watcher)\n // queue the flush\n if (!waiting) {\n waiting = true\n nextTick(flushBatcherQueue)\n }\n }\n}\n","import observe from './index'\nimport Dep from './dep'\nimport parseExpression from './expression'\nimport batch from './batcher'\nimport {\n isArray,\n isObject,\n isFunction,\n _Set as Set,\n} from './util'\nimport {WATCHERS_PROPERTY_NAME} from './constants'\n\nlet uid = 0\n\nclass Watcher {\n\n /**\n * A watcher parses an expression, collects dependencies,\n * and fires callback when the expression value changes.\n *\n * @param {Object} owner\n * @param {String|Function} getter\n * @param {Function} callback\n * @param {Object} options\n * - {Boolean} deep\n * - {Boolean} sync\n * - {Boolean} lazy\n * @constructor\n */\n\n constructor (owner, getter, callback, options) {\n owner[WATCHERS_PROPERTY_NAME].push(this)\n this.owner = owner\n this.getter = getter\n this.callback = callback\n this.options = options\n // uid for batching\n this.id = ++uid\n this.active = true\n // for lazy watchers\n this.dirty = options.lazy\n this.deps = []\n this.newDeps = []\n this.depIds = new Set()\n this.newDepIds = new Set()\n this.value = options.lazy\n ? undefined\n : this.get()\n }\n\n /**\n * Evaluate the getter, and re-collect dependencies.\n */\n\n get () {\n this.beforeGet()\n const scope = this.owner\n const value = this.getter.call(scope, scope)\n if (this.options.deep) {\n traverse(value)\n }\n this.afterGet()\n return value\n }\n\n /**\n * Prepare for dependency collection.\n */\n\n beforeGet () {\n Dep.target = this\n }\n\n /**\n * Add a dependency to this directive.\n *\n * @param {Dep} dep\n */\n\n addDep (dep) {\n const id = dep.id\n if (!this.newDepIds.has(id)) {\n this.newDepIds.add(id)\n this.newDeps.push(dep)\n if (!this.depIds.has(id)) {\n dep.addSub(this)\n }\n }\n }\n\n /**\n * Clean up for dependency collection.\n */\n\n afterGet () {\n Dep.target = null\n let i = this.deps.length\n while (i--) {\n const dep = this.deps[i]\n if (!this.newDepIds.has(dep.id)) {\n dep.removeSub(this)\n }\n }\n let tmp = this.depIds\n this.depIds = this.newDepIds\n this.newDepIds = tmp\n this.newDepIds.clear()\n tmp = this.deps\n this.deps = this.newDeps\n this.newDeps = tmp\n this.newDeps.length = 0\n }\n\n /**\n * Will be called when a dependency changes.\n */\n\n update () {\n if (this.options.lazy) {\n this.dirty = true\n } else if (this.options.sync) {\n this.run()\n } else {\n batch(this)\n }\n }\n\n /**\n * Will be called by the batcher.\n */\n\n run () {\n if (this.active) {\n const value = this.get()\n if (\n value !== this.value\n // Deep watchers and watchers on Object/Arrays should fire even when\n // the value is the same, because the value may have mutated;\n || ((isObject(value) || this.options.deep))\n ) {\n const oldValue = this.value\n this.value = value\n this.callback.call(this.owner, value, oldValue)\n }\n }\n }\n\n /**\n * Evaluate the value of the watcher.\n * This only gets called for lazy watchers.\n */\n\n evaluate () {\n // avoid overwriting another watcher that is being collected.\n const current = Dep.target\n this.value = this.get()\n this.dirty = false\n Dep.target = current\n }\n\n /**\n * Depend on all deps collected by this watcher.\n */\n\n depend () {\n let i = this.deps.length\n while (i--) {\n this.deps[i].depend()\n }\n }\n\n /**\n * Remove self from all dependencies' subcriber list.\n */\n\n teardown () {\n if (this.active) {\n let i = this.deps.length\n while (i--) {\n this.deps[i].removeSub(this)\n }\n this.active = false\n this.owner = this.callback = this.value = null\n }\n }\n}\n\n/**\n * Recrusively traverse an object to evoke all converted\n * getters, so that every nested property inside the object\n * is collected as a \"deep\" dependency.\n *\n * @param {*} value\n */\n\nfunction traverse (value) {\n let i, keys\n if (isArray(value)) {\n i = value.length\n while (i--) traverse(value[i])\n } else if (isObject(value)) {\n keys = Object.keys(value)\n i = keys.length\n while (i--) traverse(value[keys[i]])\n }\n}\n\n/**\n * Create an watcher instance, returns the new watcher.\n *\n * @param {Object} owner\n * @param {String|Function} expressionOrFunction\n * @param {Function} callback\n * @param {Object} options\n * - {Boolean} deep\n * - {Boolean} sync\n * - {Boolean} lazy\n * @return {Watcher}\n */\n\nexport function watch (owner, expressionOrFunction, callback, options) {\n // parse expression for getter\n const getter = isFunction(expressionOrFunction)\n ? expressionOrFunction\n : parseExpression(expressionOrFunction)\n return new Watcher(owner, getter, callback, options)\n}\n\n/**\n * Make a computed getter, which can collect dependencies.\n *\n * @param {Object} owner\n * @param {Function} getter\n */\n\nexport function makeComputed (owner, getter) {\n const watcher = new Watcher(owner, getter, null, {\n deep: observe.deep,\n lazy: true,\n sync: observe.sync,\n })\n return function computedGetter () {\n if (watcher.options.lazy && Dep.target && !Dep.target.options.lazy) {\n watcher.options.lazy = false\n watcher.callback = function () {\n const deps = watcher.deps\n for (let i = 0, l = deps.length; i < l; i++) {\n deps[i].notify()\n }\n }\n }\n if (watcher.dirty) {\n watcher.evaluate()\n }\n if (Dep.target) {\n watcher.depend()\n }\n return watcher.value\n }\n}\n","import {\n observe as doObserve,\n defineReactive,\n} from './observe'\nimport {\n watch as doWatch,\n makeComputed,\n} from './watcher'\nimport {\n defineValue,\n defineAccessor,\n noop,\n isFunction,\n everyEntries,\n} from './util'\nimport {\n WATCHERS_PROPERTY_NAME,\n DATA_PROPTERTY_NAME,\n} from './constants'\n\nObject.defineProperties(observe, {\n 'react': {value: react},\n 'compute': {value: compute},\n 'watch': {value: watch},\n 'default': {value: watch, writable: true}, // Only could be react, compute or watch\n 'deep': {value: false, writable: true},\n 'lazy': {value: false, writable: true},\n 'sync': {value: false, writable: true},\n})\n\n/**\n * observe\n *\n * @public\n * @param {Object} target\n * @param {*} [expression]\n * @param {*} [func]\n * @param {*} [options]\n * @return {Function} observe\n */\n\nexport default function observe (target, expression, func, options) {\n ensure(target)\n return observe.default(target, expression, func, options)\n}\n\n/**\n * React options\n *\n * @param {Object} options\n * @param {Object} [target]\n * @return {Function} observe\n */\n\nfunction react (options, target) {\n if (target) {\n ensure(target)\n } else {\n target = {}\n init(target)\n }\n options.methods && carryMethods(target, options.methods)\n options.data && reactProperties(target, options.data)\n options.computed && computeProperties(target, options.computed)\n options.watchers && watchProperties(target, options.watchers)\n return target\n}\n\n/**\n * Compute property\n *\n * @param {Object} target\n * @param {String} name\n * @param {Function|Object} getterOrAccessor\n * - Function getter\n * - Object accessor\n * - Function [get] - getter\n * - Function [set] - setter\n * - Boolean [cache]\n * @param {Boolean} [cache]\n */\n\nfunction compute (target, name, getterOrAccessor, cache) {\n ensure(target)\n let getter, setter\n if (isFunction(getterOrAccessor)) {\n getter = cache !== false\n ? makeComputed(target, getterOrAccessor)\n : getterOrAccessor.bind(this)\n setter = noop\n } else {\n getter = getterOrAccessor.get\n ? getterOrAccessor.cache !== false || cache !== false\n ? makeComputed(target, getterOrAccessor.get)\n : getterOrAccessor.get.bind(this)\n : noop\n setter = getterOrAccessor.set ? getterOrAccessor.set.bind(this) : noop\n }\n defineAccessor(target, name, getter, setter)\n}\n\n/**\n * Watch property\n *\n * @param {Object} target\n * @param {String|Function} expressionOrFunction\n * @param {Function} callback\n * @param {Object} [options]\n * - {Boolean} deep\n * - {Boolean} sync\n * - {Boolean} lazy\n * @return {Watcher}\n */\n\nfunction watch (target, expressionOrFunction, callback, options = observe) {\n ensure(target)\n return doWatch(target, expressionOrFunction, callback, options)\n}\n\n/**\n * @param {Object} target\n */\n\nfunction init (target) {\n defineValue(target, WATCHERS_PROPERTY_NAME, [], false)\n defineValue(target, DATA_PROPTERTY_NAME, Object.create(null), false)\n doObserve(target[DATA_PROPTERTY_NAME])\n reactSelfProperties(target)\n}\n\nfunction ensure (target) {\n if (!Object.prototype.hasOwnProperty.call(target, WATCHERS_PROPERTY_NAME)) {\n init(target)\n }\n}\n\n/**\n * @param {Object} target\n * @param {Object} methods\n */\n\nfunction carryMethods (target, methods) {\n everyEntries(methods, (name, method) => {\n target[name] = method.bind(target)\n })\n}\n\n/**\n * @param {Object} target\n * @param {String} key\n * @param {*} value\n */\n\nfunction reactProperty (target, key, value) {\n target[DATA_PROPTERTY_NAME][key] = value\n defineReactive(target[DATA_PROPTERTY_NAME], key, value)\n proxy(target, key)\n}\n\n/**\n * @param {Object} target\n * @param {Object} properties\n */\n\nfunction reactProperties (target, properties) {\n everyEntries(properties, (key, value) => reactProperty(target, key, value))\n}\n\n/**\n * @param {Object} target\n */\n\nfunction reactSelfProperties (target) {\n everyEntries(target, (key, value) => {\n !isFunction(value) && reactProperty(target, key, value)\n })\n}\n\n/**\n * @param {Object} target\n * @param {Object} properties\n */\n\nfunction computeProperties (target, properties) {\n everyEntries(properties, (key, value) => compute(target, key, value))\n}\n\n/**\n * @param {Object} target\n * @param {Object} properties\n */\n\nfunction watchProperties (target, properties) {\n everyEntries(properties, (expression, functionOrOption) => {\n if (isFunction(functionOrOption)) {\n watch(target, expression, functionOrOption)\n } else {\n watch(target, expression, functionOrOption.watcher, functionOrOption)\n }\n })\n}\n\n/**\n * @param {Object} target\n * @param {String} key\n */\n\nfunction proxy (target, key) {\n function getter () {\n return target[DATA_PROPTERTY_NAME][key]\n }\n function setter (value) {\n target[DATA_PROPTERTY_NAME][key] = value\n }\n defineAccessor(target, key, getter, setter)\n}\n","let uid = 0\n\n/**\n * A dep is an observable that can have multiple\n * watcher subscribing to it.\n */\n\nexport default class Dep {\n // the current target watcher being evaluated.\n // this is globally unique because there could be only one\n // watcher being evaluated at any time.\n static target = null\n\n constructor () {\n this.id = uid++\n this.subs = []\n }\n\n /**\n * Add a subscriber.\n *\n * @param {Watcher} sub\n */\n\n addSub (sub) {\n this.subs.push(sub)\n }\n\n /**\n * Remove a subscriber.\n *\n * @param {Watcher} sub\n */\n\n removeSub (sub) {\n this.subs.$remove(sub)\n }\n\n /**\n * Add self as a dependency to the target watcher.\n */\n\n depend () {\n Dep.target.addDep(this)\n }\n\n /**\n * Notify all subscribers of a new value.\n */\n\n notify () {\n const subs = this.subs\n for (let i = 0, l = subs.length; i < l; i++) {\n subs[i].update()\n }\n }\n}\n","export const OBSERVE_NAME = '__s_o__'\nexport const WATCHERS_PROPERTY_NAME = '__watchers__'\nexport const DATA_PROPTERTY_NAME = '__data__'\n\nexport const DEBUGGING = typeof process !== 'undefined'\n && process.env.NODE_ENV !== 'production'\n"],"names":["defineValue","object","property","value","enumerable","defineProperty","defineAccessor","getter","setter","isPlainObject","toString","call","OBJECT_STRING","isObject","isFunction","func","everyEntries","callback","keys","Object","i","l","length","noop","amend","array","setPrototypeOf","arrayMethods","$set","index","this","Number","splice","$remove","item","indexOf","observe","observer","prototype","hasOwnProperty","OBSERVE_NAME","Observer","isArray","isExtensible","defineReactive","key","reactiveGetter","currentValue","Dep","target","depend","childOb","dep","e","reactiveSetter","newValue","oldValue","notify","desc","getOwnPropertyDescriptor","configurable","get","set","makeGetterFunction","body","Function","parse","expression","String","trim","nextTickHandler","callbackCopies","callbacks","slice","resetBatcherState","flushBatcherQueue","queue","runBatcherQueue","queueIndex","watcher","id","run","batch","has","push","waiting","traverse","watch","owner","expressionOrFunction","options","parseExpression","Watcher","makeComputed","deep","sync","lazy","deps","dirty","evaluate","default","react","methods","carryMethods","data","reactProperties","computed","computeProperties","watchers","watchProperties","compute","name","getterOrAccessor","cache","bind","doWatch","init","WATCHERS_PROPERTY_NAME","DATA_PROPTERTY_NAME","create","ensure","method","reactProperty","properties","reactSelfProperties","functionOrOption","proxy","uid","subs","sub","addDep","update","DEBUGGING","process","env","NODE_ENV","Array","warn","console","_Set","Set","match","undefined","add","clear","arrayPrototype","arrayMutativeMethods","original","args","result","apply","inserted","observeArray","callNextTick","walk","_this","convert","items","pending","nextTick","MutationObserver","counter","textNode","document","createTextNode","setTimeout","context","arguments","unshift","active","newDeps","depIds","newDepIds","beforeGet","scope","afterGet","addSub","removeSub","tmp","current","defineProperties","writable"],"mappings":"4LAWA,SAAgBA,GAAaC,EAAQC,EAAUC,EAAOC,UAC7CC,eAAeJ,EAAQC,wBAEdE,YACJ,gBACI,IAalB,QAAgBE,GAAgBL,EAAQC,EAAUK,EAAQC,UACjDH,eAAeJ,EAAQC,OACvBK,MACAC,cACO,gBACE,IAsBlB,QAAgBC,GAAeR,SACtBS,GAASC,KAAKV,KAAYW,EAYnC,QAAgBC,GAAUZ,SACN,QAAXA,GAAqC,+BAAXA,iBAAAA,IAUnC,QAAgBa,GAAYC,SACH,kBAATA,GAUhB,QAAgBC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,EACjBU,MAAK8I,UAAUzF,IAAI/B,EAAI4B,OACtBiG,UAAUnJ,SAGdoJ,GAAMpJ,KAAK6I,YACVA,OAAS7I,KAAK8I,eACdA,UAAYM,OACZN,UAAU5B,UACTlH,KAAKmE,UACNA,KAAOnE,KAAK4I,aACZA,QAAUQ,OACVR,QAAQpJ,OAAS,mCAQlBQ,KAAK4D,QAAQM,UACVE,OAAQ,EACJpE,KAAK4D,QAAQK,UACjBd,QAECnD,uCASJA,KAAK2I,OAAQ,IACTtK,GAAQ2B,KAAK+B,SAEjB1D,IAAU2B,KAAK3B,OAGVU,EAASV,IAAU2B,KAAK4D,QAAQI,KACrC,IACMtC,GAAW1B,KAAK3B,WACjBA,MAAQA,OACRc,SAASN,KAAKmB,KAAK0D,MAAOrF,EAAOqD,2CAYpC2H,GAAUnI,EAAIC,YACf9C,MAAQ2B,KAAK+B,WACbqC,OAAQ,IACTjD,OAASkI,0CAQT/J,GAAIU,KAAKmE,KAAK3E,OACXF,UACA6E,KAAK7E,GAAG8B,+CASXpB,KAAK2I,OAAQ,QACXrJ,GAAIU,KAAKmE,KAAK3E,OACXF,UACA6E,KAAK7E,GAAG6J,UAAUnJ,WAEpB2I,QAAS,OACTjF,MAAQ1D,KAAKb,SAAWa,KAAK3B,MAAQ,qBClKhDgB,QAAOiK,iBAAiBhJ,UACZjC,MAAOkG,YACLlG,MAAO2G,UACT3G,MAAOoF,YACLpF,MAAOoF,EAAO8F,UAAU,SAC3BlL,OAAO,EAAOkL,UAAU,SACxBlL,OAAO,EAAOkL,UAAU,SACxBlL,OAAO,EAAOkL,UAAU"} \ No newline at end of file diff --git a/package.json b/package.json index 33edfc9..9768693 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "smart-observe", - "version": "1.0.1", + "version": "1.0.2", "description": "smart-observe comes from Vue.js and is a small, efficient library for observing changes of javascript Object, Array and Class.", "main": "dist/smart-observe.js", "scripts": {