@hyper-fetch/plugin-devtools 10.0.0 → 10.1.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/README.md +107 -50
- package/__tests__/devtools/devtools.browser.spec.ts +18 -0
- package/__tests__/devtools/devtools.edge-cases.spec.ts +278 -0
- package/__tests__/devtools/devtools.event-handler.spec.ts +427 -0
- package/__tests__/devtools/devtools.observers.spec.ts +255 -0
- package/__tests__/devtools/devtools.sockets.spec.ts +209 -0
- package/dist/devtools.event.handler.d.ts +7 -1
- package/dist/devtools.event.handler.d.ts.map +1 -1
- package/dist/devtools.observers-reporter.d.ts +19 -0
- package/dist/devtools.observers-reporter.d.ts.map +1 -0
- package/dist/devtools.socket-reporter.d.ts +20 -0
- package/dist/devtools.socket-reporter.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +234 -18
- package/dist/index.mjs.map +1 -1
- package/dist/types/events.types.d.ts +70 -1
- package/dist/types/events.types.d.ts.map +1 -1
- package/dist/types/plugin.types.d.ts +12 -0
- package/dist/types/plugin.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/devtools.event.handler.ts +56 -9
- package/src/devtools.observers-reporter.ts +102 -0
- package/src/devtools.socket-reporter.ts +85 -0
- package/src/index.ts +2 -0
- package/src/types/events.types.ts +71 -0
- package/src/types/plugin.types.ts +13 -0
- package/tsconfig.json +1 -0
- package/__tests__/devtools/index.spec.ts +0 -42
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { SocketInstance } from "@hyper-fetch/sockets";
|
|
2
|
+
|
|
1
3
|
export type DevtoolsPluginOptions = {
|
|
2
4
|
/**
|
|
3
5
|
* Name of your application, it will be displayed in the HyperFlow app
|
|
@@ -19,4 +21,15 @@ export type DevtoolsPluginOptions = {
|
|
|
19
21
|
* Displayed alongside the app name in HyperFlow to distinguish deployments.
|
|
20
22
|
*/
|
|
21
23
|
environment?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The `WebSocket` constructor used to connect to HyperFlow. Defaults to the global `WebSocket` of browsers,
|
|
26
|
+
* Node.js 22+, Deno and Bun. On older Node.js pass the one from the `ws` package: `import { WebSocket } from "ws"`.
|
|
27
|
+
*/
|
|
28
|
+
WebSocket?: typeof WebSocket;
|
|
29
|
+
/**
|
|
30
|
+
* Sockets to inspect in HyperFlow next to the requests of the client: their connection, the messages they receive
|
|
31
|
+
* and send, and their errors.
|
|
32
|
+
* @example DevtoolsPlugin({ appName: "My App", sockets: [socket] })
|
|
33
|
+
*/
|
|
34
|
+
sockets?: SocketInstance[];
|
|
22
35
|
};
|
package/tsconfig.json
CHANGED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Client } from "@hyper-fetch/core";
|
|
2
|
-
import { createHttpMockingServer, createWebsocketMockingServer } from "@hyper-fetch/testing";
|
|
3
|
-
|
|
4
|
-
import { DevtoolsPlugin } from "../../src/index";
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
startServer: startWebsocketServer,
|
|
8
|
-
stopServer: stopWebsocketServer,
|
|
9
|
-
// emitListenerEvent,
|
|
10
|
-
// expectEmitterEvent,
|
|
11
|
-
} = createWebsocketMockingServer("ws://localhost:2137");
|
|
12
|
-
const {
|
|
13
|
-
resetMocks,
|
|
14
|
-
startServer,
|
|
15
|
-
stopServer,
|
|
16
|
-
// mockRequest
|
|
17
|
-
} = createHttpMockingServer();
|
|
18
|
-
|
|
19
|
-
describe("Backend Devtools - Socket Test", () => {
|
|
20
|
-
let client = new Client({ url: "shared-base-url" }).addPlugin(DevtoolsPlugin({ appName: "TestApp" }));
|
|
21
|
-
let request = client.createRequest()({ endpoint: "/shared-endpoint" });
|
|
22
|
-
|
|
23
|
-
beforeAll(() => {
|
|
24
|
-
startServer();
|
|
25
|
-
startWebsocketServer();
|
|
26
|
-
});
|
|
27
|
-
beforeEach(() => {
|
|
28
|
-
client = new Client({ url: "shared-base-url" });
|
|
29
|
-
request = client.createRequest()({ endpoint: "/shared-endpoint" });
|
|
30
|
-
vi.resetAllMocks();
|
|
31
|
-
vi.clearAllMocks();
|
|
32
|
-
resetMocks();
|
|
33
|
-
});
|
|
34
|
-
afterAll(() => {
|
|
35
|
-
stopWebsocketServer();
|
|
36
|
-
stopServer();
|
|
37
|
-
});
|
|
38
|
-
it("should send REQUEST_CREATED event when a request is created", async () => {
|
|
39
|
-
console.warn("test", request);
|
|
40
|
-
expect(true).toBe(true);
|
|
41
|
-
});
|
|
42
|
-
});
|