@dlightjs/components
Advanced tools
Comparing version 1.0.0-alpha.13 to 1.0.0-alpha.14
@@ -1,2 +0,2 @@ | ||
var w=Object.defineProperty;var P=(a,t,s)=>t in a?w(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s;var g=(a,t,s)=>(P(a,typeof t!="symbol"?t+"":t,s),s);function $(){return location.hash.slice(2)}function c(){return location.pathname.slice(1)}function f(a,t){let s;if(a[0]==="/")s=a;else{a[0]!=="."&&(a="./"+a);let e=t==="history"?window.location.pathname:window.location.hash.replace(/^#/,""),n=a.split("/"),l=e.split("/").filter(u=>u),r=0;for(let u of n){if(![".",".."].includes(u))break;u===".."&&(l.length===0&&console.warn(`no ../ in ${a}`),l.pop()),r++}s="/"+[...l,...n.slice(r)].join("/")}return s}var i=class{mode="hash";hashTo(t){window.location.href="#"+f(t,this.mode)}historyTo(t){window.history.pushState({},"",f(t,this.mode))}to(t){if(this.mode==="hash"){this.hashTo(t);return}this.historyTo(t)}};import{CondNode as b,EnvNode as L,ExpNode as y,PropView as M}from"@dlightjs/dlight";import{View as U}from"@dlightjs/dlight";var v=null;var m=history.pushState,o=[],d=class extends U{constructor(t,s,e,n){super(),this.historyChangeListen=this.historyChangeListen.bind(this),this.hashChangeListen=this.hashChangeListen.bind(this),this.willMount=this.willMount.bind(this),this.didMount=this.didMount.bind(this),this.willUnmount=this.willUnmount.bind(this),this._$init(t,s,e,n)}$p$routeMap;_$contentKey="routeMap";$routeMap=v;$$routeMap=1;$s$routeMap=["updateRoute"];get routeMap(){return this.$routeMap}set routeMap(t){this._$updateProp("routeMap",t)}$p$mode;$mode="history";$$mode=2;$s$mode=["currUrl","updateRoute"];get mode(){return this.$mode}set mode(t){this._$updateProp("mode",t)}$p$getNavigator;getNavigator;$e$_$baseUrl;$_$baseUrl="";$$_$baseUrl=8;$s$_$baseUrl=["updateRoute"];get _$baseUrl(){return this.$_$baseUrl}set _$baseUrl(t){this._$updateProp("_$baseUrl",t)}$currUrl;$$currUrl=16;$s$currUrl=["updateRoute"];get currUrl(){return this.$currUrl}set currUrl(t){this._$updateProp("currUrl",t)}get $f$currUrl(){return this.mode==="hash"?$():c()}$prevPathCondition;$$prevPathCondition=32;get prevPathCondition(){return this.$prevPathCondition}set prevPathCondition(t){this._$updateProp("prevPathCondition",t)}$currentRoute={view:null,type:"view"};$$currentRoute=64;get currentRoute(){return this.$currentRoute}set currentRoute(t){this._$updateProp("currentRoute",t)}$navigator=new i;$$navigator=128;get navigator(){return this.$navigator}set navigator(t){this._$updateProp("navigator",t)}isRoutes=!0;$w$updateRoute;updateRoute(){let t=this.currUrl.replace(new RegExp(`^${this._$baseUrl}`),"");for(let[s,e]of Object.entries(this.routeMap)){let n=!1;if(d.regPathTest.test(s))n=new RegExp(s.replace(d.regPathTest,"$1")).test(t);else{let l=s.replace(/^(\.\/)+/,""),r=l==="."&&t==="",u=(t+"/").startsWith(l+"/");n=r||u||l==="*"}if(n){if(s===this.prevPathCondition)return;this.prevPathCondition=s,"propViewFunc"in e?this.currentRoute={view:e,type:"view"}:e().then(l=>{this.currentRoute={view:l.default,type:"lazy"}});return}}}historyChangeListen(){this.currUrl=c()}hashChangeListen(){this.currUrl=$()}willMount(){this.navigator.mode=this.mode,this.getNavigator?.(this.navigator)}didMount(){if(this.mode==="hash"){addEventListener("load",this.hashChangeListen),addEventListener("hashchange",this.hashChangeListen);return}addEventListener("load",this.historyChangeListen),addEventListener("popstate",this.historyChangeListen),o.push(this.historyChangeListen),history.pushState=new Proxy(m,{apply(t,s,e){let n=t.apply(s,e);return o.forEach(l=>l()),n}})}willUnmount(){if(this.mode==="hash"){removeEventListener("load",this.hashChangeListen),removeEventListener("hashchange",this.hashChangeListen);return}removeEventListener("load",this.historyChangeListen),removeEventListener("popstate",this.historyChangeListen),o=o.filter(t=>t!==this.historyChangeListen),o.length>0?history.pushState=new Proxy(m,{apply(t,s,e){let n=t.apply(s,e);return o.forEach(l=>l()),n}}):history.pushState=m}View(){let t=new L({_$baseUrl:`${this._$baseUrl}${this.prevPathCondition}/`,path:this.currUrl,navigator:this.navigator}),s=new b(e=>{if(this.currentRoute.type==="view"){if(e.cond===0)return;let n=new y(()=>this.currentRoute.view);return n._$updateFunc=l=>{l&64&&n.update()},e.cond=0,[n]}else{if(e.cond===1)return;let n=new M(()=>[new this.currentRoute.view(null,null,null,null)]),l=new y(()=>n);return l._$updateFunc=r=>{r&64&&l.update(),n.update(r)},e.cond=1,[l]}});return t.initNodes([s]),this._$update=e=>{e&18&&t.updateEnv("path",this.currUrl),e&40&&t.updateEnv("_$baseUrl",`${this._$baseUrl}${this.prevPathCondition}/`),e&64&&s.updateCond(),e&128&&t.updateEnv("navigator",this.navigator),s.update(e)},[t]}},p=d;g(p,"regPathTest",/^\/\/(.+?)\/\/$/);var x=p;import{CondNode as _,ExpNode as C,PropView as T}from"@dlightjs/dlight";import{View as R}from"@dlightjs/dlight";function _t(a,t){class s extends R{constructor(n,l,r,u){super(),this.willMount=this.willMount.bind(this),this._$init(n,l,r,u)}_$forwardProps;_$forwardPropsSet=new Set;_$forwardPropsId=[];$v;$$v=8;get v(){return this.$v}set v(n){this._$updateProp("v",n)}willMount(){a().then(n=>{this.v=n.default})}View(){let n=new _(l=>{if(this.v){if(l.cond===0)return;let r=new T(()=>[new this.v(null,null,null,this)]),u=new C(()=>r);return u._$updateFunc=h=>{h&8&&u.update(),r.update(h)},l.cond=0,[u]}else if(t){if(l.cond===1)return;let r=new t(null,null,null,null);return l.cond=1,[r]}else return l.cond=-1,[]});return this._$update=l=>{l&8&&n.updateCond(),n.update(l)},[n]}}return s}export{i as Navigator,x as Routes,_t as lazy}; | ||
var w=Object.defineProperty;var P=(a,t,e)=>t in a?w(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var m=(a,t,e)=>(P(a,typeof t!="symbol"?t+"":t,e),e);function $(){return location.hash.slice(2)}function c(){return location.pathname.slice(1)}function f(a,t){let e;if(a[0]==="/")e=a;else{a[0]!=="."&&(a="./"+a);let s=t==="history"?window.location.pathname:window.location.hash.replace(/^#/,""),n=a.split("/"),l=s.split("/").filter(u=>u),r=0;for(let u of n){if(![".",".."].includes(u))break;u===".."&&(l.length===0&&console.warn(`no ../ in ${a}`),l.pop()),r++}e="/"+[...l,...n.slice(r)].join("/")}return e}var i=class{mode="hash";hashTo(t){window.location.href="#"+f(t,this.mode)}historyTo(t){window.history.pushState({},"",f(t,this.mode))}to(t){if(this.mode==="hash"){this.hashTo(t);return}this.historyTo(t)}};import{CondNode as b,EnvNode as L,ExpNode as y,PropView as M}from"@dlightjs/dlight";import{View as U}from"@dlightjs/dlight";var v=null;var g=history.pushState,o=[],d=class extends U{constructor(t,e,s,n){super(),this.historyChangeListen=this.historyChangeListen.bind(this),this.hashChangeListen=this.hashChangeListen.bind(this),this.willMount=this.willMount.bind(this),this.didMount=this.didMount.bind(this),this.willUnmount=this.willUnmount.bind(this),this._$init(t,e,s,n)}$p$routeMap;_$contentKey="routeMap";$routeMap=v;$$routeMap=1;$s$routeMap=["updateRoute"];get routeMap(){return this.$routeMap}set routeMap(t){this._$updateProp("routeMap",t)}$p$mode;$mode="history";$$mode=2;$s$mode=["currUrl","updateRoute"];get mode(){return this.$mode}set mode(t){this._$updateProp("mode",t)}$p$getNavigator;getNavigator;$e$_$baseUrl;$_$baseUrl="";$$_$baseUrl=8;$s$_$baseUrl=["updateRoute"];get _$baseUrl(){return this.$_$baseUrl}set _$baseUrl(t){this._$updateProp("_$baseUrl",t)}$currUrl;$$currUrl=16;$s$currUrl=["updateRoute"];get currUrl(){return this.$currUrl}set currUrl(t){this._$updateProp("currUrl",t)}get $f$currUrl(){return this.mode==="hash"?$():c()}$prevPathCondition;$$prevPathCondition=32;get prevPathCondition(){return this.$prevPathCondition}set prevPathCondition(t){this._$updateProp("prevPathCondition",t)}$currentRoute={view:null,type:"view"};$$currentRoute=64;get currentRoute(){return this.$currentRoute}set currentRoute(t){this._$updateProp("currentRoute",t)}$navigator=new i;$$navigator=128;get navigator(){return this.$navigator}set navigator(t){this._$updateProp("navigator",t)}isRoutes=!0;$w$updateRoute;updateRoute(){let t=this.currUrl.replace(new RegExp(`^${this._$baseUrl}`),"");for(let[e,s]of Object.entries(this.routeMap)){let n=!1;if(d.regPathTest.test(e))n=new RegExp(e.replace(d.regPathTest,"$1")).test(t);else{let l=e.replace(/^(\.\/)+/,""),r=l==="."&&t==="",u=(t+"/").startsWith(l+"/");n=r||u||l==="*"}if(n){if(e===this.prevPathCondition)return;this.prevPathCondition=e,"propViewFunc"in s?this.currentRoute={view:s,type:"view"}:s().then(l=>{this.currentRoute={view:l.default,type:"lazy"}});return}}}historyChangeListen(){this.currUrl=c()}hashChangeListen(){this.currUrl=$()}willMount(){this.navigator.mode=this.mode,this.getNavigator?.(this.navigator)}didMount(){if(this.mode==="hash"){addEventListener("load",this.hashChangeListen),addEventListener("hashchange",this.hashChangeListen);return}addEventListener("load",this.historyChangeListen),addEventListener("popstate",this.historyChangeListen),o.push(this.historyChangeListen),history.pushState=new Proxy(g,{apply(t,e,s){let n=t.apply(e,s);return o.forEach(l=>l()),n}})}willUnmount(){if(this.mode==="hash"){removeEventListener("load",this.hashChangeListen),removeEventListener("hashchange",this.hashChangeListen);return}removeEventListener("load",this.historyChangeListen),removeEventListener("popstate",this.historyChangeListen),o=o.filter(t=>t!==this.historyChangeListen),o.length>0?history.pushState=new Proxy(g,{apply(t,e,s){let n=t.apply(e,s);return o.forEach(l=>l()),n}}):history.pushState=g}View(){let t=new L({_$baseUrl:`${this._$baseUrl}${this.prevPathCondition}/`,path:this.currUrl,navigator:this.navigator}),e=new b(s=>{if(this.currentRoute.type==="view"){if(s.cond===0)return s.didntChange=!0,[];let n=new y(()=>this.currentRoute.view);return n._$updateFunc=l=>{l&64&&n.update()},s.cond=0,[n]}else{if(s.cond===1)return s.didntChange=!0,[];let n=new M(()=>[new this.currentRoute.view(null,null,null,null)]),l=new y(()=>n);return l._$updateFunc=r=>{r&64&&l.update(),n.update(r)},s.cond=1,[l]}},64);return t.initNodes([e]),this._$update=s=>{s&18&&t.updateEnv("path",this.currUrl),s&40&&t.updateEnv("_$baseUrl",`${this._$baseUrl}${this.prevPathCondition}/`),s&64&&e.updateCond(),s&128&&t.updateEnv("navigator",this.navigator),e.update(s)},[t]}},p=d;m(p,"regPathTest",/^\/\/(.+?)\/\/$/);var x=p;import{CondNode as _,ExpNode as C,PropView as T}from"@dlightjs/dlight";import{View as R}from"@dlightjs/dlight";function _t(a,t){class e extends R{constructor(n,l,r,u){super(),this.willMount=this.willMount.bind(this),this._$init(n,l,r,u)}_$forwardProps;_$forwardPropsSet=new Set;_$forwardPropsId=[];$v;$$v=8;get v(){return this.$v}set v(n){this._$updateProp("v",n)}willMount(){a().then(n=>{this.v=n.default})}View(){let n=new _(l=>{if(this.v){if(l.cond===0)return l.didntChange=!0,[];let r=new T(()=>[new this.v(null,null,null,this)]),u=new C(()=>r);return u._$updateFunc=h=>{h&8&&u.update(),r.update(h)},l.cond=0,[u]}else if(t){if(l.cond===1)return l.didntChange=!0,[];let r=new t(null,null,null,null);return l.cond=1,[r]}else return l.cond=-1,[]},8);return this._$update=l=>{l&8&&n.updateCond(),n.update(l)},[n]}}return e}export{i as Navigator,x as Routes,_t as lazy}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@dlightjs/components", | ||
"version": "1.0.0-alpha.13", | ||
"version": "1.0.0-alpha.14", | ||
"description": "DLight components library", | ||
@@ -26,3 +26,3 @@ "author": { | ||
"@typescript-eslint/parser": "^6.16.0", | ||
"babel-preset-dlight": "1.0.0-alpha.14", | ||
"babel-preset-dlight": "1.0.0-alpha.15", | ||
"eslint": "^8.56.0", | ||
@@ -35,6 +35,6 @@ "eslint-config-prettier": "^9.1.0", | ||
"vite": "^4.5.1", | ||
"vite-plugin-dlight": "1.0.0-alpha.14" | ||
"vite-plugin-dlight": "1.0.0-alpha.15" | ||
}, | ||
"dependencies": { | ||
"@dlightjs/dlight": "1.0.0-alpha.22" | ||
"@dlightjs/dlight": "1.0.0-alpha.23" | ||
}, | ||
@@ -41,0 +41,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
85039
75
+ Added@dlightjs/dlight@1.0.0-alpha.23(transitive)
- Removed@dlightjs/dlight@1.0.0-alpha.22(transitive)