@lunora/platform-cloudflare 1.0.0-alpha.2 → 1.0.0-alpha.20
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.d.mts +111 -1
- package/dist/index.d.ts +111 -1
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/createShardAlarms-B8fXiSYz.mjs +1 -0
- package/dist/packem_shared/createShardPlatform-BQii5Qan.mjs +1 -0
- package/package.json +3 -2
- package/dist/packem_shared/createShardAlarms-CbNRtmSR.mjs +0 -1
- package/dist/packem_shared/createShardPlatform-BhZo43dZ.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -124,4 +124,114 @@ declare const createShardPlatform: (state: unknown) => ShardPlatform;
|
|
|
124
124
|
* threaded through it.
|
|
125
125
|
*/
|
|
126
126
|
declare const createWorkerPlatform: (env: unknown, options?: WorkerPlatformOptions) => WorkerPlatform;
|
|
127
|
-
export { type ShardPlatform, type WorkerPlatform, type WorkerPlatformOptions,
|
|
127
|
+
export { type ShardPlatform, type WorkerPlatform, type WorkerPlatformOptions,
|
|
128
|
+
/**
|
|
129
|
+
* `@lunora/platform-cloudflare` — the Cloudflare implementation of the
|
|
130
|
+
* `@lunora/platform` contracts.
|
|
131
|
+
*
|
|
132
|
+
* `@lunora/platform` says what a host must provide; this says how Cloudflare
|
|
133
|
+
* provides it, over `DurableObjectState`, hibernatable WebSockets, and a
|
|
134
|
+
* `DurableObjectNamespace`. A second target ships the same surface from its own
|
|
135
|
+
* `@lunora/platform-<target>` package, so adding one is a sibling rather than a
|
|
136
|
+
* refactor of `@lunora/do`.
|
|
137
|
+
*
|
|
138
|
+
* # Why this depends on nothing but the contracts
|
|
139
|
+
*
|
|
140
|
+
* An earlier version of this package sat *above* `@lunora/do` — it composed
|
|
141
|
+
* adapters that lived there, and so depended on the very package it was meant
|
|
142
|
+
* to make replaceable. That inverts the end-state, and with one host it also
|
|
143
|
+
* had zero consumers, so it was dissolved. This version is the other way up:
|
|
144
|
+
* the adapters live here, `@lunora/do` depends on this, and the only imports
|
|
145
|
+
* are `@lunora/platform` plus Cloudflare's own types. That is what makes the
|
|
146
|
+
* seam real rather than aspirational — `@lunora/do` can no longer reach a
|
|
147
|
+
* provider API except through a contract.
|
|
148
|
+
*/
|
|
149
|
+
createShardAlarms,
|
|
150
|
+
/**
|
|
151
|
+
* `@lunora/platform-cloudflare` — the Cloudflare implementation of the
|
|
152
|
+
* `@lunora/platform` contracts.
|
|
153
|
+
*
|
|
154
|
+
* `@lunora/platform` says what a host must provide; this says how Cloudflare
|
|
155
|
+
* provides it, over `DurableObjectState`, hibernatable WebSockets, and a
|
|
156
|
+
* `DurableObjectNamespace`. A second target ships the same surface from its own
|
|
157
|
+
* `@lunora/platform-<target>` package, so adding one is a sibling rather than a
|
|
158
|
+
* refactor of `@lunora/do`.
|
|
159
|
+
*
|
|
160
|
+
* # Why this depends on nothing but the contracts
|
|
161
|
+
*
|
|
162
|
+
* An earlier version of this package sat *above* `@lunora/do` — it composed
|
|
163
|
+
* adapters that lived there, and so depended on the very package it was meant
|
|
164
|
+
* to make replaceable. That inverts the end-state, and with one host it also
|
|
165
|
+
* had zero consumers, so it was dissolved. This version is the other way up:
|
|
166
|
+
* the adapters live here, `@lunora/do` depends on this, and the only imports
|
|
167
|
+
* are `@lunora/platform` plus Cloudflare's own types. That is what makes the
|
|
168
|
+
* seam real rather than aspirational — `@lunora/do` can no longer reach a
|
|
169
|
+
* provider API except through a contract.
|
|
170
|
+
*/
|
|
171
|
+
createShardDirectory,
|
|
172
|
+
/**
|
|
173
|
+
* `@lunora/platform-cloudflare` — the Cloudflare implementation of the
|
|
174
|
+
* `@lunora/platform` contracts.
|
|
175
|
+
*
|
|
176
|
+
* `@lunora/platform` says what a host must provide; this says how Cloudflare
|
|
177
|
+
* provides it, over `DurableObjectState`, hibernatable WebSockets, and a
|
|
178
|
+
* `DurableObjectNamespace`. A second target ships the same surface from its own
|
|
179
|
+
* `@lunora/platform-<target>` package, so adding one is a sibling rather than a
|
|
180
|
+
* refactor of `@lunora/do`.
|
|
181
|
+
*
|
|
182
|
+
* # Why this depends on nothing but the contracts
|
|
183
|
+
*
|
|
184
|
+
* An earlier version of this package sat *above* `@lunora/do` — it composed
|
|
185
|
+
* adapters that lived there, and so depended on the very package it was meant
|
|
186
|
+
* to make replaceable. That inverts the end-state, and with one host it also
|
|
187
|
+
* had zero consumers, so it was dissolved. This version is the other way up:
|
|
188
|
+
* the adapters live here, `@lunora/do` depends on this, and the only imports
|
|
189
|
+
* are `@lunora/platform` plus Cloudflare's own types. That is what makes the
|
|
190
|
+
* seam real rather than aspirational — `@lunora/do` can no longer reach a
|
|
191
|
+
* provider API except through a contract.
|
|
192
|
+
*/
|
|
193
|
+
createShardHost,
|
|
194
|
+
/**
|
|
195
|
+
* `@lunora/platform-cloudflare` — the Cloudflare implementation of the
|
|
196
|
+
* `@lunora/platform` contracts.
|
|
197
|
+
*
|
|
198
|
+
* `@lunora/platform` says what a host must provide; this says how Cloudflare
|
|
199
|
+
* provides it, over `DurableObjectState`, hibernatable WebSockets, and a
|
|
200
|
+
* `DurableObjectNamespace`. A second target ships the same surface from its own
|
|
201
|
+
* `@lunora/platform-<target>` package, so adding one is a sibling rather than a
|
|
202
|
+
* refactor of `@lunora/do`.
|
|
203
|
+
*
|
|
204
|
+
* # Why this depends on nothing but the contracts
|
|
205
|
+
*
|
|
206
|
+
* An earlier version of this package sat *above* `@lunora/do` — it composed
|
|
207
|
+
* adapters that lived there, and so depended on the very package it was meant
|
|
208
|
+
* to make replaceable. That inverts the end-state, and with one host it also
|
|
209
|
+
* had zero consumers, so it was dissolved. This version is the other way up:
|
|
210
|
+
* the adapters live here, `@lunora/do` depends on this, and the only imports
|
|
211
|
+
* are `@lunora/platform` plus Cloudflare's own types. That is what makes the
|
|
212
|
+
* seam real rather than aspirational — `@lunora/do` can no longer reach a
|
|
213
|
+
* provider API except through a contract.
|
|
214
|
+
*/
|
|
215
|
+
createShardKvStore, createShardPlatform,
|
|
216
|
+
/**
|
|
217
|
+
* `@lunora/platform-cloudflare` — the Cloudflare implementation of the
|
|
218
|
+
* `@lunora/platform` contracts.
|
|
219
|
+
*
|
|
220
|
+
* `@lunora/platform` says what a host must provide; this says how Cloudflare
|
|
221
|
+
* provides it, over `DurableObjectState`, hibernatable WebSockets, and a
|
|
222
|
+
* `DurableObjectNamespace`. A second target ships the same surface from its own
|
|
223
|
+
* `@lunora/platform-<target>` package, so adding one is a sibling rather than a
|
|
224
|
+
* refactor of `@lunora/do`.
|
|
225
|
+
*
|
|
226
|
+
* # Why this depends on nothing but the contracts
|
|
227
|
+
*
|
|
228
|
+
* An earlier version of this package sat *above* `@lunora/do` — it composed
|
|
229
|
+
* adapters that lived there, and so depended on the very package it was meant
|
|
230
|
+
* to make replaceable. That inverts the end-state, and with one host it also
|
|
231
|
+
* had zero consumers, so it was dissolved. This version is the other way up:
|
|
232
|
+
* the adapters live here, `@lunora/do` depends on this, and the only imports
|
|
233
|
+
* are `@lunora/platform` plus Cloudflare's own types. That is what makes the
|
|
234
|
+
* seam real rather than aspirational — `@lunora/do` can no longer reach a
|
|
235
|
+
* provider API except through a contract.
|
|
236
|
+
*/
|
|
237
|
+
createSocketHost, createWorkerPlatform };
|
package/dist/index.d.ts
CHANGED
|
@@ -124,4 +124,114 @@ declare const createShardPlatform: (state: unknown) => ShardPlatform;
|
|
|
124
124
|
* threaded through it.
|
|
125
125
|
*/
|
|
126
126
|
declare const createWorkerPlatform: (env: unknown, options?: WorkerPlatformOptions) => WorkerPlatform;
|
|
127
|
-
export { type ShardPlatform, type WorkerPlatform, type WorkerPlatformOptions,
|
|
127
|
+
export { type ShardPlatform, type WorkerPlatform, type WorkerPlatformOptions,
|
|
128
|
+
/**
|
|
129
|
+
* `@lunora/platform-cloudflare` — the Cloudflare implementation of the
|
|
130
|
+
* `@lunora/platform` contracts.
|
|
131
|
+
*
|
|
132
|
+
* `@lunora/platform` says what a host must provide; this says how Cloudflare
|
|
133
|
+
* provides it, over `DurableObjectState`, hibernatable WebSockets, and a
|
|
134
|
+
* `DurableObjectNamespace`. A second target ships the same surface from its own
|
|
135
|
+
* `@lunora/platform-<target>` package, so adding one is a sibling rather than a
|
|
136
|
+
* refactor of `@lunora/do`.
|
|
137
|
+
*
|
|
138
|
+
* # Why this depends on nothing but the contracts
|
|
139
|
+
*
|
|
140
|
+
* An earlier version of this package sat *above* `@lunora/do` — it composed
|
|
141
|
+
* adapters that lived there, and so depended on the very package it was meant
|
|
142
|
+
* to make replaceable. That inverts the end-state, and with one host it also
|
|
143
|
+
* had zero consumers, so it was dissolved. This version is the other way up:
|
|
144
|
+
* the adapters live here, `@lunora/do` depends on this, and the only imports
|
|
145
|
+
* are `@lunora/platform` plus Cloudflare's own types. That is what makes the
|
|
146
|
+
* seam real rather than aspirational — `@lunora/do` can no longer reach a
|
|
147
|
+
* provider API except through a contract.
|
|
148
|
+
*/
|
|
149
|
+
createShardAlarms,
|
|
150
|
+
/**
|
|
151
|
+
* `@lunora/platform-cloudflare` — the Cloudflare implementation of the
|
|
152
|
+
* `@lunora/platform` contracts.
|
|
153
|
+
*
|
|
154
|
+
* `@lunora/platform` says what a host must provide; this says how Cloudflare
|
|
155
|
+
* provides it, over `DurableObjectState`, hibernatable WebSockets, and a
|
|
156
|
+
* `DurableObjectNamespace`. A second target ships the same surface from its own
|
|
157
|
+
* `@lunora/platform-<target>` package, so adding one is a sibling rather than a
|
|
158
|
+
* refactor of `@lunora/do`.
|
|
159
|
+
*
|
|
160
|
+
* # Why this depends on nothing but the contracts
|
|
161
|
+
*
|
|
162
|
+
* An earlier version of this package sat *above* `@lunora/do` — it composed
|
|
163
|
+
* adapters that lived there, and so depended on the very package it was meant
|
|
164
|
+
* to make replaceable. That inverts the end-state, and with one host it also
|
|
165
|
+
* had zero consumers, so it was dissolved. This version is the other way up:
|
|
166
|
+
* the adapters live here, `@lunora/do` depends on this, and the only imports
|
|
167
|
+
* are `@lunora/platform` plus Cloudflare's own types. That is what makes the
|
|
168
|
+
* seam real rather than aspirational — `@lunora/do` can no longer reach a
|
|
169
|
+
* provider API except through a contract.
|
|
170
|
+
*/
|
|
171
|
+
createShardDirectory,
|
|
172
|
+
/**
|
|
173
|
+
* `@lunora/platform-cloudflare` — the Cloudflare implementation of the
|
|
174
|
+
* `@lunora/platform` contracts.
|
|
175
|
+
*
|
|
176
|
+
* `@lunora/platform` says what a host must provide; this says how Cloudflare
|
|
177
|
+
* provides it, over `DurableObjectState`, hibernatable WebSockets, and a
|
|
178
|
+
* `DurableObjectNamespace`. A second target ships the same surface from its own
|
|
179
|
+
* `@lunora/platform-<target>` package, so adding one is a sibling rather than a
|
|
180
|
+
* refactor of `@lunora/do`.
|
|
181
|
+
*
|
|
182
|
+
* # Why this depends on nothing but the contracts
|
|
183
|
+
*
|
|
184
|
+
* An earlier version of this package sat *above* `@lunora/do` — it composed
|
|
185
|
+
* adapters that lived there, and so depended on the very package it was meant
|
|
186
|
+
* to make replaceable. That inverts the end-state, and with one host it also
|
|
187
|
+
* had zero consumers, so it was dissolved. This version is the other way up:
|
|
188
|
+
* the adapters live here, `@lunora/do` depends on this, and the only imports
|
|
189
|
+
* are `@lunora/platform` plus Cloudflare's own types. That is what makes the
|
|
190
|
+
* seam real rather than aspirational — `@lunora/do` can no longer reach a
|
|
191
|
+
* provider API except through a contract.
|
|
192
|
+
*/
|
|
193
|
+
createShardHost,
|
|
194
|
+
/**
|
|
195
|
+
* `@lunora/platform-cloudflare` — the Cloudflare implementation of the
|
|
196
|
+
* `@lunora/platform` contracts.
|
|
197
|
+
*
|
|
198
|
+
* `@lunora/platform` says what a host must provide; this says how Cloudflare
|
|
199
|
+
* provides it, over `DurableObjectState`, hibernatable WebSockets, and a
|
|
200
|
+
* `DurableObjectNamespace`. A second target ships the same surface from its own
|
|
201
|
+
* `@lunora/platform-<target>` package, so adding one is a sibling rather than a
|
|
202
|
+
* refactor of `@lunora/do`.
|
|
203
|
+
*
|
|
204
|
+
* # Why this depends on nothing but the contracts
|
|
205
|
+
*
|
|
206
|
+
* An earlier version of this package sat *above* `@lunora/do` — it composed
|
|
207
|
+
* adapters that lived there, and so depended on the very package it was meant
|
|
208
|
+
* to make replaceable. That inverts the end-state, and with one host it also
|
|
209
|
+
* had zero consumers, so it was dissolved. This version is the other way up:
|
|
210
|
+
* the adapters live here, `@lunora/do` depends on this, and the only imports
|
|
211
|
+
* are `@lunora/platform` plus Cloudflare's own types. That is what makes the
|
|
212
|
+
* seam real rather than aspirational — `@lunora/do` can no longer reach a
|
|
213
|
+
* provider API except through a contract.
|
|
214
|
+
*/
|
|
215
|
+
createShardKvStore, createShardPlatform,
|
|
216
|
+
/**
|
|
217
|
+
* `@lunora/platform-cloudflare` — the Cloudflare implementation of the
|
|
218
|
+
* `@lunora/platform` contracts.
|
|
219
|
+
*
|
|
220
|
+
* `@lunora/platform` says what a host must provide; this says how Cloudflare
|
|
221
|
+
* provides it, over `DurableObjectState`, hibernatable WebSockets, and a
|
|
222
|
+
* `DurableObjectNamespace`. A second target ships the same surface from its own
|
|
223
|
+
* `@lunora/platform-<target>` package, so adding one is a sibling rather than a
|
|
224
|
+
* refactor of `@lunora/do`.
|
|
225
|
+
*
|
|
226
|
+
* # Why this depends on nothing but the contracts
|
|
227
|
+
*
|
|
228
|
+
* An earlier version of this package sat *above* `@lunora/do` — it composed
|
|
229
|
+
* adapters that lived there, and so depended on the very package it was meant
|
|
230
|
+
* to make replaceable. That inverts the end-state, and with one host it also
|
|
231
|
+
* had zero consumers, so it was dissolved. This version is the other way up:
|
|
232
|
+
* the adapters live here, `@lunora/do` depends on this, and the only imports
|
|
233
|
+
* are `@lunora/platform` plus Cloudflare's own types. That is what makes the
|
|
234
|
+
* seam real rather than aspirational — `@lunora/do` can no longer reach a
|
|
235
|
+
* provider API except through a contract.
|
|
236
|
+
*/
|
|
237
|
+
createSocketHost, createWorkerPlatform };
|
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-B8fXiSYz.mjs";import{createShardPlatform as h,createWorkerPlatform as m}from"./packem_shared/createShardPlatform-BQii5Qan.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 f}from"@lunora/errors";const w=(t,e,r)=>{const c=t.storage.sql;if(typeof c?.exec!="function")throw new TypeError("storage.sql.exec is not available on this DurableObjectState");return c.exec(e,...r)},p=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,e)=>{if(!(!(t instanceof Error)||t===e||t.cause!==void 0))try{Object.defineProperty(t,"cause",{configurable:!0,value:e,writable:!0})}catch{}},C=t=>{const{storage:e}=t,r={get databaseSize(){return t.storage.sql?.databaseSize},exec:(o,...a)=>w(t,o,a)},c=p(e),i=async o=>{if(typeof t.blockConcurrencyWhile=="function"){const a=await t.blockConcurrencyWhile(async()=>{try{return{ok:!0,value:await o()}}catch(s){return{error:s,ok:!1}}});if(!a.ok)throw a.error;return a.value}return o()},n=async o=>{const a=e;if(typeof a?.transaction=="function"){let s;try{return await a.transaction(async()=>{try{return await o()}catch(l){throw s={value:l},l}})}catch(l){throw s?(b(s.value,l),s.value):l}}return o()};return{alarms:c,runSerialized:i,shardKey:t.id?.name,sql:r,transaction:n,waitUntil:typeof t.waitUntil=="function"?o=>{t.waitUntil(o)}:void 0}},D=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)}),d="lunora-socket:",u=new WeakMap,h=new WeakMap;let g=0;const v=(t,e)=>{const{getTags:r}=t;if(typeof r=="function")try{return r.call(t,e).find(c=>c.startsWith(d))}catch{return}},E=(t,e)=>{const r=v(t,e);if(r!==void 0)return r.slice(d.length);const c=u.get(e);if(c!==void 0)return c;const i=h.get(e);if(i!==void 0)return i;g+=1;const n=`cf-socket-${String(g)}`;return h.set(e,n),n},y=10,S=256,k=1,m=t=>{if(!t||t.length===0)return;const e=y-k;if(t.length>e)throw new f("SOCKET_TAG_BUDGET_EXCEEDED",`${String(t.length)} tags supplied; Cloudflare allows ${String(y)} per socket and 1 is reserved for the host's identity tag — pass at most ${String(e)}.`);const r=t.find(c=>c.length>S);if(r!==void 0)throw new f("SOCKET_TAG_BUDGET_EXCEEDED",`Tag ${JSON.stringify(r)} is ${String(r.length)} characters; Cloudflare allows at most ${String(S)} characters per tag.`)},_=t=>{const e=new WeakSet;let r=0,c;const i=()=>{const n=t.getWebSockets();return(c?.generation!==r||c.length!==n.length)&&(c={generation:r,length:n.length,set:new WeakSet(n)}),c.set};return{accept:(n,o,a)=>{m(a);const s=n,l=crypto.randomUUID();return t.acceptWebSocket(s,[`${d}${l}`,...a??[]]),u.set(s,l),r+=1,o!==void 0&&s.serializeAttachment?.(o),s},getSockets:n=>t.getWebSockets(n),handleFor:n=>{const o=n;if(u.has(o)||v(t,o)!==void 0)return o;if(!e.has(o)){if(i().has(o))return o;e.add(o)}},idFor:n=>E(t,n)}},T=t=>{const e=i=>({fetch:n=>i.fetch(n)}),r=i=>i===void 0?void 0:{locationHint:i};return{get:(i,n)=>e(t.get(i,r(n))),getByName:(i,n)=>e(t.get(t.idFromName(i),r(n))),idForName:i=>t.idFromName(i),jurisdiction:i=>T(t.jurisdiction(i))}};export{p as createShardAlarms,T as createShardDirectory,C as createShardHost,D as createShardKvStore,_ as createSocketHost};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createSocketHost as n,createShardHost as d,createShardKvStore as l,createShardDirectory as i}from"./createShardAlarms-B8fXiSYz.mjs";import{CLOUDFLARE_CAPABILITIES as c}from"@lunora/platform";const h=e=>{const r=e;return{kv:l(r.storage),shard:d(r),sockets:n(r)}},m=(e,r={})=>{const s=e??{},a=o=>{const t=s[o];if(t==null)throw new Error(`@lunora/platform-cloudflare: no Durable Object namespace bound as "${o}" — add it to wrangler.jsonc's durable_objects.bindings`);return i(t)};return r.scheduler===void 0?{capabilities:c,directory:a}:{capabilities:c,directory:a,scheduler:r.scheduler}};export{h 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.20",
|
|
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.22",
|
|
47
|
+
"@lunora/platform": "1.0.0-alpha.15"
|
|
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};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{CLOUDFLARE_CAPABILITIES as c}from"@lunora/platform";import{createSocketHost as d,createShardHost as n,createShardKvStore as i,createShardDirectory as l}from"./createShardAlarms-CbNRtmSR.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};
|