wrangler 2.0.27 → 2.1.0

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 (65) hide show
  1. package/bin/wrangler.js +1 -1
  2. package/miniflare-dist/index.mjs +1141 -369
  3. package/package.json +6 -4
  4. package/src/__tests__/api-dev.test.ts +19 -0
  5. package/src/__tests__/configuration.test.ts +27 -27
  6. package/src/__tests__/dev.test.tsx +8 -6
  7. package/src/__tests__/helpers/hello-world-worker.js +5 -0
  8. package/src/__tests__/helpers/mock-cfetch.ts +4 -4
  9. package/src/__tests__/helpers/mock-console.ts +11 -2
  10. package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -0
  11. package/src/__tests__/helpers/mock-known-routes.ts +7 -0
  12. package/src/__tests__/index.test.ts +37 -37
  13. package/src/__tests__/init.test.ts +356 -5
  14. package/src/__tests__/jest.setup.ts +13 -0
  15. package/src/__tests__/middleware.test.ts +768 -0
  16. package/src/__tests__/pages.test.ts +829 -104
  17. package/src/__tests__/paths.test.ts +17 -0
  18. package/src/__tests__/publish.test.ts +512 -445
  19. package/src/__tests__/tail.test.ts +79 -72
  20. package/src/__tests__/test-old-node-version.js +3 -3
  21. package/src/__tests__/worker-namespace.test.ts +37 -35
  22. package/src/api/dev.ts +93 -28
  23. package/src/bundle.ts +239 -12
  24. package/src/cfetch/internal.ts +64 -3
  25. package/src/cli.ts +1 -1
  26. package/src/config/environment.ts +1 -1
  27. package/src/config/index.ts +4 -4
  28. package/src/config/validation.ts +3 -3
  29. package/src/create-worker-upload-form.ts +29 -26
  30. package/src/dev/dev.tsx +3 -1
  31. package/src/dev/local.tsx +319 -171
  32. package/src/dev/remote.tsx +16 -4
  33. package/src/dev/start-server.ts +416 -0
  34. package/src/dev/use-esbuild.ts +4 -0
  35. package/src/dev.tsx +340 -166
  36. package/src/dialogs.tsx +12 -0
  37. package/src/{worker-namespace.ts → dispatch-namespace.ts} +18 -18
  38. package/src/entry.ts +2 -1
  39. package/src/index.tsx +59 -12
  40. package/src/init.ts +291 -16
  41. package/src/metrics/send-event.ts +6 -5
  42. package/src/miniflare-cli/assets.ts +130 -476
  43. package/src/miniflare-cli/index.ts +39 -33
  44. package/src/pages/constants.ts +3 -0
  45. package/src/pages/dev.tsx +8 -3
  46. package/src/pages/functions/buildPlugin.ts +2 -1
  47. package/src/pages/functions/buildWorker.ts +2 -1
  48. package/src/pages/functions/routes-transformation.test.ts +12 -1
  49. package/src/pages/functions/routes-transformation.ts +7 -1
  50. package/src/pages/hash.tsx +13 -0
  51. package/src/pages/publish.tsx +82 -38
  52. package/src/pages/upload.tsx +3 -18
  53. package/src/paths.ts +20 -1
  54. package/src/publish.ts +49 -8
  55. package/src/tail/filters.ts +1 -5
  56. package/src/tail/index.ts +6 -3
  57. package/src/worker.ts +10 -9
  58. package/src/zones.ts +91 -0
  59. package/templates/middleware/common.ts +62 -0
  60. package/templates/middleware/loader-modules.ts +84 -0
  61. package/templates/middleware/loader-sw.ts +213 -0
  62. package/templates/middleware/middleware-pretty-error.ts +40 -0
  63. package/templates/middleware/middleware-scheduled.ts +14 -0
  64. package/wrangler-dist/cli.d.ts +22 -8
  65. package/wrangler-dist/cli.js +71020 -65212
@@ -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>
@@ -29,7 +33,13 @@ declare interface BodyMixin {
29
33
  readonly text: () => Promise<string>
30
34
  }
31
35
 
36
+ declare interface DevApiOptions {
37
+ testMode?: boolean;
38
+ disableExperimentalWarning?: boolean;
39
+ }
40
+
32
41
  declare interface DevOptions {
42
+ config?: string;
33
43
  env?: string;
34
44
  ip?: string;
35
45
  port?: number;
@@ -45,7 +55,7 @@ declare interface DevOptions {
45
55
  experimentalEnableLocalPersistence?: boolean;
46
56
  liveReload?: boolean;
47
57
  watch?: boolean;
48
- vars: {
58
+ vars?: {
49
59
  [key: string]: unknown;
50
60
  };
51
61
  kv?: {
@@ -87,7 +97,7 @@ declare class File extends Blob_2 {
87
97
  * @param fileName The name of the file.
88
98
  * @param options An options object containing optional attributes for the file.
89
99
  */
90
- constructor(fileBits: ReadonlyArray<string | NodeJS.ArrayBufferView | Blob_2>, fileName: string, options?: FileOptions)
100
+ constructor(fileBits: ReadonlyArray<string | NodeJS.ArrayBufferView | Blob_2>, fileName: string, options?: FilePropertyBag)
91
101
 
92
102
  /**
93
103
  * Name of the file referenced by the File object.
@@ -102,7 +112,7 @@ declare class File extends Blob_2 {
102
112
  readonly [Symbol.toStringTag]: string
103
113
  }
104
114
 
105
- declare interface FileOptions extends BlobOptions {
115
+ declare interface FilePropertyBag extends BlobPropertyBag {
106
116
  /**
107
117
  * 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.
108
118
  */
@@ -324,11 +334,15 @@ declare interface SpecIterator<T, TReturn = any, TNext = undefined> {
324
334
  * unstable_dev starts a wrangler dev server, and returns a promise that resolves with utility functions to interact with it.
325
335
  * @param {string} script
326
336
  * @param {DevOptions} options
337
+ * @param {DevApiOptions} apiOptions
338
+ * @returns {Promise<UnstableDev>}
327
339
  */
328
- export declare function unstable_dev(script: string, options: DevOptions, disableExperimentalWarning?: boolean): Promise<{
329
- stop: () => void;
330
- fetch: (init?: RequestInit | undefined) => Promise<Response | undefined>;
340
+ export declare function unstable_dev(script: string, options?: DevOptions, apiOptions?: DevApiOptions): Promise<UnstableDev>;
341
+
342
+ declare interface UnstableDev {
343
+ stop: () => Promise<void>;
344
+ fetch: (init?: RequestInit) => Promise<Response | undefined>;
331
345
  waitUntilExit: () => Promise<void>;
332
- }>;
346
+ }
333
347
 
334
348
  export { }