UNPKG

@falconjs.io/falcon

Version:
1,560 lines (1,311 loc) 41.7 kB
// modules are defined as an array // [ module function, map of requires ] // // map of requires is short require name -> numeric require // // anything defined in a previous bundle is accessed via the // orig method which is the require for previous bundles // eslint-disable-next-line no-global-assign parcelRequire = (function (modules, cache, entry, globalName) { // Save the require from previous bundle to this closure if any var previousRequire = typeof parcelRequire === 'function' && parcelRequire; var nodeRequire = typeof require === 'function' && require; function newRequire(name, jumped) { if (!cache[name]) { if (!modules[name]) { // if we cannot find the module within our internal map or // cache jump to the current global require ie. the last bundle // that was added to the page. var currentRequire = typeof parcelRequire === 'function' && parcelRequire; if (!jumped && currentRequire) { return currentRequire(name, true); } // If there are other bundles on this page the require from the // previous one is saved to 'previousRequire'. Repeat this as // many times as there are bundles until the module is found or // we exhaust the require chain. if (previousRequire) { return previousRequire(name, true); } // Try the node require function if it exists. if (nodeRequire && typeof name === 'string') { return nodeRequire(name); } var err = new Error('Cannot find module \'' + name + '\''); err.code = 'MODULE_NOT_FOUND'; throw err; } localRequire.resolve = resolve; localRequire.cache = {}; var module = cache[name] = new newRequire.Module(name); modules[name][0].call(module.exports, localRequire, module, module.exports, this); } return cache[name].exports; function localRequire(x){ return newRequire(localRequire.resolve(x)); } function resolve(x){ return modules[name][1][x] || x; } } function Module(moduleName) { this.id = moduleName; this.bundle = newRequire; this.exports = {}; } newRequire.isParcelRequire = true; newRequire.Module = Module; newRequire.modules = modules; newRequire.cache = cache; newRequire.parent = previousRequire; newRequire.register = function (id, exports) { modules[id] = [function (require, module) { module.exports = exports; }, {}]; }; for (var i = 0; i < entry.length; i++) { newRequire(entry[i]); } if (entry.length) { // Expose entry point to Node, AMD or browser globals // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js var mainExports = newRequire(entry[entry.length - 1]); // CommonJS if (typeof exports === "object" && typeof module !== "undefined") { module.exports = mainExports; // RequireJS } else if (typeof define === "function" && define.amd) { define(function () { return mainExports; }); // <script> } else if (globalName) { this[globalName] = mainExports; } } // Override the current require with this new one return newRequire; })({"../node_modules/superfine/src/index.js":[function(require,module,exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.h = exports.patch = exports.recycle = void 0; var DEFAULT = 0; var RECYCLED_NODE = 1; var TEXT_NODE = 2; var XLINK_NS = "http://www.w3.org/1999/xlink"; var SVG_NS = "http://www.w3.org/2000/svg"; var EMPTY_OBJECT = {}; var EMPTY_ARRAY = []; var map = EMPTY_ARRAY.map; var isArray = Array.isArray; var merge = function (a, b) { var target = {}; for (var i in a) target[i] = a[i]; for (var i in b) target[i] = b[i]; return target; }; var eventProxy = function (event) { return event.currentTarget.events[event.type](event); }; var updateProperty = function (element, name, lastValue, nextValue, isSvg) { if (name === "key") {} else if (name === "style") { for (var i in merge(lastValue, nextValue)) { var style = nextValue == null || nextValue[i] == null ? "" : nextValue[i]; if (i[0] === "-") { element[name].setProperty(i, style); } else { element[name][i] = style; } } } else { if (name[0] === "o" && name[1] === "n") { if (!element.events) element.events = {}; element.events[name = name.slice(2)] = nextValue; if (nextValue == null) { element.removeEventListener(name, eventProxy); } else if (lastValue == null) { element.addEventListener(name, eventProxy); } } else { var nullOrFalse = nextValue == null || nextValue === false; if (name in element && name !== "list" && name !== "draggable" && name !== "spellcheck" && name !== "translate" && !isSvg) { element[name] = nextValue == null ? "" : nextValue; if (nullOrFalse) { element.removeAttribute(name); } } else { var ns = isSvg && name !== (name = name.replace(/^xlink:?/, "")); if (ns) { if (nullOrFalse) { element.removeAttributeNS(XLINK_NS, name); } else { element.setAttributeNS(XLINK_NS, name, nextValue); } } else { if (nullOrFalse) { element.removeAttribute(name); } else { element.setAttribute(name, nextValue); } } } } } }; var createElement = function (node, lifecycle, isSvg) { var element = node.type === TEXT_NODE ? document.createTextNode(node.name) : (isSvg = isSvg || node.name === "svg") ? document.createElementNS(SVG_NS, node.name) : document.createElement(node.name); var props = node.props; if (props.oncreate) { lifecycle.push(function () { props.oncreate(element); }); } for (var i = 0, length = node.children.length; i < length; i++) { element.appendChild(createElement(node.children[i], lifecycle, isSvg)); } for (var name in props) { updateProperty(element, name, null, props[name], isSvg); } return node.element = element; }; var updateElement = function (element, lastProps, nextProps, lifecycle, isSvg, isRecycled) { for (var name in merge(lastProps, nextProps)) { if ((name === "value" || name === "checked" ? element[name] : lastProps[name]) !== nextProps[name]) { updateProperty(element, name, lastProps[name], nextProps[name], isSvg); } } var cb = isRecycled ? nextProps.oncreate : nextProps.onupdate; if (cb != null) { lifecycle.push(function () { cb(element, lastProps); }); } }; var removeChildren = function (node) { for (var i = 0, length = node.children.length; i < length; i++) { removeChildren(node.children[i]); } var cb = node.props.ondestroy; if (cb != null) { cb(node.element); } return node.element; }; var removeElement = function (parent, node) { var remove = function () { parent.removeChild(removeChildren(node)); }; var cb = node.props && node.props.onremove; if (cb != null) { cb(node.element, remove); } else { remove(); } }; var getKey = function (node) { return node == null ? null : node.key; }; var createKeyMap = function (children, start, end) { var out = {}; var key; var node; for (; start <= end; start++) { if ((key = (node = children[start]).key) != null) { out[key] = node; } } return out; }; var patchElement = function (parent, element, lastNode, nextNode, lifecycle, isSvg) { if (nextNode === lastNode) {} else if (lastNode != null && lastNode.type === TEXT_NODE && nextNode.type === TEXT_NODE) { if (lastNode.name !== nextNode.name) { element.nodeValue = nextNode.name; } } else if (lastNode == null || lastNode.name !== nextNode.name) { var newElement = parent.insertBefore(createElement(nextNode, lifecycle, isSvg), element); if (lastNode != null) removeElement(parent, lastNode); element = newElement; } else { updateElement(element, lastNode.props, nextNode.props, lifecycle, isSvg = isSvg || nextNode.name === "svg", lastNode.type === RECYCLED_NODE); var savedNode; var childNode; var lastKey; var lastChildren = lastNode.children; var lastChStart = 0; var lastChEnd = lastChildren.length - 1; var nextKey; var nextChildren = nextNode.children; var nextChStart = 0; var nextChEnd = nextChildren.length - 1; while (nextChStart <= nextChEnd && lastChStart <= lastChEnd) { lastKey = getKey(lastChildren[lastChStart]); nextKey = getKey(nextChildren[nextChStart]); if (lastKey == null || lastKey !== nextKey) break; patchElement(element, lastChildren[lastChStart].element, lastChildren[lastChStart], nextChildren[nextChStart], lifecycle, isSvg); lastChStart++; nextChStart++; } while (nextChStart <= nextChEnd && lastChStart <= lastChEnd) { lastKey = getKey(lastChildren[lastChEnd]); nextKey = getKey(nextChildren[nextChEnd]); if (lastKey == null || lastKey !== nextKey) break; patchElement(element, lastChildren[lastChEnd].element, lastChildren[lastChEnd], nextChildren[nextChEnd], lifecycle, isSvg); lastChEnd--; nextChEnd--; } if (lastChStart > lastChEnd) { while (nextChStart <= nextChEnd) { element.insertBefore(createElement(nextChildren[nextChStart++], lifecycle, isSvg), (childNode = lastChildren[lastChStart]) && childNode.element); } } else if (nextChStart > nextChEnd) { while (lastChStart <= lastChEnd) { removeElement(element, lastChildren[lastChStart++]); } } else { var lastKeyed = createKeyMap(lastChildren, lastChStart, lastChEnd); var nextKeyed = {}; while (nextChStart <= nextChEnd) { lastKey = getKey(childNode = lastChildren[lastChStart]); nextKey = getKey(nextChildren[nextChStart]); if (nextKeyed[lastKey] || nextKey != null && nextKey === getKey(lastChildren[lastChStart + 1])) { if (lastKey == null) { removeElement(element, childNode); } lastChStart++; continue; } if (nextKey == null || lastNode.type === RECYCLED_NODE) { if (lastKey == null) { patchElement(element, childNode && childNode.element, childNode, nextChildren[nextChStart], lifecycle, isSvg); nextChStart++; } lastChStart++; } else { if (lastKey === nextKey) { patchElement(element, childNode.element, childNode, nextChildren[nextChStart], lifecycle, isSvg); nextKeyed[nextKey] = true; lastChStart++; } else { if ((savedNode = lastKeyed[nextKey]) != null) { patchElement(element, element.insertBefore(savedNode.element, childNode && childNode.element), savedNode, nextChildren[nextChStart], lifecycle, isSvg); nextKeyed[nextKey] = true; } else { patchElement(element, childNode && childNode.element, null, nextChildren[nextChStart], lifecycle, isSvg); } } nextChStart++; } } while (lastChStart <= lastChEnd) { if (getKey(childNode = lastChildren[lastChStart++]) == null) { removeElement(element, childNode); } } for (var key in lastKeyed) { if (nextKeyed[key] == null) { removeElement(element, lastKeyed[key]); } } } } return nextNode.element = element; }; var createVNode = function (name, props, children, element, key, type) { return { name: name, props: props, children: children, element: element, key: key, type: type }; }; var createTextVNode = function (text, element) { return createVNode(text, EMPTY_OBJECT, EMPTY_ARRAY, element, null, TEXT_NODE); }; var recycleChild = function (element) { return element.nodeType === 3 // Node.TEXT_NODE ? createTextVNode(element.nodeValue, element) : recycleElement(element); }; var recycleElement = function (element) { return createVNode(element.nodeName.toLowerCase(), EMPTY_OBJECT, map.call(element.childNodes, recycleChild), element, null, RECYCLED_NODE); }; var recycle = function (container) { return recycleElement(container.children[0]); }; exports.recycle = recycle; var patch = function (lastNode, nextNode, container) { var lifecycle = []; patchElement(container, container.children[0], lastNode, nextNode, lifecycle); while (lifecycle.length > 0) lifecycle.pop()(); return nextNode; }; exports.patch = patch; var h = function (name, props) { var node; var rest = []; var children = []; var length = arguments.length; while (length-- > 2) rest.push(arguments[length]); if ((props = props == null ? {} : props).children != null) { if (rest.length <= 0) { rest.push(props.children); } delete props.children; } while (rest.length > 0) { if (isArray(node = rest.pop())) { for (length = node.length; length-- > 0;) { rest.push(node[length]); } } else if (node === false || node === true || node == null) {} else { children.push(typeof node === "object" ? node : createTextVNode(node)); } } return typeof name === "function" ? name(props, props.children = children) : createVNode(name, props, children, null, props.key, DEFAULT); }; exports.h = h; },{}],"../src/libs/model.js":[function(require,module,exports) { var Observable = function Observable(dataObj) { var signals = {}; var Dep = { target: null, subs: {}, depend: function depend(deps, dep) { if (!deps.includes(this.target)) { deps.push(this.target); } if (!Dep.subs[this.target].includes(dep)) { Dep.subs[this.target].push(dep); } }, getValidDeps: function getValidDeps(deps, key) { var _this = this; return deps.filter(function (dep) { return _this.subs[dep].includes(key); }); }, notifyDeps: function notifyDeps(deps) { //deps.forEach(notify) deps.map(function (sig) { return notify(sig); }); } }; /** * Observe function * * @param {*} property * @param {function} cb */ var observe = function observe(property, cb) { if (!signals[property]) signals[property] = []; signals[property].push(cb); }; var autorender = function autorender() { console.log('rerender'); }; /** * * @param {object} obj * @param {*} key */ var makeReactive = function makeReactive(obj, key, computeFunc) { var val = obj[key]; var deps = []; Object.defineProperty(obj, key, { get: function get() { if (Dep.target) { Dep.depend(deps, key); } return val; }, set: function set(newVal) { val = newVal; deps = Dep.getValidDeps(deps, key); Dep.notifyDeps(deps, key); notify(key); autorender(); } }); }; /** * * @param {object} obj */ var observeData = function observeData(obj) { for (var key in obj) { if (obj.hasOwnProperty(key)) { if (typeof obj[key] === 'function') { makeComputed(obj, key, obj[key]); } else { makeReactive(obj, key); } } } }; var notify = function notify(signal) { if (!signals[signal] || signals[signal].lenght < 1) return; signals[signal].forEach(function (signalHandler) { return signalHandler(); }); }; var makeComputed = function makeComputed(obj, key, computeFunc) { var cache = null; var deps = []; observe(key, function () { cache = null; //clear cache deps = Dep.getValidDeps(deps, key); Dep.notifyDeps(deps, key); }); Object.defineProperty(obj, key, { get: function get() { if (Dep.target) { Dep.depend(deps, key); } Dep.target = key; if (!cache) { Dep.subs[key] = []; cache = computeFunc.call(obj); } //Clear target context Dep.target = null; return cache; }, set: function set() { /*Do nothing*/ } }); }; var subscribeWatchers = function subscribeWatchers(watchers, context) { for (var key in watchers) { if (watchers.hasOwnProperty(key)) { observe(key, watchers[key].bind(context)); } } }; observeData(dataObj.data); subscribeWatchers(dataObj.watch, dataObj.data); return { state: dataObj.data, observe: observe, notify: notify }; }; module.exports = { Observable: Observable }; },{}],"../node_modules/url-mapper/mapper.js":[function(require,module,exports) { module.exports = function mapper (compileFn, options) { if (typeof compileFn !== 'function') throw new Error('URL Mapper - function to compile a route expected as first argument') options = options || {} var cache = {} function getCompiledRoute (route) { if (!cache[route]) { cache[route] = compileFn(route, options) } return cache[route] } function parse (route, url) { if (arguments.length < 2) throw new Error('URL Mapper - parse method expects 2 arguments') return getCompiledRoute(route).parse(url) } function stringify (route, values) { if (arguments.length < 2) throw new Error('URL Mapper - stringify method expects 2 arguments') return getCompiledRoute(route).stringify(values) } function map (url, routes) { if (arguments.length < 2) throw new Error('URL Mapper - map method expects 2 arguments') for (var route in routes) { var compiled = getCompiledRoute(route) var values = compiled.parse(url) if (values) { var match = routes[route] return { route: route, match: match, values: values } } } } return { parse: parse, stringify: stringify, map: map } } },{}],"../node_modules/urlon/lib/urlon.js":[function(require,module,exports) { /* eslint-disable no-labels */ 'use strict' var keyStringifyRegexp = /([=:@$/])/g var valueStringifyRegexp = /([&;/])/g var keyParseRegexp = /[=:@$]/ var valueParseRegexp = /[&;]/ function encodeString (str, regexp) { return encodeURI(str.replace(regexp, '/$1')) } function trim (res) { return typeof res === 'string' ? res.replace(/;+$/g, '') : res } function stringify (input, recursive) { if (!recursive) { return trim(stringify(input, true)) } // Number, Boolean or Null if ( typeof input === 'number' || input === true || input === false || input === null ) { return ':' + input } var res = [] // Array if (input instanceof Array) { for (var i = 0; i < input.length; ++i) { typeof input[i] === 'undefined' ? res.push(':null') : res.push(stringify(input[i], true)) } return '@' + res.join('&') + ';' } // Object if (typeof input === 'object') { for (var key in input) { var val = stringify(input[key], true) if (val) { res.push(encodeString(key, keyStringifyRegexp) + val) } } return '$' + res.join('&') + ';' } // undefined if (typeof input === 'undefined') { return } // String return '=' + encodeString(input.toString(), valueStringifyRegexp) } function parse (str) { var pos = 0 str = decodeURI(str) function readToken (regexp) { var token = '' for (; pos !== str.length; ++pos) { if (str.charAt(pos) === '/') { pos += 1 if (pos === str.length) { token += ';' break } } else if (str.charAt(pos).match(regexp)) { break } token += str.charAt(pos) } return token } function parseToken () { var type = str.charAt(pos++) // String if (type === '=') { return readToken(valueParseRegexp) } // Number, Boolean or Null if (type === ':') { var value = readToken(valueParseRegexp) if (value === 'true') { return true } if (value === 'false') { return false } value = parseFloat(value) return isNaN(value) ? null : value } var res // Array if (type === '@') { res = [] loop: { // empty array if (pos >= str.length || str.charAt(pos) === ';') { break loop } // parse array items while (1) { res.push(parseToken()) if (pos >= str.length || str.charAt(pos) === ';') { break loop } pos += 1 } } pos += 1 return res } // Object if (type === '$') { res = {} loop: { if (pos >= str.length || str.charAt(pos) === ';') { break loop } while (1) { var name = readToken(keyParseRegexp) res[name] = parseToken() if (pos >= str.length || str.charAt(pos) === ';') { break loop } pos += 1 } } pos += 1 return res } // Error throw new Error('Unexpected char ' + type) } return parseToken() } module.exports = { stringify: stringify, parse: parse } },{}],"../node_modules/path-to-regexp/index.js":[function(require,module,exports) { /** * Expose `pathToRegexp`. */ module.exports = pathToRegexp module.exports.parse = parse module.exports.compile = compile module.exports.tokensToFunction = tokensToFunction module.exports.tokensToRegExp = tokensToRegExp /** * Default configs. */ var DEFAULT_DELIMITER = '/' var DEFAULT_DELIMITERS = './' /** * The main path matching regexp utility. * * @type {RegExp} */ var PATH_REGEXP = new RegExp([ // Match escaped characters that would otherwise appear in future matches. // This allows the user to escape special characters that won't transform. '(\\\\.)', // Match Express-style parameters and un-named parameters with a prefix // and optional suffixes. Matches appear as: // // ":test(\\d+)?" => ["test", "\d+", undefined, "?"] // "(\\d+)" => [undefined, undefined, "\d+", undefined] '(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?' ].join('|'), 'g') /** * Parse a string for the raw tokens. * * @param {string} str * @param {Object=} options * @return {!Array} */ function parse (str, options) { var tokens = [] var key = 0 var index = 0 var path = '' var defaultDelimiter = (options && options.delimiter) || DEFAULT_DELIMITER var delimiters = (options && options.delimiters) || DEFAULT_DELIMITERS var pathEscaped = false var res while ((res = PATH_REGEXP.exec(str)) !== null) { var m = res[0] var escaped = res[1] var offset = res.index path += str.slice(index, offset) index = offset + m.length // Ignore already escaped sequences. if (escaped) { path += escaped[1] pathEscaped = true continue } var prev = '' var next = str[index] var name = res[2] var capture = res[3] var group = res[4] var modifier = res[5] if (!pathEscaped && path.length) { var k = path.length - 1 if (delimiters.indexOf(path[k]) > -1) { prev = path[k] path = path.slice(0, k) } } // Push the current path onto the tokens. if (path) { tokens.push(path) path = '' pathEscaped = false } var partial = prev !== '' && next !== undefined && next !== prev var repeat = modifier === '+' || modifier === '*' var optional = modifier === '?' || modifier === '*' var delimiter = prev || defaultDelimiter var pattern = capture || group tokens.push({ name: name || key++, prefix: prev, delimiter: delimiter, optional: optional, repeat: repeat, partial: partial, pattern: pattern ? escapeGroup(pattern) : '[^' + escapeString(delimiter) + ']+?' }) } // Push any remaining characters. if (path || index < str.length) { tokens.push(path + str.substr(index)) } return tokens } /** * Compile a string to a template function for the path. * * @param {string} str * @param {Object=} options * @return {!function(Object=, Object=)} */ function compile (str, options) { return tokensToFunction(parse(str, options)) } /** * Expose a method for transforming tokens into the path function. */ function tokensToFunction (tokens) { // Compile all the tokens into regexps. var matches = new Array(tokens.length) // Compile all the patterns before compilation. for (var i = 0; i < tokens.length; i++) { if (typeof tokens[i] === 'object') { matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$') } } return function (data, options) { var path = '' var encode = (options && options.encode) || encodeURIComponent for (var i = 0; i < tokens.length; i++) { var token = tokens[i] if (typeof token === 'string') { path += token continue } var value = data ? data[token.name] : undefined var segment if (Array.isArray(value)) { if (!token.repeat) { throw new TypeError('Expected "' + token.name + '" to not repeat, but got array') } if (value.length === 0) { if (token.optional) continue throw new TypeError('Expected "' + token.name + '" to not be empty') } for (var j = 0; j < value.length; j++) { segment = encode(value[j], token) if (!matches[i].test(segment)) { throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '"') } path += (j === 0 ? token.prefix : token.delimiter) + segment } continue } if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { segment = encode(String(value), token) if (!matches[i].test(segment)) { throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but got "' + segment + '"') } path += token.prefix + segment continue } if (token.optional) { // Prepend partial segment prefixes. if (token.partial) path += token.prefix continue } throw new TypeError('Expected "' + token.name + '" to be ' + (token.repeat ? 'an array' : 'a string')) } return path } } /** * Escape a regular expression string. * * @param {string} str * @return {string} */ function escapeString (str) { return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, '\\$1') } /** * Escape the capturing group by escaping special characters and meaning. * * @param {string} group * @return {string} */ function escapeGroup (group) { return group.replace(/([=!:$/()])/g, '\\$1') } /** * Get the flags for a regexp from the options. * * @param {Object} options * @return {string} */ function flags (options) { return options && options.sensitive ? '' : 'i' } /** * Pull out keys from a regexp. * * @param {!RegExp} path * @param {Array=} keys * @return {!RegExp} */ function regexpToRegexp (path, keys) { if (!keys) return path // Use a negative lookahead to match only capturing groups. var groups = path.source.match(/\((?!\?)/g) if (groups) { for (var i = 0; i < groups.length; i++) { keys.push({ name: i, prefix: null, delimiter: null, optional: false, repeat: false, partial: false, pattern: null }) } } return path } /** * Transform an array into a regexp. * * @param {!Array} path * @param {Array=} keys * @param {Object=} options * @return {!RegExp} */ function arrayToRegexp (path, keys, options) { var parts = [] for (var i = 0; i < path.length; i++) { parts.push(pathToRegexp(path[i], keys, options).source) } return new RegExp('(?:' + parts.join('|') + ')', flags(options)) } /** * Create a path regexp from string input. * * @param {string} path * @param {Array=} keys * @param {Object=} options * @return {!RegExp} */ function stringToRegexp (path, keys, options) { return tokensToRegExp(parse(path, options), keys, options) } /** * Expose a function for taking tokens and returning a RegExp. * * @param {!Array} tokens * @param {Array=} keys * @param {Object=} options * @return {!RegExp} */ function tokensToRegExp (tokens, keys, options) { options = options || {} var strict = options.strict var start = options.start !== false var end = options.end !== false var delimiter = escapeString(options.delimiter || DEFAULT_DELIMITER) var delimiters = options.delimiters || DEFAULT_DELIMITERS var endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|') var route = start ? '^' : '' var isEndDelimited = tokens.length === 0 // Iterate over the tokens and create our regexp string. for (var i = 0; i < tokens.length; i++) { var token = tokens[i] if (typeof token === 'string') { route += escapeString(token) isEndDelimited = i === tokens.length - 1 && delimiters.indexOf(token[token.length - 1]) > -1 } else { var capture = token.repeat ? '(?:' + token.pattern + ')(?:' + escapeString(token.delimiter) + '(?:' + token.pattern + '))*' : token.pattern if (keys) keys.push(token) if (token.optional) { if (token.partial) { route += escapeString(token.prefix) + '(' + capture + ')?' } else { route += '(?:' + escapeString(token.prefix) + '(' + capture + '))?' } } else { route += escapeString(token.prefix) + '(' + capture + ')' } } } if (end) { if (!strict) route += '(?:' + delimiter + ')?' route += endsWith === '$' ? '$' : '(?=' + endsWith + ')' } else { if (!strict) route += '(?:' + delimiter + '(?=' + endsWith + '))?' if (!isEndDelimited) route += '(?=' + delimiter + '|' + endsWith + ')' } return new RegExp(route, flags(options)) } /** * Normalize the given path string, returning a regular expression. * * An empty array can be passed in for the keys, which will hold the * placeholder key descriptions. For example, using `/user/:id`, `keys` will * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`. * * @param {(string|RegExp|Array)} path * @param {Array=} keys * @param {Object=} options * @return {!RegExp} */ function pathToRegexp (path, keys, options) { if (path instanceof RegExp) { return regexpToRegexp(path, keys) } if (Array.isArray(path)) { return arrayToRegexp(/** @type {!Array} */ (path), keys, options) } return stringToRegexp(/** @type {string} */ (path), keys, options) } },{}],"../node_modules/url-mapper/compileRoute.js":[function(require,module,exports) { 'use strict' var URLON = require('urlon') var pathToRegexp = require('path-to-regexp') function getKeyName (key) { return key.name.toString() } // loose escaping for segment part // see: https://github.com/pillarjs/path-to-regexp/pull/75 function encodeSegment (str) { return encodeURI(str).replace(/[/?#'"]/g, function (c) { return '%' + c.charCodeAt(0).toString(16).toUpperCase() }) } function compileRoute (route, options) { var re var compiled var keys = [] var querySeparator = options.querySeparator || '?' re = pathToRegexp(route, keys) keys = keys.map(getKeyName) compiled = pathToRegexp.compile(route) return { parse: function (url) { var path = url var result = {} if (~path.indexOf('#') && !~querySeparator.indexOf('#')) { path = path.split('#')[0] } if (~path.indexOf(querySeparator)) { if (options.query) { var queryString = '$' + path.slice(path.indexOf(querySeparator) + querySeparator.length) result = URLON.parse(queryString) } path = path.split(querySeparator)[0] } var match = re.exec(path) if (!match) return null for (var i = 1; i < match.length; ++i) { var key = keys[i - 1] var value = match[i] && decodeURIComponent(match[i]) result[key] = (value && value[0] === ':') ? URLON.parse(value) : value } return result }, stringify: function (values) { var pathParams = {} var queryParams = {} Object.keys(values).forEach(function (key) { if (~keys.indexOf(key)) { switch (typeof values[key]) { case 'boolean': case 'number': pathParams[key] = URLON.stringify(values[key]) break case 'object': if (values[key]) { throw new Error('URL Mapper - objects are not allowed to be stringified as part of path') } else { // null pathParams[key] = URLON.stringify(values[key]) } break default: pathParams[key] = values[key] } } else { queryParams[key] = values[key] } }) var path = compiled(pathParams, { encode: encodeSegment }) var queryString = '' if (options.query) { if (Object.keys(queryParams).length) { queryString = URLON.stringify(queryParams).slice(1) } } return path + (queryString ? querySeparator + queryString : '') } } } module.exports = compileRoute },{"urlon":"../node_modules/urlon/lib/urlon.js","path-to-regexp":"../node_modules/path-to-regexp/index.js"}],"../node_modules/url-mapper/index.js":[function(require,module,exports) { 'use strict' var mapper = require('./mapper') var compileRoute = require('./compileRoute') module.exports = function urlMapper (options) { return mapper(compileRoute, options) } },{"./mapper":"../node_modules/url-mapper/mapper.js","./compileRoute":"../node_modules/url-mapper/compileRoute.js"}],"../src/libs/router.js":[function(require,module,exports) { "use strict"; var _model = require("./model"); var _urlMapper = _interopRequireDefault(require("url-mapper")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var urlMapper = (0, _urlMapper.default)(); var router = function router(routes) { return function (loc) { var matchedRoute = urlMapper.map(loc, routes); return matchedRoute; }; }; module.exports = { router: router }; },{"./model":"../src/libs/model.js","url-mapper":"../node_modules/url-mapper/index.js"}],"../src/index.js":[function(require,module,exports) { "use strict"; var _superfine = require("superfine"); var _model = require("./libs/model"); var _router = require("./libs/router"); var Render = function Render(view, container, node) { return function (state) { node = (0, _superfine.patch)(node, view(state), container); }; }; module.exports = { h: _superfine.h, patch: _superfine.patch, Observable: _model.Observable, Render: Render, Router: _router.router }; },{"superfine":"../node_modules/superfine/src/index.js","./libs/model":"../src/libs/model.js","./libs/router":"../src/libs/router.js"}],"index.js":[function(require,module,exports) { "use strict"; var _src = require("../src"); var StateStore = { data: { fName: 'Falcon', lName: 'Framework', age: 25, fullName: function fullName() { return this.fName + ' ' + this.lName; }, old: function old() { var oldornot = 'Young'; if (this.age > 50) { oldornot = 'Old is Gold'; } return oldornot; } } }; var App = new _src.Observable(StateStore); var Display = function Display() { return (0, _src.h)("div", { onupdate: console.log('Display Component has been updated') }, (0, _src.h)("h1", null, App.state.fullName), (0, _src.h)("div", null, App.state.age), (0, _src.h)("div", null, App.state.old)); }; var Controller = function Controller() { return (0, _src.h)("div", null, (0, _src.h)("input", { value: App.state.fName, oninput: function oninput(e) { App.state.fName = e.target.value; } }), (0, _src.h)("input", { value: App.state.lName, oninput: function oninput(e) { App.state.lName = e.target.value; } }), (0, _src.h)("input", { type: 'range', value: App.state.age, oninput: function oninput(e) { App.state.age = e.target.value; } })); }; var View = function View() { return (0, _src.h)("div", null, (0, _src.h)(Display, null), (0, _src.h)(Controller, null)); }; var render = (0, _src.Render)(View, document.getElementById('root')); render(App); App.observe('fName', function () { render(App); }); App.observe('lName', function () { render(App); }); App.observe('age', function () { render(App); }); },{"../src":"../src/index.js"}],"C:/Users/JM/AppData/Roaming/npm/node_modules/parcel/src/builtins/hmr-runtime.js":[function(require,module,exports) { var global = arguments[3]; var OVERLAY_ID = '__parcel__error__overlay__'; var OldModule = module.bundle.Module; function Module(moduleName) { OldModule.call(this, moduleName); this.hot = { data: module.bundle.hotData, _acceptCallbacks: [], _disposeCallbacks: [], accept: function (fn) { this._acceptCallbacks.push(fn || function () {}); }, dispose: function (fn) { this._disposeCallbacks.push(fn); } }; module.bundle.hotData = null; } module.bundle.Module = Module; var parent = module.bundle.parent; if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') { var hostname = "" || location.hostname; var protocol = location.protocol === 'https:' ? 'wss' : 'ws'; var ws = new WebSocket(protocol + '://' + hostname + ':' + "50017" + '/'); ws.onmessage = function (event) { var data = JSON.parse(event.data); if (data.type === 'update') { console.clear(); data.assets.forEach(function (asset) { hmrApply(global.parcelRequire, asset); }); data.assets.forEach(function (asset) { if (!asset.isNew) { hmrAccept(global.parcelRequire, asset.id); } }); } if (data.type === 'reload') { ws.close(); ws.onclose = function () { location.reload(); }; } if (data.type === 'error-resolved') { console.log('[parcel] ✨ Error resolved'); removeErrorOverlay(); } if (data.type === 'error') { console.error('[parcel] 🚨 ' + data.error.message + '\n' + data.error.stack); removeErrorOverlay(); var overlay = createErrorOverlay(data); document.body.appendChild(overlay); } }; } function removeErrorOverlay() { var overlay = document.getElementById(OVERLAY_ID); if (overlay) { overlay.remove(); } } function createErrorOverlay(data) { var overlay = document.createElement('div'); overlay.id = OVERLAY_ID; // html encode message and stack trace var message = document.createElement('div'); var stackTrace = document.createElement('pre'); message.innerText = data.error.message; stackTrace.innerText = data.error.stack; overlay.innerHTML = '<div style="background: black; font-size: 16px; color: white; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; padding: 30px; opacity: 0.85; font-family: Menlo, Consolas, monospace; z-index: 9999;">' + '<span style="background: red; padding: 2px 4px; border-radius: 2px;">ERROR</span>' + '<span style="top: 2px; margin-left: 5px; position: relative;">🚨</span>' + '<div style="font-size: 18px; font-weight: bold; margin-top: 20px;">' + message.innerHTML + '</div>' + '<pre>' + stackTrace.innerHTML + '</pre>' + '</div>'; return overlay; } function getParents(bundle, id) { var modules = bundle.modules; if (!modules) { return []; } var parents = []; var k, d, dep; for (k in modules) { for (d in modules[k][1]) { dep = modules[k][1][d]; if (dep === id || Array.isArray(dep) && dep[dep.length - 1] === id) { parents.push(k); } } } if (bundle.parent) { parents = parents.concat(getParents(bundle.parent, id)); } return parents; } function hmrApply(bundle, asset) { var modules = bundle.modules; if (!modules) { return; } if (modules[asset.id] || !bundle.parent) { var fn = new Function('require', 'module', 'exports', asset.generated.js); asset.isNew = !modules[asset.id]; modules[asset.id] = [fn, asset.deps]; } else if (bundle.parent) { hmrApply(bundle.parent, asset); } } function hmrAccept(bundle, id) { var modules = bundle.modules; if (!modules) { return; } if (!modules[id] && bundle.parent) { return hmrAccept(bundle.parent, id); } var cached = bundle.cache[id]; bundle.hotData = {}; if (cached) { cached.hot.data = bundle.hotData; } if (cached && cached.hot && cached.hot._disposeCallbacks.length) { cached.hot._disposeCallbacks.forEach(function (cb) { cb(bundle.hotData); }); } delete bundle.cache[id]; bundle(id); cached = bundle.cache[id]; if (cached && cached.hot && cached.hot._acceptCallbacks.length) { cached.hot._acceptCallbacks.forEach(function (cb) { cb(); }); return true; } return getParents(global.parcelRequire, id).some(function (id) { return hmrAccept(global.parcelRequire, id); }); } },{}]},{},["C:/Users/JM/AppData/Roaming/npm/node_modules/parcel/src/builtins/hmr-runtime.js","index.js"], null) //# sourceMappingURL=/app.e31bb0bc.map