@comapeo/map-server 1.0.0-pre.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 (179) hide show
  1. package/README.md +610 -0
  2. package/dist/context.d.ts +46 -0
  3. package/dist/context.d.ts.map +1 -0
  4. package/dist/context.js +181 -0
  5. package/dist/index.d.ts +25 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +112 -0
  8. package/dist/lib/constants.d.ts +7 -0
  9. package/dist/lib/constants.d.ts.map +1 -0
  10. package/dist/lib/constants.js +6 -0
  11. package/dist/lib/download-request.d.ts +17 -0
  12. package/dist/lib/download-request.d.ts.map +1 -0
  13. package/dist/lib/download-request.js +113 -0
  14. package/dist/lib/errors.d.ts +88 -0
  15. package/dist/lib/errors.d.ts.map +1 -0
  16. package/dist/lib/errors.js +158 -0
  17. package/dist/lib/event-stream-response.d.ts +17 -0
  18. package/dist/lib/event-stream-response.d.ts.map +1 -0
  19. package/dist/lib/event-stream-response.js +39 -0
  20. package/dist/lib/event-target.d.ts +9 -0
  21. package/dist/lib/event-target.d.ts.map +1 -0
  22. package/dist/lib/event-target.js +4 -0
  23. package/dist/lib/fetch-api.d.ts +3 -0
  24. package/dist/lib/fetch-api.d.ts.map +1 -0
  25. package/dist/lib/fetch-api.js +16 -0
  26. package/dist/lib/map-share.d.ts +52 -0
  27. package/dist/lib/map-share.d.ts.map +1 -0
  28. package/dist/lib/map-share.js +142 -0
  29. package/dist/lib/secret-stream-fetch.d.ts +7 -0
  30. package/dist/lib/secret-stream-fetch.d.ts.map +1 -0
  31. package/dist/lib/secret-stream-fetch.js +34 -0
  32. package/dist/lib/self-evicting-map.d.ts +16 -0
  33. package/dist/lib/self-evicting-map.d.ts.map +1 -0
  34. package/dist/lib/self-evicting-map.js +29 -0
  35. package/dist/lib/state-update-event.d.ts +8 -0
  36. package/dist/lib/state-update-event.d.ts.map +1 -0
  37. package/dist/lib/state-update-event.js +10 -0
  38. package/dist/lib/utils.d.ts +32 -0
  39. package/dist/lib/utils.d.ts.map +1 -0
  40. package/dist/lib/utils.js +96 -0
  41. package/dist/middlewares/localhost-only.d.ts +11 -0
  42. package/dist/middlewares/localhost-only.d.ts.map +1 -0
  43. package/dist/middlewares/localhost-only.js +10 -0
  44. package/dist/middlewares/parse-request.d.ts +11 -0
  45. package/dist/middlewares/parse-request.d.ts.map +1 -0
  46. package/dist/middlewares/parse-request.js +25 -0
  47. package/dist/routes/downloads.d.ts +15 -0
  48. package/dist/routes/downloads.d.ts.map +1 -0
  49. package/dist/routes/downloads.js +60 -0
  50. package/dist/routes/map-shares.d.ts +19 -0
  51. package/dist/routes/map-shares.d.ts.map +1 -0
  52. package/dist/routes/map-shares.js +192 -0
  53. package/dist/routes/maps.d.ts +6 -0
  54. package/dist/routes/maps.d.ts.map +1 -0
  55. package/dist/routes/maps.js +118 -0
  56. package/dist/routes/root.d.ts +6 -0
  57. package/dist/routes/root.d.ts.map +1 -0
  58. package/dist/routes/root.js +29 -0
  59. package/dist/types.d.ts +110 -0
  60. package/dist/types.d.ts.map +1 -0
  61. package/dist/types.js +96 -0
  62. package/node_modules/@envelop/instrumentation/LICENSE +21 -0
  63. package/node_modules/@envelop/instrumentation/README.md +30 -0
  64. package/node_modules/@envelop/instrumentation/cjs/index.js +5 -0
  65. package/node_modules/@envelop/instrumentation/cjs/instrumentation.js +89 -0
  66. package/node_modules/@envelop/instrumentation/cjs/package.json +1 -0
  67. package/node_modules/@envelop/instrumentation/esm/index.js +2 -0
  68. package/node_modules/@envelop/instrumentation/esm/instrumentation.js +82 -0
  69. package/node_modules/@envelop/instrumentation/package.json +57 -0
  70. package/node_modules/@envelop/instrumentation/typings/index.d.cts +1 -0
  71. package/node_modules/@envelop/instrumentation/typings/index.d.ts +1 -0
  72. package/node_modules/@envelop/instrumentation/typings/instrumentation.d.cts +44 -0
  73. package/node_modules/@envelop/instrumentation/typings/instrumentation.d.ts +44 -0
  74. package/node_modules/@whatwg-node/disposablestack/cjs/AsyncDisposableStack.js +73 -0
  75. package/node_modules/@whatwg-node/disposablestack/cjs/DisposableStack.js +62 -0
  76. package/node_modules/@whatwg-node/disposablestack/cjs/SupressedError.js +16 -0
  77. package/node_modules/@whatwg-node/disposablestack/cjs/index.js +11 -0
  78. package/node_modules/@whatwg-node/disposablestack/cjs/package.json +1 -0
  79. package/node_modules/@whatwg-node/disposablestack/cjs/symbols.js +20 -0
  80. package/node_modules/@whatwg-node/disposablestack/cjs/utils.js +11 -0
  81. package/node_modules/@whatwg-node/disposablestack/esm/AsyncDisposableStack.js +69 -0
  82. package/node_modules/@whatwg-node/disposablestack/esm/DisposableStack.js +58 -0
  83. package/node_modules/@whatwg-node/disposablestack/esm/SupressedError.js +12 -0
  84. package/node_modules/@whatwg-node/disposablestack/esm/index.js +7 -0
  85. package/node_modules/@whatwg-node/disposablestack/esm/symbols.js +16 -0
  86. package/node_modules/@whatwg-node/disposablestack/esm/utils.js +7 -0
  87. package/node_modules/@whatwg-node/disposablestack/package.json +44 -0
  88. package/node_modules/@whatwg-node/disposablestack/typings/AsyncDisposableStack.d.cts +15 -0
  89. package/node_modules/@whatwg-node/disposablestack/typings/AsyncDisposableStack.d.ts +15 -0
  90. package/node_modules/@whatwg-node/disposablestack/typings/DisposableStack.d.cts +14 -0
  91. package/node_modules/@whatwg-node/disposablestack/typings/DisposableStack.d.ts +14 -0
  92. package/node_modules/@whatwg-node/disposablestack/typings/SupressedError.d.cts +5 -0
  93. package/node_modules/@whatwg-node/disposablestack/typings/SupressedError.d.ts +5 -0
  94. package/node_modules/@whatwg-node/disposablestack/typings/index.d.cts +4 -0
  95. package/node_modules/@whatwg-node/disposablestack/typings/index.d.ts +4 -0
  96. package/node_modules/@whatwg-node/disposablestack/typings/symbols.d.cts +5 -0
  97. package/node_modules/@whatwg-node/disposablestack/typings/symbols.d.ts +5 -0
  98. package/node_modules/@whatwg-node/disposablestack/typings/utils.d.cts +2 -0
  99. package/node_modules/@whatwg-node/disposablestack/typings/utils.d.ts +2 -0
  100. package/node_modules/@whatwg-node/promise-helpers/cjs/index.js +270 -0
  101. package/node_modules/@whatwg-node/promise-helpers/cjs/package.json +1 -0
  102. package/node_modules/@whatwg-node/promise-helpers/esm/index.js +257 -0
  103. package/node_modules/@whatwg-node/promise-helpers/package.json +43 -0
  104. package/node_modules/@whatwg-node/promise-helpers/typings/index.d.cts +31 -0
  105. package/node_modules/@whatwg-node/promise-helpers/typings/index.d.ts +31 -0
  106. package/node_modules/@whatwg-node/server/README.md +590 -0
  107. package/node_modules/@whatwg-node/server/cjs/createServerAdapter.js +368 -0
  108. package/node_modules/@whatwg-node/server/cjs/index.js +17 -0
  109. package/node_modules/@whatwg-node/server/cjs/package.json +1 -0
  110. package/node_modules/@whatwg-node/server/cjs/plugins/types.js +0 -0
  111. package/node_modules/@whatwg-node/server/cjs/plugins/useContentEncoding.js +73 -0
  112. package/node_modules/@whatwg-node/server/cjs/plugins/useCors.js +124 -0
  113. package/node_modules/@whatwg-node/server/cjs/plugins/useErrorHandling.js +52 -0
  114. package/node_modules/@whatwg-node/server/cjs/types.js +0 -0
  115. package/node_modules/@whatwg-node/server/cjs/utils.js +599 -0
  116. package/node_modules/@whatwg-node/server/cjs/uwebsockets.js +241 -0
  117. package/node_modules/@whatwg-node/server/esm/createServerAdapter.js +365 -0
  118. package/node_modules/@whatwg-node/server/esm/index.js +11 -0
  119. package/node_modules/@whatwg-node/server/esm/plugins/types.js +0 -0
  120. package/node_modules/@whatwg-node/server/esm/plugins/useContentEncoding.js +70 -0
  121. package/node_modules/@whatwg-node/server/esm/plugins/useCors.js +120 -0
  122. package/node_modules/@whatwg-node/server/esm/plugins/useErrorHandling.js +46 -0
  123. package/node_modules/@whatwg-node/server/esm/types.js +0 -0
  124. package/node_modules/@whatwg-node/server/esm/utils.js +588 -0
  125. package/node_modules/@whatwg-node/server/esm/uwebsockets.js +234 -0
  126. package/node_modules/@whatwg-node/server/package.json +46 -0
  127. package/node_modules/@whatwg-node/server/typings/createServerAdapter.d.cts +19 -0
  128. package/node_modules/@whatwg-node/server/typings/createServerAdapter.d.ts +19 -0
  129. package/node_modules/@whatwg-node/server/typings/index.d.cts +11 -0
  130. package/node_modules/@whatwg-node/server/typings/index.d.ts +11 -0
  131. package/node_modules/@whatwg-node/server/typings/plugins/types.d.cts +76 -0
  132. package/node_modules/@whatwg-node/server/typings/plugins/types.d.ts +76 -0
  133. package/node_modules/@whatwg-node/server/typings/plugins/useContentEncoding.d.cts +2 -0
  134. package/node_modules/@whatwg-node/server/typings/plugins/useContentEncoding.d.ts +2 -0
  135. package/node_modules/@whatwg-node/server/typings/plugins/useCors.d.cts +14 -0
  136. package/node_modules/@whatwg-node/server/typings/plugins/useCors.d.ts +14 -0
  137. package/node_modules/@whatwg-node/server/typings/plugins/useErrorHandling.d.cts +13 -0
  138. package/node_modules/@whatwg-node/server/typings/plugins/useErrorHandling.d.ts +13 -0
  139. package/node_modules/@whatwg-node/server/typings/types.d.cts +100 -0
  140. package/node_modules/@whatwg-node/server/typings/types.d.ts +100 -0
  141. package/node_modules/@whatwg-node/server/typings/utils.d.cts +42 -0
  142. package/node_modules/@whatwg-node/server/typings/utils.d.ts +42 -0
  143. package/node_modules/@whatwg-node/server/typings/uwebsockets.d.cts +32 -0
  144. package/node_modules/@whatwg-node/server/typings/uwebsockets.d.ts +32 -0
  145. package/node_modules/tslib/CopyrightNotice.txt +15 -0
  146. package/node_modules/tslib/LICENSE.txt +12 -0
  147. package/node_modules/tslib/README.md +164 -0
  148. package/node_modules/tslib/SECURITY.md +41 -0
  149. package/node_modules/tslib/modules/index.d.ts +38 -0
  150. package/node_modules/tslib/modules/index.js +70 -0
  151. package/node_modules/tslib/modules/package.json +3 -0
  152. package/node_modules/tslib/package.json +47 -0
  153. package/node_modules/tslib/tslib.d.ts +460 -0
  154. package/node_modules/tslib/tslib.es6.html +1 -0
  155. package/node_modules/tslib/tslib.es6.js +402 -0
  156. package/node_modules/tslib/tslib.es6.mjs +401 -0
  157. package/node_modules/tslib/tslib.html +1 -0
  158. package/node_modules/tslib/tslib.js +484 -0
  159. package/package.json +87 -0
  160. package/src/context.ts +203 -0
  161. package/src/index.ts +193 -0
  162. package/src/lib/constants.ts +6 -0
  163. package/src/lib/download-request.ts +142 -0
  164. package/src/lib/errors.ts +187 -0
  165. package/src/lib/event-stream-response.ts +57 -0
  166. package/src/lib/event-target.ts +11 -0
  167. package/src/lib/fetch-api.ts +18 -0
  168. package/src/lib/map-share.ts +185 -0
  169. package/src/lib/secret-stream-fetch.ts +42 -0
  170. package/src/lib/self-evicting-map.ts +35 -0
  171. package/src/lib/state-update-event.ts +14 -0
  172. package/src/lib/utils.ts +110 -0
  173. package/src/middlewares/localhost-only.ts +16 -0
  174. package/src/middlewares/parse-request.ts +34 -0
  175. package/src/routes/downloads.ts +92 -0
  176. package/src/routes/map-shares.ts +246 -0
  177. package/src/routes/maps.ts +146 -0
  178. package/src/routes/root.ts +37 -0
  179. package/src/types.ts +152 -0
@@ -0,0 +1,100 @@
1
+ import type { RequestListener } from 'node:http';
2
+ import type { MaybePromise, MaybePromiseLike } from '@whatwg-node/promise-helpers';
3
+ import type { NodeRequest, NodeResponse } from './utils.js';
4
+ import { UWSHandler, UWSRequest, UWSResponse } from './uwebsockets.js';
5
+ export interface FetchEvent extends Event {
6
+ waitUntil(f: MaybePromise<void>): void;
7
+ request: Request;
8
+ respondWith(r: MaybePromiseLike<Response>): void;
9
+ }
10
+ export interface ServerAdapterBaseObject<TServerContext, THandleRequest extends ServerAdapterRequestHandler<TServerContext> = ServerAdapterRequestHandler<TServerContext>> {
11
+ /**
12
+ * An async function that takes `Request` and the server context and returns a `Response`.
13
+ * If you use `requestListener`, the server context is `{ req: IncomingMessage, res: ServerResponse }`.
14
+ */
15
+ handle: THandleRequest;
16
+ }
17
+ export interface ServerAdapterObject<TServerContext> extends EventListenerObject, AsyncDisposable {
18
+ /**
19
+ * A basic request listener that takes a `Request` with the server context and returns a `Response`.
20
+ */
21
+ handleRequest: (request: Request, ctx: TServerContext & Partial<ServerAdapterInitialContext>) => MaybePromise<Response>;
22
+ /**
23
+ * WHATWG Fetch spec compliant `fetch` function that can be used for testing purposes.
24
+ */
25
+ fetch(request: Request, ctx: TServerContext): MaybePromise<Response>;
26
+ fetch(request: Request, ...ctx: Partial<TServerContext>[]): MaybePromise<Response>;
27
+ fetch(urlStr: string, ctx: TServerContext): MaybePromise<Response>;
28
+ fetch(urlStr: string, ...ctx: Partial<TServerContext>[]): MaybePromise<Response>;
29
+ fetch(urlStr: string, init: RequestInit, ctx: TServerContext): MaybePromise<Response>;
30
+ fetch(urlStr: string, init: RequestInit, ...ctx: Partial<TServerContext>[]): MaybePromise<Response>;
31
+ fetch(url: URL, ctx: TServerContext): MaybePromise<Response>;
32
+ fetch(url: URL, ...ctx: Partial<TServerContext>[]): MaybePromise<Response>;
33
+ fetch(url: URL, init: RequestInit, ctx: TServerContext): MaybePromise<Response>;
34
+ fetch(url: URL, init: RequestInit, ...ctx: Partial<TServerContext>[]): MaybePromise<Response>;
35
+ /**
36
+ * This function takes Node's request object and returns a WHATWG Fetch spec compliant `Response` object.
37
+ *
38
+ * @deprecated Use `handleNodeRequestAndResponse` instead.
39
+ **/
40
+ handleNodeRequest(nodeRequest: NodeRequest, ...ctx: Partial<TServerContext & ServerAdapterInitialContext>[]): MaybePromise<Response>;
41
+ /**
42
+ * This function takes Node's request and response objects and returns a WHATWG Fetch spec compliant `Response` object.
43
+ */
44
+ handleNodeRequestAndResponse(nodeRequest: NodeRequest, nodeResponseOrContainer: {
45
+ raw: NodeResponse;
46
+ } | NodeResponse, ...ctx: Partial<TServerContext & ServerAdapterInitialContext>[]): MaybePromise<Response>;
47
+ /**
48
+ * A request listener function that can be used with any Node server variation.
49
+ */
50
+ requestListener: RequestListener;
51
+ handleUWS: UWSHandler;
52
+ handle(req: NodeRequest, res: NodeResponse, ...ctx: Partial<TServerContext & ServerAdapterInitialContext>[]): Promise<void>;
53
+ handle(requestLike: RequestLike, ...ctx: Partial<TServerContext & ServerAdapterInitialContext>[]): MaybePromise<Response>;
54
+ handle(request: Request, ...ctx: Partial<TServerContext & ServerAdapterInitialContext>[]): MaybePromise<Response>;
55
+ handle(request: Request, ...ctx: Partial<TServerContext>[]): MaybePromise<Response>;
56
+ handle(fetchEvent: FetchEvent & Partial<TServerContext & ServerAdapterInitialContext>, ...ctx: Partial<TServerContext>[]): void;
57
+ handle(res: UWSResponse, req: UWSRequest, ...ctx: Partial<TServerContext & ServerAdapterInitialContext>[]): Promise<void>;
58
+ handle(container: {
59
+ request: Request;
60
+ } & Partial<TServerContext & ServerAdapterInitialContext>, ...ctx: Partial<TServerContext & ServerAdapterInitialContext>[]): MaybePromise<Response>;
61
+ disposableStack: AsyncDisposableStack;
62
+ dispose(): Promise<void> | void;
63
+ /**
64
+ * Register a promise that should be waited in the background for before the server process is exited.
65
+ *
66
+ * This also avoids unhandled promise rejections, which would otherwise cause the process to exit on some environment like Node.
67
+ * @param promise The promise to wait for
68
+ * @returns
69
+ */
70
+ waitUntil: WaitUntilFn;
71
+ }
72
+ export interface RequestLike {
73
+ url: string;
74
+ method: string;
75
+ headers: HeadersLike;
76
+ body?: AsyncIterable<Uint8Array> | null;
77
+ }
78
+ export interface HeadersLike extends Iterable<[string, string]> {
79
+ get(name: string): string | null | undefined;
80
+ set(name: string, value: string): void;
81
+ has(name: string): boolean;
82
+ }
83
+ export type ServerAdapter<TServerContext, TBaseObject extends ServerAdapterBaseObject<TServerContext>> = TBaseObject & ServerAdapterObject<TServerContext>['handle'] & ServerAdapterObject<TServerContext>;
84
+ export type ServerAdapterRequestHandler<TServerContext> = (request: Request, ctx: TServerContext & ServerAdapterInitialContext) => MaybePromise<Response>;
85
+ export type ServerAdapterNodeContext = {
86
+ req: NodeRequest;
87
+ res: NodeResponse;
88
+ };
89
+ export type WaitUntilFn = (promise: Promise<void> | void) => void;
90
+ export type FetchAPI = ReturnType<typeof import('@whatwg-node/fetch').createFetch>;
91
+ export type ServerAdapterInitialContext = {
92
+ /**
93
+ * Register a promise that should be waited in the background for before the server process is exited.
94
+ *
95
+ * This also avoids unhandled promise rejections, which would otherwise cause the process to exit on some environment like Node.
96
+ * @param promise The promise to wait for
97
+ * @returns
98
+ */
99
+ waitUntil: WaitUntilFn;
100
+ };
@@ -0,0 +1,42 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ import type { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
3
+ import type { Socket } from 'node:net';
4
+ import type { Readable } from 'node:stream';
5
+ import { createDeferredPromise, isPromise, MaybePromise } from '@whatwg-node/promise-helpers';
6
+ import type { FetchAPI, FetchEvent, WaitUntilFn } from './types.cjs';
7
+ export { isPromise, createDeferredPromise };
8
+ export declare function isAsyncIterable(body: any): body is AsyncIterable<any>;
9
+ export interface NodeRequest {
10
+ protocol?: string | undefined;
11
+ hostname?: string | undefined;
12
+ body?: any | undefined;
13
+ url?: string | undefined;
14
+ originalUrl?: string | undefined;
15
+ method?: string | undefined;
16
+ headers?: any | undefined;
17
+ req?: IncomingMessage | Http2ServerRequest | undefined;
18
+ raw?: IncomingMessage | Http2ServerRequest | undefined;
19
+ socket?: Socket | undefined;
20
+ query?: any | undefined;
21
+ once?(event: string, listener: (...args: any[]) => void): void;
22
+ aborted?: boolean | undefined;
23
+ }
24
+ export type NodeResponse = ServerResponse | Http2ServerResponse;
25
+ export declare function normalizeNodeRequest(nodeRequest: NodeRequest, fetchAPI: FetchAPI, nodeResponse?: NodeResponse, __useCustomAbortCtrl?: boolean): Request;
26
+ export declare function isReadable(stream: any): stream is Readable;
27
+ export declare function isNodeRequest(request: any): request is NodeRequest;
28
+ export declare function isServerResponse(stream: any): stream is NodeResponse;
29
+ export declare function isReadableStream(stream: any): stream is ReadableStream;
30
+ export declare function isFetchEvent(event: any): event is FetchEvent;
31
+ export declare function sendNodeResponse(fetchResponse: Response, serverResponse: NodeResponse, nodeRequest: NodeRequest, __useSingleWriteHead: boolean): MaybePromise<void>;
32
+ export declare function isRequestInit(val: unknown): val is RequestInit;
33
+ export declare function completeAssign(...args: any[]): any;
34
+ export { iterateAsyncVoid } from '@whatwg-node/promise-helpers';
35
+ export declare function handleErrorFromRequestHandler(error: any, ResponseCtor: typeof Response): Response;
36
+ export declare function isolateObject<TIsolatedObject extends object>(originalCtx: TIsolatedObject, waitUntilFn?: WaitUntilFn): TIsolatedObject;
37
+ export declare function handleAbortSignalAndPromiseResponse(response$: MaybePromise<Response>, abortSignal: AbortSignal): MaybePromise<Response>;
38
+ export declare const decompressedResponseMap: WeakMap<Response, Response>;
39
+ export declare function getSupportedEncodings(fetchAPI: FetchAPI): CompressionFormat[];
40
+ export declare function handleResponseDecompression(response: Response, fetchAPI: FetchAPI): Response;
41
+ export declare function ensureDisposableStackRegisteredForTerminateEvents(disposableStack: AsyncDisposableStack): void;
42
+ export declare function createCustomAbortControllerSignal(): AbortController;
@@ -0,0 +1,42 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ import type { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
3
+ import type { Socket } from 'node:net';
4
+ import type { Readable } from 'node:stream';
5
+ import { createDeferredPromise, isPromise, MaybePromise } from '@whatwg-node/promise-helpers';
6
+ import type { FetchAPI, FetchEvent, WaitUntilFn } from './types.js';
7
+ export { isPromise, createDeferredPromise };
8
+ export declare function isAsyncIterable(body: any): body is AsyncIterable<any>;
9
+ export interface NodeRequest {
10
+ protocol?: string | undefined;
11
+ hostname?: string | undefined;
12
+ body?: any | undefined;
13
+ url?: string | undefined;
14
+ originalUrl?: string | undefined;
15
+ method?: string | undefined;
16
+ headers?: any | undefined;
17
+ req?: IncomingMessage | Http2ServerRequest | undefined;
18
+ raw?: IncomingMessage | Http2ServerRequest | undefined;
19
+ socket?: Socket | undefined;
20
+ query?: any | undefined;
21
+ once?(event: string, listener: (...args: any[]) => void): void;
22
+ aborted?: boolean | undefined;
23
+ }
24
+ export type NodeResponse = ServerResponse | Http2ServerResponse;
25
+ export declare function normalizeNodeRequest(nodeRequest: NodeRequest, fetchAPI: FetchAPI, nodeResponse?: NodeResponse, __useCustomAbortCtrl?: boolean): Request;
26
+ export declare function isReadable(stream: any): stream is Readable;
27
+ export declare function isNodeRequest(request: any): request is NodeRequest;
28
+ export declare function isServerResponse(stream: any): stream is NodeResponse;
29
+ export declare function isReadableStream(stream: any): stream is ReadableStream;
30
+ export declare function isFetchEvent(event: any): event is FetchEvent;
31
+ export declare function sendNodeResponse(fetchResponse: Response, serverResponse: NodeResponse, nodeRequest: NodeRequest, __useSingleWriteHead: boolean): MaybePromise<void>;
32
+ export declare function isRequestInit(val: unknown): val is RequestInit;
33
+ export declare function completeAssign(...args: any[]): any;
34
+ export { iterateAsyncVoid } from '@whatwg-node/promise-helpers';
35
+ export declare function handleErrorFromRequestHandler(error: any, ResponseCtor: typeof Response): Response;
36
+ export declare function isolateObject<TIsolatedObject extends object>(originalCtx: TIsolatedObject, waitUntilFn?: WaitUntilFn): TIsolatedObject;
37
+ export declare function handleAbortSignalAndPromiseResponse(response$: MaybePromise<Response>, abortSignal: AbortSignal): MaybePromise<Response>;
38
+ export declare const decompressedResponseMap: WeakMap<Response, Response>;
39
+ export declare function getSupportedEncodings(fetchAPI: FetchAPI): CompressionFormat[];
40
+ export declare function handleResponseDecompression(response: Response, fetchAPI: FetchAPI): Response;
41
+ export declare function ensureDisposableStackRegisteredForTerminateEvents(disposableStack: AsyncDisposableStack): void;
42
+ export declare function createCustomAbortControllerSignal(): AbortController;
@@ -0,0 +1,32 @@
1
+ import { fakePromise } from '@whatwg-node/promise-helpers';
2
+ import type { FetchAPI } from './types.cjs';
3
+ export interface UWSRequest {
4
+ getMethod(): string;
5
+ forEach(callback: (key: string, value: string) => void): void;
6
+ getUrl(): string;
7
+ getQuery(): string;
8
+ getHeader(key: string): string | undefined;
9
+ setYield(y: boolean): void;
10
+ }
11
+ export interface UWSResponse {
12
+ onData(callback: (chunk: ArrayBuffer, isLast: boolean) => void): void;
13
+ onAborted(callback: () => void): void;
14
+ writeStatus(status: string): void;
15
+ writeHeader(key: string, value: string): void;
16
+ end(body?: any): void;
17
+ close(): void;
18
+ write(body: any): boolean;
19
+ cork(callback: () => void): void;
20
+ }
21
+ export type UWSHandler = (res: UWSResponse, req: UWSRequest) => void | Promise<void>;
22
+ export declare function isUWSResponse(res: any): res is UWSResponse;
23
+ interface GetRequestFromUWSOpts {
24
+ req: UWSRequest;
25
+ res: UWSResponse;
26
+ fetchAPI: FetchAPI;
27
+ controller: AbortController;
28
+ }
29
+ export declare function getRequestFromUWSRequest({ req, res, fetchAPI, controller, }: GetRequestFromUWSOpts): Request;
30
+ export declare function createWritableFromUWS(uwsResponse: UWSResponse, fetchAPI: FetchAPI): WritableStream<any>;
31
+ export declare function sendResponseToUwsOpts(uwsResponse: UWSResponse, fetchResponse: Response, controller: AbortController, fetchAPI: FetchAPI): Promise<void> | undefined;
32
+ export { fakePromise };
@@ -0,0 +1,32 @@
1
+ import { fakePromise } from '@whatwg-node/promise-helpers';
2
+ import type { FetchAPI } from './types.js';
3
+ export interface UWSRequest {
4
+ getMethod(): string;
5
+ forEach(callback: (key: string, value: string) => void): void;
6
+ getUrl(): string;
7
+ getQuery(): string;
8
+ getHeader(key: string): string | undefined;
9
+ setYield(y: boolean): void;
10
+ }
11
+ export interface UWSResponse {
12
+ onData(callback: (chunk: ArrayBuffer, isLast: boolean) => void): void;
13
+ onAborted(callback: () => void): void;
14
+ writeStatus(status: string): void;
15
+ writeHeader(key: string, value: string): void;
16
+ end(body?: any): void;
17
+ close(): void;
18
+ write(body: any): boolean;
19
+ cork(callback: () => void): void;
20
+ }
21
+ export type UWSHandler = (res: UWSResponse, req: UWSRequest) => void | Promise<void>;
22
+ export declare function isUWSResponse(res: any): res is UWSResponse;
23
+ interface GetRequestFromUWSOpts {
24
+ req: UWSRequest;
25
+ res: UWSResponse;
26
+ fetchAPI: FetchAPI;
27
+ controller: AbortController;
28
+ }
29
+ export declare function getRequestFromUWSRequest({ req, res, fetchAPI, controller, }: GetRequestFromUWSOpts): Request;
30
+ export declare function createWritableFromUWS(uwsResponse: UWSResponse, fetchAPI: FetchAPI): WritableStream<any>;
31
+ export declare function sendResponseToUwsOpts(uwsResponse: UWSResponse, fetchResponse: Response, controller: AbortController, fetchAPI: FetchAPI): Promise<void> | undefined;
32
+ export { fakePromise };
@@ -0,0 +1,15 @@
1
+ /******************************************************************************
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
+ ***************************************************************************** */
15
+
@@ -0,0 +1,12 @@
1
+ Copyright (c) Microsoft Corporation.
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any
4
+ purpose with or without fee is hereby granted.
5
+
6
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
7
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
8
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
9
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
10
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
11
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
12
+ PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,164 @@
1
+ # tslib
2
+
3
+ This is a runtime library for [TypeScript](https://www.typescriptlang.org/) that contains all of the TypeScript helper functions.
4
+
5
+ This library is primarily used by the `--importHelpers` flag in TypeScript.
6
+ When using `--importHelpers`, a module that uses helper functions like `__extends` and `__assign` in the following emitted file:
7
+
8
+ ```ts
9
+ var __assign = (this && this.__assign) || Object.assign || function(t) {
10
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
11
+ s = arguments[i];
12
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
13
+ t[p] = s[p];
14
+ }
15
+ return t;
16
+ };
17
+ exports.x = {};
18
+ exports.y = __assign({}, exports.x);
19
+
20
+ ```
21
+
22
+ will instead be emitted as something like the following:
23
+
24
+ ```ts
25
+ var tslib_1 = require("tslib");
26
+ exports.x = {};
27
+ exports.y = tslib_1.__assign({}, exports.x);
28
+ ```
29
+
30
+ Because this can avoid duplicate declarations of things like `__extends`, `__assign`, etc., this means delivering users smaller files on average, as well as less runtime overhead.
31
+ For optimized bundles with TypeScript, you should absolutely consider using `tslib` and `--importHelpers`.
32
+
33
+ # Installing
34
+
35
+ For the latest stable version, run:
36
+
37
+ ## npm
38
+
39
+ ```sh
40
+ # TypeScript 3.9.2 or later
41
+ npm install tslib
42
+
43
+ # TypeScript 3.8.4 or earlier
44
+ npm install tslib@^1
45
+
46
+ # TypeScript 2.3.2 or earlier
47
+ npm install tslib@1.6.1
48
+ ```
49
+
50
+ ## yarn
51
+
52
+ ```sh
53
+ # TypeScript 3.9.2 or later
54
+ yarn add tslib
55
+
56
+ # TypeScript 3.8.4 or earlier
57
+ yarn add tslib@^1
58
+
59
+ # TypeScript 2.3.2 or earlier
60
+ yarn add tslib@1.6.1
61
+ ```
62
+
63
+ ## bower
64
+
65
+ ```sh
66
+ # TypeScript 3.9.2 or later
67
+ bower install tslib
68
+
69
+ # TypeScript 3.8.4 or earlier
70
+ bower install tslib@^1
71
+
72
+ # TypeScript 2.3.2 or earlier
73
+ bower install tslib@1.6.1
74
+ ```
75
+
76
+ ## JSPM
77
+
78
+ ```sh
79
+ # TypeScript 3.9.2 or later
80
+ jspm install tslib
81
+
82
+ # TypeScript 3.8.4 or earlier
83
+ jspm install tslib@^1
84
+
85
+ # TypeScript 2.3.2 or earlier
86
+ jspm install tslib@1.6.1
87
+ ```
88
+
89
+ # Usage
90
+
91
+ Set the `importHelpers` compiler option on the command line:
92
+
93
+ ```
94
+ tsc --importHelpers file.ts
95
+ ```
96
+
97
+ or in your tsconfig.json:
98
+
99
+ ```json
100
+ {
101
+ "compilerOptions": {
102
+ "importHelpers": true
103
+ }
104
+ }
105
+ ```
106
+
107
+ #### For bower and JSPM users
108
+
109
+ You will need to add a `paths` mapping for `tslib`, e.g. For Bower users:
110
+
111
+ ```json
112
+ {
113
+ "compilerOptions": {
114
+ "module": "amd",
115
+ "importHelpers": true,
116
+ "baseUrl": "./",
117
+ "paths": {
118
+ "tslib" : ["bower_components/tslib/tslib.d.ts"]
119
+ }
120
+ }
121
+ }
122
+ ```
123
+
124
+ For JSPM users:
125
+
126
+ ```json
127
+ {
128
+ "compilerOptions": {
129
+ "module": "system",
130
+ "importHelpers": true,
131
+ "baseUrl": "./",
132
+ "paths": {
133
+ "tslib" : ["jspm_packages/npm/tslib@2.x.y/tslib.d.ts"]
134
+ }
135
+ }
136
+ }
137
+ ```
138
+
139
+ ## Deployment
140
+
141
+ - Choose your new version number
142
+ - Set it in `package.json` and `bower.json`
143
+ - Create a tag: `git tag [version]`
144
+ - Push the tag: `git push --tags`
145
+ - Create a [release in GitHub](https://github.com/microsoft/tslib/releases)
146
+ - Run the [publish to npm](https://github.com/microsoft/tslib/actions?query=workflow%3A%22Publish+to+NPM%22) workflow
147
+
148
+ Done.
149
+
150
+ # Contribute
151
+
152
+ There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md) to TypeScript.
153
+
154
+ * [Submit bugs](https://github.com/Microsoft/TypeScript/issues) and help us verify fixes as they are checked in.
155
+ * Review the [source code changes](https://github.com/Microsoft/TypeScript/pulls).
156
+ * Engage with other TypeScript users and developers on [StackOverflow](http://stackoverflow.com/questions/tagged/typescript).
157
+ * Join the [#typescript](http://twitter.com/#!/search/realtime/%23typescript) discussion on Twitter.
158
+ * [Contribute bug fixes](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md).
159
+
160
+ # Documentation
161
+
162
+ * [Quick tutorial](http://www.typescriptlang.org/Tutorial)
163
+ * [Programming handbook](http://www.typescriptlang.org/Handbook)
164
+ * [Homepage](http://www.typescriptlang.org/)
@@ -0,0 +1,41 @@
1
+ <!-- BEGIN MICROSOFT SECURITY.MD V0.0.7 BLOCK -->
2
+
3
+ ## Security
4
+
5
+ Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
6
+
7
+ If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
8
+
9
+ ## Reporting Security Issues
10
+
11
+ **Please do not report security vulnerabilities through public GitHub issues.**
12
+
13
+ Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
14
+
15
+ If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
16
+
17
+ You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
18
+
19
+ Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
20
+
21
+ * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22
+ * Full paths of source file(s) related to the manifestation of the issue
23
+ * The location of the affected source code (tag/branch/commit or direct URL)
24
+ * Any special configuration required to reproduce the issue
25
+ * Step-by-step instructions to reproduce the issue
26
+ * Proof-of-concept or exploit code (if possible)
27
+ * Impact of the issue, including how an attacker might exploit the issue
28
+
29
+ This information will help us triage your report more quickly.
30
+
31
+ If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
32
+
33
+ ## Preferred Languages
34
+
35
+ We prefer all communications to be in English.
36
+
37
+ ## Policy
38
+
39
+ Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
40
+
41
+ <!-- END MICROSOFT SECURITY.MD BLOCK -->
@@ -0,0 +1,38 @@
1
+ // Note: named reexports are used instead of `export *` because
2
+ // TypeScript itself doesn't resolve the `export *` when checking
3
+ // if a particular helper exists.
4
+ export {
5
+ __extends,
6
+ __assign,
7
+ __rest,
8
+ __decorate,
9
+ __param,
10
+ __esDecorate,
11
+ __runInitializers,
12
+ __propKey,
13
+ __setFunctionName,
14
+ __metadata,
15
+ __awaiter,
16
+ __generator,
17
+ __exportStar,
18
+ __values,
19
+ __read,
20
+ __spread,
21
+ __spreadArrays,
22
+ __spreadArray,
23
+ __await,
24
+ __asyncGenerator,
25
+ __asyncDelegator,
26
+ __asyncValues,
27
+ __makeTemplateObject,
28
+ __importStar,
29
+ __importDefault,
30
+ __classPrivateFieldGet,
31
+ __classPrivateFieldSet,
32
+ __classPrivateFieldIn,
33
+ __createBinding,
34
+ __addDisposableResource,
35
+ __disposeResources,
36
+ __rewriteRelativeImportExtension,
37
+ } from '../tslib.js';
38
+ export * as default from '../tslib.js';
@@ -0,0 +1,70 @@
1
+ import tslib from '../tslib.js';
2
+ const {
3
+ __extends,
4
+ __assign,
5
+ __rest,
6
+ __decorate,
7
+ __param,
8
+ __esDecorate,
9
+ __runInitializers,
10
+ __propKey,
11
+ __setFunctionName,
12
+ __metadata,
13
+ __awaiter,
14
+ __generator,
15
+ __exportStar,
16
+ __createBinding,
17
+ __values,
18
+ __read,
19
+ __spread,
20
+ __spreadArrays,
21
+ __spreadArray,
22
+ __await,
23
+ __asyncGenerator,
24
+ __asyncDelegator,
25
+ __asyncValues,
26
+ __makeTemplateObject,
27
+ __importStar,
28
+ __importDefault,
29
+ __classPrivateFieldGet,
30
+ __classPrivateFieldSet,
31
+ __classPrivateFieldIn,
32
+ __addDisposableResource,
33
+ __disposeResources,
34
+ __rewriteRelativeImportExtension,
35
+ } = tslib;
36
+ export {
37
+ __extends,
38
+ __assign,
39
+ __rest,
40
+ __decorate,
41
+ __param,
42
+ __esDecorate,
43
+ __runInitializers,
44
+ __propKey,
45
+ __setFunctionName,
46
+ __metadata,
47
+ __awaiter,
48
+ __generator,
49
+ __exportStar,
50
+ __createBinding,
51
+ __values,
52
+ __read,
53
+ __spread,
54
+ __spreadArrays,
55
+ __spreadArray,
56
+ __await,
57
+ __asyncGenerator,
58
+ __asyncDelegator,
59
+ __asyncValues,
60
+ __makeTemplateObject,
61
+ __importStar,
62
+ __importDefault,
63
+ __classPrivateFieldGet,
64
+ __classPrivateFieldSet,
65
+ __classPrivateFieldIn,
66
+ __addDisposableResource,
67
+ __disposeResources,
68
+ __rewriteRelativeImportExtension,
69
+ };
70
+ export default tslib;
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "tslib",
3
+ "author": "Microsoft Corp.",
4
+ "homepage": "https://www.typescriptlang.org/",
5
+ "version": "2.8.1",
6
+ "license": "0BSD",
7
+ "description": "Runtime library for TypeScript helper functions",
8
+ "keywords": [
9
+ "TypeScript",
10
+ "Microsoft",
11
+ "compiler",
12
+ "language",
13
+ "javascript",
14
+ "tslib",
15
+ "runtime"
16
+ ],
17
+ "bugs": {
18
+ "url": "https://github.com/Microsoft/TypeScript/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/Microsoft/tslib.git"
23
+ },
24
+ "main": "tslib.js",
25
+ "module": "tslib.es6.js",
26
+ "jsnext:main": "tslib.es6.js",
27
+ "typings": "tslib.d.ts",
28
+ "sideEffects": false,
29
+ "exports": {
30
+ ".": {
31
+ "module": {
32
+ "types": "./modules/index.d.ts",
33
+ "default": "./tslib.es6.mjs"
34
+ },
35
+ "import": {
36
+ "node": "./modules/index.js",
37
+ "default": {
38
+ "types": "./modules/index.d.ts",
39
+ "default": "./tslib.es6.mjs"
40
+ }
41
+ },
42
+ "default": "./tslib.js"
43
+ },
44
+ "./*": "./*",
45
+ "./": "./"
46
+ }
47
+ }