@nwire/app 0.7.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/LICENSE +21 -0
- package/README.md +60 -0
- package/dist/__tests__/define-plugin.test.d.ts +16 -0
- package/dist/__tests__/define-plugin.test.d.ts.map +1 -0
- package/dist/__tests__/define-plugin.test.js +269 -0
- package/dist/__tests__/define-plugin.test.js.map +1 -0
- package/dist/__tests__/framework-events.test.d.ts +18 -0
- package/dist/__tests__/framework-events.test.d.ts.map +1 -0
- package/dist/__tests__/framework-events.test.js +156 -0
- package/dist/__tests__/framework-events.test.js.map +1 -0
- package/dist/app.d.ts +25 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +25 -0
- package/dist/app.js.map +1 -0
- package/dist/define-plugin.d.ts +150 -0
- package/dist/define-plugin.d.ts.map +1 -0
- package/dist/define-plugin.js +72 -0
- package/dist/define-plugin.js.map +1 -0
- package/dist/framework-event-bus.d.ts +89 -0
- package/dist/framework-event-bus.d.ts.map +1 -0
- package/dist/framework-event-bus.js +154 -0
- package/dist/framework-event-bus.js.map +1 -0
- package/dist/framework-events.d.ts +217 -0
- package/dist/framework-events.d.ts.map +1 -0
- package/dist/framework-events.js +142 -0
- package/dist/framework-events.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,217 @@
|
|
|
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
|
+
export declare const PluginRegistered: FrameworkEventDefinition<{
|
|
106
|
+
readonly appName: string;
|
|
107
|
+
readonly pluginName: string;
|
|
108
|
+
}>;
|
|
109
|
+
/**
|
|
110
|
+
* Fired before a plugin's `boot()` callback (object-form) or its `boot(...)`
|
|
111
|
+
* fns registered via the closure-form setup. Interceptable — returning
|
|
112
|
+
* `false` aborts boot of the whole app (the runtime treats a vetoed plugin
|
|
113
|
+
* boot as a fatal startup failure, surfaced with the plugin name).
|
|
114
|
+
*/
|
|
115
|
+
export declare const PluginBooting: FrameworkEventDefinition<{
|
|
116
|
+
readonly appName: string;
|
|
117
|
+
readonly pluginName: string;
|
|
118
|
+
}>;
|
|
119
|
+
/** Fired after a plugin's boot completes successfully. Observable. */
|
|
120
|
+
export declare const PluginBooted: FrameworkEventDefinition<{
|
|
121
|
+
readonly appName: string;
|
|
122
|
+
readonly pluginName: string;
|
|
123
|
+
readonly durationMs: number;
|
|
124
|
+
}>;
|
|
125
|
+
/**
|
|
126
|
+
* Fired before a plugin's `shutdown()` callback runs. Interceptable. Used
|
|
127
|
+
* by observers that want to flush state before a plugin tears down.
|
|
128
|
+
*/
|
|
129
|
+
export declare const PluginShuttingDown: FrameworkEventDefinition<{
|
|
130
|
+
readonly appName: string;
|
|
131
|
+
readonly pluginName: string;
|
|
132
|
+
}>;
|
|
133
|
+
/** Fired after a plugin's shutdown completes. Observable. */
|
|
134
|
+
export declare const PluginShutdown: FrameworkEventDefinition<{
|
|
135
|
+
readonly appName: string;
|
|
136
|
+
readonly pluginName: string;
|
|
137
|
+
readonly durationMs: number;
|
|
138
|
+
}>;
|
|
139
|
+
/**
|
|
140
|
+
* Fired before an interface is attached to a host (typically an endpoint).
|
|
141
|
+
* The payload carries the transport id + the interface's `manifest()` so
|
|
142
|
+
* subscribers can inspect the wired surface before it goes live.
|
|
143
|
+
* Interceptable — return `false` to refuse the mount (useful for safety
|
|
144
|
+
* gates like "this endpoint only accepts http interfaces").
|
|
145
|
+
*/
|
|
146
|
+
export declare const WireMounting: FrameworkEventDefinition<{
|
|
147
|
+
readonly appName: string;
|
|
148
|
+
readonly transport: string;
|
|
149
|
+
readonly manifest: unknown;
|
|
150
|
+
}>;
|
|
151
|
+
/**
|
|
152
|
+
* Fired after an interface attaches successfully. Observable. Subscribers
|
|
153
|
+
* use this to register routes with introspection tools, expose the
|
|
154
|
+
* transport in Studio, etc.
|
|
155
|
+
*/
|
|
156
|
+
export declare const WireMounted: FrameworkEventDefinition<{
|
|
157
|
+
readonly appName: string;
|
|
158
|
+
readonly transport: string;
|
|
159
|
+
readonly manifest: unknown;
|
|
160
|
+
}>;
|
|
161
|
+
/**
|
|
162
|
+
* Fired after an interface is unmounted (during shutdown or live re-mount).
|
|
163
|
+
* Observable.
|
|
164
|
+
*/
|
|
165
|
+
export declare const WireUnmounted: FrameworkEventDefinition<{
|
|
166
|
+
readonly appName: string;
|
|
167
|
+
readonly transport: string;
|
|
168
|
+
}>;
|
|
169
|
+
/**
|
|
170
|
+
* Every built-in lifecycle event. Forge augments this list with its own
|
|
171
|
+
* action / event-recording events; the union catalog lives there.
|
|
172
|
+
*/
|
|
173
|
+
export declare const builtInLifecycleEvents: readonly [FrameworkEventDefinition<{
|
|
174
|
+
readonly appName: string;
|
|
175
|
+
}>, FrameworkEventDefinition<{
|
|
176
|
+
readonly appName: string;
|
|
177
|
+
}>, FrameworkEventDefinition<{
|
|
178
|
+
readonly appName: string;
|
|
179
|
+
readonly bootedAt: string;
|
|
180
|
+
}>, FrameworkEventDefinition<{
|
|
181
|
+
readonly appName: string;
|
|
182
|
+
readonly readyAt: string;
|
|
183
|
+
}>, FrameworkEventDefinition<{
|
|
184
|
+
readonly appName: string;
|
|
185
|
+
readonly reason?: string;
|
|
186
|
+
}>, FrameworkEventDefinition<{
|
|
187
|
+
readonly appName: string;
|
|
188
|
+
}>, FrameworkEventDefinition<{
|
|
189
|
+
readonly appName: string;
|
|
190
|
+
readonly pluginName: string;
|
|
191
|
+
}>, FrameworkEventDefinition<{
|
|
192
|
+
readonly appName: string;
|
|
193
|
+
readonly pluginName: string;
|
|
194
|
+
}>, FrameworkEventDefinition<{
|
|
195
|
+
readonly appName: string;
|
|
196
|
+
readonly pluginName: string;
|
|
197
|
+
readonly durationMs: number;
|
|
198
|
+
}>, FrameworkEventDefinition<{
|
|
199
|
+
readonly appName: string;
|
|
200
|
+
readonly pluginName: string;
|
|
201
|
+
}>, FrameworkEventDefinition<{
|
|
202
|
+
readonly appName: string;
|
|
203
|
+
readonly pluginName: string;
|
|
204
|
+
readonly durationMs: number;
|
|
205
|
+
}>, FrameworkEventDefinition<{
|
|
206
|
+
readonly appName: string;
|
|
207
|
+
readonly transport: string;
|
|
208
|
+
readonly manifest: unknown;
|
|
209
|
+
}>, FrameworkEventDefinition<{
|
|
210
|
+
readonly appName: string;
|
|
211
|
+
readonly transport: string;
|
|
212
|
+
readonly manifest: unknown;
|
|
213
|
+
}>, FrameworkEventDefinition<{
|
|
214
|
+
readonly appName: string;
|
|
215
|
+
readonly transport: string;
|
|
216
|
+
}>];
|
|
217
|
+
//# sourceMappingURL=framework-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-events.d.ts","sourceR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MAAM;EACQ,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,kBAAkB;sBACX,MAAM;yBACH,MAAM;EACkB,CAAC;AAEhD,6DAA6D;AAC7D,eAAO,MAAM,cAAc;sBACP,MAAM;yBACH,MAAM;yBACN,MAAM;EACU,CAAC;AAIxC;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;sBACL,MAAM;wBACJ,MAAM;uBACP,OAAO;EACY,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,WAAW;sBACJ,MAAM;wBACJ,MAAM;uBACP,OAAO;EACQ,CAAC;AAErC;;;GAGG;AACH,eAAO,MAAM,aAAa;sBACN,MAAM;wBACJ,MAAM;EACU,CAAC;AAIvC;;;GAGG;AACH,eAAO,MAAM,sBAAsB;sBArIf,MAAM;;sBASN,MAAM;;sBAQN,MAAM;uBACL,MAAM;;sBASP,MAAM;sBACN,MAAM;;sBASN,MAAM;sBACN,MAAM;;sBAKN,MAAM;;sBAWN,MAAM;yBACH,MAAM;;sBAUT,MAAM;yBACH,MAAM;;sBAKT,MAAM;yBACH,MAAM;yBACN,MAAM;;sBAQT,MAAM;yBACH,MAAM;;sBAKT,MAAM;yBACH,MAAM;yBACN,MAAM;;sBAaT,MAAM;wBACJ,MAAM;uBACP,OAAO;;sBASR,MAAM;wBACJ,MAAM;uBACP,OAAO;;sBAQR,MAAM;wBACJ,MAAM;GAwBlB,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
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
|
+
/**
|
|
34
|
+
* Declare a framework event. The mode picks dispatch semantics:
|
|
35
|
+
*
|
|
36
|
+
* defineFrameworkEvent<{...}>("nwire.action.dispatching", "series-bail");
|
|
37
|
+
* defineFrameworkEvent<{...}>("nwire.action.completed", "parallel");
|
|
38
|
+
*
|
|
39
|
+
* App authors can declare their OWN framework events (e.g.
|
|
40
|
+
* `defineFrameworkEvent<{ tenant: string }>("app.tenant-switched", "parallel")`)
|
|
41
|
+
* and fire them through the same bus. Every subscriber pattern works
|
|
42
|
+
* uniformly across built-in and user-defined events.
|
|
43
|
+
*/
|
|
44
|
+
export function defineFrameworkEvent(name, mode) {
|
|
45
|
+
return { $kind: "framework-event", name, mode };
|
|
46
|
+
}
|
|
47
|
+
// ─── App lifecycle ──────────────────────────────────────────────
|
|
48
|
+
/**
|
|
49
|
+
* Fired during `app.start()` right after plugin `register` has run, before
|
|
50
|
+
* provider boot. Plugins/apps can return `false` here to short-circuit boot.
|
|
51
|
+
*/
|
|
52
|
+
export const AppRegistering = defineFrameworkEvent("nwire.app.registering", "series-bail");
|
|
53
|
+
/**
|
|
54
|
+
* Fired during `app.start()` after provider boot and before plugin `boot`
|
|
55
|
+
* callbacks. Useful for diagnostics that need the container populated but
|
|
56
|
+
* want to run before plugins start subscribing to real traffic.
|
|
57
|
+
*/
|
|
58
|
+
export const AppBooting = defineFrameworkEvent("nwire.app.booting", "series-bail");
|
|
59
|
+
/**
|
|
60
|
+
* Fired after `app.start()` completes — all providers booted, all plugins
|
|
61
|
+
* booted, all initializers boot-phase complete. Safe to do post-boot work.
|
|
62
|
+
*/
|
|
63
|
+
export const AppBooted = defineFrameworkEvent("nwire.app.booted", "parallel");
|
|
64
|
+
/**
|
|
65
|
+
* Fired after the wire is fully ready — endpoints listening, health checks
|
|
66
|
+
* passing. This is the signal external observers (Studio, log aggregators)
|
|
67
|
+
* use to start treating the app as live.
|
|
68
|
+
*/
|
|
69
|
+
export const AppReady = defineFrameworkEvent("nwire.app.ready", "parallel");
|
|
70
|
+
/**
|
|
71
|
+
* Fired at the start of `app.stop()` — interceptable so plugins can refuse
|
|
72
|
+
* shutdown (e.g., "still draining work, give me 5 more seconds"). Throwing
|
|
73
|
+
* fails the shutdown; the runtime then falls back to hard-timeout SIGKILL.
|
|
74
|
+
*/
|
|
75
|
+
export const AppShuttingDown = defineFrameworkEvent("nwire.app.shutting-down", "series-bail");
|
|
76
|
+
/** Fired after `app.stop()` completes — everything torn down. */
|
|
77
|
+
export const AppShutdown = defineFrameworkEvent("nwire.app.shutdown", "parallel");
|
|
78
|
+
// ─── Plugin lifecycle ──────────────────────────────────────────────
|
|
79
|
+
/**
|
|
80
|
+
* Fired once per plugin during `createApp` composition, before any boot
|
|
81
|
+
* begins. Useful for an observer that wants to list "what's this app made
|
|
82
|
+
* of?" before lifecycle starts. Observable; runs in parallel.
|
|
83
|
+
*/
|
|
84
|
+
export const PluginRegistered = defineFrameworkEvent("nwire.plugin.registered", "parallel");
|
|
85
|
+
/**
|
|
86
|
+
* Fired before a plugin's `boot()` callback (object-form) or its `boot(...)`
|
|
87
|
+
* fns registered via the closure-form setup. Interceptable — returning
|
|
88
|
+
* `false` aborts boot of the whole app (the runtime treats a vetoed plugin
|
|
89
|
+
* boot as a fatal startup failure, surfaced with the plugin name).
|
|
90
|
+
*/
|
|
91
|
+
export const PluginBooting = defineFrameworkEvent("nwire.plugin.booting", "series-bail");
|
|
92
|
+
/** Fired after a plugin's boot completes successfully. Observable. */
|
|
93
|
+
export const PluginBooted = defineFrameworkEvent("nwire.plugin.booted", "parallel");
|
|
94
|
+
/**
|
|
95
|
+
* Fired before a plugin's `shutdown()` callback runs. Interceptable. Used
|
|
96
|
+
* by observers that want to flush state before a plugin tears down.
|
|
97
|
+
*/
|
|
98
|
+
export const PluginShuttingDown = defineFrameworkEvent("nwire.plugin.shutting-down", "series-bail");
|
|
99
|
+
/** Fired after a plugin's shutdown completes. Observable. */
|
|
100
|
+
export const PluginShutdown = defineFrameworkEvent("nwire.plugin.shutdown", "parallel");
|
|
101
|
+
// ─── Wire (transport interface) lifecycle ──────────────────────────
|
|
102
|
+
/**
|
|
103
|
+
* Fired before an interface is attached to a host (typically an endpoint).
|
|
104
|
+
* The payload carries the transport id + the interface's `manifest()` so
|
|
105
|
+
* subscribers can inspect the wired surface before it goes live.
|
|
106
|
+
* Interceptable — return `false` to refuse the mount (useful for safety
|
|
107
|
+
* gates like "this endpoint only accepts http interfaces").
|
|
108
|
+
*/
|
|
109
|
+
export const WireMounting = defineFrameworkEvent("nwire.wire.mounting", "series-bail");
|
|
110
|
+
/**
|
|
111
|
+
* Fired after an interface attaches successfully. Observable. Subscribers
|
|
112
|
+
* use this to register routes with introspection tools, expose the
|
|
113
|
+
* transport in Studio, etc.
|
|
114
|
+
*/
|
|
115
|
+
export const WireMounted = defineFrameworkEvent("nwire.wire.mounted", "parallel");
|
|
116
|
+
/**
|
|
117
|
+
* Fired after an interface is unmounted (during shutdown or live re-mount).
|
|
118
|
+
* Observable.
|
|
119
|
+
*/
|
|
120
|
+
export const WireUnmounted = defineFrameworkEvent("nwire.wire.unmounted", "parallel");
|
|
121
|
+
// ─── Catalog ───────────────────────────────────────────────────────
|
|
122
|
+
/**
|
|
123
|
+
* Every built-in lifecycle event. Forge augments this list with its own
|
|
124
|
+
* action / event-recording events; the union catalog lives there.
|
|
125
|
+
*/
|
|
126
|
+
export const builtInLifecycleEvents = [
|
|
127
|
+
AppRegistering,
|
|
128
|
+
AppBooting,
|
|
129
|
+
AppBooted,
|
|
130
|
+
AppReady,
|
|
131
|
+
AppShuttingDown,
|
|
132
|
+
AppShutdown,
|
|
133
|
+
PluginRegistered,
|
|
134
|
+
PluginBooting,
|
|
135
|
+
PluginBooted,
|
|
136
|
+
PluginShuttingDown,
|
|
137
|
+
PluginShutdown,
|
|
138
|
+
WireMounting,
|
|
139
|
+
WireMounted,
|
|
140
|
+
WireUnmounted,
|
|
141
|
+
];
|
|
142
|
+
//# sourceMappingURL=framework-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-events.js","sourceRoot":"","sources":["../src/framework-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAcH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAAY,EACZ,IAAwB;IAExB,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAClD,CAAC;AAED,mEAAmE;AAEnE;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAE/C,uBAAuB,EAAE,aAAa,CAAC,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,oBAAoB,CAE3C,mBAAm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B,EAAE,UAAU,CAAC,CAAC;AAEvC,sEAAsE;AAEtE;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,cAAc;IACd,UAAU;IACV,SAAS;IACT,QAAQ;IACR,eAAe;IACf,WAAW;IACX,gBAAgB;IAChB,aAAa;IACb,YAAY;IACZ,kBAAkB;IAClB,cAAc;IACd,YAAY;IACZ,WAAW;IACX,aAAa;CACL,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nwire/app",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Nwire — managed Container with plugin lifecycle, framework events, and DI hooks. The 'app' in the sealed architecture: composes modules + plugins, boots in order, exposes a Container, fires framework events at every lifecycle transition. Phase 69 extraction in progress; currently ships the framework events + bus.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"app",
|
|
7
|
+
"container",
|
|
8
|
+
"di",
|
|
9
|
+
"lifecycle",
|
|
10
|
+
"nwire",
|
|
11
|
+
"plugin"
|
|
12
|
+
],
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "./dist/app.js",
|
|
19
|
+
"types": "./dist/app.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"import": "./dist/app.js",
|
|
23
|
+
"types": "./dist/app.d.ts"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@nwire/container": "0.7.0",
|
|
31
|
+
"@nwire/logger": "0.7.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^22.19.9",
|
|
35
|
+
"typescript": "^5.9.3",
|
|
36
|
+
"vitest": "^4.0.18"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc && node ../../scripts/fix-dist-extensions.mjs dist",
|
|
40
|
+
"dev": "tsc --watch",
|
|
41
|
+
"typecheck": "tsc --noEmit"
|
|
42
|
+
}
|
|
43
|
+
}
|