laybot-vite-dev 1.0.5 → 1.0.7

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var l=Object.freeze({srcRoot:"/src",viewsDir:"/src/views",htmlFallback:"index.html",debug:!1,toSrcPrefixes:["/api/","/route/","/mock/","/store/","/utils/","/plugin/","/components/","/partials/","/laybot/","/static/","/app/","/platform/","/services/"],stripPrefixes:["/assets/"],backendPrefixes:[]});function m(t){let c=[],a=new Set;for(let d of t||[]){let e=String(d||"").trim();e&&(a.has(e)||(a.add(e),c.push(e)))}return c}function P(t){return t=String(t||"").trim(),t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")||(t=t+"/"),t):""}function h(t,c){return t+(c?`?${c}`:"")}function W(t={}){let c=t.prefixes||t.toSrcPrefixes||[],a=t.strip||t.stripPrefixes||[],d=t.backendPrefixes||t.passthroughPrefixes||[],e={...l,...t,toSrcPrefixes:m([...l.toSrcPrefixes,...c]),stripPrefixes:m([...l.stripPrefixes,...a]),backendPrefixes:m([...l.backendPrefixes,...d]).map(P)},f=(...x)=>{e.debug&&console.log("[laybot-vite-dev]",...x)};return{name:"laybot-vite-dev",enforce:"pre",configureServer(x){x.middlewares.use((i,p,o)=>{let n=i.url||"/",[r,u=""]=n.split("?");if((i.headers.upgrade||"").toLowerCase()==="websocket"||r==="/vite-hmr"||r==="/__vite_ping"||r.startsWith("/@vite")||r.startsWith("/@id")||r.startsWith("/@fs")||r.startsWith("/__vite")||r==="/favicon.ico")return o();if(r==="/"||r==="/index.html"){let s=`${e.viewsDir}/${e.htmlFallback}`;return i.url=h(s,u),f(n,"=>",i.url),o()}if(/\.html$/i.test(r)&&!r.startsWith(e.viewsDir+"/")&&!r.startsWith("/src/")&&!r.startsWith("/assets/")&&!r.startsWith("/components/")&&!r.startsWith("/partials/")&&!r.startsWith("/static/")){let s=`${e.viewsDir}${r}`;return i.url=h(s,u),f(n,"=>",i.url),o()}for(let s of e.stripPrefixes)if(s&&r.startsWith(s)){let b=r.slice(s.length-1),v=`${e.srcRoot}${b}`;return i.url=h(v,u),f(n,"=>",i.url),o()}for(let s of e.toSrcPrefixes)if(s&&r.startsWith(s)){let b=`${e.srcRoot}${r}`;return i.url=h(b,u),f(n,"=>",i.url),o()}for(let s of e.backendPrefixes)if(s&&r.startsWith(s))return o();return o()})}}}export{W as default};
1
+ var l=Object.freeze({srcRoot:"/src",viewsDir:"/src/views",htmlFallback:"index.html",debug:!1,toSrcPrefixes:["/api/","/route/","/mock/","/store/","/utils/","/plugin/","/components/","/partials/","/laybot/","/static/","/app/","/platform/","/service/"],stripPrefixes:["/assets/"],backendPrefixes:[]});function m(t){let c=[],a=new Set;for(let d of t||[]){let e=String(d||"").trim();e&&(a.has(e)||(a.add(e),c.push(e)))}return c}function P(t){return t=String(t||"").trim(),t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")||(t=t+"/"),t):""}function h(t,c){return t+(c?`?${c}`:"")}function W(t={}){let c=t.prefixes||t.toSrcPrefixes||[],a=t.strip||t.stripPrefixes||[],d=t.backendPrefixes||t.passthroughPrefixes||[],e={...l,...t,toSrcPrefixes:m([...l.toSrcPrefixes,...c]),stripPrefixes:m([...l.stripPrefixes,...a]),backendPrefixes:m([...l.backendPrefixes,...d]).map(P)},f=(...x)=>{e.debug&&console.log("[laybot-vite-dev]",...x)};return{name:"laybot-vite-dev",enforce:"pre",configureServer(x){x.middlewares.use((i,p,o)=>{let n=i.url||"/",[r,u=""]=n.split("?");if((i.headers.upgrade||"").toLowerCase()==="websocket"||r==="/vite-hmr"||r==="/__vite_ping"||r.startsWith("/@vite")||r.startsWith("/@id")||r.startsWith("/@fs")||r.startsWith("/__vite")||r==="/favicon.ico")return o();if(r==="/"||r==="/index.html"){let s=`${e.viewsDir}/${e.htmlFallback}`;return i.url=h(s,u),f(n,"=>",i.url),o()}if(/\.html$/i.test(r)&&!r.startsWith(e.viewsDir+"/")&&!r.startsWith("/src/")&&!r.startsWith("/assets/")&&!r.startsWith("/components/")&&!r.startsWith("/partials/")&&!r.startsWith("/static/")){let s=`${e.viewsDir}${r}`;return i.url=h(s,u),f(n,"=>",i.url),o()}for(let s of e.stripPrefixes)if(s&&r.startsWith(s)){let b=r.slice(s.length-1),v=`${e.srcRoot}${b}`;return i.url=h(v,u),f(n,"=>",i.url),o()}for(let s of e.toSrcPrefixes)if(s&&r.startsWith(s)){let b=`${e.srcRoot}${r}`;return i.url=h(b,u),f(n,"=>",i.url),o()}for(let s of e.backendPrefixes)if(s&&r.startsWith(s))return o();return o()})}}}export{W as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "laybot-vite-dev",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Vite dev rewrite plugin for LayBot/LarryMS MPA runtime loader",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",