simplyview 3.0.4 → 3.0.6

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,12 +1,17 @@
1
1
  (() => {
2
2
  // src/route.mjs
3
- function routes(options) {
3
+ function routes(options, optionsCompat) {
4
+ if (optionsCompat) {
5
+ let app2 = options;
6
+ options = optionsCompat;
7
+ options.app = options;
8
+ }
4
9
  return new SimplyRoute(options);
5
10
  }
6
11
  var SimplyRoute = class {
7
12
  constructor(options = {}) {
8
13
  this.root = options.root || "/";
9
- this.app = options.app;
14
+ this.app = options.app || {};
10
15
  this.addMissingSlash = !!options.addMissingSlash;
11
16
  this.matchExact = !!options.matchExact;
12
17
  this.clear();
@@ -65,7 +70,7 @@
65
70
  args.params = params;
66
71
  args = this.runListeners("call", args);
67
72
  params = args.params ? args.params : params;
68
- args.result = route.action.call(route, params);
73
+ args.result = route.action.call(this.app, params);
69
74
  this.runListeners("finish", args);
70
75
  return args.result;
71
76
  }
@@ -216,6 +221,7 @@
216
221
  if (!options.app.container) {
217
222
  options.app.container = document.body;
218
223
  }
224
+ this.app = options.app;
219
225
  this.$handlers = options.handlers || defaultHandlers;
220
226
  if (options.commands) {
221
227
  Object.assign(this, options.commands);
@@ -241,8 +247,32 @@
241
247
  options.app.container.addEventListener("change", commandHandler);
242
248
  options.app.container.addEventListener("input", commandHandler);
243
249
  }
250
+ call(command, el, value) {
251
+ if (!this[command]) {
252
+ console.error("simply.command: undefined command " + command);
253
+ return;
254
+ }
255
+ return this[command].call(this.app, el, value);
256
+ }
257
+ action(name) {
258
+ console.warn("deprecated call to `this.commands.action`");
259
+ let params = Array.from(arguments).slice();
260
+ params.shift();
261
+ return this.app.actions[name](...params);
262
+ }
263
+ appendHandler(handler) {
264
+ this.$handlers.push(handler);
265
+ }
266
+ prependHandler(handler) {
267
+ this.$handlers.unshift(handler);
268
+ }
244
269
  };
245
- function commands(options = {}) {
270
+ function commands(options = {}, optionsCompat) {
271
+ if (optionsCompat) {
272
+ let app2 = options;
273
+ options = optionsCompat;
274
+ options.app = options;
275
+ }
246
276
  return new SimplyCommands(options);
247
277
  }
248
278
  function getCommand(evt, handlers) {
@@ -328,7 +358,12 @@
328
358
  ];
329
359
 
330
360
  // src/action.mjs
331
- function actions(options) {
361
+ function actions(options, optionsCompat) {
362
+ if (optionsCompat) {
363
+ let app2 = options;
364
+ options = optionsCompat;
365
+ options.app = options;
366
+ }
332
367
  if (options.app) {
333
368
  const actionHandler = {
334
369
  get: (target, property) => {
@@ -406,14 +441,14 @@
406
441
  for (let separator of separators) {
407
442
  let keyString = keyCombination.join(separator);
408
443
  if (this[subkeyboard] && typeof this[subkeyboard][keyString] == "function") {
409
- let _continue = this[subkeyboard][keyString].call(this[subkeyboard], e);
444
+ let _continue = this[subkeyboard][keyString].call(options.app, e);
410
445
  if (!_continue) {
411
446
  e.preventDefault();
412
447
  return;
413
448
  }
414
449
  }
415
450
  if (typeof this[subkeyboard + keyString] == "function") {
416
- let _continue = this[subkeyboard + keyString].call(this, e);
451
+ let _continue = this[subkeyboard + keyString].call(options.app, e);
417
452
  if (!_continue) {
418
453
  e.preventDefault();
419
454
  return;
@@ -432,12 +467,22 @@
432
467
  options.app.container.addEventListener("keydown", keyHandler);
433
468
  }
434
469
  };
435
- function keys(options = {}) {
470
+ function keys(options = {}, optionsCompat) {
471
+ if (optionsCompat) {
472
+ let app2 = options;
473
+ options = optionsCompat;
474
+ options.app = options;
475
+ }
436
476
  return new SimplyKey(options);
437
477
  }
438
478
 
439
479
  // src/view.mjs
440
- function view(options) {
480
+ function view(options, optionsCompat) {
481
+ if (optionsCompat) {
482
+ let app2 = options;
483
+ options = optionsCompat;
484
+ options.app = options;
485
+ }
441
486
  if (options.app) {
442
487
  options.app.view = options.view || {};
443
488
  const load = () => {
@@ -472,9 +517,19 @@
472
517
  break;
473
518
  case "routes":
474
519
  this.routes = routes({ app: this, routes: options.routes });
520
+ this.routes.handleEvents();
521
+ globalThis.setTimeout(() => {
522
+ this.routes.match(globalThis.location?.pathname + globalThis.location?.hash);
523
+ });
475
524
  break;
476
525
  case "actions":
477
526
  this.actions = actions({ app: this, actions: options.actions });
527
+ this.action = function(name) {
528
+ console.warn("deprecated call to `this.action`");
529
+ let params = Array.from(arguments).slice();
530
+ params.shift();
531
+ return this.actions[name](...params);
532
+ };
478
533
  break;
479
534
  case "view":
480
535
  this.view = view({ app: this, view: options.view });
@@ -485,6 +540,9 @@
485
540
  }
486
541
  }
487
542
  }
543
+ get app() {
544
+ return this;
545
+ }
488
546
  };
489
547
  function app(options = {}) {
490
548
  return new SimplyApp(options);
@@ -1,2 +1,2 @@
1
- (()=>{function w(t){return new p(t)}var p=class{constructor(e={}){this.root=e.root||"/",this.app=e.app,this.addMissingSlash=!!e.addMissingSlash,this.matchExact=!!e.matchExact,this.clear(),e.routes&&this.load(e.routes)}load(e){A(e,this.routeInfo,this.matchExact)}clear(){this.routeInfo=[],this.listeners={match:{},call:{},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=h(e);for(let c of this.routeInfo)if(n=c.match.exec(e),this.addMissingSlash&&!n?.length&&e&&e[e.length-1]!="/"&&(n=c.match.exec(e+"/"),n&&(e+="/",history.replaceState({},"",b(e)))),n&&n.length){var s={};return c.params.forEach((l,u)=>{l=="*"&&(l="remainder"),s[l]=n[u+1]}),Object.assign(s,a),r.route=c,r.params=s,r=this.runListeners("call",r),s=r.params?r.params:s,r.result=c.action.call(c,s),this.runListeners("finish",r),r.result}return!1}runListeners(e,a){if(Object.keys(this.listeners[e]))return Object.keys(this.listeners[e]).forEach(r=>{var n=v(r);if(n.exec(a.path)){var s;for(let c of this.listeners[e][r])s=c.call(this.app,a),s&&(a=s)}}),a}handleEvents(){globalThis.addEventListener("popstate",()=>{this.match(h(document.location.pathname+document.location.hash,this.root))===!1&&this.match(h(document.location.pathname,this.root))}),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=h(a.pathname+a.hash,this.root);if(this.has(r)||(r=h(a.pathname,this.root)),this.has(r)){let n=this.runListeners("goto",{path:r});if(n.path&&this.goto(n.path))return e.preventDefault(),!1}}}})}goto(e){return history.pushState({},"",b(e)),this.match(e)}has(e){e=h(e,this.root);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.root&&(this.root=e.root)}};function h(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 b(t,e){return t=h(t,e),e[e.length-1]==="/"&&t[0]==="/"&&(t=t.substring(1)),e+t}function v(t,e=!1){return e?new RegExp("^"+t.replace(/:\w+/g,"([^/]+)").replace(/:\*/,"(.*)")+"(\\?|$)"):new RegExp("^"+t.replace(/:\w+/g,"([^/]+)").replace(/:\*/,"(.*)"))}function A(t,e,a=!1){let r=Object.keys(t),n=/:(\w+|\*)/g;for(let s of r){let c=[],l=[];do c=n.exec(s),c&&l.push(c[1]);while(c);e.push({match:v(s,a),params:l,action:t[s]})}return e}var y=class{constructor(e={}){e.app||(e.app={}),e.app.container||(e.app.container=document.body),this.$handlers=e.handlers||T,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)}};function E(t={}){return new y(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 T=[{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){if(t.app){let e={get:(a,r)=>a[r].bind(t.app)};return new Proxy(t.actions,e)}else return t}var m=Object.freeze({Compose:229,Control:17,Meta:224,Alt:18,Shift:16}),g=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===m.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!=m.Control&&s.push("Control"),r.metaKey&&r.keyCode!=m.Meta&&s.push("Meta"),r.altKey&&r.keyCode!=m.Alt&&s.push("Alt"),r.shiftKey&&r.keyCode!=m.Shift&&s.push("Shift"),s.push(r.key.toLowerCase());let c=[],l=event.target.closest("[data-simply-keyboard]");for(;l;)c.push(l.dataset.simplyKeyboard),l=l.parentNode.closest("[data-simply-keyboard]");c.push("");let u,o,K=["+","-"];for(i in c){u=c[i],u==""?o="default":(o=u,u+=".");for(let O of K){let f=s.join(O);if(this[o]&&typeof this[o][f]=="function"&&!this[o][f].call(this[o],r)){r.preventDefault();return}if(typeof this[o+f]=="function"&&!this[o+f].call(this,r)){r.preventDefault();return}if(this[n]&&this[n][f]){let d=e.app.container.querySelectorAll('[data-simply-accesskey="'+u+f+'"]');d.length&&(d.forEach(j=>j.click()),r.preventDefault())}}}};e.app.container.addEventListener("keydown",a)}};function C(t={}){return new g(t)}function L(t){if(t.app){t.app.view=t.view||{};let e=()=>{let a=t.app.view,r=globalThis.editor.data.getDataPath(t.app.container||document.body);t.app.view=globalThis.editor.currentData[r],Object.assign(t.app.view,a)};return globalThis.editor&&globalThis.editor.currentData?e():document.addEventListener("simply-content-loaded",e),t.app.view}else return t.view}var k=class{constructor(e={}){this.container=e.container||document.body;for(let a in e)switch(a){case"commands":this.commands=E({app:this,container:this.container,commands:e.commands});break;case"keys":case"keyboard":this.keys=C({app:this,keys:e.keys});break;case"routes":this.routes=w({app:this,routes:e.routes});break;case"actions":this.actions=x({app:this,actions:e.actions});break;case"view":this.view=L({app:this,view:e.view});break;default:this[a]=e[a];break}}};function $(t={}){return new k(t)}})();
1
+ (()=>{function w(t,e){if(e){let a=t;t=e,t.app=t}return new p(t)}var p=class{constructor(e={}){this.root=e.root||"/",this.app=e.app||{},this.addMissingSlash=!!e.addMissingSlash,this.matchExact=!!e.matchExact,this.clear(),e.routes&&this.load(e.routes)}load(e){O(e,this.routeInfo,this.matchExact)}clear(){this.routeInfo=[],this.listeners={match:{},call:{},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=f(e);for(let l of this.routeInfo)if(n=l.match.exec(e),this.addMissingSlash&&!n?.length&&e&&e[e.length-1]!="/"&&(n=l.match.exec(e+"/"),n&&(e+="/",history.replaceState({},"",k(e)))),n&&n.length){var s={};return l.params.forEach((c,h)=>{c=="*"&&(c="remainder"),s[c]=n[h+1]}),Object.assign(s,a),r.route=l,r.params=s,r=this.runListeners("call",r),s=r.params?r.params:s,r.result=l.action.call(this.app,s),this.runListeners("finish",r),r.result}return!1}runListeners(e,a){if(Object.keys(this.listeners[e]))return Object.keys(this.listeners[e]).forEach(r=>{var n=v(r);if(n.exec(a.path)){var s;for(let l of this.listeners[e][r])s=l.call(this.app,a),s&&(a=s)}}),a}handleEvents(){globalThis.addEventListener("popstate",()=>{this.match(f(document.location.pathname+document.location.hash,this.root))===!1&&this.match(f(document.location.pathname,this.root))}),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=f(a.pathname+a.hash,this.root);if(this.has(r)||(r=f(a.pathname,this.root)),this.has(r)){let n=this.runListeners("goto",{path:r});if(n.path&&this.goto(n.path))return e.preventDefault(),!1}}}})}goto(e){return history.pushState({},"",k(e)),this.match(e)}has(e){e=f(e,this.root);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.root&&(this.root=e.root)}};function f(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 k(t,e){return t=f(t,e),e[e.length-1]==="/"&&t[0]==="/"&&(t=t.substring(1)),e+t}function v(t,e=!1){return e?new RegExp("^"+t.replace(/:\w+/g,"([^/]+)").replace(/:\*/,"(.*)")+"(\\?|$)"):new RegExp("^"+t.replace(/:\w+/g,"([^/]+)").replace(/:\*/,"(.*)"))}function O(t,e,a=!1){let r=Object.keys(t),n=/:(\w+|\*)/g;for(let s of r){let l=[],c=[];do l=n.exec(s),l&&c.push(l[1]);while(l);e.push({match:v(s,a),params:c,action:t[s]})}return e}var y=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 n=j(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 E(t={},e){if(e){let a=t;t=e,t.app=t}return new y(t)}function j(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 x(t,e){if(e){let a=t;t=e,t.app=t}if(t.app){let a={get:(r,n)=>r[n].bind(t.app)};return new Proxy(t.actions,a)}else return t}var d=Object.freeze({Compose:229,Control:17,Meta:224,Alt:18,Shift:16}),g=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===d.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!=d.Control&&s.push("Control"),r.metaKey&&r.keyCode!=d.Meta&&s.push("Meta"),r.altKey&&r.keyCode!=d.Alt&&s.push("Alt"),r.shiftKey&&r.keyCode!=d.Shift&&s.push("Shift"),s.push(r.key.toLowerCase());let l=[],c=event.target.closest("[data-simply-keyboard]");for(;c;)l.push(c.dataset.simplyKeyboard),c=c.parentNode.closest("[data-simply-keyboard]");l.push("");let h,u,T=["+","-"];for(i in l){h=l[i],h==""?u="default":(u=h,h+=".");for(let A of T){let o=s.join(A);if(this[u]&&typeof this[u][o]=="function"&&!this[u][o].call(e.app,r)){r.preventDefault();return}if(typeof this[u+o]=="function"&&!this[u+o].call(e.app,r)){r.preventDefault();return}if(this[n]&&this[n][o]){let m=e.app.container.querySelectorAll('[data-simply-accesskey="'+h+o+'"]');m.length&&(m.forEach(K=>K.click()),r.preventDefault())}}}};e.app.container.addEventListener("keydown",a)}};function L(t={},e){if(e){let a=t;t=e,t.app=t}return new g(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}var b=class{constructor(e={}){this.container=e.container||document.body;for(let a in e)switch(a){case"commands":this.commands=E({app:this,container:this.container,commands:e.commands});break;case"keys":case"keyboard":this.keys=L({app:this,keys:e.keys});break;case"routes":this.routes=w({app:this,routes:e.routes}),this.routes.handleEvents(),globalThis.setTimeout(()=>{this.routes.match(globalThis.location?.pathname+globalThis.location?.hash)});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;default:this[a]=e[a];break}}get app(){return this}};function V(t={}){return new b(t)}})();
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/app.mjs"],
4
- "sourcesContent": ["export function routes(options) {\n\treturn new SimplyRoute(options)\n}\n\nclass SimplyRoute {\n\tconstructor(options={}) {\n\t\tthis.root = options.root || '/'\n this.app = options.app\n this.addMissingSlash = !!options.addMissingSlash\n this.matchExact = !!options.matchExact\n\t\tthis.clear()\n\t\tif (options.routes) {\n\t\t\tthis.load(options.routes)\n\t\t}\n\t}\n\n\tload(routes) {\n\t\tparseRoutes(routes, this.routeInfo, this.matchExact)\n\t}\n\n\tclear() {\n\t\tthis.routeInfo = []\n\t\tthis.listeners = {\n\t\t\tmatch: {},\n\t\t\tcall: {},\n\t\t\tfinish: {}\n\t\t}\n\t}\n\n\tmatch(path, options) {\n\t\tlet args = {\n path,\n options\n }\n args = this.runListeners('match',args)\n path = args.path ? args.path : path;\n\n let matches;\n if (!path) {\n if (this.match(document.location.pathname+document.location.hash)) {\n return true;\n } else {\n return this.match(document.location.pathname);\n }\n }\n path = getPath(path);\n for ( let route of this.routeInfo) {\n matches = route.match.exec(path)\n if (this.addMissingSlash && !matches?.length) {\n if (path && path[path.length-1]!='/') {\n matches = route.match.exec(path+'/')\n if (matches) {\n path+='/'\n history.replaceState({}, '', getURL(path))\n }\n }\n }\n if (matches && matches.length) {\n var params = {};\n route.params.forEach((key, i) => {\n if (key=='*') {\n key = 'remainder'\n }\n params[key] = matches[i+1]\n })\n Object.assign(params, options)\n args.route = route\n args.params = params\n args = this.runListeners('call', args)\n params = args.params ? args.params : params\n args.result = route.action.call(route, params)\n this.runListeners('finish', args)\n return args.result\n }\n }\n return false\n\t}\n\n\trunListeners(action, params) {\n if (!Object.keys(this.listeners[action])) {\n return\n }\n Object.keys(this.listeners[action]).forEach((route) => {\n var routeRe = getRegexpFromRoute(route);\n if (routeRe.exec(params.path)) {\n var result;\n for (let callback of this.listeners[action][route]) {\n result = callback.call(this.app, params)\n if (result) {\n params = result\n }\n }\n }\n })\n return params\n }\n\n handleEvents() {\n globalThis.addEventListener('popstate', () => {\n if (this.match(getPath(document.location.pathname + document.location.hash, this.root)) === false) {\n this.match(getPath(document.location.pathname, this.root))\n }\n })\n this.app.container.addEventListener('click', (evt) => {\n\t if (evt.ctrlKey) {\n\t return;\n\t }\n\t if (evt.which != 1) {\n\t return; // not a 'left' mouse click\n\t }\n\t var link = evt.target;\n\t while (link && link.tagName!='A') {\n\t link = link.parentElement;\n\t }\n\t if (link \n\t && link.pathname \n\t && link.hostname==globalThis.location.hostname \n\t && !link.link\n\t && !link.dataset.simplyCommand\n\t ) {\n\t let path = getPath(link.pathname+link.hash, this.root);\n\t if ( !this.has(path) ) {\n\t path = getPath(link.pathname, this.root);\n\t }\n\t if ( this.has(path) ) {\n\t let params = this.runListeners('goto', { path: path});\n\t if (params.path) {\n\t if (this.goto(params.path)) {\n // now cancel the browser navigation, since a route handler was found\n evt.preventDefault();\n return false;\n }\n\t }\n\t }\n\t }\n\t })\n }\n\n goto(path) {\n history.pushState({},'',getURL(path))\n return this.match(path)\n }\n\n has(path) {\n \tpath = getPath(path, this.root)\n \tfor (let route of this.routeInfo) {\n var matches = route.match.exec(path)\n if (matches && matches.length) {\n return true\n }\n }\n return false\n }\n\n addListener(action, route, callback) {\n if (['goto','match','call','finish'].indexOf(action)==-1) {\n throw new Error('Unknown action '+action)\n }\n if (!this.listeners[action][route]) {\n this.listeners[action][route] = []\n }\n this.listeners[action][route].push(callback)\n }\n\n removeListener(action, route, callback) {\n if (['match','call','finish'].indexOf(action)==-1) {\n throw new Error('Unknown action '+action)\n }\n if (!this.listeners[action][route]) {\n return\n }\n this.listeners[action][route] = this.listeners[action][route].filter((listener) => {\n return listener != callback\n })\n }\n\n init(options) {\n \tif (options.root) {\n \t\tthis.root = options.root\n \t}\n }\n}\n\nfunction getPath(path, root='/') {\n if (path.substring(0,root.length)==root\n ||\n ( root[root.length-1]=='/' \n && path.length==(root.length-1)\n && path == root.substring(0,path.length)\n )\n ) {\n path = path.substring(root.length)\n }\n if (path[0]!='/' && path[0]!='#') {\n path = '/'+path\n }\n return path\n}\n\nfunction getURL(path, root) {\n path = getPath(path, root)\n if (root[root.length-1]==='/' && path[0]==='/') {\n path = path.substring(1)\n }\n return root + path;\n}\n\nfunction getRegexpFromRoute(route, exact=false) {\n if (exact) {\n return new RegExp('^'+route.replace(/:\\w+/g, '([^/]+)').replace(/:\\*/, '(.*)')+'(\\\\?|$)')\n }\n return new RegExp('^'+route.replace(/:\\w+/g, '([^/]+)').replace(/:\\*/, '(.*)'))\n}\n\nfunction parseRoutes(routes, routeInfo, exact=false) {\n const paths = Object.keys(routes)\n const matchParams = /:(\\w+|\\*)/g\n for (let path of paths) {\n let matches = []\n let params = []\n do {\n matches = matchParams.exec(path)\n if (matches) {\n params.push(matches[1])\n }\n } while(matches)\n routeInfo.push({\n match: getRegexpFromRoute(path, exact),\n params: params,\n action: routes[path]\n })\n }\n return routeInfo\n}\n", "class SimplyCommands {\n\tconstructor(options={}) {\n\t\tif (!options.app) {\n\t\t\toptions.app = {}\n\t\t}\n\t\tif (!options.app.container) {\n\t\t\toptions.app.container = document.body\n\t\t}\n\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\nexport function commands(options={}) {\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) {\n\tif (options.app) {\n\t\tconst actionHandler = {\n\t\t\tget: (target, property) => {\n\t\t\t\treturn target[property].bind(options.app)\n\t\t\t}\n\t\t}\n\t\treturn new Proxy(options.actions, actionHandler)\n\t} else {\n\t\treturn options\n\t}\n}", "const KEY = Object.freeze({\n\tCompose: 229,\n\tControl: 17,\n\tMeta: 224,\n\tAlt: 18,\n\tShift: 16\n})\n\nclass SimplyKey {\n\tconstructor(options = {}) {\n\t\tif (!options.app) {\n\t\t\toptions.app = {}\n\t\t}\n\t\tif (!options.app.container) {\n\t\t\toptions.app.container = document.body\n\t\t}\n\t\tObject.assign(this, options.keys)\n\n\t\tconst keyHandler = (e) => {\n\t\t\tif (e.isComposing || e.keyCode === KEY.Compose) {\n\t\t\t return\n\t\t\t}\n\t\t\tif (e.defaultPrevented) {\n\t\t\t return\n\t\t\t}\n\t\t\tif (!e.target) {\n\t\t\t return\n\t\t\t}\n\n\t\t\tlet selectedKeyboard = 'default'\n\t\t\tif (e.target.closest('[data-simply-keyboard]')) {\n\t\t\t selectedKeyboard = e.target.closest('[data-simply-keyboard]')\n\t\t\t \t\t\t\t\t.dataset.simplyKeyboard\n\t\t\t}\n\t\t\tlet keyCombination = []\n\t\t\tif (e.ctrlKey && e.keyCode!=KEY.Control) {\n\t\t\t keyCombination.push('Control')\n\t\t\t}\n\t\t\tif (e.metaKey && e.keyCode!=KEY.Meta) {\n\t\t\t keyCombination.push('Meta')\n\t\t\t}\n\t\t\tif (e.altKey && e.keyCode!=KEY.Alt) {\n\t\t\t keyCombination.push('Alt')\n\t\t\t}\n\t\t\tif (e.shiftKey && e.keyCode!=KEY.Shift) {\n\t\t\t keyCombination.push('Shift')\n\t\t\t}\n\t\t\tkeyCombination.push(e.key.toLowerCase())\n\n\t\t\tlet keyboards = []\n\t\t\tlet keyboardElement = event.target.closest('[data-simply-keyboard]')\n\t\t\twhile (keyboardElement) {\n\t\t\t\tkeyboards.push(keyboardElement.dataset.simplyKeyboard)\n\t\t\t\tkeyboardElement = keyboardElement.parentNode.closest('[data-simply-keyboard]')\n\t\t\t}\n\t\t\tkeyboards.push('')\n\n\t\t\tlet keyboard, subkeyboard\n\t\t\tlet separators = ['+','-']\n\n\t\t\tfor (i in keyboards) {\n\t\t\t\tkeyboard = keyboards[i]\n\t\t\t\tif (keyboard == '') {\n\t\t\t\t\tsubkeyboard = 'default'\n\t\t\t\t} else {\n\t\t\t\t\tsubkeyboard = keyboard\n\t\t\t\t\tkeyboard += '.'\n\t\t\t\t}\n\t\t\t\tfor (let separator of separators) {\n\t\t\t\t\tlet keyString = keyCombination.join(separator)\n\n\t\t\t\t\tif (this[subkeyboard] && (typeof this[subkeyboard][keyString]=='function')) {\n\t\t\t\t\t\tlet _continue = this[subkeyboard][keyString].call(this[subkeyboard], e)\n\t\t\t\t\t\tif (!_continue) {\n\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof this[subkeyboard + keyString] == 'function') {\n\t\t\t\t\t\tlet _continue = this[subkeyboard + keyString].call(this, e)\n\t\t\t\t\t\tif (!_continue) {\n\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\t\t\t\t\t\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this[selectedKeyboard] && this[selectedKeyboard][keyString]) {\n\t\t\t\t\t\tlet targets = options.app.container.querySelectorAll('[data-simply-accesskey=\"'\n\t\t\t\t\t\t\t+ keyboard + keyString + '\"]')\n\t\t\t\t\t\tif (targets.length) {\n\t\t\t\t\t\t\ttargets.forEach(t => t.click())\n\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\toptions.app.container.addEventListener('keydown', keyHandler)\n\t}\n\n}\n\nexport function keys(options={}) {\n\treturn new SimplyKey(options)\n}\n\n", "export function view(options) {\n\tif (options.app) {\n\t\toptions.app.view = options.view || {}\n\n\t\tconst load = () => {\n\t\t\tconst data = options.app.view\n\t\t\tconst path = globalThis.editor.data.getDataPath(options.app.container || document.body)\n\t\t\toptions.app.view = globalThis.editor.currentData[path]\n\t\t\tObject.assign(options.app.view, data)\n\t\t}\n\t\tif (globalThis.editor && globalThis.editor.currentData) {\n\t\t\tload()\n\t\t} else {\n\t\t\tdocument.addEventListener('simply-content-loaded', load)\n\t\t}\n\t\treturn options.app.view\n\t} else {\n\t\treturn options.view\n\t}\n}", "import { routes } from './route.mjs'\nimport { commands } from './command.mjs'\nimport { actions } from './action.mjs'\nimport { keys } from './key.mjs'\nimport { view } from './view.mjs'\n\nclass SimplyApp {\n\tconstructor(options={}) {\n\t\tthis.container = options.container || document.body\n\t\tfor (let key in options) {\n\t\t\tswitch(key) {\n\t\t\t\tcase 'commands':\n\t\t\t\t\tthis.commands = commands({ app: this, container: this.container, commands: options.commands})\n\t\t\t\t\tbreak\n\t\t\t\tcase 'keys':\n\t\t\t\tcase 'keyboard': // backwards compatible\n\t\t\t\t\tthis.keys = keys({ app: this, keys: options.keys })\n\t\t\t\t\tbreak\n\t\t\t\tcase 'routes':\n\t\t\t\t\tthis.routes = routes({ app: this, routes: options.routes})\n\t\t\t\t\tbreak\n\t\t\t\tcase 'actions':\n\t\t\t\t\tthis.actions = actions({app: this, actions: options.actions})\n\t\t\t\t\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}\n\nexport function app(options={}) {\n\treturn new SimplyApp(options)\n}"],
5
- "mappings": "MAAO,SAASA,EAAOC,EAAS,CAC/B,OAAO,IAAIC,EAAYD,CAAO,CAC/B,CAEA,IAAMC,EAAN,KAAkB,CACjB,YAAYD,EAAQ,CAAC,EAAG,CACvB,KAAK,KAAOA,EAAQ,MAAQ,IACtB,KAAK,IAAMA,EAAQ,IACnB,KAAK,gBAAkB,CAAC,CAACA,EAAQ,gBACjC,KAAK,WAAa,CAAC,CAACA,EAAQ,WAClC,KAAK,MAAM,EACPA,EAAQ,QACX,KAAK,KAAKA,EAAQ,MAAM,CAE1B,CAEA,KAAKD,EAAQ,CACZG,EAAYH,EAAQ,KAAK,UAAW,KAAK,UAAU,CACpD,CAEA,OAAQ,CACP,KAAK,UAAY,CAAC,EAClB,KAAK,UAAY,CAChB,MAAO,CAAC,EACR,KAAM,CAAC,EACP,OAAQ,CAAC,CACV,CACD,CAEA,MAAMI,EAAMH,EAAS,CACpB,IAAII,EAAO,CACD,KAAAD,EACA,QAAAH,CACJ,EACAI,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,GAVAF,EAAU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AAG,EACvB,KACF,CAEF,CACD,EAEO,SAASM,EAAIP,EAAQ,CAAC,EAAG,CAC/B,OAAO,IAAID,EAAUC,CAAO,CAC7B",
6
- "names": ["routes", "options", "SimplyRoute", "parseRoutes", "path", "args", "matches", "getPath", "route", "getURL", "params", "key", "i", "action", "routeRe", "getRegexpFromRoute", "result", "callback", "evt", "link", "listener", "root", "exact", "routeInfo", "paths", "matchParams", "SimplyCommands", "options", "defaultHandlers", "commandHandler", "evt", "command", "getCommand", "commands", "handlers", "el", "handler", "values", "option", "data", "input", "actions", "options", "actionHandler", "target", "property", "KEY", "SimplyKey", "options", "keyHandler", "e", "selectedKeyboard", "keyCombination", "keyboards", "keyboardElement", "keyboard", "subkeyboard", "separators", "separator", "keyString", "targets", "t", "keys", "view", "options", "load", "data", "path", "SimplyApp", "options", "key", "commands", "keys", "routes", "actions", "view", "app"]
4
+ "sourcesContent": ["export function routes(options, optionsCompat) {\n if (optionsCompat) {\n let app = options\n options = optionsCompat\n options.app = options\n }\n\treturn new SimplyRoute(options)\n}\n\nclass SimplyRoute {\n\tconstructor(options={}) {\n\t\tthis.root = options.root || '/'\n this.app = options.app || {}\n this.addMissingSlash = !!options.addMissingSlash\n this.matchExact = !!options.matchExact\n\t\tthis.clear()\n\t\tif (options.routes) {\n\t\t\tthis.load(options.routes)\n\t\t}\n\t}\n\n\tload(routes) {\n\t\tparseRoutes(routes, this.routeInfo, this.matchExact)\n\t}\n\n\tclear() {\n\t\tthis.routeInfo = []\n\t\tthis.listeners = {\n\t\t\tmatch: {},\n\t\t\tcall: {},\n\t\t\tfinish: {}\n\t\t}\n\t}\n\n\tmatch(path, options) {\n\t\tlet args = {\n path,\n options\n }\n args = this.runListeners('match',args)\n path = args.path ? args.path : path;\n\n let matches;\n if (!path) {\n if (this.match(document.location.pathname+document.location.hash)) {\n return true;\n } else {\n return this.match(document.location.pathname);\n }\n }\n path = getPath(path);\n for ( let route of this.routeInfo) {\n matches = route.match.exec(path)\n if (this.addMissingSlash && !matches?.length) {\n if (path && path[path.length-1]!='/') {\n matches = route.match.exec(path+'/')\n if (matches) {\n path+='/'\n history.replaceState({}, '', getURL(path))\n }\n }\n }\n if (matches && matches.length) {\n var params = {};\n route.params.forEach((key, i) => {\n if (key=='*') {\n key = 'remainder'\n }\n params[key] = matches[i+1]\n })\n Object.assign(params, options)\n args.route = route\n args.params = params\n args = this.runListeners('call', args)\n params = args.params ? args.params : params\n args.result = route.action.call(this.app, params)\n this.runListeners('finish', args)\n return args.result\n }\n }\n return false\n\t}\n\n\trunListeners(action, params) {\n if (!Object.keys(this.listeners[action])) {\n return\n }\n Object.keys(this.listeners[action]).forEach((route) => {\n var routeRe = getRegexpFromRoute(route);\n if (routeRe.exec(params.path)) {\n var result;\n for (let callback of this.listeners[action][route]) {\n result = callback.call(this.app, params)\n if (result) {\n params = result\n }\n }\n }\n })\n return params\n }\n\n handleEvents() {\n globalThis.addEventListener('popstate', () => {\n if (this.match(getPath(document.location.pathname + document.location.hash, this.root)) === false) {\n this.match(getPath(document.location.pathname, this.root))\n }\n })\n this.app.container.addEventListener('click', (evt) => {\n\t if (evt.ctrlKey) {\n\t return;\n\t }\n\t if (evt.which != 1) {\n\t return; // not a 'left' mouse click\n\t }\n\t var link = evt.target;\n\t while (link && link.tagName!='A') {\n\t link = link.parentElement;\n\t }\n\t if (link \n\t && link.pathname \n\t && link.hostname==globalThis.location.hostname \n\t && !link.link\n\t && !link.dataset.simplyCommand\n\t ) {\n\t let path = getPath(link.pathname+link.hash, this.root);\n\t if ( !this.has(path) ) {\n\t path = getPath(link.pathname, this.root);\n\t }\n\t if ( this.has(path) ) {\n\t let params = this.runListeners('goto', { path: path});\n\t if (params.path) {\n\t if (this.goto(params.path)) {\n // now cancel the browser navigation, since a route handler was found\n evt.preventDefault();\n return false;\n }\n\t }\n\t }\n\t }\n\t })\n }\n\n goto(path) {\n history.pushState({},'',getURL(path))\n return this.match(path)\n }\n\n has(path) {\n \tpath = getPath(path, this.root)\n \tfor (let route of this.routeInfo) {\n var matches = route.match.exec(path)\n if (matches && matches.length) {\n return true\n }\n }\n return false\n }\n\n addListener(action, route, callback) {\n if (['goto','match','call','finish'].indexOf(action)==-1) {\n throw new Error('Unknown action '+action)\n }\n if (!this.listeners[action][route]) {\n this.listeners[action][route] = []\n }\n this.listeners[action][route].push(callback)\n }\n\n removeListener(action, route, callback) {\n if (['match','call','finish'].indexOf(action)==-1) {\n throw new Error('Unknown action '+action)\n }\n if (!this.listeners[action][route]) {\n return\n }\n this.listeners[action][route] = this.listeners[action][route].filter((listener) => {\n return listener != callback\n })\n }\n\n init(options) {\n \tif (options.root) {\n \t\tthis.root = options.root\n \t}\n }\n}\n\nfunction getPath(path, root='/') {\n if (path.substring(0,root.length)==root\n ||\n ( root[root.length-1]=='/' \n && path.length==(root.length-1)\n && path == root.substring(0,path.length)\n )\n ) {\n path = path.substring(root.length)\n }\n if (path[0]!='/' && path[0]!='#') {\n path = '/'+path\n }\n return path\n}\n\nfunction getURL(path, root) {\n path = getPath(path, root)\n if (root[root.length-1]==='/' && path[0]==='/') {\n path = path.substring(1)\n }\n return root + path;\n}\n\nfunction getRegexpFromRoute(route, exact=false) {\n if (exact) {\n return new RegExp('^'+route.replace(/:\\w+/g, '([^/]+)').replace(/:\\*/, '(.*)')+'(\\\\?|$)')\n }\n return new RegExp('^'+route.replace(/:\\w+/g, '([^/]+)').replace(/:\\*/, '(.*)'))\n}\n\nfunction parseRoutes(routes, routeInfo, exact=false) {\n const paths = Object.keys(routes)\n const matchParams = /:(\\w+|\\*)/g\n for (let path of paths) {\n let matches = []\n let params = []\n do {\n matches = matchParams.exec(path)\n if (matches) {\n params.push(matches[1])\n }\n } while(matches)\n routeInfo.push({\n match: getRegexpFromRoute(path, exact),\n params: params,\n action: routes[path]\n })\n }\n return routeInfo\n}\n", "class SimplyCommands {\n\tconstructor(options={}) {\n\t\tif (!options.app) {\n\t\t\toptions.app = {}\n\t\t}\n\t\tif (!options.app.container) {\n\t\t\toptions.app.container = document.body\n\t\t}\n this.app = options.app\n\t\tthis.$handlers = options.handlers || defaultHandlers\n if (options.commands) {\n \t\tObject.assign(this, options.commands)\n }\n\n\t\tconst commandHandler = (evt) => {\n\t\t\tconst command = getCommand(evt, this.$handlers)\n\t\t\tif (!command) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (!this[command.name]) {\n console.error('simply.command: undefined command '+command.name, command.source);\n return\n\t\t\t}\n const shouldContinue = this[command.name].call(options.app, command.source, command.value)\n if (shouldContinue!==true) {\n evt.preventDefault()\n evt.stopPropagation()\n return false\n }\n\t\t}\n\n options.app.container.addEventListener('click', commandHandler)\n options.app.container.addEventListener('submit', commandHandler)\n options.app.container.addEventListener('change', commandHandler)\n options.app.container.addEventListener('input', commandHandler)\n\t}\n\n call(command, el, value) {\n if (!this[command]) {\n console.error('simply.command: undefined command '+command);\n return\n }\n return this[command].call(this.app, el, value)\n }\n\n action(name) {\n console.warn('deprecated call to `this.commands.action`')\n let params = Array.from(arguments).slice()\n params.shift()\n return this.app.actions[name](...params)\n }\n\n appendHandler(handler) {\n this.$handlers.push(handler)\n }\n\n prependHandler(handler) {\n this.$handlers.unshift(handler)\n }\n}\n\nexport function commands(options={}, optionsCompat) {\n if (optionsCompat) {\n let app = options\n options = optionsCompat\n options.app = options\n }\n\treturn new SimplyCommands(options)\n}\n\nfunction getCommand(evt, handlers) {\n var el = evt.target.closest('[data-simply-command]')\n if (el) {\n for (let handler of handlers) {\n if (el.matches(handler.match)) {\n if (handler.check(el, evt)) {\n return {\n name: el.dataset.simplyCommand,\n source: el,\n value: handler.get(el)\n }\n }\n return null\n }\n }\n }\n return null\n}\n\nconst defaultHandlers = [\n {\n match: 'input,select,textarea',\n get: function(el) {\n if (el.tagName==='SELECT' && el.multiple) {\n let values = []\n for (let option of el.options) {\n if (option.selected) {\n values.push(option.value)\n }\n }\n return values\n }\n return el.dataset.simplyValue || el.value\n },\n check: function(el, evt) {\n return evt.type=='change' || (el.dataset.simplyImmediate && evt.type=='input')\n }\n },\n {\n match: 'a,button',\n get: function(el) {\n return el.dataset.simplyValue || el.href || el.value\n },\n check: function(el,evt) {\n return evt.type=='click' && evt.ctrlKey==false && evt.button==0\n }\n },\n {\n match: 'form',\n get: function(el) {\n let data = {}\n for (let input of Array.from(el.elements)) {\n if (input.tagName=='INPUT' \n && (input.type=='checkbox' || input.type=='radio')\n ) {\n if (!input.checked) {\n return;\n }\n }\n if (data[input.name] && !Array.isArray(data[input.name])) {\n data[input.name] = [data[input.name]]\n }\n if (Array.isArray(data[input.name])) {\n data[input.name].push(input.value)\n } else {\n data[input.name] = input.value\n }\n }\n return data\n },\n check: function(el,evt) {\n return evt.type=='submit'\n }\n },\n {\n \tmatch: '*',\n get: function(el) {\n return el.dataset.simplyValue\n },\n check: function(el, evt) {\n return evt.type=='click' && evt.ctrlKey==false && evt.button==0\n }\n }\n]", "export function actions(options, optionsCompat) {\n\tif (optionsCompat) {\n\t\tlet app = options\n\t\toptions = optionsCompat\n\t\toptions.app = options\n\t}\n\tif (options.app) {\n\t\tconst actionHandler = {\n\t\t\tget: (target, property) => {\n\t\t\t\treturn target[property].bind(options.app)\n\t\t\t}\n\t\t}\n\t\treturn new Proxy(options.actions, actionHandler)\n\t} else {\n\t\treturn options\n\t}\n}", "const KEY = Object.freeze({\n\tCompose: 229,\n\tControl: 17,\n\tMeta: 224,\n\tAlt: 18,\n\tShift: 16\n})\n\nclass SimplyKey {\n\tconstructor(options = {}) {\n\t\tif (!options.app) {\n\t\t\toptions.app = {}\n\t\t}\n\t\tif (!options.app.container) {\n\t\t\toptions.app.container = document.body\n\t\t}\n\t\tObject.assign(this, options.keys)\n\n\t\tconst keyHandler = (e) => {\n\t\t\tif (e.isComposing || e.keyCode === KEY.Compose) {\n\t\t\t return\n\t\t\t}\n\t\t\tif (e.defaultPrevented) {\n\t\t\t return\n\t\t\t}\n\t\t\tif (!e.target) {\n\t\t\t return\n\t\t\t}\n\n\t\t\tlet selectedKeyboard = 'default'\n\t\t\tif (e.target.closest('[data-simply-keyboard]')) {\n\t\t\t selectedKeyboard = e.target.closest('[data-simply-keyboard]')\n\t\t\t \t\t\t\t\t.dataset.simplyKeyboard\n\t\t\t}\n\t\t\tlet keyCombination = []\n\t\t\tif (e.ctrlKey && e.keyCode!=KEY.Control) {\n\t\t\t keyCombination.push('Control')\n\t\t\t}\n\t\t\tif (e.metaKey && e.keyCode!=KEY.Meta) {\n\t\t\t keyCombination.push('Meta')\n\t\t\t}\n\t\t\tif (e.altKey && e.keyCode!=KEY.Alt) {\n\t\t\t keyCombination.push('Alt')\n\t\t\t}\n\t\t\tif (e.shiftKey && e.keyCode!=KEY.Shift) {\n\t\t\t keyCombination.push('Shift')\n\t\t\t}\n\t\t\tkeyCombination.push(e.key.toLowerCase())\n\n\t\t\tlet keyboards = []\n\t\t\tlet keyboardElement = event.target.closest('[data-simply-keyboard]')\n\t\t\twhile (keyboardElement) {\n\t\t\t\tkeyboards.push(keyboardElement.dataset.simplyKeyboard)\n\t\t\t\tkeyboardElement = keyboardElement.parentNode.closest('[data-simply-keyboard]')\n\t\t\t}\n\t\t\tkeyboards.push('')\n\n\t\t\tlet keyboard, subkeyboard\n\t\t\tlet separators = ['+','-']\n\n\t\t\tfor (i in keyboards) {\n\t\t\t\tkeyboard = keyboards[i]\n\t\t\t\tif (keyboard == '') {\n\t\t\t\t\tsubkeyboard = 'default'\n\t\t\t\t} else {\n\t\t\t\t\tsubkeyboard = keyboard\n\t\t\t\t\tkeyboard += '.'\n\t\t\t\t}\n\t\t\t\tfor (let separator of separators) {\n\t\t\t\t\tlet keyString = keyCombination.join(separator)\n\n\t\t\t\t\tif (this[subkeyboard] && (typeof this[subkeyboard][keyString]=='function')) {\n\t\t\t\t\t\tlet _continue = this[subkeyboard][keyString].call(options.app, e)\n\t\t\t\t\t\tif (!_continue) {\n\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof this[subkeyboard + keyString] == 'function') {\n\t\t\t\t\t\tlet _continue = this[subkeyboard + keyString].call(options.app, e)\n\t\t\t\t\t\tif (!_continue) {\n\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\t\t\t\t\t\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this[selectedKeyboard] && this[selectedKeyboard][keyString]) {\n\t\t\t\t\t\tlet targets = options.app.container.querySelectorAll('[data-simply-accesskey=\"'\n\t\t\t\t\t\t\t+ keyboard + keyString + '\"]')\n\t\t\t\t\t\tif (targets.length) {\n\t\t\t\t\t\t\ttargets.forEach(t => t.click())\n\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\toptions.app.container.addEventListener('keydown', keyHandler)\n\t}\n\n}\n\nexport function keys(options={}, optionsCompat) {\n\tif (optionsCompat) {\n\t\tlet app = options\n\t\toptions = optionsCompat\n\t\toptions.app = options\n\t}\n\treturn new SimplyKey(options)\n}\n\n", "export function view(options, optionsCompat) {\n\tif (optionsCompat) {\n\t\tlet app = options\n\t\toptions = optionsCompat\n\t\toptions.app = options\n\t}\n\tif (options.app) {\n\t\toptions.app.view = options.view || {}\n\n\t\tconst load = () => {\n\t\t\tconst data = options.app.view\n\t\t\tconst path = globalThis.editor.data.getDataPath(options.app.container || document.body)\n\t\t\toptions.app.view = globalThis.editor.currentData[path]\n\t\t\tObject.assign(options.app.view, data)\n\t\t}\n\t\tif (globalThis.editor && globalThis.editor.currentData) {\n\t\t\tload()\n\t\t} else {\n\t\t\tdocument.addEventListener('simply-content-loaded', load)\n\t\t}\n\t\treturn options.app.view\n\t} else {\n\t\treturn options.view\n\t}\n}", "import { routes } from './route.mjs'\nimport { commands } from './command.mjs'\nimport { actions } from './action.mjs'\nimport { keys } from './key.mjs'\nimport { view } from './view.mjs'\n\nclass SimplyApp {\n\tconstructor(options={}) {\n\t\tthis.container = options.container || document.body\n\t\tfor (let key in options) {\n\t\t\tswitch(key) {\n\t\t\t\tcase 'commands':\n\t\t\t\t\tthis.commands = commands({ app: this, container: this.container, commands: options.commands})\n\t\t\t\t\tbreak\n\t\t\t\tcase 'keys':\n\t\t\t\tcase 'keyboard': // backwards compatible\n\t\t\t\t\tthis.keys = keys({ app: this, keys: options.keys })\n\t\t\t\t\tbreak\n\t\t\t\tcase 'routes':\n\t\t\t\t\tthis.routes = routes({ app: this, routes: options.routes})\n\t\t\t\t\tthis.routes.handleEvents();\n\t globalThis.setTimeout(() => {\n\t this.routes.match(globalThis.location?.pathname+globalThis.location?.hash);\n\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}"],
5
+ "mappings": "MAAO,SAASA,EAAOC,EAASC,EAAe,CAC3C,GAAIA,EAAe,CACf,IAAIC,EAAMF,EACVA,EAAUC,EACVD,EAAQ,IAAMA,CAClB,CACH,OAAO,IAAIG,EAAYH,CAAO,CAC/B,CAEA,IAAMG,EAAN,KAAkB,CACjB,YAAYH,EAAQ,CAAC,EAAG,CACvB,KAAK,KAAOA,EAAQ,MAAQ,IACtB,KAAK,IAAMA,EAAQ,KAAO,CAAC,EAC3B,KAAK,gBAA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CAAC,EAClD,MACD,IAAK,SACJ,KAAK,OAASI,EAAO,CAAE,IAAK,KAAM,OAAQJ,EAAQ,MAAM,CAAC,EACzD,KAAK,OAAO,aAAa,EACb,WAAW,WAAW,IAAM,CACxB,KAAK,OAAO,MAAM,WAAW,UAAU,SAAS,WAAW,UAAU,IAAI,CAC7E,CAAC,EACb,MACD,IAAK,UACJ,KAAK,QAAUK,EAAQ,CAAC,IAAK,KAAM,QAASL,EAAQ,OAAO,CAAC,EAC5D,KAAK,OAAS,SAASM,EAAM,CAC5B,QAAQ,KAAK,kCAAkC,EAC/C,IAAIC,EAAS,MAAM,KAAK,SAAS,EAAE,MAAM,EACnC,OAAAA,EAAO,MAAM,EACN,KAAK,QAAQD,CAAI,EAAE,GAAGC,CAAM,CACvC,EACH,MACD,IAAK,OACJ,KAAK,KAAOC,EAAK,CAAC,IAAK,KAAM,KAAMR,EAAQ,IAAI,CAAC,EAChD,MACD,QACC,KAAKC,CAAG,EAAID,EAAQC,CAAG,EACvB,KACF,CAEF,CACA,IAAI,KAAM,CACT,OAAO,IACR,CACD,EAEO,SAASQ,EAAIT,EAAQ,CAAC,EAAG,CAC/B,OAAO,IAAID,EAAUC,CAAO,CAC7B",
6
+ "names": ["routes", "options", "optionsCompat", "app", "SimplyRoute", "parseRoutes", "path", "args", "matches", "getPath", "route", "getURL", "params", "key", "i", "action", "routeRe", "getRegexpFromRoute", "result", "callback", "evt", "link", "listener", "root", "exact", "routeInfo", "paths", "matchParams", "SimplyCommands", "options", "defaultHandlers", "commandHandler", "evt", "command", "getCommand", "el", "value", "name", "params", "handler", "commands", "optionsCompat", "app", "handlers", "values", "option", "data", "input", "actions", "options", "optionsCompat", "app", "actionHandler", "target", "property", "KEY", "SimplyKey", "options", "keyHandler", "e", "selectedKeyboard", "keyCombination", "keyboards", "keyboardElement", "keyboard", "subkeyboard", "separators", "separator", "keyString", "targets", "t", "keys", "optionsCompat", "app", "view", "options", "optionsCompat", "app", "load", "data", "path", "SimplyApp", "options", "key", "commands", "keys", "routes", "actions", "name", "params", "view", "app"]
7
7
  }
@@ -60,7 +60,12 @@
60
60
  });
61
61
 
62
62
  // src/action.mjs
63
- function actions(options) {
63
+ function actions(options, optionsCompat) {
64
+ if (optionsCompat) {
65
+ let app2 = options;
66
+ options = optionsCompat;
67
+ options.app = options;
68
+ }
64
69
  if (options.app) {
65
70
  const actionHandler = {
66
71
  get: (target, property) => {
@@ -74,13 +79,18 @@
74
79
  }
75
80
 
76
81
  // src/route.mjs
77
- function routes(options) {
82
+ function routes(options, optionsCompat) {
83
+ if (optionsCompat) {
84
+ let app2 = options;
85
+ options = optionsCompat;
86
+ options.app = options;
87
+ }
78
88
  return new SimplyRoute(options);
79
89
  }
80
90
  var SimplyRoute = class {
81
91
  constructor(options = {}) {
82
92
  this.root = options.root || "/";
83
- this.app = options.app;
93
+ this.app = options.app || {};
84
94
  this.addMissingSlash = !!options.addMissingSlash;
85
95
  this.matchExact = !!options.matchExact;
86
96
  this.clear();
@@ -139,7 +149,7 @@
139
149
  args.params = params;
140
150
  args = this.runListeners("call", args);
141
151
  params = args.params ? args.params : params;
142
- args.result = route.action.call(route, params);
152
+ args.result = route.action.call(this.app, params);
143
153
  this.runListeners("finish", args);
144
154
  return args.result;
145
155
  }
@@ -290,6 +300,7 @@
290
300
  if (!options.app.container) {
291
301
  options.app.container = document.body;
292
302
  }
303
+ this.app = options.app;
293
304
  this.$handlers = options.handlers || defaultHandlers;
294
305
  if (options.commands) {
295
306
  Object.assign(this, options.commands);
@@ -315,8 +326,32 @@
315
326
  options.app.container.addEventListener("change", commandHandler);
316
327
  options.app.container.addEventListener("input", commandHandler);
317
328
  }
329
+ call(command, el, value) {
330
+ if (!this[command]) {
331
+ console.error("simply.command: undefined command " + command);
332
+ return;
333
+ }
334
+ return this[command].call(this.app, el, value);
335
+ }
336
+ action(name) {
337
+ console.warn("deprecated call to `this.commands.action`");
338
+ let params = Array.from(arguments).slice();
339
+ params.shift();
340
+ return this.app.actions[name](...params);
341
+ }
342
+ appendHandler(handler) {
343
+ this.$handlers.push(handler);
344
+ }
345
+ prependHandler(handler) {
346
+ this.$handlers.unshift(handler);
347
+ }
318
348
  };
319
- function commands(options = {}) {
349
+ function commands(options = {}, optionsCompat) {
350
+ if (optionsCompat) {
351
+ let app2 = options;
352
+ options = optionsCompat;
353
+ options.app = options;
354
+ }
320
355
  return new SimplyCommands(options);
321
356
  }
322
357
  function getCommand(evt, handlers) {
@@ -466,14 +501,14 @@
466
501
  for (let separator of separators) {
467
502
  let keyString = keyCombination.join(separator);
468
503
  if (this[subkeyboard] && typeof this[subkeyboard][keyString] == "function") {
469
- let _continue = this[subkeyboard][keyString].call(this[subkeyboard], e);
504
+ let _continue = this[subkeyboard][keyString].call(options.app, e);
470
505
  if (!_continue) {
471
506
  e.preventDefault();
472
507
  return;
473
508
  }
474
509
  }
475
510
  if (typeof this[subkeyboard + keyString] == "function") {
476
- let _continue = this[subkeyboard + keyString].call(this, e);
511
+ let _continue = this[subkeyboard + keyString].call(options.app, e);
477
512
  if (!_continue) {
478
513
  e.preventDefault();
479
514
  return;
@@ -492,12 +527,22 @@
492
527
  options.app.container.addEventListener("keydown", keyHandler);
493
528
  }
494
529
  };
495
- function keys(options = {}) {
530
+ function keys(options = {}, optionsCompat) {
531
+ if (optionsCompat) {
532
+ let app2 = options;
533
+ options = optionsCompat;
534
+ options.app = options;
535
+ }
496
536
  return new SimplyKey(options);
497
537
  }
498
538
 
499
539
  // src/view.mjs
500
- function view(options) {
540
+ function view(options, optionsCompat) {
541
+ if (optionsCompat) {
542
+ let app2 = options;
543
+ options = optionsCompat;
544
+ options.app = options;
545
+ }
501
546
  if (options.app) {
502
547
  options.app.view = options.view || {};
503
548
  const load = () => {
@@ -532,9 +577,19 @@
532
577
  break;
533
578
  case "routes":
534
579
  this.routes = routes({ app: this, routes: options.routes });
580
+ this.routes.handleEvents();
581
+ globalThis.setTimeout(() => {
582
+ this.routes.match(globalThis.location?.pathname + globalThis.location?.hash);
583
+ });
535
584
  break;
536
585
  case "actions":
537
586
  this.actions = actions({ app: this, actions: options.actions });
587
+ this.action = function(name) {
588
+ console.warn("deprecated call to `this.action`");
589
+ let params = Array.from(arguments).slice();
590
+ params.shift();
591
+ return this.actions[name](...params);
592
+ };
538
593
  break;
539
594
  case "view":
540
595
  this.view = view({ app: this, view: options.view });
@@ -545,6 +600,9 @@
545
600
  }
546
601
  }
547
602
  }
603
+ get app() {
604
+ return this;
605
+ }
548
606
  };
549
607
  function app(options = {}) {
550
608
  return new SimplyApp(options);
@@ -722,6 +780,31 @@
722
780
  observe();
723
781
  handleChanges2();
724
782
 
783
+ // src/render.mjs
784
+ var SimplyRender = class extends HTMLElement {
785
+ constructor() {
786
+ super();
787
+ let templateId = this.getAttribute("rel");
788
+ let template = document.getElementById(templateId);
789
+ if (template) {
790
+ let content = template.content.cloneNode(true);
791
+ for (const node of content.childNodes) {
792
+ const clone = node.cloneNode(true);
793
+ if (clone.nodeType == document.ELEMENT_NODE) {
794
+ clone.querySelectorAll("template").forEach(function(t) {
795
+ t.setAttribute("simply-render", "");
796
+ });
797
+ }
798
+ this.parentNode.insertBefore(clone, this);
799
+ }
800
+ this.parentNode.removeChild(this);
801
+ }
802
+ }
803
+ };
804
+ if (!customElements.get("simply-render")) {
805
+ customElements.define("simply-render", SimplyRender);
806
+ }
807
+
725
808
  // src/everything.mjs
726
809
  var simply = {
727
810
  activate,
@@ -732,6 +815,7 @@
732
815
  key: keys,
733
816
  route: routes,
734
817
  view
818
+ //TODO: add collect back?
735
819
  };
736
820
  window.simply = simply;
737
821
  var everything_default = simply;
@@ -1,2 +1,2 @@
1
- (()=>{var u=new Map,S={addListener:(t,e)=>{u.has(t)||u.set(t,[]),u.get(t).push(e),V(t)},removeListener:(t,e)=>{if(!u.has(t))return!1;u.set(t,u.get(t).filter(r=>r!=e))}};function V(t){let e=document.querySelectorAll('[data-simply-activate="'+t+'"]');if(e)for(let r of e)N(r)}function N(t){let e=t?.dataset?.simplyActivate;if(e&&u.has(e))for(let r of u.get(e))r.call(t)}function $(t){let e=[];for(let a of t)if(a.type=="childList"){for(let n of a.addedNodes)if(n.querySelectorAll){var r=Array.from(n.querySelectorAll("[data-simply-activate]"));n.matches("[data-simply-activate]")&&r.push(n),e=e.concat(r)}}for(let a of e)N(a)}var z=new MutationObserver($);z.observe(document,{subtree:!0,childList:!0});function g(t){if(t.app){let e={get:(r,a)=>r[a].bind(t.app)};return new Proxy(t.actions,e)}else return t}function b(t){return new C(t)}var C=class{constructor(e={}){this.root=e.root||"/",this.app=e.app,this.addMissingSlash=!!e.addMissingSlash,this.matchExact=!!e.matchExact,this.clear(),e.routes&&this.load(e.routes)}load(e){W(e,this.routeInfo,this.matchExact)}clear(){this.routeInfo=[],this.listeners={match:{},call:{},finish:{}}}match(e,r){let a={path:e,options:r};a=this.runListeners("match",a),e=a.path?a.path:e;let n;if(!e)return this.match(document.location.pathname+document.location.hash)?!0:this.match(document.location.pathname);e=f(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({},"",O(e)))),n&&n.length){var c={};return s.params.forEach((l,h)=>{l=="*"&&(l="remainder"),c[l]=n[h+1]}),Object.assign(c,r),a.route=s,a.params=c,a=this.runListeners("call",a),c=a.params?a.params:c,a.result=s.action.call(s,c),this.runListeners("finish",a),a.result}return!1}runListeners(e,r){if(Object.keys(this.listeners[e]))return Object.keys(this.listeners[e]).forEach(a=>{var n=j(a);if(n.exec(r.path)){var c;for(let s of this.listeners[e][a])c=s.call(this.app,r),c&&(r=c)}}),r}handleEvents(){globalThis.addEventListener("popstate",()=>{this.match(f(document.location.pathname+document.location.hash,this.root))===!1&&this.match(f(document.location.pathname,this.root))}),this.app.container.addEventListener("click",e=>{if(!e.ctrlKey&&e.which==1){for(var r=e.target;r&&r.tagName!="A";)r=r.parentElement;if(r&&r.pathname&&r.hostname==globalThis.location.hostname&&!r.link&&!r.dataset.simplyCommand){let a=f(r.pathname+r.hash,this.root);if(this.has(a)||(a=f(r.pathname,this.root)),this.has(a)){let n=this.runListeners("goto",{path:a});if(n.path&&this.goto(n.path))return e.preventDefault(),!1}}}})}goto(e){return history.pushState({},"",O(e)),this.match(e)}has(e){e=f(e,this.root);for(let a of this.routeInfo){var r=a.match.exec(e);if(r&&r.length)return!0}return!1}addListener(e,r,a){if(["goto","match","call","finish"].indexOf(e)==-1)throw new Error("Unknown action "+e);this.listeners[e][r]||(this.listeners[e][r]=[]),this.listeners[e][r].push(a)}removeListener(e,r,a){if(["match","call","finish"].indexOf(e)==-1)throw new Error("Unknown action "+e);this.listeners[e][r]&&(this.listeners[e][r]=this.listeners[e][r].filter(n=>n!=a))}init(e){e.root&&(this.root=e.root)}};function f(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 O(t,e){return t=f(t,e),e[e.length-1]==="/"&&t[0]==="/"&&(t=t.substring(1)),e+t}function j(t,e=!1){return e?new RegExp("^"+t.replace(/:\w+/g,"([^/]+)").replace(/:\*/,"(.*)")+"(\\?|$)"):new RegExp("^"+t.replace(/:\w+/g,"([^/]+)").replace(/:\*/,"(.*)"))}function W(t,e,r=!1){let a=Object.keys(t),n=/:(\w+|\*)/g;for(let c of a){let s=[],l=[];do s=n.exec(c),s&&l.push(s[1]);while(s);e.push({match:j(c,r),params:l,action:t[c]})}return e}var x=class{constructor(e={}){e.app||(e.app={}),e.app.container||(e.app.container=document.body),this.$handlers=e.handlers||G,e.commands&&Object.assign(this,e.commands);let r=a=>{let n=Y(a,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 a.preventDefault(),a.stopPropagation(),!1};e.app.container.addEventListener("click",r),e.app.container.addEventListener("submit",r),e.app.container.addEventListener("change",r),e.app.container.addEventListener("input",r)}};function v(t={}){return new x(t)}function Y(t,e){var r=t.target.closest("[data-simply-command]");if(r){for(let a of e)if(r.matches(a.match))return a.check(r,t)?{name:r.dataset.simplyCommand,source:r,value:a.get(r)}:null}return null}var G=[{match:"input,select,textarea",get:function(t){if(t.tagName==="SELECT"&&t.multiple){let e=[];for(let r of t.options)r.selected&&e.push(r.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 r of Array.from(t.elements)){if(r.tagName=="INPUT"&&(r.type=="checkbox"||r.type=="radio")&&!r.checked)return;e[r.name]&&!Array.isArray(e[r.name])&&(e[r.name]=[e[r.name]]),Array.isArray(e[r.name])?e[r.name].push(r.value):e[r.name]=r.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}}];var p=Object.freeze({Compose:229,Control:17,Meta:224,Alt:18,Shift:16}),T=class{constructor(e={}){e.app||(e.app={}),e.app.container||(e.app.container=document.body),Object.assign(this,e.keys);let r=a=>{if(a.isComposing||a.keyCode===p.Compose||a.defaultPrevented||!a.target)return;let n="default";a.target.closest("[data-simply-keyboard]")&&(n=a.target.closest("[data-simply-keyboard]").dataset.simplyKeyboard);let c=[];a.ctrlKey&&a.keyCode!=p.Control&&c.push("Control"),a.metaKey&&a.keyCode!=p.Meta&&c.push("Meta"),a.altKey&&a.keyCode!=p.Alt&&c.push("Alt"),a.shiftKey&&a.keyCode!=p.Shift&&c.push("Shift"),c.push(a.key.toLowerCase());let s=[],l=event.target.closest("[data-simply-keyboard]");for(;l;)s.push(l.dataset.simplyKeyboard),l=l.parentNode.closest("[data-simply-keyboard]");s.push("");let h,o,U=["+","-"];for(i in s){h=s[i],h==""?o="default":(o=h,h+=".");for(let F of U){let d=c.join(F);if(this[o]&&typeof this[o][d]=="function"&&!this[o][d].call(this[o],a)){a.preventDefault();return}if(typeof this[o+d]=="function"&&!this[o+d].call(this,a)){a.preventDefault();return}if(this[n]&&this[n][d]){let y=e.app.container.querySelectorAll('[data-simply-accesskey="'+h+d+'"]');y.length&&(y.forEach(_=>_.click()),a.preventDefault())}}}};e.app.container.addEventListener("keydown",r)}};function k(t={}){return new T(t)}function w(t){if(t.app){t.app.view=t.view||{};let e=()=>{let r=t.app.view,a=globalThis.editor.data.getDataPath(t.app.container||document.body);t.app.view=globalThis.editor.currentData[a],Object.assign(t.app.view,r)};return globalThis.editor&&globalThis.editor.currentData?e():document.addEventListener("simply-content-loaded",e),t.app.view}else return t.view}var E=class{constructor(e={}){this.container=e.container||document.body;for(let r in e)switch(r){case"commands":this.commands=v({app:this,container:this.container,commands:e.commands});break;case"keys":case"keyboard":this.keys=k({app:this,keys:e.keys});break;case"routes":this.routes=b({app:this,routes:e.routes});break;case"actions":this.actions=g({app:this,actions:e.actions});break;case"view":this.view=w({app:this,view:e.view});break;default:this[r]=e[r];break}}};function q(t={}){return new E(t)}function J(t,e){let r=0;return()=>{let a=arguments;r||(r=globalThis.setTimeout(()=>{t.apply(this,a),r=0},e))}}var Q=globalThis.requestIdleCallback?t=>{globalThis.requestIdleCallback(t,{timeout:500})}:globalThis.requestAnimationFrame;function M(t,e){let r=new URL(t,e);return m.cacheBuster&&r.searchParams.set("cb",m.cacheBuster),r.href}var K,X={},A=globalThis.document.querySelector("head"),P=globalThis.document.currentScript,R,D;P?D=P.src:(R=(()=>{var t=document.getElementsByTagName("script"),e=t.length-1,r=t[e];return()=>r.src})(),D=R());var Z=async()=>new Promise(function(t){var e=globalThis.document.createElement("script");e.src="https://cdn.jsdelivr.net/gh/simplyedit/simplyview/dist/simply.include.next.js",e.async=!1,globalThis.document.addEventListener("simply-include-next",()=>{A.removeChild(e),t()},{once:!0,passive:!0}),A.appendChild(e)}),L=[],m={cacheBuster:null,scripts:(t,e)=>{let r=t.slice(),a=()=>{let n=r.shift();if(!n)return;let c=[].map.call(n.attributes,l=>l.name),s=globalThis.document.createElement("script");for(let l of c)s.setAttribute(l,n.getAttribute(l));if(s.removeAttribute("data-simply-location"),!s.src)s.innerHTML=n.innerHTML,Z().then(()=>{let l=L[n.dataset.simplyLocation];l.parentNode.insertBefore(s,l),l.parentNode.removeChild(l),a()});else{s.src=M(s.src,e),!s.hasAttribute("async")&&!s.hasAttribute("defer")&&(s.async=!1);let l=L[n.dataset.simplyLocation];l.parentNode.insertBefore(s,l),l.parentNode.removeChild(l),X[s.src]=!0,a()}};r.length&&a()},html:(t,e)=>{let r=globalThis.document.createRange().createContextualFragment(t),a=r.querySelectorAll('link[rel="stylesheet"],style');for(let s of a)s.href&&(s.href=M(s.href,e.href)),A.appendChild(s);let n=globalThis.document.createDocumentFragment(),c=r.querySelectorAll("script");if(c.length){for(let s of c){let l=globalThis.document.createComment(s.src||"inline script");s.parentNode.insertBefore(l,s),s.dataset.simplyLocation=L.length,L.push(l),n.appendChild(s)}globalThis.setTimeout(function(){m.scripts(Array.from(n.children),e?e.href:globalThis.location.href)},10)}e.parentNode.insertBefore(r,e||null)}},I={},ee=async t=>{let e=[].reduce.call(t,(r,a)=>(a.rel=="simply-include-once"&&I[a.href]?a.parentNode.removeChild(a):(I[a.href]=!0,a.rel="simply-include-loading",r.push(a)),r),[]);for(let r of e){if(!r.href)return;let a=await fetch(r.href);if(!a.ok){console.log("simply-include: failed to load "+r.href);continue}console.log("simply-include: loaded "+r.href);let n=await a.text();m.html(n,r),r.parentNode.removeChild(r)}},B=J(()=>{Q(()=>{var t=globalThis.document.querySelectorAll('link[rel="simply-include"],link[rel="simply-include-once"]');t.length&&ee(t)})}),te=()=>{K=new MutationObserver(B),K.observe(globalThis.document,{subtree:!0,childList:!0})};te();B();var H={activate:S,action:g,app:q,command:v,include:m,key:k,route:b,view:w};window.simply=H;var Ce=H;})();
1
+ (()=>{var o=new Map,S={addListener:(t,e)=>{o.has(t)||o.set(t,[]),o.get(t).push(e),V(t)},removeListener:(t,e)=>{if(!o.has(t))return!1;o.set(t,o.get(t).filter(r=>r!=e))}};function V(t){let e=document.querySelectorAll('[data-simply-activate="'+t+'"]');if(e)for(let r of e)M(r)}function M(t){let e=t?.dataset?.simplyActivate;if(e&&o.has(e))for(let r of o.get(e))r.call(t)}function z(t){let e=[];for(let a of t)if(a.type=="childList"){for(let n of a.addedNodes)if(n.querySelectorAll){var r=Array.from(n.querySelectorAll("[data-simply-activate]"));n.matches("[data-simply-activate]")&&r.push(n),e=e.concat(r)}}for(let a of e)M(a)}var W=new MutationObserver(z);W.observe(document,{subtree:!0,childList:!0});function g(t,e){if(e){let r=t;t=e,t.app=t}if(t.app){let r={get:(a,n)=>a[n].bind(t.app)};return new Proxy(t.actions,r)}else return t}function b(t,e){if(e){let r=t;t=e,t.app=t}return new L(t)}var L=class{constructor(e={}){this.root=e.root||"/",this.app=e.app||{},this.addMissingSlash=!!e.addMissingSlash,this.matchExact=!!e.matchExact,this.clear(),e.routes&&this.load(e.routes)}load(e){Y(e,this.routeInfo,this.matchExact)}clear(){this.routeInfo=[],this.listeners={match:{},call:{},finish:{}}}match(e,r){let a={path:e,options:r};a=this.runListeners("match",a),e=a.path?a.path:e;let n;if(!e)return this.match(document.location.pathname+document.location.hash)?!0:this.match(document.location.pathname);e=f(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({},"",O(e)))),n&&n.length){var l={};return s.params.forEach((c,u)=>{c=="*"&&(c="remainder"),l[c]=n[u+1]}),Object.assign(l,r),a.route=s,a.params=l,a=this.runListeners("call",a),l=a.params?a.params:l,a.result=s.action.call(this.app,l),this.runListeners("finish",a),a.result}return!1}runListeners(e,r){if(Object.keys(this.listeners[e]))return Object.keys(this.listeners[e]).forEach(a=>{var n=q(a);if(n.exec(r.path)){var l;for(let s of this.listeners[e][a])l=s.call(this.app,r),l&&(r=l)}}),r}handleEvents(){globalThis.addEventListener("popstate",()=>{this.match(f(document.location.pathname+document.location.hash,this.root))===!1&&this.match(f(document.location.pathname,this.root))}),this.app.container.addEventListener("click",e=>{if(!e.ctrlKey&&e.which==1){for(var r=e.target;r&&r.tagName!="A";)r=r.parentElement;if(r&&r.pathname&&r.hostname==globalThis.location.hostname&&!r.link&&!r.dataset.simplyCommand){let a=f(r.pathname+r.hash,this.root);if(this.has(a)||(a=f(r.pathname,this.root)),this.has(a)){let n=this.runListeners("goto",{path:a});if(n.path&&this.goto(n.path))return e.preventDefault(),!1}}}})}goto(e){return history.pushState({},"",O(e)),this.match(e)}has(e){e=f(e,this.root);for(let a of this.routeInfo){var r=a.match.exec(e);if(r&&r.length)return!0}return!1}addListener(e,r,a){if(["goto","match","call","finish"].indexOf(e)==-1)throw new Error("Unknown action "+e);this.listeners[e][r]||(this.listeners[e][r]=[]),this.listeners[e][r].push(a)}removeListener(e,r,a){if(["match","call","finish"].indexOf(e)==-1)throw new Error("Unknown action "+e);this.listeners[e][r]&&(this.listeners[e][r]=this.listeners[e][r].filter(n=>n!=a))}init(e){e.root&&(this.root=e.root)}};function f(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 O(t,e){return t=f(t,e),e[e.length-1]==="/"&&t[0]==="/"&&(t=t.substring(1)),e+t}function q(t,e=!1){return e?new RegExp("^"+t.replace(/:\w+/g,"([^/]+)").replace(/:\*/,"(.*)")+"(\\?|$)"):new RegExp("^"+t.replace(/:\w+/g,"([^/]+)").replace(/:\*/,"(.*)"))}function Y(t,e,r=!1){let a=Object.keys(t),n=/:(\w+|\*)/g;for(let l of a){let s=[],c=[];do s=n.exec(l),s&&c.push(s[1]);while(s);e.push({match:q(l,r),params:c,action:t[l]})}return e}var T=class{constructor(e={}){e.app||(e.app={}),e.app.container||(e.app.container=document.body),this.app=e.app,this.$handlers=e.handlers||J,e.commands&&Object.assign(this,e.commands);let r=a=>{let n=G(a,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 a.preventDefault(),a.stopPropagation(),!1};e.app.container.addEventListener("click",r),e.app.container.addEventListener("submit",r),e.app.container.addEventListener("change",r),e.app.container.addEventListener("input",r)}call(e,r,a){if(!this[e]){console.error("simply.command: undefined command "+e);return}return this[e].call(this.app,r,a)}action(e){console.warn("deprecated call to `this.commands.action`");let r=Array.from(arguments).slice();return r.shift(),this.app.actions[e](...r)}appendHandler(e){this.$handlers.push(e)}prependHandler(e){this.$handlers.unshift(e)}};function v(t={},e){if(e){let r=t;t=e,t.app=t}return new T(t)}function G(t,e){var r=t.target.closest("[data-simply-command]");if(r){for(let a of e)if(r.matches(a.match))return a.check(r,t)?{name:r.dataset.simplyCommand,source:r,value:a.get(r)}:null}return null}var J=[{match:"input,select,textarea",get:function(t){if(t.tagName==="SELECT"&&t.multiple){let e=[];for(let r of t.options)r.selected&&e.push(r.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 r of Array.from(t.elements)){if(r.tagName=="INPUT"&&(r.type=="checkbox"||r.type=="radio")&&!r.checked)return;e[r.name]&&!Array.isArray(e[r.name])&&(e[r.name]=[e[r.name]]),Array.isArray(e[r.name])?e[r.name].push(r.value):e[r.name]=r.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}}];var p=Object.freeze({Compose:229,Control:17,Meta:224,Alt:18,Shift:16}),x=class{constructor(e={}){e.app||(e.app={}),e.app.container||(e.app.container=document.body),Object.assign(this,e.keys);let r=a=>{if(a.isComposing||a.keyCode===p.Compose||a.defaultPrevented||!a.target)return;let n="default";a.target.closest("[data-simply-keyboard]")&&(n=a.target.closest("[data-simply-keyboard]").dataset.simplyKeyboard);let l=[];a.ctrlKey&&a.keyCode!=p.Control&&l.push("Control"),a.metaKey&&a.keyCode!=p.Meta&&l.push("Meta"),a.altKey&&a.keyCode!=p.Alt&&l.push("Alt"),a.shiftKey&&a.keyCode!=p.Shift&&l.push("Shift"),l.push(a.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 u,h,F=["+","-"];for(i in s){u=s[i],u==""?h="default":(h=u,u+=".");for(let _ of F){let d=l.join(_);if(this[h]&&typeof this[h][d]=="function"&&!this[h][d].call(e.app,a)){a.preventDefault();return}if(typeof this[h+d]=="function"&&!this[h+d].call(e.app,a)){a.preventDefault();return}if(this[n]&&this[n][d]){let y=e.app.container.querySelectorAll('[data-simply-accesskey="'+u+d+'"]');y.length&&(y.forEach($=>$.click()),a.preventDefault())}}}};e.app.container.addEventListener("keydown",r)}};function k(t={},e){if(e){let r=t;t=e,t.app=t}return new x(t)}function w(t,e){if(e){let r=t;t=e,t.app=t}if(t.app){t.app.view=t.view||{};let r=()=>{let a=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,a)};return globalThis.editor&&globalThis.editor.currentData?r():document.addEventListener("simply-content-loaded",r),t.app.view}else return t.view}var A=class{constructor(e={}){this.container=e.container||document.body;for(let r in e)switch(r){case"commands":this.commands=v({app:this,container:this.container,commands:e.commands});break;case"keys":case"keyboard":this.keys=k({app:this,keys:e.keys});break;case"routes":this.routes=b({app:this,routes:e.routes}),this.routes.handleEvents(),globalThis.setTimeout(()=>{this.routes.match(globalThis.location?.pathname+globalThis.location?.hash)});break;case"actions":this.actions=g({app:this,actions:e.actions}),this.action=function(a){console.warn("deprecated call to `this.action`");let n=Array.from(arguments).slice();return n.shift(),this.actions[a](...n)};break;case"view":this.view=w({app:this,view:e.view});break;default:this[r]=e[r];break}}get app(){return this}};function j(t={}){return new A(t)}function Q(t,e){let r=0;return()=>{let a=arguments;r||(r=globalThis.setTimeout(()=>{t.apply(this,a),r=0},e))}}var X=globalThis.requestIdleCallback?t=>{globalThis.requestIdleCallback(t,{timeout:500})}:globalThis.requestAnimationFrame;function I(t,e){let r=new URL(t,e);return m.cacheBuster&&r.searchParams.set("cb",m.cacheBuster),r.href}var B,Z={},C=globalThis.document.querySelector("head"),D=globalThis.document.currentScript,H,K;D?K=D.src:(H=(()=>{var t=document.getElementsByTagName("script"),e=t.length-1,r=t[e];return()=>r.src})(),K=H());var ee=async()=>new Promise(function(t){var e=globalThis.document.createElement("script");e.src="https://cdn.jsdelivr.net/gh/simplyedit/simplyview/dist/simply.include.next.js",e.async=!1,globalThis.document.addEventListener("simply-include-next",()=>{C.removeChild(e),t()},{once:!0,passive:!0}),C.appendChild(e)}),E=[],m={cacheBuster:null,scripts:(t,e)=>{let r=t.slice(),a=()=>{let n=r.shift();if(!n)return;let l=[].map.call(n.attributes,c=>c.name),s=globalThis.document.createElement("script");for(let c of l)s.setAttribute(c,n.getAttribute(c));if(s.removeAttribute("data-simply-location"),!s.src)s.innerHTML=n.innerHTML,ee().then(()=>{let c=E[n.dataset.simplyLocation];c.parentNode.insertBefore(s,c),c.parentNode.removeChild(c),a()});else{s.src=I(s.src,e),!s.hasAttribute("async")&&!s.hasAttribute("defer")&&(s.async=!1);let c=E[n.dataset.simplyLocation];c.parentNode.insertBefore(s,c),c.parentNode.removeChild(c),Z[s.src]=!0,a()}};r.length&&a()},html:(t,e)=>{let r=globalThis.document.createRange().createContextualFragment(t),a=r.querySelectorAll('link[rel="stylesheet"],style');for(let s of a)s.href&&(s.href=I(s.href,e.href)),C.appendChild(s);let n=globalThis.document.createDocumentFragment(),l=r.querySelectorAll("script");if(l.length){for(let s of l){let c=globalThis.document.createComment(s.src||"inline script");s.parentNode.insertBefore(c,s),s.dataset.simplyLocation=E.length,E.push(c),n.appendChild(s)}globalThis.setTimeout(function(){m.scripts(Array.from(n.children),e?e.href:globalThis.location.href)},10)}e.parentNode.insertBefore(r,e||null)}},P={},te=async t=>{let e=[].reduce.call(t,(r,a)=>(a.rel=="simply-include-once"&&P[a.href]?a.parentNode.removeChild(a):(P[a.href]=!0,a.rel="simply-include-loading",r.push(a)),r),[]);for(let r of e){if(!r.href)return;let a=await fetch(r.href);if(!a.ok){console.log("simply-include: failed to load "+r.href);continue}console.log("simply-include: loaded "+r.href);let n=await a.text();m.html(n,r),r.parentNode.removeChild(r)}},R=Q(()=>{X(()=>{var t=globalThis.document.querySelectorAll('link[rel="simply-include"],link[rel="simply-include-once"]');t.length&&te(t)})}),re=()=>{B=new MutationObserver(R),B.observe(globalThis.document,{subtree:!0,childList:!0})};re();R();var N=class extends HTMLElement{constructor(){super();let e=this.getAttribute("rel"),r=document.getElementById(e);if(r){let a=r.content.cloneNode(!0);for(let n of a.childNodes){let l=n.cloneNode(!0);l.nodeType==document.ELEMENT_NODE&&l.querySelectorAll("template").forEach(function(s){s.setAttribute("simply-render","")}),this.parentNode.insertBefore(l,this)}this.parentNode.removeChild(this)}}};customElements.get("simply-render")||customElements.define("simply-render",N);var U={activate:S,action:g,app:j,command:v,include:m,key:k,route:b,view:w};window.simply=U;var Ce=U;})();
2
2
  //# sourceMappingURL=simply.everything.min.js.map