@rivetkit/cloudflare-workers 0.9.8 → 2.0.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/src/handler.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { AsyncLocalStorage } from "node:async_hooks";
1
+ import { env } from "cloudflare:workers";
2
2
  import type { Registry, RunConfig } from "@rivetkit/core";
3
3
  import type { Client } from "@rivetkit/core/client";
4
4
  import { Hono } from "hono";
5
- import invariant from "invariant";
6
5
  import {
7
6
  type ActorHandlerInterface,
8
7
  createActorDurableObject,
@@ -23,12 +22,8 @@ export interface Bindings {
23
22
  *
24
23
  * Use getCloudflareAmbientEnv unless using CF_AMBIENT_ENV.run.
25
24
  */
26
- export const CF_AMBIENT_ENV = new AsyncLocalStorage<Bindings>();
27
-
28
25
  export function getCloudflareAmbientEnv(): Bindings {
29
- const env = CF_AMBIENT_ENV.getStore();
30
- invariant(env, "missing CF_AMBIENT_ENV");
31
- return env;
26
+ return env as unknown as Bindings;
32
27
  }
33
28
 
34
29
  interface Handler {
@@ -87,7 +82,7 @@ export function createServer<R extends Registry<any>>(
87
82
  // Create Cloudflare handler
88
83
  const handler = {
89
84
  fetch: (request, env, ctx) => {
90
- return CF_AMBIENT_ENV.run(env, () => app.fetch(request, env, ctx));
85
+ return app.fetch(request, env, ctx);
91
86
  },
92
87
  } satisfies ExportedHandler<Bindings>;
93
88
 
@@ -164,7 +164,6 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
164
164
  });
165
165
  }
166
166
 
167
- // TODO: strip headers
168
167
  const newUrl = new URL(`http://actor${path}`);
169
168
  const actorRequest = new Request(newUrl, c.req.raw);
170
169
 
package/src/mod.ts CHANGED
@@ -1,2 +1,3 @@
1
+ export type { DriverContext } from "./actor-driver";
1
2
  export type { InputConfig as Config } from "./config";
2
3
  export { type Bindings, createServer, createServerHandler } from "./handler";