devflare 1.0.0-next.10 → 1.0.0-next.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LLM.md +683 -13
  2. package/README.md +33 -5
  3. package/dist/{build-k36xrzvy.js → build-rfh8cgh3.js} +40 -11
  4. package/dist/bundler/index.d.ts +1 -0
  5. package/dist/bundler/index.d.ts.map +1 -1
  6. package/dist/bundler/worker-bundler.d.ts +14 -0
  7. package/dist/bundler/worker-bundler.d.ts.map +1 -0
  8. package/dist/cli/commands/build.d.ts.map +1 -1
  9. package/dist/cli/commands/deploy.d.ts.map +1 -1
  10. package/dist/cli/commands/dev.d.ts.map +1 -1
  11. package/dist/config/compiler.d.ts.map +1 -1
  12. package/dist/config/index.d.ts +1 -0
  13. package/dist/config/index.d.ts.map +1 -1
  14. package/dist/config/resolve.d.ts +3 -0
  15. package/dist/config/resolve.d.ts.map +1 -0
  16. package/dist/config/schema.d.ts +37 -31
  17. package/dist/config/schema.d.ts.map +1 -1
  18. package/dist/{deploy-dbvfq8vq.js → deploy-k0fcgt3d.js} +40 -11
  19. package/dist/{dev-rk8p6pse.js → dev-d4wabqyf.js} +73 -470
  20. package/dist/dev-server/server.d.ts.map +1 -1
  21. package/dist/{doctor-06y8nxd4.js → doctor-z4ffybce.js} +2 -2
  22. package/dist/{index-jht2j546.js → index-0kzg8wed.js} +26 -6
  23. package/dist/index-1xqeptt2.js +623 -0
  24. package/dist/{index-pwgyy2q9.js → index-dr6sbp8d.js} +1 -1
  25. package/dist/{index-6v3wjg1r.js → index-rfhx0yd5.js} +11 -7
  26. package/dist/{index-05fyzwne.js → index-twpgq9k9.js} +5 -5
  27. package/dist/{index-1phx14av.js → index-wyf3s77s.js} +1 -1
  28. package/dist/{index-vs49yxn4.js → index-xxwbb2nt.js} +1 -1
  29. package/dist/index-zbvmtcn2.js +795 -0
  30. package/dist/src/browser.js +1 -1
  31. package/dist/src/cli/index.js +1 -1
  32. package/dist/src/index.js +12 -13
  33. package/dist/src/sveltekit/index.js +4 -5
  34. package/dist/src/test/index.js +6 -7
  35. package/dist/src/vite/index.js +19 -399
  36. package/dist/test/simple-context.d.ts.map +1 -1
  37. package/dist/{types-x9q7t491.js → types-sffr9681.js} +7 -8
  38. package/dist/vite/config-file.d.ts +25 -0
  39. package/dist/vite/config-file.d.ts.map +1 -0
  40. package/dist/vite/index.d.ts +1 -0
  41. package/dist/vite/index.d.ts.map +1 -1
  42. package/dist/worker-entry/composed-worker.d.ts.map +1 -1
  43. package/package.json +1 -1
  44. package/dist/index-k7r18na8.js +0 -0
  45. package/dist/index-ws68xvq2.js +0 -311
@@ -16,13 +16,13 @@ import {
16
16
  initEnv,
17
17
  setBindingHints
18
18
  } from "../index-59df49vn.js";
19
+ import"../index-fef08w43.js";
19
20
  import {
20
21
  defineConfig,
21
22
  ref,
22
23
  resolveRef,
23
24
  serviceBinding
24
25
  } from "../index-v8vvsn9x.js";
25
- import"../index-fef08w43.js";
26
26
  import"../index-37x76zdn.js";
27
27
 
28
28
  // src/browser.ts
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  parseArgs,
3
3
  runCli
4
- } from "../../index-05fyzwne.js";
4
+ } from "../../index-twpgq9k9.js";
5
5
  import"../../index-6h8xbs75.js";
6
6
  import"../../index-37x76zdn.js";
7
7
  export {
package/dist/src/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  parseArgs,
6
6
  runCli
7
- } from "../index-05fyzwne.js";
7
+ } from "../index-twpgq9k9.js";
8
8
  import"../index-6h8xbs75.js";
9
9
  import {
10
10
  createBridgeTestContext,
@@ -19,7 +19,7 @@ import {
19
19
  stopBridgeTestContext,
20
20
  testEnv,
21
21
  withTestContext
22
- } from "../index-jht2j546.js";
22
+ } from "../index-0kzg8wed.js";
23
23
  import"../index-d8bdkx2h.js";
24
24
  import {
25
25
  findExportedFunctions,
@@ -38,13 +38,13 @@ import {
38
38
  getDurableObjectOptions
39
39
  } from "../index-a855bdsx.js";
40
40
  import"../index-1p814k7s.js";
41
+ import"../index-rbht7m9r.js";
41
42
  import {
42
43
  findDurableObjectClasses,
43
44
  findDurableObjectClassesDetailed,
44
45
  generateWrapper,
45
46
  transformDurableObject
46
47
  } from "../index-9wt9x09k.js";
47
- import"../index-rbht7m9r.js";
48
48
  import {
49
49
  server_default
50
50
  } from "../index-n932ytmq.js";
@@ -53,8 +53,7 @@ import {
53
53
  startMiniflare,
54
54
  startMiniflareFromConfig,
55
55
  stopMiniflare
56
- } from "../index-vs49yxn4.js";
57
- import"../index-k7r18na8.js";
56
+ } from "../index-xxwbb2nt.js";
58
57
  import {
59
58
  BridgeClient,
60
59
  createEnvProxy,
@@ -62,23 +61,23 @@ import {
62
61
  initEnv,
63
62
  setBindingHints
64
63
  } from "../index-59df49vn.js";
65
- import {
66
- defineConfig,
67
- ref,
68
- resolveRef,
69
- serviceBinding
70
- } from "../index-v8vvsn9x.js";
71
64
  import"../index-fef08w43.js";
72
65
  import {
73
66
  compileConfig,
74
67
  stringifyConfig
75
- } from "../index-6v3wjg1r.js";
68
+ } from "../index-rfhx0yd5.js";
76
69
  import {
77
70
  ConfigNotFoundError,
78
71
  ConfigValidationError,
79
72
  configSchema,
80
73
  loadConfig
81
- } from "../index-1phx14av.js";
74
+ } from "../index-wyf3s77s.js";
75
+ import {
76
+ defineConfig,
77
+ ref,
78
+ resolveRef,
79
+ serviceBinding
80
+ } from "../index-v8vvsn9x.js";
82
81
  import"../index-tfyxa77h.js";
83
82
  import"../index-37x76zdn.js";
84
83
  export {
@@ -1,16 +1,15 @@
1
1
  import"../../index-n932ytmq.js";
2
- import"../../index-vs49yxn4.js";
3
- import"../../index-k7r18na8.js";
2
+ import"../../index-xxwbb2nt.js";
4
3
  import {
5
4
  createEnvProxy,
6
5
  getClient
7
6
  } from "../../index-59df49vn.js";
8
- import"../../index-v8vvsn9x.js";
9
7
  import"../../index-fef08w43.js";
10
- import"../../index-6v3wjg1r.js";
8
+ import"../../index-rfhx0yd5.js";
11
9
  import {
12
10
  loadConfig
13
- } from "../../index-1phx14av.js";
11
+ } from "../../index-wyf3s77s.js";
12
+ import"../../index-v8vvsn9x.js";
14
13
  import"../../index-37x76zdn.js";
15
14
 
16
15
  // src/sveltekit/platform.ts
@@ -26,7 +26,7 @@ import {
26
26
  testEnv,
27
27
  withTestContext,
28
28
  worker
29
- } from "../../index-jht2j546.js";
29
+ } from "../../index-0kzg8wed.js";
30
30
  import"../../index-d8bdkx2h.js";
31
31
  import"../../index-wfbfz02q.js";
32
32
  import"../../index-2q3pmzrx.js";
@@ -37,15 +37,14 @@ import"../../index-8gtqgb3q.js";
37
37
  import"../../index-5yxg30va.js";
38
38
  import"../../index-a855bdsx.js";
39
39
  import"../../index-1p814k7s.js";
40
- import"../../index-9wt9x09k.js";
41
40
  import"../../index-rbht7m9r.js";
42
- import"../../index-vs49yxn4.js";
43
- import"../../index-k7r18na8.js";
41
+ import"../../index-9wt9x09k.js";
42
+ import"../../index-xxwbb2nt.js";
44
43
  import"../../index-59df49vn.js";
45
- import"../../index-v8vvsn9x.js";
46
44
  import"../../index-fef08w43.js";
47
- import"../../index-6v3wjg1r.js";
48
- import"../../index-1phx14av.js";
45
+ import"../../index-rfhx0yd5.js";
46
+ import"../../index-wyf3s77s.js";
47
+ import"../../index-v8vvsn9x.js";
49
48
  import"../../index-tfyxa77h.js";
50
49
  import"../../index-37x76zdn.js";
51
50
  export {
@@ -1,405 +1,25 @@
1
1
  import {
2
- prepareComposedWorkerEntrypoint
3
- } from "../../index-ws68xvq2.js";
2
+ devflarePlugin,
3
+ getCloudflareConfig,
4
+ getDevflareConfigs,
5
+ getPluginContext,
6
+ hasInlineViteConfig,
7
+ resolveEffectiveViteProject,
8
+ resolveViteUserConfig,
9
+ writeGeneratedViteConfig
10
+ } from "../../index-zbvmtcn2.js";
4
11
  import"../../index-1p814k7s.js";
5
- import {
6
- findDurableObjectClasses
7
- } from "../../index-9wt9x09k.js";
8
- import {
9
- DEFAULT_DO_PATTERN,
10
- findFiles
11
- } from "../../index-rbht7m9r.js";
12
- import {
13
- compileConfig,
14
- compileToProgrammaticConfig,
15
- writeWranglerConfig
16
- } from "../../index-6v3wjg1r.js";
17
- import {
18
- loadConfig,
19
- resolveConfigPath
20
- } from "../../index-1phx14av.js";
21
- import {
22
- __require
23
- } from "../../index-37x76zdn.js";
24
-
25
- // src/vite/plugin.ts
26
- import { isAbsolute, relative, resolve } from "pathe";
27
- var CONFIG_DIR = ".devflare";
28
- var VIRTUAL_DO_ENTRY = "virtual:devflare-do-entry";
29
- var RESOLVED_VIRTUAL_DO_ENTRY = "\x00" + VIRTUAL_DO_ENTRY;
30
- var pluginContext = {
31
- wranglerConfig: null,
32
- cloudflareConfig: null,
33
- projectRoot: process.cwd(),
34
- auxiliaryWorkerConfig: null,
35
- durableObjects: null
36
- };
37
- function getPluginContext() {
38
- return pluginContext;
39
- }
40
- async function discoverDurableObjects(projectRoot, pattern, workerName) {
41
- const files = new Map;
42
- const matchedFiles = await findFiles(pattern, { cwd: projectRoot });
43
- const fs = await import("node:fs/promises");
44
- for (const filePath of matchedFiles) {
45
- try {
46
- const code = await fs.readFile(filePath, "utf-8");
47
- const classNames = findDurableObjectClasses(code);
48
- if (classNames.length > 0) {
49
- files.set(filePath, classNames);
50
- }
51
- } catch (error) {
52
- console.warn(`[devflare] Failed to read DO file: ${filePath}`, error);
53
- }
54
- }
55
- return { files, workerName };
56
- }
57
- function generateVirtualDOEntry(discovery) {
58
- const lines = [
59
- "// Auto-generated by devflare — DO entry module",
60
- "// Re-exports all Durable Object classes discovered from files.durableObjects pattern",
61
- ""
62
- ];
63
- for (const [filePath, classNames] of discovery.files) {
64
- const normalizedPath = filePath.replace(/\\/g, "/");
65
- lines.push(`export { ${classNames.join(", ")} } from '${normalizedPath}'`);
66
- }
67
- lines.push("");
68
- lines.push("// Default fetch handler for DO worker");
69
- lines.push("export default {");
70
- lines.push("\tasync fetch(request: Request): Promise<Response> {");
71
- lines.push('\t\treturn new Response("Devflare DO Worker", { status: 200 })');
72
- lines.push("\t}");
73
- lines.push("}");
74
- return lines.join(`
75
- `);
76
- }
77
- function createAuxiliaryWorkerConfig(wranglerConfig, discovery) {
78
- const doBindings = wranglerConfig.durable_objects?.bindings?.map((binding) => ({
79
- name: binding.name,
80
- class_name: binding.class_name
81
- })) ?? [];
82
- return {
83
- config: {
84
- name: discovery.workerName,
85
- main: VIRTUAL_DO_ENTRY,
86
- compatibility_date: wranglerConfig.compatibility_date,
87
- compatibility_flags: wranglerConfig.compatibility_flags,
88
- durable_objects: { bindings: doBindings },
89
- migrations: wranglerConfig.migrations,
90
- kv_namespaces: wranglerConfig.kv_namespaces,
91
- d1_databases: wranglerConfig.d1_databases,
92
- r2_buckets: wranglerConfig.r2_buckets,
93
- browser: wranglerConfig.browser
94
- }
95
- };
96
- }
97
- function rebaseMainPathForConfigDir(projectRoot, configDir, mainEntry) {
98
- if (!mainEntry) {
99
- return mainEntry;
100
- }
101
- const absoluteMainPath = isAbsolute(mainEntry) ? mainEntry : resolve(projectRoot, mainEntry);
102
- return relative(configDir, absoluteMainPath).replace(/\\/g, "/");
103
- }
104
- function logDiscoveredDurableObjects(projectRoot, discovery) {
105
- if (!discovery || discovery.files.size === 0) {
106
- return;
107
- }
108
- console.log(`[devflare] Discovered ${discovery.files.size} DO file(s):`);
109
- for (const [filePath, classes] of discovery.files) {
110
- console.log(` • ${filePath.replace(projectRoot, ".")} → ${classes.join(", ")}`);
111
- }
112
- }
113
- async function buildPluginContextState(projectRoot, devflareConfig, environment) {
114
- const wranglerConfig = compileConfig(devflareConfig, environment);
115
- const cloudflareConfig = compileToProgrammaticConfig(devflareConfig, environment);
116
- const composedMainEntry = await prepareComposedWorkerEntrypoint(projectRoot, devflareConfig, environment);
117
- if (composedMainEntry) {
118
- wranglerConfig.main = composedMainEntry;
119
- cloudflareConfig.main = composedMainEntry;
120
- }
121
- let durableObjects = null;
122
- let auxiliaryWorkerConfig = null;
123
- const doPatternConfig = devflareConfig.files?.durableObjects;
124
- const doPattern = typeof doPatternConfig === "string" ? doPatternConfig : DEFAULT_DO_PATTERN;
125
- if (doPatternConfig !== false) {
126
- const doWorkerName = `${wranglerConfig.name}-do`;
127
- const discovery = await discoverDurableObjects(projectRoot, doPattern, doWorkerName);
128
- if (discovery.files.size > 0) {
129
- durableObjects = discovery;
130
- if (wranglerConfig.durable_objects?.bindings) {
131
- for (const binding of wranglerConfig.durable_objects.bindings) {
132
- binding.script_name = doWorkerName;
133
- }
134
- }
135
- if (cloudflareConfig.durable_objects) {
136
- const doConfig = cloudflareConfig.durable_objects;
137
- for (const binding of doConfig.bindings) {
138
- binding.script_name = doWorkerName;
139
- }
140
- }
141
- auxiliaryWorkerConfig = createAuxiliaryWorkerConfig(wranglerConfig, discovery);
142
- }
143
- }
144
- return {
145
- wranglerConfig,
146
- cloudflareConfig,
147
- durableObjects,
148
- auxiliaryWorkerConfig
149
- };
150
- }
151
- async function ensureGeneratedConfigDir(projectRoot) {
152
- const configDir = resolve(projectRoot, CONFIG_DIR);
153
- const fs = await import("node:fs/promises");
154
- await fs.mkdir(configDir, { recursive: true });
155
- const gitignorePath = resolve(configDir, ".gitignore");
156
- try {
157
- await fs.access(gitignorePath);
158
- } catch {
159
- await fs.writeFile(gitignorePath, `*
160
- `, "utf-8");
161
- }
162
- return configDir;
163
- }
164
- async function writeGeneratedWranglerConfig(projectRoot, wranglerConfig) {
165
- const configDir = await ensureGeneratedConfigDir(projectRoot);
166
- const wranglerFileConfig = {
167
- ...wranglerConfig,
168
- ...wranglerConfig.main && {
169
- main: rebaseMainPathForConfigDir(projectRoot, configDir, wranglerConfig.main)
170
- }
171
- };
172
- await writeWranglerConfig(configDir, wranglerFileConfig, "wrangler.jsonc");
173
- }
174
- async function resolvePluginConfigPath(projectRoot, configPath) {
175
- if (configPath) {
176
- return isAbsolute(configPath) ? configPath : resolve(projectRoot, configPath);
177
- }
178
- return await resolveConfigPath(projectRoot) ?? null;
179
- }
180
- function devflarePlugin(options = {}) {
181
- const {
182
- configPath,
183
- environment,
184
- doTransforms = true,
185
- watchConfig = true,
186
- bridgePort = process.env.DEVFLARE_BRIDGE_PORT ? parseInt(process.env.DEVFLARE_BRIDGE_PORT, 10) : undefined,
187
- wsProxyPatterns = []
188
- } = options;
189
- let projectRoot;
190
- let devflareConfig;
191
- let resolvedPluginConfigPath = null;
192
- return {
193
- name: "devflare",
194
- enforce: "pre",
195
- async config(config, { command }) {
196
- const cwd = config.root ?? process.cwd();
197
- const returnConfig = {};
198
- let lfConfig = null;
199
- try {
200
- lfConfig = await loadConfig({
201
- cwd,
202
- configFile: configPath
203
- });
204
- } catch (error) {
205
- if (command === "build") {
206
- console.warn("[devflare] Could not load config:", error);
207
- }
208
- }
209
- if (lfConfig) {
210
- const workerNameValue = lfConfig.name ?? "unknown";
211
- returnConfig.define = {
212
- ...config.define ?? {},
213
- __DEVFLARE_WORKER_NAME__: JSON.stringify(workerNameValue)
214
- };
215
- }
216
- if (command === "serve" && process.env.DEVFLARE_DEV && lfConfig) {
217
- const port = bridgePort ?? 8787;
218
- const patterns = [...wsProxyPatterns];
219
- if (lfConfig.wsRoutes && lfConfig.wsRoutes.length > 0) {
220
- for (const route of lfConfig.wsRoutes) {
221
- if (!patterns.includes(route.pattern)) {
222
- patterns.push(route.pattern);
223
- }
224
- }
225
- }
226
- const proxyConfig = {};
227
- for (const pattern of patterns) {
228
- proxyConfig[pattern] = {
229
- target: `http://127.0.0.1:${port}`,
230
- changeOrigin: true,
231
- ws: true,
232
- configure: (proxy) => {
233
- proxy.on("error", (err) => {
234
- console.error(`[devflare] Proxy error: ${err.message}`);
235
- });
236
- }
237
- };
238
- }
239
- if (Object.keys(proxyConfig).length > 0) {
240
- console.log(`[devflare] WebSocket proxy configured for: ${patterns.join(", ")}`);
241
- returnConfig.server = {
242
- proxy: proxyConfig
243
- };
244
- }
245
- }
246
- return Object.keys(returnConfig).length > 0 ? returnConfig : undefined;
247
- },
248
- resolveId(id) {
249
- if (id === VIRTUAL_DO_ENTRY) {
250
- return RESOLVED_VIRTUAL_DO_ENTRY;
251
- }
252
- return null;
253
- },
254
- async load(id) {
255
- if (id === RESOLVED_VIRTUAL_DO_ENTRY) {
256
- if (!pluginContext.durableObjects) {
257
- return `// No Durable Objects configured
258
- export default { fetch: () => new Response("No DOs") }`;
259
- }
260
- return generateVirtualDOEntry(pluginContext.durableObjects);
261
- }
262
- return null;
263
- },
264
- async configResolved(config) {
265
- projectRoot = config.root;
266
- pluginContext.projectRoot = projectRoot;
267
- resolvedPluginConfigPath = await resolvePluginConfigPath(projectRoot, configPath);
268
- try {
269
- devflareConfig = await loadConfig({
270
- cwd: projectRoot,
271
- configFile: configPath
272
- });
273
- const pluginState = await buildPluginContextState(projectRoot, devflareConfig, environment);
274
- Object.assign(pluginContext, {
275
- projectRoot,
276
- ...pluginState
277
- });
278
- logDiscoveredDurableObjects(projectRoot, pluginState.durableObjects);
279
- await writeGeneratedWranglerConfig(projectRoot, pluginState.wranglerConfig);
280
- if (config.command === "serve") {
281
- console.log("[devflare] Config generated to .devflare/wrangler.jsonc");
282
- if (pluginState.auxiliaryWorkerConfig) {
283
- console.log("[devflare] ✓ Auxiliary DO worker configured");
284
- }
285
- }
286
- if (config.command === "build") {
287
- console.log(`[devflare] Generated ${CONFIG_DIR}/wrangler.jsonc`);
288
- }
289
- } catch (error) {
290
- if (error instanceof Error) {
291
- console.error("[devflare] Config error:", error.message);
292
- }
293
- throw error;
294
- }
295
- },
296
- configureServer(server) {
297
- if (!watchConfig)
298
- return;
299
- const fullConfigPath = resolvedPluginConfigPath ?? resolve(projectRoot, configPath || "devflare.config.ts");
300
- server.watcher.add(fullConfigPath);
301
- server.watcher.on("change", async (changedPath) => {
302
- if (changedPath === fullConfigPath) {
303
- console.log("[devflare] Config changed, reloading...");
304
- try {
305
- devflareConfig = await loadConfig({
306
- cwd: projectRoot,
307
- configFile: configPath
308
- });
309
- const pluginState = await buildPluginContextState(projectRoot, devflareConfig, environment);
310
- Object.assign(pluginContext, {
311
- projectRoot,
312
- ...pluginState
313
- });
314
- logDiscoveredDurableObjects(projectRoot, pluginState.durableObjects);
315
- await writeGeneratedWranglerConfig(projectRoot, pluginState.wranglerConfig);
316
- console.log("[devflare] Config reloaded");
317
- server.ws.send({
318
- type: "full-reload",
319
- path: "*"
320
- });
321
- } catch (error) {
322
- console.error("[devflare] Failed to reload config:", error);
323
- }
324
- }
325
- });
326
- },
327
- async transform(code, id) {
328
- if (id.includes("node_modules"))
329
- return null;
330
- if (!id.endsWith(".ts") && !id.endsWith(".tsx") && !id.endsWith(".js")) {
331
- return null;
332
- }
333
- if (id.endsWith("worker.ts") || id.endsWith("worker.js")) {
334
- const {
335
- shouldTransformWorker,
336
- transformWorkerEntrypoint
337
- } = await import("../../worker-entrypoint-c259fmfs.js");
338
- if (shouldTransformWorker(code, id)) {
339
- const result = transformWorkerEntrypoint(code, id);
340
- if (result) {
341
- return {
342
- code: result.code,
343
- map: result.map
344
- };
345
- }
346
- }
347
- }
348
- if (doTransforms) {
349
- if (code.includes("DurableObject") || code.includes("@durableObject")) {
350
- const { transformDurableObject } = await import("../../durable-object-yt8v1dyn.js");
351
- return transformDurableObject(code, id);
352
- }
353
- }
354
- return null;
355
- }
356
- };
357
- }
358
- async function getCloudflareConfig(options = {}) {
359
- const cwd = options.cwd ?? process.cwd();
360
- const devflareConfig = await loadConfig({
361
- cwd,
362
- configFile: options.configPath
363
- });
364
- const composedMainEntry = await prepareComposedWorkerEntrypoint(cwd, devflareConfig, options.environment);
365
- const cloudflareConfig = compileToProgrammaticConfig(devflareConfig, options.environment);
366
- if (composedMainEntry) {
367
- cloudflareConfig.main = composedMainEntry;
368
- }
369
- return cloudflareConfig;
370
- }
371
- async function getDevflareConfigs(options = {}) {
372
- const cwd = options.cwd ?? process.cwd();
373
- const devflareConfig = await loadConfig({
374
- cwd,
375
- configFile: options.configPath
376
- });
377
- const composedMainEntry = await prepareComposedWorkerEntrypoint(cwd, devflareConfig, options.environment);
378
- const wranglerConfig = compileConfig(devflareConfig, options.environment);
379
- const cloudflareConfig = { ...wranglerConfig };
380
- if (composedMainEntry) {
381
- wranglerConfig.main = composedMainEntry;
382
- cloudflareConfig.main = composedMainEntry;
383
- }
384
- const auxiliaryWorkers = [];
385
- const doPatternConfig = devflareConfig.files?.durableObjects;
386
- const doPattern = typeof doPatternConfig === "string" ? doPatternConfig : DEFAULT_DO_PATTERN;
387
- if (doPatternConfig !== false) {
388
- const doWorkerName = `${wranglerConfig.name}-do`;
389
- const discovery = await discoverDurableObjects(cwd, doPattern, doWorkerName);
390
- if (discovery.files.size > 0) {
391
- if (cloudflareConfig.durable_objects) {
392
- const doConfig = cloudflareConfig.durable_objects;
393
- for (const binding of doConfig.bindings) {
394
- binding.script_name = doWorkerName;
395
- }
396
- }
397
- auxiliaryWorkers.push(createAuxiliaryWorkerConfig(wranglerConfig, discovery));
398
- }
399
- }
400
- return { cloudflareConfig, auxiliaryWorkers };
401
- }
12
+ import"../../index-rbht7m9r.js";
13
+ import"../../index-9wt9x09k.js";
14
+ import"../../index-rfhx0yd5.js";
15
+ import"../../index-wyf3s77s.js";
16
+ import"../../index-v8vvsn9x.js";
17
+ import"../../index-37x76zdn.js";
402
18
  export {
19
+ writeGeneratedViteConfig,
20
+ resolveViteUserConfig,
21
+ resolveEffectiveViteProject,
22
+ hasInlineViteConfig,
403
23
  getPluginContext,
404
24
  getDevflareConfigs,
405
25
  getCloudflareConfig,
@@ -1 +1 @@
1
- {"version":3,"file":"simple-context.d.ts","sourceRoot":"","sources":["../../src/test/simple-context.ts"],"names":[],"mappings":"AAgKA;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA8iB1E;AA+BD;;;GAGG;AACH,MAAM,WAAW,OAAO;IACvB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACxB;AAED;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,WAAW;CAAI;AAEhC;;;;;;;;GAQG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA"}
1
+ {"version":3,"file":"simple-context.d.ts","sourceRoot":"","sources":["../../src/test/simple-context.ts"],"names":[],"mappings":"AAyLA;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA8iB1E;AA+BD;;;GAGG;AACH,MAAM,WAAW,OAAO;IACvB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACxB;AAED;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,WAAW;CAAI;AAEhC;;;;;;;;GAQG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveConfigCandidatePath
3
- } from "./index-pwgyy2q9.js";
3
+ } from "./index-dr6sbp8d.js";
4
4
  import {
5
5
  getDependencies
6
6
  } from "./index-1xpj0m4r.js";
@@ -8,21 +8,20 @@ import {
8
8
  discoverEntrypointsAsync,
9
9
  resolvePackageSpecifier
10
10
  } from "./index-2q3pmzrx.js";
11
- import {
12
- findDurableObjectClasses
13
- } from "./index-9wt9x09k.js";
14
11
  import {
15
12
  DEFAULT_DO_PATTERN,
16
13
  DEFAULT_ENTRYPOINT_PATTERN,
17
14
  findFiles
18
15
  } from "./index-rbht7m9r.js";
19
- import"./index-k7r18na8.js";
20
- import"./index-v8vvsn9x.js";
21
- import"./index-6v3wjg1r.js";
16
+ import {
17
+ findDurableObjectClasses
18
+ } from "./index-9wt9x09k.js";
19
+ import"./index-rfhx0yd5.js";
22
20
  import {
23
21
  loadConfig,
24
22
  normalizeDOBinding
25
- } from "./index-1phx14av.js";
23
+ } from "./index-wyf3s77s.js";
24
+ import"./index-v8vvsn9x.js";
26
25
  import {
27
26
  __require
28
27
  } from "./index-37x76zdn.js";
@@ -0,0 +1,25 @@
1
+ import type { ConfigEnv, UserConfig } from 'vite';
2
+ import { type DevflareConfig } from '../config';
3
+ import { type ViteProjectDetection } from '../dev-server/vite-utils';
4
+ export interface EffectiveViteProjectDetection extends ViteProjectDetection {
5
+ hasDevflareViteConfig: boolean;
6
+ shouldStartVite: boolean;
7
+ wantsViteIntegration: boolean;
8
+ }
9
+ export declare function hasInlineViteConfig(viteConfig: DevflareConfig['vite'] | undefined): boolean;
10
+ export declare function resolveEffectiveViteProject(detection: ViteProjectDetection, config: DevflareConfig, environment?: string): EffectiveViteProjectDetection;
11
+ export declare function resolveViteUserConfig(configEnv: ConfigEnv, options?: {
12
+ cwd?: string;
13
+ configPath?: string;
14
+ environment?: string;
15
+ localConfigPath?: string | null;
16
+ bridgePort?: number;
17
+ }): Promise<UserConfig>;
18
+ export declare function writeGeneratedViteConfig(options: {
19
+ cwd: string;
20
+ configPath?: string;
21
+ environment?: string;
22
+ localConfigPath?: string | null;
23
+ bridgePort?: number;
24
+ }): Promise<string>;
25
+ //# sourceMappingURL=config-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-file.d.ts","sourceRoot":"","sources":["../../src/vite/config-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAwB,UAAU,EAAE,MAAM,MAAM,CAAA;AAEvE,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA;AAE3D,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAMpE,MAAM,WAAW,6BAA8B,SAAQ,oBAAoB;IAC1E,qBAAqB,EAAE,OAAO,CAAA;IAC9B,eAAe,EAAE,OAAO,CAAA;IACxB,oBAAoB,EAAE,OAAO,CAAA;CAC7B;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,SAAS,GAAG,OAAO,CAE3F;AAED,wBAAgB,2BAA2B,CAC1C,SAAS,EAAE,oBAAoB,EAC/B,MAAM,EAAE,cAAc,EACtB,WAAW,CAAC,EAAE,MAAM,GAClB,6BAA6B,CAU/B;AAsCD,wBAAsB,qBAAqB,CAC1C,SAAS,EAAE,SAAS,EACpB,OAAO,GAAE;IACR,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAA;CACd,GACJ,OAAO,CAAC,UAAU,CAAC,CA0BrB;AAkBD,wBAAsB,wBAAwB,CAAC,OAAO,EAAE;IACvD,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB,GAAG,OAAO,CAAC,MAAM,CAAC,CAqBlB"}
@@ -1,3 +1,4 @@
1
1
  export { devflarePlugin, getPluginContext, getCloudflareConfig, getDevflareConfigs, type DevflarePluginOptions, type DevflarePluginContext, type AuxiliaryWorkerConfig, type DODiscoveryResult } from './plugin';
2
+ export { hasInlineViteConfig, resolveEffectiveViteProject, resolveViteUserConfig, writeGeneratedViteConfig, type EffectiveViteProjectDetection } from './config-file';
2
3
  export { devflarePlugin as default } from './plugin';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,MAAM,UAAU,CAAA;AAGjB,OAAO,EAAE,cAAc,IAAI,OAAO,EAAE,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,MAAM,UAAU,CAAA;AACjB,OAAO,EACN,mBAAmB,EACnB,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,KAAK,6BAA6B,EAClC,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,cAAc,IAAI,OAAO,EAAE,MAAM,UAAU,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"composed-worker.d.ts","sourceRoot":"","sources":["../../src/worker-entry/composed-worker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AA+B/C,MAAM,WAAW,kBAAkB;IAClC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACpB;AAUD,MAAM,WAAW,sCAAsC;IACtD,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC1B;AA8CD,wBAAsB,yBAAyB,CAC9C,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,cAAc,GACpB,OAAO,CAAC,kBAAkB,CAAC,CAO7B;AAuPD,wBAAsB,+BAA+B,CACpD,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,cAAc,EACtB,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,GAAE,sCAA2C,GAClD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAwCxB"}
1
+ {"version":3,"file":"composed-worker.d.ts","sourceRoot":"","sources":["../../src/worker-entry/composed-worker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAgC/C,MAAM,WAAW,kBAAkB;IAClC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACpB;AAUD,MAAM,WAAW,sCAAsC;IACtD,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC1B;AAmCD,wBAAsB,yBAAyB,CAC9C,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,cAAc,GACpB,OAAO,CAAC,kBAAkB,CAAC,CAO7B;AAuPD,wBAAsB,+BAA+B,CACpD,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,cAAc,EACtB,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,GAAE,sCAA2C,GAClD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAwCxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devflare",
3
- "version": "1.0.0-next.10",
3
+ "version": "1.0.0-next.12",
4
4
  "description": "Devflare is a developer-first toolkit for Cloudflare Workers that sits on top of Miniflare and Wrangler-compatible config",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",
File without changes