laybot-vite-dev 1.0.3 → 1.0.5

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 d=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/"]});function m(s){let n=[],u=new Set;for(let r of s||[]){let o=String(r||"").trim();o&&(u.has(o)||(u.add(o),n.push(o)))}return n}function l(s,n){return s+(n?`?${n}`:"")}function b(s={}){let n=s.prefixes||s.toSrcPrefixes||[],u=s.strip||s.stripPrefixes||[],r={...d,...s,toSrcPrefixes:m([...d.toSrcPrefixes,...n]),stripPrefixes:m([...d.stripPrefixes,...u])},o=(...h)=>{r.debug&&console.log("[laybot-vite-dev]",...h)};return{name:"laybot-vite-dev",enforce:"pre",configureServer(h){h.middlewares.use((e,p,c)=>{let f=e.url||"/",[t,a=""]=f.split("?");if((e.headers.upgrade||"").toLowerCase()==="websocket"||t==="/vite-hmr"||t==="/__vite_ping"||t.startsWith("/@vite")||t.startsWith("/@id")||t.startsWith("/@fs")||t.startsWith("/__vite")||t==="/favicon.ico")return c();if(t==="/"||t==="/index.html"){let i=`${r.viewsDir}/${r.htmlFallback}`;return e.url=l(i,a),o(f,"=>",e.url),c()}if(/\.html$/i.test(t)&&!t.startsWith(r.viewsDir+"/")){let i=`${r.viewsDir}${t}`;return e.url=l(i,a),o(f,"=>",e.url),c()}for(let i of r.stripPrefixes)if(i&&t.startsWith(i)){let v=t.slice(i.length-1),S=`${r.srcRoot}${v}`;return e.url=l(S,a),o(f,"=>",e.url),c()}for(let i of r.toSrcPrefixes)if(i&&t.startsWith(i)){let v=`${r.srcRoot}${t}`;return e.url=l(v,a),o(f,"=>",e.url),c()}return c()})}}}export{b 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/","/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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "laybot-vite-dev",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Vite dev rewrite plugin for LayBot/LarryMS MPA runtime loader",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",