@dlightjs/components
Advanced tools
Comparing version 1.0.0-alpha.22 to 1.0.0-alpha.23
@@ -1,2 +0,2 @@ | ||
var w=Object.defineProperty;var b=(r,t,a)=>t in r?w(r,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[t]=a;var v=(r,t,a)=>(b(r,typeof t!="symbol"?t+"":t,a),a);function $(){return location.hash.slice(2)}function f(){return location.pathname.slice(1)}function m(r,t){let a;if(r[0]==="/")a=r;else{r[0]!=="."&&(r="./"+r);let n=t==="history"?window.location.pathname:window.location.hash.replace(/^#/,""),e=r.split("/"),l=n.split("/").filter(u=>u),s=0;for(let u of e){if(![".",".."].includes(u))break;u===".."&&(l.length===0&&console.warn(`no ../ in ${r}`),l.pop()),s++}a="/"+[...l,...e.slice(s)].join("/")}return a}var i=class{mode;constructor(t="history"){this.mode=t}hashTo(t){window.location.href="#"+m(t,this.mode)}historyTo(t){window.history.pushState({},"",m(t,this.mode))}to(t){if(this.mode==="hash"){this.hashTo(t);return}this.historyTo(t)}};import{CondNode as U,EnvNode as L,ExpNode as P,PropView as x}from"@dlightjs/dlight";import{View as R}from"@dlightjs/dlight";var y=null;var g=history.pushState,o=[],d=class extends R{constructor(){super(),this.historyChangeListen=this.historyChangeListen.bind(this),this.hashChangeListen=this.hashChangeListen.bind(this)}$p$routeMap;_$contentKey="routeMap";$routeMap=y;$$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","watchPath","updateRoute"];get mode(){return this.$mode}set mode(t){this._$updateProp("mode",t)}$p$fallback;$fallback;$$fallback=4;$s$fallback=["updateRoute"];get fallback(){return this.$fallback}set fallback(t){this._$updateProp("fallback",t)}$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=["watchPath","updateRoute"];get currUrl(){return this.$currUrl}set currUrl(t){this._$updateProp("currUrl",t)}get $f$currUrl(){return this.mode==="hash"?$():f()}$p$onPathUpdate;$onPathUpdate;$$onPathUpdate=32;$s$onPathUpdate=["watchPath"];get onPathUpdate(){return this.$onPathUpdate}set onPathUpdate(t){this._$updateProp("onPathUpdate",t)}$w$watchPath;watchPath(){this.onPathUpdate?.(this.currUrl)}$prevPathCondition;$$prevPathCondition=64;get prevPathCondition(){return this.$prevPathCondition}set prevPathCondition(t){this._$updateProp("prevPathCondition",t)}$currentRoute={view:null,type:"view"};$$currentRoute=128;get currentRoute(){return this.$currentRoute}set currentRoute(t){this._$updateProp("currentRoute",t)}$navigator=new i;$$navigator=256;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[a,n]of Object.entries(this.routeMap)){let e=!1;if(d.regPathTest.test(a))e=new RegExp(a.replace(d.regPathTest,"$1")).test(t);else{let l=a.replace(/^(\.\/)+/,""),s=l==="."&&t==="",u=(t+"/").startsWith(l+"/");e=s||u||l==="*"}if(e){if(a===this.prevPathCondition)return;this.prevPathCondition=a,"propViewFunc"in n?this.currentRoute={view:n,type:"view"}:(this.fallback&&(this.currentRoute={view:this.fallback,type:"view"}),n().then(l=>{this.currentRoute={view:l.default,type:"lazy"}}));return}}}historyChangeListen(){this.currUrl=f()}hashChangeListen(){this.currUrl=$()}willMount(){this.navigator.mode=this.mode}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,a,n){let e=t.apply(a,n);return o.forEach(l=>l()),e}})}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,a,n){let e=t.apply(a,n);return o.forEach(l=>l()),e}}):history.pushState=g}View(){let t=null,a=null;return this._$update=n=>{n&18&&t&&t.updateEnv("path",this.currUrl),n&72&&t&&t.updateEnv("_$baseUrl",`${this._$baseUrl}${this.prevPathCondition}/`),n&128&&a&&a.updateCond(),n&256&&t&&t.updateEnv("navigator",this.navigator),a&&a.update(n)},t=new L({_$baseUrl:`${this._$baseUrl}${this.prevPathCondition}/`,path:this.currUrl,navigator:this.navigator}),a=new U(128),a.addCondFunc(n=>{if(this.currentRoute.type==="view"){if(n.cond===0)return n.didntChange=!0,[];n.cond=0;let e=null;return n.updateFunc=l=>{l&128&&e&&e.update()},e=new P(()=>this.currentRoute.view),n.cond===0?[e]:n.updateCond()}else{if(n.cond===1)return n.didntChange=!0,[];n.cond=1;let e=null,l=null;return n.updateFunc=s=>{s&128&&l&&l.update(),e&&e.update(s)},e=new x(s=>{let u=null;return u=new this.currentRoute.view,u._$init(null,null,null,null),[u]}),l=new P(()=>e),n.cond===1?[l]:n.updateCond()}}),t.initNodes([a]),[t]}},h=d;v(h,"regPathTest",/^\/\/(.+?)\/\/$/);var _=h;import{CondNode as T,ExpNode as M,PropView as E}from"@dlightjs/dlight";import{View as C}from"@dlightjs/dlight";function Et(r,t){class a extends C{_$forwardProps;_$forwardPropsSet=new Set;_$forwardPropsId=[];$v;$$v=8;get v(){return this.$v}set v(e){this._$updateProp("v",e)}willMount(){r().then(e=>{this.v=e.default})}View(){let e=null;return this._$update=l=>{l&8&&e&&e.updateCond(),e&&e.update(l)},e=new T(8),e.addCondFunc(l=>{if(this.v){if(l.cond===0)return l.didntChange=!0,[];l.cond=0;let s=null,u=null;return l.updateFunc=p=>{p&8&&u&&u.update(),s&&s.update(p)},s=new E(p=>{let c=null;return c=new this.v,c._$init(null,null,null,this),[c]}),u=new M(()=>s),l.cond===0?[u]:l.updateCond()}else if(t){if(l.cond===1)return l.didntChange=!0,[];l.cond=1;let s=null;return l.updateFunc=u=>{},s=new t,s._$init(null,null,null,null),l.cond===1?[s]:l.updateCond()}else return l.cond===2?(l.didntChange=!0,[]):(l.cond=2,l.updateFunc=s=>{},l.cond===2?[]:l.updateCond())}),[e]}}return a}export{i as Navigator,_ as Routes,Et as lazy}; | ||
var U=Object.defineProperty;var L=(u,t,a)=>t in u?U(u,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):u[t]=a;var y=(u,t,a)=>(L(u,typeof t!="symbol"?t+"":t,a),a);function c(){return location.hash.slice(2)}function f(){return location.pathname.slice(1)}function m(u,t){let a;if(u[0]==="/")a=u;else{u[0]!=="."&&(u="./"+u);let n=t==="history"?window.location.pathname:window.location.hash.replace(/^#/,""),e=u.split("/"),l=n.split("/").filter(r=>r),s=0;for(let r of e){if(![".",".."].includes(r))break;r===".."&&(l.length===0&&console.warn(`no ../ in ${u}`),l.pop()),s++}a="/"+[...l,...e.slice(s)].join("/")}return a}var h=class{mode;constructor(t="history"){this.mode=t}hashTo(t){window.location.href="#"+m(t,this.mode)}historyTo(t){window.history.pushState({},"",m(t,this.mode))}to(t){if(this.mode==="hash"){this.hashTo(t);return}this.historyTo(t)}};import{CondNode as x,EnvNode as R,ExpNode as P,PropView as _}from"@dlightjs/dlight";import{View as T}from"@dlightjs/dlight";var w=null;var g=history.pushState,p=[],$=class extends T{constructor(){super(),this.historyChangeListen=this.historyChangeListen.bind(this),this.hashChangeListen=this.hashChangeListen.bind(this)}$p$routeMap;_$contentKey="routeMap";$routeMap=w;$$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","watchPath","updateRoute"];get mode(){return this.$mode}set mode(t){this._$updateProp("mode",t)}$p$fallback;$fallback;$$fallback=4;$s$fallback=["updateRoute"];get fallback(){return this.$fallback}set fallback(t){this._$updateProp("fallback",t)}$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=["watchPath","updateRoute"];get currUrl(){return this.$currUrl}set currUrl(t){this._$updateProp("currUrl",t)}get $f$currUrl(){return this.mode==="hash"?c():f()}$p$onPathUpdate;$onPathUpdate;$$onPathUpdate=32;$s$onPathUpdate=["watchPath"];get onPathUpdate(){return this.$onPathUpdate}set onPathUpdate(t){this._$updateProp("onPathUpdate",t)}$w$watchPath;watchPath(){this.onPathUpdate?.(this.currUrl)}$prevPathCondition;$$prevPathCondition=64;get prevPathCondition(){return this.$prevPathCondition}set prevPathCondition(t){this._$updateProp("prevPathCondition",t)}$currentRoute={view:null,type:"view"};$$currentRoute=128;get currentRoute(){return this.$currentRoute}set currentRoute(t){this._$updateProp("currentRoute",t)}$navigator=new h;$$navigator=256;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[a,n]of Object.entries(this.routeMap)){let e=!1;if($.regPathTest.test(a))e=new RegExp(a.replace($.regPathTest,"$1")).test(t);else{let l=a.replace(/^(\.\/)+/,""),s=l==="."&&t==="",r=(t+"/").startsWith(l+"/");e=s||r||l==="*"}if(e){if(a===this.prevPathCondition)return;this.prevPathCondition=a,"propViewFunc"in n?this.currentRoute={view:n,type:"view"}:(this.fallback&&(this.currentRoute={view:this.fallback,type:"view"}),n().then(l=>{this.currentRoute={view:l.default,type:"lazy"}}));return}}}historyChangeListen(){this.currUrl=f()}hashChangeListen(){this.currUrl=c()}willMount(){this.navigator.mode=this.mode}didMount(){if(this.mode==="hash"){addEventListener("load",this.hashChangeListen),addEventListener("hashchange",this.hashChangeListen);return}addEventListener("load",this.historyChangeListen),addEventListener("popstate",this.historyChangeListen),p.push(this.historyChangeListen),history.pushState=new Proxy(g,{apply(t,a,n){let e=t.apply(a,n);return p.forEach(l=>l()),e}})}willUnmount(){if(this.mode==="hash"){removeEventListener("load",this.hashChangeListen),removeEventListener("hashchange",this.hashChangeListen);return}removeEventListener("load",this.historyChangeListen),removeEventListener("popstate",this.historyChangeListen),p=p.filter(t=>t!==this.historyChangeListen),p.length>0?history.pushState=new Proxy(g,{apply(t,a,n){let e=t.apply(a,n);return p.forEach(l=>l()),e}}):history.pushState=g}View(){let t=null,a=null;return this._$update=(n,e,l,s)=>{n&18&&t&&t.updateEnv("path",this.currUrl),n&72&&t&&t.updateEnv("_$baseUrl",`${this._$baseUrl}${this.prevPathCondition}/`),n&128&&a&&a.updateCond(e,l,s),n&256&&t&&t.updateEnv("navigator",this.navigator),a&&a.update(n,e,l,s)},t=new R({_$baseUrl:`${this._$baseUrl}${this.prevPathCondition}/`,path:this.currUrl,navigator:this.navigator}),a=new x(128),a.addCondFunc(n=>{if(this.currentRoute.type==="view"){if(n.cond===0)return n.didntChange=!0,[];n.cond=0;let e=null;return n.updateFunc=(l,s,r,o)=>{l&128&&e&&e.update()},e=new P(()=>this.currentRoute.view),n.cond===0?[e]:n.updateCond($key,$prevValue,$newValue)}else{if(n.cond===1)return n.didntChange=!0,[];n.cond=1;let e=null,l=null;return n.updateFunc=(s,r,o,i)=>{s&128&&l&&l.update(),e&&e.update(s,r,o,i)},e=new _(s=>{let r=null;return r=new this.currentRoute.view,r._$init(null,null,null,null),[r]}),l=new P(()=>e),n.cond===1?[l]:n.updateCond($key,$prevValue,$newValue)}}),t.initNodes([a]),[t]}},d=$;y(d,"regPathTest",/^\/\/(.+?)\/\/$/);var M=d;import{CondNode as k,ExpNode as E,PropView as C}from"@dlightjs/dlight";import{View as V}from"@dlightjs/dlight";function Ct(u,t){class a extends V{_$forwardProps;_$forwardPropsSet=new Set;_$forwardPropsId=[];$v;$$v=8;get v(){return this.$v}set v(e){this._$updateProp("v",e)}willMount(){u().then(e=>{this.v=e.default})}View(){let e=null;return this._$update=(l,s,r,o)=>{l&8&&e&&e.updateCond(s,r,o),e&&e.update(l,s,r,o)},e=new k(8),e.addCondFunc(l=>{if(this.v){if(l.cond===0)return l.didntChange=!0,[];l.cond=0;let s=null,r=null;return l.updateFunc=(o,i,v,b)=>{o&8&&r&&r.update(),s&&s.update(o,i,v,b)},s=new C(o=>{let i=null;return i=new this.v,i._$init(null,null,null,this),[i]}),r=new E(()=>s),l.cond===0?[r]:l.updateCond($key,$prevValue,$newValue)}else if(t){if(l.cond===1)return l.didntChange=!0,[];l.cond=1;let s=null;return l.updateFunc=(r,o,i,v)=>{},s=new t,s._$init(null,null,null,null),l.cond===1?[s]:l.updateCond($key,$prevValue,$newValue)}else return l.cond===2?(l.didntChange=!0,[]):(l.cond=2,l.updateFunc=(s,r,o,i)=>{},l.cond===2?[]:l.updateCond($key,$prevValue,$newValue))}),[e]}}return a}export{h as Navigator,M as Routes,Ct as lazy}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@dlightjs/components", | ||
"version": "1.0.0-alpha.22", | ||
"version": "1.0.0-alpha.23", | ||
"description": "DLight components library", | ||
@@ -26,3 +26,3 @@ "author": { | ||
"@typescript-eslint/parser": "^6.16.0", | ||
"babel-preset-dlight": "1.0.0-alpha.27", | ||
"babel-preset-dlight": "1.0.0-alpha.31", | ||
"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.27" | ||
"vite-plugin-dlight": "1.0.0-alpha.31" | ||
}, | ||
"dependencies": { | ||
"@dlightjs/dlight": "1.0.0-alpha.46" | ||
"@dlightjs/dlight": "1.0.0-alpha.55" | ||
}, | ||
@@ -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
92276
83
+ Added@dlightjs/dlight@1.0.0-alpha.55(transitive)
- Removed@dlightjs/dlight@1.0.0-alpha.46(transitive)