simplyview 3.1.4 → 3.4.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/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 goto: {},\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, this.root))\n }\n }\n }\n if (matches && matches.length) {\n let 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 const searchParams = new URLSearchParams(document.location.search)\n args.result = route.action.call(this.app, params, searchParams)\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 check = [link.hash, link.pathname+link.hash, link.pathname]\n let path\n do {\n path = getPath(check.shift(), this.root);\n } while(check.length && !this.has(path))\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, this.root))\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 if (path[0]=='#') {\n return path\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 (let 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\tif (this.routes.has(globalThis.location?.hash)) {\n\t\t\t\t\t\t\tthis.routes.match(globalThis.location.hash)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.routes.match(globalThis.location?.pathname+globalThis.location?.hash)\n\t\t\t\t\t\t}\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\nglobalThis.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,EA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EAAQD,EAAK,UAAU,EAAI,EAC7BC,EAAM,UAAY,SAAS,cAC3BA,EAAM,iBAAiB,UAAU,EAAE,QAAQ,SAASC,EAAG,CACnDA,EAAE,aAAa,gBAAiB,EAAE,CACtC,CAAC,EAEL,KAAK,WAAW,aAAaD,EAAO,IAAI,CAC5C,CACA,KAAK,WAAW,YAAY,IAAI,CACpC,CACJ,CACJ,EAEK,eAAe,IAAI,eAAe,GACnC,eAAe,OAAO,gBAAiBL,CAAY,ECfvD,IAAMO,EAAS,CACd,SAAAC,EACA,OAAAC,EACA,IAAAC,EACA,QAAAC,EACA,QAAAC,EACA,IAAAC,EACA,MAAAC,EACA,KAAAC,CACD,EAEA,WAAW,OAASR,EAEpB,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", "searchParams", "action", "routeRe", "getRegexpFromRoute", "result", "callback", "evt", "link", "check", "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", "i", "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"]
3
+ "sources": ["../src/activate.mjs", "../src/action.mjs", "../src/route.mjs", "../src/command.mjs", "../src/key.mjs", "../src/view.mjs", "../src/highlight.mjs", "../src/app.mjs", "../src/include.mjs", "../src/render.mjs", "../src/everything.mjs"],
4
+ "sourcesContent": ["if (!Symbol.onDestroy) {\n Symbol.onDestroy = Symbol('onDestroy')\n}\n\nconst 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 const onDestroy = callback.call(node)\n if (typeof onDestroy == 'function') {\n node[Symbol.onDestroy] = onDestroy\n } else if (typeof onDestroy != 'undefined') {\n console.warn('activate listener may only return a de-activate function, instead got', onDestroy)\n }\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 let 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 for (let node of change.removedNodes) {\n if (node.querySelectorAll) {\n let toDestroy = Array.from(node.querySelectorAll('[data-simply-activate]'))\n if (node.matches['[data-simply-activate']) {\n toDestroy.push(node)\n }\n for (let child of toDestroy) {\n if (child[Symbol.onDestroy]) {\n child[Symbol.onDestroy].call(child)\n }\n }\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{\n\tif (optionsCompat) {\n\t\tlet app = options\n\t\toptions = optionsCompat\n\t\toptions.app = app\n\t}\n\n\tif (options.app) {\n\t\tconst waitHandler = {\n\t\t\tapply(target, thisArg, argumentsList)\n\t\t\t{\n\t\t\t\ttry {\n\t\t\t\t\tconst result = target(...argumentsList)\n\t\t\t\t\tif (result instanceof Promise) {\n\t\t\t\t\t\toptions.app.hooks.wait(true)\n\t\t\t\t\t\treturn result.finally(() => {\n\t\t\t\t\t\t\toptions.app.hooks.wait(false, target)\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\treturn result\n\t\t\t\t} catch(err) {\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst functionHandler = {\n\t\t\tapply(target, thisArg, argumentsList)\n\t\t\t{\n\t\t\t\ttry {\n\t\t\t\t\tconst result = target(...argumentsList)\n\t\t\t\t\tif (result instanceof Promise) {\n\t\t\t\t\t\tif (options.app.hooks.wait) {\n\t\t\t\t\t\t\toptions.app.hooks.wait(true, target)\n\t\t\t\t\t\t\treturn result.catch(err => {\n\t\t\t\t\t\t\t\treturn options.app.hooks.error(err, target)\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.finally(() => {\n\t\t\t\t\t\t\t\toptions.app.hooks.wait(false, target)\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn result.catch(err => {\n\t\t\t\t\t\t\t\treturn options.app.hooks.error(err, target)\n\t\t\t\t\t\t\t})\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn result\n\t\t\t\t} catch(err) {\n\t\t\t\t\treturn options.app.hooks.error(err, target)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst actionHandler = {\n\t\t\tget(target, property)\n\t\t\t{\n\t\t\t\tif (!target[property]) {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tif (options.app.hooks?.error) {\n\t\t\t\t\treturn new Proxy(target[property].bind(options.app), functionHandler)\n\t\t\t\t} else if (options.app.hooks?.wait) {\n\t\t\t\t\treturn new Proxy(target[property].bind(options.app), waitHandler)\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}", "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.baseURL = options.baseURL || '/'\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 goto: {},\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, this.baseURL))\n }\n }\n }\n if (matches && matches.length) {\n let 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 const searchParams = new URLSearchParams(document.location.search)\n args.result = route.action.call(this.app, params, searchParams)\n this.runListeners('finish', args)\n return args.result\n }\n }\n return false\n }\n\n runListeners(action, params)\n {\n if (!this.listeners[action] || !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.baseURL)) === false) {\n this.match(getPath(document.location.pathname, this.baseURL))\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 check = [link.hash, link.pathname+link.hash, link.pathname]\n let path\n do {\n path = getPath(check.shift(), this.baseURL);\n } while(check.length && !this.has(path))\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, this.baseURL))\n return this.match(path)\n }\n\n has(path)\n {\n path = getPath(path, this.baseURL)\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.baseURL) {\n this.baseURL = options.baseURL\n }\n }\n}\n\nfunction getPath(path, baseURL='/')\n{\n if (path.substring(0,baseURL.length)==baseURL\n ||\n ( baseURL[baseURL.length-1]=='/' \n && path.length==(baseURL.length-1)\n && path == baseURL.substring(0,path.length)\n )\n ) {\n path = path.substring(baseURL.length)\n }\n if (path[0]!='/' && path[0]!='#') {\n path = '/'+path\n }\n return path\n}\n\nfunction getURL(path, baseURL)\n{\n path = getPath(path, baseURL)\n if (baseURL[baseURL.length-1]==='/' && path[0]==='/') {\n path = path.substring(1)\n }\n if (path[0]=='#') {\n return path\n }\n return baseURL + 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 (let 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}", "export function html(strings, ...values) {\n const outputArray = values.map(\n (value, index) =>\n `${strings[index]}${value}`,\n );\n return outputArray.join(\"\") + strings[strings.length - 1];\n}\n\nexport function css(strings, ...values) {\n\treturn html(strings, ...values)\n}\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'\nimport { html, css } from './highlight.mjs'\n\n\nclass SimplyApp\n{\n\n\tconstructor(options={})\n\t{\n\t\tthis.container = options.container || document.body\n\t\tif (options.components) {\n\t\t\tmergeComponents(options, options.components)\n\t\t}\n\t\tfor (let key in options) {\n\t\t\tswitch(key) {\n\t\t\t\tcase 'html':\n\t\t\t\t\tfor (const name in options.html) {\n\t\t\t\t\t\tconst element = document.createElement('div')\n\t\t\t\t\t\telement.innerHTML = options.html[name]\n\t\t\t\t\t\tlet template = this.container.querySelector('template#'+name)\n\t\t\t\t\t\tif (!template) {\n\t\t\t\t\t\t\ttemplate = document.createElement('template')\n\t\t\t\t\t\t\ttemplate.id=name\n\t\t\t\t\t\t\ttemplate.content.append(...element.children)\n\t\t\t\t\t\t\tthis.container.appendChild(template)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttemplate.content.replaceChildren(...element.children)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t\tcase 'css':\n\t\t\t\t\tfor (const name in options.css) {\n\t\t\t\t\t\tlet style = this.container.querySelector('style#'+name)\n\t\t\t\t\t\tif (!style) {\n\t\t\t\t\t\t\tstyle = document.createElement('style')\n\t\t\t\t\t\t\tstyle.id=name \n\t\t\t\t\t\t\tthis.container.appendChild(style)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstyle.innerHTML = options.css[name]\n\t\t\t\t\t}\n\t\t\t\tbreak\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 'root': // backwards compatibility\n\t\t\t\tcase 'baseURL':\n\t\t\t\t\tthis.baseURL = options[key]\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\tcase 'hooks':\n\t\t\t\t\tconst moduleHandler = {\n\t\t\t\t\t\tget: (target, property) => {\n\t\t\t\t\t\t\tif (!target[property]) {\n\t\t\t\t\t\t\t\treturn undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (typeof target[property]=='function') {\n\t\t\t\t\t\t\t\treturn new Proxy(target[property], functionHandler)\n\t\t\t\t\t\t\t} else if (target[property] && typeof target[property]=='object') {\n\t\t\t\t\t\t\t\treturn new Proxy(target[property], moduleHandler)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn target[property]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tconst functionHandler = {\n\t\t\t\t\t\tapply: (target, thisArg, argumentsList) => {\n\t\t\t\t\t\t\t// note: must use short function syntax so this is set to the app\n\t\t\t\t\t\t\treturn target.apply(this, argumentsList)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthis[key] = new Proxy(options[key], moduleHandler)\n\t\t\t\t\tbreak\n\t\t\t\tcomponents:\n\t\t\t\t\tthis.components = components\n\t\t\t\t\tbreak\n\t\t\t\tprototype:\n\t\t\t\t__proto__:\n\t\t\t\t\t// ignore this to avoid prototype pollution\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tconsole.log('simply.app: unknown initialization option \"'+key+'\", added as-is')\n\t\t\t\t\tthis[key] = options[key]\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tget app()\n\t{\n\t\treturn this\n\t}\n\n\tasync start()\n\t{\n\t\tif (this.components) {\n\t\t\tfor (const name in this.components) {\n\t\t\t\tif (this.components[name].hooks?.start) {\n\t\t\t\t\tawait this.components[name].hooks.start()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (this.hooks?.start) {\n\t\t\tawait this.hooks.start()\n\t\t}\n\t\tif (this.routes) {\n\t\t\tif (this.baseURL) {\n\t\t\t\tthis.routes.init({ baseURL: this.baseURL })\n\t\t\t}\n\t\t\tthis.routes.handleEvents();\n\t\t\tglobalThis.setTimeout(() => {\n\t\t\t\tif (this.routes.has(globalThis.location?.hash)) {\n\t\t\t\t\tthis.routes.match(globalThis.location.hash)\n\t\t\t\t} else {\n\t\t\t\t\tthis.routes.match(globalThis.location?.pathname+globalThis.location?.hash)\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n}\n\nexport function app(options={})\n{\n\treturn new SimplyApp(options)\n}\n\nif (!globalThis.html) {\n\tglobalThis.html = html\n}\nif (!globalThis.css) {\n\tglobalThis.css = css\n}\n\nfunction mergeOptions(options, otherOptions)\n{\n\tfor (const key in otherOptions) {\n\t\tswitch(typeof otherOptions[key]) {\n\t\t\tcase 'object':\n\t\t\t\tif (!otherOptions[key]) {\n\t\t\t\t\tcontinue // null\n\t\t\t\t}\n\t\t\t\tif (!options[key]) {\n\t\t\t\t\toptions[key] = otherOptions[key]\n\t\t\t\t} else {\n\t\t\t\t\t//FIXME: check that options[key] is also an object\n\t\t\t\t\tmergeOptions(options[key], otherOptions[key])\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\toptions[key] = otherOptions[key]\n\t\t}\n\t}\n}\n\nfunction mergeComponents(options, components) {\n\tfor (const name in components) {\n\t\tconst component = components[name]\n\t\tif (component.components) {\n\t\t\tmergeComponents(options, component.components)\n\t\t}\n\t\toptions.components[name] = component\n\t\tfor (const key in component) {\n\t\t\tswitch(key) {\n\t\t\t\tcase 'hooks':\n\t\t\t\t\t// don't merge these, app.hooks.start will trigger each components start hook\n\t\t\t\tcase 'components':\n\t\t\t\t\t// already handled\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tif (!options[key]) {\n\t\t\t\t\t\toptions[key] = Object.create(null)\n\t\t\t\t\t}\n\t\t\t\t\tmergeOptions(options[key], component[key])\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\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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AAAC,EACA,IAAAC,EACA,QAAAC,EACA,QAAAC,EACA,IAAAC,EACA,MAAAC,EACA,KAAAC,CACD,EAEA,WAAW,OAASR,EAEpB,IAAOS,GAAQT",
6
+ "names": ["listeners", "activate", "name", "callback", "initialCall", "listener", "nodes", "node", "callListeners", "onDestroy", "handleChanges", "changes", "activateNodes", "change", "toActivate", "toDestroy", "child", "observer", "actions", "options", "optionsCompat", "app", "waitHandler", "target", "thisArg", "argumentsList", "result", "functionHandler", "err", "actionHandler", "property", "routes", "options", "optionsCompat", "app", "SimplyRoute", "parseRoutes", "path", "args", "matches", "getPath", "route", "getURL", "params", "key", "i", "searchParams", "action", "routeRe", "getRegexpFromRoute", "result", "callback", "evt", "link", "check", "listener", "baseURL", "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", "i", "separator", "keyString", "targets", "t", "keys", "optionsCompat", "app", "view", "options", "optionsCompat", "app", "load", "data", "path", "html", "strings", "values", "value", "index", "css", "SimplyApp", "options", "mergeComponents", "key", "name", "element", "template", "style", "commands", "keys", "routes", "actions", "params", "view", "moduleHandler", "target", "property", "functionHandler", "thisArg", "argumentsList", "app", "html", "css", "mergeOptions", "otherOptions", "components", "component", "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.1.4",
3
+ "version": "3.4.0",
4
4
  "description": "Library to rapidly build UI components, using declarative tools",
5
5
  "main": "src/everything.mjs",
6
6
  "type": "module",
package/src/action.mjs CHANGED
@@ -1,17 +1,66 @@
1
- export function actions(options, optionsCompat) {
1
+ export function actions(options, optionsCompat)
2
+ {
2
3
  if (optionsCompat) {
3
4
  let app = options
4
5
  options = optionsCompat
5
6
  options.app = app
6
7
  }
8
+
7
9
  if (options.app) {
10
+ const waitHandler = {
11
+ apply(target, thisArg, argumentsList)
12
+ {
13
+ try {
14
+ const result = target(...argumentsList)
15
+ if (result instanceof Promise) {
16
+ options.app.hooks.wait(true)
17
+ return result.finally(() => {
18
+ options.app.hooks.wait(false, target)
19
+ })
20
+ }
21
+ return result
22
+ } catch(err) {
23
+ }
24
+ }
25
+ }
26
+
27
+ const functionHandler = {
28
+ apply(target, thisArg, argumentsList)
29
+ {
30
+ try {
31
+ const result = target(...argumentsList)
32
+ if (result instanceof Promise) {
33
+ if (options.app.hooks.wait) {
34
+ options.app.hooks.wait(true, target)
35
+ return result.catch(err => {
36
+ return options.app.hooks.error(err, target)
37
+ })
38
+ .finally(() => {
39
+ options.app.hooks.wait(false, target)
40
+ })
41
+ } else {
42
+ return result.catch(err => {
43
+ return options.app.hooks.error(err, target)
44
+ })
45
+ }
46
+ }
47
+ return result
48
+ } catch(err) {
49
+ return options.app.hooks.error(err, target)
50
+ }
51
+ }
52
+ }
53
+
8
54
  const actionHandler = {
9
- get(target, property) {
55
+ get(target, property)
56
+ {
10
57
  if (!target[property]) {
11
58
  return undefined
12
59
  }
13
- if (target.catch) {
60
+ if (options.app.hooks?.error) {
14
61
  return new Proxy(target[property].bind(options.app), functionHandler)
62
+ } else if (options.app.hooks?.wait) {
63
+ return new Proxy(target[property].bind(options.app), waitHandler)
15
64
  } else {
16
65
  return target[property].bind(options.app)
17
66
  }
@@ -21,20 +70,4 @@ export function actions(options, optionsCompat) {
21
70
  } else {
22
71
  return options
23
72
  }
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
- }
40
73
  }
package/src/activate.mjs CHANGED
@@ -1,3 +1,7 @@
1
+ if (!Symbol.onDestroy) {
2
+ Symbol.onDestroy = Symbol('onDestroy')
3
+ }
4
+
1
5
  const listeners = new Map()
2
6
 
3
7
  export const activate = {
@@ -31,7 +35,12 @@ function callListeners(node) {
31
35
  const activate = node?.dataset?.simplyActivate
32
36
  if (activate && listeners.has(activate)) {
33
37
  for (let callback of listeners.get(activate)) {
34
- callback.call(node)
38
+ const onDestroy = callback.call(node)
39
+ if (typeof onDestroy == 'function') {
40
+ node[Symbol.onDestroy] = onDestroy
41
+ } else if (typeof onDestroy != 'undefined') {
42
+ console.warn('activate listener may only return a de-activate function, instead got', onDestroy)
43
+ }
35
44
  }
36
45
  }
37
46
  }
@@ -42,13 +51,26 @@ function handleChanges(changes) {
42
51
  if (change.type == 'childList') {
43
52
  for (let node of change.addedNodes) {
44
53
  if (node.querySelectorAll) {
45
- var toActivate = Array.from(node.querySelectorAll('[data-simply-activate]'))
54
+ let toActivate = Array.from(node.querySelectorAll('[data-simply-activate]'))
46
55
  if (node.matches('[data-simply-activate]')) {
47
56
  toActivate.push(node)
48
57
  }
49
58
  activateNodes = activateNodes.concat(toActivate)
50
59
  }
51
60
  }
61
+ for (let node of change.removedNodes) {
62
+ if (node.querySelectorAll) {
63
+ let toDestroy = Array.from(node.querySelectorAll('[data-simply-activate]'))
64
+ if (node.matches['[data-simply-activate']) {
65
+ toDestroy.push(node)
66
+ }
67
+ for (let child of toDestroy) {
68
+ if (child[Symbol.onDestroy]) {
69
+ child[Symbol.onDestroy].call(child)
70
+ }
71
+ }
72
+ }
73
+ }
52
74
  }
53
75
  }
54
76
  for (let node of activateNodes) {
package/src/app.mjs CHANGED
@@ -3,12 +3,46 @@ import { commands } from './command.mjs'
3
3
  import { actions } from './action.mjs'
4
4
  import { keys } from './key.mjs'
5
5
  import { view } from './view.mjs'
6
+ import { html, css } from './highlight.mjs'
6
7
 
7
- class SimplyApp {
8
- constructor(options={}) {
8
+
9
+ class SimplyApp
10
+ {
11
+
12
+ constructor(options={})
13
+ {
9
14
  this.container = options.container || document.body
15
+ if (options.components) {
16
+ mergeComponents(options, options.components)
17
+ }
10
18
  for (let key in options) {
11
19
  switch(key) {
20
+ case 'html':
21
+ for (const name in options.html) {
22
+ const element = document.createElement('div')
23
+ element.innerHTML = options.html[name]
24
+ let template = this.container.querySelector('template#'+name)
25
+ if (!template) {
26
+ template = document.createElement('template')
27
+ template.id=name
28
+ template.content.append(...element.children)
29
+ this.container.appendChild(template)
30
+ } else {
31
+ template.content.replaceChildren(...element.children)
32
+ }
33
+ }
34
+ break
35
+ case 'css':
36
+ for (const name in options.css) {
37
+ let style = this.container.querySelector('style#'+name)
38
+ if (!style) {
39
+ style = document.createElement('style')
40
+ style.id=name
41
+ this.container.appendChild(style)
42
+ }
43
+ style.innerHTML = options.css[name]
44
+ }
45
+ break
12
46
  case 'commands':
13
47
  this.commands = commands({ app: this, container: this.container, commands: options.commands})
14
48
  break
@@ -16,16 +50,12 @@ class SimplyApp {
16
50
  case 'keyboard': // backwards compatible
17
51
  this.keys = keys({ app: this, keys: options.keys })
18
52
  break
53
+ case 'root': // backwards compatibility
54
+ case 'baseURL':
55
+ this.baseURL = options[key]
56
+ break
19
57
  case 'routes':
20
58
  this.routes = routes({ app: this, routes: options.routes})
21
- this.routes.handleEvents();
22
- globalThis.setTimeout(() => {
23
- if (this.routes.has(globalThis.location?.hash)) {
24
- this.routes.match(globalThis.location.hash)
25
- } else {
26
- this.routes.match(globalThis.location?.pathname+globalThis.location?.hash)
27
- }
28
- });
29
59
  break
30
60
  case 'actions':
31
61
  this.actions = actions({app: this, actions: options.actions})
@@ -39,17 +69,132 @@ class SimplyApp {
39
69
  case 'view':
40
70
  this.view = view({app: this, view: options.view})
41
71
  break
72
+ case 'hooks':
73
+ const moduleHandler = {
74
+ get: (target, property) => {
75
+ if (!target[property]) {
76
+ return undefined
77
+ }
78
+ if (typeof target[property]=='function') {
79
+ return new Proxy(target[property], functionHandler)
80
+ } else if (target[property] && typeof target[property]=='object') {
81
+ return new Proxy(target[property], moduleHandler)
82
+ } else {
83
+ return target[property]
84
+ }
85
+ }
86
+ }
87
+ const functionHandler = {
88
+ apply: (target, thisArg, argumentsList) => {
89
+ // note: must use short function syntax so this is set to the app
90
+ return target.apply(this, argumentsList)
91
+ }
92
+ }
93
+ this[key] = new Proxy(options[key], moduleHandler)
94
+ break
95
+ components:
96
+ this.components = components
97
+ break
98
+ prototype:
99
+ __proto__:
100
+ // ignore this to avoid prototype pollution
101
+ break
42
102
  default:
43
- this[key] = options[key] // allows easy additions
103
+ console.log('simply.app: unknown initialization option "'+key+'", added as-is')
104
+ this[key] = options[key]
44
105
  break
45
106
  }
46
107
  }
47
108
  }
48
- get app() {
109
+
110
+ get app()
111
+ {
49
112
  return this
50
113
  }
114
+
115
+ async start()
116
+ {
117
+ if (this.components) {
118
+ for (const name in this.components) {
119
+ if (this.components[name].hooks?.start) {
120
+ await this.components[name].hooks.start()
121
+ }
122
+ }
123
+ }
124
+ if (this.hooks?.start) {
125
+ await this.hooks.start()
126
+ }
127
+ if (this.routes) {
128
+ if (this.baseURL) {
129
+ this.routes.init({ baseURL: this.baseURL })
130
+ }
131
+ this.routes.handleEvents();
132
+ globalThis.setTimeout(() => {
133
+ if (this.routes.has(globalThis.location?.hash)) {
134
+ this.routes.match(globalThis.location.hash)
135
+ } else {
136
+ this.routes.match(globalThis.location?.pathname+globalThis.location?.hash)
137
+ }
138
+ });
139
+ }
140
+ }
141
+
51
142
  }
52
143
 
53
- export function app(options={}) {
144
+ export function app(options={})
145
+ {
54
146
  return new SimplyApp(options)
55
- }
147
+ }
148
+
149
+ if (!globalThis.html) {
150
+ globalThis.html = html
151
+ }
152
+ if (!globalThis.css) {
153
+ globalThis.css = css
154
+ }
155
+
156
+ function mergeOptions(options, otherOptions)
157
+ {
158
+ for (const key in otherOptions) {
159
+ switch(typeof otherOptions[key]) {
160
+ case 'object':
161
+ if (!otherOptions[key]) {
162
+ continue // null
163
+ }
164
+ if (!options[key]) {
165
+ options[key] = otherOptions[key]
166
+ } else {
167
+ //FIXME: check that options[key] is also an object
168
+ mergeOptions(options[key], otherOptions[key])
169
+ }
170
+ break
171
+ default:
172
+ options[key] = otherOptions[key]
173
+ }
174
+ }
175
+ }
176
+
177
+ function mergeComponents(options, components) {
178
+ for (const name in components) {
179
+ const component = components[name]
180
+ if (component.components) {
181
+ mergeComponents(options, component.components)
182
+ }
183
+ options.components[name] = component
184
+ for (const key in component) {
185
+ switch(key) {
186
+ case 'hooks':
187
+ // don't merge these, app.hooks.start will trigger each components start hook
188
+ case 'components':
189
+ // already handled
190
+ break
191
+ default:
192
+ if (!options[key]) {
193
+ options[key] = Object.create(null)
194
+ }
195
+ mergeOptions(options[key], component[key])
196
+ break
197
+ }
198
+ }
199
+ }
200
+ }
@@ -0,0 +1,11 @@
1
+ export function html(strings, ...values) {
2
+ const outputArray = values.map(
3
+ (value, index) =>
4
+ `${strings[index]}${value}`,
5
+ );
6
+ return outputArray.join("") + strings[strings.length - 1];
7
+ }
8
+
9
+ export function css(strings, ...values) {
10
+ return html(strings, ...values)
11
+ }