@web-widget/node 0.5.0 → 0.13.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.
- package/dist/node.cjs +6 -2
- package/dist/node.d.cts +30 -0
- package/dist/node.d.ts +2 -2
- package/dist/node.js +6 -2
- package/package.json +5 -5
package/dist/node.cjs
CHANGED
|
@@ -33,11 +33,15 @@ __export(src_exports, {
|
|
|
33
33
|
default: () => NodeAdapter
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(src_exports);
|
|
36
|
+
var import_node_async_hooks = require("async_hooks");
|
|
36
37
|
var import_node_utils = require("@edge-runtime/node-utils");
|
|
37
38
|
var import_primitives = __toESM(require("@edge-runtime/primitives"), 1);
|
|
38
|
-
var import_node_async_hooks = require("async_hooks");
|
|
39
39
|
if (!Reflect.get(global, "DISABLE_INSTALL_MCA_SHIMS")) {
|
|
40
|
-
Object.
|
|
40
|
+
for (const [key, value] of Object.entries(import_primitives.default)) {
|
|
41
|
+
if (!(key in global)) {
|
|
42
|
+
global[key] = value;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
41
45
|
}
|
|
42
46
|
Object.assign(global, {
|
|
43
47
|
AsyncLocalStorage: import_node_async_hooks.AsyncLocalStorage
|
package/dist/node.d.cts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { RequestOptions, NodeHandler } from '@edge-runtime/node-utils';
|
|
3
|
+
import primitives from '@edge-runtime/primitives';
|
|
4
|
+
|
|
5
|
+
type WebHandler = (req: Request, env: Record<string, unknown>, event: FetchEvent) => Promise<Response> | Response | null | undefined;
|
|
6
|
+
declare class FetchEvent {
|
|
7
|
+
request: Request;
|
|
8
|
+
awaiting: Set<Promise<void>>;
|
|
9
|
+
response: Response | null;
|
|
10
|
+
constructor(request: Request);
|
|
11
|
+
respondWith(response: Response): void;
|
|
12
|
+
waitUntil(): void;
|
|
13
|
+
}
|
|
14
|
+
interface NodeAdapterOptions extends RequestOptions {
|
|
15
|
+
}
|
|
16
|
+
interface Middleware {
|
|
17
|
+
(req: IncomingMessage, res: ServerResponse, next: Function): void;
|
|
18
|
+
}
|
|
19
|
+
declare class NodeAdapter {
|
|
20
|
+
#private;
|
|
21
|
+
constructor(webRouter: {
|
|
22
|
+
handler: WebHandler;
|
|
23
|
+
origin?: string;
|
|
24
|
+
}, options?: NodeAdapterOptions);
|
|
25
|
+
get middleware(): Middleware;
|
|
26
|
+
get handler(): NodeHandler;
|
|
27
|
+
static get primitives(): typeof primitives;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { type Middleware, type NodeAdapterOptions, NodeAdapter as default };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
1
2
|
import { RequestOptions, NodeHandler } from '@edge-runtime/node-utils';
|
|
2
3
|
import primitives from '@edge-runtime/primitives';
|
|
3
|
-
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
4
4
|
|
|
5
5
|
type WebHandler = (req: Request, env: Record<string, unknown>, event: FetchEvent) => Promise<Response> | Response | null | undefined;
|
|
6
6
|
declare class FetchEvent {
|
|
@@ -27,4 +27,4 @@ declare class NodeAdapter {
|
|
|
27
27
|
static get primitives(): typeof primitives;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export { Middleware, NodeAdapterOptions, NodeAdapter as default };
|
|
30
|
+
export { type Middleware, type NodeAdapterOptions, NodeAdapter as default };
|
package/dist/node.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
3
|
import {
|
|
3
4
|
buildToFetchEvent,
|
|
4
5
|
buildToRequest,
|
|
@@ -6,9 +7,12 @@ import {
|
|
|
6
7
|
toOutgoingHeaders
|
|
7
8
|
} from "@edge-runtime/node-utils";
|
|
8
9
|
import primitives from "@edge-runtime/primitives";
|
|
9
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
10
10
|
if (!Reflect.get(global, "DISABLE_INSTALL_MCA_SHIMS")) {
|
|
11
|
-
|
|
11
|
+
for (const [key, value] of Object.entries(primitives)) {
|
|
12
|
+
if (!(key in global)) {
|
|
13
|
+
global[key] = value;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
12
16
|
}
|
|
13
17
|
Object.assign(global, {
|
|
14
18
|
AsyncLocalStorage
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@web-widget/node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"dist/"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@edge-runtime/node-utils": "^2.2.
|
|
17
|
-
"@edge-runtime/primitives": "^
|
|
16
|
+
"@edge-runtime/node-utils": "^2.2.4",
|
|
17
|
+
"@edge-runtime/primitives": "^4.0.6"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/node": "^17.0.45",
|
|
21
|
-
"tsup": "^
|
|
22
|
-
"typescript": "^5.
|
|
21
|
+
"tsup": "^8.0.1",
|
|
22
|
+
"typescript": "^5.3.3"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=18"
|