kizlo 0.29.0 → 0.31.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.
Files changed (45) hide show
  1. package/dist/adapters/geo.cloudflare.d.ts +1 -1
  2. package/dist/adapters/geo.cloudflare.js +1 -1
  3. package/dist/adapters/request-context.d.ts +12 -0
  4. package/dist/adapters/types.d.ts +2 -0
  5. package/dist/adapters/types.js +1 -0
  6. package/dist/context.d.ts +13 -30
  7. package/dist/context.js +15 -6
  8. package/dist/index.d.ts +4 -4
  9. package/dist/integrations/nextjs/api.d.ts +13 -0
  10. package/dist/integrations/nextjs/api.js +17 -0
  11. package/dist/integrations/tanstack-start/cloudflare/cache-policy.js +14 -0
  12. package/dist/integrations/tanstack-start/cloudflare/cache.d.ts +40 -0
  13. package/dist/integrations/tanstack-start/cloudflare/cache.js +112 -0
  14. package/dist/integrations/tanstack-start/cloudflare/revalidator.d.ts +35 -0
  15. package/dist/integrations/tanstack-start/cloudflare/revalidator.js +130 -0
  16. package/dist/integrations/tanstack-start/react/cookies.js +20 -0
  17. package/dist/integrations/tanstack-start/react/integration.d.ts +25 -0
  18. package/dist/integrations/tanstack-start/react/integration.js +18 -0
  19. package/dist/integrations/tanstack-start/react/middleware.d.ts +9 -0
  20. package/dist/integrations/tanstack-start/react/middleware.js +32 -0
  21. package/dist/integrations/tanstack-start/request-context.d.ts +8 -0
  22. package/dist/integrations/tanstack-start/request-context.js +24 -0
  23. package/dist/kizlo.d.ts +2 -1
  24. package/dist/kizlo.js +24 -16
  25. package/dist/nextjs/server.d.ts +2 -1
  26. package/dist/nextjs/server.js +2 -1
  27. package/dist/package.js +1 -1
  28. package/dist/tanstack-start/cloudflare.d.ts +28 -0
  29. package/dist/tanstack-start/cloudflare.js +34 -0
  30. package/dist/tanstack-start/react/server.d.ts +14 -0
  31. package/dist/tanstack-start/react/server.js +13 -0
  32. package/dist/webhook/index.d.ts +2 -0
  33. package/dist/webhook/index.js +9 -2
  34. package/dist/webhook/schema.d.ts +36 -1
  35. package/dist/webhook/schema.js +7 -3
  36. package/dist/webhook/utils.js +11 -1
  37. package/package.json +24 -20
  38. package/dist/cloudflare/vinext.d.ts +0 -7
  39. package/dist/cloudflare/vinext.js +0 -44
  40. package/dist/cloudflare.d.ts +0 -3
  41. package/dist/cloudflare.js +0 -4
  42. package/dist/integrations/cloudflare/integration.d.ts +0 -8
  43. package/dist/integrations/cloudflare/integration.js +0 -16
  44. package/dist/integrations/cloudflare/request-context.d.ts +0 -9
  45. package/dist/integrations/cloudflare/request-context.js +0 -58
@@ -1,9 +0,0 @@
1
- import { GeoAdapter } from "../../adapters/geo.js";
2
-
3
- //#region src/integrations/cloudflare/request-context.d.ts
4
- /** Read an explicit Cloudflare request or the active Worker entry context, without framework headers. */
5
- declare function geoCloudflare(): GeoAdapter;
6
- /** Wrap the complete Worker fetch handler, including SSR and streamed response production. */
7
- declare function withCloudflareRequest(request: Request, handle: () => Response | Promise<Response>): Promise<Response>;
8
- //#endregion
9
- export { geoCloudflare, withCloudflareRequest };
@@ -1,58 +0,0 @@
1
- import { cloudflareConnInfo } from "../../adapters/cloudflare-connection.js";
2
- import { AsyncLocalStorage } from "node:async_hooks";
3
-
4
- //#region src/integrations/cloudflare/request-context.ts
5
- const requests = new AsyncLocalStorage();
6
- /** Read an explicit Cloudflare request or the active Worker entry context, without framework headers. */
7
- function geoCloudflare() {
8
- return { getConnInfo: (request) => request ? cloudflareConnInfo(request.headers) : { ...requests.getStore()?.connection ?? cloudflareConnInfo() } };
9
- }
10
- /** Wrap the complete Worker fetch handler, including SSR and streamed response production. */
11
- function withCloudflareRequest(request, handle) {
12
- const store = { connection: cloudflareConnInfo(request.headers) };
13
- return requests.run(store, async () => {
14
- try {
15
- const response = await handle();
16
- if (!response.body || response.status === 101) {
17
- store.connection = null;
18
- return response;
19
- }
20
- const reader = response.body.getReader();
21
- const body = new ReadableStream({
22
- pull(controller) {
23
- return requests.run(store, async () => {
24
- try {
25
- const { value, done } = await reader.read();
26
- if (done) {
27
- store.connection = null;
28
- reader.releaseLock();
29
- controller.close();
30
- } else controller.enqueue(value);
31
- } catch (error) {
32
- store.connection = null;
33
- reader.releaseLock();
34
- controller.error(error);
35
- }
36
- });
37
- },
38
- cancel(reason) {
39
- return requests.run(store, async () => {
40
- try {
41
- await reader.cancel(reason);
42
- } finally {
43
- store.connection = null;
44
- reader.releaseLock();
45
- }
46
- });
47
- }
48
- }, { highWaterMark: 0 });
49
- return new Response(body, response);
50
- } catch (error) {
51
- store.connection = null;
52
- throw error;
53
- }
54
- });
55
- }
56
-
57
- //#endregion
58
- export { geoCloudflare, withCloudflareRequest };