@popmelt.com/core 0.8.14 → 0.8.15
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/bridge-entry.mjs +65 -57
- package/dist/canvas.mjs +1 -1
- package/dist/chunk-U35GCRMU.mjs +1 -0
- package/dist/cli.mjs +59 -51
- package/dist/index.mjs +64 -41
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-next.mjs +1 -1
- package/dist/plugin-vite.mjs +1 -1
- package/dist/server-LYQ2TJFR.mjs +221 -0
- package/dist/server.d.mts +3 -1
- package/dist/server.mjs +60 -52
- package/package.json +1 -1
- package/dist/chunk-JJEESG5Y.mjs +0 -1
- package/dist/server-SESHQYMR.mjs +0 -213
package/dist/plugin-astro.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as d,b as l,c as g,d as u}from"./chunk-U35GCRMU.mjs";import"./chunk-NOHXTT24.mjs";import{Buffer as m}from"buffer";function c(t){return typeof t=="string"?t:t instanceof Uint8Array?m.from(t).toString("utf8"):String(t??"")}function f(t,e,r,i){let s=t.url||"";if(r.port===null||!(t.headers.accept?.includes("text/html")||s==="/"||s.endsWith(".html")))return;let o=e.write.bind(e),a=e.end.bind(e),n="";e.write=(p=>(n+=c(p),!0)),e.end=(p=>(p!==void 0&&(n+=c(p)),n=n.replace("<head>",`<head><script type="text/javascript">${u(r,i)}</script>`),e.getHeader("content-length")&&e.setHeader("content-length",m.byteLength(n)),o(n,"utf8"),a()))}function h(t){let e=t?.basePath??"/popmelt",r={port:null,projectId:null};return{name:"popmelt",hooks:{async"astro:server:setup"({server:i}){r=await d(t,i,4321),await l(r,i);let s=g(e,()=>r);i.middlewares.use((o,a,n)=>{if((o.url||"").startsWith(e))return s(o,a,n);f(o,a,r,e),n()})}}}}export{h as popmelt};
|
package/dist/plugin-next.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NextResponse as v}from"next/server";function
|
|
1
|
+
import{NextResponse as v}from"next/server";function U(e){return S(e).slice(0,12)}var M=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function S(e){let t=typeof TextEncoder<"u"?Array.from(new TextEncoder().encode(e)):G(e),s=t.length*8;for(t.push(128);t.length%64!==56;)t.push(0);for(let u=7;u>=0;u--)t.push(s/Math.pow(2,u*8)&255);let n=1779033703,a=3144134277,r=1013904242,l=2773480762,c=1359893119,i=2600822924,b=528734635,R=1541459225,x=new Array(64);for(let u=0;u<t.length;u+=64){for(let o=0;o<16;o++){let m=u+o*4;x[o]=(t[m]<<24|t[m+1]<<16|t[m+2]<<8|t[m+3])>>>0}for(let o=16;o<64;o++){let m=p(x[o-15],7)^p(x[o-15],18)^x[o-15]>>>3,E=p(x[o-2],17)^p(x[o-2],19)^x[o-2]>>>10;x[o]=x[o-16]+m+x[o-7]+E>>>0}let f=n,g=a,P=r,I=l,d=c,w=i,y=b,j=R;for(let o=0;o<64;o++){let m=p(d,6)^p(d,11)^p(d,25),E=d&w^~d&y,$=j+m+E+M[o]+x[o]>>>0,B=p(f,2)^p(f,13)^p(f,22),O=f&g^f&P^g&P,L=B+O>>>0;j=y,y=w,w=d,d=I+$>>>0,I=P,P=g,g=f,f=$+L>>>0}n=n+f>>>0,a=a+g>>>0,r=r+P>>>0,l=l+I>>>0,c=c+d>>>0,i=i+w>>>0,b=b+y>>>0,R=R+j>>>0}return[n,a,r,l,c,i,b,R].map(u=>u.toString(16).padStart(8,"0")).join("")}function p(e,t){return e>>>t|e<<32-t}function G(e){let t=[];for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);n<128?t.push(n):n<2048?t.push(192|n>>6,128|n&63):t.push(224|n>>12,128|n>>6&63,128|n&63)}return t}function A(){if(process.env.POPMELT_BRIDGE_URL)try{let e=new URL(process.env.POPMELT_BRIDGE_URL).port;if(e)return parseInt(e,10)}catch{}return parseInt(process.env.POPMELT_BRIDGE_PORT||"1111",10)}var F=1111,k=10,N=1e3,h=null;function _(){try{return typeof process<"u"&&typeof process.cwd=="function"?process.cwd():null}catch{return null}}function C(e=_()??void 0){return process.env.POPMELT_PROJECT_ID||(e?U(e):null)}async function T(e,t){let s=new AbortController,n=setTimeout(()=>s.abort(),350);try{let a=new URL("/status",`http://localhost:${e}`);t&&a.searchParams.set("projectId",t);let r=await fetch(a,{signal:s.signal,cache:"no-store"});if(!r.ok)return null;let l=await r.json();return t&&l.projectId!==t?null:l}catch{return null}finally{clearTimeout(n)}}async function D(e,t){let s=Date.now();if(h&&h.preferredPort===e&&h.projectId===t&&h.expiresAt>s)return h.port;if(await T(e,t))return h={preferredPort:e,projectId:t,port:e,expiresAt:s+N},e;if(!t)return e;let a=Array.from({length:k},(i,b)=>F+b).filter(i=>i!==e),c=(await Promise.all(a.map(async i=>await T(i,t)?i:null))).find(i=>i!==null)??e;return h={preferredPort:e,projectId:t,port:c,expiresAt:s+N},c}async function H(e,t,s){let n=await D(t,s),a=new URL(e,`http://localhost:${n}`);return s&&a.searchParams.set("projectId",s),v.rewrite(a)}function K(e,t){let s=t?.basePath??"/popmelt",n=t?.port??A(),a=t?.projectId??C(t?.projectRoot??_()??void 0);if(e.nextUrl.searchParams.get("popmelt")==="canvas"){if(process.env.NODE_ENV==="production")return null;let r=new Headers(e.headers);return r.set("x-popmelt-canvas","1"),v.next({request:{headers:r}})}if(e.nextUrl.pathname.startsWith(s+"/render")){if(process.env.NODE_ENV==="production")return null;let r=new Headers(e.headers);return r.set("x-popmelt-canvas","1"),v.next({request:{headers:r}})}if(e.nextUrl.pathname===s||e.nextUrl.pathname.startsWith(s+"/")){let r=e.nextUrl.pathname.slice(s.length),l=r===""||r==="/"?"/canvas":r==="/manifest"||r==="/app.mjs"?`/canvas${r}`:r;return H(l,n,a)}return null}function X(e,t){if(process.env.NODE_ENV==="production")return e;let s=t?.port??A(),n=t?.projectId??C(t?.projectRoot??_()??void 0),a=e.rewrites;return{...e,async rewrites(){let r=a?await a():[],c=`http://localhost:${await D(s,n)}`,i=[{source:"/popmelt/status",destination:n?`${c}/status?projectId=${encodeURIComponent(n)}`:`${c}/status`},{source:"/popmelt",destination:n?`${c}/canvas?projectId=${encodeURIComponent(n)}`:`${c}/canvas`},{source:"/popmelt/manifest",destination:n?`${c}/canvas/manifest?projectId=${encodeURIComponent(n)}`:`${c}/canvas/manifest`},{source:"/popmelt/app.mjs",destination:n?`${c}/canvas/app.mjs?projectId=${encodeURIComponent(n)}`:`${c}/canvas/app.mjs`},{source:"/popmelt/:path*",destination:n?`${c}/:path*?projectId=${encodeURIComponent(n)}`:`${c}/:path*`}];return Array.isArray(r)?{beforeFiles:i,afterFiles:r,fallback:[]}:{...r,beforeFiles:[...r.beforeFiles||[],...i]}}}}export{C as getPopmeltProjectId,K as popmeltMiddleware,X as withPopmelt};
|
package/dist/plugin-vite.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as i,b as o,c as a,d}from"./chunk-U35GCRMU.mjs";import"./chunk-NOHXTT24.mjs";function s(r){let n=r?.basePath??"/popmelt",e={port:null,projectId:null};return{name:"popmelt",async configureServer(t){e=await i(r,t,5173),await o(e,t),t.middlewares.use(a(n,()=>e))},transformIndexHtml(){if(e.port!==null)return[{tag:"script",attrs:{type:"text/javascript"},children:d(e,n),injectTo:"head-prepend"}]}}}export{s as popmelt};
|