@comapeo/map-server 1.0.0-pre.0 → 1.0.0-pre.2

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 (146) hide show
  1. package/dist/context.d.ts +1 -1
  2. package/dist/context.js +1 -1
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1 -0
  6. package/dist/lib/map-share.js +1 -1
  7. package/dist/routes/maps.js +1 -1
  8. package/dist/types.d.ts +5 -5
  9. package/dist/types.js +2 -2
  10. package/node_modules/@fastify/busboy/LICENSE +24 -0
  11. package/node_modules/@fastify/busboy/README.md +270 -0
  12. package/node_modules/@fastify/busboy/deps/dicer/LICENSE +19 -0
  13. package/node_modules/@fastify/busboy/deps/dicer/lib/Dicer.js +213 -0
  14. package/node_modules/@fastify/busboy/deps/dicer/lib/HeaderParser.js +100 -0
  15. package/node_modules/@fastify/busboy/deps/dicer/lib/PartStream.js +13 -0
  16. package/node_modules/@fastify/busboy/deps/dicer/lib/dicer.d.ts +164 -0
  17. package/node_modules/@fastify/busboy/deps/streamsearch/sbmh.js +230 -0
  18. package/node_modules/@fastify/busboy/lib/main.d.ts +196 -0
  19. package/node_modules/@fastify/busboy/lib/main.js +85 -0
  20. package/node_modules/@fastify/busboy/lib/types/multipart.js +306 -0
  21. package/node_modules/@fastify/busboy/lib/types/urlencoded.js +190 -0
  22. package/node_modules/@fastify/busboy/lib/utils/Decoder.js +54 -0
  23. package/node_modules/@fastify/busboy/lib/utils/basename.js +14 -0
  24. package/node_modules/@fastify/busboy/lib/utils/decodeText.js +114 -0
  25. package/node_modules/@fastify/busboy/lib/utils/getLimit.js +16 -0
  26. package/node_modules/@fastify/busboy/lib/utils/parseParams.js +201 -0
  27. package/node_modules/@fastify/busboy/package.json +81 -0
  28. package/node_modules/@whatwg-node/fetch/CHANGELOG.md +941 -0
  29. package/node_modules/@whatwg-node/fetch/README.md +141 -0
  30. package/node_modules/@whatwg-node/fetch/dist/create-node-ponyfill.js +100 -0
  31. package/node_modules/@whatwg-node/fetch/dist/esm-ponyfill.js +71 -0
  32. package/node_modules/@whatwg-node/fetch/dist/global-ponyfill.js +22 -0
  33. package/node_modules/@whatwg-node/fetch/dist/index.d.ts +73 -0
  34. package/node_modules/@whatwg-node/fetch/dist/node-ponyfill.js +35 -0
  35. package/node_modules/@whatwg-node/fetch/dist/shouldSkipPonyfill.js +17 -0
  36. package/node_modules/@whatwg-node/fetch/package.json +31 -0
  37. package/node_modules/@whatwg-node/node-fetch/cjs/AbortError.js +19 -0
  38. package/node_modules/@whatwg-node/node-fetch/cjs/Blob.js +291 -0
  39. package/node_modules/@whatwg-node/node-fetch/cjs/Body.js +529 -0
  40. package/node_modules/@whatwg-node/node-fetch/cjs/CompressionStream.js +34 -0
  41. package/node_modules/@whatwg-node/node-fetch/cjs/DecompressionStream.js +34 -0
  42. package/node_modules/@whatwg-node/node-fetch/cjs/File.js +15 -0
  43. package/node_modules/@whatwg-node/node-fetch/cjs/FormData.js +150 -0
  44. package/node_modules/@whatwg-node/node-fetch/cjs/Headers.js +309 -0
  45. package/node_modules/@whatwg-node/node-fetch/cjs/IteratorObject.js +134 -0
  46. package/node_modules/@whatwg-node/node-fetch/cjs/ReadableStream.js +245 -0
  47. package/node_modules/@whatwg-node/node-fetch/cjs/Request.js +128 -0
  48. package/node_modules/@whatwg-node/node-fetch/cjs/Response.js +108 -0
  49. package/node_modules/@whatwg-node/node-fetch/cjs/TextEncoderDecoder.js +49 -0
  50. package/node_modules/@whatwg-node/node-fetch/cjs/TextEncoderDecoderStream.js +40 -0
  51. package/node_modules/@whatwg-node/node-fetch/cjs/TransformStream.js +79 -0
  52. package/node_modules/@whatwg-node/node-fetch/cjs/URL.js +28 -0
  53. package/node_modules/@whatwg-node/node-fetch/cjs/URLSearchParams.js +4 -0
  54. package/node_modules/@whatwg-node/node-fetch/cjs/WritableStream.js +115 -0
  55. package/node_modules/@whatwg-node/node-fetch/cjs/fetch.js +107 -0
  56. package/node_modules/@whatwg-node/node-fetch/cjs/fetchCurl.js +142 -0
  57. package/node_modules/@whatwg-node/node-fetch/cjs/fetchNodeHttp.js +152 -0
  58. package/node_modules/@whatwg-node/node-fetch/cjs/index.js +42 -0
  59. package/node_modules/@whatwg-node/node-fetch/cjs/package.json +1 -0
  60. package/node_modules/@whatwg-node/node-fetch/cjs/utils.js +125 -0
  61. package/node_modules/@whatwg-node/node-fetch/esm/AbortError.js +15 -0
  62. package/node_modules/@whatwg-node/node-fetch/esm/Blob.js +279 -0
  63. package/node_modules/@whatwg-node/node-fetch/esm/Body.js +525 -0
  64. package/node_modules/@whatwg-node/node-fetch/esm/CompressionStream.js +29 -0
  65. package/node_modules/@whatwg-node/node-fetch/esm/DecompressionStream.js +29 -0
  66. package/node_modules/@whatwg-node/node-fetch/esm/File.js +11 -0
  67. package/node_modules/@whatwg-node/node-fetch/esm/FormData.js +145 -0
  68. package/node_modules/@whatwg-node/node-fetch/esm/Headers.js +304 -0
  69. package/node_modules/@whatwg-node/node-fetch/esm/IteratorObject.js +130 -0
  70. package/node_modules/@whatwg-node/node-fetch/esm/ReadableStream.js +241 -0
  71. package/node_modules/@whatwg-node/node-fetch/esm/Request.js +124 -0
  72. package/node_modules/@whatwg-node/node-fetch/esm/Response.js +104 -0
  73. package/node_modules/@whatwg-node/node-fetch/esm/TextEncoderDecoder.js +43 -0
  74. package/node_modules/@whatwg-node/node-fetch/esm/TextEncoderDecoderStream.js +35 -0
  75. package/node_modules/@whatwg-node/node-fetch/esm/TransformStream.js +75 -0
  76. package/node_modules/@whatwg-node/node-fetch/esm/URL.js +24 -0
  77. package/node_modules/@whatwg-node/node-fetch/esm/URLSearchParams.js +1 -0
  78. package/node_modules/@whatwg-node/node-fetch/esm/WritableStream.js +111 -0
  79. package/node_modules/@whatwg-node/node-fetch/esm/fetch.js +104 -0
  80. package/node_modules/@whatwg-node/node-fetch/esm/fetchCurl.js +139 -0
  81. package/node_modules/@whatwg-node/node-fetch/esm/fetchNodeHttp.js +148 -0
  82. package/node_modules/@whatwg-node/node-fetch/esm/index.js +18 -0
  83. package/node_modules/@whatwg-node/node-fetch/esm/utils.js +110 -0
  84. package/node_modules/@whatwg-node/node-fetch/package.json +46 -0
  85. package/node_modules/@whatwg-node/node-fetch/typings/AbortError.d.cts +4 -0
  86. package/node_modules/@whatwg-node/node-fetch/typings/AbortError.d.ts +4 -0
  87. package/node_modules/@whatwg-node/node-fetch/typings/Blob.d.cts +63 -0
  88. package/node_modules/@whatwg-node/node-fetch/typings/Blob.d.ts +63 -0
  89. package/node_modules/@whatwg-node/node-fetch/typings/Body.d.cts +54 -0
  90. package/node_modules/@whatwg-node/node-fetch/typings/Body.d.ts +54 -0
  91. package/node_modules/@whatwg-node/node-fetch/typings/CompressionStream.d.cts +6 -0
  92. package/node_modules/@whatwg-node/node-fetch/typings/CompressionStream.d.ts +6 -0
  93. package/node_modules/@whatwg-node/node-fetch/typings/DecompressionStream.d.cts +6 -0
  94. package/node_modules/@whatwg-node/node-fetch/typings/DecompressionStream.d.ts +6 -0
  95. package/node_modules/@whatwg-node/node-fetch/typings/File.d.cts +7 -0
  96. package/node_modules/@whatwg-node/node-fetch/typings/File.d.ts +7 -0
  97. package/node_modules/@whatwg-node/node-fetch/typings/FormData.d.cts +22 -0
  98. package/node_modules/@whatwg-node/node-fetch/typings/FormData.d.ts +22 -0
  99. package/node_modules/@whatwg-node/node-fetch/typings/Headers.d.cts +26 -0
  100. package/node_modules/@whatwg-node/node-fetch/typings/Headers.d.ts +26 -0
  101. package/node_modules/@whatwg-node/node-fetch/typings/IteratorObject.d.cts +20 -0
  102. package/node_modules/@whatwg-node/node-fetch/typings/IteratorObject.d.ts +20 -0
  103. package/node_modules/@whatwg-node/node-fetch/typings/ReadableStream.d.cts +27 -0
  104. package/node_modules/@whatwg-node/node-fetch/typings/ReadableStream.d.ts +27 -0
  105. package/node_modules/@whatwg-node/node-fetch/typings/Request.d.cts +38 -0
  106. package/node_modules/@whatwg-node/node-fetch/typings/Request.d.ts +38 -0
  107. package/node_modules/@whatwg-node/node-fetch/typings/Response.d.cts +23 -0
  108. package/node_modules/@whatwg-node/node-fetch/typings/Response.d.ts +23 -0
  109. package/node_modules/@whatwg-node/node-fetch/typings/TextEncoderDecoder.d.cts +15 -0
  110. package/node_modules/@whatwg-node/node-fetch/typings/TextEncoderDecoder.d.ts +15 -0
  111. package/node_modules/@whatwg-node/node-fetch/typings/TextEncoderDecoderStream.d.cts +14 -0
  112. package/node_modules/@whatwg-node/node-fetch/typings/TextEncoderDecoderStream.d.ts +14 -0
  113. package/node_modules/@whatwg-node/node-fetch/typings/TransformStream.d.cts +9 -0
  114. package/node_modules/@whatwg-node/node-fetch/typings/TransformStream.d.ts +9 -0
  115. package/node_modules/@whatwg-node/node-fetch/typings/URL.d.cts +16 -0
  116. package/node_modules/@whatwg-node/node-fetch/typings/URL.d.ts +16 -0
  117. package/node_modules/@whatwg-node/node-fetch/typings/URLSearchParams.d.cts +4 -0
  118. package/node_modules/@whatwg-node/node-fetch/typings/URLSearchParams.d.ts +4 -0
  119. package/node_modules/@whatwg-node/node-fetch/typings/WritableStream.d.cts +9 -0
  120. package/node_modules/@whatwg-node/node-fetch/typings/WritableStream.d.ts +9 -0
  121. package/node_modules/@whatwg-node/node-fetch/typings/fetch.d.cts +3 -0
  122. package/node_modules/@whatwg-node/node-fetch/typings/fetch.d.ts +3 -0
  123. package/node_modules/@whatwg-node/node-fetch/typings/fetchCurl.d.cts +3 -0
  124. package/node_modules/@whatwg-node/node-fetch/typings/fetchCurl.d.ts +3 -0
  125. package/node_modules/@whatwg-node/node-fetch/typings/fetchNodeHttp.d.cts +3 -0
  126. package/node_modules/@whatwg-node/node-fetch/typings/fetchNodeHttp.d.ts +3 -0
  127. package/node_modules/@whatwg-node/node-fetch/typings/index.d.cts +18 -0
  128. package/node_modules/@whatwg-node/node-fetch/typings/index.d.ts +18 -0
  129. package/node_modules/@whatwg-node/node-fetch/typings/utils.d.cts +21 -0
  130. package/node_modules/@whatwg-node/node-fetch/typings/utils.d.ts +21 -0
  131. package/node_modules/@whatwg-node/server/package.json +2 -1
  132. package/node_modules/urlpattern-polyfill/LICENSE +19 -0
  133. package/node_modules/urlpattern-polyfill/README.md +242 -0
  134. package/node_modules/urlpattern-polyfill/dist/index.d.ts +9 -0
  135. package/node_modules/urlpattern-polyfill/dist/types.d.ts +49 -0
  136. package/node_modules/urlpattern-polyfill/dist/urlpattern.cjs +1 -0
  137. package/node_modules/urlpattern-polyfill/dist/urlpattern.js +1 -0
  138. package/node_modules/urlpattern-polyfill/index.cjs +7 -0
  139. package/node_modules/urlpattern-polyfill/index.js +7 -0
  140. package/node_modules/urlpattern-polyfill/package.json +149 -0
  141. package/package.json +18 -8
  142. package/src/context.ts +1 -1
  143. package/src/index.ts +2 -0
  144. package/src/lib/map-share.ts +1 -1
  145. package/src/routes/maps.ts +1 -1
  146. package/src/types.ts +2 -2
@@ -0,0 +1,245 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PonyfillReadableStream = void 0;
4
+ const node_buffer_1 = require("node:buffer");
5
+ const node_events_1 = require("node:events");
6
+ const node_stream_1 = require("node:stream");
7
+ const promises_1 = require("node:stream/promises");
8
+ const promise_helpers_1 = require("@whatwg-node/promise-helpers");
9
+ const utils_js_1 = require("./utils.js");
10
+ function createController(desiredSize, readable) {
11
+ let chunks = [];
12
+ let _closed = false;
13
+ let flushed = false;
14
+ return {
15
+ desiredSize,
16
+ enqueue(chunk) {
17
+ const buf = typeof chunk === 'string' ? node_buffer_1.Buffer.from(chunk) : chunk;
18
+ if (!flushed) {
19
+ chunks.push(buf);
20
+ }
21
+ else {
22
+ readable.push(buf);
23
+ }
24
+ },
25
+ close() {
26
+ if (chunks.length > 0) {
27
+ this._flush();
28
+ }
29
+ readable.push(null);
30
+ _closed = true;
31
+ },
32
+ error(error) {
33
+ if (chunks.length > 0) {
34
+ this._flush();
35
+ }
36
+ readable.destroy(error);
37
+ },
38
+ get _closed() {
39
+ return _closed;
40
+ },
41
+ _flush() {
42
+ flushed = true;
43
+ if (chunks.length > 0) {
44
+ const concatenated = chunks.length > 1 ? node_buffer_1.Buffer.concat(chunks) : chunks[0];
45
+ readable.push(concatenated);
46
+ chunks = [];
47
+ }
48
+ },
49
+ };
50
+ }
51
+ function isNodeReadable(obj) {
52
+ return obj?.read != null;
53
+ }
54
+ function isReadableStream(obj) {
55
+ return obj?.getReader != null;
56
+ }
57
+ class PonyfillReadableStream {
58
+ readable;
59
+ constructor(underlyingSource) {
60
+ if (underlyingSource instanceof PonyfillReadableStream && underlyingSource.readable != null) {
61
+ this.readable = underlyingSource.readable;
62
+ }
63
+ else if (isNodeReadable(underlyingSource)) {
64
+ this.readable = underlyingSource;
65
+ }
66
+ else if (isReadableStream(underlyingSource)) {
67
+ this.readable = node_stream_1.Readable.fromWeb(underlyingSource);
68
+ }
69
+ else {
70
+ let started = false;
71
+ let ongoing = false;
72
+ const handleStart = (desiredSize) => {
73
+ if (!started) {
74
+ const controller = createController(desiredSize, this.readable);
75
+ started = true;
76
+ return (0, promise_helpers_1.handleMaybePromise)(() => underlyingSource?.start?.(controller), () => {
77
+ controller._flush();
78
+ if (controller._closed) {
79
+ return false;
80
+ }
81
+ return true;
82
+ });
83
+ }
84
+ return true;
85
+ };
86
+ const readImpl = (desiredSize) => {
87
+ return (0, promise_helpers_1.handleMaybePromise)(() => handleStart(desiredSize), shouldContinue => {
88
+ if (!shouldContinue) {
89
+ return;
90
+ }
91
+ const controller = createController(desiredSize, this.readable);
92
+ return (0, promise_helpers_1.handleMaybePromise)(() => underlyingSource?.pull?.(controller), () => {
93
+ controller._flush();
94
+ ongoing = false;
95
+ });
96
+ });
97
+ };
98
+ this.readable = new node_stream_1.Readable({
99
+ read(desiredSize) {
100
+ if (ongoing) {
101
+ return;
102
+ }
103
+ ongoing = true;
104
+ return readImpl(desiredSize);
105
+ },
106
+ destroy(err, callback) {
107
+ if (underlyingSource?.cancel) {
108
+ try {
109
+ const res$ = underlyingSource.cancel(err);
110
+ if (res$?.then) {
111
+ return res$.then(() => {
112
+ callback(null);
113
+ }, err => {
114
+ callback(err);
115
+ });
116
+ }
117
+ }
118
+ catch (err) {
119
+ callback(err);
120
+ return;
121
+ }
122
+ }
123
+ callback(null);
124
+ },
125
+ });
126
+ }
127
+ }
128
+ cancel(reason) {
129
+ this.readable.destroy(reason);
130
+ // @ts-expect-error - we know it is void
131
+ return (0, node_events_1.once)(this.readable, 'close');
132
+ }
133
+ locked = false;
134
+ getReader(_options) {
135
+ const iterator = this.readable[Symbol.asyncIterator]();
136
+ this.locked = true;
137
+ const thisReadable = this.readable;
138
+ return {
139
+ read() {
140
+ return iterator.next();
141
+ },
142
+ releaseLock: () => {
143
+ if (iterator.return) {
144
+ const retResult$ = iterator.return();
145
+ if (retResult$.then) {
146
+ retResult$.then(() => {
147
+ this.locked = false;
148
+ });
149
+ return;
150
+ }
151
+ }
152
+ this.locked = false;
153
+ },
154
+ cancel: reason => {
155
+ if (iterator.return) {
156
+ const retResult$ = iterator.return(reason);
157
+ if (retResult$.then) {
158
+ return retResult$.then(() => {
159
+ this.locked = false;
160
+ });
161
+ }
162
+ }
163
+ this.locked = false;
164
+ return (0, utils_js_1.fakePromise)();
165
+ },
166
+ get closed() {
167
+ return Promise.race([
168
+ (0, node_events_1.once)(thisReadable, 'end'),
169
+ (0, node_events_1.once)(thisReadable, 'error').then(err => Promise.reject(err)),
170
+ ]);
171
+ },
172
+ };
173
+ }
174
+ [Symbol.asyncIterator]() {
175
+ const iterator = this.readable[Symbol.asyncIterator]();
176
+ return {
177
+ [Symbol.asyncIterator]() {
178
+ return this;
179
+ },
180
+ next: () => iterator.next(),
181
+ return: () => {
182
+ if (!this.readable.destroyed) {
183
+ this.readable.destroy();
184
+ }
185
+ return iterator.return?.() || (0, utils_js_1.fakePromise)({ done: true, value: undefined });
186
+ },
187
+ throw: (err) => {
188
+ if (!this.readable.destroyed) {
189
+ this.readable.destroy(err);
190
+ }
191
+ return iterator.throw?.(err) || (0, utils_js_1.fakePromise)({ done: true, value: undefined });
192
+ },
193
+ };
194
+ }
195
+ tee() {
196
+ throw new Error('Not implemented');
197
+ }
198
+ async pipeToWriter(writer) {
199
+ try {
200
+ for await (const chunk of this) {
201
+ await writer.write(chunk);
202
+ }
203
+ await writer.close();
204
+ }
205
+ catch (err) {
206
+ await writer.abort(err);
207
+ }
208
+ }
209
+ pipeTo(destination) {
210
+ if (isPonyfillWritableStream(destination)) {
211
+ return (0, promises_1.pipeline)(this.readable, destination.writable, {
212
+ end: true,
213
+ });
214
+ }
215
+ else {
216
+ const writer = destination.getWriter();
217
+ return this.pipeToWriter(writer);
218
+ }
219
+ }
220
+ pipeThrough({ writable, readable, }) {
221
+ this.pipeTo(writable).catch(err => {
222
+ this.readable.destroy(err);
223
+ });
224
+ if (isPonyfillReadableStream(readable)) {
225
+ readable.readable.once('error', err => this.readable.destroy(err));
226
+ readable.readable.once('finish', () => this.readable.push(null));
227
+ readable.readable.once('close', () => this.readable.push(null));
228
+ }
229
+ return readable;
230
+ }
231
+ static [Symbol.hasInstance](instance) {
232
+ return isReadableStream(instance);
233
+ }
234
+ static from(iterable) {
235
+ return new PonyfillReadableStream(node_stream_1.Readable.from(iterable));
236
+ }
237
+ [Symbol.toStringTag] = 'ReadableStream';
238
+ }
239
+ exports.PonyfillReadableStream = PonyfillReadableStream;
240
+ function isPonyfillReadableStream(obj) {
241
+ return obj?.readable != null;
242
+ }
243
+ function isPonyfillWritableStream(obj) {
244
+ return obj?.writable != null;
245
+ }
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PonyfillRequest = void 0;
4
+ const node_http_1 = require("node:http");
5
+ const node_https_1 = require("node:https");
6
+ const Body_js_1 = require("./Body.js");
7
+ const Headers_js_1 = require("./Headers.js");
8
+ const URL_js_1 = require("./URL.js");
9
+ function isRequest(input) {
10
+ return input[Symbol.toStringTag] === 'Request';
11
+ }
12
+ function isURL(obj) {
13
+ return obj?.href != null;
14
+ }
15
+ class PonyfillRequest extends Body_js_1.PonyfillBody {
16
+ constructor(input, options) {
17
+ let _url;
18
+ let _parsedUrl;
19
+ let bodyInit = null;
20
+ let requestInit;
21
+ if (typeof input === 'string') {
22
+ _url = input;
23
+ }
24
+ else if (isURL(input)) {
25
+ _parsedUrl = input;
26
+ }
27
+ else if (isRequest(input)) {
28
+ if (input._parsedUrl) {
29
+ _parsedUrl = input._parsedUrl;
30
+ }
31
+ else if (input._url) {
32
+ _url = input._url;
33
+ }
34
+ else {
35
+ _url = input.url;
36
+ }
37
+ bodyInit = input.body;
38
+ requestInit = input;
39
+ }
40
+ if (options != null) {
41
+ bodyInit = options.body || null;
42
+ requestInit = options;
43
+ }
44
+ super(bodyInit, requestInit);
45
+ this._url = _url;
46
+ this._parsedUrl = _parsedUrl;
47
+ this.cache = requestInit?.cache || 'default';
48
+ this.credentials = requestInit?.credentials || 'same-origin';
49
+ this.headers =
50
+ requestInit?.headers && (0, Headers_js_1.isHeadersLike)(requestInit.headers)
51
+ ? requestInit.headers
52
+ : new Headers_js_1.PonyfillHeaders(requestInit?.headers);
53
+ this.integrity = requestInit?.integrity || '';
54
+ this.keepalive = requestInit?.keepalive != null ? requestInit?.keepalive : false;
55
+ this.method = requestInit?.method?.toUpperCase() || 'GET';
56
+ this.mode = requestInit?.mode || 'cors';
57
+ this.redirect = requestInit?.redirect || 'follow';
58
+ this.referrer = requestInit?.referrer || 'about:client';
59
+ this.referrerPolicy = requestInit?.referrerPolicy || 'no-referrer';
60
+ this.headersSerializer = requestInit?.headersSerializer;
61
+ this.duplex = requestInit?.duplex || 'half';
62
+ this.destination = 'document';
63
+ this.priority = 'auto';
64
+ if (this.method !== 'GET' && this.method !== 'HEAD') {
65
+ this.handleContentLengthHeader(true);
66
+ }
67
+ if (requestInit?.agent != null) {
68
+ const protocol = _parsedUrl?.protocol || _url || this.url;
69
+ if (requestInit.agent === false) {
70
+ this.agent = false;
71
+ }
72
+ else if (protocol.startsWith('http:') && requestInit.agent instanceof node_http_1.Agent) {
73
+ this.agent = requestInit.agent;
74
+ }
75
+ else if (protocol.startsWith('https:') && requestInit.agent instanceof node_https_1.Agent) {
76
+ this.agent = requestInit.agent;
77
+ }
78
+ }
79
+ }
80
+ headersSerializer;
81
+ cache;
82
+ credentials;
83
+ destination;
84
+ headers;
85
+ integrity;
86
+ keepalive;
87
+ method;
88
+ mode;
89
+ priority;
90
+ redirect;
91
+ referrer;
92
+ referrerPolicy;
93
+ _url;
94
+ get signal() {
95
+ this._signal ||= new AbortController().signal;
96
+ return this._signal;
97
+ }
98
+ get url() {
99
+ if (this._url == null) {
100
+ if (this._parsedUrl) {
101
+ this._url = this._parsedUrl.toString();
102
+ }
103
+ else {
104
+ throw new TypeError('Invalid URL');
105
+ }
106
+ }
107
+ return this._url;
108
+ }
109
+ _parsedUrl;
110
+ get parsedUrl() {
111
+ if (this._parsedUrl == null) {
112
+ if (this._url != null) {
113
+ this._parsedUrl = new URL_js_1.PonyfillURL(this._url, 'http://localhost');
114
+ }
115
+ else {
116
+ throw new TypeError('Invalid URL');
117
+ }
118
+ }
119
+ return this._parsedUrl;
120
+ }
121
+ duplex;
122
+ agent;
123
+ clone() {
124
+ return this;
125
+ }
126
+ [Symbol.toStringTag] = 'Request';
127
+ }
128
+ exports.PonyfillRequest = PonyfillRequest;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PonyfillResponse = void 0;
4
+ const node_http_1 = require("node:http");
5
+ const Body_js_1 = require("./Body.js");
6
+ const Headers_js_1 = require("./Headers.js");
7
+ const JSON_CONTENT_TYPE = 'application/json; charset=utf-8';
8
+ class PonyfillResponse extends Body_js_1.PonyfillBody {
9
+ headers;
10
+ constructor(body, init) {
11
+ super(body || null, init);
12
+ this.headers =
13
+ init?.headers && (0, Headers_js_1.isHeadersLike)(init.headers)
14
+ ? init.headers
15
+ : new Headers_js_1.PonyfillHeaders(init?.headers);
16
+ this.status = init?.status || 200;
17
+ this.statusText = init?.statusText || node_http_1.STATUS_CODES[this.status] || 'OK';
18
+ this.url = init?.url || '';
19
+ this.redirected = init?.redirected || false;
20
+ this.type = init?.type || 'default';
21
+ this.handleContentLengthHeader();
22
+ }
23
+ get ok() {
24
+ return this.status >= 200 && this.status < 300;
25
+ }
26
+ status;
27
+ statusText;
28
+ url;
29
+ redirected;
30
+ type;
31
+ clone() {
32
+ return this;
33
+ }
34
+ static error() {
35
+ return new PonyfillResponse(null, {
36
+ status: 500,
37
+ statusText: 'Internal Server Error',
38
+ });
39
+ }
40
+ static redirect(url, status = 302) {
41
+ if (status < 300 || status > 399) {
42
+ throw new RangeError('Invalid status code');
43
+ }
44
+ return new PonyfillResponse(null, {
45
+ headers: {
46
+ location: url,
47
+ },
48
+ status,
49
+ });
50
+ }
51
+ static json(data, init) {
52
+ const bodyInit = JSON.stringify(data);
53
+ if (!init) {
54
+ init = {
55
+ headers: {
56
+ 'content-type': JSON_CONTENT_TYPE,
57
+ 'content-length': Buffer.byteLength(bodyInit).toString(),
58
+ },
59
+ };
60
+ }
61
+ else if (!init.headers) {
62
+ init.headers = {
63
+ 'content-type': JSON_CONTENT_TYPE,
64
+ 'content-length': Buffer.byteLength(bodyInit).toString(),
65
+ };
66
+ }
67
+ else if ((0, Headers_js_1.isHeadersLike)(init.headers)) {
68
+ if (!init.headers.has('content-type')) {
69
+ init.headers.set('content-type', JSON_CONTENT_TYPE);
70
+ }
71
+ if (!init.headers.has('content-length')) {
72
+ init.headers.set('content-length', Buffer.byteLength(bodyInit).toString());
73
+ }
74
+ }
75
+ else if (Array.isArray(init.headers)) {
76
+ let contentTypeExists = false;
77
+ let contentLengthExists = false;
78
+ for (const [key] of init.headers) {
79
+ if (contentLengthExists && contentTypeExists) {
80
+ break;
81
+ }
82
+ if (!contentTypeExists && key.toLowerCase() === 'content-type') {
83
+ contentTypeExists = true;
84
+ }
85
+ else if (!contentLengthExists && key.toLowerCase() === 'content-length') {
86
+ contentLengthExists = true;
87
+ }
88
+ }
89
+ if (!contentTypeExists) {
90
+ init.headers.push(['content-type', JSON_CONTENT_TYPE]);
91
+ }
92
+ if (!contentLengthExists) {
93
+ init.headers.push(['content-length', Buffer.byteLength(bodyInit).toString()]);
94
+ }
95
+ }
96
+ else if (typeof init.headers === 'object') {
97
+ if (init.headers?.['content-type'] == null) {
98
+ init.headers['content-type'] = JSON_CONTENT_TYPE;
99
+ }
100
+ if (init.headers?.['content-length'] == null) {
101
+ init.headers['content-length'] = Buffer.byteLength(bodyInit).toString();
102
+ }
103
+ }
104
+ return new PonyfillResponse(bodyInit, init);
105
+ }
106
+ [Symbol.toStringTag] = 'Response';
107
+ }
108
+ exports.PonyfillResponse = PonyfillResponse;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PonyfillTextDecoder = exports.PonyfillTextEncoder = void 0;
4
+ exports.PonyfillBtoa = PonyfillBtoa;
5
+ const node_buffer_1 = require("node:buffer");
6
+ const utils_js_1 = require("./utils.js");
7
+ class PonyfillTextEncoder {
8
+ encoding;
9
+ constructor(encoding = 'utf-8') {
10
+ this.encoding = encoding;
11
+ }
12
+ encode(input) {
13
+ return node_buffer_1.Buffer.from(input, this.encoding);
14
+ }
15
+ encodeInto(source, destination) {
16
+ const buffer = this.encode(source);
17
+ const copied = buffer.copy(destination);
18
+ return {
19
+ read: copied,
20
+ written: copied,
21
+ };
22
+ }
23
+ }
24
+ exports.PonyfillTextEncoder = PonyfillTextEncoder;
25
+ class PonyfillTextDecoder {
26
+ encoding;
27
+ fatal = false;
28
+ ignoreBOM = false;
29
+ constructor(encoding = 'utf-8', options) {
30
+ this.encoding = encoding;
31
+ if (options) {
32
+ this.fatal = options.fatal || false;
33
+ this.ignoreBOM = options.ignoreBOM || false;
34
+ }
35
+ }
36
+ decode(input) {
37
+ if (node_buffer_1.Buffer.isBuffer(input)) {
38
+ return input.toString(this.encoding);
39
+ }
40
+ if ((0, utils_js_1.isArrayBufferView)(input)) {
41
+ return node_buffer_1.Buffer.from(input.buffer, input.byteOffset, input.byteLength).toString(this.encoding);
42
+ }
43
+ return node_buffer_1.Buffer.from(input).toString(this.encoding);
44
+ }
45
+ }
46
+ exports.PonyfillTextDecoder = PonyfillTextDecoder;
47
+ function PonyfillBtoa(input) {
48
+ return node_buffer_1.Buffer.from(input, 'binary').toString('base64');
49
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PonyfillTextEncoderStream = exports.PonyfillTextDecoderStream = void 0;
4
+ const TextEncoderDecoder_js_1 = require("./TextEncoderDecoder.js");
5
+ const TransformStream_js_1 = require("./TransformStream.js");
6
+ class PonyfillTextDecoderStream extends TransformStream_js_1.PonyfillTransformStream {
7
+ textDecoder;
8
+ constructor(encoding, options) {
9
+ super({
10
+ transform: (chunk, controller) => controller.enqueue(this.textDecoder.decode(chunk, { stream: true })),
11
+ });
12
+ this.textDecoder = new TextEncoderDecoder_js_1.PonyfillTextDecoder(encoding, options);
13
+ }
14
+ get encoding() {
15
+ return this.textDecoder.encoding;
16
+ }
17
+ get fatal() {
18
+ return this.textDecoder.fatal;
19
+ }
20
+ get ignoreBOM() {
21
+ return this.textDecoder.ignoreBOM;
22
+ }
23
+ }
24
+ exports.PonyfillTextDecoderStream = PonyfillTextDecoderStream;
25
+ class PonyfillTextEncoderStream extends TransformStream_js_1.PonyfillTransformStream {
26
+ textEncoder;
27
+ constructor(encoding) {
28
+ super({
29
+ transform: (chunk, controller) => controller.enqueue(this.textEncoder.encode(chunk)),
30
+ });
31
+ this.textEncoder = new TextEncoderDecoder_js_1.PonyfillTextEncoder(encoding);
32
+ }
33
+ get encoding() {
34
+ return this.textEncoder.encoding;
35
+ }
36
+ encode(input) {
37
+ return this.textEncoder.encode(input);
38
+ }
39
+ }
40
+ exports.PonyfillTextEncoderStream = PonyfillTextEncoderStream;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PonyfillTransformStream = void 0;
4
+ const node_stream_1 = require("node:stream");
5
+ const ReadableStream_js_1 = require("./ReadableStream.js");
6
+ const utils_js_1 = require("./utils.js");
7
+ const WritableStream_js_1 = require("./WritableStream.js");
8
+ class PonyfillTransformStream {
9
+ transform;
10
+ writable;
11
+ readable;
12
+ constructor(transformer) {
13
+ if (transformer instanceof node_stream_1.Transform) {
14
+ this.transform = transformer;
15
+ }
16
+ else if (transformer) {
17
+ const controller = {
18
+ enqueue(chunk) {
19
+ transform.push(chunk);
20
+ },
21
+ error(reason) {
22
+ transform.destroy(reason);
23
+ },
24
+ terminate() {
25
+ (0, utils_js_1.endStream)(transform);
26
+ },
27
+ get desiredSize() {
28
+ return transform.writableLength;
29
+ },
30
+ };
31
+ const transform = new node_stream_1.Transform({
32
+ read() { },
33
+ write(chunk, _encoding, callback) {
34
+ try {
35
+ const result = transformer.transform?.(chunk, controller);
36
+ if (result instanceof Promise) {
37
+ result.then(() => {
38
+ callback();
39
+ }, err => {
40
+ callback(err);
41
+ });
42
+ }
43
+ else {
44
+ callback();
45
+ }
46
+ }
47
+ catch (err) {
48
+ callback(err);
49
+ }
50
+ },
51
+ final(callback) {
52
+ try {
53
+ const result = transformer.flush?.(controller);
54
+ if (result instanceof Promise) {
55
+ result.then(() => {
56
+ callback();
57
+ }, err => {
58
+ callback(err);
59
+ });
60
+ }
61
+ else {
62
+ callback();
63
+ }
64
+ }
65
+ catch (err) {
66
+ callback(err);
67
+ }
68
+ },
69
+ });
70
+ this.transform = transform;
71
+ }
72
+ else {
73
+ this.transform = new node_stream_1.Transform();
74
+ }
75
+ this.writable = new WritableStream_js_1.PonyfillWritableStream(this.transform);
76
+ this.readable = new ReadableStream_js_1.PonyfillReadableStream(this.transform);
77
+ }
78
+ }
79
+ exports.PonyfillTransformStream = PonyfillTransformStream;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PonyfillURL = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const node_buffer_1 = tslib_1.__importDefault(require("node:buffer"));
6
+ const node_crypto_1 = require("node:crypto");
7
+ const NativeURL = globalThis.URL;
8
+ class URL extends NativeURL {
9
+ // This part is only needed to handle `PonyfillBlob` objects
10
+ static blobRegistry = new Map();
11
+ static createObjectURL(blob) {
12
+ const blobUrl = `blob:whatwgnode:${(0, node_crypto_1.randomUUID)()}`;
13
+ this.blobRegistry.set(blobUrl, blob);
14
+ return blobUrl;
15
+ }
16
+ static revokeObjectURL(url) {
17
+ if (!this.blobRegistry.has(url)) {
18
+ NativeURL.revokeObjectURL(url);
19
+ }
20
+ else {
21
+ this.blobRegistry.delete(url);
22
+ }
23
+ }
24
+ static getBlobFromURL(url) {
25
+ return (this.blobRegistry.get(url) || node_buffer_1.default?.resolveObjectURL?.(url));
26
+ }
27
+ }
28
+ exports.PonyfillURL = URL;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PonyfillURLSearchParams = void 0;
4
+ exports.PonyfillURLSearchParams = globalThis.URLSearchParams;