@moeru/eventa 1.0.0-beta.2 → 1.0.0-beta.3
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 +3 -0
- package/dist/adapters/broadcast-channel/index.d.mts +4 -2
- package/dist/adapters/broadcast-channel/index.mjs +2 -2
- package/dist/adapters/electron/main.d.mts +2 -2
- package/dist/adapters/electron/main.mjs +3 -3
- package/dist/adapters/electron/renderer.d.mts +2 -2
- package/dist/adapters/electron/renderer.mjs +3 -3
- package/dist/adapters/event-emitter/index.d.mts +4 -2
- package/dist/adapters/event-emitter/index.mjs +2 -2
- package/dist/adapters/event-target/index.d.mts +4 -2
- package/dist/adapters/event-target/index.mjs +2 -2
- package/dist/adapters/websocket/h3/index.d.mts +8 -8
- package/dist/adapters/websocket/h3/index.mjs +2 -2
- package/dist/adapters/websocket/index.d.mts +1 -1
- package/dist/adapters/websocket/native/index.d.mts +5 -5
- package/dist/adapters/websocket/native/index.mjs +2 -2
- package/dist/adapters/webworkers/index.d.mts +2 -2
- package/dist/adapters/webworkers/index.mjs +3 -3
- package/dist/adapters/webworkers/worker/index.d.mts +1 -1
- package/dist/adapters/webworkers/worker/index.mjs +3 -3
- package/dist/adapters/worker-threads/index.d.mts +2 -2
- package/dist/adapters/worker-threads/index.mjs +3 -3
- package/dist/adapters/worker-threads/worker/index.d.mts +1 -1
- package/dist/adapters/worker-threads/worker/index.mjs +3 -3
- package/dist/{context-ZVv99bcM.d.mts → context-BNM9nsGp.d.mts} +2 -2
- package/dist/{context-BMDJMapI.mjs → context-c10xPp3f.mjs} +10 -5
- package/dist/context-c10xPp3f.mjs.map +1 -0
- package/dist/eventa-M1FMVrH1.d.mts +106 -0
- package/dist/{index-CI_gUGXg.d.mts → index-giKJThn3.d.mts} +73 -61
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2 -2
- package/dist/{internal-ChLglF1N.mjs → internal-C-4X8bpL.mjs} +2 -2
- package/dist/{internal-ChLglF1N.mjs.map → internal-C-4X8bpL.mjs.map} +1 -1
- package/dist/{shared-DgX1R_nY.d.mts → shared-BcRXZZxh.d.mts} +4 -4
- package/dist/{shared-CA_i_yfR.mjs → shared-DeDRsHPI.mjs} +2 -2
- package/dist/{shared-CA_i_yfR.mjs.map → shared-DeDRsHPI.mjs.map} +1 -1
- package/dist/{shared-Cd4CLAdD.d.mts → shared-NFMSqOPw.d.mts} +4 -2
- package/dist/{shared-CRxfs1TC.mjs → shared-eQ-hnVHv.mjs} +3 -3
- package/dist/{shared-CRxfs1TC.mjs.map → shared-eQ-hnVHv.mjs.map} +1 -1
- package/dist/{src-eMqISeHo.mjs → src-CTkYOGiO.mjs} +137 -114
- package/dist/src-CTkYOGiO.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/context-BMDJMapI.mjs.map +0 -1
- package/dist/eventa-AJyw28P8.d.mts +0 -52
- package/dist/src-eMqISeHo.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
[![bundle][bundle-src]][bundle-href]
|
|
6
6
|
[![JSDocs][jsdocs-src]][jsdocs-href]
|
|
7
7
|
[![License][license-src]][license-href]
|
|
8
|
+
[![Ask DeepWiki][deepwiki-src]][deepwiki-href]
|
|
8
9
|
|
|
9
10
|
Transport-aware events powering ergonomic RPC and streaming flows.
|
|
10
11
|
|
|
@@ -529,3 +530,5 @@ MIT
|
|
|
529
530
|
[license-href]: https://github.com/moeru-ai/eventa/blob/main/LICENSE
|
|
530
531
|
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
|
|
531
532
|
[jsdocs-href]: https://www.jsdocs.io/package/@moeru/eventa
|
|
533
|
+
[deepwiki-src]: https://deepwiki.com/badge.svg
|
|
534
|
+
[deepwiki-href]: https://deepwiki.com/moeru-ai/eventa
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as EventTag, s as EventaType } from "../../eventa-
|
|
2
|
-
import { t as EventContext } from "../../context-
|
|
1
|
+
import { n as EventTag, s as EventaType } from "../../eventa-M1FMVrH1.mjs";
|
|
2
|
+
import { t as EventContext } from "../../context-BNM9nsGp.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/broadcast-channel/shared.d.ts
|
|
5
5
|
interface Payload<T> {
|
|
@@ -11,6 +11,8 @@ declare const errorEvent: {
|
|
|
11
11
|
body?: {
|
|
12
12
|
error: unknown;
|
|
13
13
|
} | undefined;
|
|
14
|
+
metadata?: undefined;
|
|
15
|
+
invokeMetadata?: undefined;
|
|
14
16
|
id: string;
|
|
15
17
|
type?: EventaType.Event | undefined;
|
|
16
18
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as defineEventa, c as matchBy, i as and, l as nanoid, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../context-
|
|
2
|
-
import "../../src-
|
|
1
|
+
import { a as defineEventa, c as matchBy, i as and, l as nanoid, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../context-c10xPp3f.mjs";
|
|
2
|
+
import "../../src-CTkYOGiO.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/broadcast-channel/internal.ts
|
|
5
5
|
function generatePayload(type, payload) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as EventContext } from "../../context-
|
|
2
|
-
import { n as errorEvent, t as Payload } from "../../shared-
|
|
1
|
+
import { t as EventContext } from "../../context-BNM9nsGp.mjs";
|
|
2
|
+
import { n as errorEvent, t as Payload } from "../../shared-NFMSqOPw.mjs";
|
|
3
3
|
import { BrowserWindow, IpcMain, IpcMainEvent } from "electron";
|
|
4
4
|
|
|
5
5
|
//#region src/adapters/electron/main.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as matchBy, i as and, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../context-
|
|
2
|
-
import "../../src-
|
|
3
|
-
import { n as generatePayload, r as parsePayload, t as errorEvent } from "../../shared-
|
|
1
|
+
import { c as matchBy, i as and, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../context-c10xPp3f.mjs";
|
|
2
|
+
import "../../src-CTkYOGiO.mjs";
|
|
3
|
+
import { n as generatePayload, r as parsePayload, t as errorEvent } from "../../shared-DeDRsHPI.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/adapters/electron/main.ts
|
|
6
6
|
function withRemoval(ipcMain, type, listener) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as EventContext } from "../../context-
|
|
2
|
-
import { n as errorEvent, t as Payload } from "../../shared-
|
|
1
|
+
import { t as EventContext } from "../../context-BNM9nsGp.mjs";
|
|
2
|
+
import { n as errorEvent, t as Payload } from "../../shared-NFMSqOPw.mjs";
|
|
3
3
|
import { IpcRenderer, IpcRendererListener } from "@electron-toolkit/preload";
|
|
4
4
|
|
|
5
5
|
//#region src/adapters/electron/renderer.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as matchBy, i as and, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../context-
|
|
2
|
-
import "../../src-
|
|
3
|
-
import { n as generatePayload, r as parsePayload, t as errorEvent } from "../../shared-
|
|
1
|
+
import { c as matchBy, i as and, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../context-c10xPp3f.mjs";
|
|
2
|
+
import "../../src-CTkYOGiO.mjs";
|
|
3
|
+
import { n as generatePayload, r as parsePayload, t as errorEvent } from "../../shared-DeDRsHPI.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/adapters/electron/renderer.ts
|
|
6
6
|
function createContext(ipcRenderer, options) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as EventTag, s as EventaType } from "../../eventa-
|
|
2
|
-
import { t as EventContext } from "../../context-
|
|
1
|
+
import { n as EventTag, s as EventaType } from "../../eventa-M1FMVrH1.mjs";
|
|
2
|
+
import { t as EventContext } from "../../context-BNM9nsGp.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/event-emitter/shared.d.ts
|
|
5
5
|
interface Payload<T> {
|
|
@@ -11,6 +11,8 @@ declare const errorEvent: {
|
|
|
11
11
|
body?: {
|
|
12
12
|
error: unknown;
|
|
13
13
|
} | undefined;
|
|
14
|
+
metadata?: undefined;
|
|
15
|
+
invokeMetadata?: undefined;
|
|
14
16
|
id: string;
|
|
15
17
|
type?: EventaType.Event | undefined;
|
|
16
18
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as defineEventa, c as matchBy, i as and, l as nanoid, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../context-
|
|
2
|
-
import "../../src-
|
|
1
|
+
import { a as defineEventa, c as matchBy, i as and, l as nanoid, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../context-c10xPp3f.mjs";
|
|
2
|
+
import "../../src-CTkYOGiO.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/event-emitter/internal.ts
|
|
5
5
|
function generatePayload(type, payload) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as EventTag, s as EventaType } from "../../eventa-
|
|
2
|
-
import { t as EventContext } from "../../context-
|
|
1
|
+
import { n as EventTag, s as EventaType } from "../../eventa-M1FMVrH1.mjs";
|
|
2
|
+
import { t as EventContext } from "../../context-BNM9nsGp.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/event-target/shared.d.ts
|
|
5
5
|
interface CustomEventDetail<T> {
|
|
@@ -11,6 +11,8 @@ declare const workerErrorEvent: {
|
|
|
11
11
|
body?: {
|
|
12
12
|
error: unknown;
|
|
13
13
|
} | undefined;
|
|
14
|
+
metadata?: undefined;
|
|
15
|
+
invokeMetadata?: undefined;
|
|
14
16
|
id: string;
|
|
15
17
|
type?: EventaType.Event | undefined;
|
|
16
18
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
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$1 } from "../../context-
|
|
2
|
-
import "../../src-
|
|
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$1 } from "../../context-c10xPp3f.mjs";
|
|
2
|
+
import "../../src-CTkYOGiO.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/event-target/internal.ts
|
|
5
5
|
function generateCustomEventDetail(type, payload) {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { r as Eventa } from "../../../eventa-
|
|
2
|
-
import { t as EventContext } from "../../../context-
|
|
1
|
+
import { r as Eventa } from "../../../eventa-M1FMVrH1.mjs";
|
|
2
|
+
import { t as EventContext } from "../../../context-BNM9nsGp.mjs";
|
|
3
3
|
import { Hooks, Message, Peer, WSError } from "crossws";
|
|
4
4
|
|
|
5
5
|
//#region src/adapters/websocket/h3/global.d.ts
|
|
6
6
|
declare const wsConnectedEvent: Eventa<{
|
|
7
7
|
id: string;
|
|
8
|
-
}>;
|
|
8
|
+
}, undefined, undefined>;
|
|
9
9
|
declare const wsDisconnectedEvent: Eventa<{
|
|
10
10
|
id: string;
|
|
11
|
-
}>;
|
|
11
|
+
}, undefined, undefined>;
|
|
12
12
|
declare const wsErrorEvent: Eventa<{
|
|
13
13
|
error: unknown;
|
|
14
|
-
}>;
|
|
14
|
+
}, undefined, undefined>;
|
|
15
15
|
declare function createGlobalContext(): {
|
|
16
16
|
websocketHandlers: Omit<Hooks, 'upgrade'>;
|
|
17
17
|
context: EventContext<any, {
|
|
@@ -25,13 +25,13 @@ declare function createGlobalContext(): {
|
|
|
25
25
|
//#region src/adapters/websocket/h3/peer.d.ts
|
|
26
26
|
declare const wsConnectedEvent$1: Eventa<{
|
|
27
27
|
id: string;
|
|
28
|
-
}>;
|
|
28
|
+
}, undefined, undefined>;
|
|
29
29
|
declare const wsDisconnectedEvent$1: Eventa<{
|
|
30
30
|
id: string;
|
|
31
|
-
}>;
|
|
31
|
+
}, undefined, undefined>;
|
|
32
32
|
declare const wsErrorEvent$1: Eventa<{
|
|
33
33
|
error: unknown;
|
|
34
|
-
}>;
|
|
34
|
+
}, undefined, undefined>;
|
|
35
35
|
declare function createPeerContext(peer: Peer): {
|
|
36
36
|
hooks: Pick<Hooks, 'message'>;
|
|
37
37
|
context: EventContext<any, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as defineEventa, c as matchBy, i as and, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext } from "../../../context-
|
|
2
|
-
import { n as parseWebsocketPayload, t as generateWebsocketPayload } from "../../../internal-
|
|
1
|
+
import { a as defineEventa, c as matchBy, i as and, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext } from "../../../context-c10xPp3f.mjs";
|
|
2
|
+
import { n as parseWebsocketPayload, t as generateWebsocketPayload } from "../../../internal-C-4X8bpL.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/websocket/h3/global.ts
|
|
5
5
|
const wsConnectedEvent = defineEventa("eventa:adapters:websocket-global:connected");
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { r as Eventa } from "../../../eventa-
|
|
2
|
-
import { t as EventContext } from "../../../context-
|
|
1
|
+
import { r as Eventa } from "../../../eventa-M1FMVrH1.mjs";
|
|
2
|
+
import { t as EventContext } from "../../../context-BNM9nsGp.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/websocket/native/index.d.ts
|
|
5
5
|
declare const wsConnectedEvent: Eventa<{
|
|
6
6
|
url: string;
|
|
7
|
-
}>;
|
|
7
|
+
}, undefined, undefined>;
|
|
8
8
|
declare const wsDisconnectedEvent: Eventa<{
|
|
9
9
|
url: string;
|
|
10
|
-
}>;
|
|
10
|
+
}, undefined, undefined>;
|
|
11
11
|
declare const wsErrorEvent: Eventa<{
|
|
12
12
|
error: unknown;
|
|
13
|
-
}>;
|
|
13
|
+
}, undefined, undefined>;
|
|
14
14
|
declare function createContext(wsConn: WebSocket): {
|
|
15
15
|
context: EventContext<any, {
|
|
16
16
|
raw: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as defineEventa, c as matchBy, i as and, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../../context-
|
|
2
|
-
import { n as parseWebsocketPayload, t as generateWebsocketPayload } from "../../../internal-
|
|
1
|
+
import { a as defineEventa, c as matchBy, i as and, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../../context-c10xPp3f.mjs";
|
|
2
|
+
import { n as parseWebsocketPayload, t as generateWebsocketPayload } from "../../../internal-C-4X8bpL.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/websocket/native/index.ts
|
|
5
5
|
const wsConnectedEvent = defineEventa();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as EventContext } from "../../context-
|
|
2
|
-
import { a as isWorkerEventa, c as workerMessageErrorEvent, i as defineWorkerEventa, n as WorkerPayload, o as normalizeOnListenerParameters, r as defineOutboundWorkerEventa, s as workerErrorEvent, t as WorkerEventa } from "../../shared-
|
|
1
|
+
import { t as EventContext } from "../../context-BNM9nsGp.mjs";
|
|
2
|
+
import { a as isWorkerEventa, c as workerMessageErrorEvent, i as defineWorkerEventa, n as WorkerPayload, o as normalizeOnListenerParameters, r as defineOutboundWorkerEventa, s as workerErrorEvent, t as WorkerEventa } from "../../shared-BcRXZZxh.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/webworkers/index.d.ts
|
|
5
5
|
declare function createContext(worker: Worker): {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as matchBy, i as and, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../context-
|
|
2
|
-
import { E as registerInvokeAbortEventListeners } from "../../src-
|
|
3
|
-
import { a as workerErrorEvent, i as normalizeOnListenerParameters, n as defineWorkerEventa, o as generateWorkerPayload, r as isWorkerEventa, s as parseWorkerPayload, t as defineOutboundWorkerEventa } from "../../shared-
|
|
1
|
+
import { c as matchBy, i as and, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../context-c10xPp3f.mjs";
|
|
2
|
+
import { E as registerInvokeAbortEventListeners } from "../../src-CTkYOGiO.mjs";
|
|
3
|
+
import { a as workerErrorEvent, i as normalizeOnListenerParameters, n as defineWorkerEventa, o as generateWorkerPayload, r as isWorkerEventa, s as parseWorkerPayload, t as defineOutboundWorkerEventa } from "../../shared-eQ-hnVHv.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/adapters/webworkers/index.ts
|
|
6
6
|
function createContext(worker) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as matchBy, i as and, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../../context-
|
|
2
|
-
import { E as registerInvokeAbortEventListeners } from "../../../src-
|
|
3
|
-
import { a as workerErrorEvent, i as normalizeOnListenerParameters, o as generateWorkerPayload, r as isWorkerEventa, s as parseWorkerPayload } from "../../../shared-
|
|
1
|
+
import { c as matchBy, i as and, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../../context-c10xPp3f.mjs";
|
|
2
|
+
import { E as registerInvokeAbortEventListeners } from "../../../src-CTkYOGiO.mjs";
|
|
3
|
+
import { a as workerErrorEvent, i as normalizeOnListenerParameters, o as generateWorkerPayload, r as isWorkerEventa, s as parseWorkerPayload } from "../../../shared-eQ-hnVHv.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/adapters/webworkers/worker/index.ts
|
|
6
6
|
function createContext(options) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as EventContext } from "../../context-
|
|
2
|
-
import { a as isWorkerEventa, c as workerMessageErrorEvent, i as defineWorkerEventa, n as WorkerPayload, o as normalizeOnListenerParameters, r as defineOutboundWorkerEventa, s as workerErrorEvent, t as WorkerEventa } from "../../shared-
|
|
1
|
+
import { t as EventContext } from "../../context-BNM9nsGp.mjs";
|
|
2
|
+
import { a as isWorkerEventa, c as workerMessageErrorEvent, i as defineWorkerEventa, n as WorkerPayload, o as normalizeOnListenerParameters, r as defineOutboundWorkerEventa, s as workerErrorEvent, t as WorkerEventa } from "../../shared-BcRXZZxh.mjs";
|
|
3
3
|
import { Transferable, Worker } from "node:worker_threads";
|
|
4
4
|
|
|
5
5
|
//#region src/adapters/worker-threads/index.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as matchBy, i as and, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../context-
|
|
2
|
-
import { E as registerInvokeAbortEventListeners } from "../../src-
|
|
3
|
-
import { a as workerErrorEvent, i as normalizeOnListenerParameters, n as defineWorkerEventa, o as generateWorkerPayload, r as isWorkerEventa, s as parseWorkerPayload, t as defineOutboundWorkerEventa } from "../../shared-
|
|
1
|
+
import { c as matchBy, i as and, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../context-c10xPp3f.mjs";
|
|
2
|
+
import { E as registerInvokeAbortEventListeners } from "../../src-CTkYOGiO.mjs";
|
|
3
|
+
import { a as workerErrorEvent, i as normalizeOnListenerParameters, n as defineWorkerEventa, o as generateWorkerPayload, r as isWorkerEventa, s as parseWorkerPayload, t as defineOutboundWorkerEventa } from "../../shared-eQ-hnVHv.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/adapters/worker-threads/index.ts
|
|
6
6
|
function createContext(worker) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as matchBy, i as and, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../../context-
|
|
2
|
-
import { E as registerInvokeAbortEventListeners } from "../../../src-
|
|
3
|
-
import { a as workerErrorEvent, i as normalizeOnListenerParameters, o as generateWorkerPayload, r as isWorkerEventa, s as parseWorkerPayload } from "../../../shared-
|
|
1
|
+
import { c as matchBy, i as and, n as EventaFlowDirection, o as defineInboundEventa, s as defineOutboundEventa, t as createContext$1 } from "../../../context-c10xPp3f.mjs";
|
|
2
|
+
import { E as registerInvokeAbortEventListeners } from "../../../src-CTkYOGiO.mjs";
|
|
3
|
+
import { a as workerErrorEvent, i as normalizeOnListenerParameters, o as generateWorkerPayload, r as isWorkerEventa, s as parseWorkerPayload } from "../../../shared-eQ-hnVHv.mjs";
|
|
4
4
|
import { parentPort } from "node:worker_threads";
|
|
5
5
|
|
|
6
6
|
//#region src/adapters/worker-threads/worker/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as EventTag, o as EventaMatchExpression, r as Eventa } from "./eventa-
|
|
1
|
+
import { n as EventTag, o as EventaMatchExpression, r as Eventa } from "./eventa-M1FMVrH1.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/context-hooks.d.ts
|
|
4
4
|
interface EventaAdapterProps<EmitOptions = any> {
|
|
@@ -41,4 +41,4 @@ interface EventContext<Extensions = undefined, EmitOptions = undefined> {
|
|
|
41
41
|
type EventContextEmitFn = EventContext['emit'];
|
|
42
42
|
//#endregion
|
|
43
43
|
export { EventContextEmitFn as n, createContext as r, EventContext as t };
|
|
44
|
-
//# sourceMappingURL=context-
|
|
44
|
+
//# sourceMappingURL=context-BNM9nsGp.d.mts.map
|
|
@@ -27,12 +27,17 @@ function defineOutboundEventa(id) {
|
|
|
27
27
|
_flowDirection: EventaFlowDirection.Outbound
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
function defineEventa(id) {
|
|
30
|
+
function defineEventa(id, options) {
|
|
31
31
|
if (!id) id = nanoid();
|
|
32
|
-
|
|
33
|
-
id,
|
|
34
|
-
type: EventaType.Event
|
|
32
|
+
const eventaObj = {
|
|
33
|
+
id: options?.inheritFrom?.id || id,
|
|
34
|
+
type: options?.inheritFrom?.type || EventaType.Event
|
|
35
35
|
};
|
|
36
|
+
const metadata = options?.inheritFrom?.metadata || options?.metadata;
|
|
37
|
+
if (metadata) eventaObj.metadata = metadata;
|
|
38
|
+
const invokeMetadata = options?.inheritFrom?.invokeMetadata || options?.invokeMetadata;
|
|
39
|
+
if (invokeMetadata) eventaObj.invokeMetadata = invokeMetadata;
|
|
40
|
+
return eventaObj;
|
|
36
41
|
}
|
|
37
42
|
function and(...matchExpression) {
|
|
38
43
|
return {
|
|
@@ -188,4 +193,4 @@ function createContext(props = {}) {
|
|
|
188
193
|
|
|
189
194
|
//#endregion
|
|
190
195
|
export { defineEventa as a, matchBy as c, and as i, nanoid as l, EventaFlowDirection as n, defineInboundEventa as o, EventaType as r, defineOutboundEventa as s, createContext as t, or as u };
|
|
191
|
-
//# sourceMappingURL=context-
|
|
196
|
+
//# sourceMappingURL=context-c10xPp3f.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-c10xPp3f.mjs","names":["eventaObj: Eventa<P, M, IM>","matcher: (event: E) => boolean | Promise<boolean>"],"sources":["../src/eventa.ts","../src/context.ts"],"sourcesContent":["import isGlobMatch from 'picomatch'\n\nimport { customAlphabet } from 'nanoid/non-secure'\n\nexport function nanoid() {\n return customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 16)()\n}\n\nexport interface InvokeEventConstraint<_Req, _Res> {}\n\nexport type EventTag<Res, Req> = string & InvokeEventConstraint<Req, Res>\n\nexport enum EventaType {\n Event = 'event',\n MatchExpression = 'matchExpression',\n}\n\nexport enum EventaFlowDirection {\n Inbound = 'inbound',\n Outbound = 'outbound',\n}\n\nexport interface DirectionalEventa<P, T = undefined> extends Eventa<P> {\n _flowDirection: EventaFlowDirection | T\n}\n\nexport interface InboundEventa<T> extends DirectionalEventa<T> {\n _flowDirection: EventaFlowDirection.Inbound\n}\n\nexport interface OutboundEventa<T> extends DirectionalEventa<T> {\n _flowDirection: EventaFlowDirection.Outbound\n}\n\nexport function defineInboundEventa<T>(id?: string): InboundEventa<T> {\n return {\n ...defineEventa<T>(id),\n _flowDirection: EventaFlowDirection.Inbound,\n } as InboundEventa<T>\n}\n\nexport function defineOutboundEventa<T>(id?: string): OutboundEventa<T> {\n return {\n ...defineEventa<T>(id),\n _flowDirection: EventaFlowDirection.Outbound,\n } as OutboundEventa<T>\n}\n\n// type ServerInvokeHandlerEvent<Req, Res> = symbol & InvokeEventConstraint<Req, Res>\n// type ClientInvoke<Req> = symbol & InvokeEventConstraint<Req, null>\n\nexport interface EventaLike<_P = undefined, T extends EventaType = EventaType> {\n id: string\n type?: T\n}\n\nexport interface Eventa<P = unknown, M = unknown, IM = unknown> extends EventaLike<P, EventaType.Event> {\n body?: P\n /**\n * Optional runtime metadata that can be attached to the eventa.\n *\n * NOTICE: for defineInvoke, and defineInvokeHandler, the metadata will be omitted\n * for smaller chunk size, this means for metadata, the data contains will not be available in the defineInvokeHandler.\n *\n * This can be used for various purposes such as logging, debugging, or providing additional context about the eventa.\n * Allowing the event handler to be able to access this metadata can enable more flexible and powerful event handling logic.\n */\n metadata?: M\n /**\n * Optional runtime metadata that can be attached to the eventa when invoking it.\n *\n * Unlike the `metadata` field, the `invokeMetadata` is specifically designed to be used when invoking the eventa, and it\n * will be available in the defineInvokeHandler.\n *\n * This allows for a clear separation between the metadata that describes the eventa itself and the metadata that is relevant\n * to the invocation of the eventa, providing more flexibility in how metadata is used and accessed within the event\n * handling system.\n */\n invokeMetadata?: IM\n}\n\nexport type InferEventaPayload<E> = E extends Eventa<infer P> ? P : never\n\nexport function defineEventa<P = undefined, M = undefined, IM = undefined>(\n id?: string,\n options?: {\n /**\n * Optionally inherit many properties from another parent eventa.\n */\n inheritFrom?: Eventa<P, M, IM>\n /**\n * Optional runtime metadata that can be attached to the eventa.\n *\n * NOTICE: for defineInvoke, and defineInvokeHandler, the metadata will be omitted\n * for smaller chunk size, this means for metadata, the data contains will not be available in the defineInvokeHandler.\n *\n * This can be used for various purposes such as logging, debugging, or providing additional context about the eventa.\n * Allowing the event handler to be able to access this metadata can enable more flexible and powerful event handling logic.\n */\n metadata?: M\n /**\n * Optional runtime metadata that can be attached to the eventa when invoking it.\n *\n * Unlike the `metadata` field, the `invokeMetadata` is specifically designed to be used when invoking the eventa, and it\n * will be available in the defineInvokeHandler.\n *\n * This allows for a clear separation between the metadata that describes the eventa itself and the metadata that is relevant\n * to the invocation of the eventa, providing more flexibility in how metadata is used and accessed within the event\n * handling system.\n */\n invokeMetadata?: IM\n },\n): Eventa<P, M, IM> {\n if (!id) {\n id = nanoid()\n }\n\n const eventaObj: Eventa<P, M, IM> = {\n id: options?.inheritFrom?.id || id,\n type: options?.inheritFrom?.type || EventaType.Event,\n }\n\n const metadata = options?.inheritFrom?.metadata || options?.metadata\n if (metadata) {\n eventaObj.metadata = metadata\n }\n\n const invokeMetadata = options?.inheritFrom?.invokeMetadata || options?.invokeMetadata\n if (invokeMetadata) {\n eventaObj.invokeMetadata = invokeMetadata\n }\n\n return eventaObj as Eventa<P, M, IM>\n}\n\nexport interface EventaMatchExpression<P = undefined> extends EventaLike<P, EventaType.MatchExpression> {\n matcher?: (event: Eventa<P>) => boolean | Promise<boolean>\n}\n\nexport function and<P>(...matchExpression: Array<EventaMatchExpression<P>>): EventaMatchExpression<P> {\n return {\n id: nanoid(),\n type: EventaType.MatchExpression,\n matcher: (event: Eventa<P>) => {\n return matchExpression.every(m => m.matcher ? m.matcher(event) : false)\n },\n }\n}\n\nexport function or<P>(...matchExpression: Array<EventaMatchExpression<P>>): EventaMatchExpression<P> {\n return {\n id: nanoid(),\n type: EventaType.MatchExpression,\n matcher: (event: Eventa<P>) => {\n return matchExpression.some(m => m.matcher ? m.matcher(event) : false)\n },\n }\n}\n\n/**\n * Match by is powerful utility function that allows you to create a match expression based on various criteria\n * when working with eventa (event system).\n *\n * Semantics like glob matching, RegExp, or even custom matcher function can be used to create complex match\n * expressions that can be used to filter and handle events in a flexible way.\n */\nexport function matchBy<P = undefined>(glob: string, inverted?: boolean): EventaMatchExpression<P>\nexport function matchBy<P = undefined>(options: { ids: string[] }, inverted?: boolean): EventaMatchExpression<P>\nexport function matchBy<P = undefined>(options: { eventa: Eventa<P>[] }, inverted?: boolean): EventaMatchExpression<P>\nexport function matchBy<P = undefined>(options: { types: EventaType[] }, inverted?: boolean): EventaMatchExpression<P>\nexport function matchBy<P = undefined>(regExp: RegExp, inverted?: boolean): EventaMatchExpression<P>\nexport function matchBy<P = undefined, E extends Eventa<P> = Eventa<P>>(matcher: (event: E) => boolean | Promise<boolean>): EventaMatchExpression<P>\nexport function matchBy<P = undefined, E extends Eventa<P> = Eventa<P>>(\n matchExpressionPossibleValues:\n | string\n | Eventa<any>\n | { ids: string[] }\n | { eventa: Eventa<P>[] }\n | { types: EventaType[] }\n | RegExp\n | ((event: E) => boolean | Promise<boolean>),\n inverted?: boolean,\n): EventaMatchExpression<P> {\n const id = nanoid()\n\n let matcher: (event: E) => boolean | Promise<boolean> = () => false\n if (typeof matchExpressionPossibleValues === 'string') {\n matcher = (eventa) => {\n return isGlobMatch(matchExpressionPossibleValues)(eventa.id)\n }\n }\n else if (typeof matchExpressionPossibleValues === 'object') {\n if ('ids' in matchExpressionPossibleValues) {\n matcher = (event: Eventa<P>) => {\n if (inverted) {\n return !matchExpressionPossibleValues.ids.includes(event.id)\n }\n\n return matchExpressionPossibleValues.ids.includes(event.id)\n }\n }\n else if ('eventa' in matchExpressionPossibleValues) {\n matcher = (event: Eventa<P>) => {\n if (inverted) {\n return !matchExpressionPossibleValues.eventa.some(e => e.id === event.id)\n }\n\n return matchExpressionPossibleValues.eventa.some(e => e.id === event.id)\n }\n }\n else if ('types' in matchExpressionPossibleValues) {\n matcher = (event: Eventa<P>) => {\n if (typeof event.type === 'undefined') {\n return false\n }\n if (inverted) {\n return !matchExpressionPossibleValues.types.includes(event.type)\n }\n\n return matchExpressionPossibleValues.types.includes(event.type)\n }\n }\n }\n else if (matchExpressionPossibleValues instanceof RegExp) {\n matcher = (event: Eventa<P>) => {\n if (inverted) {\n return !matchExpressionPossibleValues.test(event.id)\n }\n\n return matchExpressionPossibleValues.test(event.id)\n }\n }\n else if (typeof matchExpressionPossibleValues === 'function') {\n matcher = matchExpressionPossibleValues\n }\n\n return {\n id,\n type: EventaType.MatchExpression,\n matcher,\n } satisfies EventaMatchExpression<P>\n}\n","import type { EventaAdapter } from './context-hooks'\nimport type { Eventa, EventaMatchExpression, EventTag } from './eventa'\n\nimport { EventaType } from './eventa'\n\ninterface CreateContextProps<EmitOptions = any> {\n adapter?: EventaAdapter<EmitOptions>\n}\n\nexport function createContext<Extensions = any, Options = { raw?: any }>(props: CreateContextProps<Options> = {}): EventContext<Extensions, Options> {\n const listeners = new Map<EventTag<any, any>, Set<(params: any, options?: Options) => any>>()\n const onceListeners = new Map<EventTag<any, any>, Set<(params: any, options?: Options) => any>>()\n\n const matchExpressions = new Map<string, EventaMatchExpression<any>>()\n const matchExpressionListeners = new Map<string, Set<(params: any, options?: Options) => any>>()\n const matchExpressionOnceListeners = new Map<string, Set<(params: any, options?: Options) => any>>()\n\n const hooks = props.adapter?.(emit).hooks\n\n function emit<P>(event: Eventa<P>, payload: P, options?: Options) {\n const emittingPayload = { ...event, body: payload }\n\n for (const listener of listeners.get(event.id) || []) {\n listener(emittingPayload, options)\n hooks?.onReceived?.(event.id, emittingPayload)\n }\n\n for (const onceListener of onceListeners.get(event.id) || []) {\n onceListener(emittingPayload, options)\n hooks?.onReceived?.(event.id, emittingPayload)\n onceListeners.get(event.id)?.delete(onceListener)\n }\n\n for (const matchExpression of matchExpressions.values()) {\n if (matchExpression.matcher) {\n const match = matchExpression.matcher(emittingPayload)\n if (!match) {\n continue\n }\n\n for (const listener of matchExpressionListeners.get(matchExpression.id) || []) {\n listener(emittingPayload, options)\n hooks?.onReceived?.(matchExpression.id, emittingPayload)\n }\n for (const onceListener of matchExpressionOnceListeners.get(matchExpression.id) || []) {\n onceListener(emittingPayload, options)\n hooks?.onReceived?.(matchExpression.id, emittingPayload)\n matchExpressionOnceListeners.get(matchExpression.id)?.delete(onceListener)\n }\n }\n }\n\n hooks?.onSent(event.id, emittingPayload, options)\n }\n\n return {\n get listeners() {\n return listeners\n },\n\n get onceListeners() {\n return onceListeners\n },\n\n emit,\n\n on<P>(eventOrMatchExpression: Eventa<P> | EventaMatchExpression<P>, handler: (payload: Eventa<P>, options?: Options) => void): () => void {\n if (eventOrMatchExpression.type === EventaType.Event) {\n const event = eventOrMatchExpression as Eventa<P>\n if (!listeners.has(event.id)) {\n listeners.set(event.id, new Set())\n }\n\n listeners.get(event.id)?.add(handler)\n\n return () => listeners.get(event.id)?.delete(handler)\n }\n\n if (eventOrMatchExpression.type === EventaType.MatchExpression) {\n const matchExpression = eventOrMatchExpression as EventaMatchExpression<P>\n if (!matchExpressions.has(matchExpression.id)) {\n matchExpressions.set(matchExpression.id, matchExpression as EventaMatchExpression<P>)\n }\n if (!matchExpressionListeners.has(matchExpression.id)) {\n matchExpressionListeners.set(matchExpression.id, new Set())\n }\n\n matchExpressionListeners.get(matchExpression.id)?.add(handler)\n\n return () => matchExpressionListeners.get(matchExpression.id)?.delete(handler)\n }\n\n return () => void 0\n },\n\n once<P>(eventOrMatchExpression: Eventa<P> | EventaMatchExpression<P>, handler: (payload: Eventa<P>, options?: Options) => void): () => void {\n if (eventOrMatchExpression.type === EventaType.Event) {\n const event = eventOrMatchExpression as Eventa<P>\n if (!onceListeners.has(event.id)) {\n onceListeners.set(event.id, new Set())\n }\n\n onceListeners.get(event.id)?.add(handler)\n\n return () => onceListeners.get(event.id)?.delete(handler)\n }\n\n if (eventOrMatchExpression.type === EventaType.MatchExpression) {\n const matchExpression = eventOrMatchExpression as EventaMatchExpression<P>\n if (!matchExpressions.has(matchExpression.id)) {\n matchExpressions.set(matchExpression.id, matchExpression as EventaMatchExpression<P>)\n }\n if (!matchExpressionListeners.has(matchExpression.id)) {\n matchExpressionListeners.set(matchExpression.id, new Set())\n }\n\n matchExpressionOnceListeners.get(matchExpression.id)?.add(handler)\n\n return () => matchExpressionOnceListeners.get(matchExpression.id)?.delete(handler)\n }\n\n return () => void 0\n },\n\n off<P>(eventOrMatchExpression: Eventa<P> | EventaMatchExpression<P>, handler?: (payload: Eventa<P>, options?: Options) => void) {\n switch (eventOrMatchExpression.type) {\n case EventaType.Event:\n if (handler !== undefined) {\n listeners.get(eventOrMatchExpression.id)?.delete(handler)\n onceListeners.get(eventOrMatchExpression.id)?.delete(handler)\n break\n }\n\n listeners.delete(eventOrMatchExpression.id)\n onceListeners.delete(eventOrMatchExpression.id)\n break\n case EventaType.MatchExpression:\n if (handler !== undefined) {\n matchExpressionListeners.get(eventOrMatchExpression.id)?.delete(handler)\n matchExpressionOnceListeners.get(eventOrMatchExpression.id)?.delete(handler)\n break\n }\n\n matchExpressionListeners.delete(eventOrMatchExpression.id)\n matchExpressionOnceListeners.delete(eventOrMatchExpression.id)\n break\n }\n },\n }\n}\n\nexport interface EventContext<Extensions = undefined, EmitOptions = undefined> {\n listeners: Map<EventTag<any, any>, Set<(params: any) => any>>\n onceListeners: Map<EventTag<any, any>, Set<(params: any) => any>>\n\n emit: <P>(event: Eventa<P>, payload: P, options?: EmitOptions) => void\n on: <P>(eventOrMatchExpression: Eventa<P> | EventaMatchExpression<P>, handler: (payload: Eventa<P>, options?: EmitOptions) => void) => () => void\n once: <P>(eventOrMatchExpression: Eventa<P> | EventaMatchExpression<P>, handler: (payload: Eventa<P>, options?: EmitOptions) => void) => () => void\n off: <P>(eventOrMatchExpression: Eventa<P> | EventaMatchExpression<P>, handler?: (payload: Eventa<P>, options?: EmitOptions) => void) => void\n\n /**\n * Extensions (adapter-specific).\n *\n * Known usage: webworkers/worker-threads populate internal invoke config via\n * `extensions.__internal.invoke` to abort pending invokes on fatal errors.\n */\n extensions?: Extensions\n}\n\nexport type EventContextEmitFn = EventContext['emit']\n"],"mappings":";;;;AAIA,SAAgB,SAAS;AACvB,QAAO,eAAe,kEAAkE,GAAG,EAAE;;AAO/F,IAAY,oDAAL;AACL;AACA;;;AAGF,IAAY,sEAAL;AACL;AACA;;;AAeF,SAAgB,oBAAuB,IAA+B;AACpE,QAAO;EACL,GAAG,aAAgB,GAAG;EACtB,gBAAgB,oBAAoB;EACrC;;AAGH,SAAgB,qBAAwB,IAAgC;AACtE,QAAO;EACL,GAAG,aAAgB,GAAG;EACtB,gBAAgB,oBAAoB;EACrC;;AAsCH,SAAgB,aACd,IACA,SA2BkB;AAClB,KAAI,CAAC,GACH,MAAK,QAAQ;CAGf,MAAMA,YAA8B;EAClC,IAAI,SAAS,aAAa,MAAM;EAChC,MAAM,SAAS,aAAa,QAAQ,WAAW;EAChD;CAED,MAAM,WAAW,SAAS,aAAa,YAAY,SAAS;AAC5D,KAAI,SACF,WAAU,WAAW;CAGvB,MAAM,iBAAiB,SAAS,aAAa,kBAAkB,SAAS;AACxE,KAAI,eACF,WAAU,iBAAiB;AAG7B,QAAO;;AAOT,SAAgB,IAAO,GAAG,iBAA4E;AACpG,QAAO;EACL,IAAI,QAAQ;EACZ,MAAM,WAAW;EACjB,UAAU,UAAqB;AAC7B,UAAO,gBAAgB,OAAM,MAAK,EAAE,UAAU,EAAE,QAAQ,MAAM,GAAG,MAAM;;EAE1E;;AAGH,SAAgB,GAAM,GAAG,iBAA4E;AACnG,QAAO;EACL,IAAI,QAAQ;EACZ,MAAM,WAAW;EACjB,UAAU,UAAqB;AAC7B,UAAO,gBAAgB,MAAK,MAAK,EAAE,UAAU,EAAE,QAAQ,MAAM,GAAG,MAAM;;EAEzE;;AAgBH,SAAgB,QACd,+BAQA,UAC0B;CAC1B,MAAM,KAAK,QAAQ;CAEnB,IAAIC,gBAA0D;AAC9D,KAAI,OAAO,kCAAkC,SAC3C,YA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Ac,OAAO,uBAAuB,GAAG;AAC/C;IACF,KAAK,WAAW;AACd,SAAI,YAAY,QAAW;AACzB,+BAAyB,IAAI,uBAAuB,GAAG,EAAE,OAAO,QAAQ;AACxE,mCAA6B,IAAI,uBAAuB,GAAG,EAAE,OAAO,QAAQ;AAC5E;;AAGF,8BAAyB,OAAO,uBAAuB,GAAG;AAC1D,kCAA6B,OAAO,uBAAuB,GAAG;AAC9D;;;EAGP"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
//#region src/eventa.d.ts
|
|
2
|
+
declare function nanoid(): string;
|
|
3
|
+
interface InvokeEventConstraint<_Req, _Res> {}
|
|
4
|
+
type EventTag<Res, Req> = string & InvokeEventConstraint<Req, Res>;
|
|
5
|
+
declare enum EventaType {
|
|
6
|
+
Event = "event",
|
|
7
|
+
MatchExpression = "matchExpression",
|
|
8
|
+
}
|
|
9
|
+
declare enum EventaFlowDirection {
|
|
10
|
+
Inbound = "inbound",
|
|
11
|
+
Outbound = "outbound",
|
|
12
|
+
}
|
|
13
|
+
interface DirectionalEventa<P, T = undefined> extends Eventa<P> {
|
|
14
|
+
_flowDirection: EventaFlowDirection | T;
|
|
15
|
+
}
|
|
16
|
+
interface InboundEventa<T> extends DirectionalEventa<T> {
|
|
17
|
+
_flowDirection: EventaFlowDirection.Inbound;
|
|
18
|
+
}
|
|
19
|
+
interface OutboundEventa<T> extends DirectionalEventa<T> {
|
|
20
|
+
_flowDirection: EventaFlowDirection.Outbound;
|
|
21
|
+
}
|
|
22
|
+
declare function defineInboundEventa<T>(id?: string): InboundEventa<T>;
|
|
23
|
+
declare function defineOutboundEventa<T>(id?: string): OutboundEventa<T>;
|
|
24
|
+
interface EventaLike<_P = undefined, T extends EventaType = EventaType> {
|
|
25
|
+
id: string;
|
|
26
|
+
type?: T;
|
|
27
|
+
}
|
|
28
|
+
interface Eventa<P = unknown, M = unknown, IM = unknown> extends EventaLike<P, EventaType.Event> {
|
|
29
|
+
body?: P;
|
|
30
|
+
/**
|
|
31
|
+
* Optional runtime metadata that can be attached to the eventa.
|
|
32
|
+
*
|
|
33
|
+
* NOTICE: for defineInvoke, and defineInvokeHandler, the metadata will be omitted
|
|
34
|
+
* for smaller chunk size, this means for metadata, the data contains will not be available in the defineInvokeHandler.
|
|
35
|
+
*
|
|
36
|
+
* This can be used for various purposes such as logging, debugging, or providing additional context about the eventa.
|
|
37
|
+
* Allowing the event handler to be able to access this metadata can enable more flexible and powerful event handling logic.
|
|
38
|
+
*/
|
|
39
|
+
metadata?: M;
|
|
40
|
+
/**
|
|
41
|
+
* Optional runtime metadata that can be attached to the eventa when invoking it.
|
|
42
|
+
*
|
|
43
|
+
* Unlike the `metadata` field, the `invokeMetadata` is specifically designed to be used when invoking the eventa, and it
|
|
44
|
+
* will be available in the defineInvokeHandler.
|
|
45
|
+
*
|
|
46
|
+
* This allows for a clear separation between the metadata that describes the eventa itself and the metadata that is relevant
|
|
47
|
+
* to the invocation of the eventa, providing more flexibility in how metadata is used and accessed within the event
|
|
48
|
+
* handling system.
|
|
49
|
+
*/
|
|
50
|
+
invokeMetadata?: IM;
|
|
51
|
+
}
|
|
52
|
+
type InferEventaPayload<E> = E extends Eventa<infer P> ? P : never;
|
|
53
|
+
declare function defineEventa<P = undefined, M = undefined, IM = undefined>(id?: string, options?: {
|
|
54
|
+
/**
|
|
55
|
+
* Optionally inherit many properties from another parent eventa.
|
|
56
|
+
*/
|
|
57
|
+
inheritFrom?: Eventa<P, M, IM>;
|
|
58
|
+
/**
|
|
59
|
+
* Optional runtime metadata that can be attached to the eventa.
|
|
60
|
+
*
|
|
61
|
+
* NOTICE: for defineInvoke, and defineInvokeHandler, the metadata will be omitted
|
|
62
|
+
* for smaller chunk size, this means for metadata, the data contains will not be available in the defineInvokeHandler.
|
|
63
|
+
*
|
|
64
|
+
* This can be used for various purposes such as logging, debugging, or providing additional context about the eventa.
|
|
65
|
+
* Allowing the event handler to be able to access this metadata can enable more flexible and powerful event handling logic.
|
|
66
|
+
*/
|
|
67
|
+
metadata?: M;
|
|
68
|
+
/**
|
|
69
|
+
* Optional runtime metadata that can be attached to the eventa when invoking it.
|
|
70
|
+
*
|
|
71
|
+
* Unlike the `metadata` field, the `invokeMetadata` is specifically designed to be used when invoking the eventa, and it
|
|
72
|
+
* will be available in the defineInvokeHandler.
|
|
73
|
+
*
|
|
74
|
+
* This allows for a clear separation between the metadata that describes the eventa itself and the metadata that is relevant
|
|
75
|
+
* to the invocation of the eventa, providing more flexibility in how metadata is used and accessed within the event
|
|
76
|
+
* handling system.
|
|
77
|
+
*/
|
|
78
|
+
invokeMetadata?: IM;
|
|
79
|
+
}): Eventa<P, M, IM>;
|
|
80
|
+
interface EventaMatchExpression<P = undefined> extends EventaLike<P, EventaType.MatchExpression> {
|
|
81
|
+
matcher?: (event: Eventa<P>) => boolean | Promise<boolean>;
|
|
82
|
+
}
|
|
83
|
+
declare function and<P>(...matchExpression: Array<EventaMatchExpression<P>>): EventaMatchExpression<P>;
|
|
84
|
+
declare function or<P>(...matchExpression: Array<EventaMatchExpression<P>>): EventaMatchExpression<P>;
|
|
85
|
+
/**
|
|
86
|
+
* Match by is powerful utility function that allows you to create a match expression based on various criteria
|
|
87
|
+
* when working with eventa (event system).
|
|
88
|
+
*
|
|
89
|
+
* Semantics like glob matching, RegExp, or even custom matcher function can be used to create complex match
|
|
90
|
+
* expressions that can be used to filter and handle events in a flexible way.
|
|
91
|
+
*/
|
|
92
|
+
declare function matchBy<P = undefined>(glob: string, inverted?: boolean): EventaMatchExpression<P>;
|
|
93
|
+
declare function matchBy<P = undefined>(options: {
|
|
94
|
+
ids: string[];
|
|
95
|
+
}, inverted?: boolean): EventaMatchExpression<P>;
|
|
96
|
+
declare function matchBy<P = undefined>(options: {
|
|
97
|
+
eventa: Eventa<P>[];
|
|
98
|
+
}, inverted?: boolean): EventaMatchExpression<P>;
|
|
99
|
+
declare function matchBy<P = undefined>(options: {
|
|
100
|
+
types: EventaType[];
|
|
101
|
+
}, inverted?: boolean): EventaMatchExpression<P>;
|
|
102
|
+
declare function matchBy<P = undefined>(regExp: RegExp, inverted?: boolean): EventaMatchExpression<P>;
|
|
103
|
+
declare function matchBy<P = undefined, E extends Eventa<P> = Eventa<P>>(matcher: (event: E) => boolean | Promise<boolean>): EventaMatchExpression<P>;
|
|
104
|
+
//#endregion
|
|
105
|
+
export { nanoid as _, EventaLike as a, InboundEventa as c, OutboundEventa as d, and as f, matchBy as g, defineOutboundEventa as h, EventaFlowDirection as i, InferEventaPayload as l, defineInboundEventa as m, EventTag as n, EventaMatchExpression as o, defineEventa as p, Eventa as r, EventaType as s, DirectionalEventa as t, InvokeEventConstraint as u, or as v };
|
|
106
|
+
//# sourceMappingURL=eventa-M1FMVrH1.d.mts.map
|