@revojs/cloudflare 0.1.6 → 0.1.8

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.js CHANGED
@@ -1,10 +1,34 @@
1
- import { useKit } from "revojs/vite";
1
+ import { useKit } from "@revojs/kit";
2
+ import { getPlatformProxy } from "wrangler";
2
3
 
4
+ //#region ../revojs/dist/index.js
5
+ function useServer(scope) {
6
+ return scope.getContext(SERVER_CONTEXT);
7
+ }
8
+ const ROUTER_CONTEXT = defineContext("ROUTER_CONTEXT");
9
+ const SERVER_CONTEXT = defineContext("SERVER_CONTEXT");
10
+ function defineContext(name) {
11
+ return name;
12
+ }
13
+
14
+ //#endregion
3
15
  //#region src/index.ts
16
+ let proxy;
4
17
  function cloudflare() {
5
18
  return { setup(app) {
6
19
  const { toPath } = useKit(app, import.meta.url);
7
20
  app.config.server = toPath("./module/server.ts");
21
+ app.config.development.middlewares.push({ async fetch(scope, next) {
22
+ const { request, response } = useServer(scope);
23
+ proxy ??= await getPlatformProxy();
24
+ scope.setContext(SERVER_CONTEXT, {
25
+ states: {},
26
+ request,
27
+ response,
28
+ variables: proxy.env
29
+ });
30
+ return next?.();
31
+ } });
8
32
  } };
9
33
  }
10
34
 
@@ -7,6 +7,7 @@ export default {
7
7
  const scope = new Scope();
8
8
  try {
9
9
  scope.setContext(SERVER_CONTEXT, {
10
+ states: {},
10
11
  request,
11
12
  response: { headers: new Headers() },
12
13
  variables,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revojs/cloudflare",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "repository": "coverbase/revojs",
6
6
  "license": "MIT",
@@ -21,7 +21,8 @@
21
21
  "watch": "tsdown -w"
22
22
  },
23
23
  "dependencies": {
24
- "revojs": "*"
24
+ "@revojs/kit": "*",
25
+ "wrangler": "^4.40.2"
25
26
  },
26
27
  "devDependencies": {
27
28
  "@revojs/tsconfig": "*",