ractive
Version:
Next-generation DOM manipulation
1 lines • 907 kB
Source Map (JSON)
{"version":3,"file":"runtime.mjs","sources":["../../../src/polyfills/Object.assign.js","../../../src/utils/object.js","../../../src/utils/is.js","../../../src/polyfills/array.find.js","../../../src/polyfills/node.contains.js","../../../src/polyfills/performance.now.js","../../../src/config/environment.js","../../../src/polyfills/Promise.js","../../../src/polyfills/requestAnimationFrame.js","../../../src/Ractive/config/defaults.js","../../../src/Ractive/static/easing.js","../../../src/utils/noop.js","../../../src/utils/log.js","../../../src/config/errors.js","../../../src/shared/registry.js","../../../src/shared/interpolate.js","../../../src/Ractive/static/interpolators.js","../../../src/shared/keypaths.js","../../../src/utils/array.js","../../../src/utils/bind.js","../../../src/model/ModelBase.js","../../../src/global/capture.js","../../../src/shared/methodCallers.js","../../../src/shared/rebind.js","../../../src/model/LinkModel.js","../../../src/parse/utils/createFunction.js","../../../src/shared/getFunction.js","../../../src/parse/_parse.js","../../../src/Ractive/config/runtime-parser.js","../../../src/Ractive/helpers/getComputationSignature.js","../../../src/global/TransitionManager.js","../../../src/global/runloop.js","../../../src/shared/Ticker.js","../../../src/model/helpers/getPrefixer.js","../../../src/model/Model.js","../../../src/model/specials/SharedModel.js","../../../src/view/resolvers/resolveReference.js","../../../src/shared/getRactiveContext.js","../../../src/shared/set.js","../../../src/Ractive/prototype/shared/add.js","../../../src/Ractive/prototype/add.js","../../../src/Ractive/prototype/animate.js","../../../src/events/eventStack.js","../../../src/events/fireEvent.js","../../../src/events/Hook.js","../../../src/shared/anchors.js","../../../src/Ractive/prototype/attachChild.js","../../../src/Ractive/prototype/compute.js","../../../src/Ractive/prototype/detach.js","../../../src/Ractive/prototype/detachChild.js","../../../src/Ractive/prototype/find.js","../../../src/Ractive/prototype/findAll.js","../../../src/Ractive/prototype/findAllComponents.js","../../../src/Ractive/prototype/findComponent.js","../../../src/Ractive/prototype/findContainer.js","../../../src/Ractive/prototype/findParent.js","../../../src/config/types.js","../../../src/view/items/shared/findElement.js","../../../src/shared/getNewIndices.js","../../../src/Ractive/prototype/shared/makeArrayMethod.js","../../../src/Ractive/prototype/update.js","../../../src/shared/Context.js","../../../src/Ractive/prototype/fire.js","../../../src/Ractive/prototype/get.js","../../../src/Ractive/prototype/getLocalContext.js","../../../src/Ractive/static/getContext.js","../../../src/Ractive/prototype/getContext.js","../../../src/config/namespaces.js","../../../src/utils/dom.js","../../../src/Ractive/prototype/insert.js","../../../src/Ractive/prototype/link.js","../../../src/Ractive/prototype/observe/Observer.js","../../../src/Ractive/static/keypaths.js","../../../src/Ractive/prototype/observe/Pattern.js","../../../src/Ractive/prototype/observe/Array.js","../../../src/Ractive/prototype/observe.js","../../../src/Ractive/prototype/observeOnce.js","../../../src/Ractive/prototype/shared/trim.js","../../../src/Ractive/prototype/shared/notEmptyString.js","../../../src/Ractive/prototype/off.js","../../../src/Ractive/prototype/on.js","../../../src/Ractive/prototype/once.js","../../../src/Ractive/prototype/pop.js","../../../src/Ractive/prototype/push.js","../../../src/Ractive/prototype/readLink.js","../../../src/global/css.js","../../../src/Ractive/config/custom/adapt.js","../../../src/utils/cleanCss.js","../../../src/Ractive/config/custom/css/transform.js","../../../src/utils/id.js","../../../src/Ractive/static/styleSet.js","../../../src/model/specials/CSSModel.js","../../../src/Ractive/config/custom/css/css.js","../../../src/Ractive/config/custom/data.js","../../../src/config/template.js","../../../src/Ractive/config/custom/template.js","../../../src/Ractive/config/registries.js","../../../src/Ractive/config/wrapPrototypeMethod.js","../../../src/Ractive/config/deprecate.js","../../../src/Ractive/config/config.js","../../../src/utils/html.js","../../../src/utils/hyphenateCamel.js","../../../src/view/items/shared/Item.js","../../../src/view/helpers/specialAttrs.js","../../../src/view/items/element/attribute/getUpdateDelegate.js","../../../src/view/items/element/attribute/propertyNames.js","../../../src/view/items/element/ConditionalAttribute.js","../../../src/view/items/element/Attribute.js","../../../src/view/items/element/BindingFlag.js","../../../src/view/items/Comment.js","../../../src/Ractive/prototype/teardown.js","../../../src/model/specials/RactiveModel.js","../../../src/model/RootModel.js","../../../src/Ractive/helpers/subscribe.js","../../../src/Ractive/construct.js","../../../src/view/items/Component.js","../../../src/model/ComputationChild.js","../../../src/model/Computation.js","../../../src/view/resolvers/ExpressionProxy.js","../../../src/view/items/shared/directiveArgs.js","../../../src/view/items/element/Decorator.js","../../../src/view/items/Doctype.js","../../../src/view/items/element/binding/Binding.js","../../../src/view/items/element/binding/handleDomEvent.js","../../../src/view/items/element/binding/CheckboxBinding.js","../../../src/view/items/element/binding/getBindingGroup.js","../../../src/view/items/element/binding/CheckboxNameBinding.js","../../../src/view/items/element/binding/ContentEditableBinding.js","../../../src/view/items/element/binding/GenericBinding.js","../../../src/view/items/element/binding/FileBinding.js","../../../src/utils/getSelectedOptions.js","../../../src/view/items/element/binding/MultipleSelectBinding.js","../../../src/view/items/element/binding/NumericBinding.js","../../../src/view/items/element/binding/RadioBinding.js","../../../src/view/items/element/binding/RadioNameBinding.js","../../../src/view/items/element/binding/SingleSelectBinding.js","../../../src/view/items/element/binding/selectBinding.js","../../../src/view/items/Element.js","../../../src/view/items/element/specials/Form.js","../../../src/view/items/element/ElementEvents.js","../../../src/view/items/component/RactiveEvent.js","../../../src/view/items/shared/EventDirective.js","../../../src/view/items/shared/progressiveText.js","../../../src/view/resolvers/ReferenceExpressionProxy.js","../../../src/view/resolvers/resolve.js","../../../src/view/items/shared/Mustache.js","../../../src/view/items/Interpolator.js","../../../src/view/items/element/specials/Input.js","../../../src/parse/Parser.js","../../../src/parse/converters/expressions/primary/literal/stringLiteral/makeQuotedStringMatcher.js","../../../src/parse/converters/expressions/primary/literal/readStringLiteral.js","../../../src/parse/converters/expressions/primary/literal/readNumberLiteral.js","../../../src/parse/converters/expressions/shared/patterns.js","../../../src/parse/converters/expressions/shared/readKey.js","../../../src/utils/parseJSON.js","../../../src/view/items/component/Mapping.js","../../../src/view/items/element/specials/Option.js","../../../src/view/items/partial/getPartialTemplate.js","../../../src/view/items/Partial.js","../../../src/model/specials/KeyModel.js","../../../src/view/RepeatedFragment.js","../../../src/view/items/Section.js","../../../src/view/items/element/specials/Select.js","../../../src/view/items/element/specials/Textarea.js","../../../src/view/items/Text.js","../../../src/config/visibility.js","../../../src/view/items/element/transitions/prefix.js","../../../src/view/items/element/transitions/hyphenate.js","../../../src/view/items/element/transitions/createTransitions.js","../../../src/view/items/element/Transition.js","../../../src/view/items/triple/insertHtml.js","../../../src/view/items/Triple.js","../../../src/view/items/component/getComponentConstructor.js","../../../src/view/items/asyncProxy.js","../../../src/view/items/Await.js","../../../src/view/items/createItem.js","../../../src/view/helpers/processItems.js","../../../src/view/Fragment.js","../../../src/Ractive/initialise.js","../../../src/Ractive/render.js","../../../src/Ractive/prototype/render.js","../../../src/Ractive/prototype/reset.js","../../../src/Ractive/prototype/resetPartial.js","../../../src/Ractive/prototype/resetTemplate.js","../../../src/Ractive/prototype/reverse.js","../../../src/Ractive/prototype/set.js","../../../src/Ractive/prototype/shift.js","../../../src/Ractive/prototype/sort.js","../../../src/Ractive/prototype/splice.js","../../../src/Ractive/prototype/subtract.js","../../../src/Ractive/prototype/toggle.js","../../../src/Ractive/prototype/toCSS.js","../../../src/Ractive/prototype/toHTML.js","../../../src/Ractive/prototype/toText.js","../../../src/Ractive/prototype/transition.js","../../../src/Ractive/prototype/unlink.js","../../../src/Ractive/prototype/unrender.js","../../../src/Ractive/prototype/unshift.js","../../../src/Ractive/prototype/updateModel.js","../../../src/Ractive/prototype/use.js","../../../src/Ractive/prototype.js","../../../src/Ractive/static/isInstance.js","../../../src/Ractive/static/styleGet.js","../../../src/Ractive/static/styles.js","../../../src/Ractive/static/sharedSet.js","../../../src/Ractive/static/sharedGet.js","../../../src/Ractive/static/use.js","../../../src/extend/_extend.js","../../../src/extend/_macro.js","../../../src/Ractive/static/findPlugin.js","../../../src/Ractive.js"],"sourcesContent":["/* istanbul ignore if */\nif (!Object.assign) {\n Object.assign = function(target, ...sources) {\n if (target == null) throw new TypeError('Cannot convert undefined or null to object');\n\n const to = Object(target);\n const sourcesLength = sources.length;\n\n for (let index = 0; index < sourcesLength; index++) {\n const nextSource = sources[index];\n for (const nextKey in nextSource) {\n if (!Object.prototype.hasOwnProperty.call(nextSource, nextKey)) continue;\n to[nextKey] = nextSource[nextKey];\n }\n }\n\n return to;\n };\n}\n","export function hasOwn(obj, prop) {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nexport function fillGaps(target, ...sources) {\n for (let i = 0; i < sources.length; i++) {\n const source = sources[i];\n for (const key in source) {\n // Source can be a prototype-less object.\n if (key in target || !hasOwn(source, key)) continue;\n target[key] = source[key];\n }\n }\n\n return target;\n}\n\nexport function toPairs(obj = {}) {\n const pairs = [];\n for (const key in obj) {\n // Source can be a prototype-less object.\n if (!hasOwn(obj, key)) continue;\n pairs.push([key, obj[key]]);\n }\n return pairs;\n}\n\nconst obj = Object;\n\nexport const assign = obj.assign;\n\nexport const create = obj.create;\n\nexport const defineProperty = obj.defineProperty;\n\nexport const defineProperties = obj.defineProperties;\n\nexport const keys = obj.keys;\n","const toString = Object.prototype.toString;\nconst arrayLikePattern = /^\\[object (?:Array|FileList)\\]$/;\n\nexport function isArrayLike(obj) {\n return arrayLikePattern.test(toString.call(obj));\n}\n\nexport const isArray = Array.isArray;\n\nexport function isEqual(a, b) {\n if (a === null && b === null) {\n return true;\n }\n\n if (isObjectType(a) || isObjectType(b)) {\n return false;\n }\n\n return a === b;\n}\n\n// http://stackoverflow.com/questions/18082/validate-numbers-in-javascript-isnumeric\nexport function isNumeric(thing) {\n return !isNaN(parseFloat(thing)) && isFinite(thing);\n}\n\nexport function isObject(thing) {\n return thing && toString.call(thing) === '[object Object]';\n}\n\nexport function isObjectLike(thing) {\n return !!(thing && (isObjectType(thing) || isFunction(thing))) && !isDate(thing);\n}\n\nexport function isDate(thing) {\n return thing instanceof Date;\n}\n\nexport function isObjectType(thing) {\n return typeof thing === 'object';\n}\n\nexport function isFunction(thing) {\n return typeof thing === 'function';\n}\n\nexport function isString(thing) {\n return typeof thing === 'string';\n}\n\nexport function isNumber(thing) {\n return typeof thing === 'number';\n}\n\nexport function isUndefined(thing) {\n return thing === undefined;\n}\n","import { hasOwn, defineProperty } from 'utils/object';\nimport { isFunction, isUndefined } from 'utils/is';\n\n/* istanbul ignore if */\nif (!Array.prototype.find) {\n defineProperty(Array.prototype, 'find', {\n value(callback, thisArg) {\n if (this === null || isUndefined(this))\n throw new TypeError('Array.prototype.find called on null or undefined');\n\n if (!isFunction(callback)) throw new TypeError(`${callback} is not a function`);\n\n const array = Object(this);\n const arrayLength = array.length >>> 0;\n\n for (let index = 0; index < arrayLength; index++) {\n if (!hasOwn(array, index)) continue;\n if (!callback.call(thisArg, array[index], index, array)) continue;\n return array[index];\n }\n\n return undefined;\n },\n configurable: true,\n writable: true\n });\n}\n","// NOTE: Node doesn't exist in IE8. Nothing can be done.\n/* istanbul ignore if */\nif (\n typeof window !== 'undefined' &&\n window.Node &&\n window.Node.prototype &&\n !window.Node.prototype.contains\n) {\n Node.prototype.contains = function(node) {\n if (!node) throw new TypeError('node required');\n\n do {\n if (this === node) return true;\n } while ((node = node && node.parentNode));\n\n return false;\n };\n}\n","/* istanbul ignore if */\nif (typeof window !== 'undefined' && window.performance && !window.performance.now) {\n window.performance = window.performance || {};\n\n const nowOffset = Date.now();\n\n window.performance.now = function() {\n return Date.now() - nowOffset;\n };\n}\n","/* eslint no-console:\"off\" */\nimport { isFunction } from 'utils/is';\n\nconst win = typeof window !== 'undefined' ? window : null;\nconst doc = win ? document : null;\nconst isClient = !!doc;\nconst base = typeof global !== 'undefined' ? global : win;\nconst hasConsole =\n typeof console !== 'undefined' && isFunction(console.warn) && isFunction(console.warn.apply);\n\nconst svg = doc\n ? doc.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1')\n : false;\n\nconst vendors = ['o', 'ms', 'moz', 'webkit'];\n\nexport { win, doc, isClient, hasConsole, svg, vendors, base };\n","import { isFunction, isObjectType } from 'utils/is';\nimport { base } from 'config/environment';\n\n/* istanbul ignore if */\nif (!base.Promise) {\n const PENDING = {};\n const FULFILLED = {};\n const REJECTED = {};\n\n const Promise = (base.Promise = function(callback) {\n const fulfilledHandlers = [];\n const rejectedHandlers = [];\n let state = PENDING;\n let result;\n let dispatchHandlers;\n\n const makeResolver = newState => {\n return function(value) {\n if (state !== PENDING) return;\n result = value;\n state = newState;\n dispatchHandlers = makeDispatcher(\n state === FULFILLED ? fulfilledHandlers : rejectedHandlers,\n result\n );\n wait(dispatchHandlers);\n };\n };\n\n const fulfill = makeResolver(FULFILLED);\n const reject = makeResolver(REJECTED);\n\n try {\n callback(fulfill, reject);\n } catch (err) {\n reject(err);\n }\n\n return {\n // `then()` returns a Promise - 2.2.7\n then(onFulfilled, onRejected) {\n const promise2 = new Promise((fulfill, reject) => {\n const processResolutionHandler = (handler, handlers, forward) => {\n if (isFunction(handler)) {\n handlers.push(p1result => {\n try {\n resolve(promise2, handler(p1result), fulfill, reject);\n } catch (err) {\n reject(err);\n }\n });\n } else {\n handlers.push(forward);\n }\n };\n\n processResolutionHandler(onFulfilled, fulfilledHandlers, fulfill);\n processResolutionHandler(onRejected, rejectedHandlers, reject);\n\n if (state !== PENDING) {\n wait(dispatchHandlers);\n }\n });\n return promise2;\n },\n catch(onRejected) {\n return this.then(null, onRejected);\n },\n finally(callback) {\n return this.then(\n v => {\n callback();\n return v;\n },\n e => {\n callback();\n throw e;\n }\n );\n }\n };\n });\n\n Promise.all = function(promises) {\n return new Promise((fulfill, reject) => {\n const result = [];\n let pending;\n let i;\n\n if (!promises.length) {\n fulfill(result);\n return;\n }\n\n const processPromise = (promise, i) => {\n if (promise && isFunction(promise.then)) {\n promise.then(value => {\n result[i] = value;\n --pending || fulfill(result);\n }, reject);\n } else {\n result[i] = promise;\n --pending || fulfill(result);\n }\n };\n\n pending = i = promises.length;\n\n while (i--) {\n processPromise(promises[i], i);\n }\n });\n };\n\n Promise.race = function(promises) {\n return new Promise((fulfill, reject) => {\n let pending = true;\n function ok(v) {\n if (!pending) return;\n pending = false;\n fulfill(v);\n }\n function fail(e) {\n if (!pending) return;\n pending = false;\n reject(e);\n }\n for (let i = 0; i < promises.length; i++) {\n if (promises[i] && isFunction(promises[i].then)) {\n promises[i].then(ok, fail);\n }\n }\n });\n };\n\n Promise.resolve = function(value) {\n if (value && isFunction(value.then)) return value;\n return new Promise(fulfill => {\n fulfill(value);\n });\n };\n\n Promise.reject = function(reason) {\n if (reason && isFunction(reason.then)) return reason;\n return new Promise((fulfill, reject) => {\n reject(reason);\n });\n };\n\n // TODO use MutationObservers or something to simulate setImmediate\n const wait = function(callback) {\n setTimeout(callback, 0);\n };\n\n const makeDispatcher = function(handlers, result) {\n return function() {\n for (let handler; (handler = handlers.shift()); ) {\n handler(result);\n }\n };\n };\n\n const resolve = function(promise, x, fulfil, reject) {\n let then;\n if (x === promise) {\n throw new TypeError(`A promise's fulfillment handler cannot return the same promise`);\n }\n if (x instanceof Promise) {\n x.then(fulfil, reject);\n } else if (x && (isObjectType(x) || isFunction(x))) {\n try {\n then = x.then;\n } catch (e) {\n reject(e);\n return;\n }\n if (isFunction(then)) {\n let called;\n\n const resolvePromise = function(y) {\n if (called) return;\n called = true;\n resolve(promise, y, fulfil, reject);\n };\n const rejectPromise = function(r) {\n if (called) return;\n called = true;\n reject(r);\n };\n\n try {\n then.call(x, resolvePromise, rejectPromise);\n } catch (e) {\n if (!called) {\n reject(e);\n called = true;\n return;\n }\n }\n } else {\n fulfil(x);\n }\n } else {\n fulfil(x);\n }\n };\n}\n","/* istanbul ignore if */\nif (\n typeof window !== 'undefined' &&\n !(window.requestAnimationFrame && window.cancelAnimationFrame)\n) {\n let lastTime = 0;\n window.requestAnimationFrame = function(callback) {\n const currentTime = Date.now();\n const timeToNextCall = Math.max(0, 16 - (currentTime - lastTime));\n const id = window.setTimeout(() => {\n callback(currentTime + timeToNextCall);\n }, timeToNextCall);\n lastTime = currentTime + timeToNextCall;\n return id;\n };\n window.cancelAnimationFrame = function(id) {\n clearTimeout(id);\n };\n}\n","import { create } from 'utils/object';\n\nexport default {\n // render placement:\n el: void 0,\n append: false,\n delegate: true,\n enhance: false,\n\n // template:\n template: null,\n\n // parse:\n allowExpressions: true,\n delimiters: ['{{', '}}'],\n tripleDelimiters: ['{{{', '}}}'],\n staticDelimiters: ['[[', ']]'],\n staticTripleDelimiters: ['[[[', ']]]'],\n csp: true,\n interpolate: false,\n preserveWhitespace: false,\n preserveStandaloneSections: false,\n sanitize: false,\n stripComments: true,\n contextLines: 0,\n\n // data & binding:\n data: create(null),\n helpers: create(null),\n computed: create(null),\n syncComputedChildren: false,\n resolveInstanceMembers: false,\n warnAboutAmbiguity: false,\n adapt: [],\n isolated: true,\n twoway: true,\n lazy: false,\n\n // transitions:\n noIntro: false,\n noOutro: false,\n transitionsEnabled: true,\n complete: void 0,\n nestedTransitions: true,\n\n // css:\n css: null,\n noCSSTransform: false\n};\n","// These are a subset of the easing equations found at\n// https://raw.github.com/danro/easing-js - license info\n// follows:\n\n// --------------------------------------------------\n// easing.js v0.5.4\n// Generic set of easing functions with AMD support\n// https://github.com/danro/easing-js\n// This code may be freely distributed under the MIT license\n// http://danro.mit-license.org/\n// --------------------------------------------------\n// All functions adapted from Thomas Fuchs & Jeremy Kahn\n// Easing Equations (c) 2003 Robert Penner, BSD license\n// https://raw.github.com/danro/easing-js/master/LICENSE\n// --------------------------------------------------\n\n// In that library, the functions named easeIn, easeOut, and\n// easeInOut below are named easeInCubic, easeOutCubic, and\n// (you guessed it) easeInOutCubic.\n//\n// You can add additional easing functions to this list, and they\n// will be globally available.\n\nexport default {\n linear(pos) {\n return pos;\n },\n easeIn(pos) {\n /* istanbul ignore next */\n return Math.pow(pos, 3);\n },\n easeOut(pos) {\n return Math.pow(pos - 1, 3) + 1;\n },\n easeInOut(pos) {\n /* istanbul ignore next */\n if ((pos /= 0.5) < 1) {\n return 0.5 * Math.pow(pos, 3);\n }\n /* istanbul ignore next */\n return 0.5 * (Math.pow(pos - 2, 3) + 2);\n }\n};\n","export default function() {}\n","/* global console */\n/* eslint no-console:\"off\" */\n\nimport { hasConsole } from '../config/environment';\nimport Ractive from '../Ractive';\nimport noop from './noop';\nimport { isObjectType } from 'utils/is';\n\nconst alreadyWarned = {};\nlet log, printWarning, welcome;\n\nif (hasConsole) {\n const welcomeIntro = [\n `%cRactive.js %c1.4.4 %cin debug mode, %cmore...`,\n 'color: rgb(114, 157, 52); font-weight: normal;',\n 'color: rgb(85, 85, 85); font-weight: normal;',\n 'color: rgb(85, 85, 85); font-weight: normal;',\n 'color: rgb(82, 140, 224); font-weight: normal; text-decoration: underline;'\n ];\n const welcomeMessage = `You're running Ractive 1.4.4 in debug mode - messages will be printed to the console to help you fix problems and optimise your application.\n\nTo disable debug mode, add this line at the start of your app:\n Ractive.DEBUG = false;\n\nTo disable debug mode when your app is minified, add this snippet:\n Ractive.DEBUG = /unminified/.test(function(){/*unminified*/});\n\nGet help and support:\n http://ractive.js.org\n http://stackoverflow.com/questions/tagged/ractivejs\n http://groups.google.com/forum/#!forum/ractive-js\n http://twitter.com/ractivejs\n\nFound a bug? Raise an issue:\n https://github.com/ractivejs/ractive/issues\n\n`;\n\n welcome = () => {\n if (Ractive.WELCOME_MESSAGE === false) {\n welcome = noop;\n return;\n }\n const message = 'WELCOME_MESSAGE' in Ractive ? Ractive.WELCOME_MESSAGE : welcomeMessage;\n const hasGroup = !!console.groupCollapsed;\n if (hasGroup) console.groupCollapsed.apply(console, welcomeIntro);\n console.log(message);\n if (hasGroup) {\n console.groupEnd(welcomeIntro);\n }\n\n welcome = noop;\n };\n\n printWarning = (message, args) => {\n welcome();\n\n // extract information about the instance this message pertains to, if applicable\n if (isObjectType(args[args.length - 1])) {\n const options = args.pop();\n const ractive = options ? options.ractive : null;\n\n if (ractive) {\n // if this is an instance of a component that we know the name of, add\n // it to the message\n let name;\n if (ractive.component && (name = ractive.component.name)) {\n message = `<${name}> ${message}`;\n }\n\n let node;\n if (\n (node =\n options.node || (ractive.fragment && ractive.fragment.rendered && ractive.find('*')))\n ) {\n args.push(node);\n }\n }\n }\n\n console.warn.apply(\n console,\n ['%cRactive.js: %c' + message, 'color: rgb(114, 157, 52);', 'color: rgb(85, 85, 85);'].concat(\n args\n )\n );\n };\n\n log = function() {\n console.log.apply(console, arguments);\n };\n} else {\n printWarning = log = welcome = noop;\n}\n\nfunction format(message, args) {\n return message.replace(/%s/g, () => args.shift());\n}\n\nfunction fatal(message, ...args) {\n message = format(message, args);\n throw new Error(message);\n}\n\nfunction logIfDebug() {\n if (Ractive.DEBUG) {\n log.apply(null, arguments);\n }\n}\n\nfunction warn(message, ...args) {\n message = format(message, args);\n printWarning(message, args);\n}\n\nfunction warnOnce(message, ...args) {\n message = format(message, args);\n\n if (alreadyWarned[message]) {\n return;\n }\n\n alreadyWarned[message] = true;\n printWarning(message, args);\n}\n\nfunction warnIfDebug() {\n if (Ractive.DEBUG) {\n warn.apply(null, arguments);\n }\n}\n\nfunction warnOnceIfDebug() {\n if (Ractive.DEBUG) {\n warnOnce.apply(null, arguments);\n }\n}\n\nexport { fatal, log, logIfDebug, warn, warnOnce, warnIfDebug, warnOnceIfDebug, welcome };\n","// Error messages that are used (or could be) in multiple places\nexport const badArguments = 'Bad arguments';\nexport const noRegistryFunctionReturn =\n 'A function was specified for \"%s\" %s, but no %s was returned';\nexport const missingPlugin = (name, type) =>\n `Missing \"${name}\" ${type} plugin. You may need to download a plugin via http://ractive.js.org/integrations/#${type}s`;\n","export function findInViewHierarchy(registryName, ractive, name) {\n const instance = findInstance(registryName, ractive, name);\n return instance ? instance[registryName][name] : null;\n}\n\nexport function findInstance(registryName, ractive, name) {\n while (ractive) {\n if (name in ractive[registryName]) {\n return ractive;\n }\n\n if (ractive.isolated) {\n return null;\n }\n\n ractive = ractive.parent;\n }\n}\n","import { fatal } from 'utils/log';\nimport { missingPlugin } from 'config/errors';\nimport interpolators from '../Ractive/static/interpolators';\nimport { findInViewHierarchy } from './registry';\n\nexport default function interpolate(from, to, ractive, type) {\n if (from === to) return null;\n\n if (type) {\n const interpol = findInViewHierarchy('interpolators', ractive, type);\n if (interpol) return interpol(from, to) || null;\n\n fatal(missingPlugin(type, 'interpolator'));\n }\n\n return (\n interpolators.number(from, to) ||\n interpolators.array(from, to) ||\n interpolators.object(from, to) ||\n null\n );\n}\n","import { isArray, isObject, isNumeric } from 'utils/is';\nimport interpolate from 'shared/interpolate';\nimport { hasOwn } from 'utils/object';\n\nconst interpolators = {\n number(from, to) {\n if (!isNumeric(from) || !isNumeric(to)) {\n return null;\n }\n\n from = +from;\n to = +to;\n\n const delta = to - from;\n\n if (!delta) {\n return function() {\n return from;\n };\n }\n\n return function(t) {\n return from + t * delta;\n };\n },\n\n array(from, to) {\n let len, i;\n\n if (!isArray(from) || !isArray(to)) {\n return null;\n }\n\n const intermediate = [];\n const interpolators = [];\n\n i = len = Math.min(from.length, to.length);\n while (i--) {\n interpolators[i] = interpolate(from[i], to[i]);\n }\n\n // surplus values - don't interpolate, but don't exclude them either\n for (i = len; i < from.length; i += 1) {\n intermediate[i] = from[i];\n }\n\n for (i = len; i < to.length; i += 1) {\n intermediate[i] = to[i];\n }\n\n return function(t) {\n let i = len;\n\n while (i--) {\n intermediate[i] = interpolators[i](t);\n }\n\n return intermediate;\n };\n },\n\n object(from, to) {\n if (!isObject(from) || !isObject(to)) {\n return null;\n }\n\n const properties = [];\n const intermediate = {};\n const interpolators = {};\n\n for (const prop in from) {\n if (hasOwn(from, prop)) {\n if (hasOwn(to, prop)) {\n properties.push(prop);\n interpolators[prop] = interpolate(from[prop], to[prop]) || (() => to[prop]);\n } else {\n intermediate[prop] = from[prop];\n }\n }\n }\n\n for (const prop in to) {\n if (hasOwn(to, prop) && !hasOwn(from, prop)) {\n intermediate[prop] = to[prop];\n }\n }\n\n const len = properties.length;\n\n return function(t) {\n let i = len;\n\n while (i--) {\n const prop = properties[i];\n\n intermediate[prop] = interpolators[prop](t);\n }\n\n return intermediate;\n };\n }\n};\n\nexport default interpolators;\n","import { isString } from 'utils/is';\n\nconst refPattern = /\\[\\s*(\\*|[0-9]|[1-9][0-9]+)\\s*\\]/g;\nconst splitPattern = /([^\\\\](?:\\\\\\\\)*)\\./;\nconst escapeKeyPattern = /\\\\|\\./g;\nconst unescapeKeyPattern = /((?:\\\\)+)\\1|\\\\(\\.)/g;\n\nexport function escapeKey(key) {\n if (isString(key)) {\n return key.replace(escapeKeyPattern, '\\\\$&');\n }\n\n return key;\n}\n\nexport function normalise(ref) {\n return ref ? ref.replace(refPattern, '.$1') : '';\n}\n\nexport function splitKeypath(keypath) {\n const result = [];\n let match;\n\n keypath = normalise(keypath);\n\n while ((match = splitPattern.exec(keypath))) {\n const index = match.index + match[1].length;\n result.push(keypath.substr(0, index));\n keypath = keypath.substr(index + 1);\n }\n\n result.push(keypath);\n\n return result;\n}\n\nexport function unescapeKey(key) {\n if (isString(key)) {\n return key.replace(unescapeKeyPattern, '$1$2');\n }\n\n return key;\n}\n","import { isArray, isString, isUndefined } from './is';\n\nexport function addToArray(array, value) {\n const index = array.indexOf(value);\n\n if (index === -1) {\n array.push(value);\n }\n}\n\nexport function arrayContains(array, value) {\n for (let i = 0, c = array.length; i < c; i++) {\n if (array[i] == value) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function arrayContentsMatch(a, b) {\n let i;\n\n if (!isArray(a) || !isArray(b)) {\n return false;\n }\n\n if (a.length !== b.length) {\n return false;\n }\n\n i = a.length;\n while (i--) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function ensureArray(x) {\n if (isString(x)) {\n return [x];\n }\n\n if (isUndefined(x)) {\n return [];\n }\n\n return x;\n}\n\nexport function lastItem(array) {\n return array[array.length - 1];\n}\n\nexport function removeFromArray(array, member) {\n if (!array) {\n return;\n }\n\n const index = array.indexOf(member);\n\n if (index !== -1) {\n array.splice(index, 1);\n }\n}\n\nexport function combine(...arrays) {\n const res = arrays.concat.apply([], arrays);\n let i = res.length;\n while (i--) {\n const idx = res.indexOf(res[i]);\n if (~idx && idx < i) res.splice(i, 1);\n }\n\n return res;\n}\n\nexport function toArray(arrayLike) {\n const array = [];\n let i = arrayLike.length;\n while (i--) {\n array[i] = arrayLike[i];\n }\n\n return array;\n}\n\nexport function findMap(array, fn) {\n const len = array.length;\n for (let i = 0; i < len; i++) {\n const result = fn(array[i]);\n if (result) return result;\n }\n}\n\nexport function buildNewIndices(one, two, comparator) {\n let oldArray = one;\n let newArray = two;\n if (comparator) {\n oldArray = oldArray.map(comparator);\n newArray = newArray.map(comparator);\n }\n\n const oldLength = oldArray.length;\n\n const usedIndices = {};\n let firstUnusedIndex = 0;\n\n const result = oldArray.map(item => {\n let index;\n let start = firstUnusedIndex;\n\n do {\n index = newArray.indexOf(item, start);\n\n if (index === -1) {\n return -1;\n }\n\n start = index + 1;\n } while (usedIndices[index] === true && start < oldLength);\n\n // keep track of the first unused index, so we don't search\n // the whole of newArray for each item in oldArray unnecessarily\n if (index === firstUnusedIndex) {\n firstUnusedIndex += 1;\n }\n // allow next instance of next \"equal\" to be found item\n usedIndices[index] = true;\n return index;\n });\n\n const len = (result.oldLen = oldArray.length);\n result.newLen = newArray.length;\n\n if (len === result.newLen) {\n let i = 0;\n for (i; i < len; i++) {\n if (result[i] !== i) break;\n }\n\n if (i === len) result.same = true;\n }\n\n return result;\n}\n","const fnBind = Function.prototype.bind;\n\nexport default function bind(fn, context) {\n if (!/this/.test(fn.toString())) return fn;\n\n const bound = fnBind.call(fn, context);\n for (const prop in fn) bound[prop] = fn[prop];\n\n return bound;\n}\n","import { escapeKey, unescapeKey } from 'shared/keypaths';\nimport { addToArray, removeFromArray } from 'utils/array';\nimport { isArray, isObject, isObjectLike, isFunction } from 'utils/is';\nimport bind from 'utils/bind';\nimport { create, keys as objectKeys } from 'utils/object';\n\nconst shuffleTasks = { early: [], mark: [] };\nconst registerQueue = { early: [], mark: [] };\nexport const noVirtual = { virtual: false };\n\nexport default class ModelBase {\n constructor(parent) {\n this.deps = [];\n\n this.children = [];\n this.childByKey = {};\n this.links = [];\n\n this.bindings = [];\n\n if (parent) {\n this.parent = parent;\n this.root = parent.root;\n }\n }\n\n addShuffleTask(task, stage = 'early') {\n shuffleTasks[stage].push(task);\n }\n addShuffleRegister(item, stage = 'early') {\n registerQueue[stage].push({ model: this, item });\n }\n\n downstreamChanged() {}\n\n findMatches(keys) {\n const len = keys.length;\n\n let existingMatches = [this];\n let matches;\n let i;\n\n for (i = 0; i < len; i += 1) {\n const key = keys[i];\n\n if (key === '*') {\n matches = [];\n existingMatches.forEach(model => {\n matches.push.apply(matches, model.getValueChildren(model.get()));\n });\n } else {\n matches = existingMatches.map(model => model.joinKey(key));\n }\n\n existingMatches = matches;\n }\n\n return matches;\n }\n\n getKeypath(ractive) {\n if (ractive !== this.ractive && this._link) return this._link.target.getKeypath(ractive);\n\n if (!this.keypath) {\n const parent = this.parent && this.parent.getKeypath(ractive);\n this.keypath = parent\n ? `${this.parent.getKeypath(ractive)}.${escapeKey(this.key)}`\n : escapeKey(this.key);\n }\n\n return this.keypath;\n }\n\n getValueChildren(value) {\n let children;\n if (isArray(value)) {\n children = [];\n if ('length' in this && this.length !== value.length) {\n children.push(this.joinKey('length'));\n }\n value.forEach((m, i) => {\n children.push(this.joinKey(i));\n });\n } else if (isObject(value) || isFunction(value)) {\n children = objectKeys(value).map(key => this.joinKey(escapeKey(key)));\n } else if (value != null) {\n children = [];\n }\n\n const computed = this.computed;\n if (computed) {\n children.push.apply(children, objectKeys(computed).map(k => this.joinKey(k)));\n }\n\n return children;\n }\n\n getVirtual(shouldCapture) {\n const value = this.get(shouldCapture, { virtual: false });\n if (isObjectLike(value)) {\n const result = isArray(value) ? [] : create(null);\n\n let keys = objectKeys(value);\n let i = keys.length;\n while (i--) {\n const child = this.childByKey[keys[i]];\n if (!child) result[keys[i]] = value[keys[i]];\n else if (child._link) result[keys[i]] = child._link.getVirtual();\n else result[keys[i]] = child.getVirtual();\n }\n\n i = this.children.length;\n while (i--) {\n const child = this.children[i];\n if (!(child.key in result) && child._link) {\n result[child.key] = child._link.getVirtual();\n }\n }\n\n if (this.computed) {\n keys = objectKeys(this.computed);\n i = keys.length;\n while (i--) {\n result[keys[i]] = this.computed[keys[i]].get();\n }\n }\n\n return result;\n } else return value;\n }\n\n has(key) {\n if (this._link) return this._link.has(key);\n\n const value = this.get(false, noVirtual);\n if (!value) return false;\n\n key = unescapeKey(key);\n if ((isFunction(value) || isObject(value)) && key in value) return true;\n\n let computed = this.computed;\n if (computed && key in this.computed) return true;\n\n computed = this.root.ractive && this.root.ractive.computed;\n if (computed) {\n objectKeys(computed).forEach(k => {\n if (computed[k].pattern && computed[k].pattern.test(this.getKeypath())) return true;\n });\n }\n\n return false;\n }\n\n joinAll(keys, opts) {\n let model = this;\n for (let i = 0; i < keys.length; i += 1) {\n if (\n opts &&\n opts.lastLink === false &&\n i + 1 === keys.length &&\n model.childByKey[keys[i]] &&\n model.childByKey[keys[i]]._link\n )\n return model.childByKey[keys[i]];\n model = model.joinKey(keys[i], opts);\n }\n\n return model;\n }\n\n notifyUpstream(startPath) {\n let parent = this.parent;\n const path = startPath || [this.key];\n while (parent) {\n if (parent.patterns) parent.patterns.forEach(o => o.notify(path.slice()));\n path.unshift(parent.key);\n parent.links.forEach(l => l.notifiedUpstream(path, this.root));\n parent.deps.forEach(d => d.handleChange(path));\n parent.downstreamChanged(startPath);\n parent = parent.parent;\n }\n }\n\n rebind(next, previous, safe) {\n if (this._link) {\n this._link.rebind(next, previous, false);\n }\n\n if (next === this) return;\n\n // tell the deps to move to the new target\n let i = this.deps.length;\n while (i--) {\n if (this.deps[i].rebind) this.deps[i].rebind(next, previous, safe);\n }\n\n i = this.links.length;\n while (i--) {\n const link = this.links[i];\n // only relink the root of the link tree\n if (link.owner && link.owner._link) link.relinking(next, safe);\n }\n\n i = this.children.length;\n while (i--) {\n const child = this.children[i];\n child.rebind(next ? next.joinKey(child.key) : undefined, child._link || child, safe);\n if (this.dataModel) {\n this.addShuffleTask(() => checkDataLink(this, this.retrieve()), 'early');\n }\n }\n\n i = this.bindings.length;\n while (i--) {\n this.bindings[i].rebind(next, previous, safe);\n }\n }\n\n reference() {\n 'refs' in this ? this.refs++ : (this.refs = 1);\n }\n\n register(dep) {\n this.deps.push(dep);\n }\n\n registerLink(link) {\n addToArray(this.links, link);\n }\n\n registerPatternObserver(observer) {\n (this.patterns || (this.patterns = [])).push(observer);\n this.register(observer);\n }\n\n registerTwowayBinding(binding) {\n this.bindings.push(binding);\n }\n\n unreference() {\n if ('refs' in this) this.refs--;\n }\n\n unregister(dep) {\n removeFromArray(this.deps, dep);\n }\n\n unregisterLink(link) {\n removeFromArray(this.links, link);\n }\n\n unregisterPatternObserver(observer) {\n removeFromArray(this.patterns, observer);\n this.unregister(observer);\n }\n\n unregisterTwowayBinding(binding) {\n removeFromArray(this.bindings, binding);\n }\n\n updateFromBindings(cascade) {\n let i = this.bindings.length;\n while (i--) {\n const value = this.bindings[i].getValue();\n if (value !== this.value) this.set(value);\n }\n\n // check for one-way bindings if there are no two-ways\n if (!this.bindings.length) {\n const oneway = findBoundValue(this.deps);\n if (oneway && oneway.value !== this.value) this.set(oneway.value);\n }\n\n if (cascade) {\n this.children.forEach(updateFromBindings);\n this.links.forEach(updateFromBindings);\n if (this._link) this._link.updateFromBindings(cascade);\n }\n }\n}\n\n// TODO: this may be better handled by overriding `get` on models with a parent that isRoot\nexport function maybeBind(model, value, shouldBind) {\n if (shouldBind && isFunction(value) && model.parent && model.parent.isRoot) {\n if (!model.boundValue) {\n model.boundValue = bind(value._r_unbound || value, model.parent.ractive);\n }\n\n return model.boundValue;\n }\n\n return value;\n}\n\nfunction updateFromBindings(model) {\n model.updateFromBindings(true);\n}\n\nexport function findBoundValue(list) {\n let i = list.length;\n while (i--) {\n if (list[i].bound) {\n const owner = list[i].owner;\n if (owner) {\n const value = owner.name === 'checked' ? owner.node.checked : owner.node.value;\n return { value };\n }\n }\n }\n}\n\nexport function fireShuffleTasks(stage) {\n if (!stage) {\n fireShuffleTasks('early');\n fireShuffleTasks('mark');\n } else {\n const tasks = shuffleTasks[stage];\n shuffleTasks[stage] = [];\n let i = tasks.length;\n while (i--) tasks[i]();\n\n const register = registerQueue[stage];\n registerQueue[stage] = [];\n i = register.length;\n while (i--) register[i].model.register(register[i].item);\n }\n}\n\nexport function shuffle(model, newIndices, link, unsafe) {\n model.shuffling = true;\n\n let upstream = model.source().length !== model.source().value.length;\n let i = newIndices.length;\n while (i--) {\n const idx = newIndices[i];\n // nothing is actually changing, so move in the index and roll on\n if (i === idx) {\n continue;\n }\n\n upstream = true;\n\n // rebind the children on i to idx\n if (i in model.childByKey)\n model.childByKey[i].rebind(\n !~idx ? undefined : model.joinKey(idx),\n model.childByKey[i],\n !unsafe\n );\n }\n\n model.links.forEach(l => l.shuffle(newIndices));\n if (!link) fireShuffleTasks('early');\n\n i = model.deps.length;\n while (i--) {\n if (model.deps[i].shuffle) model.deps[i].shuffle(newIndices);\n }\n\n model[link ? 'marked' : 'mark']();\n if (!link) fireShuffleTasks('mark');\n\n if (upstream) model.notifyUpstream();\n\n model.shuffling = false;\n}\n\nexport function checkDataLink(model, value) {\n if (value !== model.dataModel) {\n if (value && value.viewmodel && value.viewmodel.isRoot && model.childByKey.data) {\n model.childByKey.data.link(value.viewmodel, 'data');\n model.dataModel = value;\n } else if (model.dataModel) {\n model.childByKey.data.unlink();\n model.dataModel = true;\n }\n }\n}\n","import { addToArray } from '../utils/array';\n\nconst stack = [];\nlet captureGroup;\n\nexport function startCapturing() {\n stack.push((captureGroup = []));\n}\n\nexport function stopCapturing() {\n const dependencies = stack.pop();\n captureGroup = stack[stack.length - 1];\n return dependencies;\n}\n\nexport function capture(model) {\n if (captureGroup) {\n addToArray(captureGroup, model);\n }\n}\n","export function bind(x) {\n x.bind();\n}\nexport function cancel(x) {\n x.cancel();\n}\nexport function destroyed(x) {\n x.destroyed();\n}\nexport function handleChange(x) {\n x.handleChange();\n}\nexport function mark(x) {\n x.mark();\n}\nexport function markForce(x) {\n x.mark(true);\n}\nexport function marked(x) {\n x.marked();\n}\nexport function markedAll(x) {\n x.markedAll();\n}\nexport function render(x) {\n x.render();\n}\nexport function shuffled(x) {\n x.shuffled();\n}\nexport function teardown(x) {\n x.teardown();\n}\nexport function unbind(x) {\n x.unbind();\n}\nexport function unrender(x) {\n x.unrender();\n}\nexport function unrenderAndDestroy(x) {\n x.unrender(true);\n}\nexport function update(x) {\n x.update();\n}\nexport function toString(x) {\n return x.toString();\n}\nexport function toEscapedString(x) {\n return x.toString(true);\n}\n","import { splitKeypath } from './keypaths';\nimport { isString } from 'utils/is';\n\n// this is the dry method of checking to see if a rebind applies to\n// a particular keypath because in some cases, a dep may be bound\n// directly to a particular keypath e.g. foo.bars.0.baz and need\n// to avoid getting kicked to foo.bars.1.baz if foo.bars is unshifted\nexport function rebindMatch(template, next, previous, fragment) {\n const keypath = template.r || template;\n\n // no valid keypath, go with next\n if (!keypath || !isString(keypath)) return next;\n\n // completely contextual ref, go with next\n if (\n keypath === '.' ||\n keypath[0] === '@' ||\n (next || previous).isKey ||\n (next || previous).isKeypath\n )\n return next;\n\n const parts = keypath.split('/');\n let keys = splitKeypath(parts[parts.length - 1]);\n const last = keys[keys.length - 1];\n\n // check the keypath against the model keypath to see if it matches\n let model = next || previous;\n\n // check to see if this was an alias\n if (model && keys.length === 1 && last !== model.key && fragment) {\n keys = findAlias(last, fragment) || keys;\n }\n\n let i = keys.length;\n let match = true;\n let shuffling = false;\n\n while (model && i--) {\n if (model.shuffling) shuffling = true;\n // non-strict comparison to account for indices in keypaths\n if (keys[i] != model.key) match = false;\n model = model.parent;\n }\n\n // next is undefined, but keypath is shuffling and previous matches\n if (!next && match && shuffling) return previous;\n else if (next && !match && shuffling)\n // next is defined, but doesn't match the keypath\n return previous;\n else return next;\n}\n\nfunction findAlias(name, fragment) {\n while (fragment) {\n const z = fragment.aliases;\n if (z && z[name]) {\n const aliases = (fragment.owner.iterations ? fragment.owner : fragment).owner.template.z;\n for (let i = 0; i < aliases.length; i++) {\n if (aliases[i].n === name) {\n const alias = aliases[i].x;\n if (!alias.r) return false;\n const parts = alias.r.split('/');\n return splitKeypath(parts[parts.length - 1]);\n }\n }\n return;\n }\n\n fragment = fragment.componentParent || fragment.parent;\n }\n}\n","import ModelBase, { fireShuffleTasks, maybeBind, shuffle } from './ModelBase';\nimport { capture } from '../global/capture';\nimport { handleChange, marked, markedAll, teardown } from 'shared/methodCallers';\nimport { rebindMatch } from 'shared/rebind';\nimport resolveReference from 'src/view/resolvers/resolveReference';\nimport noop from 'utils/noop';\nimport { hasOwn } from 'utils/object';\nimport { isUndefined } from 'utils/is';\n\n// temporary placeholder target for detached implicit links\nexport const Missing = {\n key: '@missing',\n animate: noop,\n applyValue: noop,\n get: noop,\n getKeypath() {\n return this.key;\n },\n joinAll() {\n return this;\n },\n joinKey() {\n return this;\n },\n mark: noop,\n registerLink: noop,\n shufle: noop,\n set: noop,\n unregisterLink: noop\n};\nMissing.parent = Missing;\n\nexport default class LinkModel extends ModelBase {\n constructor(parent, owner, target, key) {\n super(parent);\n\n this.owner = owner;\n this.target = target;\n this.key = isUndefined(key) ? owner.key : key;\n if (owner && owner.isLink) this.sourcePath = `${owner.sourcePath}.${this.key}`;\n\n if (target) target.registerLink(this);\n\n if (parent) this.isReadonly = parent.isReadonly;\n\n this.isLink = true;\n }\n\n animate(from, to, options, interpolator) {\n return this.target.animate(from, to, options, interpolator);\n }\n\n applyValue(value) {\n if (this.boundValue) this.boundValue = null;\n this.target.applyValue(value);\n }\n\n attach(fragment) {\n const model = resolveReference(fragment, this.key);\n if (model) {\n this.relinking(model, false);\n } else {\n // if there is no link available, move everything here to real models\n this.owner.unlink();\n }\n }\n\n detach() {\n this.relinking(Missing, false);\n }\n\n get(shouldCapture, opts = {}) {\n if (shouldCapture) {\n capture(this);\n\n // may need to tell the target to unwrap\n opts.unwrap = 'unwrap' in opts ? opts.unwrap : true;\n }\n\n const bind = 'shouldBind' in opts ? opts.shouldBind : true;\n opts.shouldBind = this.mapping &