wrangler 0.0.0-e6733a3 → 0.0.0-e6ada079

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.

Potentially problematic release.


This version of wrangler might be problematic. Click here for more details.

Files changed (119) hide show
  1. package/README.md +47 -16
  2. package/bin/wrangler.js +94 -31
  3. package/config-schema.json +3100 -0
  4. package/kv-asset-handler.js +1 -0
  5. package/package.json +154 -82
  6. package/templates/__tests__/pages-dev-util.test.ts +128 -0
  7. package/templates/__tests__/tsconfig-sanity.ts +12 -0
  8. package/templates/__tests__/tsconfig.json +8 -0
  9. package/templates/checked-fetch.js +30 -0
  10. package/templates/facade.d.ts +19 -0
  11. package/templates/gitignore +170 -0
  12. package/templates/init-tests/test-jest-new-worker.js +23 -0
  13. package/templates/init-tests/test-vitest-new-worker.js +24 -0
  14. package/templates/init-tests/test-vitest-new-worker.ts +25 -0
  15. package/templates/middleware/common.ts +67 -0
  16. package/templates/middleware/loader-modules.ts +134 -0
  17. package/templates/middleware/loader-sw.ts +229 -0
  18. package/templates/middleware/middleware-ensure-req-body-drained.ts +18 -0
  19. package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
  20. package/templates/middleware/middleware-pretty-error.ts +40 -0
  21. package/templates/middleware/middleware-scheduled.ts +15 -0
  22. package/templates/middleware/middleware-serve-static-assets.d.ts +6 -0
  23. package/templates/middleware/middleware-serve-static-assets.ts +56 -0
  24. package/templates/modules-watch-stub.js +4 -0
  25. package/templates/new-worker-scheduled.js +17 -0
  26. package/templates/new-worker-scheduled.ts +32 -0
  27. package/templates/new-worker.js +15 -0
  28. package/templates/new-worker.ts +33 -0
  29. package/templates/no-op-worker.js +10 -0
  30. package/templates/pages-dev-pipeline.ts +32 -0
  31. package/templates/pages-dev-util.ts +55 -0
  32. package/templates/pages-shim.ts +9 -0
  33. package/templates/pages-template-plugin.ts +190 -0
  34. package/templates/pages-template-worker.ts +198 -0
  35. package/templates/startDevWorker/InspectorProxyWorker.ts +664 -0
  36. package/templates/startDevWorker/ProxyWorker.ts +334 -0
  37. package/templates/tsconfig-sanity.ts +11 -0
  38. package/templates/tsconfig.init.json +22 -0
  39. package/templates/tsconfig.json +8 -0
  40. package/wrangler-dist/InspectorProxyWorker.js +464 -0
  41. package/wrangler-dist/InspectorProxyWorker.js.map +6 -0
  42. package/wrangler-dist/ProxyWorker.js +240 -0
  43. package/wrangler-dist/ProxyWorker.js.map +6 -0
  44. package/wrangler-dist/cli.d.ts +26391 -0
  45. package/wrangler-dist/cli.js +204293 -116652
  46. package/wrangler-dist/wasm-sync.wasm +0 -0
  47. package/import_meta_url.js +0 -3
  48. package/miniflare-config-stubs/.env.empty +0 -0
  49. package/miniflare-config-stubs/package.empty.json +0 -1
  50. package/miniflare-config-stubs/wrangler.empty.toml +0 -0
  51. package/pages/functions/buildWorker.ts +0 -62
  52. package/pages/functions/filepath-routing.test.ts +0 -39
  53. package/pages/functions/filepath-routing.ts +0 -221
  54. package/pages/functions/identifiers.ts +0 -78
  55. package/pages/functions/routes.ts +0 -158
  56. package/pages/functions/template-worker.ts +0 -144
  57. package/src/__tests__/clipboardy-mock.js +0 -4
  58. package/src/__tests__/dev.test.tsx +0 -66
  59. package/src/__tests__/index.test.ts +0 -287
  60. package/src/__tests__/jest.setup.ts +0 -22
  61. package/src/__tests__/kv.test.ts +0 -1098
  62. package/src/__tests__/mock-cfetch.ts +0 -171
  63. package/src/__tests__/mock-dialogs.ts +0 -65
  64. package/src/__tests__/run-in-tmp.ts +0 -19
  65. package/src/__tests__/run-wrangler.ts +0 -32
  66. package/src/api/form_data.ts +0 -131
  67. package/src/api/preview.ts +0 -128
  68. package/src/api/worker.ts +0 -155
  69. package/src/cfetch/index.ts +0 -102
  70. package/src/cfetch/internal.ts +0 -69
  71. package/src/cli.ts +0 -9
  72. package/src/config.ts +0 -487
  73. package/src/dev.tsx +0 -771
  74. package/src/dialogs.tsx +0 -77
  75. package/src/index.tsx +0 -1974
  76. package/src/inspect.ts +0 -524
  77. package/src/kv.tsx +0 -267
  78. package/src/module-collection.ts +0 -64
  79. package/src/pages.tsx +0 -1031
  80. package/src/proxy.ts +0 -294
  81. package/src/publish.ts +0 -358
  82. package/src/sites.tsx +0 -114
  83. package/src/tail.tsx +0 -73
  84. package/src/user.tsx +0 -1025
  85. package/static-asset-facade.js +0 -47
  86. package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
  87. package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
  88. package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
  89. package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
  90. package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
  91. package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
  92. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
  93. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
  94. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
  95. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
  96. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
  97. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
  98. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
  99. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
  100. package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
  101. package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
  102. package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
  103. package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
  104. package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
  105. package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
  106. package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
  107. package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
  108. package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
  109. package/vendor/wrangler-mime/CHANGELOG.md +0 -289
  110. package/vendor/wrangler-mime/LICENSE +0 -21
  111. package/vendor/wrangler-mime/Mime.js +0 -97
  112. package/vendor/wrangler-mime/README.md +0 -187
  113. package/vendor/wrangler-mime/cli.js +0 -46
  114. package/vendor/wrangler-mime/index.js +0 -4
  115. package/vendor/wrangler-mime/lite.js +0 -4
  116. package/vendor/wrangler-mime/package.json +0 -52
  117. package/vendor/wrangler-mime/types/other.js +0 -1
  118. package/vendor/wrangler-mime/types/standard.js +0 -1
  119. package/wrangler-dist/cli.js.map +0 -7
package/src/inspect.ts DELETED
@@ -1,524 +0,0 @@
1
- import type { MessageEvent } from "ws";
2
- import WebSocket, { WebSocketServer } from "ws";
3
- import type { IncomingMessage, Server, ServerResponse } from "http";
4
- import { createServer } from "http";
5
- import { useEffect, useRef, useState } from "react";
6
- import { version } from "../package.json";
7
-
8
- import type Protocol from "devtools-protocol";
9
-
10
- /**
11
- * `useInspector` is a hook for debugging Workers applications
12
- * when using `wrangler dev`.
13
- *
14
- * When we start a session with `wrangler dev`, the Workers platform
15
- * also exposes a debugging websocket that implements the DevTools
16
- * Protocol. While we could just start up DevTools and connect to this
17
- * URL, that URL changes every time we make a change to the
18
- * worker, or when the session expires. Instead, we start up a proxy
19
- * server locally that acts as a bridge between the remote DevTools
20
- * server and the local DevTools instance. So whenever the URL changes,
21
- * we can can silently connect to it and keep the local DevTools instance
22
- * up to date. Further, we also intercept these messages and selectively
23
- * log them directly to the terminal (namely, calls to `console.<x>`,
24
- * and exceptions)
25
- */
26
-
27
- /**
28
- * TODO:
29
- * - clear devtools whenever we save changes to the worker
30
- * - clear devtools when we switch between local/remote modes
31
- * - handle more methods from console
32
- */
33
-
34
- interface InspectorProps {
35
- /**
36
- * The port that the local proxy server should listen on.
37
- */
38
- port: number;
39
- /**
40
- * The websocket URL exposed by Workers that the inspector should connect to.
41
- */
42
- inspectorUrl: undefined | string;
43
- /**
44
- * Whether console statements and exceptions should be logged to the terminal.
45
- * (We don't log them in local mode because they're already getting
46
- * logged to the terminal by nature of them actually running in node locally.)
47
- */
48
- logToTerminal: boolean;
49
- }
50
-
51
- export default function useInspector(props: InspectorProps) {
52
- /** A unique ID for this session. */
53
- const inspectorIdRef = useRef(randomId());
54
- /**
55
- * The local proxy server that acts as the bridge between
56
- * the remote websocket and the local DevTools instance.
57
- */
58
- const serverRef = useRef<Server>();
59
- /** The websocket server that runs on top of the proxy server. */
60
- const wsServerRef = useRef<WebSocketServer>();
61
-
62
- /** The websocket from the devtools instance. */
63
- const [localWebSocket, setLocalWebSocket] = useState<WebSocket | undefined>();
64
- /** The websocket from the edge */
65
- const [remoteWebSocket, setRemoteWebSocket] = useState<
66
- WebSocket | undefined
67
- >();
68
-
69
- if (!serverRef.current) {
70
- // Let's create the proxy server!
71
- serverRef.current = createServer(
72
- (req: IncomingMessage, res: ServerResponse) => {
73
- switch (req.url) {
74
- // We implement a couple of well known end points
75
- // that are queried for metadata by chrome://inspect
76
- case "/json/version":
77
- res.setHeader("Content-Type", "application/json");
78
- res.end(
79
- JSON.stringify({
80
- Browser: `wrangler/v${version}`,
81
- // TODO: (someday): The DevTools protocol should match that of edgeworker.
82
- // This could be exposed by the preview API.
83
- "Protocol-Version": "1.3",
84
- })
85
- );
86
- return;
87
- case "/json":
88
- case "/json/list":
89
- {
90
- res.setHeader("Content-Type", "application/json");
91
- const localHost = `localhost:${props.port}/ws`;
92
- const devtoolsFrontendUrl = `devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=${localHost}`;
93
- const devtoolsFrontendUrlCompat = `devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=${localHost}`;
94
- res.end(
95
- JSON.stringify([
96
- {
97
- id: inspectorIdRef.current,
98
- type: "node",
99
- description: "workers",
100
- webSocketDebuggerUrl: `ws://${localHost}`,
101
- devtoolsFrontendUrl,
102
- devtoolsFrontendUrlCompat,
103
- // Below are fields that are visible in the DevTools UI.
104
- title: "Cloudflare Worker",
105
- faviconUrl: "https://workers.cloudflare.com/favicon.ico",
106
- url:
107
- "https://" +
108
- (remoteWebSocket
109
- ? new URL(remoteWebSocket.url).host
110
- : "workers.dev"),
111
- },
112
- ])
113
- );
114
- }
115
- return;
116
- default:
117
- break;
118
- }
119
- }
120
- );
121
-
122
- // Let's create the websocket server on top of the proxy server
123
- wsServerRef.current = new WebSocketServer({
124
- server: serverRef.current,
125
- clientTracking: true,
126
- });
127
- wsServerRef.current.on("connection", (ws: WebSocket) => {
128
- if (wsServerRef.current.clients.size > 1) {
129
- /** We only want to have one active Devtools instance at a time. */
130
- console.error(
131
- "Tried to open a new devtools window when a previous one was already open."
132
- );
133
- ws.close(1013, "Too many clients; only one can be connected at a time");
134
- } else {
135
- // As promised, save the created websocket in a state hook
136
- setLocalWebSocket(ws);
137
-
138
- ws.addEventListener("close", () => {
139
- // And and cleanup when devtools closes
140
- setLocalWebSocket(undefined);
141
- });
142
- }
143
- });
144
- }
145
-
146
- /**
147
- * We start and stop the server in an effect to take advantage
148
- * of the component lifecycle. Convenient.
149
- */
150
- useEffect(() => {
151
- serverRef.current.listen(props.port);
152
- return () => {
153
- serverRef.current.close();
154
- // Also disconnect any open websockets/devtools connections
155
- wsServerRef.current.clients.forEach((ws) => ws.close());
156
- wsServerRef.current.close();
157
- };
158
- }, [props.port]);
159
-
160
- /**
161
- * When connecting to the remote websocket, if we don't start either
162
- * the devtools instance or make an actual request to the worker in time,
163
- * then the connecting process can error out. When this happens, we
164
- * want to simply retry the connection. We use a state hook to trigger retries
165
- * of the effect that connects to the remote websocket.
166
- */
167
- const [
168
- retryRemoteWebSocketConnectionSigil,
169
- setRetryRemoteWebSocketConnectionSigil,
170
- ] = useState<number>(0);
171
- function retryRemoteWebSocketConnection() {
172
- setRetryRemoteWebSocketConnectionSigil((x) => x + 1);
173
- }
174
-
175
- /** A simple incrementing id to attach to messages we send to devtools */
176
- const messageCounterRef = useRef(1);
177
-
178
- // This effect tracks the connection to the remote websocket
179
- // (stored in, no surprises here, `remoteWebSocket`)
180
- useEffect(() => {
181
- if (!props.inspectorUrl) {
182
- return;
183
- }
184
- // The actual websocket instance
185
- const ws = new WebSocket(props.inspectorUrl);
186
- setRemoteWebSocket(ws);
187
-
188
- /**
189
- * A handle to the interval we run to keep the websocket alive
190
- */
191
- let keepAliveInterval: NodeJS.Timer;
192
-
193
- /**
194
- * Test if the websocket is closed
195
- */
196
- function isClosed() {
197
- return (
198
- ws.readyState === WebSocket.CLOSED ||
199
- ws.readyState === WebSocket.CLOSING
200
- );
201
- }
202
-
203
- /**
204
- * Send a message to the remote websocket
205
- */
206
- function send(event: Record<string, unknown>): void {
207
- if (!isClosed()) {
208
- ws.send(JSON.stringify(event));
209
- }
210
- }
211
-
212
- /**
213
- * Closes the inspector.
214
- */
215
- function close(): void {
216
- if (!isClosed()) {
217
- try {
218
- ws.close();
219
- } catch (err) {
220
- // Closing before the websocket is ready will throw an error.
221
- }
222
- }
223
- }
224
-
225
- /**
226
- * Since we have a handle on the remote websocket, we can tap
227
- * into its events, and log any pertinent ones directly to
228
- * the terminal (which means you have insight into your worker
229
- * without having to open the devtools).
230
- */
231
- if (props.logToTerminal) {
232
- ws.addEventListener("message", (event: MessageEvent) => {
233
- if (typeof event.data === "string") {
234
- const evt = JSON.parse(event.data);
235
- if (evt.method === "Runtime.exceptionThrown") {
236
- const params = evt.params as Protocol.Runtime.ExceptionThrownEvent;
237
- console.error(
238
- "🚨", // cheesy, but it works
239
- // maybe we could use color here too.
240
- params.exceptionDetails.text,
241
- params.exceptionDetails.exception.description
242
- );
243
- }
244
- if (evt.method === "Runtime.consoleAPICalled") {
245
- logConsoleMessage(
246
- evt.params as Protocol.Runtime.ConsoleAPICalledEvent
247
- );
248
- }
249
- } else {
250
- // We should never get here, but who know is 2022...
251
- console.error("unrecognised devtools event:", event);
252
- }
253
- });
254
- }
255
-
256
- ws.addEventListener("open", () => {
257
- send({ method: "Runtime.enable", id: messageCounterRef.current });
258
- // TODO: This doesn't actually work. Must fix.
259
- send({ method: "Network.enable", id: messageCounterRef.current++ });
260
-
261
- keepAliveInterval = setInterval(() => {
262
- send({
263
- method: "Runtime.getIsolateId",
264
- id: messageCounterRef.current++,
265
- });
266
- }, 10_000);
267
- });
268
-
269
- ws.on("unexpected-response", () => {
270
- console.log("waiting for connection...");
271
- /**
272
- * This usually means the worker is not "ready" yet
273
- * so we'll just retry the connection process
274
- */
275
- retryRemoteWebSocketConnection();
276
- });
277
-
278
- ws.addEventListener("close", () => {
279
- clearInterval(keepAliveInterval);
280
- });
281
-
282
- return () => {
283
- // clean up! Let's first stop the heartbeat interval
284
- clearInterval(keepAliveInterval);
285
- // Then we'll send a message to the devtools instance to
286
- // tell it to clear the console.
287
- wsServerRef.current.clients.forEach((client) => {
288
- // We could've used `localSocket` here, but
289
- // then we would have had to add it to the effect
290
- // change detection array, which would have made a
291
- // bunch of other stuff complicated. So we'll just
292
- // cycle through all of the server's connected clients
293
- // (in practice, there should only be one or zero) and send
294
- // the Log.clear message.
295
- client.send(
296
- JSON.stringify({
297
- // TODO: This doesn't actually work. Must fix.
298
- method: "Log.clear",
299
- // we can disable the next eslint warning since
300
- // we're referencing a ref that stays alive
301
- // eslint-disable-next-line react-hooks/exhaustive-deps
302
- id: messageCounterRef.current++,
303
- params: {},
304
- })
305
- );
306
- });
307
- // Finally, we'll close the websocket
308
- close();
309
- // And we'll clear `remoteWebsocket`
310
- setRemoteWebSocket(undefined);
311
- };
312
- }, [
313
- props.inspectorUrl,
314
- retryRemoteWebSocketConnectionSigil,
315
- props.logToTerminal,
316
- ]);
317
-
318
- /**
319
- * We want to make sure we don't lose any messages we receive from the
320
- * remote websocket before devtools connects. So we use a ref to buffer
321
- * messages, and flush them whenever devtools connects.
322
- */
323
- const messageBufferRef = useRef<MessageEvent[]>([]);
324
-
325
- // This effect tracks the state changes _between_ the local
326
- // and remote websockets, and handles how messages flow between them.
327
- useEffect(() => {
328
- /**
329
- * This event listener is used for buffering messages from
330
- * the remote websocket, and flushing them
331
- * when the local websocket connects.
332
- */
333
- function bufferMessageFromRemoteSocket(event: MessageEvent) {
334
- messageBufferRef.current.push(event);
335
- // TODO: maybe we should have a max limit on this?
336
- // if so, we should be careful when removing messages
337
- // from the front, because they could be critical for
338
- // devtools (like execution context creation, etc)
339
- }
340
-
341
- if (remoteWebSocket && !localWebSocket) {
342
- // The local websocket hasn't connected yet, so we'll
343
- // buffer messages until it does.
344
- remoteWebSocket.addEventListener(
345
- "message",
346
- bufferMessageFromRemoteSocket
347
- );
348
- }
349
-
350
- /** Send a message from the local websocket to the remote websocket */
351
- function sendMessageToRemoteWebSocket(event: MessageEvent) {
352
- try {
353
- remoteWebSocket.send(event.data);
354
- } catch (e) {
355
- if (e.message !== "WebSocket is not open: readyState 0 (CONNECTING)") {
356
- /**
357
- * ^ this just means we haven't opened a websocket yet
358
- * usually happens until there's at least one request
359
- * which is weird, because we may miss something that
360
- * happens on the first request. Maybe we should buffer
361
- * these messages too?
362
- */
363
- console.error(e);
364
- }
365
- }
366
- }
367
-
368
- /** Send a message from the local websocket to the remote websocket */
369
- function sendMessageToLocalWebSocket(event: MessageEvent) {
370
- localWebSocket.send(event.data);
371
- }
372
-
373
- if (localWebSocket && remoteWebSocket) {
374
- // Both the remote and local websockets are connected, so let's
375
- // start sending messages between them.
376
- localWebSocket.addEventListener("message", sendMessageToRemoteWebSocket);
377
- remoteWebSocket.addEventListener("message", sendMessageToLocalWebSocket);
378
-
379
- // Also, let's flush any buffered messages
380
- messageBufferRef.current.forEach(sendMessageToLocalWebSocket);
381
- messageBufferRef.current = [];
382
- }
383
-
384
- return () => {
385
- // Cleanup like good citizens
386
- if (remoteWebSocket) {
387
- remoteWebSocket.removeEventListener(
388
- "message",
389
- bufferMessageFromRemoteSocket
390
- );
391
- remoteWebSocket.removeEventListener(
392
- "message",
393
- sendMessageToLocalWebSocket
394
- );
395
- }
396
- if (localWebSocket) {
397
- localWebSocket.removeEventListener(
398
- "message",
399
- sendMessageToRemoteWebSocket
400
- );
401
- }
402
- };
403
- }, [localWebSocket, remoteWebSocket]);
404
- }
405
-
406
- // Credit: https://stackoverflow.com/a/2117523
407
- function randomId(): string {
408
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
409
- const r = (Math.random() * 16) | 0,
410
- v = c == "x" ? r : (r & 0x3) | 0x8;
411
- return v.toString(16);
412
- });
413
- }
414
-
415
- /**
416
- * This function converts a message serialised as a devtools event
417
- * into arguments suitable to be called by a console method, and
418
- * then actually calls the method with those arguments. Effectively,
419
- * we're just doing a little bit of the work of the devtools console,
420
- * directly in the terminal.
421
- */
422
- function logConsoleMessage(evt: Protocol.Runtime.ConsoleAPICalledEvent): void {
423
- const args = [];
424
- for (const ro of evt.args) {
425
- switch (ro.type) {
426
- case "string":
427
- case "number":
428
- case "boolean":
429
- case "undefined":
430
- case "symbol":
431
- case "bigint":
432
- args.push(ro.value);
433
- break;
434
- case "function":
435
- args.push(`[Function: ${ro.description}]`);
436
- break;
437
- case "object":
438
- if (!ro.preview) {
439
- args.push(ro.description);
440
- } else {
441
- args.push(ro.preview.description);
442
-
443
- switch (ro.preview.subtype) {
444
- case "array":
445
- args.push(
446
- "[ " +
447
- ro.preview.properties
448
- .map(({ value }) => {
449
- return value;
450
- })
451
- .join(", ") +
452
- (ro.preview.overflow ? "..." : "") +
453
- " ]"
454
- );
455
-
456
- break;
457
- case "map":
458
- args.push(
459
- "{\n" +
460
- ro.preview.entries
461
- .map(({ key, value }) => {
462
- return ` ${key.description} => ${value.description}`;
463
- })
464
- .join(",\n") +
465
- (ro.preview.overflow ? "\n ..." : "") +
466
- "\n}"
467
- );
468
-
469
- break;
470
- case "set":
471
- args.push(
472
- "{ " +
473
- ro.preview.entries
474
- .map(({ value }) => {
475
- return `${value.description}`;
476
- })
477
- .join(", ") +
478
- (ro.preview.overflow ? ", ..." : "") +
479
- " }"
480
- );
481
-
482
- break;
483
- case "null":
484
- args.push("null");
485
- break;
486
- case "node":
487
- case "regexp":
488
- case "date":
489
- case "weakmap":
490
- case "weakset":
491
- case "iterator":
492
- case "generator":
493
- case "error":
494
- case "proxy":
495
- case "promise":
496
- case "typedarray":
497
- case "arraybuffer":
498
- case "dataview":
499
- case "webassemblymemory":
500
- case "wasmvalue":
501
- break;
502
- default:
503
- // just a pojo
504
- args.push(
505
- "{\n" +
506
- ro.preview.properties
507
- .map(({ name, value }) => {
508
- return ` ${name}: ${value}`;
509
- })
510
- .join(",\n") +
511
- (ro.preview.overflow ? "\n ..." : "") +
512
- "\n}"
513
- );
514
- }
515
- }
516
- break;
517
- default:
518
- args.push(ro.description || ro.unserializableValue || "🦋");
519
- break;
520
- }
521
- }
522
-
523
- console[evt.type](...args);
524
- }