@moeru/eventa 1.0.0-beta.3 → 1.0.0-beta.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/README.md +50 -1
- package/dist/adapters/broadcast-channel/index.d.mts +2 -2
- package/dist/adapters/broadcast-channel/index.mjs +6 -9
- package/dist/adapters/broadcast-channel/index.mjs.map +1 -1
- package/dist/adapters/electron/main.d.mts +2 -2
- package/dist/adapters/electron/main.mjs +7 -9
- package/dist/adapters/electron/main.mjs.map +1 -1
- package/dist/adapters/electron/renderer.d.mts +134 -3
- package/dist/adapters/electron/renderer.mjs +4 -6
- package/dist/adapters/electron/renderer.mjs.map +1 -1
- package/dist/adapters/event-emitter/index.d.mts +2 -2
- package/dist/adapters/event-emitter/index.mjs +4 -7
- package/dist/adapters/event-emitter/index.mjs.map +1 -1
- package/dist/adapters/event-target/index.d.mts +2 -2
- package/dist/adapters/event-target/index.mjs +5 -8
- package/dist/adapters/event-target/index.mjs.map +1 -1
- package/dist/adapters/websocket/h3/index.d.mts +442 -3
- package/dist/adapters/websocket/h3/index.mjs +7 -9
- package/dist/adapters/websocket/h3/index.mjs.map +1 -1
- package/dist/adapters/websocket/index.d.mts +1 -1
- package/dist/adapters/websocket/index.mjs +1 -1
- package/dist/adapters/websocket/native/index.d.mts +2 -2
- package/dist/adapters/websocket/native/index.mjs +4 -5
- package/dist/adapters/websocket/native/index.mjs.map +1 -1
- package/dist/adapters/webworkers/index.d.mts +2 -2
- package/dist/adapters/webworkers/index.mjs +5 -6
- package/dist/adapters/webworkers/index.mjs.map +1 -1
- package/dist/adapters/webworkers/worker/index.d.mts +1 -1
- package/dist/adapters/webworkers/worker/index.mjs +6 -7
- package/dist/adapters/webworkers/worker/index.mjs.map +1 -1
- package/dist/adapters/window-message/index.d.mts +50 -0
- package/dist/adapters/window-message/index.mjs +79 -0
- package/dist/adapters/window-message/index.mjs.map +1 -0
- package/dist/adapters/worker-threads/index.d.mts +2 -2
- package/dist/adapters/worker-threads/index.mjs +5 -6
- package/dist/adapters/worker-threads/index.mjs.map +1 -1
- package/dist/adapters/worker-threads/worker/index.d.mts +1 -1
- package/dist/adapters/worker-threads/worker/index.mjs +6 -7
- package/dist/adapters/worker-threads/worker/index.mjs.map +1 -1
- package/dist/{context-BNM9nsGp.d.mts → context-BsqFeoer.d.mts} +2 -2
- package/dist/{context-c10xPp3f.mjs → context-Dht_IZMb.mjs} +22 -24
- package/dist/context-Dht_IZMb.mjs.map +1 -0
- package/dist/{eventa-M1FMVrH1.d.mts → eventa-DSnoBa1O.d.mts} +3 -3
- package/dist/{index-giKJThn3.d.mts → index-g6DulgOI.d.mts} +88 -88
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -4
- package/dist/{internal-C-4X8bpL.mjs → internal-CHUsXYiP.mjs} +3 -4
- package/dist/{internal-C-4X8bpL.mjs.map → internal-CHUsXYiP.mjs.map} +1 -1
- package/dist/{shared-eQ-hnVHv.mjs → shared-CA5MGwv0.mjs} +5 -7
- package/dist/shared-CA5MGwv0.mjs.map +1 -0
- package/dist/{shared-BcRXZZxh.d.mts → shared-CVTLm458.d.mts} +2 -2
- package/dist/{shared-NFMSqOPw.d.mts → shared-CfXZb-7K.d.mts} +2 -2
- package/dist/{shared-DeDRsHPI.mjs → shared-Dl0_bFq0.mjs} +4 -5
- package/dist/{shared-DeDRsHPI.mjs.map → shared-Dl0_bFq0.mjs.map} +1 -1
- package/dist/{src-CTkYOGiO.mjs → src-CTs6h4Ci.mjs} +56 -63
- package/dist/src-CTs6h4Ci.mjs.map +1 -0
- package/package.json +14 -7
- package/dist/context-c10xPp3f.mjs.map +0 -1
- package/dist/shared-eQ-hnVHv.mjs.map +0 -1
- package/dist/src-CTkYOGiO.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as EventTag, r as Eventa } from "./eventa-
|
|
2
|
-
import { t as EventContext } from "./context-
|
|
1
|
+
import { n as EventTag, r as Eventa } from "./eventa-DSnoBa1O.mjs";
|
|
2
|
+
import { t as EventContext } from "./context-BsqFeoer.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/invoke-shared.d.ts
|
|
5
5
|
declare enum InvokeEventType {
|
|
@@ -9,77 +9,77 @@ declare enum InvokeEventType {
|
|
|
9
9
|
SendEventAbort = 3,
|
|
10
10
|
ReceiveEvent = 4,
|
|
11
11
|
ReceiveEventError = 5,
|
|
12
|
-
ReceiveEventStreamEnd = 6
|
|
12
|
+
ReceiveEventStreamEnd = 6
|
|
13
13
|
}
|
|
14
|
-
interface SendEvent<Res
|
|
14
|
+
interface SendEvent<Res, Req = undefined, _ = undefined, __ = undefined, M = undefined, IM = undefined> extends Eventa<{
|
|
15
15
|
invokeId: string;
|
|
16
|
-
content: Req
|
|
16
|
+
content: Req;
|
|
17
17
|
isReqStream?: boolean;
|
|
18
|
-
}, M
|
|
19
|
-
id: EventTag<Res
|
|
18
|
+
}, M, IM> {
|
|
19
|
+
id: EventTag<Res, Req>;
|
|
20
20
|
invokeType: InvokeEventType.SendEvent;
|
|
21
21
|
}
|
|
22
|
-
interface SendEventError<Res
|
|
22
|
+
interface SendEventError<Res, Req = undefined, _ = undefined, ReqErr = Error, M = undefined, IM = undefined> extends Eventa<{
|
|
23
23
|
invokeId: string;
|
|
24
|
-
content: ReqErr
|
|
25
|
-
}, M
|
|
26
|
-
id: EventTag<Res
|
|
24
|
+
content: ReqErr;
|
|
25
|
+
}, M, IM> {
|
|
26
|
+
id: EventTag<Res, Req>;
|
|
27
27
|
invokeType: InvokeEventType.SendEventError;
|
|
28
28
|
}
|
|
29
|
-
interface SendEventStreamEnd<Res
|
|
29
|
+
interface SendEventStreamEnd<Res, Req = undefined, _ = undefined, __ = undefined, M = undefined, IM = undefined> extends Eventa<{
|
|
30
30
|
invokeId: string;
|
|
31
31
|
content: undefined;
|
|
32
|
-
}, M
|
|
33
|
-
id: EventTag<Res
|
|
32
|
+
}, M, IM> {
|
|
33
|
+
id: EventTag<Res, Req>;
|
|
34
34
|
invokeType: InvokeEventType.SendEventStreamEnd;
|
|
35
35
|
}
|
|
36
|
-
interface SendEventAbort<Res
|
|
36
|
+
interface SendEventAbort<Res, Req = undefined, _ = undefined, __ = undefined, M = undefined, IM = undefined> extends Eventa<{
|
|
37
37
|
invokeId: string;
|
|
38
38
|
content?: unknown;
|
|
39
|
-
}, M
|
|
40
|
-
id: EventTag<Res
|
|
39
|
+
}, M, IM> {
|
|
40
|
+
id: EventTag<Res, Req>;
|
|
41
41
|
invokeType: InvokeEventType.SendEventAbort;
|
|
42
42
|
}
|
|
43
|
-
interface ReceiveEvent<Res
|
|
43
|
+
interface ReceiveEvent<Res, Req = undefined, _ = undefined, __ = undefined, M = undefined, IM = undefined> extends Eventa<{
|
|
44
44
|
invokeId: string;
|
|
45
|
-
content: Res
|
|
46
|
-
}, M
|
|
47
|
-
id: EventTag<Res
|
|
45
|
+
content: Res;
|
|
46
|
+
}, M, IM> {
|
|
47
|
+
id: EventTag<Res, Req>;
|
|
48
48
|
invokeType: InvokeEventType.ReceiveEvent;
|
|
49
49
|
}
|
|
50
|
-
interface ReceiveEventError<Res
|
|
50
|
+
interface ReceiveEventError<Res, Req = undefined, ResErr = undefined, _ = undefined, M = undefined, IM = undefined> extends Eventa<{
|
|
51
51
|
invokeId: string;
|
|
52
52
|
content: {
|
|
53
|
-
error: ResErr
|
|
53
|
+
error: ResErr;
|
|
54
54
|
};
|
|
55
|
-
}, M
|
|
56
|
-
id: EventTag<Res
|
|
55
|
+
}, M, IM> {
|
|
56
|
+
id: EventTag<Res, Req>;
|
|
57
57
|
invokeType: InvokeEventType.ReceiveEventError;
|
|
58
58
|
}
|
|
59
|
-
interface ReceiveEventStreamEnd<Res
|
|
59
|
+
interface ReceiveEventStreamEnd<Res, Req = undefined, _ = undefined, __ = undefined, M = undefined, IM = undefined> extends Eventa<{
|
|
60
60
|
invokeId: string;
|
|
61
61
|
content: undefined;
|
|
62
|
-
}, M
|
|
63
|
-
id: EventTag<Res
|
|
62
|
+
}, M, IM> {
|
|
63
|
+
id: EventTag<Res, Req>;
|
|
64
64
|
invokeType: InvokeEventType.ReceiveEventStreamEnd;
|
|
65
65
|
}
|
|
66
|
-
interface InvokeEventa<Res
|
|
67
|
-
sendEvent: SendEvent<Res
|
|
68
|
-
sendEventError: SendEventError<Res
|
|
69
|
-
sendEventStreamEnd: SendEventStreamEnd<Res
|
|
70
|
-
sendEventAbort: SendEventAbort<Res
|
|
71
|
-
receiveEvent: ReceiveEvent<Res
|
|
72
|
-
receiveEventError: ReceiveEventError<Res
|
|
73
|
-
receiveEventStreamEnd: ReceiveEventStreamEnd<Res
|
|
66
|
+
interface InvokeEventa<Res, Req = undefined, ResErr = Error, ReqErr = Error, M = undefined, IM = undefined> {
|
|
67
|
+
sendEvent: SendEvent<Res, Req, ResErr, ReqErr, M, IM>;
|
|
68
|
+
sendEventError: SendEventError<Res, Req, ResErr, ReqErr, M, IM>;
|
|
69
|
+
sendEventStreamEnd: SendEventStreamEnd<Res, Req, ResErr, ReqErr, M, IM>;
|
|
70
|
+
sendEventAbort: SendEventAbort<Res, Req, ResErr, ReqErr, M, IM>;
|
|
71
|
+
receiveEvent: ReceiveEvent<Res, Req, ResErr, ReqErr, M, IM>;
|
|
72
|
+
receiveEventError: ReceiveEventError<Res, Req, ResErr, ReqErr, M, IM>;
|
|
73
|
+
receiveEventStreamEnd: ReceiveEventStreamEnd<Res, Req, ResErr, ReqErr, M, IM>;
|
|
74
74
|
}
|
|
75
|
-
interface InvokeHandlerEventa<Res
|
|
76
|
-
sendEvent: SendEvent<Res
|
|
77
|
-
sendEventError: SendEventError<Res
|
|
78
|
-
sendEventStreamEnd: SendEventStreamEnd<Res
|
|
79
|
-
sendEventAbort: SendEventAbort<Res
|
|
80
|
-
receiveEvent: ReceiveEvent<Res
|
|
81
|
-
receiveEventError: ReceiveEventError<Res
|
|
82
|
-
receiveEventStreamEnd: ReceiveEventStreamEnd<Res
|
|
75
|
+
interface InvokeHandlerEventa<Res, Req = undefined, ResErr = Error, ReqErr = Error, M = undefined, _IM = undefined> extends InvokeEventa<Res, Req, ResErr, ReqErr, M, undefined> {
|
|
76
|
+
sendEvent: SendEvent<Res, Req, ResErr, ReqErr, M, undefined>;
|
|
77
|
+
sendEventError: SendEventError<Res, Req, ResErr, ReqErr, M, undefined>;
|
|
78
|
+
sendEventStreamEnd: SendEventStreamEnd<Res, Req, ResErr, ReqErr, M, undefined>;
|
|
79
|
+
sendEventAbort: SendEventAbort<Res, Req, ResErr, ReqErr, M, undefined>;
|
|
80
|
+
receiveEvent: ReceiveEvent<Res, Req, ResErr, ReqErr, M, undefined>;
|
|
81
|
+
receiveEventError: ReceiveEventError<Res, Req, ResErr, ReqErr, M, undefined>;
|
|
82
|
+
receiveEventStreamEnd: ReceiveEventStreamEnd<Res, Req, ResErr, ReqErr, M, undefined>;
|
|
83
83
|
}
|
|
84
84
|
type InferSendEvent<T> = T extends {
|
|
85
85
|
sendEvent: SendEvent<infer Res, infer Req, infer ResErr, infer ReqErr, infer M, infer IM>;
|
|
@@ -102,17 +102,17 @@ type InferReceiveEventError<T> = T extends {
|
|
|
102
102
|
type InferReceiveEventStreamEnd<T> = T extends {
|
|
103
103
|
receiveEventStreamEnd: ReceiveEventStreamEnd<infer Res, infer Req, infer ResErr, infer ReqErr, infer M, infer IM>;
|
|
104
104
|
} ? ReceiveEventStreamEnd<Res, Req, ResErr, ReqErr, M, IM> : never;
|
|
105
|
-
declare function defineInvokeEventa<Res
|
|
106
|
-
metadata?: M
|
|
107
|
-
invokeMetadata?: IM
|
|
105
|
+
declare function defineInvokeEventa<Res, Req = undefined, ResErr = Error, ReqErr = Error, M = undefined, IM = undefined>(tag?: string, options?: {
|
|
106
|
+
metadata?: M;
|
|
107
|
+
invokeMetadata?: IM;
|
|
108
108
|
}): {
|
|
109
|
-
sendEvent: SendEvent<Res
|
|
110
|
-
sendEventError: SendEventError<Res
|
|
111
|
-
sendEventStreamEnd: SendEventStreamEnd<Res
|
|
112
|
-
sendEventAbort: SendEventAbort<Res
|
|
113
|
-
receiveEvent: ReceiveEvent<Res
|
|
114
|
-
receiveEventError: ReceiveEventError<Res
|
|
115
|
-
receiveEventStreamEnd: ReceiveEventStreamEnd<Res
|
|
109
|
+
sendEvent: SendEvent<Res, Req, ResErr, ReqErr, M, IM>;
|
|
110
|
+
sendEventError: SendEventError<Res, Req, ResErr, ReqErr, M, IM>;
|
|
111
|
+
sendEventStreamEnd: SendEventStreamEnd<Res, Req, ResErr, ReqErr, M, IM>;
|
|
112
|
+
sendEventAbort: SendEventAbort<Res, Req, ResErr, ReqErr, M, IM>;
|
|
113
|
+
receiveEvent: ReceiveEvent<Res, Req, ResErr, ReqErr, M, IM>;
|
|
114
|
+
receiveEventError: ReceiveEventError<Res, Req, ResErr, ReqErr, M, IM>;
|
|
115
|
+
receiveEventStreamEnd: ReceiveEventStreamEnd<Res, Req, ResErr, ReqErr, M, IM>;
|
|
116
116
|
};
|
|
117
117
|
declare function isInvokeEventa(event: Eventa<any>): event is SendEvent<any, any, any, any, any, any> | SendEventError<any, any, any, any, any, any> | SendEventStreamEnd<any, any, any, any, any, any> | ReceiveEvent<any, any, any, any, any, any> | ReceiveEventError<any, any, any, any, any, any> | ReceiveEventStreamEnd<any, any, any, any, any, any> | SendEventAbort<any, any, any, any, any, any>;
|
|
118
118
|
declare function isSendEvent(event: Eventa<any>): event is SendEvent<any, any, any, any, any, any> | SendEventError<any, any, any, any, any, any> | SendEventStreamEnd<any, any, any, any, any, any> | SendEventAbort<any, any, any, any, any, any>;
|
|
@@ -142,32 +142,32 @@ type ExtractInvokeResponseOptions<EC extends EventContext<any, any>> = EC extend
|
|
|
142
142
|
} ? IR : E extends {
|
|
143
143
|
invokeResponse?: infer IR;
|
|
144
144
|
} ? IR : undefined : undefined;
|
|
145
|
-
type InvokeFunction<Res
|
|
145
|
+
type InvokeFunction<Res, Req, EC extends EventContext<any, any>> = [Req] extends [undefined] ? IsInvokeRequestOptional<EC> extends true ? (req?: Req, options?: ExtractInvokeRequestOptions<EC>) => Promise<Res> : (req: Req, options: ExtractInvokeRequestOptions<EC>) => Promise<Res> : IsInvokeRequestOptional<EC> extends true ? (req: Req, options?: ExtractInvokeRequestOptions<EC>) => Promise<Res> : (req: Req, options: ExtractInvokeRequestOptions<EC>) => Promise<Res>;
|
|
146
146
|
type InvokeFunctionMap<EventMap extends Record<string, InvokeEventa<any, any, any, any>>, EC extends EventContext<any, any>> = { [K in keyof EventMap]: EventMap[K] extends InvokeEventa<infer Res, infer Req, any, any> ? InvokeFunction<Res, Req, EC> : never };
|
|
147
|
-
type ExtendableInvokeResponse<Res
|
|
148
|
-
response: Res
|
|
147
|
+
type ExtendableInvokeResponse<Res, EC extends EventContext<any, any>> = Promise<Res> | Res | Promise<{
|
|
148
|
+
response: Res;
|
|
149
149
|
invokeResponse?: ExtractInvokeResponseOptions<EC>;
|
|
150
150
|
}> | {
|
|
151
|
-
response: Res
|
|
151
|
+
response: Res;
|
|
152
152
|
invokeResponse?: ExtractInvokeResponseOptions<EC>;
|
|
153
153
|
};
|
|
154
|
-
declare function isExtendableInvokeResponseLike<Res
|
|
155
|
-
response: Res
|
|
154
|
+
declare function isExtendableInvokeResponseLike<Res, EC extends EventContext<any, any>>(value: Eventa<unknown> | ReceiveEvent<{
|
|
155
|
+
response: Res;
|
|
156
156
|
invokeResponse?: unknown;
|
|
157
157
|
}>): value is ReceiveEvent<{
|
|
158
|
-
response: Res
|
|
158
|
+
response: Res;
|
|
159
159
|
invokeResponse?: ExtractInvokeResponseOptions<EC>;
|
|
160
160
|
}>;
|
|
161
|
-
type Handler<Res
|
|
161
|
+
type Handler<Res, Req = any, EC extends EventContext<any, any> = EventContext<any, any>, RawEventOptions = unknown> = (payload: Req, options?: {
|
|
162
162
|
abortController?: AbortController;
|
|
163
|
-
} & RawEventOptions) => ExtendableInvokeResponse<Res
|
|
164
|
-
interface InternalInvokeHandler<Res
|
|
165
|
-
onSend: (params: InvokeEventa<Res
|
|
166
|
-
onSendStreamEnd: (params: InvokeEventa<Res
|
|
167
|
-
onSendAbort: (params: InvokeEventa<Res
|
|
163
|
+
} & RawEventOptions) => ExtendableInvokeResponse<Res, EC>;
|
|
164
|
+
interface InternalInvokeHandler<Res, Req = any, ResErr = Error, ReqErr = Error, EO = any, M = undefined, IM = undefined> {
|
|
165
|
+
onSend: (params: InvokeEventa<Res, Req, ResErr, ReqErr, M, IM>['sendEvent'], eventOptions?: EO) => void;
|
|
166
|
+
onSendStreamEnd: (params: InvokeEventa<Res, Req, ResErr, ReqErr, M, IM>['sendEventStreamEnd'], eventOptions?: EO) => void;
|
|
167
|
+
onSendAbort: (params: InvokeEventa<Res, Req, ResErr, ReqErr, M, IM>['sendEventAbort'], eventOptions?: EO) => void;
|
|
168
168
|
}
|
|
169
169
|
type HandlerMap<EventMap extends Record<string, InvokeEventa<any, any, any, any, any, any>>, EO = any, EC extends EventContext<any, any> = EventContext<any, any>> = { [K in keyof EventMap]: EventMap[K] extends InvokeEventa<infer Res, infer Req, any, any, any, any> ? Handler<Res, Req, EC, EO> : never };
|
|
170
|
-
interface InvocableEventContext<E
|
|
170
|
+
interface InvocableEventContext<E, EO> extends EventContext<E, EO> {
|
|
171
171
|
invokeHandlers?: Map<string, Map<Handler<any>, InternalInvokeHandler<any, any, any, any, any, any, any>>>;
|
|
172
172
|
}
|
|
173
173
|
/**
|
|
@@ -220,7 +220,7 @@ interface InvocableEventContext<E$1, EO> extends EventContext<E$1, EO> {
|
|
|
220
220
|
* @param ctx Event context on the caller/client side.
|
|
221
221
|
* @param event Invoke event definition created by `defineInvokeEventa`.
|
|
222
222
|
*/
|
|
223
|
-
declare function defineInvoke<Res
|
|
223
|
+
declare function defineInvoke<Res, Req = undefined, ResErr = Error, ReqErr = Error, M = undefined, IM = undefined, CtxExt = any, EOpts = any, ECtx extends EventContext<CtxExt, EOpts> = EventContext<CtxExt, EOpts>>(ctx: ECtx | (() => ECtx | Promise<ECtx>), event: InvokeEventa<Res, Req, ResErr, ReqErr, M, IM>): InvokeFunction<Res, Req, ECtx>;
|
|
224
224
|
/**
|
|
225
225
|
* Create a map of invoke functions from a map of invoke events (client side).
|
|
226
226
|
*
|
|
@@ -258,9 +258,9 @@ declare function defineInvokes<EK extends string, EventMap extends Record<EK, In
|
|
|
258
258
|
* @param event Invoke event definition created by `defineInvokeEventa`.
|
|
259
259
|
* @param handler Handler that returns a response (or response + metadata).
|
|
260
260
|
*/
|
|
261
|
-
declare function defineInvokeHandler<Res
|
|
261
|
+
declare function defineInvokeHandler<Res, Req = undefined, ResErr = Error, ReqErr = Error, M = undefined, IM = undefined, CtxExt = any, EOpts extends {
|
|
262
262
|
raw?: any;
|
|
263
|
-
} = any>(ctx: InvocableEventContext<CtxExt, EOpts>, event: InvokeHandlerEventa<Res
|
|
263
|
+
} = any>(ctx: InvocableEventContext<CtxExt, EOpts>, event: InvokeHandlerEventa<Res, Req, ResErr, ReqErr, M, IM>, handler: Handler<Res, Req, InvocableEventContext<CtxExt, EOpts>, EOpts>): () => void;
|
|
264
264
|
/**
|
|
265
265
|
* Define multiple invoke handlers in batch (server side).
|
|
266
266
|
*
|
|
@@ -301,7 +301,7 @@ declare function defineInvokeHandlers<EK extends string, EventMap extends Record
|
|
|
301
301
|
* @param handler Specific handler to remove (omit to remove all).
|
|
302
302
|
* @returns `true` if at least one handler was removed, `false` otherwise
|
|
303
303
|
*/
|
|
304
|
-
declare function undefineInvokeHandler<Res
|
|
304
|
+
declare function undefineInvokeHandler<Res, Req = undefined, ResErr = Error, ReqErr = Error, CtxExt = any, EOpts = any>(ctx: InvocableEventContext<CtxExt, EOpts>, event: InvokeEventa<Res, Req, ResErr, ReqErr>, handler?: Handler<Res, Req, InvocableEventContext<CtxExt, EOpts>, EOpts>): boolean;
|
|
305
305
|
//#endregion
|
|
306
306
|
//#region src/invoke-extension-transfer.d.ts
|
|
307
307
|
interface WithTransfer<T> {
|
|
@@ -327,10 +327,10 @@ interface InvokeFunctionStubOptions {
|
|
|
327
327
|
type RemoteInvokeOptions<EC extends EventContext<any, any>> = ExtractInvokeRequestOptions<EC> & {
|
|
328
328
|
functionStubs?: boolean | InvokeFunctionStubOptions;
|
|
329
329
|
};
|
|
330
|
-
interface RemoteInvokeResult<Res
|
|
330
|
+
interface RemoteInvokeResult<Res> extends Promise<Res> {
|
|
331
331
|
dispose: () => void;
|
|
332
332
|
}
|
|
333
|
-
type RemoteInvokeFunction<Res
|
|
333
|
+
type RemoteInvokeFunction<Res, Req, EC extends EventContext<any, any>> = [Req] extends [undefined] ? (req?: Req, options?: RemoteInvokeOptions<EC>) => RemoteInvokeResult<Res> : (req: Req, options?: RemoteInvokeOptions<EC>) => RemoteInvokeResult<Res>;
|
|
334
334
|
declare function createRemoteMethodTagPrefix(prefix?: string): string;
|
|
335
335
|
/**
|
|
336
336
|
* Enable "remote method" payloads for invoke: functions in the request body are
|
|
@@ -381,10 +381,10 @@ declare function createRemoteMethodTagPrefix(prefix?: string): string;
|
|
|
381
381
|
* `onDisallowedTag`, `autoDisposeMs`, and `strict` for stricter control.
|
|
382
382
|
*/
|
|
383
383
|
declare function withRemoteMethods(defaultOptions?: boolean | InvokeFunctionStubOptions): {
|
|
384
|
-
defineInvoke<Res
|
|
385
|
-
defineInvokeHandler<Res
|
|
384
|
+
defineInvoke<Res, Req = undefined, ResErr = Error, ReqErr = Error, CtxExt = any, EOpts = any, ECtx extends EventContext<CtxExt, EOpts> = EventContext<CtxExt, EOpts>>(ctx: ECtx, event: InvokeEventa<Res, Req, ResErr, ReqErr>): RemoteInvokeFunction<Res, Req, ECtx>;
|
|
385
|
+
defineInvokeHandler<Res, Req = undefined, ResErr = Error, ReqErr = Error, CtxExt = any, EOpts extends {
|
|
386
386
|
raw?: any;
|
|
387
|
-
} = any>(ctx: InvocableEventContext<CtxExt, EOpts>, event: InvokeEventa<Res
|
|
387
|
+
} = any>(ctx: InvocableEventContext<CtxExt, EOpts>, event: InvokeEventa<Res, Req, ResErr, ReqErr>, handler: Handler<Res, Req, InvocableEventContext<CtxExt, EOpts>, EOpts>): () => void;
|
|
388
388
|
};
|
|
389
389
|
//#endregion
|
|
390
390
|
//#region src/stream.d.ts
|
|
@@ -426,12 +426,12 @@ declare function withRemoteMethods(defaultOptions?: boolean | InvokeFunctionStub
|
|
|
426
426
|
* @param clientCtx Event context on the caller/client side.
|
|
427
427
|
* @param event Invoke event definition created by `defineInvokeEventa`.
|
|
428
428
|
*/
|
|
429
|
-
declare function defineStreamInvoke<Res
|
|
429
|
+
declare function defineStreamInvoke<Res, Req = undefined, ResErr = Error, ReqErr = Error, E = any, EO = any>(clientCtx: EventContext<E, EO>, event: InvokeEventa<Res, Req, ResErr, ReqErr>): (req: Req | ReadableStream<Req> | AsyncIterable<Req>, options?: {
|
|
430
430
|
signal?: AbortSignal;
|
|
431
|
-
} & EO) => ReadableStream<Res
|
|
432
|
-
type StreamHandler<Res
|
|
431
|
+
} & EO) => ReadableStream<Res>;
|
|
432
|
+
type StreamHandler<Res, Req = any, RawEventOptions = unknown> = (payload: Req, options?: {
|
|
433
433
|
abortController?: AbortController;
|
|
434
|
-
} & RawEventOptions) => AsyncGenerator<Res
|
|
434
|
+
} & RawEventOptions) => AsyncGenerator<Res, void, unknown>;
|
|
435
435
|
/**
|
|
436
436
|
* Define a stream invoke handler (server side).
|
|
437
437
|
*
|
|
@@ -460,9 +460,9 @@ type StreamHandler<Res$1, Req$1 = any, RawEventOptions = unknown> = (payload: Re
|
|
|
460
460
|
* @param event Invoke event definition created by `defineInvokeEventa`.
|
|
461
461
|
* @param fn Stream handler that yields response chunks.
|
|
462
462
|
*/
|
|
463
|
-
declare function defineStreamInvokeHandler<Res
|
|
463
|
+
declare function defineStreamInvokeHandler<Res, Req = undefined, ResErr = Error, ReqErr = Error, E = any, EO extends {
|
|
464
464
|
raw?: any;
|
|
465
|
-
} = any>(serverCtx: EventContext<E
|
|
465
|
+
} = any>(serverCtx: EventContext<E, EO>, event: InvokeEventa<Res, Req, ResErr, ReqErr>, fn: StreamHandler<Res, Req, EO>): void;
|
|
466
466
|
/**
|
|
467
467
|
* Convert a callback-style handler into a stream handler.
|
|
468
468
|
*
|
|
@@ -487,13 +487,13 @@ declare function defineStreamInvokeHandler<Res$1, Req$1 = undefined, ResErr$1 =
|
|
|
487
487
|
*
|
|
488
488
|
* @param handler Callback handler with `emit` for streaming responses.
|
|
489
489
|
*/
|
|
490
|
-
declare function toStreamHandler<Req
|
|
490
|
+
declare function toStreamHandler<Req, Res, EO extends {
|
|
491
491
|
raw?: any;
|
|
492
492
|
} = any>(handler: (context: {
|
|
493
|
-
payload: Req
|
|
493
|
+
payload: Req;
|
|
494
494
|
options?: EO;
|
|
495
|
-
emit: (data: Res
|
|
496
|
-
}) => Promise<void>): StreamHandler<Res
|
|
495
|
+
emit: (data: Res) => void;
|
|
496
|
+
}) => Promise<void>): StreamHandler<Res, Req, EO>;
|
|
497
497
|
//#endregion
|
|
498
498
|
//#region src/utils.d.ts
|
|
499
499
|
declare function randomBetween(min: number, max: number): number;
|
|
@@ -531,4 +531,4 @@ declare function createUntil<T>(options?: {
|
|
|
531
531
|
};
|
|
532
532
|
//#endregion
|
|
533
533
|
export { isReceiveEvent as $, defineInvokeHandlers as A, InferSendEventStreamEnd as B, Handler as C, InvokeFunctionMap as D, InvokeFunction as E, InferReceiveEventError as F, ReceiveEventError as G, InvokeEventa as H, InferReceiveEventStreamEnd as I, SendEventAbort as J, ReceiveEventStreamEnd as K, InferSendEvent as L, isExtendableInvokeResponseLike as M, undefineInvokeHandler as N, defineInvoke as O, InferReceiveEvent as P, isInvokeEventa as Q, InferSendEventAbort as R, ExtractInvokeResponseOptions as S, InvocableEventContext as T, InvokeHandlerEventa as U, InvokeEventType as V, ReceiveEvent as W, SendEventStreamEnd as X, SendEventError as Y, defineInvokeEventa as Z, withRemoteMethods as _, isAbortError as a, ExtendableInvokeResponse as b, randomBetween as c, toStreamHandler as d, isSendEvent as et, InvokeFunctionStubOptions as f, createRemoteMethodTagPrefix as g, RemoteInvokeResult as h, createUntilTriggeredOnce as i, defineInvokes as j, defineInvokeHandler as k, defineStreamInvoke as l, RemoteInvokeOptions as m, createUntil as n, isAsyncIterable as o, RemoteInvokeFunction as p, SendEvent as q, createUntilTriggered as r, isReadableStream as s, createAbortError as t, defineStreamInvokeHandler as u, WithTransfer as v, HandlerMap as w, ExtractInvokeRequestOptions as x, withTransfer as y, InferSendEventError as z };
|
|
534
|
-
//# sourceMappingURL=index-
|
|
534
|
+
//# sourceMappingURL=index-g6DulgOI.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as nanoid, a as EventaLike, c as InboundEventa, d as OutboundEventa, f as and, g as matchBy, h as defineOutboundEventa, i as EventaFlowDirection, l as InferEventaPayload, m as defineInboundEventa, n as EventTag, o as EventaMatchExpression, p as defineEventa, r as Eventa, s as EventaType, t as DirectionalEventa, u as InvokeEventConstraint, v as or } from "./eventa-
|
|
2
|
-
import { n as EventContextEmitFn, r as createContext, t as EventContext } from "./context-
|
|
3
|
-
import { $ as isReceiveEvent, A as defineInvokeHandlers, B as InferSendEventStreamEnd, C as Handler, D as InvokeFunctionMap, E as InvokeFunction, F as InferReceiveEventError, G as ReceiveEventError, H as InvokeEventa, I as InferReceiveEventStreamEnd, J as SendEventAbort, K as ReceiveEventStreamEnd, L as InferSendEvent, M as isExtendableInvokeResponseLike, N as undefineInvokeHandler, O as defineInvoke, P as InferReceiveEvent, Q as isInvokeEventa, R as InferSendEventAbort, S as ExtractInvokeResponseOptions, T as InvocableEventContext, U as InvokeHandlerEventa, V as InvokeEventType, W as ReceiveEvent, X as SendEventStreamEnd, Y as SendEventError, Z as defineInvokeEventa, _ as withRemoteMethods, a as isAbortError, b as ExtendableInvokeResponse, c as randomBetween, d as toStreamHandler, et as isSendEvent, f as InvokeFunctionStubOptions, g as createRemoteMethodTagPrefix, h as RemoteInvokeResult, i as createUntilTriggeredOnce, j as defineInvokes, k as defineInvokeHandler, l as defineStreamInvoke, m as RemoteInvokeOptions, n as createUntil, o as isAsyncIterable, p as RemoteInvokeFunction, q as SendEvent, r as createUntilTriggered, s as isReadableStream, t as createAbortError, u as defineStreamInvokeHandler, v as WithTransfer, w as HandlerMap, x as ExtractInvokeRequestOptions, y as withTransfer, z as InferSendEventError } from "./index-
|
|
1
|
+
import { _ as nanoid, a as EventaLike, c as InboundEventa, d as OutboundEventa, f as and, g as matchBy, h as defineOutboundEventa, i as EventaFlowDirection, l as InferEventaPayload, m as defineInboundEventa, n as EventTag, o as EventaMatchExpression, p as defineEventa, r as Eventa, s as EventaType, t as DirectionalEventa, u as InvokeEventConstraint, v as or } from "./eventa-DSnoBa1O.mjs";
|
|
2
|
+
import { n as EventContextEmitFn, r as createContext, t as EventContext } from "./context-BsqFeoer.mjs";
|
|
3
|
+
import { $ as isReceiveEvent, A as defineInvokeHandlers, B as InferSendEventStreamEnd, C as Handler, D as InvokeFunctionMap, E as InvokeFunction, F as InferReceiveEventError, G as ReceiveEventError, H as InvokeEventa, I as InferReceiveEventStreamEnd, J as SendEventAbort, K as ReceiveEventStreamEnd, L as InferSendEvent, M as isExtendableInvokeResponseLike, N as undefineInvokeHandler, O as defineInvoke, P as InferReceiveEvent, Q as isInvokeEventa, R as InferSendEventAbort, S as ExtractInvokeResponseOptions, T as InvocableEventContext, U as InvokeHandlerEventa, V as InvokeEventType, W as ReceiveEvent, X as SendEventStreamEnd, Y as SendEventError, Z as defineInvokeEventa, _ as withRemoteMethods, a as isAbortError, b as ExtendableInvokeResponse, c as randomBetween, d as toStreamHandler, et as isSendEvent, f as InvokeFunctionStubOptions, g as createRemoteMethodTagPrefix, h as RemoteInvokeResult, i as createUntilTriggeredOnce, j as defineInvokes, k as defineInvokeHandler, l as defineStreamInvoke, m as RemoteInvokeOptions, n as createUntil, o as isAsyncIterable, p as RemoteInvokeFunction, q as SendEvent, r as createUntilTriggered, s as isReadableStream, t as createAbortError, u as defineStreamInvokeHandler, v as WithTransfer, w as HandlerMap, x as ExtractInvokeRequestOptions, y as withTransfer, z as InferSendEventError } from "./index-g6DulgOI.mjs";
|
|
4
4
|
export { DirectionalEventa, EventContext, EventContextEmitFn, EventTag, Eventa, EventaFlowDirection, EventaLike, EventaMatchExpression, EventaType, ExtendableInvokeResponse, ExtractInvokeRequestOptions, ExtractInvokeResponseOptions, Handler, HandlerMap, InboundEventa, InferEventaPayload, InferReceiveEvent, InferReceiveEventError, InferReceiveEventStreamEnd, InferSendEvent, InferSendEventAbort, InferSendEventError, InferSendEventStreamEnd, InvocableEventContext, InvokeEventConstraint, InvokeEventType, InvokeEventa, InvokeFunction, InvokeFunctionMap, InvokeFunctionStubOptions, InvokeHandlerEventa, OutboundEventa, ReceiveEvent, ReceiveEventError, ReceiveEventStreamEnd, RemoteInvokeFunction, RemoteInvokeOptions, RemoteInvokeResult, SendEvent, SendEventAbort, SendEventError, SendEventStreamEnd, WithTransfer, and, createAbortError, createContext, createRemoteMethodTagPrefix, createUntil, createUntilTriggered, createUntilTriggeredOnce, defineEventa, defineInboundEventa, defineInvoke, defineInvokeEventa, defineInvokeHandler, defineInvokeHandlers, defineInvokes, defineOutboundEventa, defineStreamInvoke, defineStreamInvokeHandler, isAbortError, isAsyncIterable, isExtendableInvokeResponseLike, isInvokeEventa, isReadableStream, isReceiveEvent, isSendEvent, matchBy, nanoid, or, randomBetween, toStreamHandler, undefineInvokeHandler, withRemoteMethods, withTransfer };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { a as defineEventa, c as matchBy, i as and, l as nanoid, n as EventaFlowDirection, o as defineInboundEventa, r as EventaType, s as defineOutboundEventa, t as createContext, u as or } from "./context-
|
|
2
|
-
import { C as isInvokeEventa, S as defineInvokeEventa, T as isSendEvent, _ as isAbortError, a as withRemoteMethods, b as randomBetween, c as defineInvokeHandler, d as isExtendableInvokeResponseLike, f as undefineInvokeHandler, g as createUntilTriggeredOnce, h as createUntilTriggered, i as createRemoteMethodTagPrefix, l as defineInvokeHandlers, m as createUntil, n as defineStreamInvokeHandler, o as withTransfer, p as createAbortError, r as toStreamHandler, s as defineInvoke, t as defineStreamInvoke, u as defineInvokes, v as isAsyncIterable, w as isReceiveEvent, x as InvokeEventType, y as isReadableStream } from "./src-
|
|
3
|
-
|
|
4
|
-
export { EventaFlowDirection, EventaType, InvokeEventType, and, createAbortError, createContext, createRemoteMethodTagPrefix, createUntil, createUntilTriggered, createUntilTriggeredOnce, defineEventa, defineInboundEventa, defineInvoke, defineInvokeEventa, defineInvokeHandler, defineInvokeHandlers, defineInvokes, defineOutboundEventa, defineStreamInvoke, defineStreamInvokeHandler, isAbortError, isAsyncIterable, isExtendableInvokeResponseLike, isInvokeEventa, isReadableStream, isReceiveEvent, isSendEvent, matchBy, nanoid, or, randomBetween, toStreamHandler, undefineInvokeHandler, withRemoteMethods, withTransfer };
|
|
1
|
+
import { a as defineEventa, c as matchBy, i as and, l as nanoid, n as EventaFlowDirection, o as defineInboundEventa, r as EventaType, s as defineOutboundEventa, t as createContext, u as or } from "./context-Dht_IZMb.mjs";
|
|
2
|
+
import { C as isInvokeEventa, S as defineInvokeEventa, T as isSendEvent, _ as isAbortError, a as withRemoteMethods, b as randomBetween, c as defineInvokeHandler, d as isExtendableInvokeResponseLike, f as undefineInvokeHandler, g as createUntilTriggeredOnce, h as createUntilTriggered, i as createRemoteMethodTagPrefix, l as defineInvokeHandlers, m as createUntil, n as defineStreamInvokeHandler, o as withTransfer, p as createAbortError, r as toStreamHandler, s as defineInvoke, t as defineStreamInvoke, u as defineInvokes, v as isAsyncIterable, w as isReceiveEvent, x as InvokeEventType, y as isReadableStream } from "./src-CTs6h4Ci.mjs";
|
|
3
|
+
export { EventaFlowDirection, EventaType, InvokeEventType, and, createAbortError, createContext, createRemoteMethodTagPrefix, createUntil, createUntilTriggered, createUntilTriggeredOnce, defineEventa, defineInboundEventa, defineInvoke, defineInvokeEventa, defineInvokeHandler, defineInvokeHandlers, defineInvokes, defineOutboundEventa, defineStreamInvoke, defineStreamInvokeHandler, isAbortError, isAsyncIterable, isExtendableInvokeResponseLike, isInvokeEventa, isReadableStream, isReceiveEvent, isSendEvent, matchBy, nanoid, or, randomBetween, toStreamHandler, undefineInvokeHandler, withRemoteMethods, withTransfer };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { l as nanoid } from "./context-
|
|
2
|
-
|
|
1
|
+
import { l as nanoid } from "./context-Dht_IZMb.mjs";
|
|
3
2
|
//#region src/adapters/websocket/internal.ts
|
|
4
3
|
function generateWebsocketPayload(type, payload) {
|
|
5
4
|
return {
|
|
@@ -12,7 +11,7 @@ function generateWebsocketPayload(type, payload) {
|
|
|
12
11
|
function parseWebsocketPayload(data) {
|
|
13
12
|
return JSON.parse(data);
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
//#endregion
|
|
17
15
|
export { parseWebsocketPayload as n, generateWebsocketPayload as t };
|
|
18
|
-
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=internal-CHUsXYiP.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-
|
|
1
|
+
{"version":3,"file":"internal-CHUsXYiP.mjs","names":[],"sources":["../src/adapters/websocket/internal.ts"],"sourcesContent":["import type { EventTag } from '../../eventa'\nimport type { WebsocketPayload } from './shared'\n\nimport { nanoid } from '../../eventa'\n\nexport function generateWebsocketPayload<T>(type: EventTag<any, any>, payload: T): WebsocketPayload<T> {\n return {\n id: nanoid(),\n type,\n payload,\n timestamp: Date.now(),\n }\n}\n\nexport function parseWebsocketPayload<T>(data: string): WebsocketPayload<T> {\n return JSON.parse(data) as WebsocketPayload<T>\n}\n"],"mappings":";;AAKA,SAAgB,yBAA4B,MAA0B,SAAiC;AACrG,QAAO;EACL,IAAI,QAAQ;EACZ;EACA;EACA,WAAW,KAAK,KAAK;EACtB;;AAGH,SAAgB,sBAAyB,MAAmC;AAC1E,QAAO,KAAK,MAAM,KAAK"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { a as defineEventa, l as nanoid, s as defineOutboundEventa } from "./context-
|
|
2
|
-
import { d as isExtendableInvokeResponseLike } from "./src-
|
|
3
|
-
|
|
1
|
+
import { a as defineEventa, l as nanoid, s as defineOutboundEventa } from "./context-Dht_IZMb.mjs";
|
|
2
|
+
import { d as isExtendableInvokeResponseLike } from "./src-CTs6h4Ci.mjs";
|
|
4
3
|
//#region src/adapters/webworkers/internal.ts
|
|
5
4
|
function generateWorkerPayload(type, payload) {
|
|
6
5
|
return {
|
|
@@ -12,7 +11,6 @@ function generateWorkerPayload(type, payload) {
|
|
|
12
11
|
function parseWorkerPayload(data) {
|
|
13
12
|
return data;
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
//#endregion
|
|
17
15
|
//#region src/adapters/webworkers/shared.ts
|
|
18
16
|
function defineWorkerEventa(id) {
|
|
@@ -31,7 +29,7 @@ function isWorkerEventa(event) {
|
|
|
31
29
|
return typeof event === "object" && "_workerTransfer" in event && typeof event._workerTransfer === "boolean" && event._workerTransfer === true;
|
|
32
30
|
}
|
|
33
31
|
const workerErrorEvent = defineEventa();
|
|
34
|
-
|
|
32
|
+
defineEventa();
|
|
35
33
|
function normalizeOnListenerParameters(event, options) {
|
|
36
34
|
let eventPayload = event.body;
|
|
37
35
|
let transfer;
|
|
@@ -59,7 +57,7 @@ function normalizeOnListenerParameters(event, options) {
|
|
|
59
57
|
transfer
|
|
60
58
|
};
|
|
61
59
|
}
|
|
62
|
-
|
|
63
60
|
//#endregion
|
|
64
61
|
export { workerErrorEvent as a, normalizeOnListenerParameters as i, defineWorkerEventa as n, generateWorkerPayload as o, isWorkerEventa as r, parseWorkerPayload as s, defineOutboundWorkerEventa as t };
|
|
65
|
-
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=shared-CA5MGwv0.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-CA5MGwv0.mjs","names":[],"sources":["../src/adapters/webworkers/internal.ts","../src/adapters/webworkers/shared.ts"],"sourcesContent":["import type { EventTag } from '../..'\nimport type { WorkerPayload } from './shared'\n\nimport { nanoid } from '../..'\n\nexport function generateWorkerPayload<T>(type: EventTag<any, any>, payload: T): WorkerPayload<T> {\n return {\n id: nanoid(),\n type,\n payload,\n }\n}\n\nexport function parseWorkerPayload<T>(data: unknown): WorkerPayload<T> {\n return data as WorkerPayload<T>\n}\n","import type { EventContext } from '../../context'\nimport type { Eventa, EventTag } from '../../eventa'\n\nimport { defineEventa, defineOutboundEventa } from '../../eventa'\nimport { isExtendableInvokeResponseLike } from '../../invoke'\n\nexport interface WorkerPayload<T> {\n id: string\n type: EventTag<any, any>\n payload: T\n transfer?: Transferable[]\n}\n\nexport interface WorkerEventa<T> extends Eventa<{ message: T, transfer?: Transferable[] }> {\n _workerTransfer: true\n}\n\nexport function defineWorkerEventa<T>(id?: string): WorkerEventa<T> {\n return {\n ...defineEventa<{ message: T, transfer?: Transferable[] }>(id),\n _workerTransfer: true,\n }\n}\n\nexport function defineOutboundWorkerEventa<T>(id?: string): WorkerEventa<T> {\n return {\n ...defineOutboundEventa<{ message: T, transfer?: Transferable[] }>(id),\n _workerTransfer: true,\n }\n}\n\nexport function isWorkerEventa(event: Eventa<any>): event is WorkerEventa<any> {\n return typeof event === 'object'\n && '_workerTransfer' in event\n && typeof event._workerTransfer === 'boolean'\n && event._workerTransfer === true\n}\n\nexport const workerErrorEvent = defineEventa<{ error: unknown }>()\nexport const workerMessageErrorEvent = defineEventa<{ error: unknown, message: any }>()\n\nexport function normalizeOnListenerParameters(event: Eventa<any>, options?: { transfer?: Transferable[] } | unknown) {\n let eventPayload: any = event.body\n let transfer: Transferable[] | undefined\n\n if (isExtendableInvokeResponseLike<unknown, EventContext<{ invokeResponse?: { transfer?: Transferable[] } }>>(event)) {\n if (event.body!.content.invokeResponse?.transfer != null) {\n transfer = event.body!.content.invokeResponse!.transfer\n delete event.body!.content.invokeResponse\n }\n\n eventPayload = { ...event.body, content: event.body!.content.response }\n delete eventPayload.content.response\n }\n else if (isWorkerEventa(event)) {\n transfer = event.body?.transfer\n delete event.body?.transfer\n\n eventPayload = event.body?.message\n delete event.body?.message\n }\n\n // Override from options\n if (typeof options !== 'undefined' && options != null && typeof options === 'object' && 'transfer' in options) {\n if (Array.isArray(options.transfer)) {\n transfer = options.transfer\n }\n }\n\n return {\n body: eventPayload,\n transfer,\n }\n}\n"],"mappings":";;;AAKA,SAAgB,sBAAyB,MAA0B,SAA8B;AAC/F,QAAO;EACL,IAAI,QAAQ;EACZ;EACA;EACD;;AAGH,SAAgB,mBAAsB,MAAiC;AACrE,QAAO;;;;ACGT,SAAgB,mBAAsB,IAA8B;AAClE,QAAO;EACL,GAAG,aAAwD,GAAG;EAC9D,iBAAiB;EAClB;;AAGH,SAAgB,2BAA8B,IAA8B;AAC1E,QAAO;EACL,GAAG,qBAAgE,GAAG;EACtE,iBAAiB;EAClB;;AAGH,SAAgB,eAAe,OAAgD;AAC7E,QAAO,OAAO,UAAU,YACnB,qBAAqB,SACrB,OAAO,MAAM,oBAAoB,aACjC,MAAM,oBAAoB;;AAGjC,MAAa,mBAAmB,cAAkC;AAC3B,cAAgD;AAEvF,SAAgB,8BAA8B,OAAoB,SAAmD;CACnH,IAAI,eAAoB,MAAM;CAC9B,IAAI;AAEJ,KAAI,+BAA0G,MAAM,EAAE;AACpH,MAAI,MAAM,KAAM,QAAQ,gBAAgB,YAAY,MAAM;AACxD,cAAW,MAAM,KAAM,QAAQ,eAAgB;AAC/C,UAAO,MAAM,KAAM,QAAQ;;AAG7B,iBAAe;GAAE,GAAG,MAAM;GAAM,SAAS,MAAM,KAAM,QAAQ;GAAU;AACvE,SAAO,aAAa,QAAQ;YAErB,eAAe,MAAM,EAAE;AAC9B,aAAW,MAAM,MAAM;AACvB,SAAO,MAAM,MAAM;AAEnB,iBAAe,MAAM,MAAM;AAC3B,SAAO,MAAM,MAAM;;AAIrB,KAAI,OAAO,YAAY,eAAe,WAAW,QAAQ,OAAO,YAAY,YAAY,cAAc;MAChG,MAAM,QAAQ,QAAQ,SAAS,CACjC,YAAW,QAAQ;;AAIvB,QAAO;EACL,MAAM;EACN;EACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as EventTag, r as Eventa } from "./eventa-
|
|
1
|
+
import { n as EventTag, r as Eventa } from "./eventa-DSnoBa1O.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/adapters/webworkers/shared.d.ts
|
|
4
4
|
interface WorkerPayload<T> {
|
|
@@ -31,4 +31,4 @@ declare function normalizeOnListenerParameters(event: Eventa<any>, options?: {
|
|
|
31
31
|
};
|
|
32
32
|
//#endregion
|
|
33
33
|
export { isWorkerEventa as a, workerMessageErrorEvent as c, defineWorkerEventa as i, WorkerPayload as n, normalizeOnListenerParameters as o, defineOutboundWorkerEventa as r, workerErrorEvent as s, WorkerEventa as t };
|
|
34
|
-
//# sourceMappingURL=shared-
|
|
34
|
+
//# sourceMappingURL=shared-CVTLm458.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as EventTag, s as EventaType } from "./eventa-
|
|
1
|
+
import { n as EventTag, s as EventaType } from "./eventa-DSnoBa1O.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/adapters/electron/shared.d.ts
|
|
4
4
|
interface Payload<T> {
|
|
@@ -17,4 +17,4 @@ declare const errorEvent: {
|
|
|
17
17
|
};
|
|
18
18
|
//#endregion
|
|
19
19
|
export { errorEvent as n, Payload as t };
|
|
20
|
-
//# sourceMappingURL=shared-
|
|
20
|
+
//# sourceMappingURL=shared-CfXZb-7K.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as defineEventa, l as nanoid } from "./context-
|
|
2
|
-
|
|
1
|
+
import { a as defineEventa, l as nanoid } from "./context-Dht_IZMb.mjs";
|
|
2
|
+
import "./src-CTs6h4Ci.mjs";
|
|
3
3
|
//#region src/adapters/electron/internal.ts
|
|
4
4
|
function generatePayload(type, payload) {
|
|
5
5
|
return {
|
|
@@ -11,11 +11,10 @@ function generatePayload(type, payload) {
|
|
|
11
11
|
function parsePayload(data) {
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
14
|
//#endregion
|
|
16
15
|
//#region src/adapters/electron/shared.ts
|
|
17
16
|
const errorEvent = { ...defineEventa() };
|
|
18
|
-
|
|
19
17
|
//#endregion
|
|
20
18
|
export { generatePayload as n, parsePayload as r, errorEvent as t };
|
|
21
|
-
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=shared-Dl0_bFq0.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-Dl0_bFq0.mjs","names":[],"sources":["../src/adapters/electron/internal.ts","../src/adapters/electron/shared.ts"],"sourcesContent":["import type { EventTag } from '../..'\nimport type { Payload as CustomEventDetailDetail } from './shared'\n\nimport { nanoid } from '../..'\n\nexport function generatePayload<T>(type: EventTag<any, any>, payload: T): CustomEventDetailDetail<T> {\n return {\n id: nanoid(),\n type,\n payload,\n }\n}\n\nexport function parsePayload<T>(data: unknown): CustomEventDetailDetail<T> {\n return data as CustomEventDetailDetail<T>\n}\n","import type { EventTag } from '../../eventa'\n\nimport { defineEventa } from '../../eventa'\n\nexport interface Payload<T> {\n id: string\n type: EventTag<any, any>\n payload: T\n}\n\nexport const errorEvent = { ...defineEventa<{ error: unknown }>() }\n"],"mappings":";;;AAKA,SAAgB,gBAAmB,MAA0B,SAAwC;AACnG,QAAO;EACL,IAAI,QAAQ;EACZ;EACA;EACD;;AAGH,SAAgB,aAAgB,MAA2C;AACzE,QAAO;;;;ACJT,MAAa,aAAa,EAAE,GAAG,cAAkC,EAAE"}
|