rwsdk 1.2.3 → 1.2.4
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/runtime/server.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type ServerFunctionWrap = (fn: Function, args: any[], type: "action" | "q
|
|
|
19
19
|
* handler function, its arguments, and the type ("action" or "query").
|
|
20
20
|
* Interruptors run *outside* the wrapper.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
22
|
+
* Only one wrapper is active at a time; the most recent call wins.
|
|
23
23
|
*
|
|
24
24
|
* @example
|
|
25
25
|
* ```ts
|
package/dist/runtime/server.js
CHANGED
|
@@ -7,7 +7,7 @@ let globalWrap;
|
|
|
7
7
|
* handler function, its arguments, and the type ("action" or "query").
|
|
8
8
|
* Interruptors run *outside* the wrapper.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* Only one wrapper is active at a time; the most recent call wins.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```ts
|
|
@@ -23,10 +23,6 @@ let globalWrap;
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
export function registerServerFunctionWrap(wrap) {
|
|
26
|
-
if (globalWrap) {
|
|
27
|
-
throw new Error("registerServerFunctionWrap() has already been called. " +
|
|
28
|
-
"Only one wrapper can be registered.");
|
|
29
|
-
}
|
|
30
26
|
globalWrap = wrap;
|
|
31
27
|
}
|
|
32
28
|
/**
|
|
@@ -86,11 +86,17 @@ describe("registerServerFunctionWrap", () => {
|
|
|
86
86
|
expect(wrapSpy).not.toHaveBeenCalled();
|
|
87
87
|
expect(result).toBeInstanceOf(Response);
|
|
88
88
|
});
|
|
89
|
-
it("
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
it("replaces the wrapper if called more than once", async () => {
|
|
90
|
+
const first = vi.fn((fn, args, _type) => fn(...args));
|
|
91
|
+
const second = vi.fn((fn, args, _type) => fn(...args));
|
|
92
|
+
registerServerFunctionWrap(first);
|
|
93
|
+
registerServerFunctionWrap(second);
|
|
94
|
+
const action = serverAction(async function run() {
|
|
95
|
+
return "ok";
|
|
96
|
+
});
|
|
97
|
+
await action();
|
|
98
|
+
expect(first).not.toHaveBeenCalled();
|
|
99
|
+
expect(second).toHaveBeenCalledOnce();
|
|
94
100
|
});
|
|
95
101
|
it("without registration, handlers work normally", async () => {
|
|
96
102
|
const action = serverAction(async function echo(msg) {
|