@popmelt.com/core 0.11.3 → 0.12.0

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.
@@ -1 +1 @@
1
- import{a as p,b as d,c as l,d as g}from"./chunk-6UUYBXUW.mjs";import"./chunk-NOHXTT24.mjs";import{Buffer as c}from"buffer";function u(e){return typeof e=="string"?e:e instanceof Uint8Array?c.from(e).toString("utf8"):String(e??"")}function m(e,t,r){let o=e.url||"";if(r.port===null||!(e.headers.accept?.includes("text/html")||o==="/"||o.endsWith(".html")))return;let a=t.write.bind(t),s=t.end.bind(t),n="";t.write=(i=>(n+=u(i),!0)),t.end=(i=>(i!==void 0&&(n+=u(i)),n=n.replace("<head>",`<head><script type="text/javascript">${g(r)}</script>`),t.getHeader("content-length")&&t.setHeader("content-length",c.byteLength(n)),a(n,"utf8"),s()))}function y(e){let t=e?.basePath??"/popmelt",r={port:null,projectId:null};return{name:"popmelt",hooks:{async"astro:server:setup"({server:o}){r=await p(e,o,4321),await d(r,o);let a=l(t,()=>r);o.middlewares.use((s,n,i)=>{if((s.url||"").startsWith(t))return a(s,n,i);m(s,n,r),i()})}}}}export{y as popmelt};
1
+ import{a as p,b as d,c as l,d as g}from"./chunk-AGGSNB3B.mjs";import"./chunk-NOHXTT24.mjs";import{Buffer as c}from"buffer";function u(e){return typeof e=="string"?e:e instanceof Uint8Array?c.from(e).toString("utf8"):String(e??"")}function m(e,t,r){let o=e.url||"";if(r.port===null||!(e.headers.accept?.includes("text/html")||o==="/"||o.endsWith(".html")))return;let a=t.write.bind(t),s=t.end.bind(t),n="";t.write=(i=>(n+=u(i),!0)),t.end=(i=>(i!==void 0&&(n+=u(i)),n=n.replace("<head>",`<head><script type="text/javascript">${g(r)}</script>`),t.getHeader("content-length")&&t.setHeader("content-length",c.byteLength(n)),a(n,"utf8"),s()))}function y(e){let t=e?.basePath??"/popmelt",r={port:null,projectId:null};return{name:"popmelt",hooks:{async"astro:server:setup"({server:o}){r=await p(e,o,4321),await d(r,o);let a=l(t,()=>r);o.middlewares.use((s,n,i)=>{if((s.url||"").startsWith(t))return a(s,n,i);m(s,n,r),i()})}}}}export{y as popmelt};
@@ -0,0 +1,40 @@
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+
3
+ declare function getPopmeltProjectId(projectRoot?: string): string | null;
4
+ /**
5
+ * Popmelt middleware handler for Next.js.
6
+ * Call at the top of your middleware function to expose the project-scoped
7
+ * /popmelt/status bootstrap used by the embedded toolbar.
8
+ *
9
+ * Returns a Response if the request was handled, or null if it should continue
10
+ * to your normal middleware logic.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { popmeltMiddleware } from '@popmelt.com/core/next';
15
+ *
16
+ * export async function middleware(request: NextRequest) {
17
+ * const popmeltResponse = popmeltMiddleware(request);
18
+ * if (popmeltResponse) return popmeltResponse;
19
+ *
20
+ * // ... your normal middleware logic
21
+ * }
22
+ * ```
23
+ */
24
+ declare function popmeltMiddleware(request: NextRequest, options?: {
25
+ port?: number;
26
+ basePath?: string;
27
+ projectRoot?: string;
28
+ projectId?: string;
29
+ }): NextResponse | Promise<NextResponse> | null;
30
+ type NextConfig = {
31
+ rewrites?: () => Promise<any> | any;
32
+ [key: string]: any;
33
+ };
34
+ declare function withPopmelt(config: NextConfig, options?: {
35
+ port?: number;
36
+ projectRoot?: string;
37
+ projectId?: string;
38
+ }): NextConfig;
39
+
40
+ export { getPopmeltProjectId, popmeltMiddleware, withPopmelt };
@@ -1 +1 @@
1
- import{a as n,b as i,c as o,d as a}from"./chunk-6UUYBXUW.mjs";import"./chunk-NOHXTT24.mjs";function s(r){let d=r?.basePath??"/popmelt",e={port:null,projectId:null};return{name:"popmelt",async configureServer(t){e=await n(r,t,5173),await i(e,t),t.middlewares.use(o(d,()=>e))},transformIndexHtml(){if(e.port!==null)return[{tag:"script",attrs:{type:"text/javascript"},children:a(e),injectTo:"head-prepend"}]}}}export{s as popmelt};
1
+ import{a as n,b as i,c as o,d as a}from"./chunk-AGGSNB3B.mjs";import"./chunk-NOHXTT24.mjs";function s(r){let d=r?.basePath??"/popmelt",e={port:null,projectId:null};return{name:"popmelt",async configureServer(t){e=await n(r,t,5173),await i(e,t),t.middlewares.use(o(d,()=>e))},transformIndexHtml(){if(e.port!==null)return[{tag:"script",attrs:{type:"text/javascript"},children:a(e),injectTo:"head-prepend"}]}}}export{s as popmelt};