@marko/run 0.2.17 → 0.3.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.
@@ -10,6 +10,7 @@ import { createServer } from "vite";
10
10
  import * as webStream from "stream/web";
11
11
  import { webcrypto } from "crypto";
12
12
  import * as undici from "undici";
13
+ import { ServerResponse } from "http";
13
14
  globalThis.crypto ?? (globalThis.crypto = webcrypto);
14
15
  globalThis.fetch ?? (globalThis.fetch = undici.fetch);
15
16
  globalThis.Response ?? (globalThis.Response = undici.Response);
@@ -20,51 +21,25 @@ globalThis.TransformStream ?? (globalThis.TransformStream = webStream.TransformS
20
21
  globalThis.WritableStream ?? (globalThis.WritableStream = webStream.WritableStream);
21
22
  globalThis.FormData ?? (globalThis.FormData = undici.FormData);
22
23
  globalThis.File ?? (globalThis.File = undici.File);
23
-
24
- // src/adapter/middleware.ts
25
- function getForwardedHeader(req, name) {
26
- const value = req.headers["x-forwarded-" + name];
27
- if (value) {
28
- if (typeof value === "string") {
29
- const index = value.indexOf(",");
30
- return index < 0 ? value : value.slice(0, index);
31
- }
32
- return value[0];
33
- }
34
- }
35
- function getOrigin(req, trustProxy) {
36
- const protocol = req.protocol || trustProxy && getForwardedHeader(req, "proto") || (req.socket.encrypted ? "https" : "http");
37
- let host = req.headers.host || trustProxy && getForwardedHeader(req, "host");
38
- if (!host) {
39
- if (process.env.NODE_ENV !== "production") {
40
- host = "localhost";
41
- console.warn(
42
- `Could not automatically determine the origin host, using 'localhost'. Use the 'origin' option or the 'ORIGIN' environment variable to set the origin explicitly.`
43
- );
44
- } else {
45
- throw new Error(
46
- `Could not automatically determine the origin host. Use the 'origin' option or the 'ORIGIN' environment variable to set the origin explicitly.`
47
- );
48
- }
49
- }
50
- return `${protocol}://${host}`;
51
- }
52
- var inExpiresDateRgs = /Expires\s*=\s*(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s*$/i;
53
- function setResponseHeaders(response, res) {
54
- for (const [key, value] of response.headers) {
55
- if (key !== "set-cookie") {
56
- res.setHeader(key, value);
57
- }
58
- }
59
- const setCookies = getSetCookie(response.headers);
60
- if (setCookies == null ? void 0 : setCookies.length) {
61
- res.setHeader("set-cookie", setCookies);
24
+ var appendHeader = ServerResponse.prototype.appendHeader ? appendHeader_platform : appendHeader_fallback;
25
+ function appendHeader_platform(response, name, value) {
26
+ response.appendHeader(name, value);
27
+ }
28
+ function appendHeader_fallback(response, name, value) {
29
+ const existing = response.getHeader(name);
30
+ if (existing === void 0) {
31
+ response.setHeader(name, value);
32
+ } else if (Array.isArray(existing)) {
33
+ response.setHeader(name, existing.concat(value));
34
+ } else {
35
+ response.setHeader(name, [String(existing)].concat(value));
62
36
  }
63
37
  }
64
38
  var getSetCookie = Headers.prototype.getSetCookie ? getSetCookie_platform : getSetCookie_fallback;
65
39
  function getSetCookie_platform(headers) {
66
40
  return headers.getSetCookie();
67
41
  }
42
+ var inExpiresDateRgs = /Expires\s*=\s*(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s*$/i;
68
43
  function getSetCookie_fallback(headers) {
69
44
  const value = headers.get("set-cookie");
70
45
  if (!value)
@@ -101,6 +76,46 @@ function getSetCookie_fallback(headers) {
101
76
  }
102
77
  return value;
103
78
  }
79
+
80
+ // src/adapter/middleware.ts
81
+ function getForwardedHeader(req, name) {
82
+ const value = req.headers["x-forwarded-" + name];
83
+ if (value) {
84
+ if (typeof value === "string") {
85
+ const index = value.indexOf(",");
86
+ return index < 0 ? value : value.slice(0, index);
87
+ }
88
+ return value[0];
89
+ }
90
+ }
91
+ function getOrigin(req, trustProxy) {
92
+ const protocol = req.protocol || trustProxy && getForwardedHeader(req, "proto") || (req.socket.encrypted ? "https" : "http");
93
+ let host = req.headers.host || trustProxy && getForwardedHeader(req, "host");
94
+ if (!host) {
95
+ if (process.env.NODE_ENV !== "production") {
96
+ host = "localhost";
97
+ console.warn(
98
+ `Could not automatically determine the origin host, using 'localhost'. Use the 'origin' option or the 'ORIGIN' environment variable to set the origin explicitly.`
99
+ );
100
+ } else {
101
+ throw new Error(
102
+ `Could not automatically determine the origin host. Use the 'origin' option or the 'ORIGIN' environment variable to set the origin explicitly.`
103
+ );
104
+ }
105
+ }
106
+ return `${protocol}://${host}`;
107
+ }
108
+ function copyResponseHeaders(response, headers) {
109
+ for (const [key, value] of headers) {
110
+ if (key !== "set-cookie") {
111
+ response.setHeader(key, value);
112
+ }
113
+ }
114
+ const setCookies = getSetCookie(headers);
115
+ if (setCookies == null ? void 0 : setCookies.length) {
116
+ appendHeader(response, "set-cookie", setCookies);
117
+ }
118
+ }
104
119
  function createMiddleware(fetch2, options) {
105
120
  const {
106
121
  origin = process.env.ORIGIN,
@@ -137,9 +152,8 @@ function createMiddleware(fetch2, options) {
137
152
  console.error(signal.reason);
138
153
  }
139
154
  }
140
- let setDevClientId;
141
155
  if (process.env.NODE_ENV !== "production" && globalThis.__marko_run_dev__ && ((_a = req.headers.accept) == null ? void 0 : _a.includes("text/html"))) {
142
- setDevClientId = globalThis.__marko_run_dev__.onClient((ws) => {
156
+ globalThis.__marko_run_dev__.onClient(res, (ws) => {
143
157
  if (signal.aborted) {
144
158
  sendError();
145
159
  } else {
@@ -183,11 +197,8 @@ function createMiddleware(fetch2, options) {
183
197
  }
184
198
  return;
185
199
  }
186
- if (process.env.NODE_ENV !== "production" && setDevClientId) {
187
- setDevClientId(response);
188
- }
189
200
  res.statusCode = response.status;
190
- setResponseHeaders(response, res);
201
+ copyResponseHeaders(res, response.headers);
191
202
  if (!response.body) {
192
203
  if (!response.headers.has("content-length")) {
193
204
  res.setHeader("content-length", "0");
@@ -313,7 +324,12 @@ function logger_default(_options = {}) {
313
324
  if (index < 10) {
314
325
  inFlight ^= bitMask;
315
326
  }
316
- const contentLength = res.getHeader("content-length") || 0;
327
+ let contentLength = res.getHeader("content-length") || 0;
328
+ if (Array.isArray(contentLength)) {
329
+ contentLength = parseInt(contentLength[0], 10) || 0;
330
+ } else if (typeof contentLength === "string") {
331
+ contentLength = parseInt(contentLength, 10) || 0;
332
+ }
317
333
  logResponse(
318
334
  id,
319
335
  req,
@@ -449,7 +465,12 @@ async function createDevServer(config2) {
449
465
  }
450
466
  } else {
451
467
  res.statusCode = 500;
452
- res.end(inspect(err).replace(/([\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><])/g, ""));
468
+ res.end(
469
+ inspect(err).replace(
470
+ /([\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><])/g,
471
+ ""
472
+ )
473
+ );
453
474
  }
454
475
  } else {
455
476
  next == null ? void 0 : next();
@@ -512,7 +533,7 @@ function getDevGlobal() {
512
533
  devServer.close();
513
534
  }
514
535
  },
515
- onClient(callback) {
536
+ onClient(res, callback) {
516
537
  const expires = Date.now() + 1e3;
517
538
  const id = Math.floor(Math.random() * expires).toString(36);
518
539
  callbacks.push({
@@ -520,12 +541,10 @@ function getDevGlobal() {
520
541
  expires,
521
542
  callback
522
543
  });
523
- return (response) => {
524
- response.headers.append(
525
- "set-cookie",
526
- `${ClientIdCookieName}=${id}; Path=/; Max-Age=100; HttpOnly`
527
- );
528
- };
544
+ res.setHeader(
545
+ "set-cookie",
546
+ `${ClientIdCookieName}=${id}; Path=/; Max-Age=100; HttpOnly`
547
+ );
529
548
  }
530
549
  };
531
550
  }
@@ -539,7 +558,7 @@ function logInfoBox(address, explorer) {
539
558
  const color = !!supporsColor.stdout;
540
559
  let message = kleur2.bold("Marko Run");
541
560
  if (true) {
542
- message += ` v${"0.2.17"}`;
561
+ message += ` v${"0.3.0"}`;
543
562
  }
544
563
  message += "\n\n";
545
564
  message += kleur2.dim("Server listening at");
@@ -30,10 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/adapter/middleware.ts
31
31
  var middleware_exports = {};
32
32
  __export(middleware_exports, {
33
+ copyResponseHeaders: () => copyResponseHeaders,
33
34
  createMiddleware: () => createMiddleware,
34
- getOrigin: () => getOrigin,
35
- getSetCookie_fallback: () => getSetCookie_fallback,
36
- setResponseHeaders: () => setResponseHeaders
35
+ getOrigin: () => getOrigin
37
36
  });
38
37
  module.exports = __toCommonJS(middleware_exports);
39
38
 
@@ -45,6 +44,7 @@ var __importMetaURL = (0, import_url.pathToFileURL)(__filename);
45
44
  var webStream = __toESM(require("stream/web"), 1);
46
45
  var import_crypto = require("crypto");
47
46
  var undici = __toESM(require("undici"), 1);
47
+ var import_http = require("http");
48
48
  globalThis.crypto ?? (globalThis.crypto = import_crypto.webcrypto);
49
49
  globalThis.fetch ?? (globalThis.fetch = undici.fetch);
50
50
  globalThis.Response ?? (globalThis.Response = undici.Response);
@@ -55,51 +55,25 @@ globalThis.TransformStream ?? (globalThis.TransformStream = webStream.TransformS
55
55
  globalThis.WritableStream ?? (globalThis.WritableStream = webStream.WritableStream);
56
56
  globalThis.FormData ?? (globalThis.FormData = undici.FormData);
57
57
  globalThis.File ?? (globalThis.File = undici.File);
58
-
59
- // src/adapter/middleware.ts
60
- function getForwardedHeader(req, name) {
61
- const value = req.headers["x-forwarded-" + name];
62
- if (value) {
63
- if (typeof value === "string") {
64
- const index = value.indexOf(",");
65
- return index < 0 ? value : value.slice(0, index);
66
- }
67
- return value[0];
68
- }
58
+ var appendHeader = import_http.ServerResponse.prototype.appendHeader ? appendHeader_platform : appendHeader_fallback;
59
+ function appendHeader_platform(response, name, value) {
60
+ response.appendHeader(name, value);
69
61
  }
70
- function getOrigin(req, trustProxy) {
71
- const protocol = req.protocol || trustProxy && getForwardedHeader(req, "proto") || (req.socket.encrypted ? "https" : "http");
72
- let host = req.headers.host || trustProxy && getForwardedHeader(req, "host");
73
- if (!host) {
74
- if (process.env.NODE_ENV !== "production") {
75
- host = "localhost";
76
- console.warn(
77
- `Could not automatically determine the origin host, using 'localhost'. Use the 'origin' option or the 'ORIGIN' environment variable to set the origin explicitly.`
78
- );
79
- } else {
80
- throw new Error(
81
- `Could not automatically determine the origin host. Use the 'origin' option or the 'ORIGIN' environment variable to set the origin explicitly.`
82
- );
83
- }
84
- }
85
- return `${protocol}://${host}`;
86
- }
87
- var inExpiresDateRgs = /Expires\s*=\s*(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s*$/i;
88
- function setResponseHeaders(response, res) {
89
- for (const [key, value] of response.headers) {
90
- if (key !== "set-cookie") {
91
- res.setHeader(key, value);
92
- }
93
- }
94
- const setCookies = getSetCookie(response.headers);
95
- if (setCookies == null ? void 0 : setCookies.length) {
96
- res.setHeader("set-cookie", setCookies);
62
+ function appendHeader_fallback(response, name, value) {
63
+ const existing = response.getHeader(name);
64
+ if (existing === void 0) {
65
+ response.setHeader(name, value);
66
+ } else if (Array.isArray(existing)) {
67
+ response.setHeader(name, existing.concat(value));
68
+ } else {
69
+ response.setHeader(name, [String(existing)].concat(value));
97
70
  }
98
71
  }
99
72
  var getSetCookie = Headers.prototype.getSetCookie ? getSetCookie_platform : getSetCookie_fallback;
100
73
  function getSetCookie_platform(headers) {
101
74
  return headers.getSetCookie();
102
75
  }
76
+ var inExpiresDateRgs = /Expires\s*=\s*(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s*$/i;
103
77
  function getSetCookie_fallback(headers) {
104
78
  const value = headers.get("set-cookie");
105
79
  if (!value)
@@ -136,6 +110,46 @@ function getSetCookie_fallback(headers) {
136
110
  }
137
111
  return value;
138
112
  }
113
+
114
+ // src/adapter/middleware.ts
115
+ function getForwardedHeader(req, name) {
116
+ const value = req.headers["x-forwarded-" + name];
117
+ if (value) {
118
+ if (typeof value === "string") {
119
+ const index = value.indexOf(",");
120
+ return index < 0 ? value : value.slice(0, index);
121
+ }
122
+ return value[0];
123
+ }
124
+ }
125
+ function getOrigin(req, trustProxy) {
126
+ const protocol = req.protocol || trustProxy && getForwardedHeader(req, "proto") || (req.socket.encrypted ? "https" : "http");
127
+ let host = req.headers.host || trustProxy && getForwardedHeader(req, "host");
128
+ if (!host) {
129
+ if (process.env.NODE_ENV !== "production") {
130
+ host = "localhost";
131
+ console.warn(
132
+ `Could not automatically determine the origin host, using 'localhost'. Use the 'origin' option or the 'ORIGIN' environment variable to set the origin explicitly.`
133
+ );
134
+ } else {
135
+ throw new Error(
136
+ `Could not automatically determine the origin host. Use the 'origin' option or the 'ORIGIN' environment variable to set the origin explicitly.`
137
+ );
138
+ }
139
+ }
140
+ return `${protocol}://${host}`;
141
+ }
142
+ function copyResponseHeaders(response, headers) {
143
+ for (const [key, value] of headers) {
144
+ if (key !== "set-cookie") {
145
+ response.setHeader(key, value);
146
+ }
147
+ }
148
+ const setCookies = getSetCookie(headers);
149
+ if (setCookies == null ? void 0 : setCookies.length) {
150
+ appendHeader(response, "set-cookie", setCookies);
151
+ }
152
+ }
139
153
  function createMiddleware(fetch2, options) {
140
154
  const {
141
155
  origin = process.env.ORIGIN,
@@ -172,9 +186,8 @@ function createMiddleware(fetch2, options) {
172
186
  console.error(signal.reason);
173
187
  }
174
188
  }
175
- let setDevClientId;
176
189
  if (process.env.NODE_ENV !== "production" && globalThis.__marko_run_dev__ && ((_a = req.headers.accept) == null ? void 0 : _a.includes("text/html"))) {
177
- setDevClientId = globalThis.__marko_run_dev__.onClient((ws) => {
190
+ globalThis.__marko_run_dev__.onClient(res, (ws) => {
178
191
  if (signal.aborted) {
179
192
  sendError();
180
193
  } else {
@@ -218,11 +231,8 @@ function createMiddleware(fetch2, options) {
218
231
  }
219
232
  return;
220
233
  }
221
- if (process.env.NODE_ENV !== "production" && setDevClientId) {
222
- setDevClientId(response);
223
- }
224
234
  res.statusCode = response.status;
225
- setResponseHeaders(response, res);
235
+ copyResponseHeaders(res, response.headers);
226
236
  if (!response.body) {
227
237
  if (!response.headers.has("content-length")) {
228
238
  res.setHeader("content-length", "0");
@@ -265,8 +275,7 @@ var bodyConsumedErrorStream = new ReadableStream({
265
275
  });
266
276
  // Annotate the CommonJS export names for ESM import in node:
267
277
  0 && (module.exports = {
278
+ copyResponseHeaders,
268
279
  createMiddleware,
269
- getOrigin,
270
- getSetCookie_fallback,
271
- setResponseHeaders
280
+ getOrigin
272
281
  });
@@ -1,7 +1,6 @@
1
1
  /// <reference types="node" />
2
- import "./polyfill";
3
2
  import type { Fetch, Platform } from "../runtime";
4
- import type { IncomingMessage, ServerResponse, OutgoingMessage } from "http";
3
+ import { IncomingMessage, ServerResponse } from "http";
5
4
  export interface NodePlatformInfo {
6
5
  request: IncomingMessage;
7
6
  response: ServerResponse;
@@ -33,8 +32,7 @@ export interface NodeMiddlewareOptions {
33
32
  createPlatform?(platform: NodePlatformInfo): Platform & NodePlatformInfo;
34
33
  }
35
34
  export declare function getOrigin(req: IncomingMessage, trustProxy?: boolean): string;
36
- export declare function setResponseHeaders(response: Response, res: OutgoingMessage): void;
37
- export declare function getSetCookie_fallback(headers: Headers): string | string[] | undefined;
35
+ export declare function copyResponseHeaders(response: ServerResponse, headers: Headers): void;
38
36
  /**
39
37
  * Creates a request handler to be passed to http.createServer() or used as a
40
38
  * middleware in Connect-style frameworks like Express.
@@ -2,6 +2,7 @@
2
2
  import * as webStream from "stream/web";
3
3
  import { webcrypto } from "crypto";
4
4
  import * as undici from "undici";
5
+ import { ServerResponse } from "http";
5
6
  globalThis.crypto ?? (globalThis.crypto = webcrypto);
6
7
  globalThis.fetch ?? (globalThis.fetch = undici.fetch);
7
8
  globalThis.Response ?? (globalThis.Response = undici.Response);
@@ -12,51 +13,25 @@ globalThis.TransformStream ?? (globalThis.TransformStream = webStream.TransformS
12
13
  globalThis.WritableStream ?? (globalThis.WritableStream = webStream.WritableStream);
13
14
  globalThis.FormData ?? (globalThis.FormData = undici.FormData);
14
15
  globalThis.File ?? (globalThis.File = undici.File);
15
-
16
- // src/adapter/middleware.ts
17
- function getForwardedHeader(req, name) {
18
- const value = req.headers["x-forwarded-" + name];
19
- if (value) {
20
- if (typeof value === "string") {
21
- const index = value.indexOf(",");
22
- return index < 0 ? value : value.slice(0, index);
23
- }
24
- return value[0];
25
- }
16
+ var appendHeader = ServerResponse.prototype.appendHeader ? appendHeader_platform : appendHeader_fallback;
17
+ function appendHeader_platform(response, name, value) {
18
+ response.appendHeader(name, value);
26
19
  }
27
- function getOrigin(req, trustProxy) {
28
- const protocol = req.protocol || trustProxy && getForwardedHeader(req, "proto") || (req.socket.encrypted ? "https" : "http");
29
- let host = req.headers.host || trustProxy && getForwardedHeader(req, "host");
30
- if (!host) {
31
- if (process.env.NODE_ENV !== "production") {
32
- host = "localhost";
33
- console.warn(
34
- `Could not automatically determine the origin host, using 'localhost'. Use the 'origin' option or the 'ORIGIN' environment variable to set the origin explicitly.`
35
- );
36
- } else {
37
- throw new Error(
38
- `Could not automatically determine the origin host. Use the 'origin' option or the 'ORIGIN' environment variable to set the origin explicitly.`
39
- );
40
- }
41
- }
42
- return `${protocol}://${host}`;
43
- }
44
- var inExpiresDateRgs = /Expires\s*=\s*(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s*$/i;
45
- function setResponseHeaders(response, res) {
46
- for (const [key, value] of response.headers) {
47
- if (key !== "set-cookie") {
48
- res.setHeader(key, value);
49
- }
50
- }
51
- const setCookies = getSetCookie(response.headers);
52
- if (setCookies == null ? void 0 : setCookies.length) {
53
- res.setHeader("set-cookie", setCookies);
20
+ function appendHeader_fallback(response, name, value) {
21
+ const existing = response.getHeader(name);
22
+ if (existing === void 0) {
23
+ response.setHeader(name, value);
24
+ } else if (Array.isArray(existing)) {
25
+ response.setHeader(name, existing.concat(value));
26
+ } else {
27
+ response.setHeader(name, [String(existing)].concat(value));
54
28
  }
55
29
  }
56
30
  var getSetCookie = Headers.prototype.getSetCookie ? getSetCookie_platform : getSetCookie_fallback;
57
31
  function getSetCookie_platform(headers) {
58
32
  return headers.getSetCookie();
59
33
  }
34
+ var inExpiresDateRgs = /Expires\s*=\s*(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s*$/i;
60
35
  function getSetCookie_fallback(headers) {
61
36
  const value = headers.get("set-cookie");
62
37
  if (!value)
@@ -93,6 +68,46 @@ function getSetCookie_fallback(headers) {
93
68
  }
94
69
  return value;
95
70
  }
71
+
72
+ // src/adapter/middleware.ts
73
+ function getForwardedHeader(req, name) {
74
+ const value = req.headers["x-forwarded-" + name];
75
+ if (value) {
76
+ if (typeof value === "string") {
77
+ const index = value.indexOf(",");
78
+ return index < 0 ? value : value.slice(0, index);
79
+ }
80
+ return value[0];
81
+ }
82
+ }
83
+ function getOrigin(req, trustProxy) {
84
+ const protocol = req.protocol || trustProxy && getForwardedHeader(req, "proto") || (req.socket.encrypted ? "https" : "http");
85
+ let host = req.headers.host || trustProxy && getForwardedHeader(req, "host");
86
+ if (!host) {
87
+ if (process.env.NODE_ENV !== "production") {
88
+ host = "localhost";
89
+ console.warn(
90
+ `Could not automatically determine the origin host, using 'localhost'. Use the 'origin' option or the 'ORIGIN' environment variable to set the origin explicitly.`
91
+ );
92
+ } else {
93
+ throw new Error(
94
+ `Could not automatically determine the origin host. Use the 'origin' option or the 'ORIGIN' environment variable to set the origin explicitly.`
95
+ );
96
+ }
97
+ }
98
+ return `${protocol}://${host}`;
99
+ }
100
+ function copyResponseHeaders(response, headers) {
101
+ for (const [key, value] of headers) {
102
+ if (key !== "set-cookie") {
103
+ response.setHeader(key, value);
104
+ }
105
+ }
106
+ const setCookies = getSetCookie(headers);
107
+ if (setCookies == null ? void 0 : setCookies.length) {
108
+ appendHeader(response, "set-cookie", setCookies);
109
+ }
110
+ }
96
111
  function createMiddleware(fetch2, options) {
97
112
  const {
98
113
  origin = process.env.ORIGIN,
@@ -129,9 +144,8 @@ function createMiddleware(fetch2, options) {
129
144
  console.error(signal.reason);
130
145
  }
131
146
  }
132
- let setDevClientId;
133
147
  if (process.env.NODE_ENV !== "production" && globalThis.__marko_run_dev__ && ((_a = req.headers.accept) == null ? void 0 : _a.includes("text/html"))) {
134
- setDevClientId = globalThis.__marko_run_dev__.onClient((ws) => {
148
+ globalThis.__marko_run_dev__.onClient(res, (ws) => {
135
149
  if (signal.aborted) {
136
150
  sendError();
137
151
  } else {
@@ -175,11 +189,8 @@ function createMiddleware(fetch2, options) {
175
189
  }
176
190
  return;
177
191
  }
178
- if (process.env.NODE_ENV !== "production" && setDevClientId) {
179
- setDevClientId(response);
180
- }
181
192
  res.statusCode = response.status;
182
- setResponseHeaders(response, res);
193
+ copyResponseHeaders(res, response.headers);
183
194
  if (!response.body) {
184
195
  if (!response.headers.has("content-length")) {
185
196
  res.setHeader("content-length", "0");
@@ -221,8 +232,7 @@ var bodyConsumedErrorStream = new ReadableStream({
221
232
  }
222
233
  });
223
234
  export {
235
+ copyResponseHeaders,
224
236
  createMiddleware,
225
- getOrigin,
226
- getSetCookie_fallback,
227
- setResponseHeaders
237
+ getOrigin
228
238
  };
@@ -1,6 +1,12 @@
1
+ /// <reference types="node" />
2
+ import { ServerResponse } from 'http';
1
3
  declare global {
2
4
  interface Headers {
3
5
  getSetCookie: () => string[];
4
6
  }
5
7
  }
8
+ export declare const appendHeader: typeof appendHeader_platform;
9
+ declare function appendHeader_platform(response: ServerResponse, name: string, value: string | readonly string[]): void;
10
+ export declare const getSetCookie: typeof getSetCookie_fallback;
11
+ export declare function getSetCookie_fallback(headers: Headers): string | string[] | undefined;
6
12
  export {};