simplyview 3.0.5 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/activate.mjs", "../src/action.mjs", "../src/route.mjs", "../src/command.mjs", "../src/key.mjs", "../src/view.mjs", "../src/app.mjs", "../src/include.mjs", "../src/everything.mjs"],
4
- "sourcesContent": ["const listeners = new Map()\n\nexport const activate = {\n addListener: (name, callback) => {\n if (!listeners.has(name)) {\n listeners.set(name, [])\n }\n listeners.get(name).push(callback)\n initialCall(name)\n },\n removeListener: (name, callback) => {\n if (!listeners.has(name)) {\n return false\n }\n listeners.set(name, listeners.get(name).filter((listener) => {\n return listener!=callback\n }))\n }\n}\n\nfunction initialCall(name) {\n const nodes = document.querySelectorAll('[data-simply-activate=\"'+name+'\"]')\n if (nodes) {\n for( let node of nodes) {\n callListeners(node)\n }\n }\n}\n\nfunction callListeners(node) {\n const activate = node?.dataset?.simplyActivate\n if (activate && listeners.has(activate)) {\n for (let callback of listeners.get(activate)) {\n callback.call(node)\n }\n }\n}\n\nfunction handleChanges(changes) {\n let activateNodes = []\n for (let change of changes) {\n if (change.type == 'childList') {\n for (let node of change.addedNodes) {\n if (node.querySelectorAll) {\n var toActivate = Array.from(node.querySelectorAll('[data-simply-activate]'))\n if (node.matches('[data-simply-activate]')) {\n toActivate.push(node)\n }\n activateNodes = activateNodes.concat(toActivate)\n }\n }\n }\n }\n for (let node of activateNodes) {\n callListeners(node)\n }\n}\n\nconst observer = new MutationObserver(handleChanges)\nobserver.observe(document, {\n subtree: true,\n childList: true\n})", "export function actions(options, optionsCompat) {\n\tif (optionsCompat) {\n\t\tlet app = options\n\t\toptions = optionsCompat\n\t\toptions.app = options\n\t}\n\tif (options.app) {\n\t\tconst actionHandler = {\n\t\t\tget: (target, property) => {\n\t\t\t\treturn target[property].bind(options.app)\n\t\t\t}\n\t\t}\n\t\treturn new Proxy(options.actions, actionHandler)\n\t} else {\n\t\treturn options\n\t}\n}", "export function routes(options, optionsCompat) {\n if (optionsCompat) {\n let app = options\n options = optionsCompat\n options.app = options\n }\n\treturn new SimplyRoute(options)\n}\n\nclass SimplyRoute {\n\tconstructor(options={}) {\n\t\tthis.root = options.root || '/'\n this.app = options.app\n this.addMissingSlash = !!options.addMissingSlash\n this.matchExact = !!options.matchExact\n\t\tthis.clear()\n\t\tif (options.routes) {\n\t\t\tthis.load(options.routes)\n\t\t}\n\t}\n\n\tload(routes) {\n\t\tparseRoutes(routes, this.routeInfo, this.matchExact)\n\t}\n\n\tclear() {\n\t\tthis.routeInfo = []\n\t\tthis.listeners = {\n\t\t\tmatch: {},\n\t\t\tcall: {},\n\t\t\tfinish: {}\n\t\t}\n\t}\n\n\tmatch(path, options) {\n\t\tlet args = {\n path,\n options\n }\n args = this.runListeners('match',args)\n path = args.path ? args.path : path;\n\n let matches;\n if (!path) {\n if (this.match(document.location.pathname+document.location.hash)) {\n return true;\n } else {\n return this.match(document.location.pathname);\n }\n }\n path = getPath(path);\n for ( let route of this.routeInfo) {\n matches = route.match.exec(path)\n if (this.addMissingSlash && !matches?.length) {\n if (path && path[path.length-1]!='/') {\n matches = route.match.exec(path+'/')\n if (matches) {\n path+='/'\n history.replaceState({}, '', getURL(path))\n }\n }\n }\n if (matches && matches.length) {\n var params = {};\n route.params.forEach((key, i) => {\n if (key=='*') {\n key = 'remainder'\n }\n params[key] = matches[i+1]\n })\n Object.assign(params, options)\n args.route = route\n args.params = params\n args = this.runListeners('call', args)\n params = args.params ? args.params : params\n args.result = route.action.call(route, params)\n this.runListeners('finish', args)\n return args.result\n }\n }\n return false\n\t}\n\n\trunListeners(action, params) {\n if (!Object.keys(this.listeners[action])) {\n return\n }\n Object.keys(this.listeners[action]).forEach((route) => {\n var routeRe = getRegexpFromRoute(route);\n if (routeRe.exec(params.path)) {\n var result;\n for (let callback of this.listeners[action][route]) {\n result = callback.call(this.app, params)\n if (result) {\n params = result\n }\n }\n }\n })\n return params\n }\n\n handleEvents() {\n globalThis.addEventListener('popstate', () => {\n if (this.match(getPath(document.location.pathname + document.location.hash, this.root)) === false) {\n this.match(getPath(document.location.pathname, this.root))\n }\n })\n this.app.container.addEventListener('click', (evt) => {\n\t if (evt.ctrlKey) {\n\t return;\n\t }\n\t if (evt.which != 1) {\n\t return; // not a 'left' mouse click\n\t }\n\t var link = evt.target;\n\t while (link && link.tagName!='A') {\n\t link = link.parentElement;\n\t }\n\t if (link \n\t && link.pathname \n\t && link.hostname==globalThis.location.hostname \n\t && !link.link\n\t && !link.dataset.simplyCommand\n\t ) {\n\t let path = getPath(link.pathname+link.hash, this.root);\n\t if ( !this.has(path) ) {\n\t path = getPath(link.pathname, this.root);\n\t }\n\t if ( this.has(path) ) {\n\t let params = this.runListeners('goto', { path: path});\n\t if (params.path) {\n\t if (this.goto(params.path)) {\n // now cancel the browser navigation, since a route handler was found\n evt.preventDefault();\n return false;\n }\n\t }\n\t }\n\t }\n\t })\n }\n\n goto(path) {\n history.pushState({},'',getURL(path))\n return this.match(path)\n }\n\n has(path) {\n \tpath = getPath(path, this.root)\n \tfor (let route of this.routeInfo) {\n var matches = route.match.exec(path)\n if (matches && matches.length) {\n return true\n }\n }\n return false\n }\n\n addListener(action, route, callback) {\n if (['goto','match','call','finish'].indexOf(action)==-1) {\n throw new Error('Unknown action '+action)\n }\n if (!this.listeners[action][route]) {\n this.listeners[action][route] = []\n }\n this.listeners[action][route].push(callback)\n }\n\n removeListener(action, route, callback) {\n if (['match','call','finish'].indexOf(action)==-1) {\n throw new Error('Unknown action '+action)\n }\n if (!this.listeners[action][route]) {\n return\n }\n this.listeners[action][route] = this.listeners[action][route].filter((listener) => {\n return listener != callback\n })\n }\n\n init(options) {\n \tif (options.root) {\n \t\tthis.root = options.root\n \t}\n }\n}\n\nfunction getPath(path, root='/') {\n if (path.substring(0,root.length)==root\n ||\n ( root[root.length-1]=='/' \n && path.length==(root.length-1)\n && path == root.substring(0,path.length)\n )\n ) {\n path = path.substring(root.length)\n }\n if (path[0]!='/' && path[0]!='#') {\n path = '/'+path\n }\n return path\n}\n\nfunction getURL(path, root) {\n path = getPath(path, root)\n if (root[root.length-1]==='/' && path[0]==='/') {\n path = path.substring(1)\n }\n return root + path;\n}\n\nfunction getRegexpFromRoute(route, exact=false) {\n if (exact) {\n return new RegExp('^'+route.replace(/:\\w+/g, '([^/]+)').replace(/:\\*/, '(.*)')+'(\\\\?|$)')\n }\n return new RegExp('^'+route.replace(/:\\w+/g, '([^/]+)').replace(/:\\*/, '(.*)'))\n}\n\nfunction parseRoutes(routes, routeInfo, exact=false) {\n const paths = Object.keys(routes)\n const matchParams = /:(\\w+|\\*)/g\n for (let path of paths) {\n let matches = []\n let params = []\n do {\n matches = matchParams.exec(path)\n if (matches) {\n params.push(matches[1])\n }\n } while(matches)\n routeInfo.push({\n match: getRegexpFromRoute(path, exact),\n params: params,\n action: routes[path]\n })\n }\n return routeInfo\n}\n", "class SimplyCommands {\n\tconstructor(options={}) {\n\t\tif (!options.app) {\n\t\t\toptions.app = {}\n\t\t}\n\t\tif (!options.app.container) {\n\t\t\toptions.app.container = document.body\n\t\t}\n this.app = options.app\n\t\tthis.$handlers = options.handlers || defaultHandlers\n if (options.commands) {\n \t\tObject.assign(this, options.commands)\n }\n\n\t\tconst commandHandler = (evt) => {\n\t\t\tconst command = getCommand(evt, this.$handlers)\n\t\t\tif (!command) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (!this[command.name]) {\n console.error('simply.command: undefined command '+command.name, command.source);\n return\n\t\t\t}\n const shouldContinue = this[command.name].call(options.app, command.source, command.value)\n if (shouldContinue!==true) {\n evt.preventDefault()\n evt.stopPropagation()\n return false\n }\n\t\t}\n\n options.app.container.addEventListener('click', commandHandler)\n options.app.container.addEventListener('submit', commandHandler)\n options.app.container.addEventListener('change', commandHandler)\n options.app.container.addEventListener('input', commandHandler)\n\t}\n\n call(command, el, value) {\n if (!this[command]) {\n console.error('simply.command: undefined command '+command);\n return\n }\n return this[command].call(this.app, el, value)\n }\n\n action(name) {\n console.warn('deprecated call to `this.commands.action`')\n let params = Array.from(arguments).slice()\n params.shift()\n return this.app.actions[name](...params)\n }\n\n appendHandler(handler) {\n this.$handlers.push(handler)\n }\n\n prependHandler(handler) {\n this.$handlers.unshift(handler)\n }\n}\n\nexport function commands(options={}, optionsCompat) {\n if (optionsCompat) {\n let app = options\n options = optionsCompat\n options.app = options\n }\n\treturn new SimplyCommands(options)\n}\n\nfunction getCommand(evt, handlers) {\n var el = evt.target.closest('[data-simply-command]')\n if (el) {\n for (let handler of handlers) {\n if (el.matches(handler.match)) {\n if (handler.check(el, evt)) {\n return {\n name: el.dataset.simplyCommand,\n source: el,\n value: handler.get(el)\n }\n }\n return null\n }\n }\n }\n return null\n}\n\nconst defaultHandlers = [\n {\n match: 'input,select,textarea',\n get: function(el) {\n if (el.tagName==='SELECT' && el.multiple) {\n let values = []\n for (let option of el.options) {\n if (option.selected) {\n values.push(option.value)\n }\n }\n return values\n }\n return el.dataset.simplyValue || el.value\n },\n check: function(el, evt) {\n return evt.type=='change' || (el.dataset.simplyImmediate && evt.type=='input')\n }\n },\n {\n match: 'a,button',\n get: function(el) {\n return el.dataset.simplyValue || el.href || el.value\n },\n check: function(el,evt) {\n return evt.type=='click' && evt.ctrlKey==false && evt.button==0\n }\n },\n {\n match: 'form',\n get: function(el) {\n let data = {}\n for (let input of Array.from(el.elements)) {\n if (input.tagName=='INPUT' \n && (input.type=='checkbox' || input.type=='radio')\n ) {\n if (!input.checked) {\n return;\n }\n }\n if (data[input.name] && !Array.isArray(data[input.name])) {\n data[input.name] = [data[input.name]]\n }\n if (Array.isArray(data[input.name])) {\n data[input.name].push(input.value)\n } else {\n data[input.name] = input.value\n }\n }\n return data\n },\n check: function(el,evt) {\n return evt.type=='submit'\n }\n },\n {\n \tmatch: '*',\n get: function(el) {\n return el.dataset.simplyValue\n },\n check: function(el, evt) {\n return evt.type=='click' && evt.ctrlKey==false && evt.button==0\n }\n }\n]", "const KEY = Object.freeze({\n\tCompose: 229,\n\tControl: 17,\n\tMeta: 224,\n\tAlt: 18,\n\tShift: 16\n})\n\nclass SimplyKey {\n\tconstructor(options = {}) {\n\t\tif (!options.app) {\n\t\t\toptions.app = {}\n\t\t}\n\t\tif (!options.app.container) {\n\t\t\toptions.app.container = document.body\n\t\t}\n\t\tObject.assign(this, options.keys)\n\n\t\tconst keyHandler = (e) => {\n\t\t\tif (e.isComposing || e.keyCode === KEY.Compose) {\n\t\t\t return\n\t\t\t}\n\t\t\tif (e.defaultPrevented) {\n\t\t\t return\n\t\t\t}\n\t\t\tif (!e.target) {\n\t\t\t return\n\t\t\t}\n\n\t\t\tlet selectedKeyboard = 'default'\n\t\t\tif (e.target.closest('[data-simply-keyboard]')) {\n\t\t\t selectedKeyboard = e.target.closest('[data-simply-keyboard]')\n\t\t\t \t\t\t\t\t.dataset.simplyKeyboard\n\t\t\t}\n\t\t\tlet keyCombination = []\n\t\t\tif (e.ctrlKey && e.keyCode!=KEY.Control) {\n\t\t\t keyCombination.push('Control')\n\t\t\t}\n\t\t\tif (e.metaKey && e.keyCode!=KEY.Meta) {\n\t\t\t keyCombination.push('Meta')\n\t\t\t}\n\t\t\tif (e.altKey && e.keyCode!=KEY.Alt) {\n\t\t\t keyCombination.push('Alt')\n\t\t\t}\n\t\t\tif (e.shiftKey && e.keyCode!=KEY.Shift) {\n\t\t\t keyCombination.push('Shift')\n\t\t\t}\n\t\t\tkeyCombination.push(e.key.toLowerCase())\n\n\t\t\tlet keyboards = []\n\t\t\tlet keyboardElement = event.target.closest('[data-simply-keyboard]')\n\t\t\twhile (keyboardElement) {\n\t\t\t\tkeyboards.push(keyboardElement.dataset.simplyKeyboard)\n\t\t\t\tkeyboardElement = keyboardElement.parentNode.closest('[data-simply-keyboard]')\n\t\t\t}\n\t\t\tkeyboards.push('')\n\n\t\t\tlet keyboard, subkeyboard\n\t\t\tlet separators = ['+','-']\n\n\t\t\tfor (i in keyboards) {\n\t\t\t\tkeyboard = keyboards[i]\n\t\t\t\tif (keyboard == '') {\n\t\t\t\t\tsubkeyboard = 'default'\n\t\t\t\t} else {\n\t\t\t\t\tsubkeyboard = keyboard\n\t\t\t\t\tkeyboard += '.'\n\t\t\t\t}\n\t\t\t\tfor (let separator of separators) {\n\t\t\t\t\tlet keyString = keyCombination.join(separator)\n\n\t\t\t\t\tif (this[subkeyboard] && (typeof this[subkeyboard][keyString]=='function')) {\n\t\t\t\t\t\tlet _continue = this[subkeyboard][keyString].call(this[subkeyboard], e)\n\t\t\t\t\t\tif (!_continue) {\n\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof this[subkeyboard + keyString] == 'function') {\n\t\t\t\t\t\tlet _continue = this[subkeyboard + keyString].call(this, e)\n\t\t\t\t\t\tif (!_continue) {\n\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\t\t\t\t\t\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this[selectedKeyboard] && this[selectedKeyboard][keyString]) {\n\t\t\t\t\t\tlet targets = options.app.container.querySelectorAll('[data-simply-accesskey=\"'\n\t\t\t\t\t\t\t+ keyboard + keyString + '\"]')\n\t\t\t\t\t\tif (targets.length) {\n\t\t\t\t\t\t\ttargets.forEach(t => t.click())\n\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\toptions.app.container.addEventListener('keydown', keyHandler)\n\t}\n\n}\n\nexport function keys(options={}, optionsCompat) {\n\tif (optionsCompat) {\n\t\tlet app = options\n\t\toptions = optionsCompat\n\t\toptions.app = options\n\t}\n\treturn new SimplyKey(options)\n}\n\n", "export function view(options, optionsCompat) {\n\tif (optionsCompat) {\n\t\tlet app = options\n\t\toptions = optionsCompat\n\t\toptions.app = options\n\t}\n\tif (options.app) {\n\t\toptions.app.view = options.view || {}\n\n\t\tconst load = () => {\n\t\t\tconst data = options.app.view\n\t\t\tconst path = globalThis.editor.data.getDataPath(options.app.container || document.body)\n\t\t\toptions.app.view = globalThis.editor.currentData[path]\n\t\t\tObject.assign(options.app.view, data)\n\t\t}\n\t\tif (globalThis.editor && globalThis.editor.currentData) {\n\t\t\tload()\n\t\t} else {\n\t\t\tdocument.addEventListener('simply-content-loaded', load)\n\t\t}\n\t\treturn options.app.view\n\t} else {\n\t\treturn options.view\n\t}\n}", "import { routes } from './route.mjs'\nimport { commands } from './command.mjs'\nimport { actions } from './action.mjs'\nimport { keys } from './key.mjs'\nimport { view } from './view.mjs'\n\nclass SimplyApp {\n\tconstructor(options={}) {\n\t\tthis.container = options.container || document.body\n\t\tfor (let key in options) {\n\t\t\tswitch(key) {\n\t\t\t\tcase 'commands':\n\t\t\t\t\tthis.commands = commands({ app: this, container: this.container, commands: options.commands})\n\t\t\t\t\tbreak\n\t\t\t\tcase 'keys':\n\t\t\t\tcase 'keyboard': // backwards compatible\n\t\t\t\t\tthis.keys = keys({ app: this, keys: options.keys })\n\t\t\t\t\tbreak\n\t\t\t\tcase 'routes':\n\t\t\t\t\tthis.routes = routes({ app: this, routes: options.routes})\n\t\t\t\t\tbreak\n\t\t\t\tcase 'actions':\n\t\t\t\t\tthis.actions = actions({app: this, actions: options.actions})\n\t\t\t\t\tthis.action = function(name) { // backwards compatible wiht SimplyView2\n\t\t\t\t\t\tconsole.warn('deprecated call to `this.action`')\n\t\t\t\t\t\tlet params = Array.from(arguments).slice()\n\t\t\t\t params.shift()\n\t\t\t\t return this.actions[name](...params)\n\t\t\t\t }\n\t\t\t\t\tbreak\n\t\t\t\tcase 'view':\n\t\t\t\t\tthis.view = view({app: this, view: options.view})\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tthis[key] = options[key] // allows easy additions\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tget app() {\n\t\treturn this\n\t}\n}\n\nexport function app(options={}) {\n\treturn new SimplyApp(options)\n}", "function throttle( callbackFunction, intervalTime ) {\n let eventId = 0\n return () => {\n const myArguments = arguments\n if ( eventId ) {\n return\n } else {\n eventId = globalThis.setTimeout( () => {\n callbackFunction.apply(this, myArguments)\n eventId = 0\n }, intervalTime )\n }\n }\n}\n\nconst runWhenIdle = (() => {\n if (globalThis.requestIdleCallback) {\n return (callback) => {\n globalThis.requestIdleCallback(callback, {timeout: 500})\n }\n }\n return globalThis.requestAnimationFrame\n})()\n\nfunction rebaseHref(relative, base) {\n let url = new URL(relative, base)\n if (include.cacheBuster) {\n url.searchParams.set('cb',include.cacheBuster)\n }\n return url.href\n}\n\nlet observer, loaded = {}\nlet head = globalThis.document.querySelector('head')\nlet currentScript = globalThis.document.currentScript\nlet getScriptURL, currentScriptURL\nif (!currentScript) {\n getScriptURL = (() => {\n var scripts = document.getElementsByTagName('script')\n var index = scripts.length - 1\n var myScript = scripts[index]\n return () => myScript.src\n })()\n currentScriptURL = getScriptURL()\n} else {\n currentScriptURL = currentScript.src\n}\n\nconst waitForPreviousScripts = async () => {\n // because of the async=false attribute, this script will run after\n // the previous scripts have been loaded and run\n // simply.include.next.js only fires the simply-next-script event\n // that triggers the Promise.resolve method\n return new Promise(function(resolve) {\n var next = globalThis.document.createElement('script')\n next.src = \"https://cdn.jsdelivr.net/gh/simplyedit/simplyview/dist/simply.include.next.js\"\n next.async = false\n globalThis.document.addEventListener('simply-include-next', () => {\n head.removeChild(next)\n resolve()\n }, { once: true, passive: true})\n head.appendChild(next)\n })\n}\n\nlet scriptLocations = []\n\nexport const include = {\n cacheBuster: null,\n scripts: (scripts, base) => {\n let arr = scripts.slice()\n const importScript = () => {\n const script = arr.shift()\n if (!script) {\n return\n }\n const attrs = [].map.call(script.attributes, (attr) => {\n return attr.name\n })\n let clone = globalThis.document.createElement('script')\n for (const attr of attrs) {\n clone.setAttribute(attr, script.getAttribute(attr))\n }\n clone.removeAttribute('data-simply-location')\n if (!clone.src) {\n // this is an inline script, so copy the content and wait for previous scripts to run\n clone.innerHTML = script.innerHTML\n waitForPreviousScripts()\n .then(() => {\n const node = scriptLocations[script.dataset.simplyLocation]\n node.parentNode.insertBefore(clone, node)\n node.parentNode.removeChild(node)\n importScript()\n })\n } else {\n clone.src = rebaseHref(clone.src, base)\n if (!clone.hasAttribute('async') && !clone.hasAttribute('defer')) {\n clone.async = false //important! do not use clone.setAttribute('async', false) - it has no effect\n }\n const node = scriptLocations[script.dataset.simplyLocation]\n node.parentNode.insertBefore(clone, node)\n node.parentNode.removeChild(node)\n loaded[clone.src]=true\n importScript()\n }\n }\n if (arr.length) {\n importScript()\n }\n },\n html: (html, link) => {\n let fragment = globalThis.document.createRange().createContextualFragment(html)\n const stylesheets = fragment.querySelectorAll('link[rel=\"stylesheet\"],style')\n // add all stylesheets to head\n for (let stylesheet of stylesheets) {\n if (stylesheet.href) {\n stylesheet.href = rebaseHref(stylesheet.href, link.href)\n }\n head.appendChild(stylesheet)\n }\n // remove the scripts from the fragment, as they will not run in the\n // order in which they are defined\n let scriptsFragment = globalThis.document.createDocumentFragment()\n const scripts = fragment.querySelectorAll('script')\n if (scripts.length) {\n for (let script of scripts) {\n let placeholder = globalThis.document.createComment(script.src || 'inline script')\n script.parentNode.insertBefore(placeholder, script)\n script.dataset.simplyLocation = scriptLocations.length\n scriptLocations.push(placeholder)\n scriptsFragment.appendChild(script)\n }\n globalThis.setTimeout(function() {\n include.scripts(Array.from(scriptsFragment.children), link ? link.href : globalThis.location.href )\n }, 10)\n }\n // add the remainder before the include link\n link.parentNode.insertBefore(fragment, link ? link : null)\n\n }\n}\n\nlet included = {}\nconst includeLinks = async (links) => {\n // mark them as in progress, so handleChanges doesn't find them again\n let remainingLinks = [].reduce.call(links, (remainder, link) => {\n if (link.rel=='simply-include-once' && included[link.href]) {\n link.parentNode.removeChild(link)\n } else {\n included[link.href]=true\n link.rel = 'simply-include-loading'\n remainder.push(link)\n }\n return remainder\n }, [])\n\n for (let link of remainingLinks) {\n if (!link.href) {\n return\n }\n // fetch the html\n const response = await fetch(link.href)\n if (!response.ok) {\n console.log('simply-include: failed to load '+link.href);\n continue\n }\n console.log('simply-include: loaded '+link.href);\n const html = await response.text()\n // if succesfull import the html\n include.html(html, link)\n // remove the include link\n link.parentNode.removeChild(link)\n }\n}\n\nconst handleChanges = throttle(() => {\n runWhenIdle(() => {\n var links = globalThis.document.querySelectorAll('link[rel=\"simply-include\"],link[rel=\"simply-include-once\"]')\n if (links.length) {\n includeLinks(links)\n }\n })\n})\n\nconst observe = () => {\n observer = new MutationObserver(handleChanges)\n observer.observe(globalThis.document, {\n subtree: true,\n childList: true,\n })\n}\n\nobserve()\nhandleChanges() // check if there are include links in the dom already\n", "import { activate } from './activate.mjs'\nimport { actions as action } from './action.mjs'\nimport { app } from './app.mjs'\nimport { commands as command } from './command.mjs'\nimport { include } from './include.mjs'\nimport { keys as key } from './key.mjs'\nimport { routes as route } from './route.mjs'\nimport { view } from './view.mjs'\n\nconst simply = {\n\tactivate,\n\taction,\n\tapp,\n\tcommand,\n\tinclude,\n\tkey,\n\troute,\n\tview\n}\n\nwindow.simply = simply\n\nexport default simply"],
5
- "mappings": "MAAA,IAAMA,EAAY,IAAI,IAETC,EAAW,CACpB,YAAa,CAACC,EAAMC,IAAa,CACxBH,EAAU,IAAIE,CAAI,GACnBF,EAAU,IAAIE,EAAM,CAAC,CAAC,EAE1BF,EAAU,IAAIE,CAAI,EAAE,KAAKC,CAAQ,EACjCC,EAAYF,CAAI,CACpB,EACA,eAAgB,CAACA,EAAMC,IAAa,CAChC,GAAI,CAACH,EAAU,IAAIE,CAAI,EACnB,MAAO,GAEXF,EAAU,IAAIE,EAAMF,EAAU,IAAIE,CAAI,EAAE,OAAQG,GACrCA,GAAUF,CACpB,CAAC,CACN,CACJ,EAEA,SAASC,EAAYF,EAAM,CACvB,IAAMI,EAAQ,SAAS,iBAAiB,0BAA0BJ,EAAK,IAAI,EAC3E,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AQ,IAAI,0BAA0BA,EAAK,IAAI,EAC/C,IAAMD,EAAO,MAAMY,EAAS,KAAK,EAEjCjC,EAAQ,KAAKqB,EAAMC,CAAI,EAEvBA,EAAK,WAAW,YAAYA,CAAI,CACpC,CACJ,EAEMY,EAAgB7C,EAAS,IAAM,CACjCK,EAAY,IAAM,CACd,IAAIoC,EAAQ,WAAW,SAAS,iBAAiB,4DAA4D,EACzGA,EAAM,QACND,GAAaC,CAAK,CAE1B,CAAC,CACL,CAAC,EAEKK,GAAU,IAAM,CAClBlC,EAAW,IAAI,iBAAiBiC,CAAa,EAC7CjC,EAAS,QAAQ,WAAW,SAAU,CAClC,QAAS,GACT,UAAW,EACf,CAAC,CACL,EAEAkC,GAAQ,EACRD,EAAc,ECxLd,IAAME,EAAS,CACd,SAAAC,EACA,OAAAC,EACA,IAAAC,EACA,QAAAC,EACA,QAAAC,EACA,IAAAC,EACA,MAAAC,EACA,KAAAC,CACD,EAEA,OAAO,OAASR,EAEhB,IAAOS,GAAQT",
6
- "names": ["listeners", "activate", "name", "callback", "initialCall", "listener", "nodes", "node", "callListeners", "handleChanges", "changes", "activateNodes", "change", "toActivate", "observer", "actions", "options", "optionsCompat", "app", "actionHandler", "target", "property", "routes", "options", "optionsCompat", "app", "SimplyRoute", "parseRoutes", "path", "args", "matches", "getPath", "route", "getURL", "params", "key", "i", "action", "routeRe", "getRegexpFromRoute", "result", "callback", "evt", "link", "listener", "root", "exact", "routeInfo", "paths", "matchParams", "SimplyCommands", "options", "defaultHandlers", "commandHandler", "evt", "command", "getCommand", "el", "value", "name", "params", "handler", "commands", "optionsCompat", "app", "handlers", "values", "option", "data", "input", "KEY", "SimplyKey", "options", "keyHandler", "e", "selectedKeyboard", "keyCombination", "keyboards", "keyboardElement", "keyboard", "subkeyboard", "separators", "separator", "keyString", "targets", "t", "keys", "optionsCompat", "app", "view", "options", "optionsCompat", "app", "load", "data", "path", "SimplyApp", "options", "key", "commands", "keys", "routes", "actions", "name", "params", "view", "app", "throttle", "callbackFunction", "intervalTime", "eventId", "myArguments", "runWhenIdle", "callback", "rebaseHref", "relative", "base", "url", "include", "observer", "loaded", "head", "currentScript", "getScriptURL", "currentScriptURL", "scripts", "index", "myScript", "waitForPreviousScripts", "resolve", "next", "scriptLocations", "arr", "importScript", "script", "attrs", "attr", "clone", "node", "html", "link", "fragment", "stylesheets", "stylesheet", "scriptsFragment", "placeholder", "included", "includeLinks", "links", "remainingLinks", "remainder", "response", "handleChanges", "observe", "simply", "activate", "actions", "app", "commands", "include", "keys", "routes", "view", "everything_default"]
3
+ "sources": ["../src/activate.mjs", "../src/action.mjs", "../src/route.mjs", "../src/command.mjs", "../src/key.mjs", "../src/view.mjs", "../src/app.mjs", "../src/include.mjs", "../src/render.mjs", "../src/everything.mjs"],
4
+ "sourcesContent": ["const listeners = new Map()\n\nexport const activate = {\n addListener: (name, callback) => {\n if (!listeners.has(name)) {\n listeners.set(name, [])\n }\n listeners.get(name).push(callback)\n initialCall(name)\n },\n removeListener: (name, callback) => {\n if (!listeners.has(name)) {\n return false\n }\n listeners.set(name, listeners.get(name).filter((listener) => {\n return listener!=callback\n }))\n }\n}\n\nfunction initialCall(name) {\n const nodes = document.querySelectorAll('[data-simply-activate=\"'+name+'\"]')\n if (nodes) {\n for( let node of nodes) {\n callListeners(node)\n }\n }\n}\n\nfunction callListeners(node) {\n const activate = node?.dataset?.simplyActivate\n if (activate && listeners.has(activate)) {\n for (let callback of listeners.get(activate)) {\n callback.call(node)\n }\n }\n}\n\nfunction handleChanges(changes) {\n let activateNodes = []\n for (let change of changes) {\n if (change.type == 'childList') {\n for (let node of change.addedNodes) {\n if (node.querySelectorAll) {\n var toActivate = Array.from(node.querySelectorAll('[data-simply-activate]'))\n if (node.matches('[data-simply-activate]')) {\n toActivate.push(node)\n }\n activateNodes = activateNodes.concat(toActivate)\n }\n }\n }\n }\n for (let node of activateNodes) {\n callListeners(node)\n }\n}\n\nconst observer = new MutationObserver(handleChanges)\nobserver.observe(document, {\n subtree: true,\n childList: true\n})", "export function actions(options, optionsCompat) {\n\tif (optionsCompat) {\n\t\tlet app = options\n\t\toptions = optionsCompat\n\t\toptions.app = app\n\t}\n\tif (options.app) {\n\t\tconst actionHandler = {\n\t\t\tget(target, property) {\n\t\t\t\tif (!target[property]) {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tif (target.catch) {\n\t\t\t\t\treturn new Proxy(target[property].bind(options.app), functionHandler)\n\t\t\t\t} else {\n\t\t\t\t\treturn target[property].bind(options.app)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn new Proxy(options.actions, actionHandler)\n\t} else {\n\t\treturn options\n\t}\n}\n\nconst functionHandler = {\n\tapply(target, thisArg, argumentsList) {\n\t\ttry {\n\t\t\tconst result = target(...argumentsList)\n\t\t\tif (result instanceof Promise) {\n\t\t\t\treturn result.catch(err => {\n\t\t\t\t\treturn thisArg.catch(err)\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn result\n\t\t} catch(err) {\n\t\t\treturn thisArg.catch(err)\n\t\t}\n\t}\n}", "export function routes(options, optionsCompat)\n{\n if (optionsCompat) {\n let app = options\n options = optionsCompat\n options.app = options\n }\n return new SimplyRoute(options)\n}\n\nclass SimplyRoute\n{\n constructor(options={})\n {\n this.root = options.root || '/'\n this.app = options.app || {}\n this.addMissingSlash = !!options.addMissingSlash\n this.matchExact = !!options.matchExact\n this.clear()\n if (options.routes) {\n this.load(options.routes)\n }\n }\n\n load(routes)\n {\n parseRoutes(routes, this.routeInfo, this.matchExact)\n }\n\n clear()\n {\n this.routeInfo = []\n this.listeners = {\n match: {},\n call: {},\n finish: {}\n }\n }\n\n match(path, options)\n {\n let args = {\n path,\n options\n }\n args = this.runListeners('match',args)\n path = args.path ? args.path : path;\n\n let matches;\n if (!path) {\n if (this.match(document.location.pathname+document.location.hash)) {\n return true;\n } else {\n return this.match(document.location.pathname);\n }\n }\n path = getPath(path);\n for ( let route of this.routeInfo) {\n matches = route.match.exec(path)\n if (this.addMissingSlash && !matches?.length) {\n if (path && path[path.length-1]!='/') {\n matches = route.match.exec(path+'/')\n if (matches) {\n path+='/'\n history.replaceState({}, '', getURL(path))\n }\n }\n }\n if (matches && matches.length) {\n var params = {};\n route.params.forEach((key, i) => {\n if (key=='*') {\n key = 'remainder'\n }\n params[key] = matches[i+1]\n })\n Object.assign(params, options)\n args.route = route\n args.params = params\n args = this.runListeners('call', args)\n params = args.params ? args.params : params\n args.result = route.action.call(this.app, params)\n this.runListeners('finish', args)\n return args.result\n }\n }\n return false\n }\n\n runListeners(action, params)\n {\n if (!Object.keys(this.listeners[action])) {\n return\n }\n Object.keys(this.listeners[action]).forEach((route) => {\n var routeRe = getRegexpFromRoute(route);\n if (routeRe.exec(params.path)) {\n var result;\n for (let callback of this.listeners[action][route]) {\n result = callback.call(this.app, params)\n if (result) {\n params = result\n }\n }\n }\n })\n return params\n }\n\n handleEvents()\n {\n globalThis.addEventListener('popstate', () => {\n if (this.match(getPath(document.location.pathname + document.location.hash, this.root)) === false) {\n this.match(getPath(document.location.pathname, this.root))\n }\n })\n this.app.container.addEventListener('click', (evt) => {\n if (evt.ctrlKey) {\n return;\n }\n if (evt.which != 1) {\n return; // not a 'left' mouse click\n }\n var link = evt.target;\n while (link && link.tagName!='A') {\n link = link.parentElement;\n }\n if (link \n && link.pathname \n && link.hostname==globalThis.location.hostname \n && !link.link\n && !link.dataset.simplyCommand\n ) {\n let path = getPath(link.pathname+link.hash, this.root);\n if ( !this.has(path) ) {\n path = getPath(link.pathname, this.root);\n }\n if ( this.has(path) ) {\n let params = this.runListeners('goto', { path: path});\n if (params.path) {\n if (this.goto(params.path)) {\n // now cancel the browser navigation, since a route handler was found\n evt.preventDefault();\n return false;\n }\n }\n }\n }\n })\n }\n\n goto(path)\n {\n history.pushState({},'',getURL(path))\n return this.match(path)\n }\n\n has(path)\n {\n path = getPath(path, this.root)\n for (let route of this.routeInfo) {\n var matches = route.match.exec(path)\n if (matches && matches.length) {\n return true\n }\n }\n return false\n }\n\n addListener(action, route, callback)\n {\n if (['goto','match','call','finish'].indexOf(action)==-1) {\n throw new Error('Unknown action '+action)\n }\n if (!this.listeners[action][route]) {\n this.listeners[action][route] = []\n }\n this.listeners[action][route].push(callback)\n }\n\n removeListener(action, route, callback)\n {\n if (['match','call','finish'].indexOf(action)==-1) {\n throw new Error('Unknown action '+action)\n }\n if (!this.listeners[action][route]) {\n return\n }\n this.listeners[action][route] = this.listeners[action][route].filter((listener) => {\n return listener != callback\n })\n }\n\n init(options)\n {\n if (options.root) {\n this.root = options.root\n }\n }\n}\n\nfunction getPath(path, root='/')\n{\n if (path.substring(0,root.length)==root\n ||\n ( root[root.length-1]=='/' \n && path.length==(root.length-1)\n && path == root.substring(0,path.length)\n )\n ) {\n path = path.substring(root.length)\n }\n if (path[0]!='/' && path[0]!='#') {\n path = '/'+path\n }\n return path\n}\n\nfunction getURL(path, root)\n{\n path = getPath(path, root)\n if (root[root.length-1]==='/' && path[0]==='/') {\n path = path.substring(1)\n }\n return root + path;\n}\n\nfunction getRegexpFromRoute(route, exact=false)\n{\n if (exact) {\n return new RegExp('^'+route.replace(/:\\w+/g, '([^/]+)').replace(/:\\*/, '(.*)')+'(\\\\?|$)')\n }\n return new RegExp('^'+route.replace(/:\\w+/g, '([^/]+)').replace(/:\\*/, '(.*)'))\n}\n\nfunction parseRoutes(routes, routeInfo, exact=false)\n{\n const paths = Object.keys(routes)\n const matchParams = /:(\\w+|\\*)/g\n for (let path of paths) {\n let matches = []\n let params = []\n do {\n matches = matchParams.exec(path)\n if (matches) {\n params.push(matches[1])\n }\n } while(matches)\n routeInfo.push({\n match: getRegexpFromRoute(path, exact),\n params: params,\n action: routes[path]\n })\n }\n return routeInfo\n}", "class SimplyCommands {\n\tconstructor(options={}) {\n\t\tif (!options.app) {\n\t\t\toptions.app = {}\n\t\t}\n\t\tif (!options.app.container) {\n\t\t\toptions.app.container = document.body\n\t\t}\n this.app = options.app\n\t\tthis.$handlers = options.handlers || defaultHandlers\n if (options.commands) {\n \t\tObject.assign(this, options.commands)\n }\n\n\t\tconst commandHandler = (evt) => {\n\t\t\tconst command = getCommand(evt, this.$handlers)\n\t\t\tif (!command) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (!this[command.name]) {\n console.error('simply.command: undefined command '+command.name, command.source);\n return\n\t\t\t}\n const shouldContinue = this[command.name].call(options.app, command.source, command.value)\n if (shouldContinue!==true) {\n evt.preventDefault()\n evt.stopPropagation()\n return false\n }\n\t\t}\n\n options.app.container.addEventListener('click', commandHandler)\n options.app.container.addEventListener('submit', commandHandler)\n options.app.container.addEventListener('change', commandHandler)\n options.app.container.addEventListener('input', commandHandler)\n\t}\n\n call(command, el, value) {\n if (!this[command]) {\n console.error('simply.command: undefined command '+command);\n return\n }\n return this[command].call(this.app, el, value)\n }\n\n action(name) {\n console.warn('deprecated call to `this.commands.action`')\n let params = Array.from(arguments).slice()\n params.shift()\n return this.app.actions[name](...params)\n }\n\n appendHandler(handler) {\n this.$handlers.push(handler)\n }\n\n prependHandler(handler) {\n this.$handlers.unshift(handler)\n }\n}\n\nexport function commands(options={}, optionsCompat) {\n if (optionsCompat) {\n let app = options\n options = optionsCompat\n options.app = options\n }\n\treturn new SimplyCommands(options)\n}\n\nfunction getCommand(evt, handlers) {\n var el = evt.target.closest('[data-simply-command]')\n if (el) {\n for (let handler of handlers) {\n if (el.matches(handler.match)) {\n if (handler.check(el, evt)) {\n return {\n name: el.dataset.simplyCommand,\n source: el,\n value: handler.get(el)\n }\n }\n return null\n }\n }\n }\n return null\n}\n\nconst defaultHandlers = [\n {\n match: 'input,select,textarea',\n get: function(el) {\n if (el.tagName==='SELECT' && el.multiple) {\n let values = []\n for (let option of el.options) {\n if (option.selected) {\n values.push(option.value)\n }\n }\n return values\n }\n return el.dataset.simplyValue || el.value\n },\n check: function(el, evt) {\n return evt.type=='change' || (el.dataset.simplyImmediate && evt.type=='input')\n }\n },\n {\n match: 'a,button',\n get: function(el) {\n return el.dataset.simplyValue || el.href || el.value\n },\n check: function(el,evt) {\n return evt.type=='click' && evt.ctrlKey==false && evt.button==0\n }\n },\n {\n match: 'form',\n get: function(el) {\n let data = {}\n for (let input of Array.from(el.elements)) {\n if (input.tagName=='INPUT' \n && (input.type=='checkbox' || input.type=='radio')\n ) {\n if (!input.checked) {\n return;\n }\n }\n if (data[input.name] && !Array.isArray(data[input.name])) {\n data[input.name] = [data[input.name]]\n }\n if (Array.isArray(data[input.name])) {\n data[input.name].push(input.value)\n } else {\n data[input.name] = input.value\n }\n }\n return data\n },\n check: function(el,evt) {\n return evt.type=='submit'\n }\n },\n {\n \tmatch: '*',\n get: function(el) {\n return el.dataset.simplyValue\n },\n check: function(el, evt) {\n return evt.type=='click' && evt.ctrlKey==false && evt.button==0\n }\n }\n]", "const KEY = Object.freeze({\n\tCompose: 229,\n\tControl: 17,\n\tMeta: 224,\n\tAlt: 18,\n\tShift: 16\n})\n\nclass SimplyKey {\n\tconstructor(options = {}) {\n\t\tif (!options.app) {\n\t\t\toptions.app = {}\n\t\t}\n\t\tif (!options.app.container) {\n\t\t\toptions.app.container = document.body\n\t\t}\n\t\tObject.assign(this, options.keys)\n\n\t\tconst keyHandler = (e) => {\n\t\t\tif (e.isComposing || e.keyCode === KEY.Compose) {\n\t\t\t return\n\t\t\t}\n\t\t\tif (e.defaultPrevented) {\n\t\t\t return\n\t\t\t}\n\t\t\tif (!e.target) {\n\t\t\t return\n\t\t\t}\n\n\t\t\tlet selectedKeyboard = 'default'\n\t\t\tif (e.target.closest('[data-simply-keyboard]')) {\n\t\t\t selectedKeyboard = e.target.closest('[data-simply-keyboard]')\n\t\t\t \t\t\t\t\t.dataset.simplyKeyboard\n\t\t\t}\n\t\t\tlet keyCombination = []\n\t\t\tif (e.ctrlKey && e.keyCode!=KEY.Control) {\n\t\t\t keyCombination.push('Control')\n\t\t\t}\n\t\t\tif (e.metaKey && e.keyCode!=KEY.Meta) {\n\t\t\t keyCombination.push('Meta')\n\t\t\t}\n\t\t\tif (e.altKey && e.keyCode!=KEY.Alt) {\n\t\t\t keyCombination.push('Alt')\n\t\t\t}\n\t\t\tif (e.shiftKey && e.keyCode!=KEY.Shift) {\n\t\t\t keyCombination.push('Shift')\n\t\t\t}\n\t\t\tkeyCombination.push(e.key.toLowerCase())\n\n\t\t\tlet keyboards = []\n\t\t\tlet keyboardElement = event.target.closest('[data-simply-keyboard]')\n\t\t\twhile (keyboardElement) {\n\t\t\t\tkeyboards.push(keyboardElement.dataset.simplyKeyboard)\n\t\t\t\tkeyboardElement = keyboardElement.parentNode.closest('[data-simply-keyboard]')\n\t\t\t}\n\t\t\tkeyboards.push('')\n\n\t\t\tlet keyboard, subkeyboard\n\t\t\tlet separators = ['+','-']\n\n\t\t\tfor (i in keyboards) {\n\t\t\t\tkeyboard = keyboards[i]\n\t\t\t\tif (keyboard == '') {\n\t\t\t\t\tsubkeyboard = 'default'\n\t\t\t\t} else {\n\t\t\t\t\tsubkeyboard = keyboard\n\t\t\t\t\tkeyboard += '.'\n\t\t\t\t}\n\t\t\t\tfor (let separator of separators) {\n\t\t\t\t\tlet keyString = keyCombination.join(separator)\n\n\t\t\t\t\tif (this[subkeyboard] && (typeof this[subkeyboard][keyString]=='function')) {\n\t\t\t\t\t\tlet _continue = this[subkeyboard][keyString].call(options.app, e)\n\t\t\t\t\t\tif (!_continue) {\n\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof this[subkeyboard + keyString] == 'function') {\n\t\t\t\t\t\tlet _continue = this[subkeyboard + keyString].call(options.app, e)\n\t\t\t\t\t\tif (!_continue) {\n\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\t\t\t\t\t\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this[selectedKeyboard] && this[selectedKeyboard][keyString]) {\n\t\t\t\t\t\tlet targets = options.app.container.querySelectorAll('[data-simply-accesskey=\"'\n\t\t\t\t\t\t\t+ keyboard + keyString + '\"]')\n\t\t\t\t\t\tif (targets.length) {\n\t\t\t\t\t\t\ttargets.forEach(t => t.click())\n\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\toptions.app.container.addEventListener('keydown', keyHandler)\n\t}\n\n}\n\nexport function keys(options={}, optionsCompat) {\n\tif (optionsCompat) {\n\t\tlet app = options\n\t\toptions = optionsCompat\n\t\toptions.app = options\n\t}\n\treturn new SimplyKey(options)\n}\n\n", "export function view(options, optionsCompat) {\n\tif (optionsCompat) {\n\t\tlet app = options\n\t\toptions = optionsCompat\n\t\toptions.app = options\n\t}\n\tif (options.app) {\n\t\toptions.app.view = options.view || {}\n\n\t\tconst load = () => {\n\t\t\tconst data = options.app.view\n\t\t\tconst path = globalThis.editor.data.getDataPath(options.app.container || document.body)\n\t\t\toptions.app.view = globalThis.editor.currentData[path]\n\t\t\tObject.assign(options.app.view, data)\n\t\t}\n\t\tif (globalThis.editor && globalThis.editor.currentData) {\n\t\t\tload()\n\t\t} else {\n\t\t\tdocument.addEventListener('simply-content-loaded', load)\n\t\t}\n\t\treturn options.app.view\n\t} else {\n\t\treturn options.view\n\t}\n}", "import { routes } from './route.mjs'\nimport { commands } from './command.mjs'\nimport { actions } from './action.mjs'\nimport { keys } from './key.mjs'\nimport { view } from './view.mjs'\n\nclass SimplyApp {\n\tconstructor(options={}) {\n\t\tthis.container = options.container || document.body\n\t\tfor (let key in options) {\n\t\t\tswitch(key) {\n\t\t\t\tcase 'commands':\n\t\t\t\t\tthis.commands = commands({ app: this, container: this.container, commands: options.commands})\n\t\t\t\t\tbreak\n\t\t\t\tcase 'keys':\n\t\t\t\tcase 'keyboard': // backwards compatible\n\t\t\t\t\tthis.keys = keys({ app: this, keys: options.keys })\n\t\t\t\t\tbreak\n\t\t\t\tcase 'routes':\n\t\t\t\t\tthis.routes = routes({ app: this, routes: options.routes})\n\t\t\t\t\tthis.routes.handleEvents();\n\t\t\t\t\tglobalThis.setTimeout(() => {\n\t\t\t\t\t\tthis.routes.match(globalThis.location?.pathname+globalThis.location?.hash);\n\t\t\t\t\t});\n\t\t\t\t\tbreak\n\t\t\t\tcase 'actions':\n\t\t\t\t\tthis.actions = actions({app: this, actions: options.actions})\n\t\t\t\t\tthis.action = function(name) { // backwards compatible wiht SimplyView2\n\t\t\t\t\t\tconsole.warn('deprecated call to `this.action`')\n\t\t\t\t\t\tlet params = Array.from(arguments).slice()\n\t\t\t\t params.shift()\n\t\t\t\t return this.actions[name](...params)\n\t\t\t\t }\n\t\t\t\t\tbreak\n\t\t\t\tcase 'view':\n\t\t\t\t\tthis.view = view({app: this, view: options.view})\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tthis[key] = options[key] // allows easy additions\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tget app() {\n\t\treturn this\n\t}\n}\n\nexport function app(options={}) {\n\treturn new SimplyApp(options)\n}", "function throttle( callbackFunction, intervalTime ) {\n let eventId = 0\n return () => {\n const myArguments = arguments\n if ( eventId ) {\n return\n } else {\n eventId = globalThis.setTimeout( () => {\n callbackFunction.apply(this, myArguments)\n eventId = 0\n }, intervalTime )\n }\n }\n}\n\nconst runWhenIdle = (() => {\n if (globalThis.requestIdleCallback) {\n return (callback) => {\n globalThis.requestIdleCallback(callback, {timeout: 500})\n }\n }\n return globalThis.requestAnimationFrame\n})()\n\nfunction rebaseHref(relative, base) {\n let url = new URL(relative, base)\n if (include.cacheBuster) {\n url.searchParams.set('cb',include.cacheBuster)\n }\n return url.href\n}\n\nlet observer, loaded = {}\nlet head = globalThis.document.querySelector('head')\nlet currentScript = globalThis.document.currentScript\nlet getScriptURL, currentScriptURL\nif (!currentScript) {\n getScriptURL = (() => {\n var scripts = document.getElementsByTagName('script')\n var index = scripts.length - 1\n var myScript = scripts[index]\n return () => myScript.src\n })()\n currentScriptURL = getScriptURL()\n} else {\n currentScriptURL = currentScript.src\n}\n\nconst waitForPreviousScripts = async () => {\n // because of the async=false attribute, this script will run after\n // the previous scripts have been loaded and run\n // simply.include.next.js only fires the simply-next-script event\n // that triggers the Promise.resolve method\n return new Promise(function(resolve) {\n var next = globalThis.document.createElement('script')\n next.src = \"https://cdn.jsdelivr.net/gh/simplyedit/simplyview/dist/simply.include.next.js\"\n next.async = false\n globalThis.document.addEventListener('simply-include-next', () => {\n head.removeChild(next)\n resolve()\n }, { once: true, passive: true})\n head.appendChild(next)\n })\n}\n\nlet scriptLocations = []\n\nexport const include = {\n cacheBuster: null,\n scripts: (scripts, base) => {\n let arr = scripts.slice()\n const importScript = () => {\n const script = arr.shift()\n if (!script) {\n return\n }\n const attrs = [].map.call(script.attributes, (attr) => {\n return attr.name\n })\n let clone = globalThis.document.createElement('script')\n for (const attr of attrs) {\n clone.setAttribute(attr, script.getAttribute(attr))\n }\n clone.removeAttribute('data-simply-location')\n if (!clone.src) {\n // this is an inline script, so copy the content and wait for previous scripts to run\n clone.innerHTML = script.innerHTML\n waitForPreviousScripts()\n .then(() => {\n const node = scriptLocations[script.dataset.simplyLocation]\n node.parentNode.insertBefore(clone, node)\n node.parentNode.removeChild(node)\n importScript()\n })\n } else {\n clone.src = rebaseHref(clone.src, base)\n if (!clone.hasAttribute('async') && !clone.hasAttribute('defer')) {\n clone.async = false //important! do not use clone.setAttribute('async', false) - it has no effect\n }\n const node = scriptLocations[script.dataset.simplyLocation]\n node.parentNode.insertBefore(clone, node)\n node.parentNode.removeChild(node)\n loaded[clone.src]=true\n importScript()\n }\n }\n if (arr.length) {\n importScript()\n }\n },\n html: (html, link) => {\n let fragment = globalThis.document.createRange().createContextualFragment(html)\n const stylesheets = fragment.querySelectorAll('link[rel=\"stylesheet\"],style')\n // add all stylesheets to head\n for (let stylesheet of stylesheets) {\n if (stylesheet.href) {\n stylesheet.href = rebaseHref(stylesheet.href, link.href)\n }\n head.appendChild(stylesheet)\n }\n // remove the scripts from the fragment, as they will not run in the\n // order in which they are defined\n let scriptsFragment = globalThis.document.createDocumentFragment()\n const scripts = fragment.querySelectorAll('script')\n if (scripts.length) {\n for (let script of scripts) {\n let placeholder = globalThis.document.createComment(script.src || 'inline script')\n script.parentNode.insertBefore(placeholder, script)\n script.dataset.simplyLocation = scriptLocations.length\n scriptLocations.push(placeholder)\n scriptsFragment.appendChild(script)\n }\n globalThis.setTimeout(function() {\n include.scripts(Array.from(scriptsFragment.children), link ? link.href : globalThis.location.href )\n }, 10)\n }\n // add the remainder before the include link\n link.parentNode.insertBefore(fragment, link ? link : null)\n\n }\n}\n\nlet included = {}\nconst includeLinks = async (links) => {\n // mark them as in progress, so handleChanges doesn't find them again\n let remainingLinks = [].reduce.call(links, (remainder, link) => {\n if (link.rel=='simply-include-once' && included[link.href]) {\n link.parentNode.removeChild(link)\n } else {\n included[link.href]=true\n link.rel = 'simply-include-loading'\n remainder.push(link)\n }\n return remainder\n }, [])\n\n for (let link of remainingLinks) {\n if (!link.href) {\n return\n }\n // fetch the html\n const response = await fetch(link.href)\n if (!response.ok) {\n console.log('simply-include: failed to load '+link.href);\n continue\n }\n console.log('simply-include: loaded '+link.href);\n const html = await response.text()\n // if succesfull import the html\n include.html(html, link)\n // remove the include link\n link.parentNode.removeChild(link)\n }\n}\n\nconst handleChanges = throttle(() => {\n runWhenIdle(() => {\n var links = globalThis.document.querySelectorAll('link[rel=\"simply-include\"],link[rel=\"simply-include-once\"]')\n if (links.length) {\n includeLinks(links)\n }\n })\n})\n\nconst observe = () => {\n observer = new MutationObserver(handleChanges)\n observer.observe(globalThis.document, {\n subtree: true,\n childList: true,\n })\n}\n\nobserve()\nhandleChanges() // check if there are include links in the dom already\n", "export class SimplyRender extends HTMLElement \n{\n constructor()\n {\n super()\n let templateId = this.getAttribute(\"rel\")\n let template = document.getElementById(templateId)\n\n if (template) {\n let content = template.content.cloneNode(true)\n for (const node of content.childNodes) {\n const clone = node.cloneNode(true)\n if (clone.nodeType == document.ELEMENT_NODE) {\n clone.querySelectorAll(\"template\").forEach(function(t) {\n t.setAttribute(\"simply-render\", \"\")\n })\n }\n this.parentNode.insertBefore(clone, this)\n }\n this.parentNode.removeChild(this)\n }\n }\n}\n\nif (!customElements.get('simply-render')) {\n customElements.define('simply-render', SimplyRender);\n}\n", "import { activate } from './activate.mjs'\nimport { actions as action } from './action.mjs'\nimport { app } from './app.mjs'\nimport { commands as command } from './command.mjs'\nimport { include } from './include.mjs'\nimport { keys as key } from './key.mjs'\nimport { routes as route } from './route.mjs'\nimport { view } from './view.mjs'\nimport { SimplyRender } from './render.mjs'\n\nconst simply = {\n\tactivate,\n\taction,\n\tapp,\n\tcommand,\n\tinclude,\n\tkey,\n\troute,\n\tview\n}\n\nwindow.simply = simply\n\nexport default simply"],
5
+ "mappings": "MAAA,IAAMA,EAAY,IAAI,IAETC,EAAW,CACpB,YAAa,CAACC,EAAMC,IAAa,CACxBH,EAAU,IAAIE,CAAI,GACnBF,EAAU,IAAIE,EAAM,CAAC,CAAC,EAE1BF,EAAU,IAAIE,CAAI,EAAE,KAAKC,CAAQ,EACjCC,EAAYF,CAAI,CACpB,EACA,eAAgB,CAACA,EAAMC,IAAa,CAChC,GAAI,CAACH,EAAU,IAAIE,CAAI,EACnB,MAAO,GAEXF,EAAU,IAAIE,EAAMF,EAAU,IAAIE,CAAI,EAAE,OAAQG,GACrCA,GAAUF,CACpB,CAAC,CACN,CACJ,EAEA,SAASC,EAAYF,EAAM,CACvB,IAAMI,EAAQ,SAAS,iBAAiB,0BAA0BJ,EAAK,IAAI,EAC3E,GAAII,EACA,QAASC,KAAQD,EACbE,EAAcD,CAAI,CAG9B,CAEA,SAASC,EAAcD,EAAM,CACzB,IAAMN,EAAWM,GAAM,SAAS,eAChC,GAAIN,GAAYD,EAAU,IAAIC,CAAQ,EAClC,QAASE,KAAYH,EAAU,IAAIC,CAAQ,EACvCE,EAAS,KAAKI,CAAI,CAG9B,CAEA,SAASE,EAAcC,EAAS,CAC5B,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L,CAAY,ECfvD,IAAMO,EAAS,CACd,SAAAC,EACA,OAAAC,EACA,IAAAC,EACA,QAAAC,EACA,QAAAC,EACA,IAAAC,EACA,MAAAC,EACA,KAAAC,CACD,EAEA,OAAO,OAASR,EAEhB,IAAOS,GAAQT",
6
+ "names": ["listeners", "activate", "name", "callback", "initialCall", "listener", "nodes", "node", "callListeners", "handleChanges", "changes", "activateNodes", "change", "toActivate", "observer", "actions", "options", "optionsCompat", "app", "actionHandler", "target", "property", "functionHandler", "thisArg", "argumentsList", "result", "err", "routes", "options", "optionsCompat", "app", "SimplyRoute", "parseRoutes", "path", "args", "matches", "getPath", "route", "getURL", "params", "key", "i", "action", "routeRe", "getRegexpFromRoute", "result", "callback", "evt", "link", "listener", "root", "exact", "routeInfo", "paths", "matchParams", "SimplyCommands", "options", "defaultHandlers", "commandHandler", "evt", "command", "getCommand", "el", "value", "name", "params", "handler", "commands", "optionsCompat", "app", "handlers", "values", "option", "data", "input", "KEY", "SimplyKey", "options", "keyHandler", "e", "selectedKeyboard", "keyCombination", "keyboards", "keyboardElement", "keyboard", "subkeyboard", "separators", "separator", "keyString", "targets", "t", "keys", "optionsCompat", "app", "view", "options", "optionsCompat", "app", "load", "data", "path", "SimplyApp", "options", "key", "commands", "keys", "routes", "actions", "name", "params", "view", "app", "throttle", "callbackFunction", "intervalTime", "eventId", "myArguments", "runWhenIdle", "callback", "rebaseHref", "relative", "base", "url", "include", "observer", "loaded", "head", "currentScript", "getScriptURL", "currentScriptURL", "scripts", "index", "myScript", "waitForPreviousScripts", "resolve", "next", "scriptLocations", "arr", "importScript", "script", "attrs", "attr", "clone", "node", "html", "link", "fragment", "stylesheets", "stylesheet", "scriptsFragment", "placeholder", "included", "includeLinks", "links", "remainingLinks", "remainder", "response", "handleChanges", "observe", "SimplyRender", "templateId", "template", "content", "node", "clone", "t", "simply", "activate", "actions", "app", "commands", "include", "keys", "routes", "view", "everything_default"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simplyview",
3
- "version": "3.0.5",
3
+ "version": "3.1.0",
4
4
  "description": "Library to rapidly build UI components, using declarative tools",
5
5
  "main": "src/everything.mjs",
6
6
  "type": "module",
@@ -47,4 +47,4 @@
47
47
  "dependencies": {
48
48
  "jest-silent-reporter": "^0.6.0"
49
49
  }
50
- }
50
+ }
package/src/action.mjs CHANGED
@@ -2,16 +2,39 @@ export function actions(options, optionsCompat) {
2
2
  if (optionsCompat) {
3
3
  let app = options
4
4
  options = optionsCompat
5
- options.app = options
5
+ options.app = app
6
6
  }
7
7
  if (options.app) {
8
8
  const actionHandler = {
9
- get: (target, property) => {
10
- return target[property].bind(options.app)
9
+ get(target, property) {
10
+ if (!target[property]) {
11
+ return undefined
12
+ }
13
+ if (target.catch) {
14
+ return new Proxy(target[property].bind(options.app), functionHandler)
15
+ } else {
16
+ return target[property].bind(options.app)
17
+ }
11
18
  }
12
19
  }
13
20
  return new Proxy(options.actions, actionHandler)
14
21
  } else {
15
22
  return options
16
23
  }
24
+ }
25
+
26
+ const functionHandler = {
27
+ apply(target, thisArg, argumentsList) {
28
+ try {
29
+ const result = target(...argumentsList)
30
+ if (result instanceof Promise) {
31
+ return result.catch(err => {
32
+ return thisArg.catch(err)
33
+ })
34
+ }
35
+ return result
36
+ } catch(err) {
37
+ return thisArg.catch(err)
38
+ }
39
+ }
17
40
  }
package/src/app.mjs CHANGED
@@ -18,6 +18,10 @@ class SimplyApp {
18
18
  break
19
19
  case 'routes':
20
20
  this.routes = routes({ app: this, routes: options.routes})
21
+ this.routes.handleEvents();
22
+ globalThis.setTimeout(() => {
23
+ this.routes.match(globalThis.location?.pathname+globalThis.location?.hash);
24
+ });
21
25
  break
22
26
  case 'actions':
23
27
  this.actions = actions({app: this, actions: options.actions})
@@ -6,6 +6,7 @@ import { include } from './include.mjs'
6
6
  import { keys as key } from './key.mjs'
7
7
  import { routes as route } from './route.mjs'
8
8
  import { view } from './view.mjs'
9
+ import { SimplyRender } from './render.mjs'
9
10
 
10
11
  const simply = {
11
12
  activate,
package/src/key.mjs CHANGED
@@ -70,14 +70,14 @@ class SimplyKey {
70
70
  let keyString = keyCombination.join(separator)
71
71
 
72
72
  if (this[subkeyboard] && (typeof this[subkeyboard][keyString]=='function')) {
73
- let _continue = this[subkeyboard][keyString].call(this[subkeyboard], e)
73
+ let _continue = this[subkeyboard][keyString].call(options.app, e)
74
74
  if (!_continue) {
75
75
  e.preventDefault()
76
76
  return
77
77
  }
78
78
  }
79
79
  if (typeof this[subkeyboard + keyString] == 'function') {
80
- let _continue = this[subkeyboard + keyString].call(this, e)
80
+ let _continue = this[subkeyboard + keyString].call(options.app, e)
81
81
  if (!_continue) {
82
82
  e.preventDefault()
83
83
  return
package/src/render.mjs ADDED
@@ -0,0 +1,27 @@
1
+ export class SimplyRender extends HTMLElement
2
+ {
3
+ constructor()
4
+ {
5
+ super()
6
+ let templateId = this.getAttribute("rel")
7
+ let template = document.getElementById(templateId)
8
+
9
+ if (template) {
10
+ let content = template.content.cloneNode(true)
11
+ for (const node of content.childNodes) {
12
+ const clone = node.cloneNode(true)
13
+ if (clone.nodeType == document.ELEMENT_NODE) {
14
+ clone.querySelectorAll("template").forEach(function(t) {
15
+ t.setAttribute("simply-render", "")
16
+ })
17
+ }
18
+ this.parentNode.insertBefore(clone, this)
19
+ }
20
+ this.parentNode.removeChild(this)
21
+ }
22
+ }
23
+ }
24
+
25
+ if (!customElements.get('simply-render')) {
26
+ customElements.define('simply-render', SimplyRender);
27
+ }
package/src/route.mjs CHANGED
@@ -1,39 +1,45 @@
1
- export function routes(options, optionsCompat) {
1
+ export function routes(options, optionsCompat)
2
+ {
2
3
  if (optionsCompat) {
3
4
  let app = options
4
5
  options = optionsCompat
5
6
  options.app = options
6
7
  }
7
- return new SimplyRoute(options)
8
+ return new SimplyRoute(options)
8
9
  }
9
10
 
10
- class SimplyRoute {
11
- constructor(options={}) {
12
- this.root = options.root || '/'
13
- this.app = options.app
11
+ class SimplyRoute
12
+ {
13
+ constructor(options={})
14
+ {
15
+ this.root = options.root || '/'
16
+ this.app = options.app || {}
14
17
  this.addMissingSlash = !!options.addMissingSlash
15
18
  this.matchExact = !!options.matchExact
16
- this.clear()
17
- if (options.routes) {
18
- this.load(options.routes)
19
- }
20
- }
21
-
22
- load(routes) {
23
- parseRoutes(routes, this.routeInfo, this.matchExact)
24
- }
25
-
26
- clear() {
27
- this.routeInfo = []
28
- this.listeners = {
29
- match: {},
30
- call: {},
31
- finish: {}
32
- }
33
- }
34
-
35
- match(path, options) {
36
- let args = {
19
+ this.clear()
20
+ if (options.routes) {
21
+ this.load(options.routes)
22
+ }
23
+ }
24
+
25
+ load(routes)
26
+ {
27
+ parseRoutes(routes, this.routeInfo, this.matchExact)
28
+ }
29
+
30
+ clear()
31
+ {
32
+ this.routeInfo = []
33
+ this.listeners = {
34
+ match: {},
35
+ call: {},
36
+ finish: {}
37
+ }
38
+ }
39
+
40
+ match(path, options)
41
+ {
42
+ let args = {
37
43
  path,
38
44
  options
39
45
  }
@@ -73,15 +79,16 @@ class SimplyRoute {
73
79
  args.params = params
74
80
  args = this.runListeners('call', args)
75
81
  params = args.params ? args.params : params
76
- args.result = route.action.call(route, params)
82
+ args.result = route.action.call(this.app, params)
77
83
  this.runListeners('finish', args)
78
84
  return args.result
79
85
  }
80
86
  }
81
87
  return false
82
- }
88
+ }
83
89
 
84
- runListeners(action, params) {
90
+ runListeners(action, params)
91
+ {
85
92
  if (!Object.keys(this.listeners[action])) {
86
93
  return
87
94
  }
@@ -100,55 +107,58 @@ class SimplyRoute {
100
107
  return params
101
108
  }
102
109
 
103
- handleEvents() {
110
+ handleEvents()
111
+ {
104
112
  globalThis.addEventListener('popstate', () => {
105
113
  if (this.match(getPath(document.location.pathname + document.location.hash, this.root)) === false) {
106
114
  this.match(getPath(document.location.pathname, this.root))
107
115
  }
108
116
  })
109
117
  this.app.container.addEventListener('click', (evt) => {
110
- if (evt.ctrlKey) {
111
- return;
112
- }
113
- if (evt.which != 1) {
114
- return; // not a 'left' mouse click
115
- }
116
- var link = evt.target;
117
- while (link && link.tagName!='A') {
118
- link = link.parentElement;
119
- }
120
- if (link
121
- && link.pathname
122
- && link.hostname==globalThis.location.hostname
123
- && !link.link
124
- && !link.dataset.simplyCommand
125
- ) {
126
- let path = getPath(link.pathname+link.hash, this.root);
127
- if ( !this.has(path) ) {
128
- path = getPath(link.pathname, this.root);
129
- }
130
- if ( this.has(path) ) {
131
- let params = this.runListeners('goto', { path: path});
132
- if (params.path) {
133
- if (this.goto(params.path)) {
118
+ if (evt.ctrlKey) {
119
+ return;
120
+ }
121
+ if (evt.which != 1) {
122
+ return; // not a 'left' mouse click
123
+ }
124
+ var link = evt.target;
125
+ while (link && link.tagName!='A') {
126
+ link = link.parentElement;
127
+ }
128
+ if (link
129
+ && link.pathname
130
+ && link.hostname==globalThis.location.hostname
131
+ && !link.link
132
+ && !link.dataset.simplyCommand
133
+ ) {
134
+ let path = getPath(link.pathname+link.hash, this.root);
135
+ if ( !this.has(path) ) {
136
+ path = getPath(link.pathname, this.root);
137
+ }
138
+ if ( this.has(path) ) {
139
+ let params = this.runListeners('goto', { path: path});
140
+ if (params.path) {
141
+ if (this.goto(params.path)) {
134
142
  // now cancel the browser navigation, since a route handler was found
135
143
  evt.preventDefault();
136
144
  return false;
137
145
  }
138
- }
139
- }
140
- }
141
- })
146
+ }
147
+ }
148
+ }
149
+ })
142
150
  }
143
151
 
144
- goto(path) {
152
+ goto(path)
153
+ {
145
154
  history.pushState({},'',getURL(path))
146
155
  return this.match(path)
147
156
  }
148
157
 
149
- has(path) {
150
- path = getPath(path, this.root)
151
- for (let route of this.routeInfo) {
158
+ has(path)
159
+ {
160
+ path = getPath(path, this.root)
161
+ for (let route of this.routeInfo) {
152
162
  var matches = route.match.exec(path)
153
163
  if (matches && matches.length) {
154
164
  return true
@@ -157,7 +167,8 @@ class SimplyRoute {
157
167
  return false
158
168
  }
159
169
 
160
- addListener(action, route, callback) {
170
+ addListener(action, route, callback)
171
+ {
161
172
  if (['goto','match','call','finish'].indexOf(action)==-1) {
162
173
  throw new Error('Unknown action '+action)
163
174
  }
@@ -167,7 +178,8 @@ class SimplyRoute {
167
178
  this.listeners[action][route].push(callback)
168
179
  }
169
180
 
170
- removeListener(action, route, callback) {
181
+ removeListener(action, route, callback)
182
+ {
171
183
  if (['match','call','finish'].indexOf(action)==-1) {
172
184
  throw new Error('Unknown action '+action)
173
185
  }
@@ -179,14 +191,16 @@ class SimplyRoute {
179
191
  })
180
192
  }
181
193
 
182
- init(options) {
183
- if (options.root) {
184
- this.root = options.root
185
- }
194
+ init(options)
195
+ {
196
+ if (options.root) {
197
+ this.root = options.root
198
+ }
186
199
  }
187
200
  }
188
201
 
189
- function getPath(path, root='/') {
202
+ function getPath(path, root='/')
203
+ {
190
204
  if (path.substring(0,root.length)==root
191
205
  ||
192
206
  ( root[root.length-1]=='/'
@@ -202,7 +216,8 @@ function getPath(path, root='/') {
202
216
  return path
203
217
  }
204
218
 
205
- function getURL(path, root) {
219
+ function getURL(path, root)
220
+ {
206
221
  path = getPath(path, root)
207
222
  if (root[root.length-1]==='/' && path[0]==='/') {
208
223
  path = path.substring(1)
@@ -210,14 +225,16 @@ function getURL(path, root) {
210
225
  return root + path;
211
226
  }
212
227
 
213
- function getRegexpFromRoute(route, exact=false) {
228
+ function getRegexpFromRoute(route, exact=false)
229
+ {
214
230
  if (exact) {
215
231
  return new RegExp('^'+route.replace(/:\w+/g, '([^/]+)').replace(/:\*/, '(.*)')+'(\\?|$)')
216
232
  }
217
233
  return new RegExp('^'+route.replace(/:\w+/g, '([^/]+)').replace(/:\*/, '(.*)'))
218
234
  }
219
235
 
220
- function parseRoutes(routes, routeInfo, exact=false) {
236
+ function parseRoutes(routes, routeInfo, exact=false)
237
+ {
221
238
  const paths = Object.keys(routes)
222
239
  const matchParams = /:(\w+|\*)/g
223
240
  for (let path of paths) {
@@ -236,4 +253,4 @@ function parseRoutes(routes, routeInfo, exact=false) {
236
253
  })
237
254
  }
238
255
  return routeInfo
239
- }
256
+ }