@makoojs/core 0.4.0 → 0.6.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.CN.md +76 -252
- package/README.md +76 -254
- package/dist/adapter/types.d.ts +42 -51
- package/dist/error/MakooError.d.ts +22 -11
- package/dist/error/coreErrors.d.ts +6793 -0
- package/dist/error/defineMakooErrors.d.ts +55 -0
- package/dist/index.cjs +4 -5
- package/dist/index.d.ts +16 -19
- package/dist/index.js +923 -1707
- package/dist/injections/inject/declaration.d.ts +32 -0
- package/dist/injections/inject/inject.d.ts +38 -0
- package/dist/injections/injectEach/declaration.d.ts +25 -0
- package/dist/injections/injectEach/injectEach.d.ts +43 -0
- package/dist/injections/kinds.d.ts +12 -0
- package/dist/injections/listen/declaration.d.ts +34 -0
- package/dist/injections/listen/listen.d.ts +36 -0
- package/dist/injections/mount.d.ts +17 -0
- package/dist/instance/createMakoo.d.ts +3 -0
- package/dist/instance/residue.d.ts +7 -0
- package/dist/instance/types.d.ts +81 -0
- package/dist/runtime/injection.d.ts +94 -0
- package/dist/runtime/match.d.ts +50 -0
- package/dist/runtime/observer.d.ts +9 -0
- package/dist/runtime/scope.d.ts +28 -0
- package/dist/runtime/selector.d.ts +1 -0
- package/dist/runtime/stateNode.d.ts +51 -0
- package/package.json +1 -1
- package/dist/Makoo/createMakoo.d.ts +0 -4
- package/dist/Makoo/types.d.ts +0 -103
- package/dist/Task/TaskContext.d.ts +0 -25
- package/dist/Task/TaskLifeCycle.d.ts +0 -7
- package/dist/Task/TaskRegister.d.ts +0 -19
- package/dist/Task/TaskRunner.d.ts +0 -7
- package/dist/Task/types.d.ts +0 -76
- package/dist/Task/util.d.ts +0 -11
- package/dist/adapter/Adapter.d.ts +0 -2
- package/dist/error/AdapterError.d.ts +0 -4
- package/dist/error/ErrorCode.d.ts +0 -19
- package/dist/error/SignalError.d.ts +0 -4
- package/dist/error/TaskError.d.ts +0 -4
- package/dist/error/formatMakooError.d.ts +0 -2
- package/dist/hooks/ObserverHub.d.ts +0 -3
- package/dist/hooks/types.d.ts +0 -39
- package/dist/hooks/util.d.ts +0 -5
- package/dist/logger/Logger.d.ts +0 -14
- package/dist/logger/types.d.ts +0 -7
- package/dist/payload/buildAliveObservePayload.d.ts +0 -51
- package/dist/payload/buildDomObservePayload.d.ts +0 -46
- package/dist/payload/buildInjectObservePayload.d.ts +0 -54
- package/dist/payload/buildListenerObservePayload.d.ts +0 -44
- package/dist/payload/buildObservePayload.d.ts +0 -10
- package/dist/payload/buildRegisterObservePayload.d.ts +0 -44
- package/dist/payload/buildResourceObservePayload.d.ts +0 -45
- package/dist/payload/buildRunObservePayload.d.ts +0 -57
- package/dist/payload/buildTaskObservePayload.d.ts +0 -44
- package/dist/payload/createDomObserveEmitFactory.d.ts +0 -12
- package/dist/runtime/createRuntime.d.ts +0 -3
- package/dist/runtime/types.d.ts +0 -13
- package/dist/signal/observeActivitySignal.d.ts +0 -4
- package/dist/signal/types.d.ts +0 -15
- package/dist/util/getArtifactName.d.ts +0 -1
- package/dist/util/uuid.d.ts +0 -1
- package/dist/watcher/DomWatcher.d.ts +0 -13
- package/dist/watcher/types.d.ts +0 -15
package/README.md
CHANGED
|
@@ -1,289 +1,111 @@
|
|
|
1
1
|
# @makoojs/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p>
|
|
4
|
+
<a href="https://www.npmjs.com/package/@makoojs/core"><img alt="npm" src="https://img.shields.io/npm/v/@makoojs/core?style=flat-square"></a>
|
|
5
|
+
<a href="https://github.com/makoojs/Makoo/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/badge/License-MIT-yellow?style=flat-square"></a>
|
|
6
|
+
</p>
|
|
4
7
|
|
|
5
|
-
>
|
|
6
|
-
|
|
8
|
+
<p>
|
|
9
|
+
<a href="https://makoojs.github.io/Makoo/api/core">API Reference</a> •
|
|
10
|
+
<a href="https://github.com/makoojs/Makoo">Makoo</a> •
|
|
11
|
+
<a href="https://github.com/makoojs/Makoo/blob/main/packages/core/README.CN.md">中文</a>
|
|
12
|
+
</p>
|
|
7
13
|
|
|
8
|
-
|
|
14
|
+
The core package of Makoo, running in the browser. You use it to create a Core instance, declare components and page event listeners, then control them and read their status. Waiting for target elements, mounting, recovery after node replacement, and cleanup all happen here.
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
- Create a Makoo runtime with `createMakoo()` and start explicit task declarations.
|
|
12
|
-
- Listen to injection lifecycle events for debugging, analytics, error reporting, or visual devtools.
|
|
13
|
-
- Use low-level tools such as `DOMWatcher` and `createActivityStore` for custom integrations.
|
|
16
|
+
It doesn't depend on any frontend framework; components are mounted through the adapters provided by [`@makoojs/vue`](https://www.npmjs.com/package/@makoojs/vue) or [`@makoojs/react`](https://www.npmjs.com/package/@makoojs/react).
|
|
14
17
|
|
|
15
18
|
## Installation
|
|
16
19
|
|
|
17
|
-
```
|
|
18
|
-
# npm install @makoojs/core
|
|
19
|
-
# yarn add @makoojs/core
|
|
20
|
+
```sh
|
|
20
21
|
pnpm add @makoojs/core
|
|
21
22
|
```
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
> [!TIP]
|
|
25
|
+
> Projects created with `pnpm dlx @makoojs/create-makoo` already include it; no separate installation is needed.
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
import {
|
|
27
|
-
createMakoo,
|
|
28
|
-
inject,
|
|
29
|
-
type ResolvableMountAdapter
|
|
30
|
-
} from '@makoojs/core';
|
|
31
|
-
|
|
32
|
-
type TextArtifact = {
|
|
33
|
-
kind: 'text';
|
|
34
|
-
text: string;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const textAdapter: ResolvableMountAdapter<TextArtifact, HTMLElement> = {
|
|
38
|
-
name: 'text',
|
|
39
|
-
matches(artifact): artifact is TextArtifact {
|
|
40
|
-
return (
|
|
41
|
-
typeof artifact === 'object' &&
|
|
42
|
-
artifact !== null &&
|
|
43
|
-
(artifact as { kind?: unknown }).kind === 'text'
|
|
44
|
-
);
|
|
45
|
-
},
|
|
46
|
-
mount({ mountPoint, artifact }) {
|
|
47
|
-
const el = document.createElement('span');
|
|
48
|
-
el.textContent = artifact.text;
|
|
49
|
-
mountPoint.appendChild(el);
|
|
50
|
-
|
|
51
|
-
return { handle: el };
|
|
52
|
-
},
|
|
53
|
-
unmount({ handle }) {
|
|
54
|
-
handle.remove();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const makoo = createMakoo({
|
|
59
|
-
defaults: {
|
|
60
|
-
alive: true,
|
|
61
|
-
scope: 'local',
|
|
62
|
-
timeout: 5000
|
|
63
|
-
},
|
|
64
|
-
adapters: [textAdapter]
|
|
65
|
-
});
|
|
27
|
+
## Usage
|
|
66
28
|
|
|
67
|
-
|
|
68
|
-
inject({
|
|
69
|
-
id: 'text',
|
|
70
|
-
injectAt: '#app',
|
|
71
|
-
artifact: {
|
|
72
|
-
kind: 'text',
|
|
73
|
-
text: 'Hello from Makoo core'
|
|
74
|
-
}
|
|
75
|
-
})
|
|
76
|
-
]);
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Runtime Basics
|
|
80
|
-
|
|
81
|
-
`inject()` and `listen()` declare tasks. They do not touch the DOM or register tasks by themselves. `makoo.start([...])` registers the declarations in the provided batch and immediately schedules those tasks.
|
|
82
|
-
|
|
83
|
-
`inject()` accepts an object containing the target, artifact, and task options. Its optional `id` is used as the task ID, which is useful when you want to look up or control that task later:
|
|
84
|
-
|
|
85
|
-
```ts
|
|
86
|
-
inject({
|
|
87
|
-
id: 'settings-panel',
|
|
88
|
-
injectAt: '#settings',
|
|
89
|
-
artifact: settingsArtifact,
|
|
90
|
-
options: {
|
|
91
|
-
alive: true
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
When `id` is omitted, Makoo infers a task id from the artifact and target selector.
|
|
29
|
+
### Declare Components and Listeners
|
|
97
30
|
|
|
98
31
|
```ts
|
|
99
32
|
import { createMakoo, inject, listen } from '@makoojs/core';
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
inject({
|
|
133
|
-
id: 'save-tip',
|
|
134
|
-
injectAt: '#save-tip',
|
|
135
|
-
artifact: saveTipArtifact,
|
|
136
|
-
options: {
|
|
137
|
-
on: listen({
|
|
138
|
-
listenAt: '#save',
|
|
139
|
-
type: 'click',
|
|
140
|
-
callback: () => {
|
|
141
|
-
console.log('save clicked');
|
|
142
|
-
}
|
|
143
|
-
})
|
|
144
|
-
}
|
|
145
|
-
}),
|
|
146
|
-
listen({
|
|
147
|
-
id: 'escape-close',
|
|
148
|
-
listenAt: '#escape',
|
|
149
|
-
type: 'keydown',
|
|
150
|
-
callback: onEscape
|
|
151
|
-
})
|
|
33
|
+
import { vueAdapter } from '@makoojs/vue';
|
|
34
|
+
import Panel from './Panel.vue';
|
|
35
|
+
|
|
36
|
+
const core = createMakoo();
|
|
37
|
+
|
|
38
|
+
core.apply([
|
|
39
|
+
inject({
|
|
40
|
+
name: 'panel',
|
|
41
|
+
injectAt: '#sidebar',
|
|
42
|
+
adapter: vueAdapter,
|
|
43
|
+
component: Panel,
|
|
44
|
+
// remount after the site replaces #sidebar
|
|
45
|
+
reinject: true,
|
|
46
|
+
listeners: [
|
|
47
|
+
// attached listener: starts and stops with panel
|
|
48
|
+
listen({
|
|
49
|
+
name: 'search',
|
|
50
|
+
listenAt: '#search-form',
|
|
51
|
+
type: 'submit',
|
|
52
|
+
callback: () => console.log('Search submitted')
|
|
53
|
+
})
|
|
54
|
+
]
|
|
55
|
+
}),
|
|
56
|
+
// standalone listener: doesn't belong to any component
|
|
57
|
+
listen({
|
|
58
|
+
name: 'escape',
|
|
59
|
+
listenAt: 'body',
|
|
60
|
+
type: 'keydown',
|
|
61
|
+
callback: (event) => {
|
|
62
|
+
if ((event as KeyboardEvent).key === 'Escape') console.log('Escape pressed');
|
|
63
|
+
}
|
|
64
|
+
})
|
|
152
65
|
]);
|
|
153
66
|
```
|
|
154
67
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
```ts
|
|
158
|
-
const toolbar = started.get('toolbar');
|
|
159
|
-
|
|
160
|
-
if (toolbar?.kind === 'component') {
|
|
161
|
-
toolbar.disableAlive();
|
|
162
|
-
toolbar.enableAlive();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
started.destroyAll();
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
`started.destroyAll()` only affects tasks created by that start batch. `makoo.destroyAll()` affects the whole runtime.
|
|
169
|
-
|
|
170
|
-
## Adapter Contract
|
|
171
|
-
|
|
172
|
-
core does not care whether an artifact is a Vue component, a React component, or another object. It only requires adapters to implement a unified mounting protocol.
|
|
173
|
-
|
|
174
|
-
```ts
|
|
175
|
-
import type { ResolvableMountAdapter } from '@makoojs/core';
|
|
176
|
-
|
|
177
|
-
const adapter: ResolvableMountAdapter<MyArtifact, MyHandle, MyInstance> = {
|
|
178
|
-
name: 'my-adapter',
|
|
179
|
-
matches(artifact): artifact is MyArtifact {
|
|
180
|
-
return isMyArtifact(artifact);
|
|
181
|
-
},
|
|
182
|
-
mount(input) {
|
|
183
|
-
return {
|
|
184
|
-
handle,
|
|
185
|
-
instance
|
|
186
|
-
};
|
|
187
|
-
},
|
|
188
|
-
unmount(input) {
|
|
189
|
-
// Clean up according to input.reason.
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
`mount(input)` receives the target host, generated mount point, artifact, task ID, selector, and task-scoped `makoo` context.
|
|
68
|
+
### Mount on Every Match
|
|
195
69
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
Standalone listeners use the object form of `listen()`. Their optional `id` is the task ID;
|
|
199
|
-
use it when later task lookup or control needs a stable identity. A component's `on` listener
|
|
200
|
-
is owned by that component task and does not need its own ID.
|
|
201
|
-
|
|
202
|
-
`capture` defaults to `false`. Set it to `true` to run the listener during the DOM capture phase.
|
|
70
|
+
`injectEach()` mounts the same component on every element matching `injectAt`, including elements that appear later, and keeps watching while nothing matches:
|
|
203
71
|
|
|
204
72
|
```ts
|
|
205
|
-
import {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
console.log('save clicked');
|
|
217
|
-
},
|
|
218
|
-
activitySignal: () => enabled
|
|
219
|
-
})
|
|
73
|
+
import { injectEach } from '@makoojs/core';
|
|
74
|
+
import { vueAdapter } from '@makoojs/vue';
|
|
75
|
+
import Badge from './Badge.vue';
|
|
76
|
+
|
|
77
|
+
core.apply([
|
|
78
|
+
injectEach({
|
|
79
|
+
name: 'badges',
|
|
80
|
+
injectAt: '.comment .author',
|
|
81
|
+
adapter: vueAdapter,
|
|
82
|
+
component: Badge
|
|
83
|
+
})
|
|
220
84
|
]);
|
|
221
|
-
|
|
222
|
-
enabled.set(false);
|
|
223
|
-
enabled.set(true);
|
|
224
85
|
```
|
|
225
86
|
|
|
226
|
-
|
|
87
|
+
### Control Injections and Read Status
|
|
227
88
|
|
|
228
|
-
|
|
89
|
+
Get injections by name with `core.injection(name)` for Components and Each Injections, or `core.listener(name)` for Standalone Listeners. Use `kind` to distinguish a Component (`component`) from an Each Injection (`component-each`). An Each Injection lists its Children in document order through `children`.
|
|
229
90
|
|
|
230
91
|
```ts
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
});
|
|
92
|
+
const panel = core.injection('panel');
|
|
93
|
+
const escape = core.listener('escape');
|
|
234
94
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
ctrl.stopPropagation();
|
|
238
|
-
}
|
|
95
|
+
panel.subscribe(() => {
|
|
96
|
+
console.log(panel.status, panel.lastError);
|
|
239
97
|
});
|
|
240
98
|
|
|
241
|
-
|
|
99
|
+
panel.stop();
|
|
100
|
+
panel.start();
|
|
101
|
+
escape.stop();
|
|
242
102
|
```
|
|
243
103
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
- `register:start`
|
|
247
|
-
- `register:success`
|
|
248
|
-
- `start:requested`
|
|
249
|
-
- `start:taskScheduled`
|
|
250
|
-
- `artifact:mountStart`
|
|
251
|
-
- `artifact:mountSuccess`
|
|
252
|
-
- `artifact:mountFail`
|
|
253
|
-
- `listener:attached`
|
|
254
|
-
- `alive:enabled`
|
|
255
|
-
- `alive:observerStarted`
|
|
256
|
-
- `task:statusChange`
|
|
257
|
-
- `dom:targetFound`
|
|
258
|
-
- `dom:targetTimeout`
|
|
259
|
-
|
|
260
|
-
The full event name list is available from `OBSERVE_EVENT_NAMES`.
|
|
261
|
-
|
|
262
|
-
## DOMWatcher
|
|
263
|
-
|
|
264
|
-
`DOMWatcher` is core's low-level DOM observation utility. You usually do not need to use it directly because `makoo.start()` and alive mode already wrap target waiting and restoration.
|
|
265
|
-
|
|
266
|
-
## Logging And Errors
|
|
267
|
-
|
|
268
|
-
core uses `Logger` by default and prints logs with the `[Makoo]` prefix. You can pass a custom logger to `createMakoo({ logger })`.
|
|
269
|
-
|
|
270
|
-
core also exports these error-related types:
|
|
271
|
-
|
|
272
|
-
- `MakooError`
|
|
273
|
-
- `AdapterError`
|
|
274
|
-
- `TaskError`
|
|
275
|
-
- `SignalError`
|
|
276
|
-
- `ErrorCode`
|
|
277
|
-
- `MakooIssue`
|
|
104
|
+
The top-level injection controls `start()`, `stop()`, and `remove()` return nothing. Read the outcome of `start()` and `stop()` from `status` and `lastError`; after `remove()`, the name is no longer registered on the instance.
|
|
278
105
|
|
|
279
|
-
##
|
|
106
|
+
## Documentation
|
|
280
107
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
| Lifecycle observation | `ObserverHub`, `OBSERVE_EVENT_NAMES`, `ObserveEvent`, `ObserveHook`, `LifecycleHookMap` |
|
|
286
|
-
| DOM observation | `DOMWatcher` |
|
|
287
|
-
| Listener signal | `createActivityStore`, `ActivitySignalSource` |
|
|
288
|
-
| Logging | `Logger`, `ILogger`, `LoggerLevel` |
|
|
289
|
-
| Errors | `MakooError`, `AdapterError`, `TaskError`, `SignalError`, `ErrorCode` |
|
|
108
|
+
- [Core Instance](https://makoojs.github.io/Makoo/api/instance): `createMakoo()` and the methods on the instance.
|
|
109
|
+
- [Declarations](https://makoojs.github.io/Makoo/api/declarations): all fields of `inject()`, `injectEach()`, and `listen()`.
|
|
110
|
+
- [Control and Status](https://makoojs.github.io/Makoo/api/status): starting, stopping, removing, and what each status value means.
|
|
111
|
+
- [Errors and Error Codes](https://makoojs.github.io/Makoo/api/errors): error categories and how to handle them.
|
package/dist/adapter/types.d.ts
CHANGED
|
@@ -1,53 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export type AdapterMountInput<TArtifact = unknown> = {
|
|
26
|
-
host: HTMLElement;
|
|
27
|
-
mountPoint: HTMLElement;
|
|
28
|
-
artifact: TArtifact;
|
|
29
|
-
taskId: string;
|
|
30
|
-
injectAt: string;
|
|
31
|
-
makoo: MakooContext;
|
|
32
|
-
};
|
|
33
|
-
export type AdapterMountResult<THandle = unknown, TInstance = unknown> = {
|
|
34
|
-
handle: THandle;
|
|
35
|
-
instance?: TInstance;
|
|
36
|
-
};
|
|
37
|
-
export type AdapterUnmountInput<THandle = unknown> = {
|
|
38
|
-
host?: HTMLElement;
|
|
39
|
-
mountPoint: HTMLElement;
|
|
40
|
-
handle: THandle;
|
|
41
|
-
taskId: string;
|
|
42
|
-
injectAt: string;
|
|
43
|
-
reason: AdapterUnmountReason;
|
|
44
|
-
};
|
|
45
|
-
export interface MountAdapter<TArtifact = unknown, THandle = unknown, TInstance = unknown> {
|
|
46
|
-
name: string;
|
|
47
|
-
mount(input: AdapterMountInput<TArtifact>): AdapterMountResult<THandle, TInstance>;
|
|
48
|
-
unmount(input: AdapterUnmountInput<THandle>): void;
|
|
1
|
+
import { ComponentInjection } from '../injections/inject/inject';
|
|
2
|
+
import { ChildInjection } from '../injections/injectEach/injectEach';
|
|
3
|
+
import { ListenerInjection } from '../injections/listen/listen';
|
|
4
|
+
/** What Core passes to {@link MountAdapter.mount} for one mount. */
|
|
5
|
+
export interface AdapterMountParams<TComponent = unknown, TProps = unknown> {
|
|
6
|
+
/** The `component` from the declaration, unchanged. */
|
|
7
|
+
component: TComponent;
|
|
8
|
+
/**
|
|
9
|
+
* The component injection being mounted; same object as `core.injection(name)` for a
|
|
10
|
+
* top-level injection, or the Child Injection object (without `start`/`remove`) for a mount
|
|
11
|
+
* under an Each Injection.
|
|
12
|
+
*/
|
|
13
|
+
injection: ComponentInjection | ChildInjection;
|
|
14
|
+
/** The `props` from the declaration, unchanged. */
|
|
15
|
+
props: TProps | undefined;
|
|
16
|
+
/** The component container Core created inside the mount target; Core removes it after unmount. */
|
|
17
|
+
container: HTMLElement;
|
|
18
|
+
/**
|
|
19
|
+
* Looks up a standalone listener in the owning Core Instance.
|
|
20
|
+
*
|
|
21
|
+
* @throws `MakooError` with `MAKOO_INJECTION_NOT_FOUND` when no standalone listener has that
|
|
22
|
+
* name.
|
|
23
|
+
*/
|
|
24
|
+
listener(name: string): ListenerInjection;
|
|
49
25
|
}
|
|
50
|
-
|
|
51
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Integrates a frontend framework with Core's component mounting.
|
|
28
|
+
*
|
|
29
|
+
* @typeParam THandle - Whatever `mount` returns; Core passes it back to `unmount` untouched.
|
|
30
|
+
*/
|
|
31
|
+
export interface MountAdapter<TComponent = unknown, TProps = unknown, THandle = unknown> {
|
|
32
|
+
/**
|
|
33
|
+
* Mounts the component into `params.container` synchronously; a throw is an execution failure
|
|
34
|
+
* (`MAKOO_MOUNT_FAILED`).
|
|
35
|
+
*/
|
|
36
|
+
mount(params: AdapterMountParams<TComponent, TProps>): THandle;
|
|
37
|
+
/** Unmounts what `mount` created; a throw is a cleanup failure. */
|
|
38
|
+
unmount(mountHandle: THandle): void;
|
|
52
39
|
}
|
|
53
|
-
|
|
40
|
+
/**
|
|
41
|
+
* What a mounted component can do to its own injection: only the commands meaningful while it
|
|
42
|
+
* is mounted. An Each Child has no `start` / `remove`; `kind` narrows the union.
|
|
43
|
+
*/
|
|
44
|
+
export type MountedInjection = Pick<ComponentInjection, 'kind' | 'name' | 'remove' | 'stop'> | Pick<ChildInjection, 'kind' | 'name' | 'stop'>;
|
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/** How a Makoo error reaches the user: thrown, written to state, or reported as a diagnostic. */
|
|
2
|
+
export type ErrorCategory = 'configuration' | 'control' | 'execution' | 'cleanup' | 'callback';
|
|
3
|
+
type MakooErrorOptions = {
|
|
4
|
+
readonly code: string;
|
|
5
|
+
readonly category?: ErrorCategory;
|
|
6
|
+
readonly cause?: unknown;
|
|
7
|
+
readonly details?: unknown;
|
|
8
|
+
readonly errors?: readonly unknown[];
|
|
4
9
|
};
|
|
5
|
-
|
|
6
|
-
export type MakooErrorContext = Record<string, MakooErrorContextValue>;
|
|
10
|
+
/** The error type Core throws and reports; match on `code`, not on `message`. */
|
|
7
11
|
export declare class MakooError extends Error {
|
|
12
|
+
/** The delivery channel this error belongs to; set when created through an error table. */
|
|
13
|
+
readonly category?: ErrorCategory;
|
|
14
|
+
/** Identifies the problem: a code from the owning package's error table. */
|
|
8
15
|
readonly code: string;
|
|
9
|
-
|
|
10
|
-
readonly
|
|
11
|
-
|
|
12
|
-
readonly
|
|
13
|
-
constructor(message: string,
|
|
14
|
-
withContext(context: MakooErrorContext): this;
|
|
16
|
+
/** Structured, serializable context for the code; set when created through an error table. */
|
|
17
|
+
readonly details?: unknown;
|
|
18
|
+
/** Collected failures for aggregate codes, in the order they happened. */
|
|
19
|
+
readonly errors?: readonly unknown[];
|
|
20
|
+
constructor(message: string, options: MakooErrorOptions);
|
|
15
21
|
}
|
|
22
|
+
/** Whether the value carries the Makoo error mark; reliable across bundled copies. */
|
|
23
|
+
export declare function isMakooError(value: unknown): value is MakooError;
|
|
24
|
+
/** Appends one line per direct error to the headline of an aggregate error. */
|
|
25
|
+
export declare function aggregateMessage(message: string, errors: readonly unknown[]): string;
|
|
26
|
+
export {};
|