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
@@ -0,0 +1,143 @@
1
+ import { u as resolveConfigForEnvironment } from "./loader-DLXO60RO.js";
2
+ //#region src/cli/commands/previews-support/family.ts
3
+ function compareConfiguredWorkerFamilies(left, right) {
4
+ if (left.role === "primary" && right.role !== "primary") return -1;
5
+ if (left.role !== "primary" && right.role === "primary") return 1;
6
+ return left.baseName.localeCompare(right.baseName);
7
+ }
8
+ function comparePreviewScopeRows(left, right) {
9
+ const leftTime = left.updatedAt?.getTime() ?? 0;
10
+ const rightTime = right.updatedAt?.getTime() ?? 0;
11
+ if (rightTime !== leftTime) return rightTime - leftTime;
12
+ return left.scope.localeCompare(right.scope);
13
+ }
14
+ function collectConfiguredWorkerFamilies(config, environment) {
15
+ const resolvedConfig = resolveConfigForEnvironment(config, environment);
16
+ const families = /* @__PURE__ */ new Map();
17
+ families.set(resolvedConfig.name, {
18
+ baseName: resolvedConfig.name,
19
+ roleLabel: "primary",
20
+ role: "primary"
21
+ });
22
+ for (const [bindingName, binding] of Object.entries(resolvedConfig.bindings?.services ?? {})) {
23
+ if (families.get(binding.service)) continue;
24
+ families.set(binding.service, {
25
+ baseName: binding.service,
26
+ roleLabel: bindingName,
27
+ role: "service"
28
+ });
29
+ }
30
+ return Array.from(families.values()).sort(compareConfiguredWorkerFamilies);
31
+ }
32
+ function getWorkerUrl(workerName, workersSubdomain) {
33
+ if (!workersSubdomain) return;
34
+ return `https://${workerName}.${workersSubdomain}.workers.dev`;
35
+ }
36
+ function getWorkerScopeSuffix(workerName, baseName) {
37
+ if (!workerName.startsWith(`${baseName}-`)) return;
38
+ return workerName.slice(baseName.length + 1).trim() || void 0;
39
+ }
40
+ function buildStableWorkerRowsFromLiveWorkers(families, workers, workersSubdomain) {
41
+ const workersByName = new Map(workers.map((worker) => [worker.name, worker]));
42
+ return families.map((family) => {
43
+ const worker = workersByName.get(family.baseName);
44
+ const status = worker ? "active" : "missing";
45
+ return {
46
+ workerName: family.baseName,
47
+ role: family.roleLabel,
48
+ status,
49
+ updatedAt: worker?.modifiedOn,
50
+ url: worker ? getWorkerUrl(family.baseName, workersSubdomain) : void 0
51
+ };
52
+ });
53
+ }
54
+ function getDedicatedPreviewFamilyNamesFromWorkers(families, workers) {
55
+ const familyNames = /* @__PURE__ */ new Set();
56
+ const workerNames = workers.map((worker) => worker.name);
57
+ for (const family of families) {
58
+ if (family.role === "primary") {
59
+ familyNames.add(family.baseName);
60
+ continue;
61
+ }
62
+ if (workerNames.some((workerName) => Boolean(getWorkerScopeSuffix(workerName, family.baseName)))) familyNames.add(family.baseName);
63
+ }
64
+ return familyNames;
65
+ }
66
+ function buildPreviewScopeRowsFromLiveWorkers(families, workers, workersSubdomain) {
67
+ const workersByName = new Map(workers.map((worker) => [worker.name, worker]));
68
+ const previewFamilyNames = getDedicatedPreviewFamilyNamesFromWorkers(families, workers);
69
+ const expectedFamilies = families.filter((family) => previewFamilyNames.has(family.baseName));
70
+ const workerCandidatesByScope = buildPreviewWorkerCandidatesByScope(families, workers);
71
+ return Array.from(workerCandidatesByScope.keys()).map((scope) => {
72
+ const resolvedFamilies = expectedFamilies.map((family) => ({
73
+ family,
74
+ worker: workersByName.get(`${family.baseName}-${scope}`)
75
+ }));
76
+ const presentFamilies = resolvedFamilies.filter((entry) => entry.worker);
77
+ const updatedAt = presentFamilies.reduce((latest, entry) => {
78
+ const currentDate = entry.worker?.modifiedOn;
79
+ if (!currentDate) return latest;
80
+ if (!latest || currentDate.getTime() > latest.getTime()) return currentDate;
81
+ return latest;
82
+ }, void 0);
83
+ const entryWorker = resolvedFamilies.find((entry) => entry.family.role === "primary")?.worker ?? presentFamilies[0]?.worker;
84
+ const missingLabels = resolvedFamilies.filter((entry) => !entry.worker).map((entry) => entry.family.role === "primary" ? "primary" : entry.family.roleLabel);
85
+ const notes = [];
86
+ if (missingLabels.length > 0) notes.push(`missing ${missingLabels.join(", ")}`);
87
+ const strategy = "dedicated workers";
88
+ const status = presentFamilies.length === resolvedFamilies.length ? "ready" : "partial";
89
+ return {
90
+ scope,
91
+ strategy,
92
+ workersLabel: `${presentFamilies.length}/${resolvedFamilies.length}`,
93
+ status,
94
+ updatedAt,
95
+ notes: notes.length > 0 ? notes.join(" · ") : void 0,
96
+ entryUrl: entryWorker ? getWorkerUrl(entryWorker.name, workersSubdomain) : void 0
97
+ };
98
+ }).sort(comparePreviewScopeRows);
99
+ }
100
+ function buildPreviewWorkerCandidatesByScope(families, workers) {
101
+ const candidates = /* @__PURE__ */ new Map();
102
+ for (const worker of workers) for (const family of families) {
103
+ const scope = getWorkerScopeSuffix(worker.name, family.baseName);
104
+ if (!scope) continue;
105
+ const names = candidates.get(scope) ?? /* @__PURE__ */ new Set();
106
+ names.add(worker.name);
107
+ candidates.set(scope, names);
108
+ }
109
+ return new Map(Array.from(candidates.entries()).map(([scope, workerNames]) => {
110
+ return [scope, Array.from(workerNames).sort((left, right) => left.localeCompare(right))];
111
+ }));
112
+ }
113
+ function orderPreviewWorkerNamesForDeletion(workerNames, scope, families) {
114
+ const familyPriority = /* @__PURE__ */ new Map();
115
+ for (const family of families) familyPriority.set(family.baseName, {
116
+ priority: family.role === "primary" ? 0 : 1,
117
+ roleLabel: family.roleLabel
118
+ });
119
+ const resolveFamilyForWorker = (workerName) => {
120
+ for (const family of families) if (getWorkerScopeSuffix(workerName, family.baseName) === scope) {
121
+ const resolved = familyPriority.get(family.baseName);
122
+ if (resolved) return {
123
+ priority: resolved.priority,
124
+ roleLabel: resolved.roleLabel,
125
+ baseName: family.baseName
126
+ };
127
+ }
128
+ return {
129
+ priority: 2,
130
+ roleLabel: workerName
131
+ };
132
+ };
133
+ return [...workerNames].sort((left, right) => {
134
+ const leftFamily = resolveFamilyForWorker(left);
135
+ const rightFamily = resolveFamilyForWorker(right);
136
+ if (leftFamily.priority !== rightFamily.priority) return leftFamily.priority - rightFamily.priority;
137
+ if (leftFamily.roleLabel !== rightFamily.roleLabel) return leftFamily.roleLabel.localeCompare(rightFamily.roleLabel);
138
+ if (leftFamily.baseName && rightFamily.baseName && leftFamily.baseName !== rightFamily.baseName) return leftFamily.baseName.localeCompare(rightFamily.baseName);
139
+ return left.localeCompare(right);
140
+ });
141
+ }
142
+ //#endregion
143
+ export { orderPreviewWorkerNamesForDeletion as a, collectConfiguredWorkerFamilies as i, buildPreviewWorkerCandidatesByScope as n, buildStableWorkerRowsFromLiveWorkers as r, buildPreviewScopeRowsFromLiveWorkers as t };
@@ -0,0 +1,32 @@
1
+ import { resolve } from "pathe";
2
+ //#region src/cli/generated-artifacts.ts
3
+ const DEVFLARE_DIR = [".devflare"];
4
+ const DEVFLARE_BUILD_DIR = [".devflare", "build"];
5
+ const WRANGLER_DEPLOY_DIR = [".wrangler", "deploy"];
6
+ function getGeneratedArtifactPaths(cwd) {
7
+ const devflareDir = resolve(cwd, ...DEVFLARE_DIR);
8
+ const buildDir = resolve(cwd, ...DEVFLARE_BUILD_DIR);
9
+ const deployDir = resolve(cwd, ...WRANGLER_DEPLOY_DIR);
10
+ return {
11
+ devflareDir,
12
+ devWranglerConfigPath: resolve(devflareDir, "wrangler.jsonc"),
13
+ buildDir,
14
+ buildWorkerPath: resolve(buildDir, "worker.js"),
15
+ buildWranglerConfigPath: resolve(buildDir, "wrangler.jsonc"),
16
+ deployDir,
17
+ deployRedirectPath: resolve(deployDir, "config.json")
18
+ };
19
+ }
20
+ async function ensureGeneratedDirectory(dirPath, writeGitignore = false) {
21
+ const fs = await import("node:fs/promises");
22
+ await fs.mkdir(dirPath, { recursive: true });
23
+ if (!writeGitignore) return;
24
+ const gitignorePath = resolve(dirPath, ".gitignore");
25
+ try {
26
+ await fs.access(gitignorePath);
27
+ } catch {
28
+ await fs.writeFile(gitignorePath, "*\n", "utf-8");
29
+ }
30
+ }
31
+ //#endregion
32
+ export { getGeneratedArtifactPaths as n, ensureGeneratedDirectory as t };
@@ -0,0 +1,56 @@
1
+ import { globby, globbySync } from "globby";
2
+ //#region src/utils/glob.ts
3
+ /** Default glob pattern for Durable Object discovery */
4
+ const DEFAULT_DO_PATTERN = "**/do.*.{ts,js}";
5
+ /** Default glob pattern for WorkerEntrypoint discovery */
6
+ const DEFAULT_ENTRYPOINT_PATTERN = "**/ep.*.{ts,js}";
7
+ /** Default glob pattern for Workflow discovery */
8
+ const DEFAULT_WORKFLOW_PATTERN = "**/wf.*.{ts,js}";
9
+ /**
10
+ * Find files matching a glob pattern with .gitignore support.
11
+ * This is the async version for use in CLI commands and bundlers.
12
+ *
13
+ * @param pattern - Glob pattern (e.g., '**​/do.*.{ts,js}')
14
+ * @param options - Glob options
15
+ * @returns Array of matching file paths
16
+ */
17
+ async function findFiles(pattern, options) {
18
+ const { cwd, absolute = true, gitignore = true } = options;
19
+ return globby(pattern, {
20
+ cwd,
21
+ absolute,
22
+ gitignore,
23
+ ignore: [
24
+ "**/node_modules/**",
25
+ "**/.devflare/**",
26
+ "**/dist/**",
27
+ "**/build/**",
28
+ "**/.git/**"
29
+ ]
30
+ });
31
+ }
32
+ /**
33
+ * Find files matching a glob pattern synchronously.
34
+ * Use sparingly — prefer async version for better performance.
35
+ *
36
+ * @param pattern - Glob pattern (e.g., '**​/do.*.{ts,js}')
37
+ * @param options - Glob options
38
+ * @returns Array of matching file paths
39
+ */
40
+ function findFilesSync(pattern, options) {
41
+ const { cwd, absolute = true, gitignore = true } = options;
42
+ return globbySync(pattern, {
43
+ cwd,
44
+ absolute,
45
+ gitignore,
46
+ ignore: [
47
+ "**/node_modules/**",
48
+ "**/.devflare/**",
49
+ "**/dist/**",
50
+ "**/build/**",
51
+ "**/.git/**"
52
+ ]
53
+ });
54
+ }
55
+ //#endregion
56
+ export { findFilesSync as a, findFiles as i, DEFAULT_ENTRYPOINT_PATTERN as n, DEFAULT_WORKFLOW_PATTERN as r, DEFAULT_DO_PATTERN as t };
@@ -0,0 +1,165 @@
1
+ import { a as cyanBold, d as green, f as logLine, o as dim, r as createCliTheme } from "./ui-BUoZApvE.js";
2
+ import { t as getInitDependencyVersions } from "./package-metadata-DAuCkyvK.js";
3
+ import { t as getDependencies } from "./dependencies-C2oxFjU_.js";
4
+ import { join, resolve } from "pathe";
5
+ //#region src/cli/commands/init.ts
6
+ const MINIMAL_TEMPLATE = {
7
+ name: "minimal",
8
+ description: "Minimal starter with single handler",
9
+ files: {
10
+ "devflare.config.ts": `import { defineConfig } from 'devflare/config'
11
+
12
+ export default defineConfig({
13
+ name: '{{PROJECT_NAME}}',
14
+ compatibilityDate: '${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}',
15
+ files: {
16
+ fetch: 'src/fetch.ts'
17
+ }
18
+ })
19
+ `,
20
+ "src/fetch.ts": `import type { FetchEvent } from 'devflare/runtime'
21
+
22
+ export async function fetch({ url }: FetchEvent): Promise<Response> {
23
+ return new Response(
24
+ url.pathname === '/'
25
+ ? 'Hello from Devflare'
26
+ : \`Hello from Devflare: \${url.pathname}\`
27
+ )
28
+ }
29
+ `,
30
+ "package.json": `{
31
+ "name": "{{PROJECT_NAME}}",
32
+ "version": "0.0.1",
33
+ "private": true,
34
+ "type": "module",
35
+ "scripts": {
36
+ "dev": "devflare dev",
37
+ "build": "devflare build",
38
+ "deploy": "devflare deploy",
39
+ "types": "devflare types"
40
+ },
41
+ "devDependencies": {
42
+ "@cloudflare/workers-types": "{{WORKERS_TYPES_VERSION}}",
43
+ "devflare": "{{DEVFLARE_VERSION}}",
44
+ "typescript": "{{TYPESCRIPT_VERSION}}",
45
+ "wrangler": "{{WRANGLER_VERSION}}"
46
+ }
47
+ }
48
+ `,
49
+ "tsconfig.json": `{
50
+ "compilerOptions": {
51
+ "target": "ESNext",
52
+ "module": "ESNext",
53
+ "moduleResolution": "bundler",
54
+ "strict": true,
55
+ "skipLibCheck": true,
56
+ "types": ["@cloudflare/workers-types"]
57
+ },
58
+ "include": ["src/**/*", "env.d.ts", "devflare.config.ts"]
59
+ }
60
+ `
61
+ }
62
+ };
63
+ const TEMPLATES = {
64
+ minimal: MINIMAL_TEMPLATE,
65
+ api: {
66
+ name: "api",
67
+ description: "API starter with request-wide middleware",
68
+ files: {
69
+ "devflare.config.ts": `import { defineConfig } from 'devflare/config'
70
+
71
+ export default defineConfig({
72
+ name: '{{PROJECT_NAME}}',
73
+ compatibilityDate: '${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}',
74
+ files: {
75
+ fetch: 'src/fetch.ts'
76
+ }
77
+ })
78
+ `,
79
+ "src/fetch.ts": `import { sequence } from 'devflare/runtime'
80
+ import { corsHandle } from './middleware/cors'
81
+ import { appFetch } from './app'
82
+
83
+ export const handle = sequence(corsHandle, appFetch)
84
+ `,
85
+ "src/middleware/cors.ts": `import type { FetchEvent, ResolveFetch } from 'devflare/runtime'
86
+
87
+ export async function corsHandle(event: FetchEvent, resolve: ResolveFetch): Promise<Response> {
88
+ // Handle preflight
89
+ if (event.request.method === 'OPTIONS') {
90
+ return new Response(null, {
91
+ headers: {
92
+ 'Access-Control-Allow-Origin': '*',
93
+ 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
94
+ 'Access-Control-Allow-Headers': 'Content-Type, Authorization'
95
+ }
96
+ })
97
+ }
98
+
99
+ const response = await resolve(event)
100
+ const next = new Response(response.body, response)
101
+ next.headers.set('Access-Control-Allow-Origin', '*')
102
+ return next
103
+ }
104
+ `,
105
+ "src/app.ts": `import type { FetchEvent } from 'devflare/runtime'
106
+
107
+ export async function appFetch({ url }: FetchEvent): Promise<Response> {
108
+ if (url.pathname === '/api/health') {
109
+ return Response.json({ status: 'ok' })
110
+ }
111
+
112
+ if (url.pathname.startsWith('/api/')) {
113
+ return Response.json({ error: 'Not found' }, { status: 404 })
114
+ }
115
+
116
+ return new Response('Not Found', { status: 404 })
117
+ }
118
+ `,
119
+ "package.json": MINIMAL_TEMPLATE.files["package.json"],
120
+ "tsconfig.json": MINIMAL_TEMPLATE.files["tsconfig.json"]
121
+ }
122
+ }
123
+ };
124
+ async function runInitCommand(parsed, logger, options) {
125
+ const projectName = parsed.args[0] || "my-devflare-app";
126
+ const templateName = parsed.options.template || "minimal";
127
+ const cwd = options.cwd || process.cwd();
128
+ const theme = createCliTheme(parsed.options);
129
+ logLine(logger);
130
+ logLine(logger, `${cyanBold("init", theme)} ${dim("Creating a new Devflare project", theme)}`);
131
+ logLine(logger, `${dim("project", theme)} ${green(projectName, theme)}`);
132
+ const template = TEMPLATES[templateName];
133
+ if (!template) {
134
+ logger.error(`Unknown template: ${templateName}`);
135
+ logger.info(`Available templates: ${Object.keys(TEMPLATES).join(", ")}`);
136
+ return { exitCode: 1 };
137
+ }
138
+ const projectDir = resolve(cwd, projectName);
139
+ const dependencyVersions = await getInitDependencyVersions();
140
+ const { fs } = await getDependencies();
141
+ try {
142
+ await fs.access(projectDir);
143
+ logger.error(`Directory already exists: ${projectDir}`);
144
+ return { exitCode: 1 };
145
+ } catch {}
146
+ await fs.mkdir(projectDir, { recursive: true });
147
+ for (const [filePath, content] of Object.entries(template.files)) {
148
+ const fullPath = join(projectDir, filePath);
149
+ const dir = fullPath.substring(0, fullPath.lastIndexOf("/"));
150
+ await fs.mkdir(dir, { recursive: true }).catch(() => {});
151
+ const processedContent = content.replace(/\{\{PROJECT_NAME\}\}/g, projectName).replace(/\{\{DEVFLARE_VERSION\}\}/g, dependencyVersions.devflare).replace(/\{\{TYPESCRIPT_VERSION\}\}/g, dependencyVersions.typescript).replace(/\{\{WRANGLER_VERSION\}\}/g, dependencyVersions.wrangler).replace(/\{\{WORKERS_TYPES_VERSION\}\}/g, dependencyVersions.workersTypes);
152
+ await fs.writeFile(fullPath, processedContent, "utf-8");
153
+ logLine(logger, ` ${dim("created", theme)} ${filePath}`);
154
+ }
155
+ logger.success("Project created successfully!");
156
+ logLine(logger);
157
+ logLine(logger, dim("next steps", theme));
158
+ logLine(logger, ` cd ${projectName}`);
159
+ logLine(logger, " bun install");
160
+ logLine(logger, " bun run types");
161
+ logLine(logger, " bun run dev");
162
+ return { exitCode: 0 };
163
+ }
164
+ //#endregion
165
+ export { runInitCommand };