wrangler 0.0.0-e93d240f → 0.0.0-e94b46ff7

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 (40) hide show
  1. package/README.md +30 -38
  2. package/bin/wrangler.js +6 -35
  3. package/config-schema.json +2277 -0
  4. package/package.json +87 -112
  5. package/templates/checked-fetch.js +1 -1
  6. package/templates/facade.d.ts +7 -5
  7. package/templates/gitignore +2 -4
  8. package/templates/init-tests/test-vitest-new-worker.js +1 -1
  9. package/templates/init-tests/test-vitest-new-worker.ts +3 -3
  10. package/templates/middleware/loader-modules.ts +92 -95
  11. package/templates/middleware/loader-sw.ts +4 -3
  12. package/templates/middleware/middleware-ensure-req-body-drained.ts +18 -0
  13. package/templates/middleware/middleware-miniflare3-json-error.ts +0 -1
  14. package/templates/middleware/middleware-mock-analytics-engine.d.ts +3 -0
  15. package/templates/middleware/middleware-mock-analytics-engine.ts +30 -0
  16. package/templates/middleware/middleware-patch-console-prefix.d.ts +3 -0
  17. package/templates/middleware/middleware-patch-console-prefix.ts +21 -0
  18. package/templates/middleware/middleware-scheduled.ts +15 -1
  19. package/templates/modules-watch-stub.js +4 -0
  20. package/templates/pages-dev-pipeline.ts +5 -3
  21. package/templates/pages-template-plugin.ts +2 -2
  22. package/templates/pages-template-worker.ts +1 -1
  23. package/templates/startDevWorker/InspectorProxyWorker.ts +664 -0
  24. package/templates/startDevWorker/ProxyWorker.ts +336 -0
  25. package/templates/tsconfig.init.json +4 -87
  26. package/templates/tsconfig.json +8 -1
  27. package/templates/tsconfig.tsbuildinfo +1 -0
  28. package/wrangler-dist/InspectorProxyWorker.js +460 -0
  29. package/wrangler-dist/InspectorProxyWorker.js.map +6 -0
  30. package/wrangler-dist/ProxyWorker.js +238 -0
  31. package/wrangler-dist/ProxyWorker.js.map +6 -0
  32. package/wrangler-dist/cli.d.ts +25295 -351
  33. package/wrangler-dist/cli.js +148557 -146769
  34. package/Cloudflare_CA.pem +0 -18
  35. package/templates/middleware/middleware-d1-beta.d.ts +0 -3
  36. package/templates/middleware/middleware-multiworker-dev.d.ts +0 -4
  37. package/templates/middleware/middleware-multiworker-dev.ts +0 -59
  38. package/templates/middleware/middleware-serve-static-assets.d.ts +0 -6
  39. package/templates/middleware/middleware-serve-static-assets.ts +0 -56
  40. package/wrangler-dist/wasm-sync.wasm +0 -0
@@ -9,7 +9,21 @@ const scheduled: Middleware = async (request, env, _ctx, middlewareCtx) => {
9
9
 
10
10
  return new Response("Ran scheduled event");
11
11
  }
12
- return middlewareCtx.next(request, env);
12
+
13
+ const resp = await middlewareCtx.next(request, env);
14
+
15
+ // If you open the `/__scheduled` page in a browser, the browser will automatically make a request to `/favicon.ico`.
16
+ // For scheduled Workers _without_ a fetch handler, this will result in a 500 response that clutters the log with unhelpful error messages.
17
+ // To avoid this, inject a 404 response to favicon.ico loads on the `/__scheduled` page
18
+ if (
19
+ request.headers.get("referer")?.endsWith("/__scheduled") &&
20
+ url.pathname === "/favicon.ico" &&
21
+ resp.status === 500
22
+ ) {
23
+ return new Response(null, { status: 404 });
24
+ }
25
+
26
+ return resp;
13
27
  };
14
28
 
15
29
  export default scheduled;
@@ -0,0 +1,4 @@
1
+ // `esbuild` doesn't support returning `watch*` options from `onStart()`
2
+ // plugin callbacks. Instead, we define an empty virtual module that is
3
+ // imported by this injected file. Importing the module registers watchers.
4
+ import "wrangler:modules-watch";
@@ -1,8 +1,9 @@
1
1
  // @ts-ignore entry point will get replaced
2
2
  import worker from "__ENTRY_POINT__";
3
+ import { isRoutingRuleMatch } from "./pages-dev-util";
4
+
3
5
  // @ts-ignore entry point will get replaced
4
6
  export * from "__ENTRY_POINT__";
5
- import { isRoutingRuleMatch } from "./pages-dev-util";
6
7
 
7
8
  // @ts-ignore routes are injected
8
9
  const routes = __ROUTES__;
@@ -19,10 +20,11 @@ export default <ExportedHandler<{ ASSETS: Fetcher }>>{
19
20
 
20
21
  for (const include of routes.include) {
21
22
  if (isRoutingRuleMatch(pathname, include)) {
22
- if (worker.fetch === undefined) {
23
+ const workerAsHandler = worker as ExportedHandler;
24
+ if (workerAsHandler.fetch === undefined) {
23
25
  throw new TypeError("Entry point missing `fetch` handler");
24
26
  }
25
- return worker.fetch(request, env, context);
27
+ return workerAsHandler.fetch(request, env, context);
26
28
  }
27
29
  }
28
30
 
@@ -41,14 +41,14 @@ type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
41
41
  declare type PagesFunction<
42
42
  Env = unknown,
43
43
  P extends string = string,
44
- Data extends Record<string, unknown> = Record<string, unknown>
44
+ Data extends Record<string, unknown> = Record<string, unknown>,
45
45
  > = (context: EventContext<Env, P, Data>) => Response | Promise<Response>;
46
46
 
47
47
  declare type PagesPluginFunction<
48
48
  Env = unknown,
49
49
  P extends string = string,
50
50
  Data extends Record<string, unknown> = Record<string, unknown>,
51
- PluginArgs = unknown
51
+ PluginArgs = unknown,
52
52
  > = (
53
53
  context: EventPluginContext<Env, P, Data, PluginArgs>
54
54
  ) => Response | Promise<Response>;
@@ -29,7 +29,7 @@ type EventContext<Env, P extends string, Data> = {
29
29
  declare type PagesFunction<
30
30
  Env = unknown,
31
31
  P extends string = string,
32
- Data extends Record<string, unknown> = Record<string, unknown>
32
+ Data extends Record<string, unknown> = Record<string, unknown>,
33
33
  > = (context: EventContext<Env, P, Data>) => Response | Promise<Response>;
34
34
  /* end @cloudflare/workers-types */
35
35