diff --git a/packages/omi/examples/store/b.js b/packages/omi/examples/store/b.js index 25b7f7524..70861d4c6 100644 --- a/packages/omi/examples/store/b.js +++ b/packages/omi/examples/store/b.js @@ -1,1439 +1,1575 @@ (function () { - 'use strict'; - - /** Virtual DOM Node */ - function VNode() {} - - function getGlobal() { - if (typeof global !== 'object' || !global || global.Math !== Math || global.Array !== Array) { - if (typeof self !== 'undefined') { - return self; - } else if (typeof window !== 'undefined') { - return window; - } else if (typeof global !== 'undefined') { - return global; - } - return function () { - return this; - }(); - } - return global; - } - - /** Global options - * @public - * @namespace options {Object} - */ - var options = { - - store: null, - - root: getGlobal() - //componentChange(component, element) { }, - /** If `true`, `prop` changes trigger synchronous component updates. - * @name syncComponentUpdates - * @type Boolean - * @default true - */ - //syncComponentUpdates: true, - - /** Processes all created VNodes. - * @param {VNode} vnode A newly-created VNode to normalize/process - */ - //vnode(vnode) { } - - /** Hook invoked after a component is mounted. */ - //afterMount(component) { }, - - /** Hook invoked after the DOM is updated with a component's latest render. */ - //afterUpdate(component) { } - - /** Hook invoked immediately before a component is unmounted. */ - // beforeUnmount(component) { } - }; - - var stack = []; - var EMPTY_CHILDREN = []; - - function h(nodeName, attributes) { - var children = EMPTY_CHILDREN, - lastSimple = void 0, - child = void 0, - simple = void 0, - i = void 0; - for (i = arguments.length; i-- > 2;) { - stack.push(arguments[i]); - } - if (attributes && attributes.children != null) { - if (!stack.length) stack.push(attributes.children); - delete attributes.children; - } - while (stack.length) { - if ((child = stack.pop()) && child.pop !== undefined) { - for (i = child.length; i--;) { - stack.push(child[i]); - } - } else { - if (typeof child === 'boolean') child = null; - - if (simple = typeof nodeName !== 'function') { - if (child == null) child = '';else if (typeof child === 'number') child = String(child);else if (typeof child !== 'string') simple = false; - } - - if (simple && lastSimple) { - children[children.length - 1] += child; - } else if (children === EMPTY_CHILDREN) { - children = [child]; - } else { - children.push(child); - } - - lastSimple = simple; - } - } - - var p = new VNode(); - p.nodeName = nodeName; - p.children = children; - p.attributes = attributes == null ? undefined : attributes; - p.key = attributes == null ? undefined : attributes.key; - - // if a "vnode hook" is defined, pass every created VNode to it - if (options.vnode !== undefined) options.vnode(p); - - return p; - } - - /** - * @license - * Copyright (c) 2016 The Polymer Project Authors. All rights reserved. - * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt - * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt - * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt - * Code distributed by Google as part of the polymer project is also - * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt - */ - - /** - * This shim allows elements written in, or compiled to, ES5 to work on native - * implementations of Custom Elements v1. It sets new.target to the value of - * this.constructor so that the native HTMLElement constructor can access the - * current under-construction element's definition. - */ - (function () { - if ( - // No Reflect, no classes, no need for shim because native custom elements - // require ES2015 classes or Reflect. - window.Reflect === undefined || window.customElements === undefined || - // The webcomponentsjs custom elements polyfill doesn't require - // ES2015-compatible construction (`super()` or `Reflect.construct`). - window.customElements.hasOwnProperty('polyfillWrapFlushCallback')) { - return; - } - var BuiltInHTMLElement = HTMLElement; - window.HTMLElement = function HTMLElement() { - return Reflect.construct(BuiltInHTMLElement, [], this.constructor); - }; - HTMLElement.prototype = BuiltInHTMLElement.prototype; - HTMLElement.prototype.constructor = HTMLElement; - Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement); - })(); - - function cssToDom(css) { - var node = document.createElement('style'); - node.innerText = css; - return node; - } - - function npn(str) { - return str.replace(/-(\w)/g, function ($, $1) { - return $1.toUpperCase(); - }); - } - - /** Invoke or update a ref, depending on whether it is a function or object ref. - * @param {object|function} [ref=null] - * @param {any} [value] - */ - function applyRef(ref, value) { - if (ref != null) { - if (typeof ref == 'function') ref(value);else ref.current = value; - } - } - - /** - * Call a function asynchronously, as soon as possible. Makes - * use of HTML Promise to schedule the callback if available, - * otherwise falling back to `setTimeout` (mainly for IE<11). - * @type {(callback: function) => void} - */ - var defer = typeof Promise == 'function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout; - - function isArray(obj) { - return Object.prototype.toString.call(obj) === '[object Array]'; - } - - function nProps(props) { - if (!props || isArray(props)) return {}; - var result = {}; - Object.keys(props).forEach(function (key) { - result[key] = props[key].value; - }); - return result; - } - - // render modes - - var ATTR_KEY = '__preactattr_'; - - // DOM properties that should NOT have "px" added when numeric - var IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i; - - /** - * Check if two nodes are equivalent. - * - * @param {Node} node DOM Node to compare - * @param {VNode} vnode Virtual DOM node to compare - * @param {boolean} [hydrating=false] If true, ignores component constructors when comparing. - * @private - */ - function isSameNodeType(node, vnode, hydrating) { - if (typeof vnode === 'string' || typeof vnode === 'number') { - return node.splitText !== undefined; - } - if (typeof vnode.nodeName === 'string') { - return !node._componentConstructor && isNamedNode(node, vnode.nodeName); - } - return hydrating || node._componentConstructor === vnode.nodeName; - } - - /** - * Check if an Element has a given nodeName, case-insensitively. - * - * @param {Element} node A DOM Element to inspect the name of. - * @param {String} nodeName Unnormalized name to compare against. - */ - function isNamedNode(node, nodeName) { - return node.normalizedNodeName === nodeName || node.nodeName.toLowerCase() === nodeName.toLowerCase(); - } - - /** - * A DOM event listener - * @typedef {(e: Event) => void} EventListner - */ - - /** - * A mapping of event types to event listeners - * @typedef {Object.} EventListenerMap - */ - - /** - * Properties Preact adds to elements it creates - * @typedef PreactElementExtensions - * @property {string} [normalizedNodeName] A normalized node name to use in diffing - * @property {EventListenerMap} [_listeners] A map of event listeners added by components to this DOM node - * @property {import('../component').Component} [_component] The component that rendered this DOM node - * @property {function} [_componentConstructor] The constructor of the component that rendered this DOM node - */ - - /** - * A DOM element that has been extended with Preact properties - * @typedef {Element & ElementCSSInlineStyle & PreactElementExtensions} PreactElement - */ - - /** - * Create an element with the given nodeName. - * @param {string} nodeName The DOM node to create - * @param {boolean} [isSvg=false] If `true`, creates an element within the SVG - * namespace. - * @returns {PreactElement} The created DOM node - */ - function createNode(nodeName, isSvg) { - /** @type {PreactElement} */ - var node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName); - node.normalizedNodeName = nodeName; - return node; - } - - /** - * Remove a child node from its parent if attached. - * @param {Node} node The node to remove - */ - function removeNode(node) { - var parentNode = node.parentNode; - if (parentNode) parentNode.removeChild(node); - } - - /** - * Set a named attribute on the given Node, with special behavior for some names - * and event handlers. If `value` is `null`, the attribute/handler will be - * removed. - * @param {PreactElement} node An element to mutate - * @param {string} name The name/key to set, such as an event or attribute name - * @param {*} old The last value that was set for this name/node pair - * @param {*} value An attribute value, such as a function to be used as an - * event handler - * @param {boolean} isSvg Are we currently diffing inside an svg? - * @private - */ - function setAccessor(node, name, old, value, isSvg) { - if (name === 'className') name = 'class'; - - if (name === 'key') { - // ignore - } else if (name === 'ref') { - applyRef(old, null); - applyRef(value, node); - } else if (name === 'class' && !isSvg) { - node.className = value || ''; - } else if (name === 'style') { - if (!value || typeof value === 'string' || typeof old === 'string') { - node.style.cssText = value || ''; - } - if (value && typeof value === 'object') { - if (typeof old !== 'string') { - for (var i in old) { - if (!(i in value)) node.style[i] = ''; - } - } - for (var _i in value) { - node.style[_i] = typeof value[_i] === 'number' && IS_NON_DIMENSIONAL.test(_i) === false ? value[_i] + 'px' : value[_i]; - } - } - } else if (name === 'dangerouslySetInnerHTML') { - if (value) node.innerHTML = value.__html || ''; - } else if (name[0] == 'o' && name[1] == 'n') { - var useCapture = name !== (name = name.replace(/Capture$/, '')); - name = name.toLowerCase().substring(2); - if (value) { - if (!old) node.addEventListener(name, eventProxy, useCapture); - } else { - node.removeEventListener(name, eventProxy, useCapture); - } - (node._listeners || (node._listeners = {}))[name] = value; - } else if (name !== 'list' && name !== 'type' && !isSvg && name in node) { - // Attempt to set a DOM property to the given value. - // IE & FF throw for certain property-value combinations. - try { - node[name] = value == null ? '' : value; - } catch (e) {} - if ((value == null || value === false) && name != 'spellcheck') node.removeAttribute(name); - } else { - var ns = isSvg && name !== (name = name.replace(/^xlink:?/, '')); - // spellcheck is treated differently than all other boolean values and - // should not be removed when the value is `false`. See: - // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck - if (value == null || value === false) { - if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());else node.removeAttribute(name); - } else if (typeof value === 'string') { - if (ns) { - node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value); - } else { - node.setAttribute(name, value); - } - } - } - } - - /** - * Proxy an event to hooked event handlers - * @param {Event} e The event object from the browser - * @private - */ - function eventProxy(e) { - return this._listeners[e.type](options.event && options.event(e) || e); - } - - /** Diff recursion count, used to track the end of the diff cycle. */ - var diffLevel = 0; - - /** Global flag indicating if the diff is currently within an SVG */ - var isSvgMode = false; - - /** Global flag indicating if the diff is performing hydration */ - var hydrating = false; - - /** Apply differences in a given vnode (and it's deep children) to a real DOM Node. - * @param {Element} [dom=null] A DOM node to mutate into the shape of the `vnode` - * @param {VNode} vnode A VNode (with descendants forming a tree) representing the desired DOM structure - * @returns {Element} dom The created/mutated element - * @private - */ - function diff(dom, vnode, context, mountAll, parent, componentRoot) { - // diffLevel having been 0 here indicates initial entry into the diff (not a subdiff) - if (!diffLevel++) { - // when first starting the diff, check if we're diffing an SVG or within an SVG - isSvgMode = parent != null && parent.ownerSVGElement !== undefined; - - // hydration is indicated by the existing element to be diffed not having a prop cache - hydrating = dom != null && !(ATTR_KEY in dom); - } - - var ret = idiff(dom, vnode, context, mountAll, componentRoot); - - // append the element if its a new parent - if (parent && ret.parentNode !== parent) parent.appendChild(ret); - - // diffLevel being reduced to 0 means we're exiting the diff - if (! --diffLevel) { - hydrating = false; - // invoke queued componentDidMount lifecycle methods - } - - return ret; - } - - /** Internals of `diff()`, separated to allow bypassing diffLevel / mount flushing. */ - function idiff(dom, vnode, context, mountAll, componentRoot) { - var out = dom, - prevSvgMode = isSvgMode; - - // empty values (null, undefined, booleans) render as empty Text nodes - if (vnode == null || typeof vnode === 'boolean') vnode = ''; - - // Fast case: Strings & Numbers create/update Text nodes. - if (typeof vnode === 'string' || typeof vnode === 'number') { - - // update if it's already a Text node: - if (dom && dom.splitText !== undefined && dom.parentNode && (!dom._component || componentRoot)) { - /* istanbul ignore if */ /* Browser quirk that can't be covered: https://github.com/developit/preact/commit/fd4f21f5c45dfd75151bd27b4c217d8003aa5eb9 */ - if (dom.nodeValue != vnode) { - dom.nodeValue = vnode; - } - } else { - // it wasn't a Text node: replace it with one and recycle the old Element - out = document.createTextNode(vnode); - if (dom) { - if (dom.parentNode) dom.parentNode.replaceChild(out, dom); - recollectNodeTree(dom, true); - } - } - - out[ATTR_KEY] = true; - - return out; - } - - // If the VNode represents a Component, perform a component diff: - var vnodeName = vnode.nodeName; - - // Tracks entering and exiting SVG namespace when descending through the tree. - isSvgMode = vnodeName === 'svg' ? true : vnodeName === 'foreignObject' ? false : isSvgMode; - - // If there's no existing element or it's the wrong type, create a new one: - vnodeName = String(vnodeName); - if (!dom || !isNamedNode(dom, vnodeName)) { - out = createNode(vnodeName, isSvgMode); - - if (dom) { - // move children into the replacement node - while (dom.firstChild) { - out.appendChild(dom.firstChild); - } // if the previous Element was mounted into the DOM, replace it inline - if (dom.parentNode) dom.parentNode.replaceChild(out, dom); - - // recycle the old element (skips non-Element node types) - recollectNodeTree(dom, true); - } - } - - var fc = out.firstChild, - props = out[ATTR_KEY], - vchildren = vnode.children; - - if (props == null) { - props = out[ATTR_KEY] = {}; - for (var a = out.attributes, i = a.length; i--;) { - props[a[i].name] = a[i].value; - } - } - - // Optimization: fast-path for elements containing a single TextNode: - if (!hydrating && vchildren && vchildren.length === 1 && typeof vchildren[0] === 'string' && fc != null && fc.splitText !== undefined && fc.nextSibling == null) { - if (fc.nodeValue != vchildren[0]) { - fc.nodeValue = vchildren[0]; - } - } - // otherwise, if there are existing or new children, diff them: - else if (vchildren && vchildren.length || fc != null) { - innerDiffNode(out, vchildren, context, mountAll, hydrating || props.dangerouslySetInnerHTML != null); - } - - // Apply attributes/props from VNode to the DOM Element: - diffAttributes(out, vnode.attributes, props); - - // restore previous SVG mode: (in case we're exiting an SVG namespace) - isSvgMode = prevSvgMode; - - return out; - } - - /** Apply child and attribute changes between a VNode and a DOM Node to the DOM. - * @param {Element} dom Element whose children should be compared & mutated - * @param {Array} vchildren Array of VNodes to compare to `dom.childNodes` - * @param {Object} context Implicitly descendant context object (from most recent `getChildContext()`) - * @param {Boolean} mountAll - * @param {Boolean} isHydrating If `true`, consumes externally created elements similar to hydration - */ - function innerDiffNode(dom, vchildren, context, mountAll, isHydrating) { - var originalChildren = dom.childNodes, - children = [], - keyed = {}, - keyedLen = 0, - min = 0, - len = originalChildren.length, - childrenLen = 0, - vlen = vchildren ? vchildren.length : 0, - j = void 0, - c = void 0, - f = void 0, - vchild = void 0, - child = void 0; - - // Build up a map of keyed children and an Array of unkeyed children: - if (len !== 0) { - for (var i = 0; i < len; i++) { - var _child = originalChildren[i], - props = _child[ATTR_KEY], - key = vlen && props ? _child._component ? _child._component.__key : props.key : null; - if (key != null) { - keyedLen++; - keyed[key] = _child; - } else if (props || (_child.splitText !== undefined ? isHydrating ? _child.nodeValue.trim() : true : isHydrating)) { - children[childrenLen++] = _child; - } - } - } - - if (vlen !== 0) { - for (var _i = 0; _i < vlen; _i++) { - vchild = vchildren[_i]; - child = null; - - // attempt to find a node based on key matching - var _key = vchild.key; - if (_key != null) { - if (keyedLen && keyed[_key] !== undefined) { - child = keyed[_key]; - keyed[_key] = undefined; - keyedLen--; - } - } - // attempt to pluck a node of the same type from the existing children - else if (!child && min < childrenLen) { - for (j = min; j < childrenLen; j++) { - if (children[j] !== undefined && isSameNodeType(c = children[j], vchild, isHydrating)) { - child = c; - children[j] = undefined; - if (j === childrenLen - 1) childrenLen--; - if (j === min) min++; - break; - } - } - } - - // morph the matched/found/created DOM child to match vchild (deep) - child = idiff(child, vchild, context, mountAll); - - f = originalChildren[_i]; - if (child && child !== dom && child !== f) { - if (f == null) { - dom.appendChild(child); - } else if (child === f.nextSibling) { - removeNode(f); - } else { - dom.insertBefore(child, f); - } - } - } - } - - // remove unused keyed children: - if (keyedLen) { - for (var _i2 in keyed) { - if (keyed[_i2] !== undefined) recollectNodeTree(keyed[_i2], false); - } - } - - // remove orphaned unkeyed children: - while (min <= childrenLen) { - if ((child = children[childrenLen--]) !== undefined) recollectNodeTree(child, false); - } - } - - /** Recursively recycle (or just unmount) a node and its descendants. - * @param {Node} node DOM node to start unmount/removal from - * @param {Boolean} [unmountOnly=false] If `true`, only triggers unmount lifecycle, skips removal - */ - function recollectNodeTree(node, unmountOnly) { - - // If the node's VNode had a ref function, invoke it with null here. - // (this is part of the React spec, and smart for unsetting references) - if (node[ATTR_KEY] != null && node[ATTR_KEY].ref) node[ATTR_KEY].ref(null); - - if (unmountOnly === false || node[ATTR_KEY] == null) { - removeNode(node); - } - - removeChildren(node); - } - - /** Recollect/unmount all children. - * - we use .lastChild here because it causes less reflow than .firstChild - * - it's also cheaper than accessing the .childNodes Live NodeList - */ - function removeChildren(node) { - node = node.lastChild; - while (node) { - var next = node.previousSibling; - recollectNodeTree(node, true); - node = next; - } - } - - /** Apply differences in attributes from a VNode to the given DOM Element. - * @param {Element} dom Element with attributes to diff `attrs` against - * @param {Object} attrs The desired end-state key-value attribute pairs - * @param {Object} old Current/previous attributes (from previous VNode or element's prop cache) - */ - function diffAttributes(dom, attrs, old) { - var name = void 0; - var update = false; - var isWeElement = dom.update; - // remove attributes no longer present on the vnode by setting them to undefined - for (name in old) { - if (!(attrs && attrs[name] != null) && old[name] != null) { - setAccessor(dom, name, old[name], old[name] = undefined, isSvgMode); - if (isWeElement) { - delete dom.props[name]; - update = true; - } - } - } - - // add new & update changed attributes - for (name in attrs) { - //diable when using store system? - //!dom.store && - if (isWeElement && typeof attrs[name] === 'object') { - dom.props[npn(name)] = attrs[name]; - update = true; - } else if (name !== 'children' && name !== 'innerHTML' && (!(name in old) || attrs[name] !== (name === 'value' || name === 'checked' ? dom[name] : old[name]))) { - setAccessor(dom, name, old[name], old[name] = attrs[name], isSvgMode); - if (isWeElement) { - dom.props[npn(name)] = attrs[name]; - update = true; - } - } - } - - dom.parentNode && update && isWeElement && dom.update(); - } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var WeElement = function (_HTMLElement) { - _inherits(WeElement, _HTMLElement); - - function WeElement() { - _classCallCheck(this, WeElement); - - var _this = _possibleConstructorReturn(this, _HTMLElement.call(this)); - - _this.props = nProps(_this.constructor.props); - _this.data = _this.constructor.data || {}; - return _this; - } - - WeElement.prototype.connectedCallback = function connectedCallback() { - this.store = options.store; - if (this.store) { - this.store.instances.push(this); - } - this.install(); - - var shadowRoot = this.attachShadow({ mode: 'open' }); - - this.css && shadowRoot.appendChild(cssToDom(this.css())); - this.host = diff(null, this.render(this.props, !this.constructor.pure && this.store ? this.store.data : this.data), {}, false, null, false); - shadowRoot.appendChild(this.host); - - this.installed(); - }; - - WeElement.prototype.disconnectedCallback = function disconnectedCallback() { - this.uninstall(); - if (this.store) { - for (var i = 0, len = this.store.instances.length; i < len; i++) { - if (this.store.instances[i] === this) { - this.store.instances.splice(i, 1); - break; - } - } - } - }; - - WeElement.prototype.update = function update() { - this.beforeUpdate(); - diff(this.host, this.render(this.props, !this.constructor.pure && this.store ? this.store.data : this.data)); - this.afterUpdate(); - }; - - WeElement.prototype.fire = function fire(name, data) { - this.dispatchEvent(new CustomEvent(name, { detail: data })); - }; - - WeElement.prototype.install = function install() {}; - - WeElement.prototype.installed = function installed() {}; - - WeElement.prototype.uninstall = function uninstall() {}; - - WeElement.prototype.beforeUpdate = function beforeUpdate() {}; - - WeElement.prototype.afterUpdate = function afterUpdate() {}; - - return WeElement; - }(HTMLElement); - - /*! - * https://github.com/Palindrom/JSONPatcherProxy - * (c) 2017 Starcounter - * MIT license - */ - - /** Class representing a JS Object observer */ - - var JSONPatcherProxy = function () { - /** - * Deep clones your object and returns a new object. - */ - function deepClone(obj) { - switch (typeof obj) { - case 'object': - return JSON.parse(JSON.stringify(obj)); //Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5 - case 'undefined': - return null; //this is how JSON.stringify behaves for array items - default: - return obj; //no need to clone primitives - } - } - JSONPatcherProxy.deepClone = deepClone; - - function escapePathComponent(str) { - if (str.indexOf('/') == -1 && str.indexOf('~') == -1) return str; - return str.replace(/~/g, '~0').replace(/\//g, '~1'); - } - JSONPatcherProxy.escapePathComponent = escapePathComponent; - - /** - * Walk up the parenthood tree to get the path - * @param {JSONPatcherProxy} instance - * @param {Object} obj the object you need to find its path - */ - function findObjectPath(instance, obj) { - var pathComponents = []; - var parentAndPath = instance.parenthoodMap.get(obj); - while (parentAndPath && parentAndPath.path) { - // because we're walking up-tree, we need to use the array as a stack - pathComponents.unshift(parentAndPath.path); - parentAndPath = instance.parenthoodMap.get(parentAndPath.parent); - } - if (pathComponents.length) { - var path = pathComponents.join('/'); - return '/' + path; - } - return ''; - } - /** - * A callback to be used as th proxy set trap callback. - * It updates parenthood map if needed, proxifies nested newly-added objects, calls default callbacks with the changes occurred. - * @param {JSONPatcherProxy} instance JSONPatcherProxy instance - * @param {Object} target the affected object - * @param {String} key the effect property's name - * @param {Any} newValue the value being set - */ - function setTrap(instance, target, key, newValue) { - var parentPath = findObjectPath(instance, target); - - var destinationPropKey = parentPath + '/' + escapePathComponent(key); - - if (instance.proxifiedObjectsMap.has(newValue)) { - var newValueOriginalObject = instance.proxifiedObjectsMap.get(newValue); - - instance.parenthoodMap.set(newValueOriginalObject.originalObject, { - parent: target, - path: key - }); - } - /* - mark already proxified values as inherited. - rationale: proxy.arr.shift() - will emit - {op: replace, path: '/arr/1', value: arr_2} - {op: remove, path: '/arr/2'} - by default, the second operation would revoke the proxy, and this renders arr revoked. - That's why we need to remember the proxies that are inherited. - */ - var revokableInstance = instance.proxifiedObjectsMap.get(newValue); - /* - Why do we need to check instance.isProxifyingTreeNow? - We need to make sure we mark revokables as inherited ONLY when we're observing, - because throughout the first proxification, a sub-object is proxified and then assigned to - its parent object. This assignment of a pre-proxified object can fool us into thinking - that it's a proxified object moved around, while in fact it's the first assignment ever. - Checking isProxifyingTreeNow ensures this is not happening in the first proxification, - but in fact is is a proxified object moved around the tree - */ - if (revokableInstance && !instance.isProxifyingTreeNow) { - revokableInstance.inherited = true; - } - - // if the new value is an object, make sure to watch it - if (newValue && typeof newValue == 'object' && !instance.proxifiedObjectsMap.has(newValue)) { - instance.parenthoodMap.set(newValue, { - parent: target, - path: key - }); - newValue = instance._proxifyObjectTreeRecursively(target, newValue, key); - } - // let's start with this operation, and may or may not update it later - var operation = { - op: 'remove', - path: destinationPropKey - }; - if (typeof newValue == 'undefined') { - // applying De Morgan's laws would be a tad faster, but less readable - if (!Array.isArray(target) && !target.hasOwnProperty(key)) { - // `undefined` is being set to an already undefined value, keep silent - return Reflect.set(target, key, newValue); - } else { - // when array element is set to `undefined`, should generate replace to `null` - if (Array.isArray(target)) { - // undefined array elements are JSON.stringified to `null` - operation.op = 'replace', operation.value = null; - } - var oldValue = instance.proxifiedObjectsMap.get(target[key]); - // was the deleted a proxified object? - if (oldValue) { - instance.parenthoodMap.delete(target[key]); - instance.disableTrapsForProxy(oldValue); - instance.proxifiedObjectsMap.delete(oldValue); - } - } - } else { - if (Array.isArray(target) && !Number.isInteger(+key.toString())) { - /* array props (as opposed to indices) don't emit any patches, to avoid needless `length` patches */ - if (key != 'length') { - console.warn('JSONPatcherProxy noticed a non-integer prop was set for an array. This will not emit a patch'); - } - return Reflect.set(target, key, newValue); - } - operation.op = 'add'; - if (target.hasOwnProperty(key)) { - if (typeof target[key] !== 'undefined' || Array.isArray(target)) { - operation.op = 'replace'; // setting `undefined` array elements is a `replace` op - } - } - operation.value = newValue; - } - var reflectionResult = Reflect.set(target, key, newValue); - instance.defaultCallback(operation); - return reflectionResult; - } - /** - * A callback to be used as th proxy delete trap callback. - * It updates parenthood map if needed, calls default callbacks with the changes occurred. - * @param {JSONPatcherProxy} instance JSONPatcherProxy instance - * @param {Object} target the effected object - * @param {String} key the effected property's name - */ - function deleteTrap(instance, target, key) { - if (typeof target[key] !== 'undefined') { - var parentPath = findObjectPath(instance, target); - var destinationPropKey = parentPath + '/' + escapePathComponent(key); - - var revokableProxyInstance = instance.proxifiedObjectsMap.get(target[key]); - - if (revokableProxyInstance) { - if (revokableProxyInstance.inherited) { - /* - this is an inherited proxy (an already proxified object that was moved around), - we shouldn't revoke it, because even though it was removed from path1, it is still used in path2. - And we know that because we mark moved proxies with `inherited` flag when we move them - it is a good idea to remove this flag if we come across it here, in deleteProperty trap. - We DO want to revoke the proxy if it was removed again. - */ - revokableProxyInstance.inherited = false; - } else { - instance.parenthoodMap.delete(revokableProxyInstance.originalObject); - instance.disableTrapsForProxy(revokableProxyInstance); - instance.proxifiedObjectsMap.delete(target[key]); - } - } - var reflectionResult = Reflect.deleteProperty(target, key); - - instance.defaultCallback({ - op: 'remove', - path: destinationPropKey - }); - - return reflectionResult; - } - } - /* pre-define resume and pause functions to enhance constructors performance */ - function resume() { - var _this = this; - - this.defaultCallback = function (operation) { - _this.isRecording && _this.patches.push(operation); - _this.userCallback && _this.userCallback(operation); - }; - this.isObserving = true; - } - function pause() { - this.defaultCallback = function () {}; - this.isObserving = false; - } - /** - * Creates an instance of JSONPatcherProxy around your object of interest `root`. - * @param {Object|Array} root - the object you want to wrap - * @param {Boolean} [showDetachedWarning = true] - whether to log a warning when a detached sub-object is modified @see {@link https://github.com/Palindrom/JSONPatcherProxy#detached-objects} - * @returns {JSONPatcherProxy} - * @constructor - */ - function JSONPatcherProxy(root, showDetachedWarning) { - this.isProxifyingTreeNow = false; - this.isObserving = false; - this.proxifiedObjectsMap = new Map(); - this.parenthoodMap = new Map(); - // default to true - if (typeof showDetachedWarning !== 'boolean') { - showDetachedWarning = true; - } - - this.showDetachedWarning = showDetachedWarning; - this.originalObject = root; - this.cachedProxy = null; - this.isRecording = false; - this.userCallback; - /** - * @memberof JSONPatcherProxy - * Restores callback back to the original one provided to `observe`. - */ - this.resume = resume.bind(this); - /** - * @memberof JSONPatcherProxy - * Replaces your callback with a noop function. - */ - this.pause = pause.bind(this); - } - - JSONPatcherProxy.prototype.generateProxyAtPath = function (parent, obj, path) { - var _this2 = this; - - if (!obj) { - return obj; - } - var traps = { - set: function set(target, key, value, receiver) { - return setTrap(_this2, target, key, value, receiver); - }, - deleteProperty: function deleteProperty(target, key) { - return deleteTrap(_this2, target, key); - } - }; - var revocableInstance = Proxy.revocable(obj, traps); - // cache traps object to disable them later. - revocableInstance.trapsInstance = traps; - revocableInstance.originalObject = obj; - - /* keeping track of object's parent and path */ - - this.parenthoodMap.set(obj, { parent: parent, path: path }); - - /* keeping track of all the proxies to be able to revoke them later */ - this.proxifiedObjectsMap.set(revocableInstance.proxy, revocableInstance); - return revocableInstance.proxy; - }; - // grab tree's leaves one by one, encapsulate them into a proxy and return - JSONPatcherProxy.prototype._proxifyObjectTreeRecursively = function (parent, root, path) { - for (var key in root) { - if (root.hasOwnProperty(key)) { - if (root[key] instanceof Object) { - root[key] = this._proxifyObjectTreeRecursively(root, root[key], escapePathComponent(key)); - } - } - } - return this.generateProxyAtPath(parent, root, path); - }; - // this function is for aesthetic purposes - JSONPatcherProxy.prototype.proxifyObjectTree = function (root) { - /* - while proxyifying object tree, - the proxyifying operation itself is being - recorded, which in an unwanted behavior, - that's why we disable recording through this - initial process; - */ - this.pause(); - this.isProxifyingTreeNow = true; - var proxifiedObject = this._proxifyObjectTreeRecursively(undefined, root, ''); - /* OK you can record now */ - this.isProxifyingTreeNow = false; - this.resume(); - return proxifiedObject; - }; - /** - * Turns a proxified object into a forward-proxy object; doesn't emit any patches anymore, like a normal object - * @param {Proxy} proxy - The target proxy object - */ - JSONPatcherProxy.prototype.disableTrapsForProxy = function (revokableProxyInstance) { - if (this.showDetachedWarning) { - var message = "You're accessing an object that is detached from the observedObject tree, see https://github.com/Palindrom/JSONPatcherProxy#detached-objects"; - - revokableProxyInstance.trapsInstance.set = function (targetObject, propKey, newValue) { - console.warn(message); - return Reflect.set(targetObject, propKey, newValue); - }; - revokableProxyInstance.trapsInstance.set = function (targetObject, propKey, newValue) { - console.warn(message); - return Reflect.set(targetObject, propKey, newValue); - }; - revokableProxyInstance.trapsInstance.deleteProperty = function (targetObject, propKey) { - return Reflect.deleteProperty(targetObject, propKey); - }; - } else { - delete revokableProxyInstance.trapsInstance.set; - delete revokableProxyInstance.trapsInstance.get; - delete revokableProxyInstance.trapsInstance.deleteProperty; - } - }; - /** - * Proxifies the object that was passed in the constructor and returns a proxified mirror of it. Even though both parameters are options. You need to pass at least one of them. - * @param {Boolean} [record] - whether to record object changes to a later-retrievable patches array. - * @param {Function} [callback] - this will be synchronously called with every object change with a single `patch` as the only parameter. - */ - JSONPatcherProxy.prototype.observe = function (record, callback) { - if (!record && !callback) { - throw new Error('You need to either record changes or pass a callback'); - } - this.isRecording = record; - this.userCallback = callback; - /* - I moved it here to remove it from `unobserve`, - this will also make the constructor faster, why initiate - the array before they decide to actually observe with recording? - They might need to use only a callback. - */ - if (record) this.patches = []; - this.cachedProxy = this.proxifyObjectTree(this.originalObject); - return this.cachedProxy; - }; - /** - * If the observed is set to record, it will synchronously return all the patches and empties patches array. - */ - JSONPatcherProxy.prototype.generate = function () { - if (!this.isRecording) { - throw new Error('You should set record to true to get patches later'); - } - return this.patches.splice(0, this.patches.length); - }; - /** - * Revokes all proxies rendering the observed object useless and good for garbage collection @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable} - */ - JSONPatcherProxy.prototype.revoke = function () { - this.proxifiedObjectsMap.forEach(function (el) { - el.revoke(); - }); - }; - /** - * Disables all proxies' traps, turning the observed object into a forward-proxy object, like a normal object that you can modify silently. - */ - JSONPatcherProxy.prototype.disableTraps = function () { - this.proxifiedObjectsMap.forEach(this.disableTrapsForProxy, this); - }; - return JSONPatcherProxy; - }(); - if (typeof module !== 'undefined') { - module.exports = JSONPatcherProxy; - module.exports.default = JSONPatcherProxy; - } - - var timeout = null; - var patchs = {}; - - var handler = function handler(patch) { - - clearTimeout(timeout); - if (patch.op === 'remove') { - //fix arr splice - var kv = getArrayPatch(patch.path); - patchs[kv.k] = kv.v; - timeout = setTimeout(function () { - update(patchs); - patchs = {}; - }); - } else { - var key = fixPath(patch.path); - patchs[key] = patch.value; - timeout = setTimeout(function () { - update(patchs); - patchs = {}; - }); - } - }; - - function render(vnode, parent, store) { - parent = typeof parent === 'string' ? document.querySelector(parent) : parent; - if (store) { - store.instances = []; - extendStoreUpate(store); - options.store = store; - store.data = new JSONPatcherProxy(store.data).observe(true, handler); - } - diff(null, vnode, {}, false, parent, false); - } - - function update(patch) { - options.store.update(patch); - } - - function extendStoreUpate(store) { - store.update = function (patch) { - var _this = this; - - var updateAll = matchGlobalData(this.globalData, patch); - - if (Object.keys(patch).length > 0) { - this.instances.forEach(function (instance) { - if (updateAll || _this.updateAll || instance.constructor.updatePath && needUpdate(patch, instance.constructor.updatePath)) { - instance.update(); - } - }); - this.onChange && this.onChange(patch); - } - }; - } - - function matchGlobalData(globalData, diffResult) { - if (!globalData) return false; - for (var keyA in diffResult) { - if (globalData.indexOf(keyA) > -1) { - return true; - } - for (var i = 0, len = globalData.length; i < len; i++) { - if (includePath(keyA, globalData[i])) { - return true; - } - } - } - return false; - } - - function needUpdate(diffResult, updatePath) { - for (var keyA in diffResult) { - if (updatePath[keyA]) { - return true; - } - for (var keyB in updatePath) { - if (includePath(keyA, keyB)) { - return true; - } - } - } - return false; - } - - function includePath(pathA, pathB) { - if (pathA.indexOf(pathB) === 0) { - var next = pathA.substr(pathB.length, 1); - if (next === '[' || next === '.') { - return true; - } - } - return false; - } - - function fixPath(path) { - var mpPath = ''; - var arr = path.replace('/', '').split('/'); - arr.forEach(function (item, index) { - if (index) { - if (isNaN(parseInt(item))) { - mpPath += '.' + item; - } else { - mpPath += '[' + item + ']'; - } - } else { - mpPath += item; - } - }); - return mpPath; - } - - function getArrayPatch(path) { - var arr = path.replace('/', '').split('/'); - var current = options.store.data[arr[0]]; - for (var i = 1, len = arr.length; i < len - 1; i++) { - current = current[arr[i]]; - } - return { k: fixArrPath(path), v: current }; - } - - function fixArrPath(path) { - var mpPath = ''; - var arr = path.replace('/', '').split('/'); - var len = arr.length; - arr.forEach(function (item, index) { - if (index < len - 1) { - if (index) { - if (isNaN(parseInt(item))) { - mpPath += '.' + item; - } else { - mpPath += '[' + item + ']'; - } - } else { - mpPath += item; - } - } - }); - return mpPath; - } - - var OBJECTTYPE = '[object Object]'; - var ARRAYTYPE = '[object Array]'; - - function define(name, ctor) { - customElements.define(name, ctor); - if (ctor.data && !ctor.pure) { - ctor.updatePath = getUpdatePath(ctor.data); - } - } - - function getUpdatePath(data) { - var result = {}; - dataToPath(data, result); - return result; - } - - function dataToPath(data, result) { - Object.keys(data).forEach(function (key) { - result[key] = true; - var type = Object.prototype.toString.call(data[key]); - if (type === OBJECTTYPE) { - _objToPath(data[key], key, result); - } else if (type === ARRAYTYPE) { - _arrayToPath(data[key], key, result); - } - }); - } - - function _objToPath(data, path, result) { - Object.keys(data).forEach(function (key) { - result[path + '.' + key] = true; - delete result[path]; - var type = Object.prototype.toString.call(data[key]); - if (type === OBJECTTYPE) { - _objToPath(data[key], path + '.' + key, result); - } else if (type === ARRAYTYPE) { - _arrayToPath(data[key], path + '.' + key, result); - } - }); - } - - function _arrayToPath(data, path, result) { - data.forEach(function (item, index) { - result[path + '[' + index + ']'] = true; - delete result[path]; - var type = Object.prototype.toString.call(item); - if (type === OBJECTTYPE) { - _objToPath(item, path + '[' + index + ']', result); - } else if (type === ARRAYTYPE) { - _arrayToPath(item, path + '[' + index + ']', result); - } - }); - } - - function tag(name, pure) { - return function (target) { - target.pure = pure; - define(name, target); - }; - } - - options.root.Omi = { - tag: tag, - WeElement: WeElement, - render: render, - h: h, - createElement: h, - options: options, - define: define - }; - - options.root.Omi.version = '4.0.0'; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _dec, _class, _dec2, _class2; - - function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn$1(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits$1(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var TodoList = (_dec = tag('todo-list', true), _dec(_class = function (_WeElement) { - _inherits$1(TodoList, _WeElement); - - function TodoList() { - _classCallCheck$1(this, TodoList); - - return _possibleConstructorReturn$1(this, _WeElement.apply(this, arguments)); - } - - TodoList.prototype.render = function render$$1(props) { - return Omi.h( - 'ul', - null, - props.items.map(function (item) { - return Omi.h( - 'li', - { key: item.id }, - item.text - ); - }) - ); - }; - - return TodoList; - }(WeElement)) || _class); - var TodoApp = (_dec2 = tag('todo-app'), _dec2(_class2 = function (_WeElement2) { - _inherits$1(TodoApp, _WeElement2); - - function TodoApp() { - var _temp, _this2, _ret; - - _classCallCheck$1(this, TodoApp); - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _ret = (_temp = (_this2 = _possibleConstructorReturn$1(this, _WeElement2.call.apply(_WeElement2, [this].concat(args))), _this2), _this2.handleChange = function (e) { - _this2.store.data.text = e.target.value; - }, _this2.handleSubmit = function (e) { - e.preventDefault(); - _this2.store.add(); - }, _temp), _possibleConstructorReturn$1(_this2, _ret); - } - - TodoApp.prototype.render = function render$$1(props, data) { - return Omi.h( - 'div', - null, - Omi.h( - 'h3', - null, - 'TODO by ', - data.fullName() - ), - data.showList && Omi.h('todo-list', { items: data.items }), - Omi.h( - 'form', - { onSubmit: this.handleSubmit }, - Omi.h('input', { - id: 'new-todo', - onChange: this.handleChange, - value: data.text - }), - Omi.h( - 'button', - null, - 'Add #', - data.items.length + 1 - ) - ) - ); - }; - - TodoApp.prototype.installed = function installed() { - var _this3 = this; - - setTimeout(function () { - _this3.store.rename(); - }, 2000); - - setTimeout(function () { - _this3.store.data.items.push({ text: 'abc' }); - }, 4000); - - setTimeout(function () { - _this3.store.data.items[2].text = 'changed'; - }, 6000); - - setTimeout(function () { - _this3.store.data.items.splice(1, 1); - }, 8000); - - setTimeout(function () { - _this3.store.data.showList = false; - }, 10000); - - setTimeout(function () { - _this3.store.data.showList = true; - }, 12000); - }; - - _createClass(TodoApp, null, [{ - key: 'data', - get: function get() { - return { - showList: null, - items: null, - text: null, - firstName: null, - lastName: null - }; - } - }]); - - return TodoApp; - }(WeElement)) || _class2); - - - var store = { - data: { - showList: true, - items: [{ text: 'Omi', id: Date.now() }, { text: 'JSX', id: Date.now() }], - text: '', - firstName: 'dnt', - lastName: 'zhang', - fullName: function fullName() { - return this.firstName + this.lastName; - } - }, - rename: function rename() { - this.data.firstName = 'Dnt'; - }, - add: function add() { - if (!this.data.text.trim().length) { - return; - } - this.data.items.push({ - text: this.data.text, - id: Date.now() - }); - this.data.text = ''; - } - }; - - render(Omi.h('todo-app', null), 'body', store); + 'use strict'; + + /** Virtual DOM Node */ + function VNode() {} + + function getGlobal() { + if (typeof global !== 'object' || !global || global.Math !== Math || global.Array !== Array) { + return self || window || global || function () { + return this; + }(); + } + return global; + } + + /** Global options + * @public + * @namespace options {Object} + */ + var options = { + store: null, + root: getGlobal() + }; + + var stack = []; + var EMPTY_CHILDREN = []; + + function h(nodeName, attributes) { + var children = EMPTY_CHILDREN, + lastSimple = void 0, + child = void 0, + simple = void 0, + i = void 0; + for (i = arguments.length; i-- > 2;) { + stack.push(arguments[i]); + } + if (attributes && attributes.children != null) { + if (!stack.length) stack.push(attributes.children); + delete attributes.children; + } + while (stack.length) { + if ((child = stack.pop()) && child.pop !== undefined) { + for (i = child.length; i--;) { + stack.push(child[i]); + } + } else { + if (typeof child === 'boolean') child = null; + + if (simple = typeof nodeName !== 'function') { + if (child == null) child = '';else if (typeof child === 'number') child = String(child);else if (typeof child !== 'string') simple = false; + } + + if (simple && lastSimple) { + children[children.length - 1] += child; + } else if (children === EMPTY_CHILDREN) { + children = [child]; + } else { + children.push(child); + } + + lastSimple = simple; + } + } + + var p = new VNode(); + p.nodeName = nodeName; + p.children = children; + p.attributes = attributes == null ? undefined : attributes; + p.key = attributes == null ? undefined : attributes.key; + + // if a "vnode hook" is defined, pass every created VNode to it + if (options.vnode !== undefined) options.vnode(p); + + return p; + } + + /** + * @license + * Copyright (c) 2016 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt + */ + (function () { + if ( + // No Reflect, no classes, no need for shim because native custom elements + // require ES2015 classes or Reflect. + window.Reflect === undefined || window.customElements === undefined || + // The webcomponentsjs custom elements polyfill doesn't require + // ES2015-compatible construction (`super()` or `Reflect.construct`). + window.customElements.hasOwnProperty('polyfillWrapFlushCallback')) { + return; + } + var BuiltInHTMLElement = HTMLElement; + window.HTMLElement = function HTMLElement() { + return Reflect.construct(BuiltInHTMLElement, [], this.constructor); + }; + HTMLElement.prototype = BuiltInHTMLElement.prototype; + HTMLElement.prototype.constructor = HTMLElement; + Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement); + })(); + + function cssToDom(css) { + var node = document.createElement('style'); + node.textContent = css; + return node; + } + + function npn(str) { + return str.replace(/-(\w)/g, function ($, $1) { + return $1.toUpperCase(); + }); + } + + function extend(obj, props) { + for (var i in props) { + obj[i] = props[i]; + }return obj; + } + + /** Invoke or update a ref, depending on whether it is a function or object ref. + * @param {object|function} [ref=null] + * @param {any} [value] + */ + function applyRef(ref, value) { + if (ref != null) { + if (typeof ref == 'function') ref(value);else ref.current = value; + } + } + + /** + * Call a function asynchronously, as soon as possible. Makes + * use of HTML Promise to schedule the callback if available, + * otherwise falling back to `setTimeout` (mainly for IE<11). + * @type {(callback: function) => void} + */ + var defer = typeof Promise == 'function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout; + + function isArray(obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; + } + + function nProps(props) { + if (!props || isArray(props)) return {}; + var result = {}; + Object.keys(props).forEach(function (key) { + result[key] = props[key].value; + }); + return result; + } + + // render modes + + var ATTR_KEY = '__preactattr_'; + + // DOM properties that should NOT have "px" added when numeric + var IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i; + + /** + * Check if two nodes are equivalent. + * + * @param {Node} node DOM Node to compare + * @param {VNode} vnode Virtual DOM node to compare + * @param {boolean} [hydrating=false] If true, ignores component constructors when comparing. + * @private + */ + function isSameNodeType(node, vnode, hydrating) { + if (typeof vnode === 'string' || typeof vnode === 'number') { + return node.splitText !== undefined; + } + if (typeof vnode.nodeName === 'string') { + return !node._componentConstructor && isNamedNode(node, vnode.nodeName); + } + return hydrating || node._componentConstructor === vnode.nodeName; + } + + /** + * Check if an Element has a given nodeName, case-insensitively. + * + * @param {Element} node A DOM Element to inspect the name of. + * @param {String} nodeName Unnormalized name to compare against. + */ + function isNamedNode(node, nodeName) { + return node.normalizedNodeName === nodeName || node.nodeName.toLowerCase() === nodeName.toLowerCase(); + } + + /** + * A DOM event listener + * @typedef {(e: Event) => void} EventListner + */ + + /** + * A mapping of event types to event listeners + * @typedef {Object.} EventListenerMap + */ + + /** + * Properties Preact adds to elements it creates + * @typedef PreactElementExtensions + * @property {string} [normalizedNodeName] A normalized node name to use in diffing + * @property {EventListenerMap} [_listeners] A map of event listeners added by components to this DOM node + * @property {import('../component').Component} [_component] The component that rendered this DOM node + * @property {function} [_componentConstructor] The constructor of the component that rendered this DOM node + */ + + /** + * A DOM element that has been extended with Preact properties + * @typedef {Element & ElementCSSInlineStyle & PreactElementExtensions} PreactElement + */ + + /** + * Create an element with the given nodeName. + * @param {string} nodeName The DOM node to create + * @param {boolean} [isSvg=false] If `true`, creates an element within the SVG + * namespace. + * @returns {PreactElement} The created DOM node + */ + function createNode(nodeName, isSvg) { + /** @type {PreactElement} */ + var node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName); + node.normalizedNodeName = nodeName; + return node; + } + + /** + * Remove a child node from its parent if attached. + * @param {Node} node The node to remove + */ + function removeNode(node) { + var parentNode = node.parentNode; + if (parentNode) parentNode.removeChild(node); + } + + /** + * Set a named attribute on the given Node, with special behavior for some names + * and event handlers. If `value` is `null`, the attribute/handler will be + * removed. + * @param {PreactElement} node An element to mutate + * @param {string} name The name/key to set, such as an event or attribute name + * @param {*} old The last value that was set for this name/node pair + * @param {*} value An attribute value, such as a function to be used as an + * event handler + * @param {boolean} isSvg Are we currently diffing inside an svg? + * @private + */ + function setAccessor(node, name, old, value, isSvg) { + if (name === 'className') name = 'class'; + + if (name === 'key') { + // ignore + } else if (name === 'ref') { + applyRef(old, null); + applyRef(value, node); + } else if (name === 'class' && !isSvg) { + node.className = value || ''; + } else if (name === 'style') { + if (!value || typeof value === 'string' || typeof old === 'string') { + node.style.cssText = value || ''; + } + if (value && typeof value === 'object') { + if (typeof old !== 'string') { + for (var i in old) { + if (!(i in value)) node.style[i] = ''; + } + } + for (var _i in value) { + node.style[_i] = typeof value[_i] === 'number' && IS_NON_DIMENSIONAL.test(_i) === false ? value[_i] + 'px' : value[_i]; + } + } + } else if (name === 'dangerouslySetInnerHTML') { + if (value) node.innerHTML = value.__html || ''; + } else if (name[0] == 'o' && name[1] == 'n') { + var useCapture = name !== (name = name.replace(/Capture$/, '')); + name = name.toLowerCase().substring(2); + if (value) { + if (!old) node.addEventListener(name, eventProxy, useCapture); + } else { + node.removeEventListener(name, eventProxy, useCapture); + } + (node._listeners || (node._listeners = {}))[name] = value; + } else if (name !== 'list' && name !== 'type' && !isSvg && name in node) { + // Attempt to set a DOM property to the given value. + // IE & FF throw for certain property-value combinations. + try { + node[name] = value == null ? '' : value; + } catch (e) {} + if ((value == null || value === false) && name != 'spellcheck') node.removeAttribute(name); + } else { + var ns = isSvg && name !== (name = name.replace(/^xlink:?/, '')); + // spellcheck is treated differently than all other boolean values and + // should not be removed when the value is `false`. See: + // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck + if (value == null || value === false) { + if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());else node.removeAttribute(name); + } else if (typeof value === 'string') { + if (ns) { + node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value); + } else { + node.setAttribute(name, value); + } + } + } + } + + /** + * Proxy an event to hooked event handlers + * @param {Event} e The event object from the browser + * @private + */ + function eventProxy(e) { + return this._listeners[e.type](options.event && options.event(e) || e); + } + + /** Diff recursion count, used to track the end of the diff cycle. */ + var diffLevel = 0; + + /** Global flag indicating if the diff is currently within an SVG */ + var isSvgMode = false; + + /** Global flag indicating if the diff is performing hydration */ + var hydrating = false; + + /** Apply differences in a given vnode (and it's deep children) to a real DOM Node. + * @param {Element} [dom=null] A DOM node to mutate into the shape of the `vnode` + * @param {VNode} vnode A VNode (with descendants forming a tree) representing the desired DOM structure + * @returns {Element} dom The created/mutated element + * @private + */ + function diff(dom, vnode, context, mountAll, parent, componentRoot) { + // diffLevel having been 0 here indicates initial entry into the diff (not a subdiff) + var ret = void 0; + if (!diffLevel++) { + // when first starting the diff, check if we're diffing an SVG or within an SVG + isSvgMode = parent != null && parent.ownerSVGElement !== undefined; + + // hydration is indicated by the existing element to be diffed not having a prop cache + hydrating = dom != null && !(ATTR_KEY in dom); + } + if (isArray(vnode)) { + ret = []; + var parentNode = null; + if (isArray(dom)) { + var domLength = dom.length; + var vnodeLength = vnode.length; + var maxLength = domLength >= vnodeLength ? domLength : vnodeLength; + parentNode = dom[0].parentNode; + for (var i = 0; i < maxLength; i++) { + ret.push(idiff(dom[i], vnode[i], context, mountAll, componentRoot)); + } + } else { + vnode.forEach(function (item) { + ret.push(idiff(dom, item, context, mountAll, componentRoot)); + }); + } + if (parent) { + ret.forEach(function (vnode) { + parent.appendChild(vnode); + }); + } else if (isArray(dom)) { + dom.forEach(function (node) { + parentNode.appendChild(node); + }); + } + } else { + ret = idiff(dom, vnode, context, mountAll, componentRoot); + // append the element if its a new parent + if (parent && ret.parentNode !== parent) parent.appendChild(ret); + } + + // diffLevel being reduced to 0 means we're exiting the diff + if (! --diffLevel) { + hydrating = false; + // invoke queued componentDidMount lifecycle methods + } + + return ret; + } + + /** Internals of `diff()`, separated to allow bypassing diffLevel / mount flushing. */ + function idiff(dom, vnode, context, mountAll, componentRoot) { + if (dom && vnode && dom.props) { + dom.props.children = vnode.children; + } + var out = dom, + prevSvgMode = isSvgMode; + + // empty values (null, undefined, booleans) render as empty Text nodes + if (vnode == null || typeof vnode === 'boolean') vnode = ''; + + // Fast case: Strings & Numbers create/update Text nodes. + if (typeof vnode === 'string' || typeof vnode === 'number') { + // update if it's already a Text node: + if (dom && dom.splitText !== undefined && dom.parentNode && (!dom._component || componentRoot)) { + /* istanbul ignore if */ /* Browser quirk that can't be covered: https://github.com/developit/preact/commit/fd4f21f5c45dfd75151bd27b4c217d8003aa5eb9 */ + if (dom.nodeValue != vnode) { + dom.nodeValue = vnode; + } + } else { + // it wasn't a Text node: replace it with one and recycle the old Element + out = document.createTextNode(vnode); + if (dom) { + if (dom.parentNode) dom.parentNode.replaceChild(out, dom); + recollectNodeTree(dom, true); + } + } + + out[ATTR_KEY] = true; + + return out; + } + + // If the VNode represents a Component, perform a component diff: + var vnodeName = vnode.nodeName; + + // Tracks entering and exiting SVG namespace when descending through the tree. + isSvgMode = vnodeName === 'svg' ? true : vnodeName === 'foreignObject' ? false : isSvgMode; + + // If there's no existing element or it's the wrong type, create a new one: + vnodeName = String(vnodeName); + if (!dom || !isNamedNode(dom, vnodeName)) { + out = createNode(vnodeName, isSvgMode); + + if (dom) { + // move children into the replacement node + while (dom.firstChild) { + out.appendChild(dom.firstChild); + } // if the previous Element was mounted into the DOM, replace it inline + if (dom.parentNode) dom.parentNode.replaceChild(out, dom); + + // recycle the old element (skips non-Element node types) + recollectNodeTree(dom, true); + } + } + + var fc = out.firstChild, + props = out[ATTR_KEY], + vchildren = vnode.children; + + if (props == null) { + props = out[ATTR_KEY] = {}; + for (var a = out.attributes, i = a.length; i--;) { + props[a[i].name] = a[i].value; + } + } + + // Optimization: fast-path for elements containing a single TextNode: + if (!hydrating && vchildren && vchildren.length === 1 && typeof vchildren[0] === 'string' && fc != null && fc.splitText !== undefined && fc.nextSibling == null) { + if (fc.nodeValue != vchildren[0]) { + fc.nodeValue = vchildren[0]; + } + } + // otherwise, if there are existing or new children, diff them: + else if (vchildren && vchildren.length || fc != null) { + if (!(out.constructor.is == 'WeElement' && out.constructor.noSlot)) { + innerDiffNode(out, vchildren, context, mountAll, hydrating || props.dangerouslySetInnerHTML != null); + } + } + + // Apply attributes/props from VNode to the DOM Element: + diffAttributes(out, vnode.attributes, props); + if (out.props) { + out.props.children = vnode.children; + } + // restore previous SVG mode: (in case we're exiting an SVG namespace) + isSvgMode = prevSvgMode; + + return out; + } + + /** Apply child and attribute changes between a VNode and a DOM Node to the DOM. + * @param {Element} dom Element whose children should be compared & mutated + * @param {Array} vchildren Array of VNodes to compare to `dom.childNodes` + * @param {Object} context Implicitly descendant context object (from most recent `getChildContext()`) + * @param {Boolean} mountAll + * @param {Boolean} isHydrating If `true`, consumes externally created elements similar to hydration + */ + function innerDiffNode(dom, vchildren, context, mountAll, isHydrating) { + var originalChildren = dom.childNodes, + children = [], + keyed = {}, + keyedLen = 0, + min = 0, + len = originalChildren.length, + childrenLen = 0, + vlen = vchildren ? vchildren.length : 0, + j = void 0, + c = void 0, + f = void 0, + vchild = void 0, + child = void 0; + + // Build up a map of keyed children and an Array of unkeyed children: + if (len !== 0) { + for (var i = 0; i < len; i++) { + var _child = originalChildren[i], + props = _child[ATTR_KEY], + key = vlen && props ? _child._component ? _child._component.__key : props.key : null; + if (key != null) { + keyedLen++; + keyed[key] = _child; + } else if (props || (_child.splitText !== undefined ? isHydrating ? _child.nodeValue.trim() : true : isHydrating)) { + children[childrenLen++] = _child; + } + } + } + + if (vlen !== 0) { + for (var _i = 0; _i < vlen; _i++) { + vchild = vchildren[_i]; + child = null; + + // attempt to find a node based on key matching + var _key = vchild.key; + if (_key != null) { + if (keyedLen && keyed[_key] !== undefined) { + child = keyed[_key]; + keyed[_key] = undefined; + keyedLen--; + } + } + // attempt to pluck a node of the same type from the existing children + else if (!child && min < childrenLen) { + for (j = min; j < childrenLen; j++) { + if (children[j] !== undefined && isSameNodeType(c = children[j], vchild, isHydrating)) { + child = c; + children[j] = undefined; + if (j === childrenLen - 1) childrenLen--; + if (j === min) min++; + break; + } + } + } + + // morph the matched/found/created DOM child to match vchild (deep) + child = idiff(child, vchild, context, mountAll); + + f = originalChildren[_i]; + if (child && child !== dom && child !== f) { + if (f == null) { + dom.appendChild(child); + } else if (child === f.nextSibling) { + removeNode(f); + } else { + dom.insertBefore(child, f); + } + } + } + } + + // remove unused keyed children: + if (keyedLen) { + for (var _i2 in keyed) { + if (keyed[_i2] !== undefined) recollectNodeTree(keyed[_i2], false); + } + } + + // remove orphaned unkeyed children: + while (min <= childrenLen) { + if ((child = children[childrenLen--]) !== undefined) recollectNodeTree(child, false); + } + } + + /** Recursively recycle (or just unmount) a node and its descendants. + * @param {Node} node DOM node to start unmount/removal from + * @param {Boolean} [unmountOnly=false] If `true`, only triggers unmount lifecycle, skips removal + */ + function recollectNodeTree(node, unmountOnly) { + // If the node's VNode had a ref function, invoke it with null here. + // (this is part of the React spec, and smart for unsetting references) + if (node[ATTR_KEY] != null && node[ATTR_KEY].ref) node[ATTR_KEY].ref(null); + + if (unmountOnly === false || node[ATTR_KEY] == null) { + removeNode(node); + } + + removeChildren(node); + } + + /** Recollect/unmount all children. + * - we use .lastChild here because it causes less reflow than .firstChild + * - it's also cheaper than accessing the .childNodes Live NodeList + */ + function removeChildren(node) { + node = node.lastChild; + while (node) { + var next = node.previousSibling; + recollectNodeTree(node, true); + node = next; + } + } + + /** Apply differences in attributes from a VNode to the given DOM Element. + * @param {Element} dom Element with attributes to diff `attrs` against + * @param {Object} attrs The desired end-state key-value attribute pairs + * @param {Object} old Current/previous attributes (from previous VNode or element's prop cache) + */ + function diffAttributes(dom, attrs, old) { + var name = void 0; + var update = false; + var isWeElement = dom.update; + // remove attributes no longer present on the vnode by setting them to undefined + for (name in old) { + if (!(attrs && attrs[name] != null) && old[name] != null) { + setAccessor(dom, name, old[name], old[name] = undefined, isSvgMode); + if (isWeElement) { + delete dom.props[name]; + update = true; + } + } + } + + // add new & update changed attributes + for (name in attrs) { + //diable when using store system? + //!dom.store && + if (isWeElement && typeof attrs[name] === 'object') { + dom.props[npn(name)] = attrs[name]; + update = true; + } else if (name !== 'children' && name !== 'innerHTML' && (!(name in old) || attrs[name] !== (name === 'value' || name === 'checked' ? dom[name] : old[name]))) { + setAccessor(dom, name, old[name], old[name] = attrs[name], isSvgMode); + if (isWeElement) { + dom.props[npn(name)] = attrs[name]; + update = true; + } + } + } + + dom.parentNode && update && isWeElement && dom.update(); + } + + /*! + * https://github.com/Palindrom/JSONPatcherProxy + * (c) 2017 Starcounter + * MIT license + */ + + /** Class representing a JS Object observer */ + var JSONPatcherProxy = function () { + /** + * Deep clones your object and returns a new object. + */ + function deepClone(obj) { + switch (typeof obj) { + case 'object': + return JSON.parse(JSON.stringify(obj)); //Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5 + case 'undefined': + return null; //this is how JSON.stringify behaves for array items + default: + return obj; //no need to clone primitives + } + } + JSONPatcherProxy.deepClone = deepClone; + + function escapePathComponent(str) { + if (str.indexOf('/') == -1 && str.indexOf('~') == -1) return str; + return str.replace(/~/g, '~0').replace(/\//g, '~1'); + } + JSONPatcherProxy.escapePathComponent = escapePathComponent; + + /** + * Walk up the parenthood tree to get the path + * @param {JSONPatcherProxy} instance + * @param {Object} obj the object you need to find its path + */ + function findObjectPath(instance, obj) { + var pathComponents = []; + var parentAndPath = instance.parenthoodMap.get(obj); + while (parentAndPath && parentAndPath.path) { + // because we're walking up-tree, we need to use the array as a stack + pathComponents.unshift(parentAndPath.path); + parentAndPath = instance.parenthoodMap.get(parentAndPath.parent); + } + if (pathComponents.length) { + var path = pathComponents.join('/'); + return '/' + path; + } + return ''; + } + /** + * A callback to be used as th proxy set trap callback. + * It updates parenthood map if needed, proxifies nested newly-added objects, calls default callbacks with the changes occurred. + * @param {JSONPatcherProxy} instance JSONPatcherProxy instance + * @param {Object} target the affected object + * @param {String} key the effect property's name + * @param {Any} newValue the value being set + */ + function setTrap(instance, target, key, newValue) { + var parentPath = findObjectPath(instance, target); + + var destinationPropKey = parentPath + '/' + escapePathComponent(key); + + if (instance.proxifiedObjectsMap.has(newValue)) { + var newValueOriginalObject = instance.proxifiedObjectsMap.get(newValue); + + instance.parenthoodMap.set(newValueOriginalObject.originalObject, { + parent: target, + path: key + }); + } + /* + mark already proxified values as inherited. + rationale: proxy.arr.shift() + will emit + {op: replace, path: '/arr/1', value: arr_2} + {op: remove, path: '/arr/2'} + by default, the second operation would revoke the proxy, and this renders arr revoked. + That's why we need to remember the proxies that are inherited. + */ + var revokableInstance = instance.proxifiedObjectsMap.get(newValue); + /* + Why do we need to check instance.isProxifyingTreeNow? + We need to make sure we mark revokables as inherited ONLY when we're observing, + because throughout the first proxification, a sub-object is proxified and then assigned to + its parent object. This assignment of a pre-proxified object can fool us into thinking + that it's a proxified object moved around, while in fact it's the first assignment ever. + Checking isProxifyingTreeNow ensures this is not happening in the first proxification, + but in fact is is a proxified object moved around the tree + */ + if (revokableInstance && !instance.isProxifyingTreeNow) { + revokableInstance.inherited = true; + } + + // if the new value is an object, make sure to watch it + if (newValue && typeof newValue == 'object' && !instance.proxifiedObjectsMap.has(newValue)) { + instance.parenthoodMap.set(newValue, { + parent: target, + path: key + }); + newValue = instance._proxifyObjectTreeRecursively(target, newValue, key); + } + // let's start with this operation, and may or may not update it later + var operation = { + op: 'remove', + path: destinationPropKey + }; + if (typeof newValue == 'undefined') { + // applying De Morgan's laws would be a tad faster, but less readable + if (!Array.isArray(target) && !target.hasOwnProperty(key)) { + // `undefined` is being set to an already undefined value, keep silent + return Reflect.set(target, key, newValue); + } + // when array element is set to `undefined`, should generate replace to `null` + if (Array.isArray(target)) { + operation.op = 'replace', operation.value = null; + } + var oldValue = instance.proxifiedObjectsMap.get(target[key]); + // was the deleted a proxified object? + if (oldValue) { + instance.parenthoodMap.delete(target[key]); + instance.disableTrapsForProxy(oldValue); + instance.proxifiedObjectsMap.delete(oldValue); + } + } else { + if (Array.isArray(target) && !Number.isInteger(+key.toString())) { + /* array props (as opposed to indices) don't emit any patches, to avoid needless `length` patches */ + if (key != 'length') { + console.warn('JSONPatcherProxy noticed a non-integer prop was set for an array. This will not emit a patch'); + } + return Reflect.set(target, key, newValue); + } + operation.op = 'add'; + if (target.hasOwnProperty(key)) { + if (typeof target[key] !== 'undefined' || Array.isArray(target)) { + operation.op = 'replace'; // setting `undefined` array elements is a `replace` op + } + } + operation.value = newValue; + } + operation.oldValue = target[key]; + var reflectionResult = Reflect.set(target, key, newValue); + instance.defaultCallback(operation); + return reflectionResult; + } + /** + * A callback to be used as th proxy delete trap callback. + * It updates parenthood map if needed, calls default callbacks with the changes occurred. + * @param {JSONPatcherProxy} instance JSONPatcherProxy instance + * @param {Object} target the effected object + * @param {String} key the effected property's name + */ + function deleteTrap(instance, target, key) { + if (typeof target[key] !== 'undefined') { + var parentPath = findObjectPath(instance, target); + var destinationPropKey = parentPath + '/' + escapePathComponent(key); + + var revokableProxyInstance = instance.proxifiedObjectsMap.get(target[key]); + + if (revokableProxyInstance) { + if (revokableProxyInstance.inherited) { + /* + this is an inherited proxy (an already proxified object that was moved around), + we shouldn't revoke it, because even though it was removed from path1, it is still used in path2. + And we know that because we mark moved proxies with `inherited` flag when we move them + it is a good idea to remove this flag if we come across it here, in deleteProperty trap. + We DO want to revoke the proxy if it was removed again. + */ + revokableProxyInstance.inherited = false; + } else { + instance.parenthoodMap.delete(revokableProxyInstance.originalObject); + instance.disableTrapsForProxy(revokableProxyInstance); + instance.proxifiedObjectsMap.delete(target[key]); + } + } + var reflectionResult = Reflect.deleteProperty(target, key); + + instance.defaultCallback({ + op: 'remove', + path: destinationPropKey + }); + + return reflectionResult; + } + } + /* pre-define resume and pause functions to enhance constructors performance */ + function resume() { + var _this = this; + + this.defaultCallback = function (operation) { + _this.isRecording && _this.patches.push(operation); + _this.userCallback && _this.userCallback(operation); + }; + this.isObserving = true; + } + function pause() { + this.defaultCallback = function () {}; + this.isObserving = false; + } + /** + * Creates an instance of JSONPatcherProxy around your object of interest `root`. + * @param {Object|Array} root - the object you want to wrap + * @param {Boolean} [showDetachedWarning = true] - whether to log a warning when a detached sub-object is modified @see {@link https://github.com/Palindrom/JSONPatcherProxy#detached-objects} + * @returns {JSONPatcherProxy} + * @constructor + */ + function JSONPatcherProxy(root, showDetachedWarning) { + this.isProxifyingTreeNow = false; + this.isObserving = false; + this.proxifiedObjectsMap = new Map(); + this.parenthoodMap = new Map(); + // default to true + if (typeof showDetachedWarning !== 'boolean') { + showDetachedWarning = true; + } + + this.showDetachedWarning = showDetachedWarning; + this.originalObject = root; + this.cachedProxy = null; + this.isRecording = false; + this.userCallback; + /** + * @memberof JSONPatcherProxy + * Restores callback back to the original one provided to `observe`. + */ + this.resume = resume.bind(this); + /** + * @memberof JSONPatcherProxy + * Replaces your callback with a noop function. + */ + this.pause = pause.bind(this); + } + + JSONPatcherProxy.prototype.generateProxyAtPath = function (parent, obj, path) { + var _this2 = this; + + if (!obj) { + return obj; + } + var traps = { + set: function set(target, key, value, receiver) { + return setTrap(_this2, target, key, value, receiver); + }, + deleteProperty: function deleteProperty(target, key) { + return deleteTrap(_this2, target, key); + } + }; + var revocableInstance = Proxy.revocable(obj, traps); + // cache traps object to disable them later. + revocableInstance.trapsInstance = traps; + revocableInstance.originalObject = obj; + + /* keeping track of object's parent and path */ + + this.parenthoodMap.set(obj, { parent: parent, path: path }); + + /* keeping track of all the proxies to be able to revoke them later */ + this.proxifiedObjectsMap.set(revocableInstance.proxy, revocableInstance); + return revocableInstance.proxy; + }; + // grab tree's leaves one by one, encapsulate them into a proxy and return + JSONPatcherProxy.prototype._proxifyObjectTreeRecursively = function (parent, root, path) { + for (var key in root) { + if (root.hasOwnProperty(key)) { + if (root[key] instanceof Object) { + root[key] = this._proxifyObjectTreeRecursively(root, root[key], escapePathComponent(key)); + } + } + } + return this.generateProxyAtPath(parent, root, path); + }; + // this function is for aesthetic purposes + JSONPatcherProxy.prototype.proxifyObjectTree = function (root) { + /* + while proxyifying object tree, + the proxyifying operation itself is being + recorded, which in an unwanted behavior, + that's why we disable recording through this + initial process; + */ + this.pause(); + this.isProxifyingTreeNow = true; + var proxifiedObject = this._proxifyObjectTreeRecursively(undefined, root, ''); + /* OK you can record now */ + this.isProxifyingTreeNow = false; + this.resume(); + return proxifiedObject; + }; + /** + * Turns a proxified object into a forward-proxy object; doesn't emit any patches anymore, like a normal object + * @param {Proxy} proxy - The target proxy object + */ + JSONPatcherProxy.prototype.disableTrapsForProxy = function (revokableProxyInstance) { + if (this.showDetachedWarning) { + var message = "You're accessing an object that is detached from the observedObject tree, see https://github.com/Palindrom/JSONPatcherProxy#detached-objects"; + + revokableProxyInstance.trapsInstance.set = function (targetObject, propKey, newValue) { + console.warn(message); + return Reflect.set(targetObject, propKey, newValue); + }; + revokableProxyInstance.trapsInstance.set = function (targetObject, propKey, newValue) { + console.warn(message); + return Reflect.set(targetObject, propKey, newValue); + }; + revokableProxyInstance.trapsInstance.deleteProperty = function (targetObject, propKey) { + return Reflect.deleteProperty(targetObject, propKey); + }; + } else { + delete revokableProxyInstance.trapsInstance.set; + delete revokableProxyInstance.trapsInstance.get; + delete revokableProxyInstance.trapsInstance.deleteProperty; + } + }; + /** + * Proxifies the object that was passed in the constructor and returns a proxified mirror of it. Even though both parameters are options. You need to pass at least one of them. + * @param {Boolean} [record] - whether to record object changes to a later-retrievable patches array. + * @param {Function} [callback] - this will be synchronously called with every object change with a single `patch` as the only parameter. + */ + JSONPatcherProxy.prototype.observe = function (record, callback) { + if (!record && !callback) { + throw new Error('You need to either record changes or pass a callback'); + } + this.isRecording = record; + this.userCallback = callback; + /* + I moved it here to remove it from `unobserve`, + this will also make the constructor faster, why initiate + the array before they decide to actually observe with recording? + They might need to use only a callback. + */ + if (record) this.patches = []; + this.cachedProxy = this.proxifyObjectTree(this.originalObject); + return this.cachedProxy; + }; + /** + * If the observed is set to record, it will synchronously return all the patches and empties patches array. + */ + JSONPatcherProxy.prototype.generate = function () { + if (!this.isRecording) { + throw new Error('You should set record to true to get patches later'); + } + return this.patches.splice(0, this.patches.length); + }; + /** + * Revokes all proxies rendering the observed object useless and good for garbage collection @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable} + */ + JSONPatcherProxy.prototype.revoke = function () { + this.proxifiedObjectsMap.forEach(function (el) { + el.revoke(); + }); + }; + /** + * Disables all proxies' traps, turning the observed object into a forward-proxy object, like a normal object that you can modify silently. + */ + JSONPatcherProxy.prototype.disableTraps = function () { + this.proxifiedObjectsMap.forEach(this.disableTrapsForProxy, this); + }; + return JSONPatcherProxy; + }(); + + function observe(target) { + target.observe = true; + } + + function proxyUpdate(ele) { + var timeout = null; + ele.data = new JSONPatcherProxy(ele.data).observe(false, function (info) { + if (info.oldValue === info.value) { + return; + } + + clearTimeout(timeout); + + timeout = setTimeout(function () { + ele.update(); + }, 16.6); + }); + } + + var _class, _temp; + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + + function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + + var WeElement = (_temp = _class = function (_HTMLElement) { + _inherits(WeElement, _HTMLElement); + + function WeElement() { + _classCallCheck(this, WeElement); + + var _this = _possibleConstructorReturn(this, _HTMLElement.call(this)); + + _this.props = Object.assign(nProps(_this.constructor.props), _this.constructor.defaultProps); + _this.data = _this.constructor.data || {}; + return _this; + } + + WeElement.prototype.connectedCallback = function connectedCallback() { + if (!this.constructor.pure) { + var p = this.parentNode; + while (p && !this.store) { + this.store = p.store; + p = p.parentNode || p.host; + } + if (this.store) { + this.store.instances.push(this); + } + } + + !this._isInstalled && this.install(); + var shadowRoot = void 0; + if (!this.shadowRoot) { + shadowRoot = this.attachShadow({ + mode: 'open' + }); + } else { + shadowRoot = this.shadowRoot; + var fc = void 0; + while (fc = shadowRoot.firstChild) { + shadowRoot.removeChild(fc); + } + } + + this.css && shadowRoot.appendChild(cssToDom(this.css())); + !this._isInstalled && this.beforeRender(); + options.afterInstall && options.afterInstall(this); + if (this.constructor.observe) { + proxyUpdate(this); + } + this.host = diff(null, this.render(this.props, this.data, this.store), {}, false, null, false); + if (isArray(this.host)) { + this.host.forEach(function (item) { + shadowRoot.appendChild(item); + }); + } else { + shadowRoot.appendChild(this.host); + } + !this._isInstalled && this.installed(); + this._isInstalled = true; + }; + + WeElement.prototype.disconnectedCallback = function disconnectedCallback() { + this.uninstall(); + if (this.store) { + for (var i = 0, len = this.store.instances.length; i < len; i++) { + if (this.store.instances[i] === this) { + this.store.instances.splice(i, 1); + break; + } + } + } + }; + + WeElement.prototype.update = function update() { + this.beforeUpdate(); + this.beforeRender(); + diff(this.host, this.render(this.props, this.data, this.store)); + this.afterUpdate(); + }; + + WeElement.prototype.fire = function fire(name, data) { + this.dispatchEvent(new CustomEvent(name, { detail: data })); + }; + + WeElement.prototype.install = function install() {}; + + WeElement.prototype.installed = function installed() {}; + + WeElement.prototype.uninstall = function uninstall() {}; + + WeElement.prototype.beforeUpdate = function beforeUpdate() {}; + + WeElement.prototype.afterUpdate = function afterUpdate() {}; + + WeElement.prototype.beforeRender = function beforeRender() {}; + + return WeElement; + }(HTMLElement), _class.is = 'WeElement', _temp); + + function render(vnode, parent, store) { + parent = typeof parent === 'string' ? document.querySelector(parent) : parent; + if (store) { + store.instances = []; + extendStoreUpate(store); + var timeout = null; + var patchs = {}; + store.data = new JSONPatcherProxy(store.data).observe(false, function (patch) { + clearTimeout(timeout); + if (patch.op === 'remove') { + // fix arr splice + var kv = getArrayPatch(patch.path, store); + patchs[kv.k] = kv.v; + timeout = setTimeout(function () { + update(patchs, store); + patchs = {}; + }, 16.6); + } else { + var key = fixPath(patch.path); + patchs[key] = patch.value; + timeout = setTimeout(function () { + update(patchs, store); + patchs = {}; + }, 16.6); + } + }); + parent.store = store; + } + diff(null, vnode, {}, false, parent, false); + } + + function update(patch, store) { + store.update(patch); + } + + function extendStoreUpate(store) { + store.update = function (patch) { + var _this = this; + + var updateAll = matchGlobalData(this.globalData, patch); + + if (Object.keys(patch).length > 0) { + this.instances.forEach(function (instance) { + if (updateAll || _this.updateAll || instance.constructor.updatePath && needUpdate(patch, instance.constructor.updatePath)) { + instance.update(); + } + }); + this.onChange && this.onChange(patch); + } + }; + } + + function matchGlobalData(globalData, diffResult) { + if (!globalData) return false; + for (var keyA in diffResult) { + if (globalData.indexOf(keyA) > -1) { + return true; + } + for (var i = 0, len = globalData.length; i < len; i++) { + if (includePath(keyA, globalData[i])) { + return true; + } + } + } + return false; + } + + function needUpdate(diffResult, updatePath) { + for (var keyA in diffResult) { + if (updatePath[keyA]) { + return true; + } + for (var keyB in updatePath) { + if (includePath(keyA, keyB)) { + return true; + } + } + } + return false; + } + + function includePath(pathA, pathB) { + if (pathA.indexOf(pathB) === 0) { + var next = pathA.substr(pathB.length, 1); + if (next === '[' || next === '.') { + return true; + } + } + return false; + } + + function fixPath(path) { + var mpPath = ''; + var arr = path.replace('/', '').split('/'); + arr.forEach(function (item, index) { + if (index) { + if (isNaN(Number(item))) { + mpPath += '.' + item; + } else { + mpPath += '[' + item + ']'; + } + } else { + mpPath += item; + } + }); + return mpPath; + } + + function getArrayPatch(path, store) { + var arr = path.replace('/', '').split('/'); + var current = store.data[arr[0]]; + for (var i = 1, len = arr.length; i < len - 1; i++) { + current = current[arr[i]]; + } + return { k: fixArrPath(path), v: current }; + } + + function fixArrPath(path) { + var mpPath = ''; + var arr = path.replace('/', '').split('/'); + var len = arr.length; + arr.forEach(function (item, index) { + if (index < len - 1) { + if (index) { + if (isNaN(Number(item))) { + mpPath += '.' + item; + } else { + mpPath += '[' + item + ']'; + } + } else { + mpPath += item; + } + } + }); + return mpPath; + } + + function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + function _possibleConstructorReturn$1(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + + function _inherits$1(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + + var OBJECTTYPE = '[object Object]'; + var ARRAYTYPE = '[object Array]'; + + function define(name, ctor) { + if (ctor.is === 'WeElement') { + customElements.define(name, ctor); + if (ctor.data && !ctor.pure) { + ctor.updatePath = getUpdatePath(ctor.data); + } + } else { + var Element = function (_WeElement) { + _inherits$1(Element, _WeElement); + + function Element() { + var _temp, _this, _ret; + + _classCallCheck$1(this, Element); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this = _possibleConstructorReturn$1(this, _WeElement.call.apply(_WeElement, [this].concat(args))), _this), _this._useId = 0, _this._useMap = {}, _temp), _possibleConstructorReturn$1(_this, _ret); + } + + Element.prototype.render = function render(props, data) { + return ctor.call(this, props, data); + }; + + Element.prototype.beforeRender = function beforeRender() { + this._useId = 0; + }; + + Element.prototype.useCss = function useCss(css) { + var style = this.shadowRoot.querySelector('style'); + style && this.shadowRoot.removeChild(style); + this.shadowRoot.appendChild(cssToDom(css)); + }; + + Element.prototype.useData = function useData(data) { + return this.use({ data: data }); + }; + + Element.prototype.use = function use(option) { + var _this2 = this; + + this._useId++; + var updater = function updater(newValue) { + var item = _this2._useMap[updater.id]; + + item.data = newValue; + + _this2.update(); + item.effect && item.effect(); + }; + + updater.id = this._useId; + if (!this._isInstalled) { + this._useMap[this._useId] = option; + return [option.data, updater]; + } + + return [this._useMap[this._useId].data, updater]; + }; + + Element.prototype.installed = function installed() { + this._isInstalled = true; + }; + + return Element; + }(WeElement); + + customElements.define(name, Element); + } + } + + function getUpdatePath(data) { + var result = {}; + dataToPath(data, result); + return result; + } + + function dataToPath(data, result) { + Object.keys(data).forEach(function (key) { + result[key] = true; + var type = Object.prototype.toString.call(data[key]); + if (type === OBJECTTYPE) { + _objToPath(data[key], key, result); + } else if (type === ARRAYTYPE) { + _arrayToPath(data[key], key, result); + } + }); + } + + function _objToPath(data, path, result) { + Object.keys(data).forEach(function (key) { + result[path + '.' + key] = true; + delete result[path]; + var type = Object.prototype.toString.call(data[key]); + if (type === OBJECTTYPE) { + _objToPath(data[key], path + '.' + key, result); + } else if (type === ARRAYTYPE) { + _arrayToPath(data[key], path + '.' + key, result); + } + }); + } + + function _arrayToPath(data, path, result) { + data.forEach(function (item, index) { + result[path + '[' + index + ']'] = true; + delete result[path]; + var type = Object.prototype.toString.call(item); + if (type === OBJECTTYPE) { + _objToPath(item, path + '[' + index + ']', result); + } else if (type === ARRAYTYPE) { + _arrayToPath(item, path + '[' + index + ']', result); + } + }); + } + + function tag(name, pure) { + return function (target) { + target.pure = pure; + define(name, target); + }; + } + + /** + * Clones the given VNode, optionally adding attributes/props and replacing its children. + * @param {VNode} vnode The virtual DOM element to clone + * @param {Object} props Attributes/props to add when cloning + * @param {VNode} rest Any additional arguments will be used as replacement children. + */ + function cloneElement(vnode, props) { + return h(vnode.nodeName, extend(extend({}, vnode.attributes), props), arguments.length > 2 ? [].slice.call(arguments, 2) : vnode.children); + } + + function getHost(ele) { + var p = ele.parentNode; + while (p) { + if (p.host) { + return p.host; + } else { + p = p.parentNode; + } + } + } + + var Component = WeElement; + + var omi = { + tag: tag, + WeElement: WeElement, + Component: Component, + render: render, + h: h, + createElement: h, + options: options, + define: define, + observe: observe, + cloneElement: cloneElement, + getHost: getHost + }; + + options.root.Omi = omi; + options.root.Omi.version = '4.0.22'; + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + function _possibleConstructorReturn$2(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + + function _inherits$2(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + + define('todo-list', function (_WeElement) { + _inherits$2(_class, _WeElement); + + function _class() { + _classCallCheck$2(this, _class); + + return _possibleConstructorReturn$2(this, _WeElement.apply(this, arguments)); + } + + _class.prototype.render = function render$$1(props) { + return Omi.h( + 'ul', + null, + props.items.map(function (item) { + return Omi.h( + 'li', + { key: item.id }, + item.text + ); + }) + ); + }; + + return _class; + }(WeElement)); + + define('todo-app', function (_WeElement2) { + _inherits$2(_class3, _WeElement2); + + function _class3() { + var _temp, _this2, _ret; + + _classCallCheck$2(this, _class3); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this2 = _possibleConstructorReturn$2(this, _WeElement2.call.apply(_WeElement2, [this].concat(args))), _this2), _this2.handleChange = function (e) { + _this2.store.data.text = e.target.value; + }, _this2.handleSubmit = function (e) { + e.preventDefault(); + _this2.store.add(); + }, _temp), _possibleConstructorReturn$2(_this2, _ret); + } + + _class3.prototype.render = function render$$1(props, data, store) { + return Omi.h( + 'div', + null, + Omi.h( + 'h3', + null, + 'TODO by ', + store.data.fullName() + ), + store.data.showList && Omi.h('todo-list', { items: store.data.items }), + Omi.h( + 'form', + { onSubmit: this.handleSubmit }, + Omi.h('input', { id: 'new-todo', onChange: this.handleChange, value: store.data.text }), + Omi.h( + 'button', + null, + 'Add #', + store.data.items.length + 1 + ) + ) + ); + }; + + _class3.prototype.installed = function installed() { + var _this3 = this; + + setTimeout(function () { + _this3.store.rename(); + }, 2000); + + setTimeout(function () { + _this3.store.data.items.push({ text: 'abc' }); + }, 4000); + + setTimeout(function () { + _this3.store.data.items[2].text = 'changed'; + }, 6000); + + setTimeout(function () { + _this3.store.data.items.splice(1, 1); + }, 8000); + + setTimeout(function () { + _this3.store.data.showList = false; + }, 10000); + + setTimeout(function () { + _this3.store.data.showList = true; + }, 12000); + }; + + _createClass(_class3, null, [{ + key: 'data', + get: function get() { + return { + showList: null, + items: null, + text: null, + firstName: null, + lastName: null + }; + } + }]); + + return _class3; + }(WeElement)); + + var store = { + data: { + showList: true, + items: [{ text: 'Omi', id: Date.now() }, { text: 'JSX', id: Date.now() }], + text: '', + firstName: 'dnt', + lastName: 'zhang', + fullName: function fullName() { + return this.firstName + this.lastName; + } + }, + rename: function rename() { + this.data.firstName = 'Dnt'; + }, + add: function add() { + if (!this.data.text.trim().length) { + return; + } + this.data.items.push({ + text: this.data.text, + id: Date.now() + }); + this.data.text = ''; + } + }; + + render(Omi.h('todo-app', null), 'body', store); }()); //# sourceMappingURL=b.js.map diff --git a/packages/omi/examples/store/b.js.map b/packages/omi/examples/store/b.js.map index 5f44ec403..1a67d0eec 100644 --- a/packages/omi/examples/store/b.js.map +++ b/packages/omi/examples/store/b.js.map @@ -1 +1 @@ -{"version":3,"file":"b.js","sources":["../../src/vnode.js","../../src/options.js","../../src/h.js","../../src/util.js","../../src/constants.js","../../src/vdom/index.js","../../src/dom/index.js","../../src/vdom/diff.js","../../src/we-element.js","../../src/proxy.js","../../src/render.js","../../src/define.js","../../src/tag.js","../../src/omi.js","main.js"],"sourcesContent":["/** Virtual DOM Node */\r\nexport function VNode() {}\r\n","function getGlobal() {\r\n\tif (typeof global !== 'object' || !global || global.Math !== Math || global.Array !== Array) {\r\n\t\tif (typeof self !== 'undefined') {\r\n\t\t\treturn self;\r\n\t\t} else if (typeof window !== 'undefined') {\r\n\t\t\treturn window;\r\n\t\t} else if (typeof global !== 'undefined') {\r\n\t\t\treturn global;\r\n\t\t}\r\n\t\treturn (function(){\r\n\t\t\treturn this;\r\n\t\t})();\r\n\t\t\r\n\t}\r\n\treturn global;\r\n}\r\n\r\n/** Global options\r\n *\t@public\r\n *\t@namespace options {Object}\r\n */\r\nexport default {\r\n\r\n\tstore: null,\r\n\t\r\n\troot: getGlobal()\r\n\t//componentChange(component, element) { },\r\n\t/** If `true`, `prop` changes trigger synchronous component updates.\r\n\t *\t@name syncComponentUpdates\r\n\t *\t@type Boolean\r\n\t *\t@default true\r\n\t */\r\n\t//syncComponentUpdates: true,\r\n\r\n\t/** Processes all created VNodes.\r\n\t *\t@param {VNode} vnode\tA newly-created VNode to normalize/process\r\n\t */\r\n\t//vnode(vnode) { }\r\n\r\n\t/** Hook invoked after a component is mounted. */\r\n\t//afterMount(component) { },\r\n\r\n\t/** Hook invoked after the DOM is updated with a component's latest render. */\r\n\t//afterUpdate(component) { }\r\n\r\n\t/** Hook invoked immediately before a component is unmounted. */\r\n\t// beforeUnmount(component) { }\r\n};\r\n","import { VNode } from './vnode';\r\nimport options from './options';\r\n\r\nconst stack = [];\r\nconst EMPTY_CHILDREN = [];\r\n\r\nexport function h(nodeName, attributes) {\r\n\tlet children = EMPTY_CHILDREN, lastSimple, child, simple, i;\r\n\tfor (i = arguments.length; i-- > 2;) {\r\n\t\tstack.push(arguments[i]);\r\n\t}\r\n\tif (attributes && attributes.children != null) {\r\n\t\tif (!stack.length) stack.push(attributes.children);\r\n\t\tdelete attributes.children;\r\n\t}\r\n\twhile (stack.length) {\r\n\t\tif ((child = stack.pop()) && child.pop !== undefined) {\r\n\t\t\tfor (i = child.length; i--;) stack.push(child[i]);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (typeof child === 'boolean') child = null;\r\n\r\n\t\t\tif ((simple = typeof nodeName !== 'function')) {\r\n\t\t\t\tif (child == null) child = '';\r\n\t\t\t\telse if (typeof child === 'number') child = String(child);\r\n\t\t\t\telse if (typeof child !== 'string') simple = false;\r\n\t\t\t}\r\n\r\n\t\t\tif (simple && lastSimple) {\r\n\t\t\t\tchildren[children.length - 1] += child;\r\n\t\t\t}\r\n\t\t\telse if (children === EMPTY_CHILDREN) {\r\n\t\t\t\tchildren = [child];\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tchildren.push(child);\r\n\t\t\t}\r\n\r\n\t\t\tlastSimple = simple;\r\n\t\t}\r\n\t}\r\n\r\n\tlet p = new VNode();\r\n\tp.nodeName = nodeName;\r\n\tp.children = children;\r\n\tp.attributes = attributes == null ? undefined : attributes;\r\n\tp.key = attributes == null ? undefined : attributes.key;\r\n\r\n\t// if a \"vnode hook\" is defined, pass every created VNode to it\r\n\tif (options.vnode !== undefined) options.vnode(p);\r\n\r\n\treturn p;\r\n}","/**\r\n * @license\r\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\r\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\r\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\r\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\r\n * Code distributed by Google as part of the polymer project is also\r\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\r\n */\r\n\r\n/**\r\n * This shim allows elements written in, or compiled to, ES5 to work on native\r\n * implementations of Custom Elements v1. It sets new.target to the value of\r\n * this.constructor so that the native HTMLElement constructor can access the\r\n * current under-construction element's definition.\r\n */\r\n(function() {\r\n if (\r\n // No Reflect, no classes, no need for shim because native custom elements\r\n // require ES2015 classes or Reflect.\r\n window.Reflect === undefined ||\r\n window.customElements === undefined ||\r\n // The webcomponentsjs custom elements polyfill doesn't require\r\n // ES2015-compatible construction (`super()` or `Reflect.construct`).\r\n window.customElements.hasOwnProperty('polyfillWrapFlushCallback')\r\n ) {\r\n return;\r\n }\r\n const BuiltInHTMLElement = HTMLElement;\r\n window.HTMLElement = function HTMLElement() {\r\n return Reflect.construct(BuiltInHTMLElement, [], this.constructor);\r\n };\r\n HTMLElement.prototype = BuiltInHTMLElement.prototype;\r\n HTMLElement.prototype.constructor = HTMLElement;\r\n Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement);\r\n })();\r\n\r\n\r\n\r\nexport function cssToDom(css) {\r\n const node = document.createElement('style')\r\n node.innerText = css\r\n return node\r\n}\r\n\r\n\r\nexport function npn(str) {\r\n return str.replace(/-(\\w)/g, function ($, $1) {\r\n return $1.toUpperCase();\r\n });\r\n}\r\n\r\nexport function extend(obj, props) {\r\n\tfor (let i in props) obj[i] = props[i];\r\n\treturn obj;\r\n}\r\n\r\n/** Invoke or update a ref, depending on whether it is a function or object ref.\r\n * @param {object|function} [ref=null]\r\n * @param {any} [value]\r\n */\r\nexport function applyRef(ref, value) {\r\n\tif (ref!=null) {\r\n\t\tif (typeof ref=='function') ref(value);\r\n\t\telse ref.current = value;\r\n\t}\r\n}\r\n\r\n/**\r\n * Call a function asynchronously, as soon as possible. Makes\r\n * use of HTML Promise to schedule the callback if available,\r\n * otherwise falling back to `setTimeout` (mainly for IE<11).\r\n * @type {(callback: function) => void}\r\n */\r\nexport const defer = typeof Promise=='function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout;\r\n\r\nexport function isArray(obj){\r\n return Object.prototype.toString.call(obj) === '[object Array]'\r\n}\r\n\r\nexport function nProps(props){\r\n if(!props || isArray(props)) return {}\r\n const result = {}\r\n Object.keys(props).forEach(key =>{\r\n result[key] = props[key].value \r\n })\r\n return result\r\n}\r\n","// render modes\r\n\r\nexport const NO_RENDER = 0;\r\nexport const SYNC_RENDER = 1;\r\nexport const FORCE_RENDER = 2;\r\nexport const ASYNC_RENDER = 3;\r\n\r\n\r\nexport const ATTR_KEY = '__preactattr_';\r\n\r\n// DOM properties that should NOT have \"px\" added when numeric\r\nexport const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;\r\n\r\n","import { extend } from '../util';\r\n\r\n\r\n/**\r\n * Check if two nodes are equivalent.\r\n *\r\n * @param {Node} node\t\t\tDOM Node to compare\r\n * @param {VNode} vnode\t\t\tVirtual DOM node to compare\r\n * @param {boolean} [hydrating=false]\tIf true, ignores component constructors when comparing.\r\n * @private\r\n */\r\nexport function isSameNodeType(node, vnode, hydrating) {\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\t\treturn node.splitText!==undefined;\r\n\t}\r\n\tif (typeof vnode.nodeName==='string') {\r\n\t\treturn !node._componentConstructor && isNamedNode(node, vnode.nodeName);\r\n\t}\r\n\treturn hydrating || node._componentConstructor===vnode.nodeName;\r\n}\r\n\r\n\r\n/**\r\n * Check if an Element has a given nodeName, case-insensitively.\r\n *\r\n * @param {Element} node\tA DOM Element to inspect the name of.\r\n * @param {String} nodeName\tUnnormalized name to compare against.\r\n */\r\nexport function isNamedNode(node, nodeName) {\r\n\treturn node.normalizedNodeName===nodeName || node.nodeName.toLowerCase()===nodeName.toLowerCase();\r\n}\r\n\r\n\r\n/**\r\n * Reconstruct Component-style `props` from a VNode.\r\n * Ensures default/fallback values from `defaultProps`:\r\n * Own-properties of `defaultProps` not present in `vnode.attributes` are added.\r\n *\r\n * @param {VNode} vnode\r\n * @returns {Object} props\r\n */\r\nexport function getNodeProps(vnode) {\r\n\tlet props = extend({}, vnode.attributes);\r\n\tprops.children = vnode.children;\r\n\r\n\tlet defaultProps = vnode.nodeName.defaultProps;\r\n\tif (defaultProps!==undefined) {\r\n\t\tfor (let i in defaultProps) {\r\n\t\t\tif (props[i]===undefined) {\r\n\t\t\t\tprops[i] = defaultProps[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn props;\r\n}\r\n","import { IS_NON_DIMENSIONAL } from '../constants';\r\nimport { applyRef } from '../util';\r\nimport options from '../options';\r\n\r\n/**\r\n * A DOM event listener\r\n * @typedef {(e: Event) => void} EventListner\r\n */\r\n\r\n/**\r\n * A mapping of event types to event listeners\r\n * @typedef {Object.} EventListenerMap\r\n */\r\n\r\n/**\r\n * Properties Preact adds to elements it creates\r\n * @typedef PreactElementExtensions\r\n * @property {string} [normalizedNodeName] A normalized node name to use in diffing\r\n * @property {EventListenerMap} [_listeners] A map of event listeners added by components to this DOM node\r\n * @property {import('../component').Component} [_component] The component that rendered this DOM node\r\n * @property {function} [_componentConstructor] The constructor of the component that rendered this DOM node\r\n */\r\n\r\n/**\r\n * A DOM element that has been extended with Preact properties\r\n * @typedef {Element & ElementCSSInlineStyle & PreactElementExtensions} PreactElement\r\n */\r\n\r\n/**\r\n * Create an element with the given nodeName.\r\n * @param {string} nodeName The DOM node to create\r\n * @param {boolean} [isSvg=false] If `true`, creates an element within the SVG\r\n * namespace.\r\n * @returns {PreactElement} The created DOM node\r\n */\r\nexport function createNode(nodeName, isSvg) {\r\n\t/** @type {PreactElement} */\r\n\tlet node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);\r\n\tnode.normalizedNodeName = nodeName;\r\n\treturn node;\r\n}\r\n\r\n\r\n/**\r\n * Remove a child node from its parent if attached.\r\n * @param {Node} node The node to remove\r\n */\r\nexport function removeNode(node) {\r\n\tlet parentNode = node.parentNode;\r\n\tif (parentNode) parentNode.removeChild(node);\r\n}\r\n\r\n\r\n/**\r\n * Set a named attribute on the given Node, with special behavior for some names\r\n * and event handlers. If `value` is `null`, the attribute/handler will be\r\n * removed.\r\n * @param {PreactElement} node An element to mutate\r\n * @param {string} name The name/key to set, such as an event or attribute name\r\n * @param {*} old The last value that was set for this name/node pair\r\n * @param {*} value An attribute value, such as a function to be used as an\r\n * event handler\r\n * @param {boolean} isSvg Are we currently diffing inside an svg?\r\n * @private\r\n */\r\nexport function setAccessor(node, name, old, value, isSvg) {\r\n\tif (name==='className') name = 'class';\r\n\r\n\r\n\tif (name==='key') {\r\n\t\t// ignore\r\n\t}\r\n\telse if (name==='ref') {\r\n\t\tapplyRef(old, null);\r\n\t\tapplyRef(value, node);\r\n\t}\r\n\telse if (name==='class' && !isSvg) {\r\n\t\tnode.className = value || '';\r\n\t}\r\n\telse if (name==='style') {\r\n\t\tif (!value || typeof value==='string' || typeof old==='string') {\r\n\t\t\tnode.style.cssText = value || '';\r\n\t\t}\r\n\t\tif (value && typeof value==='object') {\r\n\t\t\tif (typeof old!=='string') {\r\n\t\t\t\tfor (let i in old) if (!(i in value)) node.style[i] = '';\r\n\t\t\t}\r\n\t\t\tfor (let i in value) {\r\n\t\t\t\tnode.style[i] = typeof value[i]==='number' && IS_NON_DIMENSIONAL.test(i)===false ? (value[i]+'px') : value[i];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\telse if (name==='dangerouslySetInnerHTML') {\r\n\t\tif (value) node.innerHTML = value.__html || '';\r\n\t}\r\n\telse if (name[0]=='o' && name[1]=='n') {\r\n\t\tlet useCapture = name !== (name=name.replace(/Capture$/, ''));\r\n\t\tname = name.toLowerCase().substring(2);\r\n\t\tif (value) {\r\n\t\t\tif (!old) node.addEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tnode.removeEventListener(name, eventProxy, useCapture);\r\n\t\t}\r\n\t\t(node._listeners || (node._listeners = {}))[name] = value;\r\n\t}\r\n\telse if (name!=='list' && name!=='type' && !isSvg && name in node) {\r\n\t\t// Attempt to set a DOM property to the given value.\r\n\t\t// IE & FF throw for certain property-value combinations.\r\n\t\ttry {\r\n\t\t\tnode[name] = value==null ? '' : value;\r\n\t\t} catch (e) { }\r\n\t\tif ((value==null || value===false) && name!='spellcheck') node.removeAttribute(name);\r\n\t}\r\n\telse {\r\n\t\tlet ns = isSvg && (name !== (name = name.replace(/^xlink:?/, '')));\r\n\t\t// spellcheck is treated differently than all other boolean values and\r\n\t\t// should not be removed when the value is `false`. See:\r\n\t\t// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck\r\n\t\tif (value==null || value===false) {\r\n\t\t\tif (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());\r\n\t\t\telse node.removeAttribute(name);\r\n\t\t}\r\n\t\telse if (typeof value === 'string') {\r\n\t\t\tif (ns) {\r\n\t\t\t\tnode.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);\r\n\t\t\t} else {\r\n\t\t\t\tnode.setAttribute(name, value);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\n/**\r\n * Proxy an event to hooked event handlers\r\n * @param {Event} e The event object from the browser\r\n * @private\r\n */\r\nfunction eventProxy(e) {\r\n\treturn this._listeners[e.type](options.event && options.event(e) || e);\r\n}","import { ATTR_KEY } from '../constants';\r\nimport { isSameNodeType, isNamedNode } from './index';\r\nimport { createNode, setAccessor } from '../dom/index';\r\nimport { npn } from '../util'\r\nimport { removeNode } from '../dom/index';\r\n\r\n/** Queue of components that have been mounted and are awaiting componentDidMount */\r\nexport const mounts = [];\r\n\r\n/** Diff recursion count, used to track the end of the diff cycle. */\r\nexport let diffLevel = 0;\r\n\r\n/** Global flag indicating if the diff is currently within an SVG */\r\nlet isSvgMode = false;\r\n\r\n/** Global flag indicating if the diff is performing hydration */\r\nlet hydrating = false;\r\n\r\n\r\n\r\n\r\n/** Apply differences in a given vnode (and it's deep children) to a real DOM Node.\r\n *\t@param {Element} [dom=null]\t\tA DOM node to mutate into the shape of the `vnode`\r\n *\t@param {VNode} vnode\t\t\tA VNode (with descendants forming a tree) representing the desired DOM structure\r\n *\t@returns {Element} dom\t\t\tThe created/mutated element\r\n *\t@private\r\n */\r\nexport function diff(dom, vnode, context, mountAll, parent, componentRoot) {\r\n\t// diffLevel having been 0 here indicates initial entry into the diff (not a subdiff)\r\n\tif (!diffLevel++) {\r\n\t\t// when first starting the diff, check if we're diffing an SVG or within an SVG\r\n\t\tisSvgMode = parent!=null && parent.ownerSVGElement!==undefined;\r\n\r\n\t\t// hydration is indicated by the existing element to be diffed not having a prop cache\r\n\t\thydrating = dom!=null && !(ATTR_KEY in dom);\r\n\t}\r\n\r\n\tlet ret = idiff(dom, vnode, context, mountAll, componentRoot);\r\n\r\n\t// append the element if its a new parent\r\n\tif (parent && ret.parentNode!==parent) parent.appendChild(ret);\r\n\r\n\t// diffLevel being reduced to 0 means we're exiting the diff\r\n\tif (!--diffLevel) {\r\n\t\thydrating = false;\r\n\t\t// invoke queued componentDidMount lifecycle methods\r\n\t\t\r\n\t}\r\n\r\n\treturn ret;\r\n}\r\n\r\n\r\n/** Internals of `diff()`, separated to allow bypassing diffLevel / mount flushing. */\r\nfunction idiff(dom, vnode, context, mountAll, componentRoot) {\r\n\tlet out = dom,\r\n\t\tprevSvgMode = isSvgMode;\r\n\r\n\t// empty values (null, undefined, booleans) render as empty Text nodes\r\n\tif (vnode==null || typeof vnode==='boolean') vnode = '';\r\n\r\n\r\n\t// Fast case: Strings & Numbers create/update Text nodes.\r\n\tif (typeof vnode==='string' || typeof vnode==='number') {\r\n\r\n\t\t// update if it's already a Text node:\r\n\t\tif (dom && dom.splitText!==undefined && dom.parentNode && (!dom._component || componentRoot)) {\r\n\t\t\t/* istanbul ignore if */ /* Browser quirk that can't be covered: https://github.com/developit/preact/commit/fd4f21f5c45dfd75151bd27b4c217d8003aa5eb9 */\r\n\t\t\tif (dom.nodeValue!=vnode) {\r\n\t\t\t\tdom.nodeValue = vnode;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\t// it wasn't a Text node: replace it with one and recycle the old Element\r\n\t\t\tout = document.createTextNode(vnode);\r\n\t\t\tif (dom) {\r\n\t\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\t\t\t\trecollectNodeTree(dom, true);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tout[ATTR_KEY] = true;\r\n\r\n\t\treturn out;\r\n\t}\r\n\r\n\r\n\t// If the VNode represents a Component, perform a component diff:\r\n\tlet vnodeName = vnode.nodeName;\r\n\t\r\n\r\n\t// Tracks entering and exiting SVG namespace when descending through the tree.\r\n\tisSvgMode = vnodeName==='svg' ? true : vnodeName==='foreignObject' ? false : isSvgMode;\r\n\r\n\r\n\t// If there's no existing element or it's the wrong type, create a new one:\r\n\tvnodeName = String(vnodeName);\r\n\tif (!dom || !isNamedNode(dom, vnodeName)) {\r\n\t\tout = createNode(vnodeName, isSvgMode);\r\n\r\n\t\tif (dom) {\r\n\t\t\t// move children into the replacement node\r\n\t\t\twhile (dom.firstChild) out.appendChild(dom.firstChild);\r\n\r\n\t\t\t// if the previous Element was mounted into the DOM, replace it inline\r\n\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\r\n\r\n\t\t\t// recycle the old element (skips non-Element node types)\r\n\t\t\trecollectNodeTree(dom, true);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tlet fc = out.firstChild,\r\n\t\tprops = out[ATTR_KEY],\r\n\t\tvchildren = vnode.children;\r\n\r\n\tif (props==null) {\r\n\t\tprops = out[ATTR_KEY] = {};\r\n\t\tfor (let a=out.attributes, i=a.length; i--; ) props[a[i].name] = a[i].value;\r\n\t}\r\n\r\n\t// Optimization: fast-path for elements containing a single TextNode:\r\n\tif (!hydrating && vchildren && vchildren.length===1 && typeof vchildren[0]==='string' && fc!=null && fc.splitText!==undefined && fc.nextSibling==null) {\r\n\t\tif (fc.nodeValue!=vchildren[0]) {\r\n\t\t\tfc.nodeValue = vchildren[0];\r\n\t\t}\r\n\t}\r\n\t// otherwise, if there are existing or new children, diff them:\r\n\telse if (vchildren && vchildren.length || fc!=null) {\r\n\t\tinnerDiffNode(out, vchildren, context, mountAll, hydrating || props.dangerouslySetInnerHTML!=null);\r\n\t}\r\n\r\n\r\n\t// Apply attributes/props from VNode to the DOM Element:\r\n\tdiffAttributes(out, vnode.attributes, props);\r\n\r\n\r\n\t// restore previous SVG mode: (in case we're exiting an SVG namespace)\r\n\tisSvgMode = prevSvgMode;\r\n\r\n\treturn out;\r\n}\r\n\r\n\r\n/** Apply child and attribute changes between a VNode and a DOM Node to the DOM.\r\n *\t@param {Element} dom\t\t\tElement whose children should be compared & mutated\r\n *\t@param {Array} vchildren\t\tArray of VNodes to compare to `dom.childNodes`\r\n *\t@param {Object} context\t\t\tImplicitly descendant context object (from most recent `getChildContext()`)\r\n *\t@param {Boolean} mountAll\r\n *\t@param {Boolean} isHydrating\tIf `true`, consumes externally created elements similar to hydration\r\n */\r\nfunction innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {\r\n\tlet originalChildren = dom.childNodes,\r\n\t\tchildren = [],\r\n\t\tkeyed = {},\r\n\t\tkeyedLen = 0,\r\n\t\tmin = 0,\r\n\t\tlen = originalChildren.length,\r\n\t\tchildrenLen = 0,\r\n\t\tvlen = vchildren ? vchildren.length : 0,\r\n\t\tj, c, f, vchild, child;\r\n\r\n\t// Build up a map of keyed children and an Array of unkeyed children:\r\n\tif (len!==0) {\r\n\t\tfor (let i=0; i {\n this.isRecording && this.patches.push(operation);\n this.userCallback && this.userCallback(operation);\n };\n this.isObserving = true;\n }\n function pause() {\n this.defaultCallback = () => {};\n this.isObserving = false;\n }\n /**\n * Creates an instance of JSONPatcherProxy around your object of interest `root`. \n * @param {Object|Array} root - the object you want to wrap\n * @param {Boolean} [showDetachedWarning = true] - whether to log a warning when a detached sub-object is modified @see {@link https://github.com/Palindrom/JSONPatcherProxy#detached-objects} \n * @returns {JSONPatcherProxy}\n * @constructor\n */\n function JSONPatcherProxy(root, showDetachedWarning) {\n this.isProxifyingTreeNow = false;\n this.isObserving = false;\n this.proxifiedObjectsMap = new Map();\n this.parenthoodMap = new Map();\n // default to true\n if (typeof showDetachedWarning !== 'boolean') {\n showDetachedWarning = true;\n }\n\n this.showDetachedWarning = showDetachedWarning;\n this.originalObject = root;\n this.cachedProxy = null;\n this.isRecording = false;\n this.userCallback;\n /**\n * @memberof JSONPatcherProxy\n * Restores callback back to the original one provided to `observe`.\n */\n this.resume = resume.bind(this);\n /**\n * @memberof JSONPatcherProxy\n * Replaces your callback with a noop function.\n */\n this.pause = pause.bind(this);\n }\n\n JSONPatcherProxy.prototype.generateProxyAtPath = function(parent, obj, path) {\n if (!obj) {\n return obj;\n }\n const traps = {\n set: (target, key, value, receiver) =>\n setTrap(this, target, key, value, receiver),\n deleteProperty: (target, key) => deleteTrap(this, target, key)\n };\n const revocableInstance = Proxy.revocable(obj, traps);\n // cache traps object to disable them later.\n revocableInstance.trapsInstance = traps;\n revocableInstance.originalObject = obj;\n\n /* keeping track of object's parent and path */\n\n this.parenthoodMap.set(obj, { parent, path });\n\n /* keeping track of all the proxies to be able to revoke them later */\n this.proxifiedObjectsMap.set(revocableInstance.proxy, revocableInstance);\n return revocableInstance.proxy;\n };\n // grab tree's leaves one by one, encapsulate them into a proxy and return\n JSONPatcherProxy.prototype._proxifyObjectTreeRecursively = function(\n parent,\n root,\n path\n ) {\n for (let key in root) {\n if (root.hasOwnProperty(key)) {\n if (root[key] instanceof Object) {\n root[key] = this._proxifyObjectTreeRecursively(\n root,\n root[key],\n escapePathComponent(key)\n );\n }\n }\n }\n return this.generateProxyAtPath(parent, root, path);\n };\n // this function is for aesthetic purposes\n JSONPatcherProxy.prototype.proxifyObjectTree = function(root) {\n /*\n while proxyifying object tree,\n the proxyifying operation itself is being\n recorded, which in an unwanted behavior,\n that's why we disable recording through this\n initial process;\n */\n this.pause();\n this.isProxifyingTreeNow = true;\n const proxifiedObject = this._proxifyObjectTreeRecursively(\n undefined,\n root,\n ''\n );\n /* OK you can record now */\n this.isProxifyingTreeNow = false;\n this.resume();\n return proxifiedObject;\n };\n /**\n * Turns a proxified object into a forward-proxy object; doesn't emit any patches anymore, like a normal object\n * @param {Proxy} proxy - The target proxy object\n */\n JSONPatcherProxy.prototype.disableTrapsForProxy = function(\n revokableProxyInstance\n ) {\n if (this.showDetachedWarning) {\n const message =\n \"You're accessing an object that is detached from the observedObject tree, see https://github.com/Palindrom/JSONPatcherProxy#detached-objects\";\n\n revokableProxyInstance.trapsInstance.set = (\n targetObject,\n propKey,\n newValue\n ) => {\n console.warn(message);\n return Reflect.set(targetObject, propKey, newValue);\n };\n revokableProxyInstance.trapsInstance.set = (\n targetObject,\n propKey,\n newValue\n ) => {\n console.warn(message);\n return Reflect.set(targetObject, propKey, newValue);\n };\n revokableProxyInstance.trapsInstance.deleteProperty = (\n targetObject,\n propKey\n ) => {\n return Reflect.deleteProperty(targetObject, propKey);\n };\n } else {\n delete revokableProxyInstance.trapsInstance.set;\n delete revokableProxyInstance.trapsInstance.get;\n delete revokableProxyInstance.trapsInstance.deleteProperty;\n }\n };\n /**\n * Proxifies the object that was passed in the constructor and returns a proxified mirror of it. Even though both parameters are options. You need to pass at least one of them.\n * @param {Boolean} [record] - whether to record object changes to a later-retrievable patches array.\n * @param {Function} [callback] - this will be synchronously called with every object change with a single `patch` as the only parameter.\n */\n JSONPatcherProxy.prototype.observe = function(record, callback) {\n if (!record && !callback) {\n throw new Error('You need to either record changes or pass a callback');\n }\n this.isRecording = record;\n this.userCallback = callback;\n /*\n I moved it here to remove it from `unobserve`,\n this will also make the constructor faster, why initiate\n the array before they decide to actually observe with recording?\n They might need to use only a callback.\n */\n if (record) this.patches = [];\n this.cachedProxy = this.proxifyObjectTree(this.originalObject);\n return this.cachedProxy;\n };\n /**\n * If the observed is set to record, it will synchronously return all the patches and empties patches array.\n */\n JSONPatcherProxy.prototype.generate = function() {\n if (!this.isRecording) {\n throw new Error('You should set record to true to get patches later');\n }\n return this.patches.splice(0, this.patches.length);\n };\n /**\n * Revokes all proxies rendering the observed object useless and good for garbage collection @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable}\n */\n JSONPatcherProxy.prototype.revoke = function() {\n this.proxifiedObjectsMap.forEach(el => {\n el.revoke();\n });\n };\n /**\n * Disables all proxies' traps, turning the observed object into a forward-proxy object, like a normal object that you can modify silently.\n */\n JSONPatcherProxy.prototype.disableTraps = function() {\n this.proxifiedObjectsMap.forEach(this.disableTrapsForProxy, this);\n };\n return JSONPatcherProxy;\n})();\n\nexport default JSONPatcherProxy\nif (typeof module !== 'undefined') {\n module.exports = JSONPatcherProxy;\n module.exports.default = JSONPatcherProxy;\n}\n","\r\nimport { diff } from './vdom/diff'\r\nimport options from './options'\r\nimport JSONProxy from './proxy';\r\n\r\nlet timeout = null\r\nlet patchs = {}\r\n\r\nconst handler = function (patch) {\r\n\r\n clearTimeout(timeout)\r\n if (patch.op === 'remove') {//fix arr splice \r\n const kv = getArrayPatch(patch.path)\r\n patchs[kv.k] = kv.v\r\n timeout = setTimeout(function () {\r\n update(patchs)\r\n patchs = {}\r\n })\r\n } else {\r\n const key = fixPath(patch.path)\r\n patchs[key] = patch.value\r\n timeout = setTimeout(function () {\r\n update(patchs)\r\n patchs = {}\r\n })\r\n }\r\n}\r\n\r\nexport function render(vnode, parent, store) {\r\n parent = typeof parent === 'string' ? document.querySelector(parent) : parent\r\n if (store) {\r\n store.instances = []\r\n extendStoreUpate(store)\r\n options.store = store\r\n store.data = new JSONProxy(store.data).observe(true, handler)\r\n }\r\n diff(null, vnode, {}, false, parent, false)\r\n}\r\n\r\nfunction update(patch) {\r\n options.store.update(patch)\r\n}\r\n\r\nfunction extendStoreUpate(store) {\r\n store.update = function (patch) {\r\n const updateAll = matchGlobalData(this.globalData, patch)\r\n\r\n if (Object.keys(patch).length > 0) {\r\n this.instances.forEach(instance => {\r\n if (updateAll || this.updateAll || instance.constructor.updatePath && needUpdate(patch, instance.constructor.updatePath)) {\r\n instance.update()\r\n }\r\n })\r\n this.onChange && this.onChange(patch)\r\n }\r\n }\r\n}\r\n\r\nfunction matchGlobalData(globalData, diffResult) {\r\n if (!globalData) return false\r\n for (let keyA in diffResult) {\r\n if (globalData.indexOf(keyA) > -1) {\r\n return true\r\n }\r\n for (let i = 0, len = globalData.length; i < len; i++) {\r\n if (includePath(keyA, globalData[i])) {\r\n return true\r\n }\r\n }\r\n }\r\n return false\r\n}\r\n\r\nfunction needUpdate(diffResult, updatePath) {\r\n for (let keyA in diffResult) {\r\n if (updatePath[keyA]) {\r\n return true\r\n }\r\n for (let keyB in updatePath) {\r\n if (includePath(keyA, keyB)) {\r\n return true\r\n }\r\n }\r\n }\r\n return false\r\n}\r\n\r\nfunction includePath(pathA, pathB) {\r\n if (pathA.indexOf(pathB) === 0) {\r\n const next = pathA.substr(pathB.length, 1)\r\n if (next === '[' || next === '.') {\r\n return true\r\n }\r\n }\r\n return false\r\n}\r\n\r\nfunction updateByPath(origin, path, value) {\r\n const arr = path.replace(/]/g, '').replace(/\\[/g, '.').split('.')\r\n let current = origin\r\n for (let i = 0, len = arr.length; i < len; i++) {\r\n if (i === len - 1) {\r\n current[arr[i]] = value\r\n } else {\r\n current = current[arr[i]]\r\n }\r\n }\r\n}\r\n\r\nfunction fixPath(path) {\r\n let mpPath = ''\r\n const arr = path.replace('/', '').split('/')\r\n arr.forEach((item, index) => {\r\n if (index) {\r\n if (isNaN(parseInt(item))) {\r\n mpPath += '.' + item\r\n\r\n } else {\r\n mpPath += '[' + item + ']'\r\n }\r\n } else {\r\n mpPath += item\r\n }\r\n })\r\n return mpPath\r\n}\r\n\r\nfunction getArrayPatch(path) {\r\n const arr = path.replace('/', '').split('/')\r\n let current = options.store.data[arr[0]]\r\n for (let i = 1, len = arr.length; i < len - 1; i++) {\r\n current = current[arr[i]]\r\n }\r\n return { k: fixArrPath(path), v: current }\r\n}\r\n\r\nfunction fixArrPath(path) {\r\n let mpPath = ''\r\n const arr = path.replace('/', '').split('/')\r\n const len = arr.length\r\n arr.forEach((item, index) => {\r\n if (index < len - 1) {\r\n if (index) {\r\n if (isNaN(parseInt(item))) {\r\n mpPath += '.' + item\r\n\r\n } else {\r\n mpPath += '[' + item + ']'\r\n }\r\n } else {\r\n mpPath += item\r\n }\r\n }\r\n })\r\n return mpPath\r\n}","const OBJECTTYPE = '[object Object]'\r\nconst ARRAYTYPE = '[object Array]'\r\n\r\nexport function define(name, ctor) {\r\n customElements.define(name, ctor)\r\n if (ctor.data && !ctor.pure) {\r\n ctor.updatePath = getUpdatePath(ctor.data)\r\n }\r\n}\r\n\r\nfunction getUpdatePath(data) {\r\n const result = {}\r\n dataToPath(data, result)\r\n return result\r\n}\r\n\r\nfunction dataToPath(data, result) {\r\n Object.keys(data).forEach(key => {\r\n result[key] = true\r\n const type = Object.prototype.toString.call(data[key])\r\n if (type === OBJECTTYPE) {\r\n _objToPath(data[key], key, result)\r\n } else if (type === ARRAYTYPE) {\r\n _arrayToPath(data[key], key, result)\r\n }\r\n })\r\n}\r\n\r\nfunction _objToPath(data, path, result) {\r\n Object.keys(data).forEach(key => {\r\n result[path + '.' + key] = true\r\n delete result[path]\r\n const type = Object.prototype.toString.call(data[key])\r\n if (type === OBJECTTYPE) {\r\n _objToPath(data[key], path + '.' + key, result)\r\n } else if (type === ARRAYTYPE) {\r\n _arrayToPath(data[key], path + '.' + key, result)\r\n }\r\n })\r\n}\r\n\r\nfunction _arrayToPath(data, path, result) {\r\n data.forEach((item, index) => {\r\n result[path + '[' + index + ']'] = true\r\n delete result[path]\r\n const type = Object.prototype.toString.call(item)\r\n if (type === OBJECTTYPE) {\r\n _objToPath(item, path + '[' + index + ']', result)\r\n } else if (type === ARRAYTYPE) {\r\n _arrayToPath(item, path + '[' + index + ']', result)\r\n }\r\n })\r\n}","import { define } from './define'\r\n\r\nexport function tag(name, pure) {\r\n return function (target) {\r\n target.pure = pure\r\n define(name, target)\r\n }\r\n}","import { h, h as createElement } from './h';\r\nimport options from './options';\r\nimport WeElement from './we-element';\r\nimport { render } from './render';\r\nimport { define } from './define'\r\nimport { tag } from './tag'\r\n\r\noptions.root.Omi = {\r\n\ttag,\r\n\tWeElement,\r\n\trender,\r\n\th,\r\n\tcreateElement,\r\n\toptions,\r\n\tdefine\r\n};\r\n\r\noptions.root.Omi.version = '4.0.0';\r\n\r\nexport default {\r\n\ttag,\r\n\tWeElement,\r\n\trender,\r\n\th,\r\n\tcreateElement,\r\n\toptions,\r\n\tdefine\r\n};\r\n\r\nexport {\r\n\ttag,\r\n\tWeElement,\r\n\trender,\r\n\th,\r\n\tcreateElement,\r\n\toptions,\r\n\tdefine\r\n};\r\n","import { render, WeElement, tag } from '../../src/omi'\r\n\r\n@tag('todo-list', true)\r\nclass TodoList extends WeElement {\r\n render(props) {\r\n return (\r\n
    \r\n {props.items.map(item => (\r\n
  • {item.text}
  • \r\n ))}\r\n
\r\n );\r\n }\r\n}\r\n\r\n@tag('todo-app')\r\nclass TodoApp extends WeElement {\r\n static get data() {\r\n return {\r\n showList: null,\r\n items: null,\r\n text: null,\r\n firstName: null,\r\n lastName: null,\r\n }\r\n }\r\n\r\n render(props, data) {\r\n return (\r\n
\r\n

TODO by {data.fullName()}

\r\n {data.showList &&}\r\n
\r\n \r\n \r\n \r\n
\r\n );\r\n }\r\n\r\n handleChange = (e) => {\r\n this.store.data.text = e.target.value\r\n }\r\n\r\n handleSubmit = (e) => {\r\n e.preventDefault()\r\n this.store.add()\r\n }\r\n\r\n installed() {\r\n setTimeout(() => {\r\n this.store.rename()\r\n }, 2000)\r\n\r\n setTimeout(() => {\r\n this.store.data.items.push({ text: 'abc' })\r\n }, 4000)\r\n\r\n setTimeout(() => {\r\n this.store.data.items[2].text = 'changed'\r\n }, 6000)\r\n\r\n setTimeout(() => {\r\n this.store.data.items.splice(1, 1)\r\n }, 8000)\r\n\r\n setTimeout(() => {\r\n this.store.data.showList = false\r\n }, 10000)\r\n\r\n setTimeout(() => {\r\n this.store.data.showList = true\r\n }, 12000)\r\n\r\n }\r\n}\r\n\r\nconst store = {\r\n data: {\r\n showList :true,\r\n items: [\r\n { text: 'Omi', id: Date.now() },\r\n { text: 'JSX', id: Date.now() }\r\n ],\r\n text: '',\r\n firstName: 'dnt',\r\n lastName: 'zhang',\r\n fullName: function () {\r\n return this.firstName + this.lastName\r\n }\r\n },\r\n rename: function () {\r\n this.data.firstName = 'Dnt'\r\n },\r\n add: function () {\r\n if (!this.data.text.trim().length) {\r\n return;\r\n }\r\n this.data.items.push({\r\n text: this.data.text,\r\n id: Date.now()\r\n })\r\n this.data.text = ''\r\n }\r\n}\r\n\r\nrender(, 'body', store)"],"names":["VNode","getGlobal","global","Math","Array","self","window","store","root","stack","EMPTY_CHILDREN","h","nodeName","attributes","children","lastSimple","child","simple","i","arguments","length","push","pop","undefined","String","p","key","options","vnode","Reflect","customElements","hasOwnProperty","BuiltInHTMLElement","HTMLElement","construct","constructor","prototype","Object","setPrototypeOf","cssToDom","css","node","document","createElement","innerText","npn","str","replace","$","$1","toUpperCase","applyRef","ref","value","current","defer","Promise","resolve","then","bind","setTimeout","isArray","obj","toString","call","nProps","props","result","keys","forEach","ATTR_KEY","IS_NON_DIMENSIONAL","isSameNodeType","hydrating","splitText","_componentConstructor","isNamedNode","normalizedNodeName","toLowerCase","createNode","isSvg","createElementNS","removeNode","parentNode","removeChild","setAccessor","name","old","className","style","cssText","test","innerHTML","__html","useCapture","substring","addEventListener","eventProxy","removeEventListener","_listeners","e","removeAttribute","ns","removeAttributeNS","setAttributeNS","setAttribute","type","event","diffLevel","isSvgMode","diff","dom","context","mountAll","parent","componentRoot","ownerSVGElement","ret","idiff","appendChild","out","prevSvgMode","_component","nodeValue","createTextNode","replaceChild","recollectNodeTree","vnodeName","firstChild","fc","vchildren","a","nextSibling","innerDiffNode","dangerouslySetInnerHTML","diffAttributes","isHydrating","originalChildren","childNodes","keyed","keyedLen","min","len","childrenLen","vlen","j","c","f","vchild","__key","trim","insertBefore","unmountOnly","removeChildren","lastChild","next","previousSibling","attrs","update","isWeElement","WeElement","data","connectedCallback","instances","install","shadowRoot","attachShadow","mode","host","render","pure","installed","disconnectedCallback","uninstall","splice","beforeUpdate","afterUpdate","fire","dispatchEvent","CustomEvent","detail","JSONPatcherProxy","deepClone","JSON","parse","stringify","escapePathComponent","indexOf","findObjectPath","instance","pathComponents","parentAndPath","parenthoodMap","get","path","unshift","join","setTrap","target","newValue","parentPath","destinationPropKey","proxifiedObjectsMap","has","newValueOriginalObject","set","originalObject","revokableInstance","isProxifyingTreeNow","inherited","_proxifyObjectTreeRecursively","operation","op","oldValue","delete","disableTrapsForProxy","Number","isInteger","console","warn","reflectionResult","defaultCallback","deleteTrap","revokableProxyInstance","deleteProperty","resume","isRecording","patches","userCallback","isObserving","pause","showDetachedWarning","Map","cachedProxy","generateProxyAtPath","traps","receiver","revocableInstance","Proxy","revocable","trapsInstance","proxy","proxifyObjectTree","proxifiedObject","message","targetObject","propKey","observe","record","callback","Error","generate","revoke","el","disableTraps","module","exports","default","timeout","patchs","handler","patch","clearTimeout","kv","getArrayPatch","k","v","fixPath","querySelector","extendStoreUpate","JSONProxy","updateAll","matchGlobalData","globalData","updatePath","needUpdate","onChange","diffResult","keyA","includePath","keyB","pathA","pathB","substr","mpPath","arr","split","item","index","isNaN","parseInt","fixArrPath","OBJECTTYPE","ARRAYTYPE","define","ctor","getUpdatePath","dataToPath","_objToPath","_arrayToPath","tag","Omi","version","TodoList","items","map","id","text","TodoApp","handleChange","handleSubmit","preventDefault","add","fullName","showList","rename","firstName","lastName","Date","now"],"mappings":";;;CAAA;AACA,CAAO,SAASA,KAAT,GAAiB;;CCDxB,SAASC,SAAT,GAAqB;CACpB,KAAI,OAAOC,MAAP,KAAkB,QAAlB,IAA8B,CAACA,MAA/B,IAAyCA,OAAOC,IAAP,KAAgBA,IAAzD,IAAiED,OAAOE,KAAP,KAAiBA,KAAtF,EAA6F;CAC5F,MAAI,OAAOC,IAAP,KAAgB,WAApB,EAAiC;CAChC,UAAOA,IAAP;CACA,GAFD,MAEO,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;CACzC,UAAOA,MAAP;CACA,GAFM,MAEA,IAAI,OAAOJ,MAAP,KAAkB,WAAtB,EAAmC;CACzC,UAAOA,MAAP;CACA;CACD,SAAQ,YAAU;CACjB,UAAO,IAAP;CAC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":["../../src/vnode.js","../../src/options.js","../../src/h.js","../../src/util.js","../../src/constants.js","../../src/vdom/index.js","../../src/dom/index.js","../../src/vdom/diff.js","../../src/proxy.js","../../src/observe.js","../../src/we-element.js","../../src/render.js","../../src/define.js","../../src/tag.js","../../src/clone-element.js","../../src/get-host.js","../../src/omi.js","main.js"],"sourcesContent":["/** Virtual DOM Node */\r\nexport function VNode() {}\r\n","function getGlobal() {\n if (\n typeof global !== 'object' ||\n !global ||\n global.Math !== Math ||\n global.Array !== Array\n ) {\n return (\n self ||\n window ||\n global ||\n (function() {\n return this\n })()\n )\n }\n return global\n}\n\n/** Global options\n *\t@public\n *\t@namespace options {Object}\n */\nexport default {\n store: null,\n root: getGlobal()\n}\n","import { VNode } from './vnode'\nimport options from './options'\n\nconst stack = []\nconst EMPTY_CHILDREN = []\n\nexport function h(nodeName, attributes) {\n let children = EMPTY_CHILDREN,\n lastSimple,\n child,\n simple,\n i\n for (i = arguments.length; i-- > 2; ) {\n stack.push(arguments[i])\n }\n if (attributes && attributes.children != null) {\n if (!stack.length) stack.push(attributes.children)\n delete attributes.children\n }\n while (stack.length) {\n if ((child = stack.pop()) && child.pop !== undefined) {\n for (i = child.length; i--; ) stack.push(child[i])\n } else {\n if (typeof child === 'boolean') child = null\n\n if ((simple = typeof nodeName !== 'function')) {\n if (child == null) child = ''\n else if (typeof child === 'number') child = String(child)\n else if (typeof child !== 'string') simple = false\n }\n\n if (simple && lastSimple) {\n children[children.length - 1] += child\n } else if (children === EMPTY_CHILDREN) {\n children = [child]\n } else {\n children.push(child)\n }\n\n lastSimple = simple\n }\n }\n\n let p = new VNode()\n p.nodeName = nodeName\n p.children = children\n p.attributes = attributes == null ? undefined : attributes\n p.key = attributes == null ? undefined : attributes.key\n\n // if a \"vnode hook\" is defined, pass every created VNode to it\n if (options.vnode !== undefined) options.vnode(p)\n\n return p\n}\n","/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\n/**\n * This shim allows elements written in, or compiled to, ES5 to work on native\n * implementations of Custom Elements v1. It sets new.target to the value of\n * this.constructor so that the native HTMLElement constructor can access the\n * current under-construction element's definition.\n */\n;(function() {\n if (\n // No Reflect, no classes, no need for shim because native custom elements\n // require ES2015 classes or Reflect.\n window.Reflect === undefined ||\n window.customElements === undefined ||\n // The webcomponentsjs custom elements polyfill doesn't require\n // ES2015-compatible construction (`super()` or `Reflect.construct`).\n window.customElements.hasOwnProperty('polyfillWrapFlushCallback')\n ) {\n return\n }\n const BuiltInHTMLElement = HTMLElement\n window.HTMLElement = function HTMLElement() {\n return Reflect.construct(BuiltInHTMLElement, [], this.constructor)\n }\n HTMLElement.prototype = BuiltInHTMLElement.prototype\n HTMLElement.prototype.constructor = HTMLElement\n Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement)\n})()\n\nexport function cssToDom(css) {\n const node = document.createElement('style')\n node.textContent = css\n return node\n}\n\nexport function npn(str) {\n return str.replace(/-(\\w)/g, ($, $1) => {\n return $1.toUpperCase()\n })\n}\n\nexport function extend(obj, props) {\n for (let i in props) obj[i] = props[i]\n return obj\n}\n\n/** Invoke or update a ref, depending on whether it is a function or object ref.\n * @param {object|function} [ref=null]\n * @param {any} [value]\n */\nexport function applyRef(ref, value) {\n if (ref != null) {\n if (typeof ref == 'function') ref(value)\n else ref.current = value\n }\n}\n\n/**\n * Call a function asynchronously, as soon as possible. Makes\n * use of HTML Promise to schedule the callback if available,\n * otherwise falling back to `setTimeout` (mainly for IE<11).\n * @type {(callback: function) => void}\n */\nexport const defer =\n typeof Promise == 'function'\n ? Promise.resolve().then.bind(Promise.resolve())\n : setTimeout\n\nexport function isArray(obj) {\n return Object.prototype.toString.call(obj) === '[object Array]'\n}\n\nexport function nProps(props) {\n if (!props || isArray(props)) return {}\n const result = {}\n Object.keys(props).forEach(key => {\n result[key] = props[key].value\n })\n return result\n}\n","// render modes\n\nexport const NO_RENDER = 0\nexport const SYNC_RENDER = 1\nexport const FORCE_RENDER = 2\nexport const ASYNC_RENDER = 3\n\nexport const ATTR_KEY = '__preactattr_'\n\n// DOM properties that should NOT have \"px\" added when numeric\nexport const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i\n","import { extend } from '../util'\n\n/**\n * Check if two nodes are equivalent.\n *\n * @param {Node} node\t\t\tDOM Node to compare\n * @param {VNode} vnode\t\t\tVirtual DOM node to compare\n * @param {boolean} [hydrating=false]\tIf true, ignores component constructors when comparing.\n * @private\n */\nexport function isSameNodeType(node, vnode, hydrating) {\n if (typeof vnode === 'string' || typeof vnode === 'number') {\n return node.splitText !== undefined\n }\n if (typeof vnode.nodeName === 'string') {\n return !node._componentConstructor && isNamedNode(node, vnode.nodeName)\n }\n return hydrating || node._componentConstructor === vnode.nodeName\n}\n\n/**\n * Check if an Element has a given nodeName, case-insensitively.\n *\n * @param {Element} node\tA DOM Element to inspect the name of.\n * @param {String} nodeName\tUnnormalized name to compare against.\n */\nexport function isNamedNode(node, nodeName) {\n return (\n node.normalizedNodeName === nodeName ||\n node.nodeName.toLowerCase() === nodeName.toLowerCase()\n )\n}\n\n/**\n * Reconstruct Component-style `props` from a VNode.\n * Ensures default/fallback values from `defaultProps`:\n * Own-properties of `defaultProps` not present in `vnode.attributes` are added.\n *\n * @param {VNode} vnode\n * @returns {Object} props\n */\nexport function getNodeProps(vnode) {\n let props = extend({}, vnode.attributes)\n props.children = vnode.children\n\n let defaultProps = vnode.nodeName.defaultProps\n if (defaultProps !== undefined) {\n for (let i in defaultProps) {\n if (props[i] === undefined) {\n props[i] = defaultProps[i]\n }\n }\n }\n\n return props\n}\n","import { IS_NON_DIMENSIONAL } from '../constants'\nimport { applyRef } from '../util'\nimport options from '../options'\n\n/**\n * A DOM event listener\n * @typedef {(e: Event) => void} EventListner\n */\n\n/**\n * A mapping of event types to event listeners\n * @typedef {Object.} EventListenerMap\n */\n\n/**\n * Properties Preact adds to elements it creates\n * @typedef PreactElementExtensions\n * @property {string} [normalizedNodeName] A normalized node name to use in diffing\n * @property {EventListenerMap} [_listeners] A map of event listeners added by components to this DOM node\n * @property {import('../component').Component} [_component] The component that rendered this DOM node\n * @property {function} [_componentConstructor] The constructor of the component that rendered this DOM node\n */\n\n/**\n * A DOM element that has been extended with Preact properties\n * @typedef {Element & ElementCSSInlineStyle & PreactElementExtensions} PreactElement\n */\n\n/**\n * Create an element with the given nodeName.\n * @param {string} nodeName The DOM node to create\n * @param {boolean} [isSvg=false] If `true`, creates an element within the SVG\n * namespace.\n * @returns {PreactElement} The created DOM node\n */\nexport function createNode(nodeName, isSvg) {\n /** @type {PreactElement} */\n let node = isSvg\n ? document.createElementNS('http://www.w3.org/2000/svg', nodeName)\n : document.createElement(nodeName)\n node.normalizedNodeName = nodeName\n return node\n}\n\n/**\n * Remove a child node from its parent if attached.\n * @param {Node} node The node to remove\n */\nexport function removeNode(node) {\n let parentNode = node.parentNode\n if (parentNode) parentNode.removeChild(node)\n}\n\n/**\n * Set a named attribute on the given Node, with special behavior for some names\n * and event handlers. If `value` is `null`, the attribute/handler will be\n * removed.\n * @param {PreactElement} node An element to mutate\n * @param {string} name The name/key to set, such as an event or attribute name\n * @param {*} old The last value that was set for this name/node pair\n * @param {*} value An attribute value, such as a function to be used as an\n * event handler\n * @param {boolean} isSvg Are we currently diffing inside an svg?\n * @private\n */\nexport function setAccessor(node, name, old, value, isSvg) {\n if (name === 'className') name = 'class'\n\n if (name === 'key') {\n // ignore\n } else if (name === 'ref') {\n applyRef(old, null)\n applyRef(value, node)\n } else if (name === 'class' && !isSvg) {\n node.className = value || ''\n } else if (name === 'style') {\n if (!value || typeof value === 'string' || typeof old === 'string') {\n node.style.cssText = value || ''\n }\n if (value && typeof value === 'object') {\n if (typeof old !== 'string') {\n for (let i in old) if (!(i in value)) node.style[i] = ''\n }\n for (let i in value) {\n node.style[i] =\n typeof value[i] === 'number' && IS_NON_DIMENSIONAL.test(i) === false\n ? value[i] + 'px'\n : value[i]\n }\n }\n } else if (name === 'dangerouslySetInnerHTML') {\n if (value) node.innerHTML = value.__html || ''\n } else if (name[0] == 'o' && name[1] == 'n') {\n let useCapture = name !== (name = name.replace(/Capture$/, ''))\n name = name.toLowerCase().substring(2)\n if (value) {\n if (!old) node.addEventListener(name, eventProxy, useCapture)\n } else {\n node.removeEventListener(name, eventProxy, useCapture)\n }\n ;(node._listeners || (node._listeners = {}))[name] = value\n } else if (name !== 'list' && name !== 'type' && !isSvg && name in node) {\n // Attempt to set a DOM property to the given value.\n // IE & FF throw for certain property-value combinations.\n try {\n node[name] = value == null ? '' : value\n } catch (e) {}\n if ((value == null || value === false) && name != 'spellcheck')\n node.removeAttribute(name)\n } else {\n let ns = isSvg && name !== (name = name.replace(/^xlink:?/, ''))\n // spellcheck is treated differently than all other boolean values and\n // should not be removed when the value is `false`. See:\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck\n if (value == null || value === false) {\n if (ns)\n node.removeAttributeNS(\n 'http://www.w3.org/1999/xlink',\n name.toLowerCase()\n )\n else node.removeAttribute(name)\n } else if (typeof value === 'string') {\n if (ns) {\n node.setAttributeNS(\n 'http://www.w3.org/1999/xlink',\n name.toLowerCase(),\n value\n )\n } else {\n node.setAttribute(name, value)\n }\n }\n }\n}\n\n/**\n * Proxy an event to hooked event handlers\n * @param {Event} e The event object from the browser\n * @private\n */\nfunction eventProxy(e) {\n return this._listeners[e.type]((options.event && options.event(e)) || e)\n}\n","import { ATTR_KEY } from '../constants'\nimport { isSameNodeType, isNamedNode } from './index'\nimport { createNode, setAccessor } from '../dom/index'\nimport { npn, isArray } from '../util'\nimport { removeNode } from '../dom/index'\n\n/** Queue of components that have been mounted and are awaiting componentDidMount */\nexport const mounts = []\n\n/** Diff recursion count, used to track the end of the diff cycle. */\nexport let diffLevel = 0\n\n/** Global flag indicating if the diff is currently within an SVG */\nlet isSvgMode = false\n\n/** Global flag indicating if the diff is performing hydration */\nlet hydrating = false\n\n/** Apply differences in a given vnode (and it's deep children) to a real DOM Node.\n *\t@param {Element} [dom=null]\t\tA DOM node to mutate into the shape of the `vnode`\n *\t@param {VNode} vnode\t\t\tA VNode (with descendants forming a tree) representing the desired DOM structure\n *\t@returns {Element} dom\t\t\tThe created/mutated element\n *\t@private\n */\nexport function diff(dom, vnode, context, mountAll, parent, componentRoot) {\n // diffLevel having been 0 here indicates initial entry into the diff (not a subdiff)\n let ret\n if (!diffLevel++) {\n // when first starting the diff, check if we're diffing an SVG or within an SVG\n isSvgMode = parent != null && parent.ownerSVGElement !== undefined\n\n // hydration is indicated by the existing element to be diffed not having a prop cache\n hydrating = dom != null && !(ATTR_KEY in dom)\n }\n if (isArray(vnode)) {\n ret = []\n let parentNode = null\n if (isArray(dom)) {\n let domLength = dom.length\n let vnodeLength = vnode.length\n let maxLength = domLength >= vnodeLength ? domLength : vnodeLength\n parentNode = dom[0].parentNode\n for (let i = 0; i < maxLength; i++) {\n ret.push(idiff(dom[i], vnode[i], context, mountAll, componentRoot))\n }\n } else {\n vnode.forEach(function(item) {\n ret.push(idiff(dom, item, context, mountAll, componentRoot))\n })\n }\n if (parent) {\n ret.forEach(function(vnode) {\n parent.appendChild(vnode)\n })\n } else if (isArray(dom)) {\n dom.forEach(function(node) {\n parentNode.appendChild(node)\n })\n }\n } else {\n ret = idiff(dom, vnode, context, mountAll, componentRoot)\n // append the element if its a new parent\n if (parent && ret.parentNode !== parent) parent.appendChild(ret)\n }\n\n // diffLevel being reduced to 0 means we're exiting the diff\n if (!--diffLevel) {\n hydrating = false\n // invoke queued componentDidMount lifecycle methods\n }\n\n return ret\n}\n\n/** Internals of `diff()`, separated to allow bypassing diffLevel / mount flushing. */\nfunction idiff(dom, vnode, context, mountAll, componentRoot) {\n if (dom && vnode && dom.props) {\n dom.props.children = vnode.children\n }\n let out = dom,\n prevSvgMode = isSvgMode\n\n // empty values (null, undefined, booleans) render as empty Text nodes\n if (vnode == null || typeof vnode === 'boolean') vnode = ''\n\n // Fast case: Strings & Numbers create/update Text nodes.\n if (typeof vnode === 'string' || typeof vnode === 'number') {\n // update if it's already a Text node:\n if (\n dom &&\n dom.splitText !== undefined &&\n dom.parentNode &&\n (!dom._component || componentRoot)\n ) {\n /* istanbul ignore if */ /* Browser quirk that can't be covered: https://github.com/developit/preact/commit/fd4f21f5c45dfd75151bd27b4c217d8003aa5eb9 */\n if (dom.nodeValue != vnode) {\n dom.nodeValue = vnode\n }\n } else {\n // it wasn't a Text node: replace it with one and recycle the old Element\n out = document.createTextNode(vnode)\n if (dom) {\n if (dom.parentNode) dom.parentNode.replaceChild(out, dom)\n recollectNodeTree(dom, true)\n }\n }\n\n out[ATTR_KEY] = true\n\n return out\n }\n\n // If the VNode represents a Component, perform a component diff:\n let vnodeName = vnode.nodeName\n\n // Tracks entering and exiting SVG namespace when descending through the tree.\n isSvgMode =\n vnodeName === 'svg'\n ? true\n : vnodeName === 'foreignObject'\n ? false\n : isSvgMode\n\n // If there's no existing element or it's the wrong type, create a new one:\n vnodeName = String(vnodeName)\n if (!dom || !isNamedNode(dom, vnodeName)) {\n out = createNode(vnodeName, isSvgMode)\n\n if (dom) {\n // move children into the replacement node\n while (dom.firstChild) out.appendChild(dom.firstChild)\n\n // if the previous Element was mounted into the DOM, replace it inline\n if (dom.parentNode) dom.parentNode.replaceChild(out, dom)\n\n // recycle the old element (skips non-Element node types)\n recollectNodeTree(dom, true)\n }\n }\n\n let fc = out.firstChild,\n props = out[ATTR_KEY],\n vchildren = vnode.children\n\n if (props == null) {\n props = out[ATTR_KEY] = {}\n for (let a = out.attributes, i = a.length; i--; )\n props[a[i].name] = a[i].value\n }\n\n // Optimization: fast-path for elements containing a single TextNode:\n if (\n !hydrating &&\n vchildren &&\n vchildren.length === 1 &&\n typeof vchildren[0] === 'string' &&\n fc != null &&\n fc.splitText !== undefined &&\n fc.nextSibling == null\n ) {\n if (fc.nodeValue != vchildren[0]) {\n fc.nodeValue = vchildren[0]\n }\n }\n // otherwise, if there are existing or new children, diff them:\n else if ((vchildren && vchildren.length) || fc != null) {\n if (!(out.constructor.is == 'WeElement' && out.constructor.noSlot)) {\n innerDiffNode(\n out,\n vchildren,\n context,\n mountAll,\n hydrating || props.dangerouslySetInnerHTML != null\n )\n }\n }\n\n // Apply attributes/props from VNode to the DOM Element:\n diffAttributes(out, vnode.attributes, props)\n if (out.props) {\n out.props.children = vnode.children\n }\n // restore previous SVG mode: (in case we're exiting an SVG namespace)\n isSvgMode = prevSvgMode\n\n return out\n}\n\n/** Apply child and attribute changes between a VNode and a DOM Node to the DOM.\n *\t@param {Element} dom\t\t\tElement whose children should be compared & mutated\n *\t@param {Array} vchildren\t\tArray of VNodes to compare to `dom.childNodes`\n *\t@param {Object} context\t\t\tImplicitly descendant context object (from most recent `getChildContext()`)\n *\t@param {Boolean} mountAll\n *\t@param {Boolean} isHydrating\tIf `true`, consumes externally created elements similar to hydration\n */\nfunction innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {\n let originalChildren = dom.childNodes,\n children = [],\n keyed = {},\n keyedLen = 0,\n min = 0,\n len = originalChildren.length,\n childrenLen = 0,\n vlen = vchildren ? vchildren.length : 0,\n j,\n c,\n f,\n vchild,\n child\n\n // Build up a map of keyed children and an Array of unkeyed children:\n if (len !== 0) {\n for (let i = 0; i < len; i++) {\n let child = originalChildren[i],\n props = child[ATTR_KEY],\n key =\n vlen && props\n ? child._component\n ? child._component.__key\n : props.key\n : null\n if (key != null) {\n keyedLen++\n keyed[key] = child\n } else if (\n props ||\n (child.splitText !== undefined\n ? isHydrating\n ? child.nodeValue.trim()\n : true\n : isHydrating)\n ) {\n children[childrenLen++] = child\n }\n }\n }\n\n if (vlen !== 0) {\n for (let i = 0; i < vlen; i++) {\n vchild = vchildren[i]\n child = null\n\n // attempt to find a node based on key matching\n let key = vchild.key\n if (key != null) {\n if (keyedLen && keyed[key] !== undefined) {\n child = keyed[key]\n keyed[key] = undefined\n keyedLen--\n }\n }\n // attempt to pluck a node of the same type from the existing children\n else if (!child && min < childrenLen) {\n for (j = min; j < childrenLen; j++) {\n if (\n children[j] !== undefined &&\n isSameNodeType((c = children[j]), vchild, isHydrating)\n ) {\n child = c\n children[j] = undefined\n if (j === childrenLen - 1) childrenLen--\n if (j === min) min++\n break\n }\n }\n }\n\n // morph the matched/found/created DOM child to match vchild (deep)\n child = idiff(child, vchild, context, mountAll)\n\n f = originalChildren[i]\n if (child && child !== dom && child !== f) {\n if (f == null) {\n dom.appendChild(child)\n } else if (child === f.nextSibling) {\n removeNode(f)\n } else {\n dom.insertBefore(child, f)\n }\n }\n }\n }\n\n // remove unused keyed children:\n if (keyedLen) {\n for (let i in keyed)\n if (keyed[i] !== undefined) recollectNodeTree(keyed[i], false)\n }\n\n // remove orphaned unkeyed children:\n while (min <= childrenLen) {\n if ((child = children[childrenLen--]) !== undefined)\n recollectNodeTree(child, false)\n }\n}\n\n/** Recursively recycle (or just unmount) a node and its descendants.\n *\t@param {Node} node\t\t\t\t\t\tDOM node to start unmount/removal from\n *\t@param {Boolean} [unmountOnly=false]\tIf `true`, only triggers unmount lifecycle, skips removal\n */\nexport function recollectNodeTree(node, unmountOnly) {\n // If the node's VNode had a ref function, invoke it with null here.\n // (this is part of the React spec, and smart for unsetting references)\n if (node[ATTR_KEY] != null && node[ATTR_KEY].ref) node[ATTR_KEY].ref(null)\n\n if (unmountOnly === false || node[ATTR_KEY] == null) {\n removeNode(node)\n }\n\n removeChildren(node)\n}\n\n/** Recollect/unmount all children.\n *\t- we use .lastChild here because it causes less reflow than .firstChild\n *\t- it's also cheaper than accessing the .childNodes Live NodeList\n */\nexport function removeChildren(node) {\n node = node.lastChild\n while (node) {\n let next = node.previousSibling\n recollectNodeTree(node, true)\n node = next\n }\n}\n\n/** Apply differences in attributes from a VNode to the given DOM Element.\n *\t@param {Element} dom\t\tElement with attributes to diff `attrs` against\n *\t@param {Object} attrs\t\tThe desired end-state key-value attribute pairs\n *\t@param {Object} old\t\t\tCurrent/previous attributes (from previous VNode or element's prop cache)\n */\nfunction diffAttributes(dom, attrs, old) {\n let name\n let update = false\n let isWeElement = dom.update\n // remove attributes no longer present on the vnode by setting them to undefined\n for (name in old) {\n if (!(attrs && attrs[name] != null) && old[name] != null) {\n setAccessor(dom, name, old[name], (old[name] = undefined), isSvgMode)\n if (isWeElement) {\n delete dom.props[name]\n update = true\n }\n }\n }\n\n // add new & update changed attributes\n for (name in attrs) {\n //diable when using store system?\n //!dom.store &&\n if (isWeElement && typeof attrs[name] === 'object') {\n dom.props[npn(name)] = attrs[name]\n update = true\n } else if (\n name !== 'children' &&\n name !== 'innerHTML' &&\n (!(name in old) ||\n attrs[name] !==\n (name === 'value' || name === 'checked' ? dom[name] : old[name]))\n ) {\n setAccessor(dom, name, old[name], (old[name] = attrs[name]), isSvgMode)\n if (isWeElement) {\n dom.props[npn(name)] = attrs[name]\n update = true\n }\n }\n }\n\n dom.parentNode && update && isWeElement && dom.update()\n}\n","/*!\n * https://github.com/Palindrom/JSONPatcherProxy\n * (c) 2017 Starcounter\n * MIT license\n */\n\n/** Class representing a JS Object observer */\nconst JSONPatcherProxy = (function() {\n /**\n * Deep clones your object and returns a new object.\n */\n function deepClone(obj) {\n switch (typeof obj) {\n case 'object':\n return JSON.parse(JSON.stringify(obj)) //Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5\n case 'undefined':\n return null //this is how JSON.stringify behaves for array items\n default:\n return obj //no need to clone primitives\n }\n }\n JSONPatcherProxy.deepClone = deepClone\n\n function escapePathComponent(str) {\n if (str.indexOf('/') == -1 && str.indexOf('~') == -1) return str\n return str.replace(/~/g, '~0').replace(/\\//g, '~1')\n }\n JSONPatcherProxy.escapePathComponent = escapePathComponent\n\n /**\n * Walk up the parenthood tree to get the path\n * @param {JSONPatcherProxy} instance\n * @param {Object} obj the object you need to find its path\n */\n function findObjectPath(instance, obj) {\n const pathComponents = []\n let parentAndPath = instance.parenthoodMap.get(obj)\n while (parentAndPath && parentAndPath.path) {\n // because we're walking up-tree, we need to use the array as a stack\n pathComponents.unshift(parentAndPath.path)\n parentAndPath = instance.parenthoodMap.get(parentAndPath.parent)\n }\n if (pathComponents.length) {\n const path = pathComponents.join('/')\n return '/' + path\n }\n return ''\n }\n /**\n * A callback to be used as th proxy set trap callback.\n * It updates parenthood map if needed, proxifies nested newly-added objects, calls default callbacks with the changes occurred.\n * @param {JSONPatcherProxy} instance JSONPatcherProxy instance\n * @param {Object} target the affected object\n * @param {String} key the effect property's name\n * @param {Any} newValue the value being set\n */\n function setTrap(instance, target, key, newValue) {\n const parentPath = findObjectPath(instance, target)\n\n const destinationPropKey = parentPath + '/' + escapePathComponent(key)\n\n if (instance.proxifiedObjectsMap.has(newValue)) {\n const newValueOriginalObject = instance.proxifiedObjectsMap.get(newValue)\n\n instance.parenthoodMap.set(newValueOriginalObject.originalObject, {\n parent: target,\n path: key\n })\n }\n /*\n mark already proxified values as inherited.\n rationale: proxy.arr.shift()\n will emit\n {op: replace, path: '/arr/1', value: arr_2}\n {op: remove, path: '/arr/2'}\n\n by default, the second operation would revoke the proxy, and this renders arr revoked.\n That's why we need to remember the proxies that are inherited.\n */\n const revokableInstance = instance.proxifiedObjectsMap.get(newValue)\n /*\n Why do we need to check instance.isProxifyingTreeNow?\n\n We need to make sure we mark revokables as inherited ONLY when we're observing,\n because throughout the first proxification, a sub-object is proxified and then assigned to\n its parent object. This assignment of a pre-proxified object can fool us into thinking\n that it's a proxified object moved around, while in fact it's the first assignment ever.\n\n Checking isProxifyingTreeNow ensures this is not happening in the first proxification,\n but in fact is is a proxified object moved around the tree\n */\n if (revokableInstance && !instance.isProxifyingTreeNow) {\n revokableInstance.inherited = true\n }\n\n // if the new value is an object, make sure to watch it\n if (\n newValue &&\n typeof newValue == 'object' &&\n !instance.proxifiedObjectsMap.has(newValue)\n ) {\n instance.parenthoodMap.set(newValue, {\n parent: target,\n path: key\n })\n newValue = instance._proxifyObjectTreeRecursively(target, newValue, key)\n }\n // let's start with this operation, and may or may not update it later\n const operation = {\n op: 'remove',\n path: destinationPropKey\n }\n if (typeof newValue == 'undefined') {\n // applying De Morgan's laws would be a tad faster, but less readable\n if (!Array.isArray(target) && !target.hasOwnProperty(key)) {\n // `undefined` is being set to an already undefined value, keep silent\n return Reflect.set(target, key, newValue)\n }\n // when array element is set to `undefined`, should generate replace to `null`\n if (Array.isArray(target)) {\n // undefined array elements are JSON.stringified to `null`\n ;(operation.op = 'replace'), (operation.value = null)\n }\n const oldValue = instance.proxifiedObjectsMap.get(target[key])\n // was the deleted a proxified object?\n if (oldValue) {\n instance.parenthoodMap.delete(target[key])\n instance.disableTrapsForProxy(oldValue)\n instance.proxifiedObjectsMap.delete(oldValue)\n }\n } else {\n if (Array.isArray(target) && !Number.isInteger(+key.toString())) {\n /* array props (as opposed to indices) don't emit any patches, to avoid needless `length` patches */\n if (key != 'length') {\n console.warn(\n 'JSONPatcherProxy noticed a non-integer prop was set for an array. This will not emit a patch'\n )\n }\n return Reflect.set(target, key, newValue)\n }\n operation.op = 'add'\n if (target.hasOwnProperty(key)) {\n if (typeof target[key] !== 'undefined' || Array.isArray(target)) {\n operation.op = 'replace' // setting `undefined` array elements is a `replace` op\n }\n }\n operation.value = newValue\n }\n operation.oldValue = target[key]\n const reflectionResult = Reflect.set(target, key, newValue)\n instance.defaultCallback(operation)\n return reflectionResult\n }\n /**\n * A callback to be used as th proxy delete trap callback.\n * It updates parenthood map if needed, calls default callbacks with the changes occurred.\n * @param {JSONPatcherProxy} instance JSONPatcherProxy instance\n * @param {Object} target the effected object\n * @param {String} key the effected property's name\n */\n function deleteTrap(instance, target, key) {\n if (typeof target[key] !== 'undefined') {\n const parentPath = findObjectPath(instance, target)\n const destinationPropKey = parentPath + '/' + escapePathComponent(key)\n\n const revokableProxyInstance = instance.proxifiedObjectsMap.get(\n target[key]\n )\n\n if (revokableProxyInstance) {\n if (revokableProxyInstance.inherited) {\n /*\n this is an inherited proxy (an already proxified object that was moved around),\n we shouldn't revoke it, because even though it was removed from path1, it is still used in path2.\n And we know that because we mark moved proxies with `inherited` flag when we move them\n\n it is a good idea to remove this flag if we come across it here, in deleteProperty trap.\n We DO want to revoke the proxy if it was removed again.\n */\n revokableProxyInstance.inherited = false\n } else {\n instance.parenthoodMap.delete(revokableProxyInstance.originalObject)\n instance.disableTrapsForProxy(revokableProxyInstance)\n instance.proxifiedObjectsMap.delete(target[key])\n }\n }\n const reflectionResult = Reflect.deleteProperty(target, key)\n\n instance.defaultCallback({\n op: 'remove',\n path: destinationPropKey\n })\n\n return reflectionResult\n }\n }\n /* pre-define resume and pause functions to enhance constructors performance */\n function resume() {\n this.defaultCallback = operation => {\n this.isRecording && this.patches.push(operation)\n this.userCallback && this.userCallback(operation)\n }\n this.isObserving = true\n }\n function pause() {\n this.defaultCallback = () => {}\n this.isObserving = false\n }\n /**\n * Creates an instance of JSONPatcherProxy around your object of interest `root`.\n * @param {Object|Array} root - the object you want to wrap\n * @param {Boolean} [showDetachedWarning = true] - whether to log a warning when a detached sub-object is modified @see {@link https://github.com/Palindrom/JSONPatcherProxy#detached-objects}\n * @returns {JSONPatcherProxy}\n * @constructor\n */\n function JSONPatcherProxy(root, showDetachedWarning) {\n this.isProxifyingTreeNow = false\n this.isObserving = false\n this.proxifiedObjectsMap = new Map()\n this.parenthoodMap = new Map()\n // default to true\n if (typeof showDetachedWarning !== 'boolean') {\n showDetachedWarning = true\n }\n\n this.showDetachedWarning = showDetachedWarning\n this.originalObject = root\n this.cachedProxy = null\n this.isRecording = false\n this.userCallback\n /**\n * @memberof JSONPatcherProxy\n * Restores callback back to the original one provided to `observe`.\n */\n this.resume = resume.bind(this)\n /**\n * @memberof JSONPatcherProxy\n * Replaces your callback with a noop function.\n */\n this.pause = pause.bind(this)\n }\n\n JSONPatcherProxy.prototype.generateProxyAtPath = function(parent, obj, path) {\n if (!obj) {\n return obj\n }\n const traps = {\n set: (target, key, value, receiver) =>\n setTrap(this, target, key, value, receiver),\n deleteProperty: (target, key) => deleteTrap(this, target, key)\n }\n const revocableInstance = Proxy.revocable(obj, traps)\n // cache traps object to disable them later.\n revocableInstance.trapsInstance = traps\n revocableInstance.originalObject = obj\n\n /* keeping track of object's parent and path */\n\n this.parenthoodMap.set(obj, { parent, path })\n\n /* keeping track of all the proxies to be able to revoke them later */\n this.proxifiedObjectsMap.set(revocableInstance.proxy, revocableInstance)\n return revocableInstance.proxy\n }\n // grab tree's leaves one by one, encapsulate them into a proxy and return\n JSONPatcherProxy.prototype._proxifyObjectTreeRecursively = function(\n parent,\n root,\n path\n ) {\n for (let key in root) {\n if (root.hasOwnProperty(key)) {\n if (root[key] instanceof Object) {\n root[key] = this._proxifyObjectTreeRecursively(\n root,\n root[key],\n escapePathComponent(key)\n )\n }\n }\n }\n return this.generateProxyAtPath(parent, root, path)\n }\n // this function is for aesthetic purposes\n JSONPatcherProxy.prototype.proxifyObjectTree = function(root) {\n /*\n while proxyifying object tree,\n the proxyifying operation itself is being\n recorded, which in an unwanted behavior,\n that's why we disable recording through this\n initial process;\n */\n this.pause()\n this.isProxifyingTreeNow = true\n const proxifiedObject = this._proxifyObjectTreeRecursively(\n undefined,\n root,\n ''\n )\n /* OK you can record now */\n this.isProxifyingTreeNow = false\n this.resume()\n return proxifiedObject\n }\n /**\n * Turns a proxified object into a forward-proxy object; doesn't emit any patches anymore, like a normal object\n * @param {Proxy} proxy - The target proxy object\n */\n JSONPatcherProxy.prototype.disableTrapsForProxy = function(\n revokableProxyInstance\n ) {\n if (this.showDetachedWarning) {\n const message =\n \"You're accessing an object that is detached from the observedObject tree, see https://github.com/Palindrom/JSONPatcherProxy#detached-objects\"\n\n revokableProxyInstance.trapsInstance.set = (\n targetObject,\n propKey,\n newValue\n ) => {\n console.warn(message)\n return Reflect.set(targetObject, propKey, newValue)\n }\n revokableProxyInstance.trapsInstance.set = (\n targetObject,\n propKey,\n newValue\n ) => {\n console.warn(message)\n return Reflect.set(targetObject, propKey, newValue)\n }\n revokableProxyInstance.trapsInstance.deleteProperty = (\n targetObject,\n propKey\n ) => {\n return Reflect.deleteProperty(targetObject, propKey)\n }\n } else {\n delete revokableProxyInstance.trapsInstance.set\n delete revokableProxyInstance.trapsInstance.get\n delete revokableProxyInstance.trapsInstance.deleteProperty\n }\n }\n /**\n * Proxifies the object that was passed in the constructor and returns a proxified mirror of it. Even though both parameters are options. You need to pass at least one of them.\n * @param {Boolean} [record] - whether to record object changes to a later-retrievable patches array.\n * @param {Function} [callback] - this will be synchronously called with every object change with a single `patch` as the only parameter.\n */\n JSONPatcherProxy.prototype.observe = function(record, callback) {\n if (!record && !callback) {\n throw new Error('You need to either record changes or pass a callback')\n }\n this.isRecording = record\n this.userCallback = callback\n /*\n I moved it here to remove it from `unobserve`,\n this will also make the constructor faster, why initiate\n the array before they decide to actually observe with recording?\n They might need to use only a callback.\n */\n if (record) this.patches = []\n this.cachedProxy = this.proxifyObjectTree(this.originalObject)\n return this.cachedProxy\n }\n /**\n * If the observed is set to record, it will synchronously return all the patches and empties patches array.\n */\n JSONPatcherProxy.prototype.generate = function() {\n if (!this.isRecording) {\n throw new Error('You should set record to true to get patches later')\n }\n return this.patches.splice(0, this.patches.length)\n }\n /**\n * Revokes all proxies rendering the observed object useless and good for garbage collection @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable}\n */\n JSONPatcherProxy.prototype.revoke = function() {\n this.proxifiedObjectsMap.forEach(el => {\n el.revoke()\n })\n }\n /**\n * Disables all proxies' traps, turning the observed object into a forward-proxy object, like a normal object that you can modify silently.\n */\n JSONPatcherProxy.prototype.disableTraps = function() {\n this.proxifiedObjectsMap.forEach(this.disableTrapsForProxy, this)\n }\n return JSONPatcherProxy\n})()\n\nexport default JSONPatcherProxy\n","import JSONProxy from './proxy'\n\nexport function observe(target) {\n target.observe = true\n}\n\nexport function proxyUpdate(ele) {\n let timeout = null\n ele.data = new JSONProxy(ele.data).observe(false, info => {\n if (info.oldValue === info.value) {\n return\n }\n\n clearTimeout(timeout)\n\n timeout = setTimeout(() => {\n ele.update()\n }, 16.6)\n })\n}\n","import { cssToDom, nProps, isArray } from './util'\nimport { diff } from './vdom/diff'\nimport options from './options'\nimport { proxyUpdate } from './observe'\n\nexport default class WeElement extends HTMLElement {\n static is = 'WeElement'\n\n constructor() {\n super()\n this.props = Object.assign(\n nProps(this.constructor.props),\n this.constructor.defaultProps\n )\n this.data = this.constructor.data || {}\n }\n\n connectedCallback() {\n if (!this.constructor.pure) {\n let p = this.parentNode\n while (p && !this.store) {\n this.store = p.store\n p = p.parentNode || p.host\n }\n if (this.store) {\n this.store.instances.push(this)\n }\n }\n\n !this._isInstalled && this.install()\n let shadowRoot\n if (!this.shadowRoot) {\n shadowRoot = this.attachShadow({\n mode: 'open'\n })\n } else {\n shadowRoot = this.shadowRoot\n let fc\n while ((fc = shadowRoot.firstChild)) {\n shadowRoot.removeChild(fc)\n }\n }\n\n this.css && shadowRoot.appendChild(cssToDom(this.css()))\n !this._isInstalled && this.beforeRender()\n options.afterInstall && options.afterInstall(this)\n if (this.constructor.observe) {\n proxyUpdate(this)\n }\n this.host = diff(\n null,\n this.render(\n this.props,\n\t\t\t\tthis.data,\n\t\t\t\tthis.store\n ),\n {},\n false,\n null,\n false\n )\n if (isArray(this.host)) {\n this.host.forEach(function(item) {\n shadowRoot.appendChild(item)\n })\n } else {\n shadowRoot.appendChild(this.host)\n }\n !this._isInstalled && this.installed()\n this._isInstalled = true\n }\n\n disconnectedCallback() {\n this.uninstall()\n if (this.store) {\n for (let i = 0, len = this.store.instances.length; i < len; i++) {\n if (this.store.instances[i] === this) {\n this.store.instances.splice(i, 1)\n break\n }\n }\n }\n }\n\n update() {\n this.beforeUpdate()\n this.beforeRender()\n diff(\n this.host,\n this.render(\n this.props,\n\t\t\t\tthis.data,\n\t\t\t\tthis.store\n )\n )\n this.afterUpdate()\n }\n\n fire(name, data) {\n this.dispatchEvent(new CustomEvent(name, { detail: data }))\n }\n\n install() {}\n\n installed() {}\n\n uninstall() {}\n\n beforeUpdate() {}\n\n afterUpdate() {}\n\n beforeRender() {}\n}\n","import { diff } from './vdom/diff'\nimport JSONProxy from './proxy'\n\nexport function render(vnode, parent, store) {\n parent = typeof parent === 'string' ? document.querySelector(parent) : parent\n if (store) {\n store.instances = []\n extendStoreUpate(store)\n let timeout = null\n let patchs = {}\n store.data = new JSONProxy(store.data).observe(false, function(patch) {\n clearTimeout(timeout)\n if (patch.op === 'remove') {\n // fix arr splice\n const kv = getArrayPatch(patch.path, store)\n patchs[kv.k] = kv.v\n timeout = setTimeout(() => {\n update(patchs, store)\n patchs = {}\n }, 16.6)\n } else {\n const key = fixPath(patch.path)\n patchs[key] = patch.value\n timeout = setTimeout(() => {\n update(patchs, store)\n patchs = {}\n }, 16.6)\n }\n })\n parent.store = store\n }\n diff(null, vnode, {}, false, parent, false)\n}\n\nfunction update(patch, store) {\n store.update(patch)\n}\n\nfunction extendStoreUpate(store) {\n store.update = function(patch) {\n const updateAll = matchGlobalData(this.globalData, patch)\n\n if (Object.keys(patch).length > 0) {\n this.instances.forEach(instance => {\n if (\n updateAll ||\n this.updateAll ||\n (instance.constructor.updatePath &&\n needUpdate(patch, instance.constructor.updatePath))\n ) {\n instance.update()\n }\n })\n this.onChange && this.onChange(patch)\n }\n }\n}\n\nexport function matchGlobalData(globalData, diffResult) {\n if (!globalData) return false\n for (let keyA in diffResult) {\n if (globalData.indexOf(keyA) > -1) {\n return true\n }\n for (let i = 0, len = globalData.length; i < len; i++) {\n if (includePath(keyA, globalData[i])) {\n return true\n }\n }\n }\n return false\n}\n\nexport function needUpdate(diffResult, updatePath) {\n for (let keyA in diffResult) {\n if (updatePath[keyA]) {\n return true\n }\n for (let keyB in updatePath) {\n if (includePath(keyA, keyB)) {\n return true\n }\n }\n }\n return false\n}\n\nfunction includePath(pathA, pathB) {\n if (pathA.indexOf(pathB) === 0) {\n const next = pathA.substr(pathB.length, 1)\n if (next === '[' || next === '.') {\n return true\n }\n }\n return false\n}\n\nexport function fixPath(path) {\n let mpPath = ''\n const arr = path.replace('/', '').split('/')\n arr.forEach((item, index) => {\n if (index) {\n if (isNaN(Number(item))) {\n mpPath += '.' + item\n } else {\n mpPath += '[' + item + ']'\n }\n } else {\n mpPath += item\n }\n })\n return mpPath\n}\n\nfunction getArrayPatch(path, store) {\n const arr = path.replace('/', '').split('/')\n let current = store.data[arr[0]]\n for (let i = 1, len = arr.length; i < len - 1; i++) {\n current = current[arr[i]]\n }\n return { k: fixArrPath(path), v: current }\n}\n\nfunction fixArrPath(path) {\n let mpPath = ''\n const arr = path.replace('/', '').split('/')\n const len = arr.length\n arr.forEach((item, index) => {\n if (index < len - 1) {\n if (index) {\n if (isNaN(Number(item))) {\n mpPath += '.' + item\n } else {\n mpPath += '[' + item + ']'\n }\n } else {\n mpPath += item\n }\n }\n })\n return mpPath\n}\n","import WeElement from './we-element'\nimport { cssToDom } from './util'\n\nconst OBJECTTYPE = '[object Object]'\nconst ARRAYTYPE = '[object Array]'\n\nexport function define(name, ctor) {\n if (ctor.is === 'WeElement') {\n customElements.define(name, ctor)\n if (ctor.data && !ctor.pure) {\n ctor.updatePath = getUpdatePath(ctor.data)\n }\n } else {\n class Element extends WeElement {\n _useId = 0\n\n _useMap = {}\n\n render(props, data) {\n return ctor.call(this, props, data)\n }\n\n beforeRender() {\n this._useId = 0\n }\n\n useCss(css) {\n const style = this.shadowRoot.querySelector('style')\n style && this.shadowRoot.removeChild(style)\n this.shadowRoot.appendChild(cssToDom(css))\n }\n\n useData(data) {\n return this.use({ data: data })\n }\n\n use(option) {\n this._useId++\n const updater = newValue => {\n const item = this._useMap[updater.id]\n\n item.data = newValue\n\n this.update()\n item.effect && item.effect()\n }\n\n updater.id = this._useId\n if (!this._isInstalled) {\n this._useMap[this._useId] = option\n return [option.data, updater]\n }\n\n return [this._useMap[this._useId].data, updater]\n }\n\n installed() {\n this._isInstalled = true\n }\n }\n customElements.define(name, Element)\n }\n}\n\nexport function getUpdatePath(data) {\n const result = {}\n dataToPath(data, result)\n return result\n}\n\nfunction dataToPath(data, result) {\n Object.keys(data).forEach(key => {\n result[key] = true\n const type = Object.prototype.toString.call(data[key])\n if (type === OBJECTTYPE) {\n _objToPath(data[key], key, result)\n } else if (type === ARRAYTYPE) {\n _arrayToPath(data[key], key, result)\n }\n })\n}\n\nfunction _objToPath(data, path, result) {\n Object.keys(data).forEach(key => {\n result[path + '.' + key] = true\n delete result[path]\n const type = Object.prototype.toString.call(data[key])\n if (type === OBJECTTYPE) {\n _objToPath(data[key], path + '.' + key, result)\n } else if (type === ARRAYTYPE) {\n _arrayToPath(data[key], path + '.' + key, result)\n }\n })\n}\n\nfunction _arrayToPath(data, path, result) {\n data.forEach((item, index) => {\n result[path + '[' + index + ']'] = true\n delete result[path]\n const type = Object.prototype.toString.call(item)\n if (type === OBJECTTYPE) {\n _objToPath(item, path + '[' + index + ']', result)\n } else if (type === ARRAYTYPE) {\n _arrayToPath(item, path + '[' + index + ']', result)\n }\n })\n}\n","import { define } from './define'\n\nexport function tag(name, pure) {\n return function(target) {\n target.pure = pure\n define(name, target)\n }\n}\n","import { extend } from './util'\nimport { h } from './h'\n\n/**\n * Clones the given VNode, optionally adding attributes/props and replacing its children.\n * @param {VNode} vnode\t\tThe virtual DOM element to clone\n * @param {Object} props\tAttributes/props to add when cloning\n * @param {VNode} rest\t\tAny additional arguments will be used as replacement children.\n */\nexport function cloneElement(vnode, props) {\n return h(\n vnode.nodeName,\n extend(extend({}, vnode.attributes), props),\n arguments.length > 2 ? [].slice.call(arguments, 2) : vnode.children\n )\n}\n","export function getHost(ele) {\n let p = ele.parentNode\n while (p) {\n if (p.host) {\n return p.host\n } else {\n p = p.parentNode\n }\n }\n}\n","import { h, h as createElement } from './h'\nimport options from './options'\nimport WeElement from './we-element'\nimport { render } from './render'\nimport { define } from './define'\nimport { tag } from './tag'\nimport { observe } from './observe'\nimport { cloneElement } from './clone-element'\nimport { getHost } from './get-host'\n\nconst Component = WeElement\n\nconst omi = {\n tag,\n WeElement,\n Component,\n render,\n h,\n createElement,\n options,\n define,\n observe,\n cloneElement,\n getHost\n}\n\noptions.root.Omi = omi\noptions.root.Omi.version = '4.0.22'\n\nexport default omi\n\nexport {\n tag,\n WeElement,\n Component,\n render,\n h,\n createElement,\n options,\n define,\n observe,\n cloneElement,\n getHost\n}\n","import { render, WeElement, define } from '../../src/omi'\n\ndefine('todo-list', class extends WeElement {\n render(props) {\n return (\n
    \n {props.items.map(item => (\n
  • {item.text}
  • \n ))}\n
\n )\n }\n})\n\ndefine('todo-app', class extends WeElement {\n static get data() {\n return {\n showList: null,\n items: null,\n text: null,\n firstName: null,\n lastName: null\n }\n }\n\n render(props, data, store) {\n return (\n
\n

TODO by {store.data.fullName()}

\n {store.data.showList && }\n
\n \n \n
\n
\n )\n }\n\n handleChange = e => {\n this.store.data.text = e.target.value\n }\n\n handleSubmit = e => {\n e.preventDefault()\n this.store.add()\n }\n\n installed() {\n setTimeout(() => {\n this.store.rename()\n }, 2000)\n\n setTimeout(() => {\n this.store.data.items.push({ text: 'abc' })\n }, 4000)\n\n setTimeout(() => {\n this.store.data.items[2].text = 'changed'\n }, 6000)\n\n setTimeout(() => {\n this.store.data.items.splice(1, 1)\n }, 8000)\n\n setTimeout(() => {\n this.store.data.showList = false\n }, 10000)\n\n setTimeout(() => {\n this.store.data.showList = true\n }, 12000)\n }\n})\n\nconst store = {\n data: {\n showList: true,\n items: [{ text: 'Omi', id: Date.now() }, { text: 'JSX', id: Date.now() }],\n text: '',\n firstName: 'dnt',\n lastName: 'zhang',\n fullName: function() {\n return this.firstName + this.lastName\n }\n },\n rename: function() {\n this.data.firstName = 'Dnt'\n },\n add: function() {\n if (!this.data.text.trim().length) {\n return\n }\n this.data.items.push({\n text: this.data.text,\n id: Date.now()\n })\n this.data.text = ''\n }\n}\n\nrender(, 'body', store)\n"],"names":["VNode","getGlobal","global","Math","Array","self","window","store","root","stack","EMPTY_CHILDREN","h","nodeName","attributes","children","lastSimple","child","simple","i","arguments","length","push","pop","undefined","String","p","key","options","vnode","Reflect","customElements","hasOwnProperty","BuiltInHTMLElement","HTMLElement","construct","constructor","prototype","Object","setPrototypeOf","cssToDom","css","node","document","createElement","textContent","npn","str","replace","$","$1","toUpperCase","extend","obj","props","applyRef","ref","value","current","defer","Promise","resolve","then","bind","setTimeout","isArray","toString","call","nProps","result","keys","forEach","ATTR_KEY","IS_NON_DIMENSIONAL","isSameNodeType","hydrating","splitText","_componentConstructor","isNamedNode","normalizedNodeName","toLowerCase","createNode","isSvg","createElementNS","removeNode","parentNode","removeChild","setAccessor","name","old","className","style","cssText","test","innerHTML","__html","useCapture","substring","addEventListener","eventProxy","removeEventListener","_listeners","e","removeAttribute","ns","removeAttributeNS","setAttributeNS","setAttribute","type","event","diffLevel","isSvgMode","diff","dom","context","mountAll","parent","componentRoot","ret","ownerSVGElement","domLength","vnodeLength","maxLength","idiff","item","appendChild","out","prevSvgMode","_component","nodeValue","createTextNode","replaceChild","recollectNodeTree","vnodeName","firstChild","fc","vchildren","a","nextSibling","is","noSlot","innerDiffNode","dangerouslySetInnerHTML","diffAttributes","isHydrating","originalChildren","childNodes","keyed","keyedLen","min","len","childrenLen","vlen","j","c","f","vchild","__key","trim","insertBefore","unmountOnly","removeChildren","lastChild","next","previousSibling","attrs","update","isWeElement","JSONPatcherProxy","deepClone","JSON","parse","stringify","escapePathComponent","indexOf","findObjectPath","instance","pathComponents","parentAndPath","parenthoodMap","get","path","unshift","join","setTrap","target","newValue","parentPath","destinationPropKey","proxifiedObjectsMap","has","newValueOriginalObject","set","originalObject","revokableInstance","isProxifyingTreeNow","inherited","_proxifyObjectTreeRecursively","operation","op","oldValue","delete","disableTrapsForProxy","Number","isInteger","console","warn","reflectionResult","defaultCallback","deleteTrap","revokableProxyInstance","deleteProperty","resume","isRecording","patches","userCallback","isObserving","pause","showDetachedWarning","Map","cachedProxy","generateProxyAtPath","traps","receiver","revocableInstance","Proxy","revocable","trapsInstance","proxy","proxifyObjectTree","proxifiedObject","message","targetObject","propKey","observe","record","callback","Error","generate","splice","revoke","el","disableTraps","proxyUpdate","ele","timeout","data","JSONProxy","info","clearTimeout","WeElement","assign","defaultProps","connectedCallback","pure","host","instances","_isInstalled","install","shadowRoot","attachShadow","mode","beforeRender","afterInstall","render","installed","disconnectedCallback","uninstall","beforeUpdate","afterUpdate","fire","dispatchEvent","CustomEvent","detail","querySelector","extendStoreUpate","patchs","patch","kv","getArrayPatch","k","v","fixPath","updateAll","matchGlobalData","globalData","updatePath","needUpdate","onChange","diffResult","keyA","includePath","keyB","pathA","pathB","substr","mpPath","arr","split","index","isNaN","fixArrPath","OBJECTTYPE","ARRAYTYPE","define","ctor","getUpdatePath","Element","_useId","_useMap","useCss","useData","use","option","updater","id","effect","dataToPath","_objToPath","_arrayToPath","tag","cloneElement","slice","getHost","Component","omi","Omi","version","items","map","text","handleChange","handleSubmit","preventDefault","add","fullName","showList","rename","firstName","lastName","Date","now"],"mappings":";;;EAAA;AACA,EAAO,SAASA,KAAT,GAAiB;;ECDxB,SAASC,SAAT,GAAqB;EACnB,MACE,OAAOC,MAAP,KAAkB,QAAlB,IACA,CAACA,MADD,IAEAA,OAAOC,IAAP,KAAgBA,IAFhB,IAGAD,OAAOE,KAAP,KAAiBA,KAJnB,EAKE;EACA,WACEC,QACAC,MADA,IAEAJ,MAFA,IAGC,YAAW;EACV,aAAO,IAAP;EACD,KAFD,EAJF;EAQD;EACD,SAAOA,MAAP;EACD;;EAED;;;;AAIA,gBAAe;EACbK,SAAO,IADM;EAEbC,QAAMP;EAFO,CAAf;;ECpBA,IAAMQ,QAAQ,EAAd;EACA,IAAMC,iBAAiB,EAAvB;;AAEA,EAAO,SAASC,CAAT,CAAWC,QAAX,EAAqBC,UAArB,EAAiC;EACtC,MAAIC,WAAWJ,cAAf;EAAA,MACEK,mBADF;EA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,IAFF;EAGLE,cAAM,IAHD;EAILQ,mBAAW,IAJN;EAKLC,kBAAU;EALL,OAAP;EAOD;EATH;;EAAA;EAAA,EAAiCzF,SAAjC;;EA4DA,IAAMlP,QAAQ;EACZ8O,QAAM;EACJ0F,cAAU,IADN;EAEJR,WAAO,CAAC,EAAEE,MAAM,KAAR,EAAef,IAAIyB,KAAKC,GAAL,EAAnB,EAAD,EAAkC,EAAEX,MAAM,KAAR,EAAef,IAAIyB,KAAKC,GAAL,EAAnB,EAAlC,CAFH;EAGJX,UAAM,EAHF;EAIJQ,eAAW,KAJP;EAKJC,cAAU,OALN;EAMJJ,cAAU,oBAAW;EACnB,aAAO,KAAKG,SAAL,GAAiB,KAAKC,QAA7B;EACD;EARG,GADM;EAWZF,UAAQ,kBAAW;EACjB,SAAK3F,IAAL,CAAU4F,SAAV,GAAsB,KAAtB;EACD,GAbW;EAcZJ,OAAK,eAAW;EACd,QAAI,CAAC,KAAKxF,IAAL,CAAUoF,IAAV,CAAe5K,IAAf,GAAsBzI,MAA3B,EAAmC;EACjC;EACD;EACD,SAAKiO,IAAL,CAAUkF,KAAV,CAAgBlT,IAAhB,CAAqB;EACnBoT,YAAM,KAAKpF,IAAL,CAAUoF,IADG;EAEnBf,UAAIyB,KAAKC,GAAL;EAFe,KAArB;EAIA,SAAK/F,IAAL,CAAUoF,IAAV,GAAiB,EAAjB;EACD;EAvBW,CAAd;;EA0BAlE,OAAO,uBAAP,EAAqB,MAArB,EAA6BhQ,KAA7B;;;;"} \ No newline at end of file diff --git a/packages/omi/examples/store/main.js b/packages/omi/examples/store/main.js index fbb95fbc6..14b9b0068 100644 --- a/packages/omi/examples/store/main.js +++ b/packages/omi/examples/store/main.js @@ -1,7 +1,6 @@ -import { render, WeElement, tag } from '../../src/omi' +import { render, WeElement, define } from '../../src/omi' -@tag('todo-list', true) -class TodoList extends WeElement { +define('todo-list', class extends WeElement { render(props) { return (
    @@ -11,10 +10,9 @@ class TodoList extends WeElement {
) } -} +}) -@tag('todo-app') -class TodoApp extends WeElement { +define('todo-app', class extends WeElement { static get data() { return { showList: null, @@ -25,14 +23,18 @@ class TodoApp extends WeElement { } } - render(props, data) { + render(props, data, store) { return (
-

TODO by {data.fullName()}

- {data.showList && } +

TODO by {store.data.fullName()}

+ {store.data.showList && }
- - + +
) @@ -72,7 +74,7 @@ class TodoApp extends WeElement { this.store.data.showList = true }, 12000) } -} +}) const store = { data: { diff --git a/packages/omi/src/tag.js b/packages/omi/src/tag.js index 7652f42db..f8b763293 100644 --- a/packages/omi/src/tag.js +++ b/packages/omi/src/tag.js @@ -1,5 +1,5 @@ import { define } from './define' -import WeElement from './we-element' + export function tag(name, pure) { return function(target) { target.pure = pure diff --git a/packages/omi/src/we-element.js b/packages/omi/src/we-element.js index 4c44e55da..bf5ac3b24 100644 --- a/packages/omi/src/we-element.js +++ b/packages/omi/src/we-element.js @@ -49,10 +49,7 @@ export default class WeElement extends HTMLElement { } this.host = diff( null, - this.render( - this.props, - !this.constructor.pure && this.store ? this.store.data : this.data - ), + this.render(this.props, this.data, this.store), {}, false, null, @@ -84,13 +81,7 @@ export default class WeElement extends HTMLElement { update() { this.beforeUpdate() this.beforeRender() - diff( - this.host, - this.render( - this.props, - !this.constructor.pure && this.store ? this.store.data : this.data - ) - ) + diff(this.host, this.render(this.props, this.data, this.store)) this.afterUpdate() }