devflare 1.0.0-next.39 → 1.0.0-next.40

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 (277) hide show
  1. package/dist/_chunks/account-BtWcv3X9.js +462 -0
  2. package/dist/_chunks/account-resources-CsmVowJp.js +159 -0
  3. package/dist/_chunks/ai-CBEuLdoP.js +322 -0
  4. package/dist/_chunks/api-TzdliH-6.js +568 -0
  5. package/dist/_chunks/build-3T6O4uIg.js +24 -0
  6. package/dist/_chunks/build-artifacts-8TqBSQkG.js +483 -0
  7. package/dist/_chunks/cli-BTF1X4SG.js +1128 -0
  8. package/dist/_chunks/cloudflare-BaloqI3H.js +157 -0
  9. package/dist/_chunks/colors-DiK6wPJ5.js +13 -0
  10. package/dist/_chunks/command-utils-BsfkmTqh.js +45 -0
  11. package/dist/_chunks/compiler-uoyAQ8zW.js +424 -0
  12. package/dist/_chunks/config-D5u-bEkn.js +78 -0
  13. package/dist/_chunks/config-path-DCPto4XB.js +42 -0
  14. package/dist/_chunks/context-CX50Y2Kb.js +2250 -0
  15. package/dist/_chunks/decorators-QmV57ixr.js +19 -0
  16. package/dist/_chunks/dependencies-C2oxFjU_.js +57 -0
  17. package/dist/_chunks/deploy-DMTr6JeR.js +915 -0
  18. package/dist/_chunks/dev-CvRHmRFZ.js +3456 -0
  19. package/dist/_chunks/doctor-DIG8DoFU.js +219 -0
  20. package/dist/_chunks/durable-object-DMtH0XYX.js +234 -0
  21. package/dist/_chunks/env-S0_nMVz1.js +125 -0
  22. package/dist/_chunks/family-DXC5SdFK.js +143 -0
  23. package/dist/_chunks/generated-artifacts-dMJY4KAt.js +32 -0
  24. package/dist/_chunks/glob-CmQOvunB.js +56 -0
  25. package/dist/_chunks/init-3moXTgpb.js +165 -0
  26. package/dist/_chunks/loader-DLXO60RO.js +1153 -0
  27. package/dist/_chunks/local-dev-vars-CTSa-wvF.js +81 -0
  28. package/dist/_chunks/local-hyperdrive-CJ90j46O.js +119 -0
  29. package/dist/_chunks/local-media-bindings-DsAW4AMF.js +335 -0
  30. package/dist/_chunks/local-secrets-DMmEOygL.js +123 -0
  31. package/dist/_chunks/local-workflow-entrypoints-Wip3o1u8.js +90 -0
  32. package/dist/_chunks/login-BmnDzDlH.js +51 -0
  33. package/dist/_chunks/package-metadata-DAuCkyvK.js +39 -0
  34. package/dist/_chunks/preferences-BKp_7XJx.js +241 -0
  35. package/dist/_chunks/preview-BhqDmq8I.js +456 -0
  36. package/dist/_chunks/preview-registry-ClAbLTHH.js +1186 -0
  37. package/dist/_chunks/preview-resources-DdXj8LMM.js +358 -0
  38. package/dist/_chunks/previews-Dlr13x5M.js +1134 -0
  39. package/dist/_chunks/productions-D3AnOHac.js +411 -0
  40. package/dist/_chunks/ref-CYJNAAe_.js +178 -0
  41. package/dist/_chunks/remote-CZnP-HLJ.js +79 -0
  42. package/dist/_chunks/remote-config-D39BY9ji.js +132 -0
  43. package/dist/_chunks/resolve-package-Y84HB3Nt.js +133 -0
  44. package/dist/_chunks/rolldown-runtime-CvQ6eiug.js +14 -0
  45. package/dist/_chunks/routes-C3FqES2W.js +796 -0
  46. package/dist/_chunks/runtime-FvXvfuZ2.js +550 -0
  47. package/dist/_chunks/schema-normalization-DWVleVxo.js +477 -0
  48. package/dist/_chunks/secrets-70eN0Q6C.js +95 -0
  49. package/dist/_chunks/token-kguIDmej.js +333 -0
  50. package/dist/_chunks/tokens-iVcgNXi-.js +221 -0
  51. package/dist/_chunks/types-OrLbzv4I.js +476 -0
  52. package/dist/_chunks/ui-BUoZApvE.js +103 -0
  53. package/dist/_chunks/usage-BBTGzjon.js +272 -0
  54. package/dist/_chunks/vite-CsI0E-uV.js +1235 -0
  55. package/dist/_chunks/vite-utils-OVLMV605.js +183 -0
  56. package/dist/_chunks/worker-CS1jgNFE.js +410 -0
  57. package/dist/_chunks/worker-bundler-dTTnYU3n.js +458 -0
  58. package/dist/_chunks/worker-entrypoint-CQW77lG8.js +247 -0
  59. package/dist/_chunks/workerName-CFJsLZA-.js +23 -0
  60. package/dist/bridge/index.d.ts +6 -6
  61. package/dist/bridge/miniflare.d.ts +2 -2
  62. package/dist/bridge/proxy.d.ts +1 -1
  63. package/dist/bridge/v2/body-streams.d.ts +1 -1
  64. package/dist/bridge/v2/codec.d.ts +4 -4
  65. package/dist/bridge/v2/index.d.ts +10 -10
  66. package/dist/bridge/v2/serialization.d.ts +1 -1
  67. package/dist/bridge/v2/value-codec.d.ts +1 -1
  68. package/dist/bridge/v2/value-serialization.d.ts.map +1 -1
  69. package/dist/bridge/v2/ws-relay.d.ts +3 -3
  70. package/dist/browser-shim/index.d.ts +2 -2
  71. package/dist/browser.d.ts +70 -70
  72. package/dist/browser.js +74 -2462
  73. package/dist/bundler/do-bundler.d.ts +1 -1
  74. package/dist/bundler/index.d.ts +3 -3
  75. package/dist/bundler/rolldown-shared.d.ts +1 -1
  76. package/dist/bundler/worker-bundler.d.ts +1 -1
  77. package/dist/cli/build-manifest.d.ts +1 -1
  78. package/dist/cli/command-utils.d.ts +1 -1
  79. package/dist/cli/commands/account.d.ts +1 -1
  80. package/dist/cli/commands/ai.d.ts +1 -1
  81. package/dist/cli/commands/build-artifacts.d.ts +5 -5
  82. package/dist/cli/commands/build.d.ts +1 -1
  83. package/dist/cli/commands/config.d.ts +1 -1
  84. package/dist/cli/commands/deploy/prepare.d.ts +2 -2
  85. package/dist/cli/commands/deploy/runtime.d.ts +1 -1
  86. package/dist/cli/commands/deploy/verification.d.ts +1 -1
  87. package/dist/cli/commands/deploy.d.ts +1 -1
  88. package/dist/cli/commands/dev.d.ts +1 -1
  89. package/dist/cli/commands/doctor.d.ts +1 -1
  90. package/dist/cli/commands/init.d.ts +1 -1
  91. package/dist/cli/commands/login.d.ts +1 -1
  92. package/dist/cli/commands/previews-support/cleanup.d.ts +1 -1
  93. package/dist/cli/commands/previews-support/family.d.ts +3 -3
  94. package/dist/cli/commands/previews-support/render.d.ts +3 -3
  95. package/dist/cli/commands/previews-support/theme.d.ts +2 -2
  96. package/dist/cli/commands/previews-support/types.d.ts +2 -2
  97. package/dist/cli/commands/previews.d.ts +1 -1
  98. package/dist/cli/commands/productions.d.ts +1 -1
  99. package/dist/cli/commands/remote.d.ts +1 -1
  100. package/dist/cli/commands/secrets.d.ts +1 -1
  101. package/dist/cli/commands/token.d.ts +1 -1
  102. package/dist/cli/commands/type-generation/discovery.d.ts +2 -2
  103. package/dist/cli/commands/type-generation/generator.d.ts +3 -3
  104. package/dist/cli/commands/type-generation/models.d.ts +1 -1
  105. package/dist/cli/commands/types.d.ts +1 -1
  106. package/dist/cli/commands/worker.d.ts +1 -1
  107. package/dist/cli/deploy-strategy.d.ts +1 -1
  108. package/dist/cli/deploy-target.d.ts +1 -1
  109. package/dist/cli/help-pages/pages/account.d.ts +1 -1
  110. package/dist/cli/help-pages/pages/core.d.ts +1 -1
  111. package/dist/cli/help-pages/pages/index.d.ts +1 -1
  112. package/dist/cli/help-pages/pages/misc.d.ts +1 -1
  113. package/dist/cli/help-pages/pages/previews.d.ts +1 -1
  114. package/dist/cli/help-pages/pages/productions.d.ts +1 -1
  115. package/dist/cli/help-pages/render.d.ts +2 -2
  116. package/dist/cli/help-pages/shared.d.ts +1 -1
  117. package/dist/cli/help.d.ts +2 -2
  118. package/dist/cli/index.js +2 -1383
  119. package/dist/cli/preview-bindings.d.ts +3 -3
  120. package/dist/cli/preview.d.ts +1 -1
  121. package/dist/cli/wrangler-auth.d.ts +1 -1
  122. package/dist/cloudflare/account-core.d.ts +2 -2
  123. package/dist/cloudflare/account-resources.d.ts +2 -2
  124. package/dist/cloudflare/account-status.d.ts +1 -1
  125. package/dist/cloudflare/account-workers.d.ts +2 -2
  126. package/dist/cloudflare/account.d.ts +7 -7
  127. package/dist/cloudflare/auth.d.ts +1 -1
  128. package/dist/cloudflare/index.d.ts +13 -13
  129. package/dist/cloudflare/index.js +4 -59
  130. package/dist/cloudflare/kv-namespace.d.ts +1 -1
  131. package/dist/cloudflare/preview-registry-cache.d.ts +1 -1
  132. package/dist/cloudflare/preview-registry-inference.d.ts +2 -2
  133. package/dist/cloudflare/preview-registry-records.d.ts +3 -3
  134. package/dist/cloudflare/preview-registry-shape.d.ts +2 -2
  135. package/dist/cloudflare/preview-registry-store.d.ts +3 -3
  136. package/dist/cloudflare/preview-registry-transport.d.ts +2 -2
  137. package/dist/cloudflare/preview-registry-types.d.ts +2 -2
  138. package/dist/cloudflare/preview-registry.d.ts +5 -5
  139. package/dist/cloudflare/tokens.d.ts +2 -2
  140. package/dist/cloudflare/usage.d.ts +2 -2
  141. package/dist/config/binding-resolution-helpers.d.ts +1 -1
  142. package/dist/config/compiler/bindings.d.ts +2 -2
  143. package/dist/config/compiler/core-helpers.d.ts +2 -2
  144. package/dist/config/compiler/do-workers.d.ts +2 -2
  145. package/dist/config/compiler/paths.d.ts +1 -1
  146. package/dist/config/compiler.d.ts +6 -6
  147. package/dist/config/define.d.ts +2 -2
  148. package/dist/config/deploy-resources.d.ts +5 -5
  149. package/dist/config/env-vars.d.ts +1 -1
  150. package/dist/config/framework-providers.d.ts +1 -1
  151. package/dist/config/index.d.ts +12 -12
  152. package/dist/config/loader.d.ts +2 -2
  153. package/dist/config/local-dev-vars.d.ts +1 -1
  154. package/dist/config/preview-resources.d.ts +4 -4
  155. package/dist/config/preview.d.ts +1 -1
  156. package/dist/config/ref.d.ts +2 -2
  157. package/dist/config/resolve-phased.d.ts +4 -4
  158. package/dist/config/resolve.d.ts +1 -1
  159. package/dist/config/resource-resolution.d.ts +6 -6
  160. package/dist/config/schema-env.d.ts +20 -20
  161. package/dist/config/schema-normalization.d.ts +1 -1
  162. package/dist/config/schema-types-bindings.d.ts +4 -4
  163. package/dist/config/schema-types-build.d.ts +1 -1
  164. package/dist/config/schema-types.d.ts +7 -7
  165. package/dist/config/schema.d.ts +46 -46
  166. package/dist/config/service-bindings-validation.d.ts +1 -1
  167. package/dist/config-entry.d.ts +6 -6
  168. package/dist/config-entry.js +3 -8
  169. package/dist/decorators/index.d.ts +2 -2
  170. package/dist/decorators/index.js +2 -9
  171. package/dist/dev-server/d1-migrations.d.ts +1 -1
  172. package/dist/dev-server/dev-server-state.d.ts +6 -6
  173. package/dist/dev-server/gateway-script.d.ts +1 -1
  174. package/dist/dev-server/index.d.ts +1 -1
  175. package/dist/dev-server/miniflare-bindings.d.ts +1 -1
  176. package/dist/dev-server/miniflare-dev-config.d.ts +5 -5
  177. package/dist/dev-server/miniflare-worker-config.d.ts +3 -3
  178. package/dist/dev-server/server-startup-helpers.d.ts +6 -6
  179. package/dist/dev-server/worker-surface-paths.d.ts +2 -2
  180. package/dist/index.d.ts +8 -8
  181. package/dist/index.js +9 -22
  182. package/dist/runtime/context-events.d.ts +1 -1
  183. package/dist/runtime/context.d.ts +3 -3
  184. package/dist/runtime/exports.d.ts +2 -2
  185. package/dist/runtime/index.d.ts +10 -10
  186. package/dist/runtime/index.js +5 -57
  187. package/dist/runtime/middleware.d.ts +1 -1
  188. package/dist/runtime/router/index.d.ts +3 -3
  189. package/dist/runtime/validation.d.ts +1 -1
  190. package/dist/secrets/local-secrets.d.ts +1 -1
  191. package/dist/shims/local-media-bindings.d.ts +1 -1
  192. package/dist/sveltekit/index.d.ts +1 -1
  193. package/dist/sveltekit/index.js +327 -9
  194. package/dist/sveltekit/local-bindings.d.ts +1 -1
  195. package/dist/sveltekit/platform.d.ts +1 -1
  196. package/dist/test/binding-hints.d.ts +2 -2
  197. package/dist/test/cf.d.ts +19 -19
  198. package/dist/test/index.d.ts +18 -18
  199. package/dist/test/index.js +4495 -46
  200. package/dist/test/offline-bindings.d.ts +3 -3
  201. package/dist/test/resolve-service-bindings.d.ts +1 -1
  202. package/dist/test/simple-context-bindings.d.ts +1 -1
  203. package/dist/test/simple-context-durable-objects.d.ts +1 -1
  204. package/dist/test/simple-context-env.d.ts +2 -2
  205. package/dist/test/simple-context-handlers.d.ts +2 -2
  206. package/dist/test/simple-context-lifecycle.d.ts +2 -2
  207. package/dist/test/simple-context-mfconfig.d.ts +1 -1
  208. package/dist/test/simple-context-multi-worker.d.ts +2 -2
  209. package/dist/test/simple-context-runtime.d.ts +1 -1
  210. package/dist/test/simple-context-startup.d.ts +1 -1
  211. package/dist/test/simple-context.d.ts +1 -1
  212. package/dist/test/utilities/env.d.ts +3 -3
  213. package/dist/test/utilities.d.ts +10 -10
  214. package/dist/test/worker.d.ts +1 -1
  215. package/dist/transform/index.d.ts +2 -2
  216. package/dist/utils/send-email.js +163 -19
  217. package/dist/vite/config-file.d.ts +2 -2
  218. package/dist/vite/index.d.ts +3 -3
  219. package/dist/vite/index.js +2 -31
  220. package/dist/vite/plugin-config-hook.d.ts +1 -1
  221. package/dist/vite/plugin-context.d.ts +3 -3
  222. package/dist/vite/plugin-durable-objects.d.ts +2 -2
  223. package/dist/vite/plugin-programmatic.d.ts +1 -1
  224. package/dist/vite/plugin-service-bindings.d.ts +2 -2
  225. package/dist/vite/plugin.d.ts +3 -3
  226. package/dist/worker-entry/composed-worker.d.ts +1 -1
  227. package/dist/worker-entry/routes.d.ts +2 -2
  228. package/dist/worker-entry/surface-paths.d.ts +1 -1
  229. package/dist/workflows/local-workflow-entrypoints.d.ts +1 -1
  230. package/package.json +5 -3
  231. package/dist/account-4tgh03a8.js +0 -484
  232. package/dist/ai-r3zqmxan.js +0 -261
  233. package/dist/api-6z01z734.js +0 -33
  234. package/dist/build-kw625v84.js +0 -51
  235. package/dist/config-ghk2bxj3.js +0 -102
  236. package/dist/deploy-9kee65n9.js +0 -1062
  237. package/dist/dev-x8zr249a.js +0 -3569
  238. package/dist/doctor-0ng5qrr1.js +0 -258
  239. package/dist/durable-object-0ybmg08a.js +0 -13
  240. package/dist/index-04wh9bxx.js +0 -514
  241. package/dist/index-0cc05hzv.js +0 -74
  242. package/dist/index-2yv7w548.js +0 -185
  243. package/dist/index-37x76zdn.js +0 -4
  244. package/dist/index-3cpzsr47.js +0 -125
  245. package/dist/index-3t6rypgc.js +0 -13
  246. package/dist/index-4mmpccrb.js +0 -309
  247. package/dist/index-5dkjffqz.js +0 -25
  248. package/dist/index-5hy7jmv3.js +0 -890
  249. package/dist/index-627srx16.js +0 -45
  250. package/dist/index-7m557715.js +0 -283
  251. package/dist/index-a8pnvg3r.js +0 -52
  252. package/dist/index-aabgympv.js +0 -39
  253. package/dist/index-atwc3csp.js +0 -256
  254. package/dist/index-cv4cvrxe.js +0 -2046
  255. package/dist/index-h7r11y4a.js +0 -539
  256. package/dist/index-hvtd936d.js +0 -1229
  257. package/dist/index-kcp7y951.js +0 -136
  258. package/dist/index-maw0jjnn.js +0 -147
  259. package/dist/index-mek9msfv.js +0 -705
  260. package/dist/index-n4xkaymm.js +0 -236
  261. package/dist/index-nkk59p3y.js +0 -579
  262. package/dist/index-phcrvs6d.js +0 -342
  263. package/dist/index-se4kw8tm.js +0 -460
  264. package/dist/index-x8s9rwfh.js +0 -2020
  265. package/dist/index-y7w3x9p1.js +0 -18
  266. package/dist/index-z9gy8w6b.js +0 -57
  267. package/dist/index-zdd0d9qa.js +0 -199
  268. package/dist/init-tb8jqgvr.js +0 -180
  269. package/dist/login-4h1sfsed.js +0 -75
  270. package/dist/previews-qr7c5j8h.js +0 -1336
  271. package/dist/productions-xpmd6bw8.js +0 -505
  272. package/dist/remote-kqcvhnfx.js +0 -192
  273. package/dist/secrets-6wbdsdek.js +0 -89
  274. package/dist/token-yp1qa70y.js +0 -419
  275. package/dist/types-15yv4cj3.js +0 -701
  276. package/dist/worker-1yg72jxg.js +0 -510
  277. package/dist/worker-entrypoint-y8s9kdcx.js +0 -15
@@ -1,10 +1,328 @@
1
- import"../index-37x76zdn.js";
2
- export {
3
- resetPlatform,
4
- resetConfigCache,
5
- isDevflareDev,
6
- handle,
7
- getBridgePort,
8
- createHandle,
9
- createDevflarePlatform
1
+ import { r as loadConfig } from "../_chunks/loader-DLXO60RO.js";
2
+ import { c as normalizeHyperdriveBinding } from "../_chunks/schema-normalization-DWVleVxo.js";
3
+ import { D as createFetchEvent, I as getClient, M as createEnvProxy, P as setBindingHints, v as runWithEventContext } from "../_chunks/context-CX50Y2Kb.js";
4
+ import { createLocalSendEmailBinding } from "../utils/send-email.js";
5
+ import { i as extractBindingHints, n as createLocalWorkerLoaderBinding, t as createLocalHyperdrive } from "../_chunks/local-hyperdrive-CJ90j46O.js";
6
+ import { t as buildLocalSecretNodeBindings } from "../_chunks/local-secrets-DMmEOygL.js";
7
+ import { n as createLocalImagesBinding, r as createLocalMediaBinding } from "../_chunks/local-media-bindings-DsAW4AMF.js";
8
+ //#region src/sveltekit/local-bindings.ts
9
+ function buildLocalHyperdriveBindings(config) {
10
+ const bindings = {};
11
+ for (const [name, binding] of Object.entries(config.bindings?.hyperdrive ?? {})) {
12
+ const normalized = normalizeHyperdriveBinding(binding);
13
+ if (normalized.localConnectionString) bindings[name] = createLocalHyperdrive(normalized.localConnectionString);
14
+ }
15
+ return bindings;
16
+ }
17
+ function buildSvelteKitLocalBindings(config, cwd) {
18
+ const bindings = {
19
+ ...config.vars ?? {},
20
+ ...buildLocalHyperdriveBindings(config),
21
+ ...buildLocalSecretNodeBindings(config, cwd)
22
+ };
23
+ for (const [name, binding] of Object.entries(config.bindings?.sendEmail ?? {})) bindings[name] = createLocalSendEmailBinding(binding);
24
+ for (const name of Object.keys(config.bindings?.workerLoaders ?? {})) bindings[name] = createLocalWorkerLoaderBinding();
25
+ for (const name of Object.keys(config.bindings?.images ?? {})) bindings[name] = createLocalImagesBinding();
26
+ for (const name of Object.keys(config.bindings?.media ?? {})) bindings[name] = createLocalMediaBinding();
27
+ return bindings;
28
+ }
29
+ function overlayLocalBindings(baseEnv, localBindings) {
30
+ if (Object.keys(localBindings).length === 0) return baseEnv;
31
+ return new Proxy(baseEnv, {
32
+ get(target, prop, receiver) {
33
+ if (typeof prop === "string" && prop in localBindings) return localBindings[prop];
34
+ return Reflect.get(target, prop, receiver);
35
+ },
36
+ has(target, prop) {
37
+ return typeof prop === "string" && prop in localBindings || Reflect.has(target, prop);
38
+ },
39
+ ownKeys(target) {
40
+ return Array.from(new Set([...Reflect.ownKeys(target), ...Reflect.ownKeys(localBindings)]));
41
+ },
42
+ getOwnPropertyDescriptor(target, prop) {
43
+ if (typeof prop === "string" && prop in localBindings) return {
44
+ configurable: true,
45
+ enumerable: true,
46
+ writable: false,
47
+ value: localBindings[prop]
48
+ };
49
+ return Reflect.getOwnPropertyDescriptor(target, prop);
50
+ }
51
+ });
52
+ }
53
+ //#endregion
54
+ //#region src/sveltekit/platform.ts
55
+ /** Cached platform keyed by bridgeUrl + binding hint fingerprint */
56
+ let platformCache = null;
57
+ /**
58
+ * Generate a stable fingerprint for binding hints so cached platforms are not
59
+ * shared across configs with differing hint sets.
60
+ */
61
+ function fingerprintHints(hints) {
62
+ const entries = Object.keys(hints).sort().map((name) => [name, hints[name]]);
63
+ return JSON.stringify(entries);
64
+ }
65
+ /**
66
+ * Generate cache key from options
67
+ */
68
+ function getPlatformCacheKey(bridgeUrl, hints) {
69
+ return `${bridgeUrl}\u0000${fingerprintHints(hints)}`;
70
+ }
71
+ function shouldUseCachedPlatform(localBindings) {
72
+ return Object.keys(localBindings).length === 0;
73
+ }
74
+ /**
75
+ * Build a dev-mode ExecutionContext that records `waitUntil()` rejections on
76
+ * the provided `pendingErrors` array. The original console.error log is kept
77
+ * for parity with existing behavior.
78
+ */
79
+ function createDevExecutionContext(pendingErrors) {
80
+ return {
81
+ waitUntil: (promise) => {
82
+ promise.catch((err) => {
83
+ console.error("[devflare] waitUntil error:", err);
84
+ pendingErrors.push(err);
85
+ });
86
+ },
87
+ passThroughOnException: () => {}
88
+ };
89
+ }
90
+ /**
91
+ * Create a platform object that routes bindings through the bridge
92
+ *
93
+ * Use this in dev mode to get access to Miniflare bindings via WebSocket RPC.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * // src/hooks.server.ts
98
+ * import { dev } from '$app/environment'
99
+ * import { createDevflarePlatform } from 'devflare/sveltekit'
100
+ *
101
+ * export async function handle({ event, resolve }) {
102
+ * if (dev && process.env.DEVFLARE_DEV) {
103
+ * // Override platform with bridge-connected proxy
104
+ * event.platform = await createDevflarePlatform({
105
+ * hints: {
106
+ * MY_KV: 'kv',
107
+ * MY_DO: 'do',
108
+ * MY_D1: 'd1',
109
+ * MY_R2: 'r2'
110
+ * }
111
+ * })
112
+ * }
113
+ * return resolve(event)
114
+ * }
115
+ * ```
116
+ */
117
+ async function createDevflarePlatform(options = {}) {
118
+ const { bridgeUrl = `ws://localhost:${process.env.DEVFLARE_BRIDGE_PORT ?? 8787}`, hints = {}, localBindings = {} } = options;
119
+ const cacheKey = getPlatformCacheKey(bridgeUrl, hints);
120
+ if (shouldUseCachedPlatform(localBindings) && platformCache?.key === cacheKey) return platformCache.platform;
121
+ const client = getClient({ url: bridgeUrl });
122
+ await client.connect();
123
+ const env = overlayLocalBindings(createEnvProxy({
124
+ client,
125
+ hints,
126
+ strict: true
127
+ }), localBindings);
128
+ const pendingErrors = [];
129
+ const platform = {
130
+ env,
131
+ context: createDevExecutionContext(pendingErrors),
132
+ caches: {
133
+ default: createMockCache(),
134
+ open: async (cacheName) => createMockCache()
135
+ },
136
+ cf: {
137
+ colo: "DEV",
138
+ country: "XX",
139
+ city: "Development",
140
+ continent: "XX",
141
+ latitude: "0",
142
+ longitude: "0",
143
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
144
+ region: "Development",
145
+ regionCode: "DEV",
146
+ asn: 0,
147
+ asOrganization: "Devflare Dev"
148
+ },
149
+ pendingErrors
150
+ };
151
+ if (shouldUseCachedPlatform(localBindings)) platformCache = {
152
+ key: cacheKey,
153
+ platform
154
+ };
155
+ return platform;
156
+ }
157
+ /**
158
+ * Create a simple mock cache for dev mode
159
+ * Note: Cloudflare's Cache interface differs from browser Cache API
160
+ */
161
+ function createMockCache() {
162
+ const store = /* @__PURE__ */ new Map();
163
+ return {
164
+ async match(request) {
165
+ const key = typeof request === "string" ? request : request instanceof URL ? request.href : request.url;
166
+ return store.get(key)?.clone();
167
+ },
168
+ async put(request, response) {
169
+ const key = typeof request === "string" ? request : request instanceof URL ? request.href : request.url;
170
+ store.set(key, response.clone());
171
+ },
172
+ async delete(request) {
173
+ const key = typeof request === "string" ? request : request instanceof URL ? request.href : request.url;
174
+ return store.delete(key);
175
+ }
176
+ };
177
+ }
178
+ /**
179
+ * Reset the cached platform (for testing)
180
+ */
181
+ function resetPlatform() {
182
+ platformCache = null;
183
+ }
184
+ /**
185
+ * Reset the cached config (for testing)
186
+ */
187
+ function resetConfigCache() {
188
+ configCache = null;
189
+ }
190
+ /**
191
+ * Check if running in devflare dev mode
192
+ */
193
+ function isDevflareDev() {
194
+ return process.env.DEVFLARE_DEV === "true";
195
+ }
196
+ /**
197
+ * Get the bridge port from environment
198
+ */
199
+ function getBridgePort() {
200
+ return Number.parseInt(process.env.DEVFLARE_BRIDGE_PORT ?? "8787", 10);
201
+ }
202
+ /** Cached config promise keyed by cwd + explicit config path */
203
+ let configCache = null;
204
+ function getConfigFileFromEnv() {
205
+ return process.env.DEVFLARE_CONFIG_PATH;
206
+ }
207
+ async function loadConfigFromCurrentCwd() {
208
+ const cwd = process.cwd();
209
+ const configFile = getConfigFileFromEnv();
210
+ if (configCache?.cwd === cwd && configCache.configFile === configFile) return configCache.promise;
211
+ const promise = loadConfig({
212
+ cwd,
213
+ configFile
214
+ }).catch((err) => {
215
+ if (process.env.DEVFLARE_DEBUG) console.warn("[devflare] Failed to load config for hints:", err.message);
216
+ return null;
217
+ });
218
+ configCache = {
219
+ cwd,
220
+ configFile,
221
+ promise
222
+ };
223
+ return promise;
224
+ }
225
+ async function loadPlatformOptionsFromConfig() {
226
+ const cwd = process.cwd();
227
+ const config = await loadConfigFromCurrentCwd();
228
+ if (!config) return {
229
+ hints: {},
230
+ localBindings: {}
231
+ };
232
+ return {
233
+ hints: extractBindingHints(config),
234
+ localBindings: buildSvelteKitLocalBindings(config, cwd)
235
+ };
236
+ }
237
+ function resolveWithPlatformContext(event, resolve, platform) {
238
+ if (!(event.request instanceof Request)) return resolve(event);
239
+ return runWithEventContext(createFetchEvent(event.request, platform.env, platform.context), () => resolve(event));
240
+ }
241
+ async function createPlatformWithRequestContext(event, resolve, options) {
242
+ const platform = await createDevflarePlatform(options);
243
+ event.platform = platform;
244
+ return resolveWithPlatformContext(event, resolve, platform);
245
+ }
246
+ async function getAutoPlatformOptions() {
247
+ const options = await loadPlatformOptionsFromConfig();
248
+ setBindingHints(options.hints ?? {});
249
+ return options;
250
+ }
251
+ async function getCustomPlatformOptions(options) {
252
+ if (options.hints) setBindingHints(options.hints);
253
+ return options;
254
+ }
255
+ /**
256
+ * Create a SvelteKit handle that automatically injects the devflare platform
257
+ * in development mode. This eliminates the need for boilerplate in hooks.server.ts.
258
+ *
259
+ * @example
260
+ * ```ts
261
+ * // src/hooks.server.ts
262
+ * import { createHandle } from 'devflare/sveltekit'
263
+ *
264
+ * export const handle = createHandle({
265
+ * hints: {
266
+ * MY_KV: 'kv',
267
+ * MY_DO: 'do',
268
+ * MY_D1: 'd1',
269
+ * MY_R2: 'r2'
270
+ * }
271
+ * })
272
+ * ```
273
+ *
274
+ * @example Composing with other handles using SvelteKit's sequence
275
+ * ```ts
276
+ * import { sequence } from '@sveltejs/kit/hooks'
277
+ * import { createHandle } from 'devflare/sveltekit'
278
+ *
279
+ * const devflareHandle = createHandle({ hints: { ... } })
280
+ * const authHandle: Handle = async ({ event, resolve }) => { ... }
281
+ *
282
+ * export const handle = sequence(devflareHandle, authHandle)
283
+ * ```
284
+ */
285
+ function createHandle(options = {}) {
286
+ const { shouldEnable, ...platformOptions } = options;
287
+ return async ({ event, resolve }) => {
288
+ if (shouldEnable ? shouldEnable() : process.env.NODE_ENV !== "production" && process.env.DEVFLARE_DEV === "true") try {
289
+ return await createPlatformWithRequestContext(event, resolve, await getCustomPlatformOptions(platformOptions));
290
+ } catch (error) {
291
+ console.error("[devflare] Failed to create platform:", error);
292
+ }
293
+ return resolve(event);
294
+ };
295
+ }
296
+ /**
297
+ * Pre-configured SvelteKit handle that auto-loads binding hints from devflare.config.ts.
298
+ *
299
+ * This is the simplest way to integrate devflare with SvelteKit:
300
+ *
301
+ * @example Simplest usage — just re-export
302
+ * ```ts
303
+ * // src/hooks.server.ts
304
+ * export { handle } from 'devflare/sveltekit'
305
+ * ```
306
+ *
307
+ * @example With other handles
308
+ * ```ts
309
+ * // src/hooks.server.ts
310
+ * import { sequence } from '@sveltejs/kit/hooks'
311
+ * import { handle as devflareHandle } from 'devflare/sveltekit'
312
+ *
313
+ * const authHandle: Handle = async ({ event, resolve }) => { ... }
314
+ *
315
+ * export const handle = sequence(devflareHandle, authHandle)
316
+ * ```
317
+ */
318
+ const handle = async (input) => {
319
+ const { event, resolve } = input;
320
+ if (process.env.NODE_ENV !== "production" && process.env.DEVFLARE_DEV === "true") try {
321
+ return await createPlatformWithRequestContext(event, resolve, await getAutoPlatformOptions());
322
+ } catch (error) {
323
+ console.error("[devflare] Failed to create platform:", error);
324
+ }
325
+ return resolve(event);
10
326
  };
327
+ //#endregion
328
+ export { createDevflarePlatform, createHandle, getBridgePort, handle, isDevflareDev, resetConfigCache, resetPlatform };
@@ -1,4 +1,4 @@
1
- import { type DevflareConfig } from '../config';
1
+ import { type DevflareConfig } from '../config/index.js';
2
2
  export declare function buildSvelteKitLocalBindings(config: DevflareConfig, cwd: string): Record<string, unknown>;
3
3
  export declare function overlayLocalBindings(baseEnv: Record<string, unknown>, localBindings: Record<string, unknown>): Record<string, unknown>;
4
4
  //# sourceMappingURL=local-bindings.d.ts.map
@@ -1,4 +1,4 @@
1
- import { type BindingHints } from '../bridge';
1
+ import { type BindingHints } from '../bridge/index.js';
2
2
  /**
3
3
  * SvelteKit platform object shape
4
4
  */
@@ -1,5 +1,5 @@
1
- import type { BindingHints } from '../bridge/proxy';
2
- import type { DevflareConfig } from '../config';
1
+ import type { BindingHints } from '../bridge/proxy.js';
2
+ import type { DevflareConfig } from '../config/index.js';
3
3
  /**
4
4
  * Derive `BindingHints` from a resolved Devflare config.
5
5
  *
package/dist/test/cf.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- export { email } from './email';
2
- export { queue } from './queue';
3
- export { scheduled } from './scheduled';
4
- export { worker } from './worker';
5
- export { tail } from './tail';
6
- export type { EmailSendOptions, ReceivedEmail, EmailReceiveCallback } from './email';
7
- export type { QueueMessageOptions, QueueTriggerResult } from './queue';
8
- export type { ScheduledTriggerOptions, ScheduledTriggerResult } from './scheduled';
9
- export type { WorkerFetchOptions } from './worker';
10
- export type { TraceItemOptions, TailTriggerResult } from './tail';
1
+ export { email } from './email.js';
2
+ export { queue } from './queue.js';
3
+ export { scheduled } from './scheduled.js';
4
+ export { worker } from './worker.js';
5
+ export { tail } from './tail.js';
6
+ export type { EmailSendOptions, ReceivedEmail, EmailReceiveCallback } from './email.js';
7
+ export type { QueueMessageOptions, QueueTriggerResult } from './queue.js';
8
+ export type { ScheduledTriggerOptions, ScheduledTriggerResult } from './scheduled.js';
9
+ export type { WorkerFetchOptions } from './worker.js';
10
+ export type { TraceItemOptions, TailTriggerResult } from './tail.js';
11
11
  /**
12
12
  * Unified Cloudflare test helpers.
13
13
  *
@@ -76,9 +76,9 @@ export declare const cf: {
76
76
  * runtime exposes it.
77
77
  */
78
78
  email: {
79
- send: (options: import("./email").EmailSendOptions) => Promise<Response>;
80
- onReceive: (callback: import("./email").EmailReceiveCallback) => () => void;
81
- getSentEmails: () => import("./email").ReceivedEmail[];
79
+ send: (options: import("./email.js").EmailSendOptions) => Promise<Response>;
80
+ onReceive: (callback: import("./email.js").EmailReceiveCallback) => () => void;
81
+ getSentEmails: () => import("./email.js").ReceivedEmail[];
82
82
  clearSentEmails: () => void;
83
83
  };
84
84
  /**
@@ -90,8 +90,8 @@ export declare const cf: {
90
90
  * Returns result with `acked`, `retried`, `failed` message IDs.
91
91
  */
92
92
  queue: {
93
- trigger: <T = unknown>(messages: Array<import("./queue").QueueMessageOptions<T> | T>) => Promise<import("./queue").QueueTriggerResult>;
94
- send: <T = unknown>(message: import("./queue").QueueMessageOptions<T> | T) => Promise<import("./queue").QueueTriggerResult>;
93
+ trigger: <T = unknown>(messages: Array<import("./queue.js").QueueMessageOptions<T> | T>) => Promise<import("./queue.js").QueueTriggerResult>;
94
+ send: <T = unknown>(message: import("./queue.js").QueueMessageOptions<T> | T) => Promise<import("./queue.js").QueueTriggerResult>;
95
95
  };
96
96
  /**
97
97
  * Scheduled (cron) handler testing.
@@ -104,7 +104,7 @@ export declare const cf: {
104
104
  * await cf.scheduled.trigger('0 0 * * 1') // Weekly Monday
105
105
  */
106
106
  scheduled: {
107
- trigger: (cronOrOptions?: string | import("./scheduled").ScheduledTriggerOptions) => Promise<import("./scheduled").ScheduledTriggerResult>;
107
+ trigger: (cronOrOptions?: string | import("./scheduled.js").ScheduledTriggerOptions) => Promise<import("./scheduled.js").ScheduledTriggerResult>;
108
108
  };
109
109
  /**
110
110
  * Fetch (HTTP) handler testing.
@@ -120,7 +120,7 @@ export declare const cf: {
120
120
  * `src/routes/**` file routes when they are present.
121
121
  */
122
122
  worker: {
123
- fetch: (request: Request | string, options?: import("./worker").WorkerFetchOptions) => Promise<Response>;
123
+ fetch: (request: Request | string, options?: import("./worker.js").WorkerFetchOptions) => Promise<Response>;
124
124
  get: (path: string, headers?: Record<string, string>) => Promise<Response>;
125
125
  post: (path: string, body?: unknown, headers?: Record<string, string>) => Promise<Response>;
126
126
  put: (path: string, body?: unknown, headers?: Record<string, string>) => Promise<Response>;
@@ -137,8 +137,8 @@ export declare const cf: {
137
137
  * `cf.tail.trigger()` is wired automatically.
138
138
  */
139
139
  tail: {
140
- trigger: (items: Array<import("@cloudflare/workers-types").TraceItem | import("./tail").TraceItemOptions>) => Promise<import("./tail").TailTriggerResult>;
141
- create: (options?: import("./tail").TraceItemOptions) => import("@cloudflare/workers-types").TraceItem;
140
+ trigger: (items: Array<import("@cloudflare/workers-types").TraceItem | import("./tail.js").TraceItemOptions>) => Promise<import("./tail.js").TailTriggerResult>;
141
+ create: (options?: import("./tail.js").TraceItemOptions) => import("@cloudflare/workers-types").TraceItem;
142
142
  };
143
143
  };
144
144
  //# sourceMappingURL=cf.d.ts.map
@@ -1,19 +1,19 @@
1
- export { createTestContext, env, type DevflareEnv, type TestEnv } from './simple-context';
2
- export { cf } from './cf';
3
- export { email } from './email';
4
- export { queue } from './queue';
5
- export { scheduled } from './scheduled';
6
- export { worker } from './worker';
7
- export { tail } from './tail';
8
- export type { EmailSendOptions, ReceivedEmail, EmailReceiveCallback } from './email';
9
- export type { QueueMessageOptions, QueueTriggerResult } from './queue';
10
- export type { ScheduledTriggerOptions, ScheduledTriggerResult } from './scheduled';
11
- export type { WorkerFetchOptions } from './worker';
12
- export type { TraceItemOptions, TailTriggerResult } from './tail';
13
- export { hasServiceBindings, resolveServiceBindings, hasCrossWorkerDOs, resolveDOBindings, clearBundleCache, type ResolvedWorker, type ServiceBindingResolution, type DOBindingResolution } from './resolve-service-bindings';
14
- export { shouldSkip } from './should-skip';
15
- export { containers, createContainerManager, detectContainerEngine, getContainerSkipReason, stopActiveContainers, type ContainerCommandResult, type ContainerCommandRunner, type ContainerEngineCheck, type ContainerEngineName, type ContainerEnginePreference, type ContainerEngineStatus, type ContainerManager, type ContainerManagerOptions, type DevflareContainerInstance, type LocalContainerState, type StartContainerOptions } from './containers';
16
- export { createOfflineBindings, createOfflineEnv, describeOfflineSupport, getOfflineSupportMatrix, type OfflineBindingFixtures, type OfflineBindingsResult, type OfflineMissingFixture, type OfflineRemoteBoundary, type OfflineSupportEntry, type OfflineSupportTier } from './offline-bindings';
17
- export { createMockAISearchInstance, createMockAISearchNamespace, type MockAISearchInstance, type MockAISearchInstanceOptions, type MockAISearchItemFixture, type MockAISearchNamespace, type MockAISearchNamespaceOptions } from './ai-search';
18
- export { createMockTestContext, createMockKV, createMockD1, createMockR2, createMockQueue, createMockRateLimit, createMockVersionMetadata, createMockHyperdrive, createMockWorkerLoader, createMockMTLSCertificate, createMockDispatchNamespace, createMockWorkflow, createMockPipeline, createMockImagesBinding, createMockMediaBinding, createMockArtifacts, createMockSecretsStoreSecret, createMockEnv, withTestContext, type TestContext, type TestContextOptions, type MockEnvOptions, type MockRateLimitOptions, type MockWorkerLoaderOptions, type MockFetchInput, type MockFetcherHandler, type MockDispatchNamespaceOptions, type MockWorkflowOptions, type MockWorkflowInstanceOptions, type MockPipeline, type MockImagesBindingOptions, type MockMediaBindingOptions, type MockArtifactsOptions } from './utilities';
1
+ export { createTestContext, env, type DevflareEnv, type TestEnv } from './simple-context.js';
2
+ export { cf } from './cf.js';
3
+ export { email } from './email.js';
4
+ export { queue } from './queue.js';
5
+ export { scheduled } from './scheduled.js';
6
+ export { worker } from './worker.js';
7
+ export { tail } from './tail.js';
8
+ export type { EmailSendOptions, ReceivedEmail, EmailReceiveCallback } from './email.js';
9
+ export type { QueueMessageOptions, QueueTriggerResult } from './queue.js';
10
+ export type { ScheduledTriggerOptions, ScheduledTriggerResult } from './scheduled.js';
11
+ export type { WorkerFetchOptions } from './worker.js';
12
+ export type { TraceItemOptions, TailTriggerResult } from './tail.js';
13
+ export { hasServiceBindings, resolveServiceBindings, hasCrossWorkerDOs, resolveDOBindings, clearBundleCache, type ResolvedWorker, type ServiceBindingResolution, type DOBindingResolution } from './resolve-service-bindings.js';
14
+ export { shouldSkip } from './should-skip.js';
15
+ export { containers, createContainerManager, detectContainerEngine, getContainerSkipReason, stopActiveContainers, type ContainerCommandResult, type ContainerCommandRunner, type ContainerEngineCheck, type ContainerEngineName, type ContainerEnginePreference, type ContainerEngineStatus, type ContainerManager, type ContainerManagerOptions, type DevflareContainerInstance, type LocalContainerState, type StartContainerOptions } from './containers.js';
16
+ export { createOfflineBindings, createOfflineEnv, describeOfflineSupport, getOfflineSupportMatrix, type OfflineBindingFixtures, type OfflineBindingsResult, type OfflineMissingFixture, type OfflineRemoteBoundary, type OfflineSupportEntry, type OfflineSupportTier } from './offline-bindings.js';
17
+ export { createMockAISearchInstance, createMockAISearchNamespace, type MockAISearchInstance, type MockAISearchInstanceOptions, type MockAISearchItemFixture, type MockAISearchNamespace, type MockAISearchNamespaceOptions } from './ai-search.js';
18
+ export { createMockTestContext, createMockKV, createMockD1, createMockR2, createMockQueue, createMockRateLimit, createMockVersionMetadata, createMockHyperdrive, createMockWorkerLoader, createMockMTLSCertificate, createMockDispatchNamespace, createMockWorkflow, createMockPipeline, createMockImagesBinding, createMockMediaBinding, createMockArtifacts, createMockSecretsStoreSecret, createMockEnv, withTestContext, type TestContext, type TestContextOptions, type MockEnvOptions, type MockRateLimitOptions, type MockWorkerLoaderOptions, type MockFetchInput, type MockFetcherHandler, type MockDispatchNamespaceOptions, type MockWorkflowOptions, type MockWorkflowInstanceOptions, type MockPipeline, type MockImagesBindingOptions, type MockMediaBindingOptions, type MockArtifactsOptions } from './utilities.js';
19
19
  //# sourceMappingURL=index.d.ts.map