@guren/plugin-cloudflare 0.5.0 → 0.7.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.
package/README.md CHANGED
@@ -20,12 +20,13 @@ bunx wrangler deploy
20
20
 
21
21
  ## API
22
22
 
23
- - **`createWorkersHandler(app)`** — wraps a Guren `Application` in a Workers module handler. Boot is lazy and deduplicated on the first request, because `boot()` performs I/O that workerd forbids in global scope. The handler deduplicates boot itself, so boot-once holds for anything matching `WorkersAppLike`, not only Guren's `Application`.
24
- - **`getWorkersEnv<Env>()`** — exposes the first request's bindings to boot-time config through a write-once holder. workerd can also expose bindings at module scope via `cloudflare:workers`, but importing that from shared config would break every other runtime (Bun, Lambda, Vercel) — the holder keeps `config/*.ts` portable. Use it to hand a D1 binding to the ORM:
23
+ - **`createWorkersHandler(app)`** — wraps a Guren `Application` in a Workers module handler. Boot is lazy and deduplicated on the first request, because `boot()` performs I/O that workerd forbids in global scope. The handler deduplicates boot itself, so boot-once holds for anything matching `WorkersAppLike`, not only Guren's `Application`. It also exposes `boot(env)`, for an entrypoint that holds `env` but no request — an agent Durable Object woken by an alarm. The latch behind both is `bootWorkersApp(app, env)` / `bootAndFetch(app, request, env, ctx)`, keyed on the app.
24
+ - **Durable agents** — when the app has a `config/agents.ts` (see `@guren/plugin-agents`), `cloudflare:build` appends a named export per registered class to the generated worker, verifies the committed `wrangler.jsonc` hosts each one as a SQLite-backed Durable Object (failing with the exact JSON to add), and mounts `/agents/*` deny-all behind the registry's `routing.authorize`.
25
+ - **`getWorkersEnv<Env>()`** and **`isWorkersRuntime()`** — from `@guren/plugin-cloudflare/env`, an import-free subpath, so `config/*.ts` does not drag the deploy generator into every boot. `getWorkersEnv` exposes the first request's bindings to boot-time config through a write-once holder; `isWorkersRuntime()` is the workerd check the snippets below branch on. workerd can also expose bindings at module scope via `cloudflare:workers`, but importing that from shared config would break every other runtime (Bun, Lambda, Vercel) — the holder keeps `config/*.ts` portable. Use it to hand a D1 binding to the ORM:
25
26
 
26
27
  ```typescript
27
28
  import { createD1Database } from '@guren/core'
28
- import { getWorkersEnv } from '@guren/plugin-cloudflare'
29
+ import { getWorkersEnv } from '@guren/plugin-cloudflare/env'
29
30
 
30
31
  const database = createD1Database({
31
32
  binding: () => getWorkersEnv<{ DB: unknown }>().DB,
@@ -38,7 +39,8 @@ bunx wrangler deploy
38
39
 
39
40
  ```typescript
40
41
  import { createStorageManager, LocalStorageDriver } from '@guren/core'
41
- import { R2Driver, getWorkersEnv } from '@guren/plugin-cloudflare'
42
+ import { getWorkersEnv, isWorkersRuntime } from '@guren/plugin-cloudflare/env'
43
+ import { R2Driver } from '@guren/plugin-cloudflare'
42
44
 
43
45
  const storage = createStorageManager({ default: 'media' })
44
46
  storage.registerDisk('media', () =>