simplyview 3.4.3 → 3.5.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.
@@ -371,42 +371,18 @@
371
371
  options.app = app2;
372
372
  }
373
373
  if (options.app) {
374
- const waitHandler = {
375
- apply(target, thisArg, argumentsList) {
376
- try {
377
- const result = target(...argumentsList);
378
- if (result instanceof Promise) {
379
- options.app.hooks.wait(true);
380
- return result.finally(() => {
381
- options.app.hooks.wait(false, target);
382
- });
383
- }
384
- return result;
385
- } catch (err) {
386
- }
387
- }
388
- };
389
374
  const functionHandler = {
390
375
  apply(target, thisArg, argumentsList) {
391
376
  try {
392
377
  const result = target(...argumentsList);
393
378
  if (result instanceof Promise) {
394
- if (options.app.hooks.wait) {
395
- options.app.hooks.wait(true, target);
396
- return result.catch((err) => {
397
- return options.app.hooks.error(err, target);
398
- }).finally(() => {
399
- options.app.hooks.wait(false, target);
400
- });
401
- } else {
402
- return result.catch((err) => {
403
- return options.app.hooks.error(err, target);
404
- });
405
- }
379
+ return result.catch((err) => {
380
+ return options.app.hooks.error.call(this, err, target);
381
+ });
406
382
  }
407
383
  return result;
408
384
  } catch (err) {
409
- return options.app.hooks.error(err, target);
385
+ return options.app.hooks.error.call(this, err, target);
410
386
  }
411
387
  }
412
388
  };
@@ -417,8 +393,6 @@
417
393
  }
418
394
  if (options.app.hooks?.error) {
419
395
  return new Proxy(target[property].bind(options.app), functionHandler);
420
- } else if (options.app.hooks?.wait) {
421
- return new Proxy(target[property].bind(options.app), waitHandler);
422
396
  } else {
423
397
  return target[property].bind(options.app);
424
398
  }
@@ -633,33 +607,12 @@
633
607
  this.view = view({ app: this, view: options.view });
634
608
  break;
635
609
  case "hooks":
636
- const moduleHandler = {
637
- get: (target, property) => {
638
- if (!target[property]) {
639
- return void 0;
640
- }
641
- if (typeof target[property] == "function") {
642
- return new Proxy(target[property], functionHandler);
643
- } else if (target[property] && typeof target[property] == "object") {
644
- return new Proxy(target[property], moduleHandler);
645
- } else {
646
- return target[property];
647
- }
648
- }
649
- };
650
- const functionHandler = {
651
- apply: (target, thisArg, argumentsList) => {
652
- return target.apply(this, argumentsList);
653
- }
654
- };
655
- this[key] = new Proxy(options[key], moduleHandler);
610
+ case "components":
611
+ this[key] = options[key];
656
612
  break;
657
- components:
658
- this.components = components;
613
+ case "prototype":
614
+ case "__proto__":
659
615
  break;
660
- prototype:
661
- __proto__:
662
- break;
663
616
  default:
664
617
  console.log('simply.app: unknown initialization option "' + key + '", added as-is');
665
618
  this[key] = options[key];
@@ -670,34 +623,30 @@
670
623
  get app() {
671
624
  return this;
672
625
  }
673
- async start() {
674
- if (this.components) {
675
- for (const name in this.components) {
676
- if (this.components[name].hooks?.start) {
677
- await this.components[name].hooks.start.call(this, this.components[name]);
678
- }
679
- }
680
- }
681
- if (this.hooks?.start) {
682
- await this.hooks.start();
683
- }
684
- if (this.routes) {
685
- if (this.baseURL) {
686
- this.routes.init({ baseURL: this.baseURL });
687
- }
688
- this.routes.handleEvents();
689
- globalThis.setTimeout(() => {
690
- if (this.routes.has(globalThis.location?.hash)) {
691
- this.routes.match(globalThis.location.hash);
692
- } else {
693
- this.routes.match(globalThis.location?.pathname + globalThis.location?.hash);
694
- }
695
- });
626
+ };
627
+ function initRoutes(app2) {
628
+ if (app2.routes) {
629
+ if (app2.baseURL) {
630
+ app2.routes.init({ baseURL: this.baseURL });
696
631
  }
632
+ app2.routes.handleEvents();
633
+ globalThis.setTimeout(() => {
634
+ if (app2.routes.has(globalThis.location?.hash)) {
635
+ app2.routes.match(globalThis.location.hash);
636
+ } else {
637
+ app2.routes.match(globalThis.location?.pathname + globalThis.location?.hash);
638
+ }
639
+ });
697
640
  }
698
- };
641
+ }
699
642
  function app(options = {}) {
700
- return new SimplyApp(options);
643
+ const app2 = new SimplyApp(options);
644
+ if (app2.hooks?.start) {
645
+ app2.hooks.start.call(app2).then(() => initRoutes(app2));
646
+ } else {
647
+ initRoutes(app2);
648
+ }
649
+ return app2;
701
650
  }
702
651
  if (!globalThis.html) {
703
652
  globalThis.html = html;
@@ -723,9 +672,9 @@
723
672
  }
724
673
  }
725
674
  }
726
- function mergeComponents(options, components2) {
727
- for (const name in components2) {
728
- const component = components2[name];
675
+ function mergeComponents(options, components) {
676
+ for (const name in components) {
677
+ const component = components[name];
729
678
  if (component.components) {
730
679
  mergeComponents(options, component.components);
731
680
  }
@@ -1,2 +1,2 @@
1
- (()=>{function v(t,e){if(e){let a=t;t=e,t.app=t}return new d(t)}var d=class{constructor(e={}){this.baseURL=e.baseURL||"/",this.app=e.app||{},this.addMissingSlash=!!e.addMissingSlash,this.matchExact=!!e.matchExact,this.clear(),e.routes&&this.load(e.routes)}load(e){K(e,this.routeInfo,this.matchExact)}clear(){this.routeInfo=[],this.listeners={match:{},call:{},goto:{},finish:{}}}match(e,a){let r={path:e,options:a};r=this.runListeners("match",r),e=r.path?r.path:e;let i;if(!e)return this.match(document.location.pathname+document.location.hash)?!0:this.match(document.location.pathname);e=o(e);for(let n of this.routeInfo)if(i=n.match.exec(e),this.addMissingSlash&&!i?.length&&e&&e[e.length-1]!="/"&&(i=n.match.exec(e+"/"),i&&(e+="/",history.replaceState({},"",w(e,this.baseURL)))),i&&i.length){let s={};n.params.forEach((l,h)=>{l=="*"&&(l="remainder"),s[l]=i[h+1]}),Object.assign(s,a),r.route=n,r.params=s,r=this.runListeners("call",r),s=r.params?r.params:s;let c=new URLSearchParams(document.location.search);return r.result=n.action.call(this.app,s,c),this.runListeners("finish",r),r.result}return!1}runListeners(e,a){if(!(!this.listeners[e]||!Object.keys(this.listeners[e])))return Object.keys(this.listeners[e]).forEach(r=>{var i=x(r);if(i.exec(a.path)){var n;for(let s of this.listeners[e][r])n=s.call(this.app,a),n&&(a=n)}}),a}handleEvents(){globalThis.addEventListener("popstate",()=>{this.match(o(document.location.pathname+document.location.hash,this.baseURL))===!1&&this.match(o(document.location.pathname,this.baseURL))}),this.app.container.addEventListener("click",e=>{if(!e.ctrlKey&&e.which==1){for(var a=e.target;a&&a.tagName!="A";)a=a.parentElement;if(a&&a.pathname&&a.hostname==globalThis.location.hostname&&!a.link&&!a.dataset.simplyCommand){let r=[a.hash,a.pathname+a.hash,a.pathname],i;do i=o(r.shift(),this.baseURL);while(r.length&&!this.has(i));if(this.has(i)){let n=this.runListeners("goto",{path:i});if(n.path&&this.goto(n.path))return e.preventDefault(),!1}}}})}goto(e){return history.pushState({},"",w(e,this.baseURL)),this.match(e)}has(e){e=o(e,this.baseURL);for(let r of this.routeInfo){var a=r.match.exec(e);if(a&&a.length)return!0}return!1}addListener(e,a,r){if(["goto","match","call","finish"].indexOf(e)==-1)throw new Error("Unknown action "+e);this.listeners[e][a]||(this.listeners[e][a]=[]),this.listeners[e][a].push(r)}removeListener(e,a,r){if(["match","call","finish"].indexOf(e)==-1)throw new Error("Unknown action "+e);this.listeners[e][a]&&(this.listeners[e][a]=this.listeners[e][a].filter(i=>i!=r))}init(e){e.baseURL&&(this.baseURL=e.baseURL)}};function o(t,e="/"){return(t.substring(0,e.length)==e||e[e.length-1]=="/"&&t.length==e.length-1&&t==e.substring(0,t.length))&&(t=t.substring(e.length)),t[0]!="/"&&t[0]!="#"&&(t="/"+t),t}function w(t,e){return t=o(t,e),e[e.length-1]==="/"&&t[0]==="/"&&(t=t.substring(1)),t[0]=="#"?t:e+t}function x(t,e=!1){return e?new RegExp("^"+t.replace(/:\w+/g,"([^/]+)").replace(/:\*/,"(.*)")+"(\\?|$)"):new RegExp("^"+t.replace(/:\w+/g,"([^/]+)").replace(/:\*/,"(.*)"))}function K(t,e,a=!1){let r=Object.keys(t),i=/:(\w+|\*)/g;for(let n of r){let s=[],c=[];do s=i.exec(n),s&&c.push(s[1]);while(s);e.push({match:x(n,a),params:c,action:t[n]})}return e}var p=class{constructor(e={}){e.app||(e.app={}),e.app.container||(e.app.container=document.body),this.app=e.app,this.$handlers=e.handlers||D,e.commands&&Object.assign(this,e.commands);let a=r=>{let i=S(r,this.$handlers);if(!i)return;if(!this[i.name]){console.error("simply.command: undefined command "+i.name,i.source);return}if(this[i.name].call(e.app,i.source,i.value)!==!0)return r.preventDefault(),r.stopPropagation(),!1};e.app.container.addEventListener("click",a),e.app.container.addEventListener("submit",a),e.app.container.addEventListener("change",a),e.app.container.addEventListener("input",a)}call(e,a,r){if(!this[e]){console.error("simply.command: undefined command "+e);return}return this[e].call(this.app,a,r)}action(e){console.warn("deprecated call to `this.commands.action`");let a=Array.from(arguments).slice();return a.shift(),this.app.actions[e](...a)}appendHandler(e){this.$handlers.push(e)}prependHandler(e){this.$handlers.unshift(e)}};function E(t={},e){if(e){let a=t;t=e,t.app=t}return new p(t)}function S(t,e){var a=t.target.closest("[data-simply-command]");if(a){for(let r of e)if(a.matches(r.match))return r.check(a,t)?{name:a.dataset.simplyCommand,source:a,value:r.get(a)}:null}return null}var D=[{match:"input,select,textarea",get:function(t){if(t.tagName==="SELECT"&&t.multiple){let e=[];for(let a of t.options)a.selected&&e.push(a.value);return e}return t.dataset.simplyValue||t.value},check:function(t,e){return e.type=="change"||t.dataset.simplyImmediate&&e.type=="input"}},{match:"a,button",get:function(t){return t.dataset.simplyValue||t.href||t.value},check:function(t,e){return e.type=="click"&&e.ctrlKey==!1&&e.button==0}},{match:"form",get:function(t){let e={};for(let a of Array.from(t.elements)){if(a.tagName=="INPUT"&&(a.type=="checkbox"||a.type=="radio")&&!a.checked)return;e[a.name]&&!Array.isArray(e[a.name])&&(e[a.name]=[e[a.name]]),Array.isArray(e[a.name])?e[a.name].push(a.value):e[a.name]=a.value}return e},check:function(t,e){return e.type=="submit"}},{match:"*",get:function(t){return t.dataset.simplyValue},check:function(t,e){return e.type=="click"&&e.ctrlKey==!1&&e.button==0}}];function L(t,e){if(e){let a=t;t=e,t.app=a}if(t.app){let a={apply(n,s,c){try{let l=n(...c);return l instanceof Promise?(t.app.hooks.wait(!0),l.finally(()=>{t.app.hooks.wait(!1,n)})):l}catch{}}},r={apply(n,s,c){try{let l=n(...c);return l instanceof Promise?t.app.hooks.wait?(t.app.hooks.wait(!0,n),l.catch(h=>t.app.hooks.error(h,n)).finally(()=>{t.app.hooks.wait(!1,n)})):l.catch(h=>t.app.hooks.error(h,n)):l}catch(l){return t.app.hooks.error(l,n)}}},i={get(n,s){if(n[s])return t.app.hooks?.error?new Proxy(n[s].bind(t.app),r):t.app.hooks?.wait?new Proxy(n[s].bind(t.app),a):n[s].bind(t.app)}};return new Proxy(t.actions,i)}else return t}var f=Object.freeze({Compose:229,Control:17,Meta:224,Alt:18,Shift:16}),y=class{constructor(e={}){e.app||(e.app={}),e.app.container||(e.app.container=document.body),Object.assign(this,e.keys);let a=r=>{if(r.isComposing||r.keyCode===f.Compose||r.defaultPrevented||!r.target)return;let i="default";r.target.closest("[data-simply-keyboard]")&&(i=r.target.closest("[data-simply-keyboard]").dataset.simplyKeyboard);let n=[];r.ctrlKey&&r.keyCode!=f.Control&&n.push("Control"),r.metaKey&&r.keyCode!=f.Meta&&n.push("Meta"),r.altKey&&r.keyCode!=f.Alt&&n.push("Alt"),r.shiftKey&&r.keyCode!=f.Shift&&n.push("Shift"),n.push(r.key.toLowerCase());let s=[],c=event.target.closest("[data-simply-keyboard]");for(;c;)s.push(c.dataset.simplyKeyboard),c=c.parentNode.closest("[data-simply-keyboard]");s.push("");let l,h,R=["+","-"];for(let j in s){l=s[j],l==""?h="default":(h=l,l+=".");for(let H of R){let u=n.join(H);if(this[h]&&typeof this[h][u]=="function"&&!this[h][u].call(e.app,r)){r.preventDefault();return}if(typeof this[h+u]=="function"&&!this[h+u].call(e.app,r)){r.preventDefault();return}if(this[i]&&this[i][u]){let m=e.app.container.querySelectorAll('[data-simply-accesskey="'+l+u+'"]');m.length&&(m.forEach(U=>U.click()),r.preventDefault())}}}};e.app.container.addEventListener("keydown",a)}};function T(t={},e){if(e){let a=t;t=e,t.app=t}return new y(t)}function C(t,e){if(e){let a=t;t=e,t.app=t}if(t.app){t.app.view=t.view||{};let a=()=>{let r=t.app.view,i=globalThis.editor.data.getDataPath(t.app.container||document.body);t.app.view=globalThis.editor.currentData[i],Object.assign(t.app.view,r)};return globalThis.editor&&globalThis.editor.currentData?a():document.addEventListener("simply-content-loaded",a),t.app.view}else return t.view}function k(t,...e){return e.map((r,i)=>`${t[i]}${r}`).join("")+t[t.length-1]}function A(t,...e){return k(t,...e)}var b=class{constructor(e={}){if(this.container=e.container||document.body,e.components){let a={};P(a,e.components),g(a,e),e=a}for(let a in e)switch(a){case"html":for(let n in e.html){let s=document.createElement("div");s.innerHTML=e.html[n];let c=this.container.querySelector("template#"+n);c?c.content.replaceChildren(...s.children):(c=document.createElement("template"),c.id=n,c.content.append(...s.children),this.container.appendChild(c))}break;case"css":for(let n in e.css){let s=this.container.querySelector("style#"+n);s||(s=document.createElement("style"),s.id=n,this.container.appendChild(s)),s.innerHTML=e.css[n]}break;case"commands":this.commands=E({app:this,container:this.container,commands:e.commands});break;case"keys":case"keyboard":this.keys=T({app:this,keys:e.keys});break;case"root":case"baseURL":this.baseURL=e[a];break;case"routes":this.routes=v({app:this,routes:e.routes});break;case"actions":this.actions=L({app:this,actions:e.actions}),this.action=function(n){console.warn("deprecated call to `this.action`");let s=Array.from(arguments).slice();return s.shift(),this.actions[n](...s)};break;case"view":this.view=C({app:this,view:e.view});break;case"hooks":let r={get:(n,s)=>{if(n[s])return typeof n[s]=="function"?new Proxy(n[s],i):n[s]&&typeof n[s]=="object"?new Proxy(n[s],r):n[s]}},i={apply:(n,s,c)=>n.apply(this,c)};this[a]=new Proxy(e[a],r);break;default:console.log('simply.app: unknown initialization option "'+a+'", added as-is'),this[a]=e[a];break}}get app(){return this}async start(){if(this.components)for(let e in this.components)this.components[e].hooks?.start&&await this.components[e].hooks.start.call(this,this.components[e]);this.hooks?.start&&await this.hooks.start(),this.routes&&(this.baseURL&&this.routes.init({baseURL:this.baseURL}),this.routes.handleEvents(),globalThis.setTimeout(()=>{this.routes.has(globalThis.location?.hash)?this.routes.match(globalThis.location.hash):this.routes.match(globalThis.location?.pathname+globalThis.location?.hash)}))}};function G(t={}){return new b(t)}globalThis.html||(globalThis.html=k);globalThis.css||(globalThis.css=A);function g(t,e){for(let a in e)switch(typeof e[a]){case"object":if(!e[a])continue;t[a]?g(t[a],e[a]):t[a]=e[a];break;default:t[a]=e[a]}}function P(t,e){for(let a in e){let r=e[a];r.components&&P(t,r.components),t.components||(t.components={}),t.components[a]=r;for(let i in r)switch(i){case"hooks":case"components":break;default:t[i]||(t[i]=Object.create(null)),g(t[i],r[i]);break}}}})();
1
+ (()=>{function v(t,e){if(e){let a=t;t=e,t.app=t}return new d(t)}var d=class{constructor(e={}){this.baseURL=e.baseURL||"/",this.app=e.app||{},this.addMissingSlash=!!e.addMissingSlash,this.matchExact=!!e.matchExact,this.clear(),e.routes&&this.load(e.routes)}load(e){H(e,this.routeInfo,this.matchExact)}clear(){this.routeInfo=[],this.listeners={match:{},call:{},goto:{},finish:{}}}match(e,a){let r={path:e,options:a};r=this.runListeners("match",r),e=r.path?r.path:e;let n;if(!e)return this.match(document.location.pathname+document.location.hash)?!0:this.match(document.location.pathname);e=o(e);for(let s of this.routeInfo)if(n=s.match.exec(e),this.addMissingSlash&&!n?.length&&e&&e[e.length-1]!="/"&&(n=s.match.exec(e+"/"),n&&(e+="/",history.replaceState({},"",w(e,this.baseURL)))),n&&n.length){let i={};s.params.forEach((l,h)=>{l=="*"&&(l="remainder"),i[l]=n[h+1]}),Object.assign(i,a),r.route=s,r.params=i,r=this.runListeners("call",r),i=r.params?r.params:i;let c=new URLSearchParams(document.location.search);return r.result=s.action.call(this.app,i,c),this.runListeners("finish",r),r.result}return!1}runListeners(e,a){if(!(!this.listeners[e]||!Object.keys(this.listeners[e])))return Object.keys(this.listeners[e]).forEach(r=>{var n=E(r);if(n.exec(a.path)){var s;for(let i of this.listeners[e][r])s=i.call(this.app,a),s&&(a=s)}}),a}handleEvents(){globalThis.addEventListener("popstate",()=>{this.match(o(document.location.pathname+document.location.hash,this.baseURL))===!1&&this.match(o(document.location.pathname,this.baseURL))}),this.app.container.addEventListener("click",e=>{if(!e.ctrlKey&&e.which==1){for(var a=e.target;a&&a.tagName!="A";)a=a.parentElement;if(a&&a.pathname&&a.hostname==globalThis.location.hostname&&!a.link&&!a.dataset.simplyCommand){let r=[a.hash,a.pathname+a.hash,a.pathname],n;do n=o(r.shift(),this.baseURL);while(r.length&&!this.has(n));if(this.has(n)){let s=this.runListeners("goto",{path:n});if(s.path&&this.goto(s.path))return e.preventDefault(),!1}}}})}goto(e){return history.pushState({},"",w(e,this.baseURL)),this.match(e)}has(e){e=o(e,this.baseURL);for(let r of this.routeInfo){var a=r.match.exec(e);if(a&&a.length)return!0}return!1}addListener(e,a,r){if(["goto","match","call","finish"].indexOf(e)==-1)throw new Error("Unknown action "+e);this.listeners[e][a]||(this.listeners[e][a]=[]),this.listeners[e][a].push(r)}removeListener(e,a,r){if(["match","call","finish"].indexOf(e)==-1)throw new Error("Unknown action "+e);this.listeners[e][a]&&(this.listeners[e][a]=this.listeners[e][a].filter(n=>n!=r))}init(e){e.baseURL&&(this.baseURL=e.baseURL)}};function o(t,e="/"){return(t.substring(0,e.length)==e||e[e.length-1]=="/"&&t.length==e.length-1&&t==e.substring(0,t.length))&&(t=t.substring(e.length)),t[0]!="/"&&t[0]!="#"&&(t="/"+t),t}function w(t,e){return t=o(t,e),e[e.length-1]==="/"&&t[0]==="/"&&(t=t.substring(1)),t[0]=="#"?t:e+t}function E(t,e=!1){return e?new RegExp("^"+t.replace(/:\w+/g,"([^/]+)").replace(/:\*/,"(.*)")+"(\\?|$)"):new RegExp("^"+t.replace(/:\w+/g,"([^/]+)").replace(/:\*/,"(.*)"))}function H(t,e,a=!1){let r=Object.keys(t),n=/:(\w+|\*)/g;for(let s of r){let i=[],c=[];do i=n.exec(s),i&&c.push(i[1]);while(i);e.push({match:E(s,a),params:c,action:t[s]})}return e}var p=class{constructor(e={}){e.app||(e.app={}),e.app.container||(e.app.container=document.body),this.app=e.app,this.$handlers=e.handlers||M,e.commands&&Object.assign(this,e.commands);let a=r=>{let n=D(r,this.$handlers);if(!n)return;if(!this[n.name]){console.error("simply.command: undefined command "+n.name,n.source);return}if(this[n.name].call(e.app,n.source,n.value)!==!0)return r.preventDefault(),r.stopPropagation(),!1};e.app.container.addEventListener("click",a),e.app.container.addEventListener("submit",a),e.app.container.addEventListener("change",a),e.app.container.addEventListener("input",a)}call(e,a,r){if(!this[e]){console.error("simply.command: undefined command "+e);return}return this[e].call(this.app,a,r)}action(e){console.warn("deprecated call to `this.commands.action`");let a=Array.from(arguments).slice();return a.shift(),this.app.actions[e](...a)}appendHandler(e){this.$handlers.push(e)}prependHandler(e){this.$handlers.unshift(e)}};function L(t={},e){if(e){let a=t;t=e,t.app=t}return new p(t)}function D(t,e){var a=t.target.closest("[data-simply-command]");if(a){for(let r of e)if(a.matches(r.match))return r.check(a,t)?{name:a.dataset.simplyCommand,source:a,value:r.get(a)}:null}return null}var M=[{match:"input,select,textarea",get:function(t){if(t.tagName==="SELECT"&&t.multiple){let e=[];for(let a of t.options)a.selected&&e.push(a.value);return e}return t.dataset.simplyValue||t.value},check:function(t,e){return e.type=="change"||t.dataset.simplyImmediate&&e.type=="input"}},{match:"a,button",get:function(t){return t.dataset.simplyValue||t.href||t.value},check:function(t,e){return e.type=="click"&&e.ctrlKey==!1&&e.button==0}},{match:"form",get:function(t){let e={};for(let a of Array.from(t.elements)){if(a.tagName=="INPUT"&&(a.type=="checkbox"||a.type=="radio")&&!a.checked)return;e[a.name]&&!Array.isArray(e[a.name])&&(e[a.name]=[e[a.name]]),Array.isArray(e[a.name])?e[a.name].push(a.value):e[a.name]=a.value}return e},check:function(t,e){return e.type=="submit"}},{match:"*",get:function(t){return t.dataset.simplyValue},check:function(t,e){return e.type=="click"&&e.ctrlKey==!1&&e.button==0}}];function x(t,e){if(e){let a=t;t=e,t.app=a}if(t.app){let a={apply(n,s,i){try{let c=n(...i);return c instanceof Promise?c.catch(l=>t.app.hooks.error.call(this,l,n)):c}catch(c){return t.app.hooks.error.call(this,c,n)}}},r={get(n,s){if(n[s])return t.app.hooks?.error?new Proxy(n[s].bind(t.app),a):n[s].bind(t.app)}};return new Proxy(t.actions,r)}else return t}var f=Object.freeze({Compose:229,Control:17,Meta:224,Alt:18,Shift:16}),y=class{constructor(e={}){e.app||(e.app={}),e.app.container||(e.app.container=document.body),Object.assign(this,e.keys);let a=r=>{if(r.isComposing||r.keyCode===f.Compose||r.defaultPrevented||!r.target)return;let n="default";r.target.closest("[data-simply-keyboard]")&&(n=r.target.closest("[data-simply-keyboard]").dataset.simplyKeyboard);let s=[];r.ctrlKey&&r.keyCode!=f.Control&&s.push("Control"),r.metaKey&&r.keyCode!=f.Meta&&s.push("Meta"),r.altKey&&r.keyCode!=f.Alt&&s.push("Alt"),r.shiftKey&&r.keyCode!=f.Shift&&s.push("Shift"),s.push(r.key.toLowerCase());let i=[],c=event.target.closest("[data-simply-keyboard]");for(;c;)i.push(c.dataset.simplyKeyboard),c=c.parentNode.closest("[data-simply-keyboard]");i.push("");let l,h,U=["+","-"];for(let P in i){l=i[P],l==""?h="default":(h=l,l+=".");for(let K of U){let u=s.join(K);if(this[h]&&typeof this[h][u]=="function"&&!this[h][u].call(e.app,r)){r.preventDefault();return}if(typeof this[h+u]=="function"&&!this[h+u].call(e.app,r)){r.preventDefault();return}if(this[n]&&this[n][u]){let m=e.app.container.querySelectorAll('[data-simply-accesskey="'+l+u+'"]');m.length&&(m.forEach(S=>S.click()),r.preventDefault())}}}};e.app.container.addEventListener("keydown",a)}};function T(t={},e){if(e){let a=t;t=e,t.app=t}return new y(t)}function C(t,e){if(e){let a=t;t=e,t.app=t}if(t.app){t.app.view=t.view||{};let a=()=>{let r=t.app.view,n=globalThis.editor.data.getDataPath(t.app.container||document.body);t.app.view=globalThis.editor.currentData[n],Object.assign(t.app.view,r)};return globalThis.editor&&globalThis.editor.currentData?a():document.addEventListener("simply-content-loaded",a),t.app.view}else return t.view}function g(t,...e){return e.map((r,n)=>`${t[n]}${r}`).join("")+t[t.length-1]}function R(t,...e){return g(t,...e)}var b=class{constructor(e={}){if(this.container=e.container||document.body,e.components){let a={};j(a,e.components),k(a,e),e=a}for(let a in e)switch(a){case"html":for(let r in e.html){let n=document.createElement("div");n.innerHTML=e.html[r];let s=this.container.querySelector("template#"+r);s?s.content.replaceChildren(...n.children):(s=document.createElement("template"),s.id=r,s.content.append(...n.children),this.container.appendChild(s))}break;case"css":for(let r in e.css){let n=this.container.querySelector("style#"+r);n||(n=document.createElement("style"),n.id=r,this.container.appendChild(n)),n.innerHTML=e.css[r]}break;case"commands":this.commands=L({app:this,container:this.container,commands:e.commands});break;case"keys":case"keyboard":this.keys=T({app:this,keys:e.keys});break;case"root":case"baseURL":this.baseURL=e[a];break;case"routes":this.routes=v({app:this,routes:e.routes});break;case"actions":this.actions=x({app:this,actions:e.actions}),this.action=function(r){console.warn("deprecated call to `this.action`");let n=Array.from(arguments).slice();return n.shift(),this.actions[r](...n)};break;case"view":this.view=C({app:this,view:e.view});break;case"hooks":case"components":this[a]=e[a];break;case"prototype":case"__proto__":break;default:console.log('simply.app: unknown initialization option "'+a+'", added as-is'),this[a]=e[a];break}}get app(){return this}};function A(t){t.routes&&(t.baseURL&&t.routes.init({baseURL:this.baseURL}),t.routes.handleEvents(),globalThis.setTimeout(()=>{t.routes.has(globalThis.location?.hash)?t.routes.match(globalThis.location.hash):t.routes.match(globalThis.location?.pathname+globalThis.location?.hash)}))}function J(t={}){let e=new b(t);return e.hooks?.start?e.hooks.start.call(e).then(()=>A(e)):A(e),e}globalThis.html||(globalThis.html=g);globalThis.css||(globalThis.css=R);function k(t,e){for(let a in e)switch(typeof e[a]){case"object":if(!e[a])continue;t[a]?k(t[a],e[a]):t[a]=e[a];break;default:t[a]=e[a]}}function j(t,e){for(let a in e){let r=e[a];r.components&&j(t,r.components),t.components||(t.components={}),t.components[a]=r;for(let n in r)switch(n){case"hooks":case"components":break;default:t[n]||(t[n]=Object.create(null)),k(t[n],r[n]);break}}}})();
2
2
  //# sourceMappingURL=simply.app.min.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/route.mjs", "../src/command.mjs", "../src/action.mjs", "../src/key.mjs", "../src/view.mjs", "../src/highlight.mjs", "../src/app.mjs"],
4
- "sourcesContent": ["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]", "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}", "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\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\tlet tempOptions = {}\n\t\t\tmergeComponents(tempOptions, options.components)\n\t\t\tmergeOptions(tempOptions, options) // make sure options to the app override components options\n\t\t\toptions = tempOptions\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.call(this, this.components[name])\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\tif (!options.components) {\n\t\t\toptions.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"],
5
- "mappings": "MAAO,SAASA,EAAOC,EAASC,EAChC,CACI,GAAIA,EAAe,CACf,IAAIC,EAAMF,EACVA,EAAUC,EACVD,EAAQ,IAAMA,CAClB,CACA,OAAO,IAAIG,EAAYH,CAAO,CAClC,CAEA,IAAMG,EAAN,KACA,CACI,YAAYH,EAAQ,CAAC,EACrB,CACI,KAAK,QAAUA,EAAQ,SAAW,IAClC,KAAK,IAAMA,EAAQ,KAAO,CAAC,EAC3B,KAAK,gBAAkB,CAAC,CAACA,EAAQ,gBACjC,KAAK,WAAa,CAAC,CAACA,EAAQ,WAC5B,KAAK,MAAM,EACPA,EAAQ,QACR,KAAK,KAAKA,EAAQ,MAAM,CAEhC,CAEA,KAAKD,EACL,CACIK,EAAYL,EAAQ,KAAK,UAAW,KAAK,UAAU,CACvD,CAEA,OACA,CACI,KAAK,UAAY,CAAC,EAClB,KAAK,UAAY,CACb,MAAO,CAAC,EACR,KAAM,CAAC,EACP,KAAM,CAAC,EACP,OAAQ,CAAC,CACb,CACJ,CAEA,MAAMM,EAAML,EACZ,CACI,IAAIM,EAAO,CACP,KAAAD,EACA,QAAAL,CACJ,EACAM,EAAO,KAAK,aAAa,QAAQA,CAAI,EACrCD,EAAOC,EAAK,KAAOA,EAAK,KAAOD,EAE/B,IAAIE,EACJ,GAAI,CAACF,EACD,OAAI,KAAK,MAAM,SAAS,SAAS,SAAS,SAAS,SAAS,IAAI,EACrD,GAEA,KAAK,MAAM,SAAS,SAAS,QAAQ,EAGpDA,EAAOG,EAAQH,CAAI,EACnB,QAAUI,KAAS,KAAK,UAWpB,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AIoB,EAAapB,CAAG,CACjC,CAEF,CAEA,SAASF,EAAgBF,EAASyB,EAAY,CAC7C,QAAWpB,KAAQoB,EAAY,CAC9B,IAAMC,EAAYD,EAAWpB,CAAI,EAC7BqB,EAAU,YACbxB,EAAgBF,EAAS0B,EAAU,UAAU,EAEzC1B,EAAQ,aACZA,EAAQ,WAAa,CAAC,GAEvBA,EAAQ,WAAWK,CAAI,EAAIqB,EAC3B,QAAWtB,KAAOsB,EACjB,OAAOtB,EAAK,CACX,IAAK,QAEL,IAAK,aAEJ,MACD,QACMJ,EAAQI,CAAG,IACfJ,EAAQI,CAAG,EAAI,OAAO,OAAO,IAAI,GAElCD,EAAaH,EAAQI,CAAG,EAAGsB,EAAUtB,CAAG,CAAC,EACzC,KACF,CAEF,CACD",
6
- "names": ["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", "actions", "options", "optionsCompat", "app", "waitHandler", "target", "thisArg", "argumentsList", "result", "functionHandler", "err", "actionHandler", "property", "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", "tempOptions", "mergeComponents", "mergeOptions", "key", "name", "element", "template", "style", "commands", "keys", "routes", "actions", "params", "view", "moduleHandler", "target", "property", "functionHandler", "thisArg", "argumentsList", "app", "html", "css", "otherOptions", "components", "component"]
4
+ "sourcesContent": ["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]", "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 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\treturn result.catch(err => {\n\t\t\t\t\t\t\treturn options.app.hooks.error.call(this, err, target)\n\t\t\t\t\t\t})\t\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.call(this, 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 {\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}", "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\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\tlet tempOptions = {}\n\t\t\tmergeComponents(tempOptions, options.components)\n\t\t\tmergeOptions(tempOptions, options) // make sure options to the app override components options\n\t\t\toptions = tempOptions\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\tcase 'components':\n\t\t\t\t\tthis[key] = options[key]\n\t\t\t\t\tbreak\n\t\t\t\tcase 'prototype':\n\t\t\t\tcase '__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() //backwards compatibility, actions/commands used to call this.app instead of this\n\t{\n\t\treturn this\n\t}\n\n}\n\nfunction initRoutes(app) {\n\tif (app.routes) {\n\t\tif (app.baseURL) {\n\t\t\tapp.routes.init({ baseURL: this.baseURL })\n\t\t}\n\t\tapp.routes.handleEvents();\n\t\tglobalThis.setTimeout(() => {\n\t\t\tif (app.routes.has(globalThis.location?.hash)) {\n\t\t\t\tapp.routes.match(globalThis.location.hash)\n\t\t\t} else {\n\t\t\t\tapp.routes.match(globalThis.location?.pathname+globalThis.location?.hash)\n\t\t\t}\n\t\t});\n\t}\n}\n\nexport function app(options={})\n{\n\tconst app = new SimplyApp(options)\n\tif (app.hooks?.start) {\n\t\tapp.hooks.start.call(app)\n\t\t// yagni - for now do this in your own app.hooks.start\n\t\t// if (app.components) {\n\t\t// \tfor (const name in app.components) {\n\t\t// \t\tif (app.components[name].hooks?.start) {\n\t\t// \t\t\tawait app.components[name].hooks.start.call(app, this.components[name])\n\t\t// \t\t}\n\t\t// \t}\n\t\t// }\n\t\t.then(() => initRoutes(app))\n\t} else {\n\t\tinitRoutes(app)\n\t}\n\treturn app\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\tif (!options.components) {\n\t\t\toptions.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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CAAG,EAAIe,EAAaf,CAAG,CACjC,CAEF,CAEA,SAASF,EAAgBF,EAASoB,EAAY,CAC7C,QAAWf,KAAQe,EAAY,CAC9B,IAAMC,EAAYD,EAAWf,CAAI,EAC7BgB,EAAU,YACbnB,EAAgBF,EAASqB,EAAU,UAAU,EAEzCrB,EAAQ,aACZA,EAAQ,WAAa,CAAC,GAEvBA,EAAQ,WAAWK,CAAI,EAAIgB,EAC3B,QAAWjB,KAAOiB,EACjB,OAAOjB,EAAK,CACX,IAAK,QAEL,IAAK,aAEJ,MACD,QACMJ,EAAQI,CAAG,IACfJ,EAAQI,CAAG,EAAI,OAAO,OAAO,IAAI,GAElCD,EAAaH,EAAQI,CAAG,EAAGiB,EAAUjB,CAAG,CAAC,EACzC,KACF,CAEF,CACD",
6
+ "names": ["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", "actions", "options", "optionsCompat", "app", "functionHandler", "target", "thisArg", "argumentsList", "result", "err", "actionHandler", "property", "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", "tempOptions", "mergeComponents", "mergeOptions", "key", "name", "element", "template", "style", "commands", "keys", "routes", "actions", "params", "view", "initRoutes", "app", "html", "css", "otherOptions", "components", "component"]
7
7
  }
@@ -88,42 +88,18 @@
88
88
  options.app = app2;
89
89
  }
90
90
  if (options.app) {
91
- const waitHandler = {
92
- apply(target, thisArg, argumentsList) {
93
- try {
94
- const result = target(...argumentsList);
95
- if (result instanceof Promise) {
96
- options.app.hooks.wait(true);
97
- return result.finally(() => {
98
- options.app.hooks.wait(false, target);
99
- });
100
- }
101
- return result;
102
- } catch (err) {
103
- }
104
- }
105
- };
106
91
  const functionHandler = {
107
92
  apply(target, thisArg, argumentsList) {
108
93
  try {
109
94
  const result = target(...argumentsList);
110
95
  if (result instanceof Promise) {
111
- if (options.app.hooks.wait) {
112
- options.app.hooks.wait(true, target);
113
- return result.catch((err) => {
114
- return options.app.hooks.error(err, target);
115
- }).finally(() => {
116
- options.app.hooks.wait(false, target);
117
- });
118
- } else {
119
- return result.catch((err) => {
120
- return options.app.hooks.error(err, target);
121
- });
122
- }
96
+ return result.catch((err) => {
97
+ return options.app.hooks.error.call(this, err, target);
98
+ });
123
99
  }
124
100
  return result;
125
101
  } catch (err) {
126
- return options.app.hooks.error(err, target);
102
+ return options.app.hooks.error.call(this, err, target);
127
103
  }
128
104
  }
129
105
  };
@@ -134,8 +110,6 @@
134
110
  }
135
111
  if (options.app.hooks?.error) {
136
112
  return new Proxy(target[property].bind(options.app), functionHandler);
137
- } else if (options.app.hooks?.wait) {
138
- return new Proxy(target[property].bind(options.app), waitHandler);
139
113
  } else {
140
114
  return target[property].bind(options.app);
141
115
  }
@@ -714,33 +688,12 @@
714
688
  this.view = view({ app: this, view: options.view });
715
689
  break;
716
690
  case "hooks":
717
- const moduleHandler = {
718
- get: (target, property) => {
719
- if (!target[property]) {
720
- return void 0;
721
- }
722
- if (typeof target[property] == "function") {
723
- return new Proxy(target[property], functionHandler);
724
- } else if (target[property] && typeof target[property] == "object") {
725
- return new Proxy(target[property], moduleHandler);
726
- } else {
727
- return target[property];
728
- }
729
- }
730
- };
731
- const functionHandler = {
732
- apply: (target, thisArg, argumentsList) => {
733
- return target.apply(this, argumentsList);
734
- }
735
- };
736
- this[key] = new Proxy(options[key], moduleHandler);
691
+ case "components":
692
+ this[key] = options[key];
737
693
  break;
738
- components:
739
- this.components = components;
694
+ case "prototype":
695
+ case "__proto__":
740
696
  break;
741
- prototype:
742
- __proto__:
743
- break;
744
697
  default:
745
698
  console.log('simply.app: unknown initialization option "' + key + '", added as-is');
746
699
  this[key] = options[key];
@@ -751,34 +704,30 @@
751
704
  get app() {
752
705
  return this;
753
706
  }
754
- async start() {
755
- if (this.components) {
756
- for (const name in this.components) {
757
- if (this.components[name].hooks?.start) {
758
- await this.components[name].hooks.start.call(this, this.components[name]);
759
- }
760
- }
761
- }
762
- if (this.hooks?.start) {
763
- await this.hooks.start();
764
- }
765
- if (this.routes) {
766
- if (this.baseURL) {
767
- this.routes.init({ baseURL: this.baseURL });
707
+ };
708
+ function initRoutes(app2) {
709
+ if (app2.routes) {
710
+ if (app2.baseURL) {
711
+ app2.routes.init({ baseURL: this.baseURL });
712
+ }
713
+ app2.routes.handleEvents();
714
+ globalThis.setTimeout(() => {
715
+ if (app2.routes.has(globalThis.location?.hash)) {
716
+ app2.routes.match(globalThis.location.hash);
717
+ } else {
718
+ app2.routes.match(globalThis.location?.pathname + globalThis.location?.hash);
768
719
  }
769
- this.routes.handleEvents();
770
- globalThis.setTimeout(() => {
771
- if (this.routes.has(globalThis.location?.hash)) {
772
- this.routes.match(globalThis.location.hash);
773
- } else {
774
- this.routes.match(globalThis.location?.pathname + globalThis.location?.hash);
775
- }
776
- });
777
- }
720
+ });
778
721
  }
779
- };
722
+ }
780
723
  function app(options = {}) {
781
- return new SimplyApp(options);
724
+ const app2 = new SimplyApp(options);
725
+ if (app2.hooks?.start) {
726
+ app2.hooks.start.call(app2).then(() => initRoutes(app2));
727
+ } else {
728
+ initRoutes(app2);
729
+ }
730
+ return app2;
782
731
  }
783
732
  if (!globalThis.html) {
784
733
  globalThis.html = html;
@@ -804,9 +753,9 @@
804
753
  }
805
754
  }
806
755
  }
807
- function mergeComponents(options, components2) {
808
- for (const name in components2) {
809
- const component = components2[name];
756
+ function mergeComponents(options, components) {
757
+ for (const name in components) {
758
+ const component = components[name];
810
759
  if (component.components) {
811
760
  mergeComponents(options, component.components);
812
761
  }
@@ -1012,10 +961,9 @@
1012
961
  if (!pointer) {
1013
962
  return dataset;
1014
963
  }
1015
- pointer.split(".").reduce(function(acc, name) {
964
+ return pointer.split(".").reduce(function(acc, name) {
1016
965
  return acc && acc[name] ? acc[name] : null;
1017
966
  }, dataset);
1018
- return dataset;
1019
967
  },
1020
968
  set: function(dataset, pointer, value) {
1021
969
  const parent = path.get(dataset, path.parent(pointer));
@@ -1042,31 +990,6 @@
1042
990
  };
1043
991
  var path_default = path;
1044
992
 
1045
- // src/render.mjs
1046
- var SimplyRender = class extends HTMLElement {
1047
- constructor() {
1048
- super();
1049
- let templateId = this.getAttribute("rel");
1050
- let template = document.getElementById(templateId);
1051
- if (template) {
1052
- let content = template.content.cloneNode(true);
1053
- for (const node of content.childNodes) {
1054
- const clone = node.cloneNode(true);
1055
- if (clone.nodeType == document.ELEMENT_NODE) {
1056
- clone.querySelectorAll("template").forEach(function(t) {
1057
- t.setAttribute("simply-render", "");
1058
- });
1059
- }
1060
- this.parentNode.insertBefore(clone, this);
1061
- }
1062
- this.parentNode.removeChild(this);
1063
- }
1064
- }
1065
- };
1066
- if (!customElements.get("simply-render")) {
1067
- customElements.define("simply-render", SimplyRender);
1068
- }
1069
-
1070
993
  // src/everything.mjs
1071
994
  var simply = {
1072
995
  activate,