@nwire/app 0.9.2 → 0.10.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 +81 -95
- package/dist/app.d.ts +7 -24
- package/dist/app.js +6 -24
- package/dist/compose-app.d.ts +35 -0
- package/dist/compose-app.js +138 -0
- package/dist/create-app.d.ts +38 -66
- package/dist/create-app.js +42 -216
- package/dist/define-plugin.d.ts +10 -149
- package/dist/define-plugin.js +11 -62
- package/dist/runtime/framework-hooks.d.ts +110 -0
- package/dist/runtime/framework-hooks.js +39 -0
- package/dist/runtime/index.d.ts +6 -0
- package/dist/runtime/index.js +6 -0
- package/dist/runtime/runtime.d.ts +349 -0
- package/dist/runtime/runtime.js +642 -0
- package/package.json +8 -5
- package/dist/__tests__/create-app.test.d.ts +0 -6
- package/dist/__tests__/create-app.test.d.ts.map +0 -1
- package/dist/__tests__/create-app.test.js +0 -126
- package/dist/__tests__/create-app.test.js.map +0 -1
- package/dist/__tests__/define-plugin.test.d.ts +0 -16
- package/dist/__tests__/define-plugin.test.d.ts.map +0 -1
- package/dist/__tests__/define-plugin.test.js +0 -269
- package/dist/__tests__/define-plugin.test.js.map +0 -1
- package/dist/__tests__/framework-events.test.d.ts +0 -18
- package/dist/__tests__/framework-events.test.d.ts.map +0 -1
- package/dist/__tests__/framework-events.test.js +0 -156
- package/dist/__tests__/framework-events.test.js.map +0 -1
- package/dist/app.d.ts.map +0 -1
- package/dist/app.js.map +0 -1
- package/dist/create-app.d.ts.map +0 -1
- package/dist/create-app.js.map +0 -1
- package/dist/define-plugin.d.ts.map +0 -1
- package/dist/define-plugin.js.map +0 -1
- package/dist/framework-event-bus.d.ts +0 -129
- package/dist/framework-event-bus.d.ts.map +0 -1
- package/dist/framework-event-bus.js +0 -188
- package/dist/framework-event-bus.js.map +0 -1
- package/dist/framework-events.d.ts +0 -233
- package/dist/framework-events.d.ts.map +0 -1
- package/dist/framework-events.js +0 -136
- package/dist/framework-events.js.map +0 -1
- package/dist/runtime.d.ts +0 -185
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js +0 -197
- package/dist/runtime.js.map +0 -1
package/dist/create-app.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-app.js","sourceRoot":"","sources":["../src/create-app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,eAAe,EAAkB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAe,MAAM,eAAe,CAAC;AAExD,OAAO,EACL,cAAc,EACd,UAAU,EACV,SAAS,EACT,QAAQ,EACR,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,cAAc,GACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AA8C1D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS,CAAC,OAAyB;IACjD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAChC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,eAAe,EAAE,CAAC;IACzD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;IAClD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACzD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;IAEtC;;;OAGG;IACH,MAAM,QAAQ,GAIT,EAAE,CAAC;IACR,MAAM,KAAK,GAAiE,EAAE,CAAC;IAC/E,MAAM,SAAS,GAAiE,EAAE,CAAC;IAEnF,6EAA6E;IAC7E,MAAM,YAAY,GAAG,IAAI,GAAG,EAAmB,CAAC;IAEhD,yEAAyE;IACzE,sEAAsE;IACtE,4DAA4D;IAC5D,OAAO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AC1B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GACrD,mBAAmB,CAOrB;AAED,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,mBAAmB,CAMhE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-plugin.js","sourceRoot":"","sources":["../src/define-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EAAE,qBAAqB,EAAuB,MAAM,iBAAiB,CAAC;AA8G7E,qEAAqE;AAErE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAY,EACZ,KAAsD;IAEtD,OAAO;QACL,eAAe,EAAE,IAAI;QACrB,IAAI;QACJ,KAAK;QACL,OAAO,EAAE,qBAAqB,EAAE;KACjC,CAAC;AACJ,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,OAAO,CACL,OAAO,CAAC,KAAK,QAAQ;QACrB,CAAC,KAAK,IAAI;QACT,CAAmC,CAAC,eAAe,KAAK,IAAI,CAC9D,CAAC;AACJ,CAAC"}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `FrameworkEventBus` — the dispatcher behind framework events.
|
|
3
|
-
*
|
|
4
|
-
* Owned by an app's runtime. One bus per app instance. Plugins, apps,
|
|
5
|
-
* and modules subscribe with `bus.on(Event, handler)`; the runtime fires
|
|
6
|
-
* events at the appropriate lifecycle points with `bus.fire(Event, payload)`.
|
|
7
|
-
*
|
|
8
|
-
* Internals: every event delegates to a `hook<TPayload>(name)` from
|
|
9
|
-
* `@nwire/hooks`. Subscribers attach as hook chain steps (series /
|
|
10
|
-
* series-bail) or hook listeners (parallel). Dispatch is `hook.run()` —
|
|
11
|
-
* no parallel subscription map. Telemetry, replay, .tap observation,
|
|
12
|
-
* cancellation all come from hooks substrate by construction.
|
|
13
|
-
*
|
|
14
|
-
* Dispatch semantics come from the event's `mode`:
|
|
15
|
-
*
|
|
16
|
-
* parallel → handlers fire as hook listeners (Promise.allSettled);
|
|
17
|
-
* one failing doesn't affect others; errors are logged.
|
|
18
|
-
* series → handlers fire as chain steps in priority order;
|
|
19
|
-
* one throwing stops the chain.
|
|
20
|
-
* series-bail → handlers fire as chain steps in priority order;
|
|
21
|
-
* returning `false` short-circuits (don't call next()).
|
|
22
|
-
* `fire()` returns false to signal "prevented".
|
|
23
|
-
*
|
|
24
|
-
* The bus lives in `@nwire/app` (the "managed Container with lifecycle"
|
|
25
|
-
* layer). `@nwire/forge` re-exports the same surface so consumers that
|
|
26
|
-
* pull from forge get one import line.
|
|
27
|
-
*/
|
|
28
|
-
import { type Hook } from "@nwire/hooks";
|
|
29
|
-
import type { Logger } from "@nwire/logger";
|
|
30
|
-
import type { FrameworkEventDefinition } from "./framework-events.js";
|
|
31
|
-
/**
|
|
32
|
-
* Handler signature. The handler MAY:
|
|
33
|
-
* - return nothing → "continue"
|
|
34
|
-
* - return false → "prevent" (series-bail only)
|
|
35
|
-
* - return a Promise resolving to either
|
|
36
|
-
* - throw → "fail" (propagates in series modes,
|
|
37
|
-
* logged-and-swallowed in parallel)
|
|
38
|
-
*
|
|
39
|
-
* In parallel/series modes the return value is ignored entirely.
|
|
40
|
-
*/
|
|
41
|
-
export type FrameworkEventHandler<TPayload> = (payload: TPayload) => Promise<void | boolean> | void | boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Per-fire observer — receives every framework-event firing on the bus.
|
|
44
|
-
* Used by the dev logger, Studio Live stream, and OTel exporter to surface
|
|
45
|
-
* lifecycle activity without each one re-subscribing per event type.
|
|
46
|
-
*
|
|
47
|
-
* `phase: "fired"` — handler chain completed without a veto.
|
|
48
|
-
* `phase: "prevented"` — a series-bail handler returned false.
|
|
49
|
-
*/
|
|
50
|
-
export interface FrameworkEventObservation {
|
|
51
|
-
readonly eventName: string;
|
|
52
|
-
readonly payload: unknown;
|
|
53
|
-
readonly mode: "parallel" | "series" | "series-bail";
|
|
54
|
-
readonly phase: "fired" | "prevented";
|
|
55
|
-
readonly ts: string;
|
|
56
|
-
}
|
|
57
|
-
export type FrameworkEventObserver = (record: FrameworkEventObservation) => void;
|
|
58
|
-
/**
|
|
59
|
-
* The bus. Subscriptions and dispatch live here so an app's runtime stays
|
|
60
|
-
* focused on the domain pipeline. Designed to be reusable — Studio, the
|
|
61
|
-
* orchestrator, and external plugins all hit the same surface.
|
|
62
|
-
*/
|
|
63
|
-
export declare class FrameworkEventBus {
|
|
64
|
-
private readonly observers;
|
|
65
|
-
private readonly logger;
|
|
66
|
-
/**
|
|
67
|
-
* One hook per event name. Each event's subscribers attach as chain
|
|
68
|
-
* steps (series / series-bail) or listeners (parallel) on its hook;
|
|
69
|
-
* dispatch is `hook.run()`. `listHooks()` + scan + Studio see every
|
|
70
|
-
* framework event in the registry by construction.
|
|
71
|
-
*
|
|
72
|
-
* Runtime can pass an `adoptHook` callback in the constructor; each
|
|
73
|
-
* lazily-created hook is adopted so taps flow into the canonical
|
|
74
|
-
* telemetry stream as `kind: "hook.step"`.
|
|
75
|
-
*/
|
|
76
|
-
private readonly eventHooks;
|
|
77
|
-
private readonly adoptHook?;
|
|
78
|
-
constructor(logger: Logger, options?: {
|
|
79
|
-
adoptHook?: (h: Hook<unknown>) => void;
|
|
80
|
-
/**
|
|
81
|
-
* Built-in framework events to pre-create observation hooks for at
|
|
82
|
-
* construction. Pass the host's known event registry (e.g. forge's
|
|
83
|
-
* `builtInFrameworkEvents`) so `listHooks()` + scan see them BEFORE
|
|
84
|
-
* the first fire — Studio's Hooks page and CLI both consume that.
|
|
85
|
-
*/
|
|
86
|
-
events?: ReadonlyArray<{
|
|
87
|
-
readonly name: string;
|
|
88
|
-
}>;
|
|
89
|
-
});
|
|
90
|
-
/** Lazily create + adopt the per-event hook. Bus dispatches through these. */
|
|
91
|
-
private ensureEventHook;
|
|
92
|
-
/**
|
|
93
|
-
* Subscribe to EVERY framework-event firing on this bus. Used by the
|
|
94
|
-
* dev logger, Studio Live, and OTel exporter to surface lifecycle
|
|
95
|
-
* activity without each one re-subscribing per event type.
|
|
96
|
-
*
|
|
97
|
-
* Returns an unsubscribe handle.
|
|
98
|
-
*/
|
|
99
|
-
onFire(observer: FrameworkEventObserver): () => void;
|
|
100
|
-
private notify;
|
|
101
|
-
/**
|
|
102
|
-
* Subscribe to a framework event. `priority` controls ordering for
|
|
103
|
-
* series-bail / series modes (higher runs first; default 0). Framework
|
|
104
|
-
* built-ins should subscribe at priority 100+; debug/observer plugins
|
|
105
|
-
* at -100 so they see the final post-mutation state.
|
|
106
|
-
*
|
|
107
|
-
* Attaches to the per-event hook: as a listener (parallel mode) or as
|
|
108
|
-
* a chain step (series / series-bail). The returned handle calls
|
|
109
|
-
* `hook.off()` to detach.
|
|
110
|
-
*/
|
|
111
|
-
on<TPayload>(event: FrameworkEventDefinition<TPayload>, handler: FrameworkEventHandler<TPayload>, priority?: number): () => void;
|
|
112
|
-
/**
|
|
113
|
-
* Fire a framework event. Resolves to `false` when a series-bail handler
|
|
114
|
-
* vetoed; `true` otherwise. The boolean is irrelevant for parallel /
|
|
115
|
-
* series modes and always returns `true` there.
|
|
116
|
-
*
|
|
117
|
-
* Internally: delegates to the per-event hook's `.run()` (parallel /
|
|
118
|
-
* series) or `.runDetailed()` (series-bail, to detect "prevented"
|
|
119
|
-
* outcome from short-circuit). The hook's observability surface (.tap,
|
|
120
|
-
* StepObservation) lights up automatically.
|
|
121
|
-
*/
|
|
122
|
-
fire<TPayload>(event: FrameworkEventDefinition<TPayload>, payload: TPayload): Promise<boolean>;
|
|
123
|
-
/**
|
|
124
|
-
* Count subscribers for an event — diagnostic surface (Studio, tests).
|
|
125
|
-
* Sums chain steps and listeners attached to the per-event hook.
|
|
126
|
-
*/
|
|
127
|
-
subscriberCount(event: FrameworkEventDefinition): number;
|
|
128
|
-
}
|
|
129
|
-
//# sourceMappingURL=framework-event-bus.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"framework-event-bus.d.ts","sourceRoot":"","sources":["../src/framework-event-bus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAQ,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEnE;;;;;;;;;GASG;AACH,MAAM,MAAM,qBAAqB,CAAC,QAAQ,IAAI,CAC5C,OAAO,EAAE,QAAQ,KACd,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,QAAQ,GAAG,aAAa,CAAC;IACrD,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAAC;IACtC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AACD,MAAM,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAAE,yBAAyB,KAAK,IAAI,CAAC;AAEjF;;;;GAIG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgC;IAC1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;;;;;;OASG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoC;IAC/D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAA6B;gBAGtD,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;QACP,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;QACvC;;;;;WAKG;QACH,MAAM,CAAC,EAAE,aAAa,CAAC;YAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC9C;IASR,8EAA8E;IAC9E,OAAO,CAAC,eAAe;IASvB;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,EAAE,sBAAsB,GAAG,MAAM,IAAI;IAQpD,OAAO,CAAC,MAAM;IAgBd;;;;;;;;;OASG;IACH,EAAE,CAAC,QAAQ,EACT,KAAK,EAAE,wBAAwB,CAAC,QAAQ,CAAC,EACzC,OAAO,EAAE,qBAAqB,CAAC,QAAQ,CAAC,EACxC,QAAQ,GAAE,MAAU,GACnB,MAAM,IAAI;IAiCb;;;;;;;;;OASG;IACG,IAAI,CAAC,QAAQ,EACjB,KAAK,EAAE,wBAAwB,CAAC,QAAQ,CAAC,EACzC,OAAO,EAAE,QAAQ,GAChB,OAAO,CAAC,OAAO,CAAC;IAgCnB;;;OAGG;IACH,eAAe,CAAC,KAAK,EAAE,wBAAwB,GAAG,MAAM;CAMzD"}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `FrameworkEventBus` — the dispatcher behind framework events.
|
|
3
|
-
*
|
|
4
|
-
* Owned by an app's runtime. One bus per app instance. Plugins, apps,
|
|
5
|
-
* and modules subscribe with `bus.on(Event, handler)`; the runtime fires
|
|
6
|
-
* events at the appropriate lifecycle points with `bus.fire(Event, payload)`.
|
|
7
|
-
*
|
|
8
|
-
* Internals: every event delegates to a `hook<TPayload>(name)` from
|
|
9
|
-
* `@nwire/hooks`. Subscribers attach as hook chain steps (series /
|
|
10
|
-
* series-bail) or hook listeners (parallel). Dispatch is `hook.run()` —
|
|
11
|
-
* no parallel subscription map. Telemetry, replay, .tap observation,
|
|
12
|
-
* cancellation all come from hooks substrate by construction.
|
|
13
|
-
*
|
|
14
|
-
* Dispatch semantics come from the event's `mode`:
|
|
15
|
-
*
|
|
16
|
-
* parallel → handlers fire as hook listeners (Promise.allSettled);
|
|
17
|
-
* one failing doesn't affect others; errors are logged.
|
|
18
|
-
* series → handlers fire as chain steps in priority order;
|
|
19
|
-
* one throwing stops the chain.
|
|
20
|
-
* series-bail → handlers fire as chain steps in priority order;
|
|
21
|
-
* returning `false` short-circuits (don't call next()).
|
|
22
|
-
* `fire()` returns false to signal "prevented".
|
|
23
|
-
*
|
|
24
|
-
* The bus lives in `@nwire/app` (the "managed Container with lifecycle"
|
|
25
|
-
* layer). `@nwire/forge` re-exports the same surface so consumers that
|
|
26
|
-
* pull from forge get one import line.
|
|
27
|
-
*/
|
|
28
|
-
import { hook } from "@nwire/hooks";
|
|
29
|
-
/**
|
|
30
|
-
* The bus. Subscriptions and dispatch live here so an app's runtime stays
|
|
31
|
-
* focused on the domain pipeline. Designed to be reusable — Studio, the
|
|
32
|
-
* orchestrator, and external plugins all hit the same surface.
|
|
33
|
-
*/
|
|
34
|
-
export class FrameworkEventBus {
|
|
35
|
-
observers = [];
|
|
36
|
-
logger;
|
|
37
|
-
/**
|
|
38
|
-
* One hook per event name. Each event's subscribers attach as chain
|
|
39
|
-
* steps (series / series-bail) or listeners (parallel) on its hook;
|
|
40
|
-
* dispatch is `hook.run()`. `listHooks()` + scan + Studio see every
|
|
41
|
-
* framework event in the registry by construction.
|
|
42
|
-
*
|
|
43
|
-
* Runtime can pass an `adoptHook` callback in the constructor; each
|
|
44
|
-
* lazily-created hook is adopted so taps flow into the canonical
|
|
45
|
-
* telemetry stream as `kind: "hook.step"`.
|
|
46
|
-
*/
|
|
47
|
-
eventHooks = new Map();
|
|
48
|
-
adoptHook;
|
|
49
|
-
constructor(logger, options = {}) {
|
|
50
|
-
this.logger = logger;
|
|
51
|
-
this.adoptHook = options.adoptHook;
|
|
52
|
-
for (const event of options.events ?? []) {
|
|
53
|
-
this.ensureEventHook(event.name);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/** Lazily create + adopt the per-event hook. Bus dispatches through these. */
|
|
57
|
-
ensureEventHook(eventName) {
|
|
58
|
-
let h = this.eventHooks.get(eventName);
|
|
59
|
-
if (h)
|
|
60
|
-
return h;
|
|
61
|
-
h = hook(`framework.event:${eventName}`);
|
|
62
|
-
this.eventHooks.set(eventName, h);
|
|
63
|
-
this.adoptHook?.(h);
|
|
64
|
-
return h;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Subscribe to EVERY framework-event firing on this bus. Used by the
|
|
68
|
-
* dev logger, Studio Live, and OTel exporter to surface lifecycle
|
|
69
|
-
* activity without each one re-subscribing per event type.
|
|
70
|
-
*
|
|
71
|
-
* Returns an unsubscribe handle.
|
|
72
|
-
*/
|
|
73
|
-
onFire(observer) {
|
|
74
|
-
this.observers.push(observer);
|
|
75
|
-
return () => {
|
|
76
|
-
const i = this.observers.indexOf(observer);
|
|
77
|
-
if (i >= 0)
|
|
78
|
-
this.observers.splice(i, 1);
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
notify(rec) {
|
|
82
|
-
// Observers run after the actual fire — they MUST NOT veto or alter
|
|
83
|
-
// semantics. Errors are swallowed + logged so a buggy observer can't
|
|
84
|
-
// break the lifecycle.
|
|
85
|
-
for (const o of this.observers) {
|
|
86
|
-
try {
|
|
87
|
-
o(rec);
|
|
88
|
-
}
|
|
89
|
-
catch (err) {
|
|
90
|
-
this.logger.error?.("framework-event observer threw", {
|
|
91
|
-
event: rec.eventName,
|
|
92
|
-
error: err?.message ?? String(err),
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Subscribe to a framework event. `priority` controls ordering for
|
|
99
|
-
* series-bail / series modes (higher runs first; default 0). Framework
|
|
100
|
-
* built-ins should subscribe at priority 100+; debug/observer plugins
|
|
101
|
-
* at -100 so they see the final post-mutation state.
|
|
102
|
-
*
|
|
103
|
-
* Attaches to the per-event hook: as a listener (parallel mode) or as
|
|
104
|
-
* a chain step (series / series-bail). The returned handle calls
|
|
105
|
-
* `hook.off()` to detach.
|
|
106
|
-
*/
|
|
107
|
-
on(event, handler, priority = 0) {
|
|
108
|
-
const eventHook = this.ensureEventHook(event.name);
|
|
109
|
-
if (event.mode === "parallel") {
|
|
110
|
-
const listener = async (payload) => {
|
|
111
|
-
try {
|
|
112
|
-
await handler(payload);
|
|
113
|
-
}
|
|
114
|
-
catch (err) {
|
|
115
|
-
this.logger.error?.("framework-event handler threw (parallel)", {
|
|
116
|
-
event: event.name,
|
|
117
|
-
error: err?.message ?? String(err),
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
eventHook.on(listener, { priority });
|
|
122
|
-
return () => eventHook.off(listener);
|
|
123
|
-
}
|
|
124
|
-
// series + series-bail both run as chain steps; series-bail returning
|
|
125
|
-
// false short-circuits by not calling next().
|
|
126
|
-
const step = async (ctx, next) => {
|
|
127
|
-
const result = await handler(ctx);
|
|
128
|
-
if (event.mode === "series-bail" && result === false) {
|
|
129
|
-
// Don't call next() — short-circuits the chain. fire() sees
|
|
130
|
-
// outcome === "prevented" via runDetailed.
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
await next();
|
|
134
|
-
};
|
|
135
|
-
eventHook.use(step, { priority });
|
|
136
|
-
return () => eventHook.off(step);
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Fire a framework event. Resolves to `false` when a series-bail handler
|
|
140
|
-
* vetoed; `true` otherwise. The boolean is irrelevant for parallel /
|
|
141
|
-
* series modes and always returns `true` there.
|
|
142
|
-
*
|
|
143
|
-
* Internally: delegates to the per-event hook's `.run()` (parallel /
|
|
144
|
-
* series) or `.runDetailed()` (series-bail, to detect "prevented"
|
|
145
|
-
* outcome from short-circuit). The hook's observability surface (.tap,
|
|
146
|
-
* StepObservation) lights up automatically.
|
|
147
|
-
*/
|
|
148
|
-
async fire(event, payload) {
|
|
149
|
-
const eventHook = this.ensureEventHook(event.name);
|
|
150
|
-
const ts = new Date().toISOString();
|
|
151
|
-
const obsRec = (phase) => ({
|
|
152
|
-
eventName: event.name,
|
|
153
|
-
payload,
|
|
154
|
-
mode: event.mode,
|
|
155
|
-
phase,
|
|
156
|
-
ts,
|
|
157
|
-
});
|
|
158
|
-
if (event.mode === "series-bail") {
|
|
159
|
-
const result = await eventHook.runDetailed(payload);
|
|
160
|
-
const fired = result.outcome === "completed";
|
|
161
|
-
if (!fired) {
|
|
162
|
-
this.logger.info?.("framework-event prevented by handler", {
|
|
163
|
-
event: event.name,
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
this.notify(obsRec(fired ? "fired" : "prevented"));
|
|
167
|
-
return fired;
|
|
168
|
-
}
|
|
169
|
-
// parallel + series: hook.run handles dispatch; listener errors in
|
|
170
|
-
// parallel mode are swallowed by the listener wrapper in on(); chain
|
|
171
|
-
// errors in series mode propagate (matches old behaviour).
|
|
172
|
-
await eventHook.run(payload);
|
|
173
|
-
this.notify(obsRec("fired"));
|
|
174
|
-
return true;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Count subscribers for an event — diagnostic surface (Studio, tests).
|
|
178
|
-
* Sums chain steps and listeners attached to the per-event hook.
|
|
179
|
-
*/
|
|
180
|
-
subscriberCount(event) {
|
|
181
|
-
const h = this.eventHooks.get(event.name);
|
|
182
|
-
if (!h)
|
|
183
|
-
return 0;
|
|
184
|
-
const counts = h.stepCounts();
|
|
185
|
-
return counts.chain + counts.listeners;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
//# sourceMappingURL=framework-event-bus.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"framework-event-bus.js","sourceRoot":"","sources":["../src/framework-event-bus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,IA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AM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;YACnD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,mEAAmE;QACnE,qEAAqE;QACrE,2DAA2D;QAC3D,MAAM,SAAS,CAAC,GAAG,CAAC,OAAkB,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,eAAe,CAAC,KAA+B;QAC7C,MAAM,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC;QACjB,MAAM,MAAM,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC;IACzC,CAAC;CACF"}
|
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Framework events — lifecycle hooks expressed as values.
|
|
3
|
-
*
|
|
4
|
-
* The principle: every primitive is a value; lifecycle is events. There is
|
|
5
|
-
* no separate "hooks" system — plugins (and apps) react to framework events
|
|
6
|
-
* with the same `on(Event, handler)` shape they'd use for a domain event.
|
|
7
|
-
*
|
|
8
|
-
* Tense convention encodes dispatch semantics:
|
|
9
|
-
*
|
|
10
|
-
* `*-ing` → series-bail (sequential, return false to prevent, throw to fail)
|
|
11
|
-
* `*-ed` → parallel (Promise.allSettled, fire-and-forget)
|
|
12
|
-
*
|
|
13
|
-
* A third mode `series` exists for the rare case where you need ordering
|
|
14
|
-
* but no veto power — currently unused on built-in events but available to
|
|
15
|
-
* apps that define their own framework-like events.
|
|
16
|
-
*
|
|
17
|
-
* ## What's in this file
|
|
18
|
-
*
|
|
19
|
-
* The generic infrastructure (`defineFrameworkEvent`, `FrameworkEventDefinition`)
|
|
20
|
-
* and the app-lifecycle events (`AppRegistering` / `AppBooting` / `AppBooted` /
|
|
21
|
-
* `AppReady` / `AppShuttingDown` / `AppShutdown`). These have no domain
|
|
22
|
-
* coupling — they take only the app name + timing metadata.
|
|
23
|
-
*
|
|
24
|
-
* Action-specific events (`ActionDispatching` / `ActionCompleted` /
|
|
25
|
-
* `ActionFailed`) and event-recording events (`EventRecording` /
|
|
26
|
-
* `EventRecorded`) live in `@nwire/forge` because their payload types
|
|
27
|
-
* reference forge-specific types (`ActionDefinition`, `HandlerContext`).
|
|
28
|
-
*
|
|
29
|
-
* Both packages re-export from each other through forge's index so that
|
|
30
|
-
* `import { AppBooted, ActionCompleted } from "@nwire/forge"` keeps
|
|
31
|
-
* working — most consumers don't notice the split.
|
|
32
|
-
*/
|
|
33
|
-
/** Three dispatch modes. The tense of the event name picks one of these. */
|
|
34
|
-
export type FrameworkEventMode = "parallel" | "series" | "series-bail";
|
|
35
|
-
/** Framework event definition — name + dispatch mode + payload type. */
|
|
36
|
-
export interface FrameworkEventDefinition<TPayload = unknown> {
|
|
37
|
-
readonly $kind: "framework-event";
|
|
38
|
-
readonly name: string;
|
|
39
|
-
readonly mode: FrameworkEventMode;
|
|
40
|
-
/** Type-only marker; runtime carries the actual payload. */
|
|
41
|
-
readonly __payload?: TPayload;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Declare a framework event. The mode picks dispatch semantics:
|
|
45
|
-
*
|
|
46
|
-
* defineFrameworkEvent<{...}>("nwire.action.dispatching", "series-bail");
|
|
47
|
-
* defineFrameworkEvent<{...}>("nwire.action.completed", "parallel");
|
|
48
|
-
*
|
|
49
|
-
* App authors can declare their OWN framework events (e.g.
|
|
50
|
-
* `defineFrameworkEvent<{ tenant: string }>("app.tenant-switched", "parallel")`)
|
|
51
|
-
* and fire them through the same bus. Every subscriber pattern works
|
|
52
|
-
* uniformly across built-in and user-defined events.
|
|
53
|
-
*/
|
|
54
|
-
export declare function defineFrameworkEvent<TPayload>(name: string, mode: FrameworkEventMode): FrameworkEventDefinition<TPayload>;
|
|
55
|
-
/**
|
|
56
|
-
* Fired during `app.start()` right after plugin `register` has run, before
|
|
57
|
-
* provider boot. Plugins/apps can return `false` here to short-circuit boot.
|
|
58
|
-
*/
|
|
59
|
-
export declare const AppRegistering: FrameworkEventDefinition<{
|
|
60
|
-
readonly appName: string;
|
|
61
|
-
}>;
|
|
62
|
-
/**
|
|
63
|
-
* Fired during `app.start()` after provider boot and before plugin `boot`
|
|
64
|
-
* callbacks. Useful for diagnostics that need the container populated but
|
|
65
|
-
* want to run before plugins start subscribing to real traffic.
|
|
66
|
-
*/
|
|
67
|
-
export declare const AppBooting: FrameworkEventDefinition<{
|
|
68
|
-
readonly appName: string;
|
|
69
|
-
}>;
|
|
70
|
-
/**
|
|
71
|
-
* Fired after `app.start()` completes — all providers booted, all plugins
|
|
72
|
-
* booted, all initializers boot-phase complete. Safe to do post-boot work.
|
|
73
|
-
*/
|
|
74
|
-
export declare const AppBooted: FrameworkEventDefinition<{
|
|
75
|
-
readonly appName: string;
|
|
76
|
-
readonly bootedAt: string;
|
|
77
|
-
}>;
|
|
78
|
-
/**
|
|
79
|
-
* Fired after the wire is fully ready — endpoints listening, health checks
|
|
80
|
-
* passing. This is the signal external observers (Studio, log aggregators)
|
|
81
|
-
* use to start treating the app as live.
|
|
82
|
-
*/
|
|
83
|
-
export declare const AppReady: FrameworkEventDefinition<{
|
|
84
|
-
readonly appName: string;
|
|
85
|
-
readonly readyAt: string;
|
|
86
|
-
}>;
|
|
87
|
-
/**
|
|
88
|
-
* Fired at the start of `app.stop()` — interceptable so plugins can refuse
|
|
89
|
-
* shutdown (e.g., "still draining work, give me 5 more seconds"). Throwing
|
|
90
|
-
* fails the shutdown; the runtime then falls back to hard-timeout SIGKILL.
|
|
91
|
-
*/
|
|
92
|
-
export declare const AppShuttingDown: FrameworkEventDefinition<{
|
|
93
|
-
readonly appName: string;
|
|
94
|
-
readonly reason?: string;
|
|
95
|
-
}>;
|
|
96
|
-
/** Fired after `app.stop()` completes — everything torn down. */
|
|
97
|
-
export declare const AppShutdown: FrameworkEventDefinition<{
|
|
98
|
-
readonly appName: string;
|
|
99
|
-
}>;
|
|
100
|
-
/**
|
|
101
|
-
* Fired once per plugin during `createApp` composition, before any boot
|
|
102
|
-
* begins. Useful for an observer that wants to list "what's this app made
|
|
103
|
-
* of?" before lifecycle starts. Observable; runs in parallel.
|
|
104
|
-
*/
|
|
105
|
-
/**
|
|
106
|
-
* `kind` distinguishes a plugin proper from a module that's been compiled
|
|
107
|
-
* onto the plugin lifecycle. Optional + defaulting to "plugin" so existing
|
|
108
|
-
* subscribers stay back-compat.
|
|
109
|
-
*/
|
|
110
|
-
export type PluginKind = "plugin" | "module";
|
|
111
|
-
export declare const PluginRegistered: FrameworkEventDefinition<{
|
|
112
|
-
readonly appName: string;
|
|
113
|
-
readonly pluginName: string;
|
|
114
|
-
readonly kind?: PluginKind;
|
|
115
|
-
}>;
|
|
116
|
-
/**
|
|
117
|
-
* Fired before a plugin's `boot()` callback (object-form) or its `boot(...)`
|
|
118
|
-
* fns registered via the closure-form setup. Interceptable — returning
|
|
119
|
-
* `false` aborts boot of the whole app (the runtime treats a vetoed plugin
|
|
120
|
-
* boot as a fatal startup failure, surfaced with the plugin name).
|
|
121
|
-
*/
|
|
122
|
-
export declare const PluginBooting: FrameworkEventDefinition<{
|
|
123
|
-
readonly appName: string;
|
|
124
|
-
readonly pluginName: string;
|
|
125
|
-
readonly kind?: PluginKind;
|
|
126
|
-
}>;
|
|
127
|
-
/** Fired after a plugin's boot completes successfully. Observable. */
|
|
128
|
-
export declare const PluginBooted: FrameworkEventDefinition<{
|
|
129
|
-
readonly appName: string;
|
|
130
|
-
readonly pluginName: string;
|
|
131
|
-
readonly durationMs: number;
|
|
132
|
-
readonly kind?: PluginKind;
|
|
133
|
-
}>;
|
|
134
|
-
/**
|
|
135
|
-
* Fired before a plugin's `shutdown()` callback runs. Interceptable. Used
|
|
136
|
-
* by observers that want to flush state before a plugin tears down.
|
|
137
|
-
*/
|
|
138
|
-
export declare const PluginShuttingDown: FrameworkEventDefinition<{
|
|
139
|
-
readonly appName: string;
|
|
140
|
-
readonly pluginName: string;
|
|
141
|
-
readonly kind?: PluginKind;
|
|
142
|
-
}>;
|
|
143
|
-
/** Fired after a plugin's shutdown completes. Observable. */
|
|
144
|
-
export declare const PluginShutdown: FrameworkEventDefinition<{
|
|
145
|
-
readonly appName: string;
|
|
146
|
-
readonly pluginName: string;
|
|
147
|
-
readonly durationMs: number;
|
|
148
|
-
readonly kind?: PluginKind;
|
|
149
|
-
}>;
|
|
150
|
-
/**
|
|
151
|
-
* Fired before an interface is attached to a host (typically an endpoint).
|
|
152
|
-
* The payload carries the transport id + the interface's `manifest()` so
|
|
153
|
-
* subscribers can inspect the wired surface before it goes live.
|
|
154
|
-
* Interceptable — return `false` to refuse the mount (useful for safety
|
|
155
|
-
* gates like "this endpoint only accepts http interfaces").
|
|
156
|
-
*/
|
|
157
|
-
export declare const WireMounting: FrameworkEventDefinition<{
|
|
158
|
-
readonly appName: string;
|
|
159
|
-
readonly transport: string;
|
|
160
|
-
readonly manifest: unknown;
|
|
161
|
-
}>;
|
|
162
|
-
/**
|
|
163
|
-
* Fired after an interface attaches successfully. Observable. Subscribers
|
|
164
|
-
* use this to register routes with introspection tools, expose the
|
|
165
|
-
* transport in Studio, etc.
|
|
166
|
-
*/
|
|
167
|
-
export declare const WireMounted: FrameworkEventDefinition<{
|
|
168
|
-
readonly appName: string;
|
|
169
|
-
readonly transport: string;
|
|
170
|
-
readonly manifest: unknown;
|
|
171
|
-
}>;
|
|
172
|
-
/**
|
|
173
|
-
* Fired after an interface is unmounted (during shutdown or live re-mount).
|
|
174
|
-
* Observable.
|
|
175
|
-
*/
|
|
176
|
-
export declare const WireUnmounted: FrameworkEventDefinition<{
|
|
177
|
-
readonly appName: string;
|
|
178
|
-
readonly transport: string;
|
|
179
|
-
}>;
|
|
180
|
-
/**
|
|
181
|
-
* Every built-in lifecycle event. Forge augments this list with its own
|
|
182
|
-
* action / event-recording events; the union catalog lives there.
|
|
183
|
-
*/
|
|
184
|
-
export declare const builtInLifecycleEvents: readonly [FrameworkEventDefinition<{
|
|
185
|
-
readonly appName: string;
|
|
186
|
-
}>, FrameworkEventDefinition<{
|
|
187
|
-
readonly appName: string;
|
|
188
|
-
}>, FrameworkEventDefinition<{
|
|
189
|
-
readonly appName: string;
|
|
190
|
-
readonly bootedAt: string;
|
|
191
|
-
}>, FrameworkEventDefinition<{
|
|
192
|
-
readonly appName: string;
|
|
193
|
-
readonly readyAt: string;
|
|
194
|
-
}>, FrameworkEventDefinition<{
|
|
195
|
-
readonly appName: string;
|
|
196
|
-
readonly reason?: string;
|
|
197
|
-
}>, FrameworkEventDefinition<{
|
|
198
|
-
readonly appName: string;
|
|
199
|
-
}>, FrameworkEventDefinition<{
|
|
200
|
-
readonly appName: string;
|
|
201
|
-
readonly pluginName: string;
|
|
202
|
-
readonly kind?: PluginKind;
|
|
203
|
-
}>, FrameworkEventDefinition<{
|
|
204
|
-
readonly appName: string;
|
|
205
|
-
readonly pluginName: string;
|
|
206
|
-
readonly kind?: PluginKind;
|
|
207
|
-
}>, FrameworkEventDefinition<{
|
|
208
|
-
readonly appName: string;
|
|
209
|
-
readonly pluginName: string;
|
|
210
|
-
readonly durationMs: number;
|
|
211
|
-
readonly kind?: PluginKind;
|
|
212
|
-
}>, FrameworkEventDefinition<{
|
|
213
|
-
readonly appName: string;
|
|
214
|
-
readonly pluginName: string;
|
|
215
|
-
readonly kind?: PluginKind;
|
|
216
|
-
}>, FrameworkEventDefinition<{
|
|
217
|
-
readonly appName: string;
|
|
218
|
-
readonly pluginName: string;
|
|
219
|
-
readonly durationMs: number;
|
|
220
|
-
readonly kind?: PluginKind;
|
|
221
|
-
}>, FrameworkEventDefinition<{
|
|
222
|
-
readonly appName: string;
|
|
223
|
-
readonly transport: string;
|
|
224
|
-
readonly manifest: unknown;
|
|
225
|
-
}>, FrameworkEventDefinition<{
|
|
226
|
-
readonly appName: string;
|
|
227
|
-
readonly transport: string;
|
|
228
|
-
readonly manifest: unknown;
|
|
229
|
-
}>, FrameworkEventDefinition<{
|
|
230
|
-
readonly appName: string;
|
|
231
|
-
readonly transport: string;
|
|
232
|
-
}>];
|
|
233
|
-
//# sourceMappingURL=framework-events.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"framework-events.d.ts","sourceRoot":"","sources":["../src/framework-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,4EAA4E;AAC5E,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,CAAC;AAEvE,wEAAwE;AACxE,MAAM,WAAW,wBAAwB,CAAC,QAAQ,GAAG,OAAO;IAC1D,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,4DAA4D;IAC5D,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC;CAC/B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAC3C,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,kBAAkB,GACvB,wBAAwB,CAAC,QAAQ,CAAC,CAEpC;AAID;;;GAGG;AACH,eAAO,MAAM,cAAc;sBACP,MAAM;EACgB,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,UAAU;sBACH,MAAM;EACY,CAAC;AAEvC;;;GAGG;AACH,eAAO,MAAM,SAAS;sBACF,MAAM;uBACL,MAAM;EACO,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,QAAQ;sBACD,MAAM;sBACN,MAAM;EACO,CAAC;AAElC;;;;GAIG;AACH,eAAO,MAAM,eAAe;sBACR,MAAM;sBACN,MAAM;EACkB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