devflare 0.0.0 → 1.0.0-next.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 (198) hide show
  1. package/README.md +737 -1
  2. package/bin/devflare.js +14 -0
  3. package/dist/account-rvrj687w.js +397 -0
  4. package/dist/ai-dx4fr9jh.js +107 -0
  5. package/dist/bridge/client.d.ts +82 -0
  6. package/dist/bridge/client.d.ts.map +1 -0
  7. package/dist/bridge/index.d.ts +7 -0
  8. package/dist/bridge/index.d.ts.map +1 -0
  9. package/dist/bridge/miniflare.d.ts +70 -0
  10. package/dist/bridge/miniflare.d.ts.map +1 -0
  11. package/dist/bridge/protocol.d.ts +146 -0
  12. package/dist/bridge/protocol.d.ts.map +1 -0
  13. package/dist/bridge/proxy.d.ts +49 -0
  14. package/dist/bridge/proxy.d.ts.map +1 -0
  15. package/dist/bridge/serialization.d.ts +83 -0
  16. package/dist/bridge/serialization.d.ts.map +1 -0
  17. package/dist/bridge/server.d.ts +8 -0
  18. package/dist/bridge/server.d.ts.map +1 -0
  19. package/dist/browser-shim/binding-worker.d.ts +7 -0
  20. package/dist/browser-shim/binding-worker.d.ts.map +1 -0
  21. package/dist/browser-shim/handler.d.ts +21 -0
  22. package/dist/browser-shim/handler.d.ts.map +1 -0
  23. package/dist/browser-shim/index.d.ts +3 -0
  24. package/dist/browser-shim/index.d.ts.map +1 -0
  25. package/dist/browser-shim/server.d.ts +25 -0
  26. package/dist/browser-shim/server.d.ts.map +1 -0
  27. package/dist/browser-shim/worker.d.ts +14 -0
  28. package/dist/browser-shim/worker.d.ts.map +1 -0
  29. package/dist/build-mnf6v8gd.js +53 -0
  30. package/dist/bundler/do-bundler.d.ts +42 -0
  31. package/dist/bundler/do-bundler.d.ts.map +1 -0
  32. package/dist/bundler/index.d.ts +2 -0
  33. package/dist/bundler/index.d.ts.map +1 -0
  34. package/dist/cli/bin.d.ts +3 -0
  35. package/dist/cli/bin.d.ts.map +1 -0
  36. package/dist/cli/colors.d.ts +11 -0
  37. package/dist/cli/colors.d.ts.map +1 -0
  38. package/dist/cli/commands/account.d.ts +4 -0
  39. package/dist/cli/commands/account.d.ts.map +1 -0
  40. package/dist/cli/commands/ai.d.ts +3 -0
  41. package/dist/cli/commands/ai.d.ts.map +1 -0
  42. package/dist/cli/commands/build.d.ts +4 -0
  43. package/dist/cli/commands/build.d.ts.map +1 -0
  44. package/dist/cli/commands/deploy.d.ts +4 -0
  45. package/dist/cli/commands/deploy.d.ts.map +1 -0
  46. package/dist/cli/commands/dev.d.ts +4 -0
  47. package/dist/cli/commands/dev.d.ts.map +1 -0
  48. package/dist/cli/commands/doctor.d.ts +4 -0
  49. package/dist/cli/commands/doctor.d.ts.map +1 -0
  50. package/dist/cli/commands/init.d.ts +4 -0
  51. package/dist/cli/commands/init.d.ts.map +1 -0
  52. package/dist/cli/commands/remote.d.ts +4 -0
  53. package/dist/cli/commands/remote.d.ts.map +1 -0
  54. package/dist/cli/commands/types.d.ts +4 -0
  55. package/dist/cli/commands/types.d.ts.map +1 -0
  56. package/dist/cli/dependencies.d.ts +90 -0
  57. package/dist/cli/dependencies.d.ts.map +1 -0
  58. package/dist/cli/index.d.ts +23 -0
  59. package/dist/cli/index.d.ts.map +1 -0
  60. package/dist/cli/wrangler-auth.d.ts +36 -0
  61. package/dist/cli/wrangler-auth.d.ts.map +1 -0
  62. package/dist/cloudflare/account.d.ts +65 -0
  63. package/dist/cloudflare/account.d.ts.map +1 -0
  64. package/dist/cloudflare/api.d.ts +51 -0
  65. package/dist/cloudflare/api.d.ts.map +1 -0
  66. package/dist/cloudflare/auth.d.ts +35 -0
  67. package/dist/cloudflare/auth.d.ts.map +1 -0
  68. package/dist/cloudflare/index.d.ts +107 -0
  69. package/dist/cloudflare/index.d.ts.map +1 -0
  70. package/dist/cloudflare/index.js +13 -0
  71. package/dist/cloudflare/preferences.d.ts +46 -0
  72. package/dist/cloudflare/preferences.d.ts.map +1 -0
  73. package/dist/cloudflare/pricing.d.ts +15 -0
  74. package/dist/cloudflare/pricing.d.ts.map +1 -0
  75. package/dist/cloudflare/remote-config.d.ts +37 -0
  76. package/dist/cloudflare/remote-config.d.ts.map +1 -0
  77. package/dist/cloudflare/types.d.ts +161 -0
  78. package/dist/cloudflare/types.d.ts.map +1 -0
  79. package/dist/cloudflare/usage.d.ts +77 -0
  80. package/dist/cloudflare/usage.d.ts.map +1 -0
  81. package/dist/config/compiler.d.ts +146 -0
  82. package/dist/config/compiler.d.ts.map +1 -0
  83. package/dist/config/define.d.ts +44 -0
  84. package/dist/config/define.d.ts.map +1 -0
  85. package/dist/config/index.d.ts +6 -0
  86. package/dist/config/index.d.ts.map +1 -0
  87. package/dist/config/loader.d.ts +52 -0
  88. package/dist/config/loader.d.ts.map +1 -0
  89. package/dist/config/ref.d.ts +160 -0
  90. package/dist/config/ref.d.ts.map +1 -0
  91. package/dist/config/schema.d.ts +3318 -0
  92. package/dist/config/schema.d.ts.map +1 -0
  93. package/dist/decorators/durable-object.d.ts +59 -0
  94. package/dist/decorators/durable-object.d.ts.map +1 -0
  95. package/dist/decorators/index.d.ts +3 -0
  96. package/dist/decorators/index.d.ts.map +1 -0
  97. package/dist/decorators/index.js +9 -0
  98. package/dist/deploy-nhceck39.js +70 -0
  99. package/dist/dev-qnxet3j9.js +2096 -0
  100. package/dist/dev-server/index.d.ts +2 -0
  101. package/dist/dev-server/index.d.ts.map +1 -0
  102. package/dist/dev-server/server.d.ts +30 -0
  103. package/dist/dev-server/server.d.ts.map +1 -0
  104. package/dist/doctor-e8fy6fj5.js +186 -0
  105. package/dist/durable-object-t4kbb0yt.js +13 -0
  106. package/dist/env.d.ts +48 -0
  107. package/dist/env.d.ts.map +1 -0
  108. package/dist/index-07q6yxyc.js +168 -0
  109. package/dist/index-1xpj0m4r.js +57 -0
  110. package/dist/index-37x76zdn.js +4 -0
  111. package/dist/index-3t6rypgc.js +13 -0
  112. package/dist/index-67qcae0f.js +183 -0
  113. package/dist/index-a855bdsx.js +18 -0
  114. package/dist/index-d8bdkx2h.js +109 -0
  115. package/dist/index-ep3445yc.js +2225 -0
  116. package/dist/index-gz1gndna.js +307 -0
  117. package/dist/index-hcex3rgh.js +266 -0
  118. package/dist/index-m2q41jwa.js +462 -0
  119. package/dist/index-n7rs26ft.js +77 -0
  120. package/dist/index-pf5s73n9.js +1413 -0
  121. package/dist/index-rbht7m9r.js +36 -0
  122. package/dist/index-tfyxa77h.js +850 -0
  123. package/dist/index-tk6ej9dj.js +94 -0
  124. package/dist/index-z14anrqp.js +226 -0
  125. package/dist/index.d.ts +13 -0
  126. package/dist/index.d.ts.map +1 -0
  127. package/dist/index.js +298 -0
  128. package/dist/init-f9mgmew3.js +186 -0
  129. package/dist/remote-q59qk463.js +97 -0
  130. package/dist/runtime/context.d.ts +46 -0
  131. package/dist/runtime/context.d.ts.map +1 -0
  132. package/dist/runtime/exports.d.ts +118 -0
  133. package/dist/runtime/exports.d.ts.map +1 -0
  134. package/dist/runtime/index.d.ts +4 -0
  135. package/dist/runtime/index.d.ts.map +1 -0
  136. package/dist/runtime/index.js +111 -0
  137. package/dist/runtime/middleware.d.ts +82 -0
  138. package/dist/runtime/middleware.d.ts.map +1 -0
  139. package/dist/runtime/validation.d.ts +37 -0
  140. package/dist/runtime/validation.d.ts.map +1 -0
  141. package/dist/sveltekit/index.d.ts +2 -0
  142. package/dist/sveltekit/index.d.ts.map +1 -0
  143. package/dist/sveltekit/index.js +182 -0
  144. package/dist/sveltekit/platform.d.ts +141 -0
  145. package/dist/sveltekit/platform.d.ts.map +1 -0
  146. package/dist/test/bridge-context.d.ts +73 -0
  147. package/dist/test/bridge-context.d.ts.map +1 -0
  148. package/dist/test/cf.d.ts +130 -0
  149. package/dist/test/cf.d.ts.map +1 -0
  150. package/dist/test/email.d.ts +75 -0
  151. package/dist/test/email.d.ts.map +1 -0
  152. package/dist/test/index.d.ts +22 -0
  153. package/dist/test/index.d.ts.map +1 -0
  154. package/dist/test/index.js +71 -0
  155. package/dist/test/multi-worker-context.d.ts +114 -0
  156. package/dist/test/multi-worker-context.d.ts.map +1 -0
  157. package/dist/test/queue.d.ts +74 -0
  158. package/dist/test/queue.d.ts.map +1 -0
  159. package/dist/test/remote-ai.d.ts +6 -0
  160. package/dist/test/remote-ai.d.ts.map +1 -0
  161. package/dist/test/remote-vectorize.d.ts +6 -0
  162. package/dist/test/remote-vectorize.d.ts.map +1 -0
  163. package/dist/test/resolve-service-bindings.d.ts +68 -0
  164. package/dist/test/resolve-service-bindings.d.ts.map +1 -0
  165. package/dist/test/scheduled.d.ts +58 -0
  166. package/dist/test/scheduled.d.ts.map +1 -0
  167. package/dist/test/should-skip.d.ts +50 -0
  168. package/dist/test/should-skip.d.ts.map +1 -0
  169. package/dist/test/simple-context.d.ts +43 -0
  170. package/dist/test/simple-context.d.ts.map +1 -0
  171. package/dist/test/tail.d.ts +86 -0
  172. package/dist/test/tail.d.ts.map +1 -0
  173. package/dist/test/utilities.d.ts +99 -0
  174. package/dist/test/utilities.d.ts.map +1 -0
  175. package/dist/test/worker.d.ts +76 -0
  176. package/dist/test/worker.d.ts.map +1 -0
  177. package/dist/transform/durable-object.d.ts +46 -0
  178. package/dist/transform/durable-object.d.ts.map +1 -0
  179. package/dist/transform/index.d.ts +3 -0
  180. package/dist/transform/index.d.ts.map +1 -0
  181. package/dist/transform/worker-entrypoint.d.ts +66 -0
  182. package/dist/transform/worker-entrypoint.d.ts.map +1 -0
  183. package/dist/types-5nyrz1sz.js +454 -0
  184. package/dist/utils/entrypoint-discovery.d.ts +29 -0
  185. package/dist/utils/entrypoint-discovery.d.ts.map +1 -0
  186. package/dist/utils/glob.d.ts +33 -0
  187. package/dist/utils/glob.d.ts.map +1 -0
  188. package/dist/utils/resolve-package.d.ts +10 -0
  189. package/dist/utils/resolve-package.d.ts.map +1 -0
  190. package/dist/vite/index.d.ts +3 -0
  191. package/dist/vite/index.d.ts.map +1 -0
  192. package/dist/vite/index.js +339 -0
  193. package/dist/vite/plugin.d.ts +138 -0
  194. package/dist/vite/plugin.d.ts.map +1 -0
  195. package/dist/worker-entrypoint-m9th0rg0.js +13 -0
  196. package/dist/workerName.d.ts +17 -0
  197. package/dist/workerName.d.ts.map +1 -0
  198. package/package.json +111 -1
@@ -0,0 +1,99 @@
1
+ export interface TestContextOptions<TEnv = Record<string, unknown>> {
2
+ env?: TEnv;
3
+ request?: Request | null;
4
+ type?: 'fetch' | 'scheduled' | 'queue' | 'email' | 'tail';
5
+ }
6
+ export interface TestContext<TEnv = Record<string, unknown>> {
7
+ env: TEnv;
8
+ ctx: ExecutionContext;
9
+ request: Request | null;
10
+ waitUntilPromises: Promise<unknown>[];
11
+ }
12
+ export interface MockEnvOptions {
13
+ kv?: string[];
14
+ d1?: string[];
15
+ r2?: string[];
16
+ queues?: string[];
17
+ durableObjects?: string[];
18
+ vars?: Record<string, string>;
19
+ secrets?: Record<string, string>;
20
+ custom?: Record<string, unknown>;
21
+ }
22
+ /**
23
+ * Creates a test context with mock ExecutionContext
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const ctx = createTestContext({
28
+ * env: { API_KEY: 'test' },
29
+ * request: new Request('https://test.com')
30
+ * })
31
+ * ```
32
+ */
33
+ export declare function createMockTestContext<TEnv = Record<string, unknown>>(options?: TestContextOptions<TEnv>): TestContext<TEnv>;
34
+ /**
35
+ * Runs a function within a test context
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const response = await withTestContext(
40
+ * { env: { DB: mockD1 } },
41
+ * async () => {
42
+ * // env, ctx, locals all work here
43
+ * return handler.fetch(new Request('https://test.com'))
44
+ * }
45
+ * )
46
+ * ```
47
+ */
48
+ export declare function withTestContext<T, TEnv = Record<string, unknown>>(options: TestContextOptions<TEnv>, handler: () => Promise<T>): Promise<T>;
49
+ /**
50
+ * Creates a mock KVNamespace for testing
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * const kv = createMockKV({ 'key': 'value' })
55
+ * await kv.get('key') // 'value'
56
+ * ```
57
+ */
58
+ export declare function createMockKV(initialData?: Record<string, string>): KVNamespace;
59
+ /**
60
+ * Creates a mock D1Database for testing
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * const d1 = createMockD1([
65
+ * { id: 1, name: 'Alice' }
66
+ * ])
67
+ * const result = await d1.prepare('SELECT * FROM users').all()
68
+ * ```
69
+ */
70
+ export declare function createMockD1(mockResults?: unknown[]): D1Database;
71
+ /**
72
+ * Creates a mock R2Bucket for testing
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * const r2 = createMockR2()
77
+ * await r2.put('file.txt', 'content')
78
+ * const obj = await r2.get('file.txt')
79
+ * ```
80
+ */
81
+ export declare function createMockR2(): R2Bucket;
82
+ /**
83
+ * Creates a mock Queue for testing
84
+ */
85
+ export declare function createMockQueue(): Queue;
86
+ /**
87
+ * Creates a complete mock environment with specified bindings
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * const env = createMockEnv({
92
+ * kv: ['CACHE'],
93
+ * d1: ['DB'],
94
+ * vars: { API_KEY: 'secret' }
95
+ * })
96
+ * ```
97
+ */
98
+ export declare function createMockEnv(options?: MockEnvOptions): Record<string, unknown>;
99
+ //# sourceMappingURL=utilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../src/test/utilities.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,kBAAkB,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACjE,GAAG,CAAC,EAAE,IAAI,CAAA;IACV,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IACxB,IAAI,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAA;CACzD;AAED,MAAM,WAAW,WAAW,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC1D,GAAG,EAAE,IAAI,CAAA;IACT,GAAG,EAAE,gBAAgB,CAAA;IACrB,OAAO,EAAE,OAAO,GA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B,eAAe,IAAI,KAAK,CAiBvC;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,cAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA+CnF"}
@@ -0,0 +1,76 @@
1
+ export interface WorkerFetchOptions {
2
+ /** Request method (default: GET) */
3
+ method?: string;
4
+ /** Request headers */
5
+ headers?: Record<string, string>;
6
+ /** Request body (will be JSON-serialized if object) */
7
+ body?: unknown;
8
+ }
9
+ /**
10
+ * Configure the worker test helper
11
+ * @internal Called by createTestContext to set up handler path and env
12
+ */
13
+ export declare function configureWorker(options: {
14
+ handlerPath: string | null;
15
+ configDir: string;
16
+ getEnv: () => Record<string, unknown>;
17
+ }): void;
18
+ /**
19
+ * Reset worker helper state
20
+ * @internal Called when test context is disposed
21
+ */
22
+ export declare function resetWorkerState(): void;
23
+ /**
24
+ * Trigger the fetch handler with a request.
25
+ * This directly invokes the fetch handler function from your config.
26
+ *
27
+ * @param request - Request object or URL string
28
+ * @param options - Optional fetch options (method, headers, body)
29
+ * @returns Response from the handler
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * // With Request object
34
+ * const response = await cf.worker.fetch(new Request('http://localhost/api'))
35
+ *
36
+ * // With URL string
37
+ * const response = await cf.worker.fetch('http://localhost/api')
38
+ *
39
+ * // With options
40
+ * const response = await cf.worker.fetch('/api/users', {
41
+ * method: 'POST',
42
+ * body: { name: 'Alice' }
43
+ * })
44
+ * ```
45
+ */
46
+ declare function fetch(request: Request | string, options?: WorkerFetchOptions): Promise<Response>;
47
+ /**
48
+ * Shorthand for GET requests
49
+ */
50
+ declare function get(path: string, headers?: Record<string, string>): Promise<Response>;
51
+ /**
52
+ * Shorthand for POST requests with JSON body
53
+ */
54
+ declare function post(path: string, body?: unknown, headers?: Record<string, string>): Promise<Response>;
55
+ /**
56
+ * Shorthand for PUT requests with JSON body
57
+ */
58
+ declare function put(path: string, body?: unknown, headers?: Record<string, string>): Promise<Response>;
59
+ /**
60
+ * Shorthand for DELETE requests
61
+ */
62
+ declare function del(path: string, headers?: Record<string, string>): Promise<Response>;
63
+ /**
64
+ * Shorthand for PATCH requests with JSON body
65
+ */
66
+ declare function patch(path: string, body?: unknown, headers?: Record<string, string>): Promise<Response>;
67
+ export declare const worker: {
68
+ fetch: typeof fetch;
69
+ get: typeof get;
70
+ post: typeof post;
71
+ put: typeof put;
72
+ delete: typeof del;
73
+ patch: typeof patch;
74
+ };
75
+ export {};
76
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/test/worker.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,kBAAkB;IAClC,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,uDAAuD;IACvD,IAAI,CAAC,EAAE,OAAO,CAAA;CACd;AAcD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE;IACxC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACrC,GAAG,IAAI,CAIP;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAIvC;AAMD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iBAAe,KAAK,CACnB,OAAO,EAAE,OAAO,GAAG,MAAM,EACzB,OAAO,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,QAAQ,CAAC,CA2EnB;AAED;;GAEG;AACH,iBAAe,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEpF;AAED;;GAEG;AACH,iBAAe,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAErG;AAED;;GAEG;AACH,iBAAe,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEpG;AAED;;GAEG;AACH,iBAAe,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEpF;AAED;;GAEG;AACH,iBAAe,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEtG;AAMD,eAAO,MAAM,MAAM;;;;;;;CAOlB,CAAA"}
@@ -0,0 +1,46 @@
1
+ import MagicString from 'magic-string';
2
+ /**
3
+ * Information about a detected Durable Object class
4
+ */
5
+ export interface DOClassInfo {
6
+ /** Class name */
7
+ name: string;
8
+ /** Whether the class extends DurableObject */
9
+ extendsBase: boolean;
10
+ /** Whether the class has @durableObject decorator */
11
+ hasDecorator: boolean;
12
+ /** Parsed decorator options (if any) */
13
+ decoratorOptions?: Record<string, unknown>;
14
+ }
15
+ /**
16
+ * Finds all class names that extend DurableObject or have @durableObject decorator
17
+ */
18
+ export declare function findDurableObjectClasses(code: string): string[];
19
+ /**
20
+ * Finds detailed info about all Durable Object classes
21
+ */
22
+ export declare function findDurableObjectClassesDetailed(code: string): DOClassInfo[];
23
+ /**
24
+ * Options for wrapper generation
25
+ */
26
+ export interface WrapperOptions {
27
+ alarms?: boolean;
28
+ websockets?: boolean;
29
+ }
30
+ /**
31
+ * Generates a wrapper class that injects context into DO methods
32
+ */
33
+ export declare function generateWrapper(className: string, options?: WrapperOptions): string;
34
+ export interface TransformResult {
35
+ code: string;
36
+ map: ReturnType<MagicString['generateMap']>;
37
+ }
38
+ /**
39
+ * Transforms a source file to wrap Durable Object classes
40
+ *
41
+ * @param code - Source code to transform
42
+ * @param id - File path/id for source mapping
43
+ * @returns Transformed code with source map, or null if no transforms needed
44
+ */
45
+ export declare function transformDurableObject(code: string, id: string): Promise<TransformResult | null>;
46
+ //# sourceMappingURL=durable-object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durable-object.d.ts","sourceRoot":"","sources":["../../src/transform/durable-object.ts"],"names":[],"mappings":"AAOA,OAAO,WAAW,MAAM,cAAc,CAAA;AAoBtC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,8CAA8C;IAC9C,WAAW,EAAE,OAAO,CAAA;IACpB,qDAAqD;IACrD,YAAY,EAAE,OAAO,CAAA;IACrB,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAmB/D;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAqD5E;AAiED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,UAAU,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,MAAM,CA6EvF;AAMD,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAA;CAC3C;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC3C,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACR,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CA0GjC"}
@@ -0,0 +1,3 @@
1
+ export { transformDurableObject, findDurableObjectClasses, generateWrapper, type TransformResult } from './durable-object';
2
+ export { transformWorkerEntrypoint, findExportedFunctions, shouldTransformWorker, generateRpcInterface, type ExportedFunction, type WorkerTransformOptions, type WorkerTransformResult } from './worker-entrypoint';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transform/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,sBAAsB,EACtB,wBAAwB,EACxB,eAAe,EACf,KAAK,eAAe,EACpB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACN,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,MAAM,qBAAqB,CAAA"}
@@ -0,0 +1,66 @@
1
+ import MagicString from 'magic-string';
2
+ /**
3
+ * Information about an exported function
4
+ */
5
+ export interface ExportedFunction {
6
+ /** Function name */
7
+ name: string;
8
+ /** Whether it's an async function */
9
+ isAsync: boolean;
10
+ /** Function parameters (as string) */
11
+ params: string;
12
+ /** Return type annotation (if any) */
13
+ returnType?: string;
14
+ /** Start position in source */
15
+ start: number;
16
+ /** End position in source */
17
+ end: number;
18
+ /** The full function text for preservation */
19
+ body?: string;
20
+ /** Whether this is the default export */
21
+ isDefault?: boolean;
22
+ }
23
+ /**
24
+ * Options for worker entrypoint transformation
25
+ */
26
+ export interface WorkerTransformOptions {
27
+ /** Class name to generate (default: 'Worker') */
28
+ className?: string;
29
+ /** Whether to inject context wrapper for fetch (default: true) */
30
+ injectContext?: boolean;
31
+ }
32
+ /**
33
+ * Result of transformation
34
+ */
35
+ export interface WorkerTransformResult {
36
+ code: string;
37
+ map: ReturnType<MagicString['generateMap']>;
38
+ /** List of RPC methods (exported functions except fetch) */
39
+ rpcMethods: string[];
40
+ /** Generated class name */
41
+ className: string;
42
+ }
43
+ /**
44
+ * Find all exported functions in a worker.ts file using TypeScript AST
45
+ */
46
+ export declare function findExportedFunctions(code: string): ExportedFunction[];
47
+ /**
48
+ * Check if a file should be transformed as a worker entrypoint
49
+ * Returns true if the file has exported functions that could be RPC methods
50
+ */
51
+ export declare function shouldTransformWorker(code: string, filePath: string): boolean;
52
+ /**
53
+ * Transform a worker.ts file into a WorkerEntrypoint class
54
+ *
55
+ * @param code - Source code to transform
56
+ * @param id - File path/id for source mapping
57
+ * @param options - Transform options
58
+ * @returns Transformed code with source map
59
+ */
60
+ export declare function transformWorkerEntrypoint(code: string, id: string, options?: WorkerTransformOptions): WorkerTransformResult | null;
61
+ /**
62
+ * Generate TypeScript interface for RPC methods
63
+ * This is useful for creating type-safe service binding contracts
64
+ */
65
+ export declare function generateRpcInterface(functions: ExportedFunction[], interfaceName: string): string;
66
+ //# sourceMappingURL=worker-entrypoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-entrypoint.d.ts","sourceRoot":"","sources":["../../src/transform/worker-entrypoint.ts"],"names":[],"mappings":"AAwBA,OAAO,WAAW,MAAM,cAAc,CAAA;AAMtC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,qCAAqC;IACrC,OAAO,EAAE,OAAO,CAAA;IAChB,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,sCAAsC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,6BAA6B;IAC7B,GAAG,EAAE,MAAM,CAAA;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