all repos — h3 @ 5fb2bc21efa8ab98aa835431057b7c79d73fc798

A tiny, extremely minimalist JavaScript microframework.

Updated all files.
h3rald h3rald@h3rald.com
Sat, 17 Oct 2020 21:47:31 +0200
commit

5fb2bc21efa8ab98aa835431057b7c79d73fc798

parent

c30f1f4b5de124b7a36c573e7b9ddd4ef8ddb404

5 files changed, 197 insertions(+), 335 deletions(-)

jump to
M docs/H3_DeveloperGuide.htmdocs/H3_DeveloperGuide.htm

@@ -8125,7 +8125,7 @@ </ul>

</div> <div id="footer"> - <p><span class="copy"></span> Fabio Cevasco &ndash; August 2, 2020</p> + <p><span class="copy"></span> Fabio Cevasco &ndash; October 17, 2020</p> <p><span>Powered by</span> <a href="https://h3rald.com/hastyscribe"><span class="hastyscribe"></span></a></p> </div> </div>
M docs/example/assets/js/h3.jsdocs/example/assets/js/h3.js

@@ -6,6 +6,9 @@ * @license MIT

* For the full license, see: https://github.com/h3rald/h3/blob/master/LICENSE */ const checkProperties = (obj1, obj2) => { + if (Object.keys(obj1).length !== Object.keys(obj2).length) { + return false; + } for (const key in obj1) { if (!(key in obj2)) { return false;

@@ -18,24 +21,16 @@ return true;

}; const equal = (obj1, obj2) => { - if ( - (obj1 === null && obj2 === null) || - (obj1 === undefined && obj2 === undefined) - ) { + if ((obj1 === null && obj2 === null) || (obj1 === undefined && obj2 === undefined)) { return true; } - if ( - (obj1 === undefined && obj2 !== undefined) || - (obj1 !== undefined && obj2 === undefined) || - (obj1 === null && obj2 !== null) || - (obj1 !== null && obj2 === null) - ) { + if ((obj1 === undefined && obj2 !== undefined) || (obj1 !== undefined && obj2 === undefined) || (obj1 === null && obj2 !== null) || (obj1 !== null && obj2 === null)) { return false; } if (obj1.constructor !== obj2.constructor) { return false; } - if (typeof obj1 === "function") { + if (typeof obj1 === 'function') { if (obj1.toString() !== obj2.toString()) { return false; }

@@ -54,7 +49,7 @@ }

} return true; } - return checkProperties(obj1, obj2); + return checkProperties(obj1, obj2); }; const selectorRegex = /^([a-z][a-z0-9:_=-]*)?(#[a-z0-9:_=-]+)?(\.[^ ]+)*$/i;

@@ -76,49 +71,37 @@ this.children = [];

this.classList = []; this.eventListeners = {}; if (args.length === 0) { - throw new Error("[VNode] No arguments passed to VNode constructor."); + throw new Error('[VNode] No arguments passed to VNode constructor.'); } if (args.length === 1) { let vnode = args[0]; - if (typeof vnode === "string") { + if (typeof vnode === 'string') { // Assume empty element this.processSelector(vnode); - } else if ( - typeof vnode === "function" || - (typeof vnode === "object" && vnode !== null) - ) { + } else if (typeof vnode === 'function' || (typeof vnode === 'object' && vnode !== null)) { // Text node - if (vnode.type === "#text") { - this.type = "#text"; + if (vnode.type === '#text') { + this.type = '#text'; this.value = vnode.value; } else { this.from(this.processVNodeObject(vnode)); } } else { - throw new Error( - "[VNode] Invalid first argument passed to VNode constructor." - ); + throw new Error('[VNode] Invalid first argument passed to VNode constructor.'); } } else if (args.length === 2) { let [selector, data] = args; - if (typeof selector !== "string") { - throw new Error( - "[VNode] Invalid first argument passed to VNode constructor." - ); + if (typeof selector !== 'string') { + throw new Error('[VNode] Invalid first argument passed to VNode constructor.'); } this.processSelector(selector); - if (typeof data === "string") { + if (typeof data === 'string') { // Assume single child text node - this.children = [new VNode({ type: "#text", value: data })]; + this.children = [new VNode({ type: '#text', value: data })]; return; } - if ( - typeof data !== "function" && - (typeof data !== "object" || data === null) - ) { - throw new Error( - "[VNode] The second argument of a VNode constructor must be an object, an array or a string." - ); + if (typeof data !== 'function' && (typeof data !== 'object' || data === null)) { + throw new Error('[VNode] The second argument of a VNode constructor must be an object, an array or a string.'); } if (Array.isArray(data)) { // Assume 2nd argument as children

@@ -137,24 +120,16 @@ if (args.length > 3) {

children = args.slice(2); } children = Array.isArray(children) ? children : [children]; - if (typeof selector !== "string") { - throw new Error( - "[VNode] Invalid first argument passed to VNode constructor." - ); + if (typeof selector !== 'string') { + throw new Error('[VNode] Invalid first argument passed to VNode constructor.'); } this.processSelector(selector); - if ( - props instanceof Function || - props instanceof VNode || - typeof props === "string" - ) { + if (props instanceof Function || props instanceof VNode || typeof props === 'string') { // 2nd argument is a child children = [props].concat(children); } else { - if (typeof props !== "object" || props === null) { - throw new Error( - "[VNode] Invalid second argument passed to VNode constructor." - ); + if (typeof props !== 'object' || props === null) { + throw new Error('[VNode] Invalid second argument passed to VNode constructor.'); } this.processProperties(props); }

@@ -188,18 +163,13 @@ this.$onrender = attrs.$onrender;

this.style = attrs.style; this.value = attrs.value; this.data = attrs.data || {}; - this.classList = - attrs.classList && attrs.classList.length > 0 - ? attrs.classList - : this.classList; + this.classList = attrs.classList && attrs.classList.length > 0 ? attrs.classList : this.classList; this.props = attrs; Object.keys(attrs) - .filter((a) => a.startsWith("on") && attrs[a]) + .filter((a) => a.startsWith('on') && attrs[a]) .forEach((key) => { - if (typeof attrs[key] !== "function") { - throw new Error( - `[VNode] Event handler specified for ${key} event is not a function.` - ); + if (typeof attrs[key] !== 'function') { + throw new Error(`[VNode] Event handler specified for ${key} event is not a function.`); } this.eventListeners[key.slice(2)] = attrs[key]; delete this.props[key];

@@ -222,7 +192,7 @@ this.type = type;

if (id) { this.id = id.slice(1); } - this.classList = (classes && classes.split(".").slice(1)) || []; + this.classList = (classes && classes.split('.').slice(1)) || []; } processVNodeObject(arg) {

@@ -231,27 +201,25 @@ return arg;

} if (arg instanceof Function) { let vnode = arg(); - if (typeof vnode === "string") { - vnode = new VNode({ type: "#text", value: vnode }); + if (typeof vnode === 'string') { + vnode = new VNode({ type: '#text', value: vnode }); } if (!(vnode instanceof VNode)) { - throw new Error("[VNode] Function argument does not return a VNode"); + throw new Error('[VNode] Function argument does not return a VNode'); } return vnode; } - throw new Error( - "[VNode] Invalid first argument provided to VNode constructor." - ); + throw new Error('[VNode] Invalid first argument provided to VNode constructor.'); } processChildren(arg) { const children = Array.isArray(arg) ? arg : [arg]; this.children = children .map((c) => { - if (typeof c === "string") { - return new VNode({ type: "#text", value: c }); + if (typeof c === 'string') { + return new VNode({ type: '#text', value: c }); } - if (typeof c === "function" || (typeof c === "object" && c !== null)) { + if (typeof c === 'function' || (typeof c === 'object' && c !== null)) { return this.processVNodeObject(c); } if (c) {

@@ -263,7 +231,7 @@ }

// Renders the actual DOM Node corresponding to the current Virtual Node render() { - if (this.type === "#text") { + if (this.type === '#text') { return document.createTextNode(this.value); } const node = document.createElement(this.type);

@@ -272,10 +240,10 @@ node.id = this.id;

} Object.keys(this.props).forEach((p) => { // Set attributes - if (typeof this.props[p] === "boolean") { - this.props[p] ? node.setAttribute(p, "") : node.removeAttribute(p); + if (typeof this.props[p] === 'boolean') { + this.props[p] ? node.setAttribute(p, '') : node.removeAttribute(p); } - if (["string", "number"].includes(typeof this.props[p])) { + if (['string', 'number'].includes(typeof this.props[p])) { node.setAttribute(p, this.props[p]); } // Set properties

@@ -287,10 +255,10 @@ node.addEventListener(event, this.eventListeners[event]);

}); // Value if (this.value) { - if (["textarea", "input"].includes(this.type)) { + if (['textarea', 'input'].includes(this.type)) { node.value = this.value; } else { - node.setAttribute("value", this.value); + node.setAttribute('value', this.value); } } // Style

@@ -325,9 +293,7 @@ const oldvnode = this;

if ( oldvnode.constructor !== newvnode.constructor || oldvnode.type !== newvnode.type || - (oldvnode.type === newvnode.type && - oldvnode.type === "#text" && - oldvnode !== newvnode) + (oldvnode.type === newvnode.type && oldvnode.type === '#text' && oldvnode !== newvnode) ) { const renderedNode = newvnode.render(); node.parentNode.replaceChild(renderedNode, node);

@@ -337,16 +303,16 @@ return;

} // ID if (oldvnode.id !== newvnode.id) { - node.id = newvnode.id || ""; + node.id = newvnode.id || ''; oldvnode.id = newvnode.id; } // Value if (oldvnode.value !== newvnode.value) { oldvnode.value = newvnode.value; - if (["textarea", "input"].includes(oldvnode.type)) { - node.value = newvnode.value || ""; + if (['textarea', 'input'].includes(oldvnode.type)) { + node.value = newvnode.value || ''; } else { - node.setAttribute("value", newvnode.value || ""); + node.setAttribute('value', newvnode.value || ''); } } // Classes

@@ -365,7 +331,7 @@ oldvnode.classList = newvnode.classList;

} // Style if (oldvnode.style !== newvnode.style) { - node.style.cssText = newvnode.style || ""; + node.style.cssText = newvnode.style || ''; oldvnode.style = newvnode.style; } // Data

@@ -388,20 +354,15 @@ // Properties & Attributes

if (!equal(oldvnode.props, newvnode.props)) { Object.keys(oldvnode.props).forEach((a) => { node[a] = newvnode.props[a]; - if (typeof newvnode.props[a] === "boolean") { + if (typeof newvnode.props[a] === 'boolean') { oldvnode.props[a] = newvnode.props[a]; - newvnode.props[a] - ? node.setAttribute(a, "") - : node.removeAttribute(a); - } else if (!newvnode.props[a]) { + newvnode.props[a] ? node.setAttribute(a, '') : node.removeAttribute(a); + } else if ([null, undefined].includes(newvnode.props[a])) { delete oldvnode.props[a]; node.removeAttribute(a); - } else if ( - newvnode.props[a] && - newvnode.props[a] !== oldvnode.props[a] - ) { + } else if (newvnode.props[a] !== oldvnode.props[a]) { oldvnode.props[a] = newvnode.props[a]; - if (["string", "number"].includes(typeof newvnode.props[a])) { + if (['string', 'number'].includes(typeof newvnode.props[a])) { node.setAttribute(a, newvnode.props[a]); } }

@@ -409,7 +370,9 @@ });

Object.keys(newvnode.props).forEach((a) => { if (!oldvnode.props[a] && newvnode.props[a]) { oldvnode.props[a] = newvnode.props[a]; - node.setAttribute(a, newvnode.props[a]); + if (['string', 'number'].includes(typeof newvnode.props[a])) { + node.setAttribute(a, newvnode.props[a]); + } } }); }

@@ -418,9 +381,7 @@ if (!equal(oldvnode.eventListeners, newvnode.eventListeners)) {

Object.keys(oldvnode.eventListeners).forEach((a) => { if (!newvnode.eventListeners[a]) { node.removeEventListener(a, oldvnode.eventListeners[a]); - } else if ( - !equal(newvnode.eventListeners[a], oldvnode.eventListeners[a]) - ) { + } else if (!equal(newvnode.eventListeners[a], oldvnode.eventListeners[a])) { node.removeEventListener(a, oldvnode.eventListeners[a]); node.addEventListener(a, newvnode.eventListeners[a]); }

@@ -455,8 +416,7 @@ case INSERT: {

oldvnode.children.splice(count, 0, newvnode.children[count]); const renderedNode = newvnode.children[count].render(); node.insertBefore(renderedNode, node.childNodes[count]); - newvnode.children[count].$onrender && - newvnode.children[count].$onrender(renderedNode); + newvnode.children[count].$onrender && newvnode.children[count].$onrender(renderedNode); break checkmap; } case DELETE: {

@@ -501,11 +461,7 @@ op = oIdx; // Same node found

break; } } - if ( - op < 0 && - newList.length >= oldList.length && - map.length >= oldList.length - ) { + if (op < 0 && newList.length >= oldList.length && map.length >= oldList.length) { op = INSERT; } map.push(op);

@@ -513,9 +469,7 @@ }

const oldNodesFound = map.filter((c) => c >= 0); if (oldList.length > newList.length) { // Remove remaining nodes - [...Array(oldList.length - newList.length).keys()].forEach(() => - map.push(DELETE) - ); + [...Array(oldList.length - newList.length).keys()].forEach(() => map.push(DELETE)); } else if (oldNodesFound.length === oldList.length) { // All nodes not found are insertions map = map.map((c) => (c < 0 ? INSERT : c));

@@ -535,7 +489,7 @@ this.events = {};

this.state = {}; } dispatch(event, data) { - if (event !== "$log") this.dispatch("$log", { event, data }); + if (event !== '$log') this.dispatch('$log', { event, data }); if (this.events[event]) { let changes = {}; let changed;

@@ -562,9 +516,9 @@ this.query = query;

this.parts = parts; this.params = {}; if (this.query) { - const rawParams = this.query.split("&"); + const rawParams = this.query.split('&'); rawParams.forEach((p) => { - const [name, value] = p.split("="); + const [name, value] = p.split('='); this.params[decodeURIComponent(name)] = decodeURIComponent(value); }); }

@@ -578,7 +532,7 @@ this.redraw = null;

this.store = store; this.location = location || window.location; if (!routes || Object.keys(routes).length === 0) { - throw new Error("[Router] No routes defined."); + throw new Error('[Router] No routes defined.'); } const defs = Object.keys(routes); this.routes = routes;

@@ -590,34 +544,29 @@ vnode.redraw({

node: this.element.childNodes[0], vnode: this.routes[this.route.def](state), }); - this.store.dispatch("$redraw"); + this.store.dispatch('$redraw'); }; } async start() { const processPath = async (data) => { const oldRoute = this.route; - const fragment = - (data && - data.newURL && - data.newURL.match(/(#.+)$/) && - data.newURL.match(/(#.+)$/)[1]) || - this.location.hash; - const path = fragment.replace(/\?.+$/, "").slice(1); + const fragment = (data && data.newURL && data.newURL.match(/(#.+)$/) && data.newURL.match(/(#.+)$/)[1]) || this.location.hash; + const path = fragment.replace(/\?.+$/, '').slice(1); const rawQuery = fragment.match(/\?(.+)$/); - const query = rawQuery && rawQuery[1] ? rawQuery[1] : ""; - const pathParts = path.split("/").slice(1); + const query = rawQuery && rawQuery[1] ? rawQuery[1] : ''; + const pathParts = path.split('/').slice(1); let parts = {}; for (let def of Object.keys(this.routes)) { - let routeParts = def.split("/").slice(1); + let routeParts = def.split('/').slice(1); let match = true; let index = 0; parts = {}; while (match && routeParts[index]) { const rP = routeParts[index]; const pP = pathParts[index]; - if (rP.startsWith(":") && pP) { + if (rP.startsWith(':') && pP) { parts[rP.slice(1)] = pP; } else { match = rP === pP;

@@ -636,19 +585,15 @@ // Old route component teardown

let state = {}; if (oldRoute) { const oldRouteComponent = this.routes[oldRoute.def]; - state = - (oldRouteComponent.teardown && - (await oldRouteComponent.teardown(oldRouteComponent.state))) || - state; + state = (oldRouteComponent.teardown && (await oldRouteComponent.teardown(oldRouteComponent.state))) || state; } // New route component setup const newRouteComponent = this.routes[this.route.def]; newRouteComponent.state = state; - newRouteComponent.setup && - (await newRouteComponent.setup(newRouteComponent.state)); + newRouteComponent.setup && (await newRouteComponent.setup(newRouteComponent.state)); // Redrawing... redrawing = true; - this.store.dispatch("$navigation", this.route); + this.store.dispatch('$navigation', this.route); while (this.element.firstChild) { this.element.removeChild(this.element.firstChild); }

@@ -661,17 +606,17 @@ vnode.$onrender && vnode.$onrender(node);

$onrenderCallbacks.forEach((cbk) => cbk()); $onrenderCallbacks = []; window.scrollTo(0, 0); - this.store.dispatch("$redraw"); + this.store.dispatch('$redraw'); }; - window.addEventListener("hashchange", processPath); + window.addEventListener('hashchange', processPath); await processPath(); } navigateTo(path, params) { let query = Object.keys(params || {}) .map((p) => `${encodeURIComponent(p)}=${encodeURIComponent(params[p])}`) - .join("&"); - query = query ? `?${query}` : ""; + .join('&'); + query = query ? `?${query}` : ''; this.location.hash = `#${path}${query}`; } }

@@ -692,23 +637,21 @@ h3.init = (config) => {

let { element, routes, modules, preStart, postStart, location } = config; if (!routes) { // Assume config is a component object, define default route - if (typeof config !== "function") { - throw new Error( - "[h3.init] The specified argument is not a valid configuration object or component function" - ); + if (typeof config !== 'function') { + throw new Error('[h3.init] The specified argument is not a valid configuration object or component function'); } - routes = { "/": config }; + routes = { '/': config }; } element = element || document.body; if (!(element && element instanceof Element)) { - throw new Error("[h3.init] Invalid element specified."); + throw new Error('[h3.init] Invalid element specified.'); } // Initialize store store = new Store(); (modules || []).forEach((i) => { i(store); }); - store.dispatch("$init"); + store.dispatch('$init'); // Initialize router router = new Router({ element, routes, store, location }); return Promise.resolve(preStart && preStart())

@@ -718,30 +661,24 @@ };

h3.navigateTo = (path, params) => { if (!router) { - throw new Error( - "[h3.navigateTo] No application initialized, unable to navigate." - ); + throw new Error('[h3.navigateTo] No application initialized, unable to navigate.'); } return router.navigateTo(path, params); }; -Object.defineProperty(h3, "route", { +Object.defineProperty(h3, 'route', { get: () => { if (!router) { - throw new Error( - "[h3.route] No application initialized, unable to retrieve current route." - ); + throw new Error('[h3.route] No application initialized, unable to retrieve current route.'); } return router.route; }, }); -Object.defineProperty(h3, "state", { +Object.defineProperty(h3, 'state', { get: () => { if (!store) { - throw new Error( - "[h3.state] No application initialized, unable to retrieve current state." - ); + throw new Error('[h3.state] No application initialized, unable to retrieve current state.'); } return store.state; },

@@ -749,27 +686,21 @@ });

h3.on = (event, cb) => { if (!store) { - throw new Error( - "[h3.on] No application initialized, unable to listen to events." - ); + throw new Error('[h3.on] No application initialized, unable to listen to events.'); } return store.on(event, cb); }; h3.dispatch = (event, data) => { if (!store) { - throw new Error( - "[h3.dispatch] No application initialized, unable to dispatch events." - ); + throw new Error('[h3.dispatch] No application initialized, unable to dispatch events.'); } return store.dispatch(event, data); }; h3.redraw = (setRedrawing) => { if (!router || !router.redraw) { - throw new Error( - "[h3.redraw] No application initialized, unable to redraw." - ); + throw new Error('[h3.redraw] No application initialized, unable to redraw.'); } if (redrawing) { return;

@@ -780,14 +711,14 @@ redrawing = setRedrawing || false;

}; h3.screen = ({ setup, display, teardown }) => { - if (!display || typeof display !== "function") { - throw new Error("[h3.screen] No display property specified."); + if (!display || typeof display !== 'function') { + throw new Error('[h3.screen] No display property specified.'); } - if (setup && typeof setup !== "function") { - throw new Error("[h3.screen] setup property is not a function."); + if (setup && typeof setup !== 'function') { + throw new Error('[h3.screen] setup property is not a function.'); } - if (teardown && typeof teardown !== "function") { - throw new Error("[h3.screen] teardown property is not a function."); + if (teardown && typeof teardown !== 'function') { + throw new Error('[h3.screen] teardown property is not a function.'); } const fn = display; if (setup) {
M docs/js/h3.jsdocs/js/h3.js

@@ -6,6 +6,9 @@ * @license MIT

* For the full license, see: https://github.com/h3rald/h3/blob/master/LICENSE */ const checkProperties = (obj1, obj2) => { + if (Object.keys(obj1).length !== Object.keys(obj2).length) { + return false; + } for (const key in obj1) { if (!(key in obj2)) { return false;

@@ -18,24 +21,16 @@ return true;

}; const equal = (obj1, obj2) => { - if ( - (obj1 === null && obj2 === null) || - (obj1 === undefined && obj2 === undefined) - ) { + if ((obj1 === null && obj2 === null) || (obj1 === undefined && obj2 === undefined)) { return true; } - if ( - (obj1 === undefined && obj2 !== undefined) || - (obj1 !== undefined && obj2 === undefined) || - (obj1 === null && obj2 !== null) || - (obj1 !== null && obj2 === null) - ) { + if ((obj1 === undefined && obj2 !== undefined) || (obj1 !== undefined && obj2 === undefined) || (obj1 === null && obj2 !== null) || (obj1 !== null && obj2 === null)) { return false; } if (obj1.constructor !== obj2.constructor) { return false; } - if (typeof obj1 === "function") { + if (typeof obj1 === 'function') { if (obj1.toString() !== obj2.toString()) { return false; }

@@ -54,7 +49,7 @@ }

} return true; } - return checkProperties(obj1, obj2); + return checkProperties(obj1, obj2); }; const selectorRegex = /^([a-z][a-z0-9:_=-]*)?(#[a-z0-9:_=-]+)?(\.[^ ]+)*$/i;

@@ -76,49 +71,37 @@ this.children = [];

this.classList = []; this.eventListeners = {}; if (args.length === 0) { - throw new Error("[VNode] No arguments passed to VNode constructor."); + throw new Error('[VNode] No arguments passed to VNode constructor.'); } if (args.length === 1) { let vnode = args[0]; - if (typeof vnode === "string") { + if (typeof vnode === 'string') { // Assume empty element this.processSelector(vnode); - } else if ( - typeof vnode === "function" || - (typeof vnode === "object" && vnode !== null) - ) { + } else if (typeof vnode === 'function' || (typeof vnode === 'object' && vnode !== null)) { // Text node - if (vnode.type === "#text") { - this.type = "#text"; + if (vnode.type === '#text') { + this.type = '#text'; this.value = vnode.value; } else { this.from(this.processVNodeObject(vnode)); } } else { - throw new Error( - "[VNode] Invalid first argument passed to VNode constructor." - ); + throw new Error('[VNode] Invalid first argument passed to VNode constructor.'); } } else if (args.length === 2) { let [selector, data] = args; - if (typeof selector !== "string") { - throw new Error( - "[VNode] Invalid first argument passed to VNode constructor." - ); + if (typeof selector !== 'string') { + throw new Error('[VNode] Invalid first argument passed to VNode constructor.'); } this.processSelector(selector); - if (typeof data === "string") { + if (typeof data === 'string') { // Assume single child text node - this.children = [new VNode({ type: "#text", value: data })]; + this.children = [new VNode({ type: '#text', value: data })]; return; } - if ( - typeof data !== "function" && - (typeof data !== "object" || data === null) - ) { - throw new Error( - "[VNode] The second argument of a VNode constructor must be an object, an array or a string." - ); + if (typeof data !== 'function' && (typeof data !== 'object' || data === null)) { + throw new Error('[VNode] The second argument of a VNode constructor must be an object, an array or a string.'); } if (Array.isArray(data)) { // Assume 2nd argument as children

@@ -137,24 +120,16 @@ if (args.length > 3) {

children = args.slice(2); } children = Array.isArray(children) ? children : [children]; - if (typeof selector !== "string") { - throw new Error( - "[VNode] Invalid first argument passed to VNode constructor." - ); + if (typeof selector !== 'string') { + throw new Error('[VNode] Invalid first argument passed to VNode constructor.'); } this.processSelector(selector); - if ( - props instanceof Function || - props instanceof VNode || - typeof props === "string" - ) { + if (props instanceof Function || props instanceof VNode || typeof props === 'string') { // 2nd argument is a child children = [props].concat(children); } else { - if (typeof props !== "object" || props === null) { - throw new Error( - "[VNode] Invalid second argument passed to VNode constructor." - ); + if (typeof props !== 'object' || props === null) { + throw new Error('[VNode] Invalid second argument passed to VNode constructor.'); } this.processProperties(props); }

@@ -188,18 +163,13 @@ this.$onrender = attrs.$onrender;

this.style = attrs.style; this.value = attrs.value; this.data = attrs.data || {}; - this.classList = - attrs.classList && attrs.classList.length > 0 - ? attrs.classList - : this.classList; + this.classList = attrs.classList && attrs.classList.length > 0 ? attrs.classList : this.classList; this.props = attrs; Object.keys(attrs) - .filter((a) => a.startsWith("on") && attrs[a]) + .filter((a) => a.startsWith('on') && attrs[a]) .forEach((key) => { - if (typeof attrs[key] !== "function") { - throw new Error( - `[VNode] Event handler specified for ${key} event is not a function.` - ); + if (typeof attrs[key] !== 'function') { + throw new Error(`[VNode] Event handler specified for ${key} event is not a function.`); } this.eventListeners[key.slice(2)] = attrs[key]; delete this.props[key];

@@ -222,7 +192,7 @@ this.type = type;

if (id) { this.id = id.slice(1); } - this.classList = (classes && classes.split(".").slice(1)) || []; + this.classList = (classes && classes.split('.').slice(1)) || []; } processVNodeObject(arg) {

@@ -231,27 +201,25 @@ return arg;

} if (arg instanceof Function) { let vnode = arg(); - if (typeof vnode === "string") { - vnode = new VNode({ type: "#text", value: vnode }); + if (typeof vnode === 'string') { + vnode = new VNode({ type: '#text', value: vnode }); } if (!(vnode instanceof VNode)) { - throw new Error("[VNode] Function argument does not return a VNode"); + throw new Error('[VNode] Function argument does not return a VNode'); } return vnode; } - throw new Error( - "[VNode] Invalid first argument provided to VNode constructor." - ); + throw new Error('[VNode] Invalid first argument provided to VNode constructor.'); } processChildren(arg) { const children = Array.isArray(arg) ? arg : [arg]; this.children = children .map((c) => { - if (typeof c === "string") { - return new VNode({ type: "#text", value: c }); + if (typeof c === 'string') { + return new VNode({ type: '#text', value: c }); } - if (typeof c === "function" || (typeof c === "object" && c !== null)) { + if (typeof c === 'function' || (typeof c === 'object' && c !== null)) { return this.processVNodeObject(c); } if (c) {

@@ -263,7 +231,7 @@ }

// Renders the actual DOM Node corresponding to the current Virtual Node render() { - if (this.type === "#text") { + if (this.type === '#text') { return document.createTextNode(this.value); } const node = document.createElement(this.type);

@@ -272,10 +240,10 @@ node.id = this.id;

} Object.keys(this.props).forEach((p) => { // Set attributes - if (typeof this.props[p] === "boolean") { - this.props[p] ? node.setAttribute(p, "") : node.removeAttribute(p); + if (typeof this.props[p] === 'boolean') { + this.props[p] ? node.setAttribute(p, '') : node.removeAttribute(p); } - if (["string", "number"].includes(typeof this.props[p])) { + if (['string', 'number'].includes(typeof this.props[p])) { node.setAttribute(p, this.props[p]); } // Set properties

@@ -287,10 +255,10 @@ node.addEventListener(event, this.eventListeners[event]);

}); // Value if (this.value) { - if (["textarea", "input"].includes(this.type)) { + if (['textarea', 'input'].includes(this.type)) { node.value = this.value; } else { - node.setAttribute("value", this.value); + node.setAttribute('value', this.value); } } // Style

@@ -325,9 +293,7 @@ const oldvnode = this;

if ( oldvnode.constructor !== newvnode.constructor || oldvnode.type !== newvnode.type || - (oldvnode.type === newvnode.type && - oldvnode.type === "#text" && - oldvnode !== newvnode) + (oldvnode.type === newvnode.type && oldvnode.type === '#text' && oldvnode !== newvnode) ) { const renderedNode = newvnode.render(); node.parentNode.replaceChild(renderedNode, node);

@@ -337,16 +303,16 @@ return;

} // ID if (oldvnode.id !== newvnode.id) { - node.id = newvnode.id || ""; + node.id = newvnode.id || ''; oldvnode.id = newvnode.id; } // Value if (oldvnode.value !== newvnode.value) { oldvnode.value = newvnode.value; - if (["textarea", "input"].includes(oldvnode.type)) { - node.value = newvnode.value || ""; + if (['textarea', 'input'].includes(oldvnode.type)) { + node.value = newvnode.value || ''; } else { - node.setAttribute("value", newvnode.value || ""); + node.setAttribute('value', newvnode.value || ''); } } // Classes

@@ -365,7 +331,7 @@ oldvnode.classList = newvnode.classList;

} // Style if (oldvnode.style !== newvnode.style) { - node.style.cssText = newvnode.style || ""; + node.style.cssText = newvnode.style || ''; oldvnode.style = newvnode.style; } // Data

@@ -388,20 +354,15 @@ // Properties & Attributes

if (!equal(oldvnode.props, newvnode.props)) { Object.keys(oldvnode.props).forEach((a) => { node[a] = newvnode.props[a]; - if (typeof newvnode.props[a] === "boolean") { + if (typeof newvnode.props[a] === 'boolean') { oldvnode.props[a] = newvnode.props[a]; - newvnode.props[a] - ? node.setAttribute(a, "") - : node.removeAttribute(a); - } else if (!newvnode.props[a]) { + newvnode.props[a] ? node.setAttribute(a, '') : node.removeAttribute(a); + } else if ([null, undefined].includes(newvnode.props[a])) { delete oldvnode.props[a]; node.removeAttribute(a); - } else if ( - newvnode.props[a] && - newvnode.props[a] !== oldvnode.props[a] - ) { + } else if (newvnode.props[a] !== oldvnode.props[a]) { oldvnode.props[a] = newvnode.props[a]; - if (["string", "number"].includes(typeof newvnode.props[a])) { + if (['string', 'number'].includes(typeof newvnode.props[a])) { node.setAttribute(a, newvnode.props[a]); } }

@@ -409,7 +370,9 @@ });

Object.keys(newvnode.props).forEach((a) => { if (!oldvnode.props[a] && newvnode.props[a]) { oldvnode.props[a] = newvnode.props[a]; - node.setAttribute(a, newvnode.props[a]); + if (['string', 'number'].includes(typeof newvnode.props[a])) { + node.setAttribute(a, newvnode.props[a]); + } } }); }

@@ -418,9 +381,7 @@ if (!equal(oldvnode.eventListeners, newvnode.eventListeners)) {

Object.keys(oldvnode.eventListeners).forEach((a) => { if (!newvnode.eventListeners[a]) { node.removeEventListener(a, oldvnode.eventListeners[a]); - } else if ( - !equal(newvnode.eventListeners[a], oldvnode.eventListeners[a]) - ) { + } else if (!equal(newvnode.eventListeners[a], oldvnode.eventListeners[a])) { node.removeEventListener(a, oldvnode.eventListeners[a]); node.addEventListener(a, newvnode.eventListeners[a]); }

@@ -455,8 +416,7 @@ case INSERT: {

oldvnode.children.splice(count, 0, newvnode.children[count]); const renderedNode = newvnode.children[count].render(); node.insertBefore(renderedNode, node.childNodes[count]); - newvnode.children[count].$onrender && - newvnode.children[count].$onrender(renderedNode); + newvnode.children[count].$onrender && newvnode.children[count].$onrender(renderedNode); break checkmap; } case DELETE: {

@@ -501,11 +461,7 @@ op = oIdx; // Same node found

break; } } - if ( - op < 0 && - newList.length >= oldList.length && - map.length >= oldList.length - ) { + if (op < 0 && newList.length >= oldList.length && map.length >= oldList.length) { op = INSERT; } map.push(op);

@@ -513,9 +469,7 @@ }

const oldNodesFound = map.filter((c) => c >= 0); if (oldList.length > newList.length) { // Remove remaining nodes - [...Array(oldList.length - newList.length).keys()].forEach(() => - map.push(DELETE) - ); + [...Array(oldList.length - newList.length).keys()].forEach(() => map.push(DELETE)); } else if (oldNodesFound.length === oldList.length) { // All nodes not found are insertions map = map.map((c) => (c < 0 ? INSERT : c));

@@ -535,7 +489,7 @@ this.events = {};

this.state = {}; } dispatch(event, data) { - if (event !== "$log") this.dispatch("$log", { event, data }); + if (event !== '$log') this.dispatch('$log', { event, data }); if (this.events[event]) { let changes = {}; let changed;

@@ -562,9 +516,9 @@ this.query = query;

this.parts = parts; this.params = {}; if (this.query) { - const rawParams = this.query.split("&"); + const rawParams = this.query.split('&'); rawParams.forEach((p) => { - const [name, value] = p.split("="); + const [name, value] = p.split('='); this.params[decodeURIComponent(name)] = decodeURIComponent(value); }); }

@@ -578,7 +532,7 @@ this.redraw = null;

this.store = store; this.location = location || window.location; if (!routes || Object.keys(routes).length === 0) { - throw new Error("[Router] No routes defined."); + throw new Error('[Router] No routes defined.'); } const defs = Object.keys(routes); this.routes = routes;

@@ -590,34 +544,29 @@ vnode.redraw({

node: this.element.childNodes[0], vnode: this.routes[this.route.def](state), }); - this.store.dispatch("$redraw"); + this.store.dispatch('$redraw'); }; } async start() { const processPath = async (data) => { const oldRoute = this.route; - const fragment = - (data && - data.newURL && - data.newURL.match(/(#.+)$/) && - data.newURL.match(/(#.+)$/)[1]) || - this.location.hash; - const path = fragment.replace(/\?.+$/, "").slice(1); + const fragment = (data && data.newURL && data.newURL.match(/(#.+)$/) && data.newURL.match(/(#.+)$/)[1]) || this.location.hash; + const path = fragment.replace(/\?.+$/, '').slice(1); const rawQuery = fragment.match(/\?(.+)$/); - const query = rawQuery && rawQuery[1] ? rawQuery[1] : ""; - const pathParts = path.split("/").slice(1); + const query = rawQuery && rawQuery[1] ? rawQuery[1] : ''; + const pathParts = path.split('/').slice(1); let parts = {}; for (let def of Object.keys(this.routes)) { - let routeParts = def.split("/").slice(1); + let routeParts = def.split('/').slice(1); let match = true; let index = 0; parts = {}; while (match && routeParts[index]) { const rP = routeParts[index]; const pP = pathParts[index]; - if (rP.startsWith(":") && pP) { + if (rP.startsWith(':') && pP) { parts[rP.slice(1)] = pP; } else { match = rP === pP;

@@ -636,19 +585,15 @@ // Old route component teardown

let state = {}; if (oldRoute) { const oldRouteComponent = this.routes[oldRoute.def]; - state = - (oldRouteComponent.teardown && - (await oldRouteComponent.teardown(oldRouteComponent.state))) || - state; + state = (oldRouteComponent.teardown && (await oldRouteComponent.teardown(oldRouteComponent.state))) || state; } // New route component setup const newRouteComponent = this.routes[this.route.def]; newRouteComponent.state = state; - newRouteComponent.setup && - (await newRouteComponent.setup(newRouteComponent.state)); + newRouteComponent.setup && (await newRouteComponent.setup(newRouteComponent.state)); // Redrawing... redrawing = true; - this.store.dispatch("$navigation", this.route); + this.store.dispatch('$navigation', this.route); while (this.element.firstChild) { this.element.removeChild(this.element.firstChild); }

@@ -661,17 +606,17 @@ vnode.$onrender && vnode.$onrender(node);

$onrenderCallbacks.forEach((cbk) => cbk()); $onrenderCallbacks = []; window.scrollTo(0, 0); - this.store.dispatch("$redraw"); + this.store.dispatch('$redraw'); }; - window.addEventListener("hashchange", processPath); + window.addEventListener('hashchange', processPath); await processPath(); } navigateTo(path, params) { let query = Object.keys(params || {}) .map((p) => `${encodeURIComponent(p)}=${encodeURIComponent(params[p])}`) - .join("&"); - query = query ? `?${query}` : ""; + .join('&'); + query = query ? `?${query}` : ''; this.location.hash = `#${path}${query}`; } }

@@ -692,23 +637,21 @@ h3.init = (config) => {

let { element, routes, modules, preStart, postStart, location } = config; if (!routes) { // Assume config is a component object, define default route - if (typeof config !== "function") { - throw new Error( - "[h3.init] The specified argument is not a valid configuration object or component function" - ); + if (typeof config !== 'function') { + throw new Error('[h3.init] The specified argument is not a valid configuration object or component function'); } - routes = { "/": config }; + routes = { '/': config }; } element = element || document.body; if (!(element && element instanceof Element)) { - throw new Error("[h3.init] Invalid element specified."); + throw new Error('[h3.init] Invalid element specified.'); } // Initialize store store = new Store(); (modules || []).forEach((i) => { i(store); }); - store.dispatch("$init"); + store.dispatch('$init'); // Initialize router router = new Router({ element, routes, store, location }); return Promise.resolve(preStart && preStart())

@@ -718,30 +661,24 @@ };

h3.navigateTo = (path, params) => { if (!router) { - throw new Error( - "[h3.navigateTo] No application initialized, unable to navigate." - ); + throw new Error('[h3.navigateTo] No application initialized, unable to navigate.'); } return router.navigateTo(path, params); }; -Object.defineProperty(h3, "route", { +Object.defineProperty(h3, 'route', { get: () => { if (!router) { - throw new Error( - "[h3.route] No application initialized, unable to retrieve current route." - ); + throw new Error('[h3.route] No application initialized, unable to retrieve current route.'); } return router.route; }, }); -Object.defineProperty(h3, "state", { +Object.defineProperty(h3, 'state', { get: () => { if (!store) { - throw new Error( - "[h3.state] No application initialized, unable to retrieve current state." - ); + throw new Error('[h3.state] No application initialized, unable to retrieve current state.'); } return store.state; },

@@ -749,27 +686,21 @@ });

h3.on = (event, cb) => { if (!store) { - throw new Error( - "[h3.on] No application initialized, unable to listen to events." - ); + throw new Error('[h3.on] No application initialized, unable to listen to events.'); } return store.on(event, cb); }; h3.dispatch = (event, data) => { if (!store) { - throw new Error( - "[h3.dispatch] No application initialized, unable to dispatch events." - ); + throw new Error('[h3.dispatch] No application initialized, unable to dispatch events.'); } return store.dispatch(event, data); }; h3.redraw = (setRedrawing) => { if (!router || !router.redraw) { - throw new Error( - "[h3.redraw] No application initialized, unable to redraw." - ); + throw new Error('[h3.redraw] No application initialized, unable to redraw.'); } if (redrawing) { return;

@@ -780,14 +711,14 @@ redrawing = setRedrawing || false;

}; h3.screen = ({ setup, display, teardown }) => { - if (!display || typeof display !== "function") { - throw new Error("[h3.screen] No display property specified."); + if (!display || typeof display !== 'function') { + throw new Error('[h3.screen] No display property specified.'); } - if (setup && typeof setup !== "function") { - throw new Error("[h3.screen] setup property is not a function."); + if (setup && typeof setup !== 'function') { + throw new Error('[h3.screen] setup property is not a function.'); } - if (teardown && typeof teardown !== "function") { - throw new Error("[h3.screen] teardown property is not a function."); + if (teardown && typeof teardown !== 'function') { + throw new Error('[h3.screen] teardown property is not a function.'); } const fn = display; if (setup) {
M h3.js.maph3.js.map

@@ -1,1 +1,1 @@

-{"version":3,"sources":["0"],"names":["checkProperties","obj1","obj2","key","equal","undefined","constructor","toString","String","Number","Boolean","includes","Array","length","i","selectorRegex","PATCH","INSERT","DELETE","$onrenderCallbacks","VNode","[object Object]","args","this","type","props","data","id","$html","$onrender","style","value","children","classList","eventListeners","Error","vnode","processSelector","from","processVNodeObject","selector","isArray","Function","processChildren","processProperties","slice","concat","a","b","attrs","Object","keys","filter","startsWith","forEach","match","classes","split","arg","map","c","document","createTextNode","node","createElement","p","setAttribute","removeAttribute","event","addEventListener","cssText","add","dataset","cnode","render","appendChild","push","innerHTML","newvnode","oldvnode","renderedNode","parentNode","replaceChild","remove","removeEventListener","childMap","mapChildren","resultMap","count","checkmap","redraw","childNodes","splice","insertBefore","removeChild","vtarget","target","newList","oldList","nIdx","op","oIdx","oldNodesFound","Store","events","state","dispatch","cb","Route","path","def","query","parts","params","name","decodeURIComponent","Router","element","routes","store","location","window","route","processPath","async","oldRoute","fragment","newURL","hash","replace","rawQuery","pathParts","routeParts","index","rP","pP","oldRouteComponent","teardown","newRouteComponent","setup","redrawing","firstChild","setRedraw","cbk","scrollTo","encodeURIComponent","join","h","h3","router","init","config","modules","preStart","postStart","/","body","Element","Promise","resolve","then","start","navigateTo","defineProperty","get","on","setRedrawing","screen","display","fn"],"mappings":";;;;;;;AAOA,MAAMA,gBAAkB,CAACC,EAAMC,KAC7B,IAA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D,OACrB,MAAM,IAAIvD,MACR,6DAGAyG,YAGJA,WAAY,EACZS,OAAO3D,SACPkD,UAAY0B,IAAgB,IAG9BlB,GAAGmB,OAAS,EAAG5B,MAAAA,EAAO6B,QAAAA,EAAS/B,SAAAA,MAC7B,IAAK+B,GAA8B,mBAAZA,EACrB,MAAM,IAAIrI,MAAM,8CAElB,GAAIwG,GAA0B,mBAAVA,EAClB,MAAM,IAAIxG,MAAM,iDAElB,GAAIsG,GAAgC,mBAAbA,EACrB,MAAM,IAAItG,MAAM,oDAElB,MAAMsI,EAAKD,EAOX,OANI7B,IACF8B,EAAG9B,MAAQA,GAETF,IACFgC,EAAGhC,SAAWA,GAETgC,kBAGMrB","file":"h3.js"}+{"version":3,"sources":["0"],"names":["checkProperties","obj1","obj2","Object","keys","length","key","equal","undefined","constructor","toString","String","Number","Boolean","includes","Array","i","selectorRegex","PATCH","INSERT","DELETE","$onrenderCallbacks","VNode","[object Object]","args","this","type","props","data","id","$html","$onrender","style","value","children","classList","eventListeners","Error","vnode","processSelector","from","processVNodeObject","selector","isArray","Function","processChildren","processProperties","slice","concat","a","b","attrs","filter","startsWith","forEach","match","classes","split","arg","map","c","document","createTextNode","node","createElement","p","setAttribute","removeAttribute","event","addEventListener","cssText","add","dataset","cnode","render","appendChild","push","innerHTML","newvnode","oldvnode","renderedNode","parentNode","replaceChild","remove","removeEventListener","childMap","mapChildren","resultMap","count","checkmap","redraw","childNodes","splice","insertBefore","removeChild","vtarget","target","newList","oldList","nIdx","op","oIdx","oldNodesFound","Store","events","state","dispatch","cb","Route","path","def","query","parts","params","name","decodeURIComponent","Router","element","routes","store","location","window","route","processPath","async","oldRoute","fragment","newURL","hash","replace","rawQuery","pathParts","routeParts","index","rP","pP","oldRouteComponent","teardown","newRouteComponent","setup","redrawing","firstChild","setRedraw","cbk","scrollTo","encodeURIComponent","join","h","h3","router","init","config","modules","preStart","postStart","/","body","Element","Promise","resolve","then","start","navigateTo","defineProperty","get","on","setRedrawing","screen","display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iB,GAAK,CAACjG,EAAOuC,KACd,IAAKY,MACH,MAAM,IAAIlF,MAAM,mEAElB,OAAOkF,MAAM8C,GAAGjG,EAAOuC,IAGzByC,GAAG1C,SAAW,CAACtC,EAAOxC,KACpB,IAAK2F,MACH,MAAM,IAAIlF,MAAM,wEAElB,OAAOkF,MAAMb,SAAStC,EAAOxC,IAG/BwH,GAAG1D,OAAU4E,IACX,IAAKjB,SAAWA,OAAO3D,OACrB,MAAM,IAAIrD,MAAM,6DAEduG,YAGJA,WAAY,EACZS,OAAO3D,SACPkD,UAAY0B,IAAgB,IAG9BlB,GAAGmB,OAAS,EAAG5B,MAAAA,EAAO6B,QAAAA,EAAS/B,SAAAA,MAC7B,IAAK+B,GAA8B,mBAAZA,EACrB,MAAM,IAAInI,MAAM,8CAElB,GAAIsG,GAA0B,mBAAVA,EAClB,MAAM,IAAItG,MAAM,iDAElB,GAAIoG,GAAgC,mBAAbA,EACrB,MAAM,IAAIpG,MAAM,oDAElB,MAAMoI,EAAKD,EAOX,OANI7B,IACF8B,EAAG9B,MAAQA,GAETF,IACFgC,EAAGhC,SAAWA,GAETgC,kBAGMrB","file":"h3.js"}
M h3.min.jsh3.min.js

@@ -5,5 +5,5 @@ *

* @license MIT * For the full license, see: https://github.com/h3rald/h3/blob/master/LICENSE */ -const checkProperties=(e,t)=>{for(const r in e){if(!(r in t))return!1;if(!equal(e[r],t[r]))return!1}return!0},equal=(e,t)=>{if(null===e&&null===t||void 0===e&&void 0===t)return!0;if(void 0===e&&void 0!==t||void 0!==e&&void 0===t||null===e&&null!==t||null!==e&&null===t)return!1;if(e.constructor!==t.constructor)return!1;if("function"==typeof e&&e.toString()!==t.toString())return!1;if([String,Number,Boolean].includes(e.constructor))return e===t;if(e.constructor===Array){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!equal(e[r],t[r]))return!1;return!0}return checkProperties(e,t)},selectorRegex=/^([a-z][a-z0-9:_=-]*)?(#[a-z0-9:_=-]+)?(\.[^ ]+)*$/i,[PATCH,INSERT,DELETE]=[-1,-2,-3];let $onrenderCallbacks=[];class VNode{constructor(...e){if(this.type=void 0,this.props={},this.data={},this.id=void 0,this.$html=void 0,this.$onrender=void 0,this.style=void 0,this.value=void 0,this.children=[],this.classList=[],this.eventListeners={},0===e.length)throw new Error("[VNode] No arguments passed to VNode constructor.");if(1===e.length){let t=e[0];if("string"==typeof t)this.processSelector(t);else{if("function"!=typeof t&&("object"!=typeof t||null===t))throw new Error("[VNode] Invalid first argument passed to VNode constructor.");"#text"===t.type?(this.type="#text",this.value=t.value):this.from(this.processVNodeObject(t))}}else if(2===e.length){let[t,r]=e;if("string"!=typeof t)throw new Error("[VNode] Invalid first argument passed to VNode constructor.");if(this.processSelector(t),"string"==typeof r)return void(this.children=[new VNode({type:"#text",value:r})]);if("function"!=typeof r&&("object"!=typeof r||null===r))throw new Error("[VNode] The second argument of a VNode constructor must be an object, an array or a string.");Array.isArray(r)||r instanceof Function||r instanceof VNode?this.processChildren(r):this.processProperties(r)}else{let[t,r,s]=e;if(e.length>3&&(s=e.slice(2)),s=Array.isArray(s)?s:[s],"string"!=typeof t)throw new Error("[VNode] Invalid first argument passed to VNode constructor.");if(this.processSelector(t),r instanceof Function||r instanceof VNode||"string"==typeof r)s=[r].concat(s);else{if("object"!=typeof r||null===r)throw new Error("[VNode] Invalid second argument passed to VNode constructor.");this.processProperties(r)}this.processChildren(s)}}from(e){this.value=e.value,this.type=e.type,this.id=e.id,this.$html=e.$html,this.$onrender=e.$onrender,this.style=e.style,this.data=e.data,this.value=e.value,this.eventListeners=e.eventListeners,this.children=e.children,this.props=e.props,this.classList=e.classList}equal(e,t){return equal(e,void 0===t?this:t)}processProperties(e){this.id=this.id||e.id,this.$html=e.$html,this.$onrender=e.$onrender,this.style=e.style,this.value=e.value,this.data=e.data||{},this.classList=e.classList&&e.classList.length>0?e.classList:this.classList,this.props=e,Object.keys(e).filter(t=>t.startsWith("on")&&e[t]).forEach(t=>{if("function"!=typeof e[t])throw new Error(`[VNode] Event handler specified for ${t} event is not a function.`);this.eventListeners[t.slice(2)]=e[t],delete this.props[t]}),delete this.props.value,delete this.props.$html,delete this.props.$onrender,delete this.props.id,delete this.props.data,delete this.props.style,delete this.props.classList}processSelector(e){if(!e.match(selectorRegex)||0===e.length)throw new Error("[VNode] Invalid selector: "+e);const[,t,r,s]=e.match(selectorRegex);this.type=t,r&&(this.id=r.slice(1)),this.classList=s&&s.split(".").slice(1)||[]}processVNodeObject(e){if(e instanceof VNode)return e;if(e instanceof Function){let t=e();if("string"==typeof t&&(t=new VNode({type:"#text",value:t})),!(t instanceof VNode))throw new Error("[VNode] Function argument does not return a VNode");return t}throw new Error("[VNode] Invalid first argument provided to VNode constructor.")}processChildren(e){const t=Array.isArray(e)?e:[e];this.children=t.map(e=>{if("string"==typeof e)return new VNode({type:"#text",value:e});if("function"==typeof e||"object"==typeof e&&null!==e)return this.processVNodeObject(e);if(e)throw new Error("[VNode] Specified child is not a VNode: "+e)}).filter(e=>e)}render(){if("#text"===this.type)return document.createTextNode(this.value);const e=document.createElement(this.type);return this.id&&(e.id=this.id),Object.keys(this.props).forEach(t=>{"boolean"==typeof this.props[t]&&(this.props[t]?e.setAttribute(t,""):e.removeAttribute(t)),["string","number"].includes(typeof this.props[t])&&e.setAttribute(t,this.props[t]),e[t]=this.props[t]}),Object.keys(this.eventListeners).forEach(t=>{e.addEventListener(t,this.eventListeners[t])}),this.value&&(["textarea","input"].includes(this.type)?e.value=this.value:e.setAttribute("value",this.value)),this.style&&(e.style.cssText=this.style),this.classList.forEach(t=>{e.classList.add(t)}),Object.keys(this.data).forEach(t=>{e.dataset[t]=this.data[t]}),this.children.forEach(t=>{const r=t.render();e.appendChild(r),t.$onrender&&$onrenderCallbacks.push(()=>t.$onrender(r))}),this.$html&&(e.innerHTML=this.$html),e}redraw(e){let{node:t,vnode:r}=e;const s=r,o=this;if(o.constructor!==s.constructor||o.type!==s.type||o.type===s.type&&"#text"===o.type&&o!==s){const e=s.render();return t.parentNode.replaceChild(e,t),s.$onrender&&s.$onrender(e),void o.from(s)}o.id!==s.id&&(t.id=s.id||"",o.id=s.id),o.value!==s.value&&(o.value=s.value,["textarea","input"].includes(o.type)?t.value=s.value||"":t.setAttribute("value",s.value||"")),equal(o.classList,s.classList)||(o.classList.forEach(e=>{s.classList.includes(e)||t.classList.remove(e)}),s.classList.forEach(e=>{o.classList.includes(e)||t.classList.add(e)}),o.classList=s.classList),o.style!==s.style&&(t.style.cssText=s.style||"",o.style=s.style),equal(o.data,s.data)||(Object.keys(o.data).forEach(e=>{s.data[e]?s.data[e]!==o.data[e]&&(t.dataset[e]=s.data[e]):delete t.dataset[e]}),Object.keys(s.data).forEach(e=>{o.data[e]||(t.dataset[e]=s.data[e])}),o.data=s.data),equal(o.props,s.props)||(Object.keys(o.props).forEach(e=>{t[e]=s.props[e],"boolean"==typeof s.props[e]?(o.props[e]=s.props[e],s.props[e]?t.setAttribute(e,""):t.removeAttribute(e)):s.props[e]?s.props[e]&&s.props[e]!==o.props[e]&&(o.props[e]=s.props[e],["string","number"].includes(typeof s.props[e])&&t.setAttribute(e,s.props[e])):(delete o.props[e],t.removeAttribute(e))}),Object.keys(s.props).forEach(e=>{!o.props[e]&&s.props[e]&&(o.props[e]=s.props[e],t.setAttribute(e,s.props[e]))})),equal(o.eventListeners,s.eventListeners)||(Object.keys(o.eventListeners).forEach(e=>{s.eventListeners[e]?equal(s.eventListeners[e],o.eventListeners[e])||(t.removeEventListener(e,o.eventListeners[e]),t.addEventListener(e,s.eventListeners[e])):t.removeEventListener(e,o.eventListeners[e])}),Object.keys(s.eventListeners).forEach(e=>{o.eventListeners[e]||t.addEventListener(e,s.eventListeners[e])}),o.eventListeners=s.eventListeners);let i=mapChildren(o,s),n=[...Array(s.children.length).keys()];for(;!equal(i,n);){let e=-1;e:for(const r of i)if(e++,r!==e)switch(r){case PATCH:o.children[e].redraw({node:t.childNodes[e],vnode:s.children[e]});break e;case INSERT:{o.children.splice(e,0,s.children[e]);const r=s.children[e].render();t.insertBefore(r,t.childNodes[e]),s.children[e].$onrender&&s.children[e].$onrender(r);break e}case DELETE:o.children.splice(e,1),t.removeChild(t.childNodes[e]);break e;default:{const s=o.children.splice(r,1)[0];o.children.splice(e,0,s);const i=t.removeChild(t.childNodes[r]);t.insertBefore(i,t.childNodes[e]);break e}}i=mapChildren(o,s),n=[...Array(s.children.length).keys()]}equal(o.$onrender,s.$onrender)||(o.$onrender=s.$onrender),o.$html!==s.$html&&(t.innerHTML=s.$html,o.$html=s.$html,o.$onrender&&o.$onrender(t))}}const mapChildren=(e,t)=>{const r=t.children,s=e.children;let o=[];for(let e=0;e<r.length;e++){let t=PATCH;for(let i=0;i<s.length;i++)if(equal(r[e],s[i])&&!o.includes(i)){t=i;break}t<0&&r.length>=s.length&&o.length>=s.length&&(t=INSERT),o.push(t)}const i=o.filter(e=>e>=0);return s.length>r.length?[...Array(s.length-r.length).keys()].forEach(()=>o.push(DELETE)):i.length===s.length&&(o=o.map(e=>e<0?INSERT:e)),o};class Store{constructor(){this.events={},this.state={}}dispatch(e,t){if("$log"!==e&&this.dispatch("$log",{event:e,data:t}),this.events[e]){this.events[e].forEach(e=>{this.state={...this.state,...e(this.state,t)}})}}on(e,t){return(this.events[e]||(this.events[e]=[])).push(t),()=>{this.events[e]=this.events[e].filter(e=>e!==t)}}}class Route{constructor({path:e,def:t,query:r,parts:s}){if(this.path=e,this.def=t,this.query=r,this.parts=s,this.params={},this.query){this.query.split("&").forEach(e=>{const[t,r]=e.split("=");this.params[decodeURIComponent(t)]=decodeURIComponent(r)})}}}class Router{constructor({element:e,routes:t,store:r,location:s}){if(this.element=e,this.redraw=null,this.store=r,this.location=s||window.location,!t||0===Object.keys(t).length)throw new Error("[Router] No routes defined.");Object.keys(t);this.routes=t}setRedraw(e,t){this.redraw=()=>{e.redraw({node:this.element.childNodes[0],vnode:this.routes[this.route.def](t)}),this.store.dispatch("$redraw")}}async start(){const e=async e=>{const t=this.route,r=e&&e.newURL&&e.newURL.match(/(#.+)$/)&&e.newURL.match(/(#.+)$/)[1]||this.location.hash,s=r.replace(/\?.+$/,"").slice(1),o=r.match(/\?(.+)$/),i=o&&o[1]?o[1]:"",n=s.split("/").slice(1);let a={};for(let e of Object.keys(this.routes)){let t=e.split("/").slice(1),r=!0,o=0;for(a={};r&&t[o];){const e=t[o],s=n[o];e.startsWith(":")&&s?a[e.slice(1)]=s:r=e===s,o++}if(r){this.route=new Route({query:i,path:s,def:e,parts:a});break}}if(!this.route)throw new Error(`[Router] No route matches '${r}'`);let l={};if(t){const e=this.routes[t.def];l=e.teardown&&await e.teardown(e.state)||l}const h=this.routes[this.route.def];for(h.state=l,h.setup&&await h.setup(h.state),redrawing=!0,this.store.dispatch("$navigation",this.route);this.element.firstChild;)this.element.removeChild(this.element.firstChild);const d=h(h.state),c=d.render();this.element.appendChild(c),this.setRedraw(d,h.state),redrawing=!1,d.$onrender&&d.$onrender(c),$onrenderCallbacks.forEach(e=>e()),$onrenderCallbacks=[],window.scrollTo(0,0),this.store.dispatch("$redraw")};window.addEventListener("hashchange",e),await e()}navigateTo(e,t){let r=Object.keys(t||{}).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`).join("&");r=r?"?"+r:"",this.location.hash=`#${e}${r}`}}export const h=(...e)=>new VNode(...e);export const h3={};let store=null,router=null,redrawing=!1;h3.init=e=>{let{element:t,routes:r,modules:s,preStart:o,postStart:i,location:n}=e;if(!r){if("function"!=typeof e)throw new Error("[h3.init] The specified argument is not a valid configuration object or component function");r={"/":e}}if(t=t||document.body,!(t&&t instanceof Element))throw new Error("[h3.init] Invalid element specified.");return store=new Store,(s||[]).forEach(e=>{e(store)}),store.dispatch("$init"),router=new Router({element:t,routes:r,store:store,location:n}),Promise.resolve(o&&o()).then(()=>router.start()).then(()=>i&&i())},h3.navigateTo=(e,t)=>{if(!router)throw new Error("[h3.navigateTo] No application initialized, unable to navigate.");return router.navigateTo(e,t)},Object.defineProperty(h3,"route",{get:()=>{if(!router)throw new Error("[h3.route] No application initialized, unable to retrieve current route.");return router.route}}),Object.defineProperty(h3,"state",{get:()=>{if(!store)throw new Error("[h3.state] No application initialized, unable to retrieve current state.");return store.state}}),h3.on=(e,t)=>{if(!store)throw new Error("[h3.on] No application initialized, unable to listen to events.");return store.on(e,t)},h3.dispatch=(e,t)=>{if(!store)throw new Error("[h3.dispatch] No application initialized, unable to dispatch events.");return store.dispatch(e,t)},h3.redraw=e=>{if(!router||!router.redraw)throw new Error("[h3.redraw] No application initialized, unable to redraw.");redrawing||(redrawing=!0,router.redraw(),redrawing=e||!1)},h3.screen=({setup:e,display:t,teardown:r})=>{if(!t||"function"!=typeof t)throw new Error("[h3.screen] No display property specified.");if(e&&"function"!=typeof e)throw new Error("[h3.screen] setup property is not a function.");if(r&&"function"!=typeof r)throw new Error("[h3.screen] teardown property is not a function.");const s=t;return e&&(s.setup=e),r&&(s.teardown=r),s};export default h3; +const checkProperties=(e,t)=>{if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e){if(!(r in t))return!1;if(!equal(e[r],t[r]))return!1}return!0},equal=(e,t)=>{if(null===e&&null===t||void 0===e&&void 0===t)return!0;if(void 0===e&&void 0!==t||void 0!==e&&void 0===t||null===e&&null!==t||null!==e&&null===t)return!1;if(e.constructor!==t.constructor)return!1;if("function"==typeof e&&e.toString()!==t.toString())return!1;if([String,Number,Boolean].includes(e.constructor))return e===t;if(e.constructor===Array){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!equal(e[r],t[r]))return!1;return!0}return checkProperties(e,t)},selectorRegex=/^([a-z][a-z0-9:_=-]*)?(#[a-z0-9:_=-]+)?(\.[^ ]+)*$/i,[PATCH,INSERT,DELETE]=[-1,-2,-3];let $onrenderCallbacks=[];class VNode{constructor(...e){if(this.type=void 0,this.props={},this.data={},this.id=void 0,this.$html=void 0,this.$onrender=void 0,this.style=void 0,this.value=void 0,this.children=[],this.classList=[],this.eventListeners={},0===e.length)throw new Error("[VNode] No arguments passed to VNode constructor.");if(1===e.length){let t=e[0];if("string"==typeof t)this.processSelector(t);else{if("function"!=typeof t&&("object"!=typeof t||null===t))throw new Error("[VNode] Invalid first argument passed to VNode constructor.");"#text"===t.type?(this.type="#text",this.value=t.value):this.from(this.processVNodeObject(t))}}else if(2===e.length){let[t,r]=e;if("string"!=typeof t)throw new Error("[VNode] Invalid first argument passed to VNode constructor.");if(this.processSelector(t),"string"==typeof r)return void(this.children=[new VNode({type:"#text",value:r})]);if("function"!=typeof r&&("object"!=typeof r||null===r))throw new Error("[VNode] The second argument of a VNode constructor must be an object, an array or a string.");Array.isArray(r)||r instanceof Function||r instanceof VNode?this.processChildren(r):this.processProperties(r)}else{let[t,r,s]=e;if(e.length>3&&(s=e.slice(2)),s=Array.isArray(s)?s:[s],"string"!=typeof t)throw new Error("[VNode] Invalid first argument passed to VNode constructor.");if(this.processSelector(t),r instanceof Function||r instanceof VNode||"string"==typeof r)s=[r].concat(s);else{if("object"!=typeof r||null===r)throw new Error("[VNode] Invalid second argument passed to VNode constructor.");this.processProperties(r)}this.processChildren(s)}}from(e){this.value=e.value,this.type=e.type,this.id=e.id,this.$html=e.$html,this.$onrender=e.$onrender,this.style=e.style,this.data=e.data,this.value=e.value,this.eventListeners=e.eventListeners,this.children=e.children,this.props=e.props,this.classList=e.classList}equal(e,t){return equal(e,void 0===t?this:t)}processProperties(e){this.id=this.id||e.id,this.$html=e.$html,this.$onrender=e.$onrender,this.style=e.style,this.value=e.value,this.data=e.data||{},this.classList=e.classList&&e.classList.length>0?e.classList:this.classList,this.props=e,Object.keys(e).filter(t=>t.startsWith("on")&&e[t]).forEach(t=>{if("function"!=typeof e[t])throw new Error(`[VNode] Event handler specified for ${t} event is not a function.`);this.eventListeners[t.slice(2)]=e[t],delete this.props[t]}),delete this.props.value,delete this.props.$html,delete this.props.$onrender,delete this.props.id,delete this.props.data,delete this.props.style,delete this.props.classList}processSelector(e){if(!e.match(selectorRegex)||0===e.length)throw new Error("[VNode] Invalid selector: "+e);const[,t,r,s]=e.match(selectorRegex);this.type=t,r&&(this.id=r.slice(1)),this.classList=s&&s.split(".").slice(1)||[]}processVNodeObject(e){if(e instanceof VNode)return e;if(e instanceof Function){let t=e();if("string"==typeof t&&(t=new VNode({type:"#text",value:t})),!(t instanceof VNode))throw new Error("[VNode] Function argument does not return a VNode");return t}throw new Error("[VNode] Invalid first argument provided to VNode constructor.")}processChildren(e){const t=Array.isArray(e)?e:[e];this.children=t.map(e=>{if("string"==typeof e)return new VNode({type:"#text",value:e});if("function"==typeof e||"object"==typeof e&&null!==e)return this.processVNodeObject(e);if(e)throw new Error("[VNode] Specified child is not a VNode: "+e)}).filter(e=>e)}render(){if("#text"===this.type)return document.createTextNode(this.value);const e=document.createElement(this.type);return this.id&&(e.id=this.id),Object.keys(this.props).forEach(t=>{"boolean"==typeof this.props[t]&&(this.props[t]?e.setAttribute(t,""):e.removeAttribute(t)),["string","number"].includes(typeof this.props[t])&&e.setAttribute(t,this.props[t]),e[t]=this.props[t]}),Object.keys(this.eventListeners).forEach(t=>{e.addEventListener(t,this.eventListeners[t])}),this.value&&(["textarea","input"].includes(this.type)?e.value=this.value:e.setAttribute("value",this.value)),this.style&&(e.style.cssText=this.style),this.classList.forEach(t=>{e.classList.add(t)}),Object.keys(this.data).forEach(t=>{e.dataset[t]=this.data[t]}),this.children.forEach(t=>{const r=t.render();e.appendChild(r),t.$onrender&&$onrenderCallbacks.push(()=>t.$onrender(r))}),this.$html&&(e.innerHTML=this.$html),e}redraw(e){let{node:t,vnode:r}=e;const s=r,o=this;if(o.constructor!==s.constructor||o.type!==s.type||o.type===s.type&&"#text"===o.type&&o!==s){const e=s.render();return t.parentNode.replaceChild(e,t),s.$onrender&&s.$onrender(e),void o.from(s)}o.id!==s.id&&(t.id=s.id||"",o.id=s.id),o.value!==s.value&&(o.value=s.value,["textarea","input"].includes(o.type)?t.value=s.value||"":t.setAttribute("value",s.value||"")),equal(o.classList,s.classList)||(o.classList.forEach(e=>{s.classList.includes(e)||t.classList.remove(e)}),s.classList.forEach(e=>{o.classList.includes(e)||t.classList.add(e)}),o.classList=s.classList),o.style!==s.style&&(t.style.cssText=s.style||"",o.style=s.style),equal(o.data,s.data)||(Object.keys(o.data).forEach(e=>{s.data[e]?s.data[e]!==o.data[e]&&(t.dataset[e]=s.data[e]):delete t.dataset[e]}),Object.keys(s.data).forEach(e=>{o.data[e]||(t.dataset[e]=s.data[e])}),o.data=s.data),equal(o.props,s.props)||(Object.keys(o.props).forEach(e=>{t[e]=s.props[e],"boolean"==typeof s.props[e]?(o.props[e]=s.props[e],s.props[e]?t.setAttribute(e,""):t.removeAttribute(e)):[null,void 0].includes(s.props[e])?(delete o.props[e],t.removeAttribute(e)):s.props[e]!==o.props[e]&&(o.props[e]=s.props[e],["string","number"].includes(typeof s.props[e])&&t.setAttribute(e,s.props[e]))}),Object.keys(s.props).forEach(e=>{!o.props[e]&&s.props[e]&&(o.props[e]=s.props[e],["string","number"].includes(typeof s.props[e])&&t.setAttribute(e,s.props[e]))})),equal(o.eventListeners,s.eventListeners)||(Object.keys(o.eventListeners).forEach(e=>{s.eventListeners[e]?equal(s.eventListeners[e],o.eventListeners[e])||(t.removeEventListener(e,o.eventListeners[e]),t.addEventListener(e,s.eventListeners[e])):t.removeEventListener(e,o.eventListeners[e])}),Object.keys(s.eventListeners).forEach(e=>{o.eventListeners[e]||t.addEventListener(e,s.eventListeners[e])}),o.eventListeners=s.eventListeners);let i=mapChildren(o,s),n=[...Array(s.children.length).keys()];for(;!equal(i,n);){let e=-1;e:for(const r of i)if(e++,r!==e)switch(r){case PATCH:o.children[e].redraw({node:t.childNodes[e],vnode:s.children[e]});break e;case INSERT:{o.children.splice(e,0,s.children[e]);const r=s.children[e].render();t.insertBefore(r,t.childNodes[e]),s.children[e].$onrender&&s.children[e].$onrender(r);break e}case DELETE:o.children.splice(e,1),t.removeChild(t.childNodes[e]);break e;default:{const s=o.children.splice(r,1)[0];o.children.splice(e,0,s);const i=t.removeChild(t.childNodes[r]);t.insertBefore(i,t.childNodes[e]);break e}}i=mapChildren(o,s),n=[...Array(s.children.length).keys()]}equal(o.$onrender,s.$onrender)||(o.$onrender=s.$onrender),o.$html!==s.$html&&(t.innerHTML=s.$html,o.$html=s.$html,o.$onrender&&o.$onrender(t))}}const mapChildren=(e,t)=>{const r=t.children,s=e.children;let o=[];for(let e=0;e<r.length;e++){let t=PATCH;for(let i=0;i<s.length;i++)if(equal(r[e],s[i])&&!o.includes(i)){t=i;break}t<0&&r.length>=s.length&&o.length>=s.length&&(t=INSERT),o.push(t)}const i=o.filter(e=>e>=0);return s.length>r.length?[...Array(s.length-r.length).keys()].forEach(()=>o.push(DELETE)):i.length===s.length&&(o=o.map(e=>e<0?INSERT:e)),o};class Store{constructor(){this.events={},this.state={}}dispatch(e,t){if("$log"!==e&&this.dispatch("$log",{event:e,data:t}),this.events[e]){this.events[e].forEach(e=>{this.state={...this.state,...e(this.state,t)}})}}on(e,t){return(this.events[e]||(this.events[e]=[])).push(t),()=>{this.events[e]=this.events[e].filter(e=>e!==t)}}}class Route{constructor({path:e,def:t,query:r,parts:s}){if(this.path=e,this.def=t,this.query=r,this.parts=s,this.params={},this.query){this.query.split("&").forEach(e=>{const[t,r]=e.split("=");this.params[decodeURIComponent(t)]=decodeURIComponent(r)})}}}class Router{constructor({element:e,routes:t,store:r,location:s}){if(this.element=e,this.redraw=null,this.store=r,this.location=s||window.location,!t||0===Object.keys(t).length)throw new Error("[Router] No routes defined.");Object.keys(t);this.routes=t}setRedraw(e,t){this.redraw=()=>{e.redraw({node:this.element.childNodes[0],vnode:this.routes[this.route.def](t)}),this.store.dispatch("$redraw")}}async start(){const e=async e=>{const t=this.route,r=e&&e.newURL&&e.newURL.match(/(#.+)$/)&&e.newURL.match(/(#.+)$/)[1]||this.location.hash,s=r.replace(/\?.+$/,"").slice(1),o=r.match(/\?(.+)$/),i=o&&o[1]?o[1]:"",n=s.split("/").slice(1);let a={};for(let e of Object.keys(this.routes)){let t=e.split("/").slice(1),r=!0,o=0;for(a={};r&&t[o];){const e=t[o],s=n[o];e.startsWith(":")&&s?a[e.slice(1)]=s:r=e===s,o++}if(r){this.route=new Route({query:i,path:s,def:e,parts:a});break}}if(!this.route)throw new Error(`[Router] No route matches '${r}'`);let l={};if(t){const e=this.routes[t.def];l=e.teardown&&await e.teardown(e.state)||l}const h=this.routes[this.route.def];for(h.state=l,h.setup&&await h.setup(h.state),redrawing=!0,this.store.dispatch("$navigation",this.route);this.element.firstChild;)this.element.removeChild(this.element.firstChild);const c=h(h.state),d=c.render();this.element.appendChild(d),this.setRedraw(c,h.state),redrawing=!1,c.$onrender&&c.$onrender(d),$onrenderCallbacks.forEach(e=>e()),$onrenderCallbacks=[],window.scrollTo(0,0),this.store.dispatch("$redraw")};window.addEventListener("hashchange",e),await e()}navigateTo(e,t){let r=Object.keys(t||{}).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`).join("&");r=r?"?"+r:"",this.location.hash=`#${e}${r}`}}export const h=(...e)=>new VNode(...e);export const h3={};let store=null,router=null,redrawing=!1;h3.init=e=>{let{element:t,routes:r,modules:s,preStart:o,postStart:i,location:n}=e;if(!r){if("function"!=typeof e)throw new Error("[h3.init] The specified argument is not a valid configuration object or component function");r={"/":e}}if(t=t||document.body,!(t&&t instanceof Element))throw new Error("[h3.init] Invalid element specified.");return store=new Store,(s||[]).forEach(e=>{e(store)}),store.dispatch("$init"),router=new Router({element:t,routes:r,store:store,location:n}),Promise.resolve(o&&o()).then(()=>router.start()).then(()=>i&&i())},h3.navigateTo=(e,t)=>{if(!router)throw new Error("[h3.navigateTo] No application initialized, unable to navigate.");return router.navigateTo(e,t)},Object.defineProperty(h3,"route",{get:()=>{if(!router)throw new Error("[h3.route] No application initialized, unable to retrieve current route.");return router.route}}),Object.defineProperty(h3,"state",{get:()=>{if(!store)throw new Error("[h3.state] No application initialized, unable to retrieve current state.");return store.state}}),h3.on=(e,t)=>{if(!store)throw new Error("[h3.on] No application initialized, unable to listen to events.");return store.on(e,t)},h3.dispatch=(e,t)=>{if(!store)throw new Error("[h3.dispatch] No application initialized, unable to dispatch events.");return store.dispatch(e,t)},h3.redraw=e=>{if(!router||!router.redraw)throw new Error("[h3.redraw] No application initialized, unable to redraw.");redrawing||(redrawing=!0,router.redraw(),redrawing=e||!1)},h3.screen=({setup:e,display:t,teardown:r})=>{if(!t||"function"!=typeof t)throw new Error("[h3.screen] No display property specified.");if(e&&"function"!=typeof e)throw new Error("[h3.screen] setup property is not a function.");if(r&&"function"!=typeof r)throw new Error("[h3.screen] teardown property is not a function.");const s=t;return e&&(s.setup=e),r&&(s.teardown=r),s};export default h3; //# sourceMappingURL=h3.js.map