kt.js 0.4.1 → 0.4.2
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.
- package/dist/index.iife.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var kt=function(n){"use strict";var t=Object.freeze(Object.create(null)),e=Array.isArray,r=Array.prototype.filter,o=Object.
|
|
1
|
+
var kt=function(n){"use strict";var t=Object.freeze(Object.create(null)),e=Array.isArray,r=Array.prototype.filter,o=Object.prototype.hasOwnProperty,u=Object.keys,i=function(){return{}},f="undefined"==typeof Promise?i:Promise.resolve,a="undefined"==typeof Promise?i:Promise.reject,c=document.createElement,d=document.createTextNode,l=document.createDocumentFragment,s=function(n){return void 0===n&&(n=""),d.call(document,n)},v=HTMLElement.prototype.addEventListener,p=HTMLElement.prototype.setAttribute,m=HTMLElement.prototype.appendChild,h=HTMLElement.prototype.append,y="function"==typeof h?function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return h.apply(this,r.call(n,function(n){return n!==t}))}:function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];if(n.length<50)for(var r=0;r<n.length;r++){"string"==typeof(u=n[r])?m.call(this,s(u)):u!==t&&m.call(this,u)}else{var o=l.call(document);for(r=0;r<n.length;r++){var u;"string"==typeof(u=n[r])?m.call(o,s(u)):u!==t&&m.call(o,u)}m.call(this,o)}},b=function(n){throw new Error("Kt.js:".concat(n))};function w(n,t,e){t in n?n[t]=!!e:p.call(n,t,e)}function g(n,t,e){t in n?n[t]=e:p.call(n,t,e)}var E={checked:w,selected:w,value:g,valueAsDate:g,valueAsNumber:g,defaultValue:g,defaultChecked:w,defaultSelected:w,disabled:w,readOnly:w,multiple:w,required:w,autofocus:w,open:w,controls:w,autoplay:w,loop:w,muted:w,defer:w,async:w,hidden:function(n,t,e){n.hidden=!!e}},j=function(n,t,e){return p.call(n,t,e)};function A(n,t){"string"==typeof t?n.className=t:"object"==typeof t&&null!==t?function(n,t){var e=t.class,r=t.style;if(void 0!==e&&(n.className=e,delete t.class),r){if("string"==typeof r)p.call(n,"style",r);else if("object"==typeof r)for(var i in r)o.call(n.style,i)&&(n.style[i]=r[i]);delete t.style}for(var f=u(t),a=f.length-1;a>=0;a--){var c=t[i=f[a]];"function"!=typeof c?(E[i]||j)(n,i,c):v.call(n,i,c)}void 0!==e&&(t.style=e),void 0!==r&&(t.style=r)}(n,t):b("applyAttr attr must be an object.")}function O(n,t,r){void 0===t&&(t=""),void 0===r&&(r=""),"string"!=typeof n&&b("h tagName must be a string.");var o,u=(o=n,c.call(document,o));return A(u,t),function(n,t){e(t)?y.apply(n,t):y.call(n,t)}(u,r),u}var P=function(n){return function(t,e){return O(n,t,e)}},R=P("div"),k=P("span"),H=P("label"),L=P("p"),M=P("h1"),T=P("h2"),q=P("h3"),C=P("h4"),N=P("h5"),I=P("h6"),U=P("ul"),x=P("ol"),D=P("li"),K=P("button"),S=P("form"),V=P("input"),$=P("select"),z=P("option"),B=P("table"),F=P("thead"),G=P("tbody"),J=P("tr"),Q=P("th"),W=P("td"),X=P("a"),Y=P("img"),Z=function(){return!0};return n.a=X,n.btn=K,n.createRouter=function(n){var t=n.routes,e=n.container,r=n.beforeEach,o=void 0===r?Z:r,u=n.afterEach,i=void 0===u?Z:u,c=n.onError,d=void 0===c?console.error:c,l=null,s=t.map(function(n){var t=[],e=n.path.replace(/\/:([^/]+)/g,function(n,e){return t.push(e),"/([^/]+)"});return{route:n,pattern:new RegExp("^".concat(e,"$")),names:t}}),v=function(n){for(var t=0;t<s.length;t++){var e=s[t],r=e.route,o=e.pattern,u=e.names,i=n.match(o);if(i){for(var f={},a=0;a<u.length;a++)f[u[a]]=i[a+1];return{route:r,params:f}}}return null},p=function(n){var t={};if(!n)return t;for(var e=(0===n.indexOf("?")?n.slice(1):n).split("&"),r=0;r<e.length;r++){var o=e[r].split("="),u=o[0];u&&(t[decodeURIComponent(u)]=decodeURIComponent(o[1]||""))}return t},m="undefined"!=typeof Promise?function(n){var t=n.split("?"),r=t[0],u=t[1],c=p(u||""),s=v(r);if(!s){var m=new Error("Route not found: ".concat(r));return d(m),a(m)}var h={params:s.params,query:c,path:r,meta:s.route.meta};return f(o(h,l)).then(function(n){return n?(window.location.hash=u?"".concat(r,"?").concat(u):r,s.route.handler(h)):a(new Error("Navigation blocked by guard"))}).then(function(n){e&&n&&(e.innerHTML="",e.appendChild(n)),i(l=h)}).catch(function(n){return d(n),a(n)})}:function(n){var t=n.split("?"),r=t[0],u=t[1],f=p(u||""),a=v(r);if(a){var c={params:a.params,query:f,path:r,meta:a.route.meta};try{if(!o(c,l))return;window.location.hash=u?"".concat(r,"?").concat(u):r;var s=a.route.handler(c);e&&s&&"function"!=typeof s.then&&(e.innerHTML="",e.appendChild(s)),i(l=c)}catch(n){d(n)}}else d(new Error("Route not found: ".concat(r)))},h=function(){return m(window.location.hash.slice(1)||"/")};return{start:function(){window.addEventListener("hashchange",h),h()},stop:function(){return window.removeEventListener("hashchange",h)},push:function(n){return m(n)},current:function(){return l}}},n.div=R,n.form=S,n.h=O,n.h1=M,n.h2=T,n.h3=q,n.h4=C,n.h5=N,n.h6=I,n.img=Y,n.input=V,n.ktnull=t,n.label=H,n.li=D,n.ol=x,n.option=z,n.p=L,n.select=$,n.span=k,n.table=B,n.tbody=G,n.td=W,n.th=Q,n.thead=F,n.tr=J,n.ul=U,n}({});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var n=Object.freeze(Object.create(null)),t=Array.isArray,e=Array.prototype.filter,r=Object.
|
|
1
|
+
var n=Object.freeze(Object.create(null)),t=Array.isArray,e=Array.prototype.filter,r=Object.prototype.hasOwnProperty,o=Object.keys,u=function(){return{}},i="undefined"==typeof Promise?u:Promise.resolve,f="undefined"==typeof Promise?u:Promise.reject,a=document.createElement,c=document.createTextNode,d=document.createDocumentFragment,l=function(n){return void 0===n&&(n=""),c.call(document,n)},s=HTMLElement.prototype.addEventListener,v=HTMLElement.prototype.setAttribute,p=HTMLElement.prototype.appendChild,m=HTMLElement.prototype.append,h="function"==typeof m?function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return m.apply(this,e.call(t,function(t){return t!==n}))}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(t.length<50)for(var r=0;r<t.length;r++){"string"==typeof(u=t[r])?p.call(this,l(u)):u!==n&&p.call(this,u)}else{var o=d.call(document);for(r=0;r<t.length;r++){var u;"string"==typeof(u=t[r])?p.call(o,l(u)):u!==n&&p.call(o,u)}p.call(this,o)}},y=function(n){throw new Error("Kt.js:".concat(n))};function b(n,t,e){t in n?n[t]=!!e:v.call(n,t,e)}function w(n,t,e){t in n?n[t]=e:v.call(n,t,e)}var g={checked:b,selected:b,value:w,valueAsDate:w,valueAsNumber:w,defaultValue:w,defaultChecked:b,defaultSelected:b,disabled:b,readOnly:b,multiple:b,required:b,autofocus:b,open:b,controls:b,autoplay:b,loop:b,muted:b,defer:b,async:b,hidden:function(n,t,e){n.hidden=!!e}},E=function(n,t,e){return v.call(n,t,e)};function j(n,t){"string"==typeof t?n.className=t:"object"==typeof t&&null!==t?function(n,t){var e=t.class,u=t.style;if(void 0!==e&&(n.className=e,delete t.class),u){if("string"==typeof u)v.call(n,"style",u);else if("object"==typeof u)for(var i in u)r.call(n.style,i)&&(n.style[i]=u[i]);delete t.style}for(var f=o(t),a=f.length-1;a>=0;a--){var c=t[i=f[a]];"function"!=typeof c?(g[i]||E)(n,i,c):s.call(n,i,c)}void 0!==e&&(t.style=e),void 0!==u&&(t.style=u)}(n,t):y("applyAttr attr must be an object.")}function A(n,e,r){void 0===e&&(e=""),void 0===r&&(r=""),"string"!=typeof n&&y("h tagName must be a string.");var o,u=(o=n,a.call(document,o));return j(u,e),function(n,e){t(e)?h.apply(n,e):h.call(n,e)}(u,r),u}var O=function(n){return function(t,e){return A(n,t,e)}},P=O("div"),R=O("span"),H=O("label"),L=O("p"),M=O("h1"),T=O("h2"),k=O("h3"),q=O("h4"),C=O("h5"),N=O("h6"),x=O("ul"),I=O("ol"),U=O("li"),D=O("button"),K=O("form"),S=O("input"),V=O("select"),$=O("option"),z=O("table"),B=O("thead"),F=O("tbody"),G=O("tr"),J=O("th"),Q=O("td"),W=O("a"),X=O("img"),Y=function(){return!0};function Z(n){var t=n.routes,e=n.container,r=n.beforeEach,o=void 0===r?Y:r,u=n.afterEach,a=void 0===u?Y:u,c=n.onError,d=void 0===c?console.error:c,l=null,s=t.map(function(n){var t=[],e=n.path.replace(/\/:([^/]+)/g,function(n,e){return t.push(e),"/([^/]+)"});return{route:n,pattern:new RegExp("^".concat(e,"$")),names:t}}),v=function(n){for(var t=0;t<s.length;t++){var e=s[t],r=e.route,o=e.pattern,u=e.names,i=n.match(o);if(i){for(var f={},a=0;a<u.length;a++)f[u[a]]=i[a+1];return{route:r,params:f}}}return null},p=function(n){var t={};if(!n)return t;for(var e=(0===n.indexOf("?")?n.slice(1):n).split("&"),r=0;r<e.length;r++){var o=e[r].split("="),u=o[0];u&&(t[decodeURIComponent(u)]=decodeURIComponent(o[1]||""))}return t},m="undefined"!=typeof Promise?function(n){var t=n.split("?"),r=t[0],u=t[1],c=p(u||""),s=v(r);if(!s){var m=new Error("Route not found: ".concat(r));return d(m),f(m)}var h={params:s.params,query:c,path:r,meta:s.route.meta};return i(o(h,l)).then(function(n){return n?(window.location.hash=u?"".concat(r,"?").concat(u):r,s.route.handler(h)):f(new Error("Navigation blocked by guard"))}).then(function(n){e&&n&&(e.innerHTML="",e.appendChild(n)),a(l=h)}).catch(function(n){return d(n),f(n)})}:function(n){var t=n.split("?"),r=t[0],u=t[1],i=p(u||""),f=v(r);if(f){var c={params:f.params,query:i,path:r,meta:f.route.meta};try{if(!o(c,l))return;window.location.hash=u?"".concat(r,"?").concat(u):r;var s=f.route.handler(c);e&&s&&"function"!=typeof s.then&&(e.innerHTML="",e.appendChild(s)),a(l=c)}catch(n){d(n)}}else d(new Error("Route not found: ".concat(r)))},h=function(){return m(window.location.hash.slice(1)||"/")};return{start:function(){window.addEventListener("hashchange",h),h()},stop:function(){return window.removeEventListener("hashchange",h)},push:function(n){return m(n)},current:function(){return l}}}export{W as a,D as btn,Z as createRouter,P as div,K as form,A as h,M as h1,T as h2,k as h3,q as h4,C as h5,N as h6,X as img,S as input,n as ktnull,H as label,U as li,I as ol,$ as option,L as p,V as select,R as span,z as table,F as tbody,Q as td,J as th,B as thead,G as tr,x as ul};
|