wrangler 2.0.25 → 2.0.28

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 (66) hide show
  1. package/bin/wrangler.js +1 -1
  2. package/miniflare-dist/index.mjs +15 -3
  3. package/package.json +8 -6
  4. package/src/__tests__/configuration.test.ts +33 -29
  5. package/src/__tests__/dev.test.tsx +8 -6
  6. package/src/__tests__/generate.test.ts +2 -4
  7. package/src/__tests__/helpers/mock-cfetch.ts +33 -0
  8. package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -0
  9. package/src/__tests__/helpers/mock-known-routes.ts +7 -0
  10. package/src/__tests__/index.test.ts +30 -30
  11. package/src/__tests__/init.test.ts +537 -359
  12. package/src/__tests__/jest.setup.ts +7 -0
  13. package/src/__tests__/metrics.test.ts +1 -1
  14. package/src/__tests__/pages.test.ts +14 -0
  15. package/src/__tests__/publish.test.ts +59 -18
  16. package/src/__tests__/r2.test.ts +4 -3
  17. package/src/__tests__/tail.test.ts +53 -3
  18. package/src/__tests__/test-old-node-version.js +3 -3
  19. package/src/__tests__/user.test.ts +11 -0
  20. package/src/__tests__/worker-namespace.test.ts +37 -35
  21. package/src/api/dev.ts +1 -0
  22. package/src/bundle.ts +1 -1
  23. package/src/cfetch/internal.ts +118 -1
  24. package/src/config/environment.ts +1 -1
  25. package/src/config/index.ts +4 -4
  26. package/src/config/validation-helpers.ts +19 -6
  27. package/src/config/validation.ts +11 -5
  28. package/src/config-cache.ts +2 -1
  29. package/src/create-worker-upload-form.ts +29 -26
  30. package/src/dev/dev.tsx +4 -0
  31. package/src/dev/remote.tsx +10 -1
  32. package/src/dev.tsx +36 -8
  33. package/src/{worker-namespace.ts → dispatch-namespace.ts} +18 -18
  34. package/src/generate.ts +1 -1
  35. package/src/index.tsx +54 -8
  36. package/src/init.ts +111 -38
  37. package/src/{metrics/is-ci.ts → is-ci.ts} +0 -0
  38. package/src/metrics/metrics-config.ts +1 -1
  39. package/src/metrics/send-event.ts +5 -5
  40. package/src/miniflare-cli/assets.ts +8 -0
  41. package/src/miniflare-cli/index.ts +6 -3
  42. package/src/pages/build.tsx +41 -15
  43. package/src/pages/constants.ts +1 -0
  44. package/src/pages/dev.tsx +93 -37
  45. package/src/pages/errors.ts +22 -0
  46. package/src/pages/functions/routes-consolidation.test.ts +185 -1
  47. package/src/pages/functions/routes-consolidation.ts +46 -2
  48. package/src/pages/functions/routes-transformation.ts +0 -3
  49. package/src/pages/functions.tsx +96 -0
  50. package/src/pages/index.tsx +65 -55
  51. package/src/pages/publish.tsx +27 -16
  52. package/src/proxy.ts +10 -0
  53. package/src/publish.ts +19 -4
  54. package/src/r2.ts +4 -4
  55. package/src/tail/filters.ts +3 -1
  56. package/src/tail/printing.ts +2 -0
  57. package/src/user/user.tsx +6 -4
  58. package/src/whoami.tsx +5 -5
  59. package/src/worker.ts +3 -2
  60. package/src/zones.ts +91 -0
  61. package/templates/pages-template-plugin.ts +16 -4
  62. package/templates/pages-template-worker.ts +16 -5
  63. package/templates/service-bindings-module-facade.js +10 -7
  64. package/templates/service-bindings-sw-facade.js +10 -7
  65. package/wrangler-dist/cli.d.ts +8 -3
  66. package/wrangler-dist/cli.js +6757 -1639
@@ -7,20 +7,23 @@ for (const [name, details] of Object.entries(Workers)) {
7
7
  if (details) {
8
8
  globalThis[name] = {
9
9
  async fetch(...reqArgs) {
10
+ const reqFromArgs = new Request(...reqArgs);
10
11
  if (details.headers) {
11
- const req = new Request(...reqArgs);
12
12
  for (const [key, value] of Object.entries(details.headers)) {
13
13
  // In remote mode, you need to add a couple of headers
14
14
  // to make sure it's talking to the 'dev' preview session
15
15
  // (much like wrangler dev already does via proxy.ts)
16
- req.headers.set(key, value);
16
+ reqFromArgs.headers.set(key, value);
17
17
  }
18
- return env[name].fetch(req);
18
+ return env[name].fetch(reqFromArgs);
19
19
  }
20
- const url = `${details.protocol}://${details.host}${
21
- details.port ? `:${details.port}` : ""
22
- }`;
23
- const request = new Request(url, ...reqArgs);
20
+
21
+ const url = new URL(reqFromArgs.url);
22
+ url.protocol = details.protocol;
23
+ url.host = details.host;
24
+ if (details.port !== undefined) url.port = details.port;
25
+
26
+ const request = new Request(url.toString(), reqFromArgs);
24
27
  return fetch(request);
25
28
  },
26
29
  };
@@ -1,12 +1,16 @@
1
1
  /// <reference types="node" />
2
2
 
3
3
  import { Blob as Blob_2 } from 'buffer';
4
- import { BlobOptions } from 'buffer';
5
4
  import Dispatcher = require('./dispatcher');
6
5
  import { ReadableStream } from 'stream/web';
7
6
  import { URL as URL_2 } from 'url';
8
7
  import { URLSearchParams as URLSearchParams_2 } from 'url';
9
8
 
9
+ declare interface BlobPropertyBag {
10
+ type?: string
11
+ endings?: 'native' | 'transparent'
12
+ }
13
+
10
14
  declare type BodyInit =
11
15
  | ArrayBuffer
12
16
  | AsyncIterable<Uint8Array>
@@ -41,6 +45,7 @@ declare interface DevOptions {
41
45
  siteExclude?: string[];
42
46
  nodeCompat?: boolean;
43
47
  compatibilityDate?: string;
48
+ compatibilityFlags?: string[];
44
49
  experimentalEnableLocalPersistence?: boolean;
45
50
  liveReload?: boolean;
46
51
  watch?: boolean;
@@ -86,7 +91,7 @@ declare class File extends Blob_2 {
86
91
  * @param fileName The name of the file.
87
92
  * @param options An options object containing optional attributes for the file.
88
93
  */
89
- constructor(fileBits: ReadonlyArray<string | NodeJS.ArrayBufferView | Blob_2>, fileName: string, options?: FileOptions)
94
+ constructor(fileBits: ReadonlyArray<string | NodeJS.ArrayBufferView | Blob_2>, fileName: string, options?: FilePropertyBag)
90
95
 
91
96
  /**
92
97
  * Name of the file referenced by the File object.
@@ -101,7 +106,7 @@ declare class File extends Blob_2 {
101
106
  readonly [Symbol.toStringTag]: string
102
107
  }
103
108
 
104
- declare interface FileOptions extends BlobOptions {
109
+ declare interface FilePropertyBag extends BlobPropertyBag {
105
110
  /**
106
111
  * The last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.
107
112
  */