@lunora/platform-node 1.0.0-alpha.156 → 1.0.0-alpha.157
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/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NODE_SCHEDULER_DISPATCH_PATH as r,createNodeDispatchRoute as t}from"./packem_shared/NODE_SCHEDULER_DISPATCH_PATH-CNBAtztq.mjs";import{createNodeGlobalStore as d,createNodeSqlExec as c}from"./packem_shared/createNodeGlobalStore-DhHyIT8I.mjs";import{createNodeHttpServer as p}from"./packem_shared/createNodeHttpServer-
|
|
1
|
+
import{NODE_SCHEDULER_DISPATCH_PATH as r,createNodeDispatchRoute as t}from"./packem_shared/NODE_SCHEDULER_DISPATCH_PATH-CNBAtztq.mjs";import{createNodeGlobalStore as d,createNodeSqlExec as c}from"./packem_shared/createNodeGlobalStore-DhHyIT8I.mjs";import{createNodeHttpServer as p}from"./packem_shared/createNodeHttpServer-BmIbUCl7.mjs";import{createNodeShardKvStore as m}from"./packem_shared/createNodeShardKvStore-DVi1OsvH.mjs";import{createNodePlatform as S}from"./packem_shared/createNodePlatform-bL7EdY_5.mjs";import{createNodeProfileHandler as l}from"./packem_shared/createNodeProfileHandler-MX5xKPg0.mjs";import{createNodeQueueHost as h}from"./packem_shared/createNodeQueueHost-CttDb5sY.mjs";import{createNodeR2Bucket as k}from"./packem_shared/createNodeR2Bucket-6I2HobcB.mjs";import{createNodeSchedulerHost as E}from"./packem_shared/createNodeSchedulerHost-BIJ4H38-.mjs";import{createNodeShardHost as R}from"./packem_shared/createNodeShardHost-B6mt1S-h.mjs";import{createNodeShardNamespace as _}from"./packem_shared/createNodeShardNamespace-BgQjDv7V.mjs";import{createNodeShardRegistry as w}from"./packem_shared/createNodeShardRegistry-q-46Oj8M.mjs";import{createNodeShardState as C}from"./packem_shared/createNodeShardState-D6XMWbFs.mjs";import{createNodeSocketHost as W}from"./packem_shared/createNodeSocketHost-DQs85G7W.mjs";import{createNodeWorkflowHost as g}from"./packem_shared/createNodeWorkflowHost-B76TKiw_.mjs";import{createNodeWorkflowStore as q}from"./packem_shared/createNodeWorkflowStore-CL7RYP6H.mjs";export{r as NODE_SCHEDULER_DISPATCH_PATH,t as createNodeDispatchRoute,d as createNodeGlobalStore,p as createNodeHttpServer,S as createNodePlatform,l as createNodeProfileHandler,h as createNodeQueueHost,k as createNodeR2Bucket,E as createNodeSchedulerHost,R as createNodeShardHost,m as createNodeShardKvStore,_ as createNodeShardNamespace,w as createNodeShardRegistry,C as createNodeShardState,W as createNodeSocketHost,c as createNodeSqlExec,g as createNodeWorkflowHost,q as createNodeWorkflowStore};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createServer as f}from"node:http";const i=e=>e.includes(":")&&!e.startsWith("[")?`[${e}]`:e,p=e=>{const t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:")throw new RangeError(`origin must be an http or https URL, got scheme ${t.protocol}`);return t.origin},w=/^(?:127\.\d+\.\d+\.\d+|::1|localhost)$/,u=1048576,b=5e3,y=(e,t)=>{const n=e[Symbol.asyncIterator]();return new ReadableStream({cancel(){if(t.headersSent){e.destroy();return}if(e.complete){e.resume();return}let s=0,c=!1;const o=()=>{if(!e.complete){if(c=!0,t.writableFinished){e.destroy();return}e.removeAllListeners("readable"),e.pause()}},r=setTimeout(o,b),a=()=>{clearTimeout(r)};t.once("finish",()=>{c&&e.destroy()}),e.once("end",a),e.once("close",a),e.removeAllListeners("readable"),e.on("readable",()=>{let d=e.read();for(;d!==null;){if(s+=d.byteLength,s>u){o();return}d=e.read()}})},async pull(s){const c=await n.next();c.done?s.close():s.enqueue(c.value)}})},v=(e,t)=>{const n=new URL(e??"/",t),s=new URL(t);return s.pathname=n.pathname,s.search=n.search,s},R=(e,t,n,s)=>{const c=new Headers;for(const[a,d]of Object.entries(e.headers))if(Array.isArray(d))for(const l of d)c.append(a,l);else d!==void 0&&c.set(a,d);const o=e.method??"GET",r={headers:c,method:o,signal:s};return o!=="GET"&&o!=="HEAD"&&(r.body=y(e,t),r.duplex="half"),new Request(v(e.url,n),r)},S=e=>e.destroyed,E=async(e,t)=>{if(t.on("error",()=>{t.destroy()}),S(t)){await e.body?.cancel().catch(()=>{});return}const n={};e.headers.forEach((r,a)=>{a!=="set-cookie"&&(n[a]=r)});const s=e.headers.getSetCookie();if(s.length>0&&(n["set-cookie"]=s),t.writeHead(e.status,n),e.body===null){t.end();return}const c=e.body.getReader();t.once("close",()=>{c.cancel().catch(()=>{})});let o=await c.read();for(;!o.done&&!t.destroyed;)t.write(o.value)||await new Promise(r=>{const a=()=>{t.off("drain",a),t.off("close",a),r()};t.on("drain",a),t.on("close",a)}),o=await c.read();t.end()},H=async e=>{const t=e.host??"127.0.0.1",n=e.origin===void 0?void 0:p(e.origin);if(n===void 0&&!w.test(t))throw new Error(`createNodeHttpServer: host "${t}" is not a loopback address, so set origin to the public URL (e.g. https://app.example). Without it, browser requests fail the CSRF origin check and signed URLs point at the bound address.`);const s=f();s.on("request",(o,r)=>{const a=n??`http://${i(t)}:${String(s.address().port)}`,d=new AbortController;r.once("close",()=>{r.writableFinished||d.abort()});let l;try{l=R(o,r,a,d.signal)}catch{r.writeHead(400,{"content-type":"text/plain; charset=utf-8"}),r.end("Bad Request");return}Promise.resolve().then(()=>e.fetch(l)).then(h=>E(h,r),()=>{r.headersSent||r.writeHead(500,{"content-type":"text/plain; charset=utf-8"}),r.end("Internal Server Error")}).catch(()=>{r.destroy()})}),await new Promise((o,r)=>{s.once("error",r),s.listen(e.port??0,t,()=>{s.off("error",r),o()})});const{port:c}=s.address();return{close:()=>new Promise((o,r)=>{s.closeAllConnections(),s.close(a=>{a===void 0?o():r(a)})}),origin:`http://${i(t)}:${String(c)}`}};export{H as createNodeHttpServer};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/platform-node",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.157",
|
|
4
4
|
"description": "Node implementation of the Lunora platform contracts: ShardHost, SocketHost, ShardDirectory, ShardKvStore, SchedulerHost over better-sqlite3 and an in-process socket registry (dev/test target)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"better-sqlite3",
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@lunora/d1": "1.0.0-alpha.
|
|
49
|
+
"@lunora/d1": "1.0.0-alpha.188",
|
|
50
50
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
51
51
|
"@lunora/platform": "1.0.0-alpha.68",
|
|
52
|
-
"@lunora/queue": "1.0.0-alpha.
|
|
53
|
-
"@lunora/runtime": "1.0.0-alpha.
|
|
54
|
-
"@lunora/sql-store": "1.0.0-alpha.
|
|
55
|
-
"@lunora/workflow": "1.0.0-alpha.
|
|
52
|
+
"@lunora/queue": "1.0.0-alpha.114",
|
|
53
|
+
"@lunora/runtime": "1.0.0-alpha.216",
|
|
54
|
+
"@lunora/sql-store": "1.0.0-alpha.189",
|
|
55
|
+
"@lunora/workflow": "1.0.0-alpha.83",
|
|
56
56
|
"@visulima/cron-parser": "2.0.0",
|
|
57
57
|
"@visulima/workflow": "3.0.0",
|
|
58
58
|
"better-sqlite3": "^13.0.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createServer as f}from"node:http";const l=e=>e.includes(":")&&!e.startsWith("[")?`[${e}]`:e,w=e=>{const t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:")throw new RangeError(`origin must be an http or https URL, got scheme ${t.protocol}`);return t.origin},p=/^(?:127\.\d+\.\d+\.\d+|::1|localhost)$/,y=e=>{const t=e[Symbol.asyncIterator]();return new ReadableStream({cancel(){e.destroy()},async pull(o){const r=await t.next();r.done?o.close():o.enqueue(r.value)}})},b=(e,t)=>{const o=new URL(e??"/",t),r=new URL(t);return r.pathname=o.pathname,r.search=o.search,r},u=(e,t,o)=>{const r=new Headers;for(const[s,a]of Object.entries(e.headers))if(Array.isArray(a))for(const d of a)r.append(s,d);else a!==void 0&&r.set(s,a);const c=e.method??"GET",n={headers:r,method:c,signal:o};return c!=="GET"&&c!=="HEAD"&&(n.body=y(e),n.duplex="half"),new Request(b(e.url,t),n)},v=e=>e.destroyed,R=async(e,t)=>{if(t.on("error",()=>{t.destroy()}),v(t)){await e.body?.cancel().catch(()=>{});return}const o={};e.headers.forEach((s,a)=>{a!=="set-cookie"&&(o[a]=s)});const r=e.headers.getSetCookie();if(r.length>0&&(o["set-cookie"]=r),t.writeHead(e.status,o),e.body===null){t.end();return}const c=e.body.getReader();t.once("close",()=>{c.cancel().catch(()=>{})});let n=await c.read();for(;!n.done&&!t.destroyed;)t.write(n.value)||await new Promise(s=>{const a=()=>{t.off("drain",a),t.off("close",a),s()};t.on("drain",a),t.on("close",a)}),n=await c.read();t.end()},S=async e=>{const t=e.host??"127.0.0.1",o=e.origin===void 0?void 0:w(e.origin);if(o===void 0&&!p.test(t))throw new Error(`createNodeHttpServer: host "${t}" is not a loopback address, so set origin to the public URL (e.g. https://app.example). Without it, browser requests fail the CSRF origin check and signed URLs point at the bound address.`);const r=f();r.on("request",(n,s)=>{const a=o??`http://${l(t)}:${String(r.address().port)}`,d=new AbortController;s.once("close",()=>{s.writableFinished||d.abort()});let i;try{i=u(n,a,d.signal)}catch{s.writeHead(400,{"content-type":"text/plain; charset=utf-8"}),s.end("Bad Request");return}Promise.resolve().then(()=>e.fetch(i)).then(h=>R(h,s),()=>{s.headersSent||s.writeHead(500,{"content-type":"text/plain; charset=utf-8"}),s.end("Internal Server Error")}).catch(()=>{s.destroy()})}),await new Promise((n,s)=>{r.once("error",s),r.listen(e.port??0,t,()=>{r.off("error",s),n()})});const{port:c}=r.address();return{close:()=>new Promise((n,s)=>{r.closeAllConnections(),r.close(a=>{a===void 0?n():s(a)})}),origin:`http://${l(t)}:${String(c)}`}};export{S as createNodeHttpServer};
|