@lunora/platform-cloudflare 1.0.0-alpha.2 → 1.0.0-alpha.3
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{createShardAlarms as t,createShardDirectory as a,createShardHost as o,createShardKvStore as c,createSocketHost as S}from"./packem_shared/createShardAlarms-
|
|
1
|
+
import{createShardAlarms as t,createShardDirectory as a,createShardHost as o,createShardKvStore as c,createSocketHost as S}from"./packem_shared/createShardAlarms-Cz5Aeu5r.mjs";import{createShardPlatform as h,createWorkerPlatform as m}from"./packem_shared/createShardPlatform-BeTNHclr.mjs";export{t as createShardAlarms,a as createShardDirectory,o as createShardHost,c as createShardKvStore,h as createShardPlatform,S as createSocketHost,m as createWorkerPlatform};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as u}from"@lunora/errors";const S=(t,e,r)=>{const a=t.storage.sql;if(typeof a?.exec!="function")throw new TypeError("storage.sql.exec is not available on this DurableObjectState");return a.exec(e,...r)},m=t=>({delete:()=>typeof t.deleteAlarm=="function"?t.deleteAlarm():Promise.resolve(),get:()=>typeof t.getAlarm=="function"?t.getAlarm():null,set:e=>typeof t.setAlarm=="function"?t.setAlarm(e):Promise.resolve()}),W=t=>{const{storage:e}=t,r={get databaseSize(){return t.storage.sql?.databaseSize},exec:(n,...s)=>S(t,n,s)},a=m(e),i=async n=>typeof t.blockConcurrencyWhile=="function"?t.blockConcurrencyWhile(n):n(),o=async n=>{const s=e;return typeof s?.transaction=="function"?s.transaction(async()=>n()):n()};return{alarms:a,runSerialized:i,shardKey:t.id?.name,sql:r,transaction:o,waitUntil:typeof t.waitUntil=="function"?n=>{t.waitUntil(n)}:void 0}},A=t=>({delete:async e=>!!await t.delete(e),get:e=>t.get(e),list:e=>{if(typeof t.list!="function")throw new TypeError("storage.list is not available on this DurableObjectStorage");return t.list(e)},put:(e,r)=>t.put(e,r)}),l="lunora-socket:",g=new WeakMap,d=new WeakMap;let h=0;const w=(t,e)=>{const{getTags:r}=t;if(typeof r!="function")return!1;try{return r.call(t,e).some(a=>a.startsWith(l))}catch{return!1}},E=(t,e)=>{const{getTags:r}=t;if(typeof r=="function"){let n;try{n=r.call(t,e).find(s=>s.startsWith(l))}catch{n=void 0}if(n!==void 0)return n.slice(l.length)}const a=g.get(e);if(a!==void 0)return a;const i=d.get(e);if(i!==void 0)return i;h+=1;const o=`cf-socket-${String(h)}`;return d.set(e,o),o},p=10,y=256,k=1,b=t=>{if(!t||t.length===0)return;const e=p-k;if(t.length>e)throw new u("SOCKET_TAG_BUDGET_EXCEEDED",`${String(t.length)} tags supplied; Cloudflare allows ${String(p)} per socket and 1 is reserved for the host's identity tag — pass at most ${String(e)}.`);const r=t.find(a=>a.length>y);if(r!==void 0)throw new u("SOCKET_TAG_BUDGET_EXCEEDED",`Tag ${JSON.stringify(r)} is ${String(r.length)} characters; Cloudflare allows at most ${String(y)} characters per tag.`)},D=t=>{const e=new WeakSet;let r=0,a;const i=()=>{const o=t.getWebSockets();return(a?.generation!==r||a.length!==o.length)&&(a={generation:r,length:o.length,set:new WeakSet(o)}),a.set};return{accept:(o,n,s)=>{b(s);const c=o,f=crypto.randomUUID();return t.acceptWebSocket(c,[`${l}${f}`,...s??[]]),g.set(c,f),r+=1,n!==void 0&&c.serializeAttachment?.(n),c},getSockets:o=>t.getWebSockets(o),handleFor:o=>{const n=o;if(g.has(n)||w(t,n))return n;if(!e.has(n)){if(i().has(n))return n;e.add(n)}},idFor:o=>E(t,o)}},v=t=>{const e=r=>({fetch:a=>r.fetch(a)});return{get:r=>e(t.get(r)),getByName:r=>e(t.get(t.idFromName(r))),idForName:r=>t.idFromName(r),jurisdiction:r=>v(t.jurisdiction(r))}};export{m as createShardAlarms,v as createShardDirectory,W as createShardHost,A as createShardKvStore,D as createSocketHost};
|
package/dist/packem_shared/{createShardPlatform-BhZo43dZ.mjs → createShardPlatform-BeTNHclr.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CLOUDFLARE_CAPABILITIES as c}from"@lunora/platform";import{createSocketHost as d,createShardHost as n,createShardKvStore as i,createShardDirectory as l}from"./createShardAlarms-
|
|
1
|
+
import{CLOUDFLARE_CAPABILITIES as c}from"@lunora/platform";import{createSocketHost as d,createShardHost as n,createShardKvStore as i,createShardDirectory as l}from"./createShardAlarms-Cz5Aeu5r.mjs";const b=e=>{const r=e;return{kv:i(r.storage),shard:n(r),sockets:d(r)}},m=(e,r={})=>{const s=e??{},t=o=>{const a=s[o];if(a==null)throw new Error(`@lunora/platform-cloudflare: no Durable Object namespace bound as "${o}" — add it to wrangler.jsonc's durable_objects.bindings`);return l(a)};return r.scheduler===void 0?{capabilities:c,directory:t}:{capabilities:c,directory:t,scheduler:r.scheduler}};export{b as createShardPlatform,m as createWorkerPlatform};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/platform-cloudflare",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
4
4
|
"description": "Cloudflare implementation of the Lunora platform contracts: ShardHost, SocketHost, ShardDirectory, ShardKvStore over Durable Objects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@lunora/
|
|
46
|
+
"@lunora/errors": "1.0.0-alpha.12",
|
|
47
|
+
"@lunora/platform": "1.0.0-alpha.3"
|
|
47
48
|
},
|
|
48
49
|
"engines": {
|
|
49
50
|
"node": "^22.15.0 || >=24.11.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const h=(t,e,n)=>{const a=t.storage.sql;if(typeof a?.exec!="function")throw new TypeError("storage.sql.exec is not available on this DurableObjectState");return a.exec(e,...n)},y=t=>({delete:()=>typeof t.deleteAlarm=="function"?t.deleteAlarm():Promise.resolve(),get:()=>typeof t.getAlarm=="function"?t.getAlarm():null,set:e=>typeof t.setAlarm=="function"?t.setAlarm(e):Promise.resolve()}),b=t=>{const{storage:e}=t,n={get databaseSize(){return t.storage.sql?.databaseSize},exec:(r,...s)=>h(t,r,s)},a=y(e),i=async r=>typeof t.blockConcurrencyWhile=="function"?t.blockConcurrencyWhile(r):r(),o=async r=>{const s=e;return typeof s?.transaction=="function"?s.transaction(async()=>r()):r()};return{alarms:a,runSerialized:i,shardKey:t.id?.name,sql:n,transaction:o,waitUntil:typeof t.waitUntil=="function"?r=>{t.waitUntil(r)}:void 0}},k=t=>({delete:async e=>!!await t.delete(e),get:e=>t.get(e),list:e=>{if(typeof t.list!="function")throw new TypeError("storage.list is not available on this DurableObjectStorage");return t.list(e)},put:(e,n)=>t.put(e,n)}),l="lunora-socket:",u=new WeakMap,g=new WeakMap;let d=0;const m=(t,e)=>{const{getTags:n}=t;if(typeof n!="function")return!1;try{return n.call(t,e).some(a=>a.startsWith(l))}catch{return!1}},p=(t,e)=>{const{getTags:n}=t;if(typeof n=="function"){let r;try{r=n.call(t,e).find(s=>s.startsWith(l))}catch{r=void 0}if(r!==void 0)return r.slice(l.length)}const a=u.get(e);if(a!==void 0)return a;const i=g.get(e);if(i!==void 0)return i;d+=1;const o=`cf-socket-${String(d)}`;return g.set(e,o),o},w=t=>{const e=new WeakSet;let n=0,a;const i=()=>{const o=t.getWebSockets();return(a?.generation!==n||a.length!==o.length)&&(a={generation:n,length:o.length,set:new WeakSet(o)}),a.set};return{accept:(o,r,s)=>{const c=o,f=crypto.randomUUID();return t.acceptWebSocket(c,[`${l}${f}`,...s??[]]),u.set(c,f),n+=1,r!==void 0&&c.serializeAttachment?.(r),c},getSockets:o=>t.getWebSockets(o),handleFor:o=>{const r=o;if(u.has(r)||m(t,r))return r;if(!e.has(r)){if(i().has(r))return r;e.add(r)}},idFor:o=>p(t,o)}},S=t=>{const e=n=>({fetch:a=>n.fetch(a)});return{get:n=>e(t.get(n)),getByName:n=>e(t.get(t.idFromName(n))),idForName:n=>t.idFromName(n),jurisdiction:n=>S(t.jurisdiction(n))}};export{y as createShardAlarms,S as createShardDirectory,b as createShardHost,k as createShardKvStore,w as createSocketHost};
|