@moyarich/console-core 0.1.0 → 0.2.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 +31 -1
- package/dist/index.d.cts +648 -0
- package/package.json +16 -6
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ A React console toolkit for **capturing and displaying runtime output**.
|
|
|
4
4
|
|
|
5
5
|
Bring browser-style `console.*` messages, inspectable JavaScript values, and ANSI-formatted process output into your application. Console works well in code playgrounds, developer tools, embedded previews, and applications connected to remote runtimes.
|
|
6
6
|
|
|
7
|
+
[Documentation and live examples](https://moyarich.github.io/console/)
|
|
8
|
+
|
|
7
9
|
## Features
|
|
8
10
|
|
|
9
11
|
- **Structured messages:** Render familiar console levels and inspect JavaScript values.
|
|
@@ -20,7 +22,22 @@ Console handles presentation and message transport; your application remains in
|
|
|
20
22
|
npm install @moyarich/console
|
|
21
23
|
```
|
|
22
24
|
|
|
23
|
-
Requires React 18 or newer.
|
|
25
|
+
Requires React 18 or newer. If your application does not already include React, install it too:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install react react-dom
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The package includes TypeScript declarations and loads its core stylesheet automatically.
|
|
32
|
+
|
|
33
|
+
### GitHub Packages setup
|
|
34
|
+
|
|
35
|
+
For installations from GitHub Packages, configure the scope and authenticate with a GitHub personal access token that has `read:packages` access:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm config set @moyarich:registry https://npm.pkg.github.com
|
|
39
|
+
npm login --scope=@moyarich --registry=https://npm.pkg.github.com
|
|
40
|
+
```
|
|
24
41
|
|
|
25
42
|
## Quick start
|
|
26
43
|
|
|
@@ -50,6 +67,7 @@ Use the console-compatible producer from event handlers or runtime callbacks to
|
|
|
50
67
|
- [Console examples and guides](packages/console/examples/page.mdx)
|
|
51
68
|
- [High-volume output accessibility](packages/console/examples/36-high-volume-accessibility/page.mdx)
|
|
52
69
|
- [Virtualized output guide](packages/console/examples/38-virtualization/page.mdx)
|
|
70
|
+
- [Console lifecycle callback contracts](docs/console-lifecycle.md)
|
|
53
71
|
|
|
54
72
|
## Packages and addons
|
|
55
73
|
|
|
@@ -70,6 +88,7 @@ Console is a family of independently installable packages. Start with `@moyarich
|
|
|
70
88
|
| `@moyarich/console-addon-markdown` | Render GitHub Flavored Markdown |
|
|
71
89
|
| `@moyarich/console-addon-metadata` | Display message metadata |
|
|
72
90
|
| `@moyarich/console-addon-navigation` | Navigate between messages |
|
|
91
|
+
| `@moyarich/console-addon-persistence` | Save output through configurable persistence adapters |
|
|
73
92
|
| `@moyarich/console-addon-process-state` | Represent process execution state |
|
|
74
93
|
| `@moyarich/console-addon-resizable` | Resize the console frame |
|
|
75
94
|
| `@moyarich/console-addon-search` | Search console output |
|
|
@@ -82,3 +101,14 @@ Core console features work without optional addons. Each addon is installed sepa
|
|
|
82
101
|
## License
|
|
83
102
|
|
|
84
103
|
MIT
|
|
104
|
+
|
|
105
|
+
## Local development
|
|
106
|
+
|
|
107
|
+
Run `npm run dev` to start the playground and Storybook together:
|
|
108
|
+
|
|
109
|
+
- Playground: <http://localhost:5173/>
|
|
110
|
+
- Storybook: <http://localhost:5173/storybook/>
|
|
111
|
+
|
|
112
|
+
Both support hot reload and link to each other. Ctrl+C stops both servers. Storybook runs internally on port 6007; set `DEV_PORT` or `STORYBOOK_DEV_PORT` to change the ports.
|
|
113
|
+
|
|
114
|
+
Use `npm run dev:playground` or `npm run storybook` to start an individual server. Run `npx playwright test -c playwright.dev.config.ts` to check navigation and live connections through the unified server.
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,648 @@
|
|
|
1
|
+
/** Version of the public addon-host contract. */
|
|
2
|
+
export declare const CONSOLE_ADDON_API_VERSION = "1";
|
|
3
|
+
/** Resource that can be released deterministically. */
|
|
4
|
+
export interface ConsoleDisposable {
|
|
5
|
+
dispose(): void;
|
|
6
|
+
}
|
|
7
|
+
/** Cleanup value optionally returned from {@link ConsoleAddon.activate}. */
|
|
8
|
+
export type ConsoleAddonCleanup = void | (() => void) | ConsoleDisposable;
|
|
9
|
+
/**
|
|
10
|
+
* A console addon owns lifecycle only. Feature-specific behavior is registered
|
|
11
|
+
* through extension points and services on the addon host.
|
|
12
|
+
*/
|
|
13
|
+
export interface ConsoleAddon {
|
|
14
|
+
/**
|
|
15
|
+
* Stable, package-qualified identifier used for lifecycle management and
|
|
16
|
+
* duplicate detection. Prefer the npm package name, or
|
|
17
|
+
* `<package>:<feature>` when one package provides multiple addons.
|
|
18
|
+
*/
|
|
19
|
+
readonly id: string;
|
|
20
|
+
/** Activates the addon against one scoped console host. */
|
|
21
|
+
activate(host: ConsoleAddonHost): ConsoleAddonCleanup;
|
|
22
|
+
}
|
|
23
|
+
/** Typed token identifying a multi-provider extension point. */
|
|
24
|
+
/**
|
|
25
|
+
* Describes how multiple contributions to the same extension point compose.
|
|
26
|
+
*
|
|
27
|
+
* Contributions are always resolved in deterministic extension order:
|
|
28
|
+
* higher `priority` first, then registration order for equal priorities.
|
|
29
|
+
*
|
|
30
|
+
* - `"pipeline"`: every contribution runs sequentially. Each stage receives
|
|
31
|
+
* the immutable state produced by preceding stages.
|
|
32
|
+
* - `"first-result"`: contributions are tried in order until one handles the
|
|
33
|
+
* input and returns a result.
|
|
34
|
+
* - `"collect"`: all applicable contributions are accumulated in order.
|
|
35
|
+
* - `"all"`: every contribution must accept/pass the input. Hosts may
|
|
36
|
+
* short-circuit once the result is known.
|
|
37
|
+
* - `"middleware"`: contributions wrap the next contribution/default
|
|
38
|
+
* behavior, with the earliest resolved contribution forming the outer layer.
|
|
39
|
+
*/
|
|
40
|
+
export type ConsoleExtensionComposition = "pipeline" | "first-result" | "collect" | "all" | "middleware";
|
|
41
|
+
/** Typed metadata token identifying one multi-provider extension contract. */
|
|
42
|
+
export interface ConsoleExtensionPoint<T> {
|
|
43
|
+
/** Stable package-independent identifier used by the extension registry. */
|
|
44
|
+
readonly id: string;
|
|
45
|
+
/**
|
|
46
|
+
* Declares the host's composition semantics when multiple contributions are
|
|
47
|
+
* registered for this point.
|
|
48
|
+
*/
|
|
49
|
+
readonly composition: ConsoleExtensionComposition;
|
|
50
|
+
/** Type-only marker for the contribution accepted by this point. */
|
|
51
|
+
readonly __consoleExtensionType?: T;
|
|
52
|
+
}
|
|
53
|
+
/** Ordering metadata for one extension contribution. */
|
|
54
|
+
export interface ConsoleExtensionRegistrationOptions {
|
|
55
|
+
/** Optional identifier unique within this extension point. */
|
|
56
|
+
readonly id?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Higher priorities are resolved before lower priorities.
|
|
59
|
+
* Equal priorities preserve registration order.
|
|
60
|
+
* @default 0
|
|
61
|
+
*/
|
|
62
|
+
readonly priority?: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Registry for ordered, multi-provider console extensions.
|
|
66
|
+
*
|
|
67
|
+
* The registry owns ordering only. The host implements the behavior described
|
|
68
|
+
* by each extension point's `composition` metadata.
|
|
69
|
+
*/
|
|
70
|
+
export interface ConsoleExtensionRegistry {
|
|
71
|
+
/**
|
|
72
|
+
* Registers one contribution.
|
|
73
|
+
*
|
|
74
|
+
* Contributions with higher priorities resolve first. Equal priorities keep
|
|
75
|
+
* registration order. Disposing the returned handle removes the contribution.
|
|
76
|
+
*/
|
|
77
|
+
register<T>(point: ConsoleExtensionPoint<T>, contribution: T, options?: ConsoleExtensionRegistrationOptions): ConsoleDisposable;
|
|
78
|
+
/**
|
|
79
|
+
* Returns contributions in effective execution/rendering order.
|
|
80
|
+
*
|
|
81
|
+
* The returned order is higher priority first and stable registration order
|
|
82
|
+
* for equal priorities.
|
|
83
|
+
*/
|
|
84
|
+
getAll<T>(point: ConsoleExtensionPoint<T>): readonly T[];
|
|
85
|
+
/** Subscribes to extension registration and disposal changes. */
|
|
86
|
+
subscribe(listener: () => void): ConsoleDisposable;
|
|
87
|
+
}
|
|
88
|
+
/** Typed token identifying a single-provider service. */
|
|
89
|
+
export interface ConsoleServiceToken<T> {
|
|
90
|
+
readonly id: string;
|
|
91
|
+
readonly __consoleServiceType?: T;
|
|
92
|
+
}
|
|
93
|
+
/** Registry for shared core/addon APIs and stateful services. */
|
|
94
|
+
export interface ConsoleServiceRegistry {
|
|
95
|
+
has<T>(token: ConsoleServiceToken<T>): boolean;
|
|
96
|
+
get<T>(token: ConsoleServiceToken<T>): T | undefined;
|
|
97
|
+
require<T>(token: ConsoleServiceToken<T>): T;
|
|
98
|
+
provide<T>(token: ConsoleServiceToken<T>, service: T): ConsoleDisposable;
|
|
99
|
+
subscribe(listener: () => void): ConsoleDisposable;
|
|
100
|
+
}
|
|
101
|
+
/** Stable identifier for optional host functionality. */
|
|
102
|
+
export interface ConsoleCapability {
|
|
103
|
+
readonly id: string;
|
|
104
|
+
}
|
|
105
|
+
/** Read-only capability discovery available to addons. */
|
|
106
|
+
export interface ConsoleCapabilityRegistry {
|
|
107
|
+
has(capability: ConsoleCapability): boolean;
|
|
108
|
+
getAll(): readonly ConsoleCapability[];
|
|
109
|
+
}
|
|
110
|
+
/** Disposable collection owned by one addon activation. */
|
|
111
|
+
export interface ConsoleDisposableScope extends ConsoleDisposable {
|
|
112
|
+
add<T extends ConsoleDisposable>(disposable: T): T;
|
|
113
|
+
defer(cleanup: () => void): ConsoleDisposable;
|
|
114
|
+
}
|
|
115
|
+
/** Public surface supplied to one addon activation. */
|
|
116
|
+
export interface ConsoleAddonHost {
|
|
117
|
+
readonly version: string;
|
|
118
|
+
readonly extensions: ConsoleExtensionRegistry;
|
|
119
|
+
readonly services: ConsoleServiceRegistry;
|
|
120
|
+
readonly capabilities: ConsoleCapabilityRegistry;
|
|
121
|
+
readonly scope: ConsoleDisposableScope;
|
|
122
|
+
}
|
|
123
|
+
/** Options used to construct an addon manager. */
|
|
124
|
+
export interface CreateConsoleAddonManagerOptions {
|
|
125
|
+
readonly version?: string;
|
|
126
|
+
readonly capabilities?: readonly ConsoleCapability[];
|
|
127
|
+
}
|
|
128
|
+
/** Loads addons and owns the registries shared by those addon activations. */
|
|
129
|
+
export interface ConsoleAddonManager extends ConsoleDisposable {
|
|
130
|
+
readonly version: string;
|
|
131
|
+
readonly extensions: ConsoleExtensionRegistry;
|
|
132
|
+
readonly services: ConsoleServiceRegistry;
|
|
133
|
+
readonly capabilities: ConsoleCapabilityRegistry;
|
|
134
|
+
load(addon: ConsoleAddon): ConsoleDisposable;
|
|
135
|
+
unload(id: string): boolean;
|
|
136
|
+
has(id: string): boolean;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Creates a typed multi-provider extension-point token.
|
|
140
|
+
*
|
|
141
|
+
* @param id Stable identifier for the extension contract.
|
|
142
|
+
* @param composition How a host composes multiple registered contributions.
|
|
143
|
+
* @defaultValue composition `"collect"`
|
|
144
|
+
*/
|
|
145
|
+
export declare function createConsoleExtensionPoint<T>(id: string, composition?: ConsoleExtensionComposition): ConsoleExtensionPoint<T>;
|
|
146
|
+
/** Creates an independent extension registry for advanced/headless hosts. */
|
|
147
|
+
export declare function createConsoleExtensionRegistry(): ConsoleExtensionRegistry;
|
|
148
|
+
/** Creates a typed single-provider service token. */
|
|
149
|
+
export declare function createConsoleServiceToken<T>(id: string): ConsoleServiceToken<T>;
|
|
150
|
+
/** Creates an independent service registry for advanced/headless hosts. */
|
|
151
|
+
export declare function createConsoleServiceRegistry(): ConsoleServiceRegistry;
|
|
152
|
+
/** Creates a stable capability identifier. */
|
|
153
|
+
export declare function createConsoleCapability(id: string): ConsoleCapability;
|
|
154
|
+
/** Creates an independent read-only capability registry. */
|
|
155
|
+
export declare function createConsoleCapabilityRegistry(capabilities?: readonly ConsoleCapability[]): ConsoleCapabilityRegistry;
|
|
156
|
+
/** Creates an idempotent disposable collection. */
|
|
157
|
+
export declare function createConsoleDisposableScope(): ConsoleDisposableScope;
|
|
158
|
+
/**
|
|
159
|
+
* Creates an addon manager suitable for UI or headless console hosts.
|
|
160
|
+
*
|
|
161
|
+
* Each loaded addon receives a scoped host. Registrations made through that
|
|
162
|
+
* host are automatically removed when the addon is unloaded.
|
|
163
|
+
*/
|
|
164
|
+
export declare function createConsoleAddonManager(options?: CreateConsoleAddonManagerOptions): ConsoleAddonManager;
|
|
165
|
+
/** Structured console message method understood by console hosts. */
|
|
166
|
+
export type ConsoleMethod = "log" | "debug" | "info" | "warn" | "error" | "assert" | "dir" | "table" | "count" | "timeEnd" | "trace" | "group" | "groupCollapsed";
|
|
167
|
+
/** Rendering/data mode understood by console hosts. */
|
|
168
|
+
export type ConsoleMode = "console" | "terminal";
|
|
169
|
+
/** Structured message shared by hosts, transports, and addons. */
|
|
170
|
+
export interface ConsoleMessageData {
|
|
171
|
+
id?: string;
|
|
172
|
+
method: ConsoleMethod;
|
|
173
|
+
data: unknown[];
|
|
174
|
+
depth: number;
|
|
175
|
+
timestamp?: number;
|
|
176
|
+
source?: string;
|
|
177
|
+
columns?: string[];
|
|
178
|
+
expandLevel?: number;
|
|
179
|
+
showNonenumerable?: boolean;
|
|
180
|
+
}
|
|
181
|
+
/** Context used to decide whether one structured console message is visible. */
|
|
182
|
+
export interface ConsoleMessageFilterContext {
|
|
183
|
+
readonly message: ConsoleMessageData;
|
|
184
|
+
readonly index: number;
|
|
185
|
+
readonly messages: readonly ConsoleMessageData[];
|
|
186
|
+
}
|
|
187
|
+
/** Predicate used to decide whether a structured console message is visible. */
|
|
188
|
+
export type ConsoleMessageFilter = (context: ConsoleMessageFilterContext) => boolean;
|
|
189
|
+
export interface RunOutput {
|
|
190
|
+
messages: ConsoleMessageData[];
|
|
191
|
+
error?: string;
|
|
192
|
+
}
|
|
193
|
+
export interface DirOptions {
|
|
194
|
+
depth?: number | null;
|
|
195
|
+
showHidden?: boolean;
|
|
196
|
+
}
|
|
197
|
+
export type ConsoleEvent = {
|
|
198
|
+
type: "message";
|
|
199
|
+
message: ConsoleMessageData;
|
|
200
|
+
} | {
|
|
201
|
+
type: "clear";
|
|
202
|
+
};
|
|
203
|
+
export interface ConsoleTransportEnvelope {
|
|
204
|
+
type: "CONSOLE_PANEL";
|
|
205
|
+
version: 1;
|
|
206
|
+
channel: string;
|
|
207
|
+
event: ConsoleEvent;
|
|
208
|
+
}
|
|
209
|
+
export type ConsoleOutputStream = "stdout" | "stderr";
|
|
210
|
+
export type ConsoleProcessOutputMetadata = Readonly<Record<string, unknown>>;
|
|
211
|
+
export interface ConsoleStdoutEntry {
|
|
212
|
+
id?: string;
|
|
213
|
+
data: string;
|
|
214
|
+
stream?: ConsoleOutputStream;
|
|
215
|
+
metadata?: ConsoleProcessOutputMetadata;
|
|
216
|
+
}
|
|
217
|
+
export interface ConsoleLink {
|
|
218
|
+
text: string;
|
|
219
|
+
start: number;
|
|
220
|
+
end: number;
|
|
221
|
+
target?: string;
|
|
222
|
+
title?: string;
|
|
223
|
+
action?: (context: ConsoleLinkActionContext) => void;
|
|
224
|
+
}
|
|
225
|
+
export interface ConsoleLinkProviderContext {
|
|
226
|
+
readonly text: string;
|
|
227
|
+
readonly mode: ConsoleMode;
|
|
228
|
+
readonly value?: unknown;
|
|
229
|
+
readonly propertyKey?: string;
|
|
230
|
+
readonly index?: number;
|
|
231
|
+
readonly id?: string;
|
|
232
|
+
readonly stream?: ConsoleOutputStream;
|
|
233
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
234
|
+
}
|
|
235
|
+
export interface ConsoleLinkActionContext extends ConsoleLinkProviderContext {
|
|
236
|
+
readonly link: ConsoleLink;
|
|
237
|
+
readonly providerId?: string;
|
|
238
|
+
}
|
|
239
|
+
export interface ConsoleLinkProvider {
|
|
240
|
+
readonly id?: string;
|
|
241
|
+
provideLinks(context: ConsoleLinkProviderContext): readonly ConsoleLink[] | undefined | void;
|
|
242
|
+
}
|
|
243
|
+
export interface ConsoleProcessOutput {
|
|
244
|
+
readonly data: string;
|
|
245
|
+
readonly structuredValue?: unknown;
|
|
246
|
+
readonly links?: readonly ConsoleLink[];
|
|
247
|
+
readonly metadata: ConsoleProcessOutputMetadata;
|
|
248
|
+
}
|
|
249
|
+
export interface ConsoleProcessControlEvent {
|
|
250
|
+
readonly type: string;
|
|
251
|
+
readonly data?: Readonly<Record<string, unknown>>;
|
|
252
|
+
}
|
|
253
|
+
export interface ConsoleProcessControlOutput {
|
|
254
|
+
readonly data: string;
|
|
255
|
+
readonly metadata: ConsoleProcessOutputMetadata;
|
|
256
|
+
}
|
|
257
|
+
export interface ConsoleProcessControlParserContext {
|
|
258
|
+
readonly output: ConsoleProcessControlOutput;
|
|
259
|
+
readonly entry: ConsoleStdoutEntry | string;
|
|
260
|
+
readonly index: number;
|
|
261
|
+
readonly id?: string;
|
|
262
|
+
readonly stream?: ConsoleOutputStream;
|
|
263
|
+
}
|
|
264
|
+
export interface ConsoleProcessControlParserResult {
|
|
265
|
+
data?: string;
|
|
266
|
+
metadata?: Readonly<Record<string, unknown>>;
|
|
267
|
+
events?: readonly ConsoleProcessControlEvent[];
|
|
268
|
+
omit?: boolean;
|
|
269
|
+
}
|
|
270
|
+
export interface ConsoleProcessControlParser {
|
|
271
|
+
readonly id?: string;
|
|
272
|
+
parse(context: ConsoleProcessControlParserContext): ConsoleProcessControlParserResult | undefined | void;
|
|
273
|
+
reset?(): void;
|
|
274
|
+
}
|
|
275
|
+
export interface ConsoleProcessOutputProcessorContext {
|
|
276
|
+
readonly output: ConsoleProcessOutput;
|
|
277
|
+
readonly entry: ConsoleStdoutEntry | string;
|
|
278
|
+
readonly index: number;
|
|
279
|
+
readonly text: string;
|
|
280
|
+
readonly id?: string;
|
|
281
|
+
readonly stream?: ConsoleOutputStream;
|
|
282
|
+
}
|
|
283
|
+
export interface ConsoleProcessOutputProcessorResult {
|
|
284
|
+
data?: string;
|
|
285
|
+
structuredValue?: unknown;
|
|
286
|
+
links?: readonly ConsoleLink[];
|
|
287
|
+
metadata?: Readonly<Record<string, unknown>>;
|
|
288
|
+
}
|
|
289
|
+
export interface ConsoleProcessOutputProcessor {
|
|
290
|
+
readonly id?: string;
|
|
291
|
+
process(context: ConsoleProcessOutputProcessorContext): ConsoleProcessOutputProcessorResult | undefined | void;
|
|
292
|
+
}
|
|
293
|
+
export interface ConsoleResolvedProcessOutputEntry {
|
|
294
|
+
readonly entry: ConsoleStdoutEntry;
|
|
295
|
+
readonly output: ConsoleProcessOutput;
|
|
296
|
+
}
|
|
297
|
+
export type ConsoleProcessViewEntry = ConsoleResolvedProcessOutputEntry;
|
|
298
|
+
export interface ConsoleStructuredOutputParserContext {
|
|
299
|
+
readonly text: string;
|
|
300
|
+
readonly entry: ConsoleStdoutEntry | string;
|
|
301
|
+
readonly index: number;
|
|
302
|
+
readonly id?: string;
|
|
303
|
+
readonly stream?: ConsoleOutputStream;
|
|
304
|
+
readonly metadata?: ConsoleProcessOutputMetadata;
|
|
305
|
+
}
|
|
306
|
+
export type ConsoleStructuredOutputParser = (context: ConsoleStructuredOutputParserContext) => unknown | undefined;
|
|
307
|
+
export interface ConsoleStructuredDataSnapshot {
|
|
308
|
+
readonly mode: "console";
|
|
309
|
+
readonly all: readonly ConsoleMessageData[];
|
|
310
|
+
readonly visible: readonly ConsoleMessageData[];
|
|
311
|
+
}
|
|
312
|
+
export interface ConsoleProcessDataSnapshot {
|
|
313
|
+
readonly mode: "terminal";
|
|
314
|
+
readonly rawEntries: readonly (ConsoleStdoutEntry | string)[];
|
|
315
|
+
readonly all: readonly ConsoleProcessViewEntry[];
|
|
316
|
+
readonly visible: readonly ConsoleProcessViewEntry[];
|
|
317
|
+
readonly controlEvents?: readonly ConsoleProcessControlEvent[];
|
|
318
|
+
}
|
|
319
|
+
export type ConsoleDataSnapshot = ConsoleStructuredDataSnapshot | ConsoleProcessDataSnapshot;
|
|
320
|
+
export interface ConsoleDataService {
|
|
321
|
+
getSnapshot(): ConsoleDataSnapshot;
|
|
322
|
+
subscribe(listener: () => void): ConsoleDisposable;
|
|
323
|
+
}
|
|
324
|
+
export interface ConsoleScrollOptions {
|
|
325
|
+
behavior?: ScrollBehavior;
|
|
326
|
+
block?: ScrollLogicalPosition;
|
|
327
|
+
inline?: ScrollLogicalPosition;
|
|
328
|
+
}
|
|
329
|
+
export interface ConsoleViewportService {
|
|
330
|
+
scrollToTop(): void;
|
|
331
|
+
scrollToBottom(): void;
|
|
332
|
+
scrollToMessage(id: string, options?: ConsoleScrollOptions): boolean;
|
|
333
|
+
isAtBottom(): boolean;
|
|
334
|
+
isAtTop(): boolean;
|
|
335
|
+
focus(): void;
|
|
336
|
+
}
|
|
337
|
+
export interface ConsoleActionContextBase {
|
|
338
|
+
readonly mode: ConsoleMode;
|
|
339
|
+
readonly hasMessages: boolean;
|
|
340
|
+
}
|
|
341
|
+
export interface ConsoleSurfaceActionContext extends ConsoleActionContextBase {
|
|
342
|
+
readonly kind: "console";
|
|
343
|
+
}
|
|
344
|
+
export interface ConsoleObjectActionContext extends ConsoleActionContextBase {
|
|
345
|
+
readonly kind: "object";
|
|
346
|
+
readonly value: object;
|
|
347
|
+
}
|
|
348
|
+
export interface ConsoleMessageActionContext extends ConsoleActionContextBase {
|
|
349
|
+
readonly kind: "message";
|
|
350
|
+
readonly message: ConsoleMessageData;
|
|
351
|
+
readonly index: number;
|
|
352
|
+
readonly messages: readonly ConsoleMessageData[];
|
|
353
|
+
}
|
|
354
|
+
export type ConsoleContextMenuActionContext = ConsoleSurfaceActionContext | ConsoleObjectActionContext | ConsoleMessageActionContext;
|
|
355
|
+
export type ConsoleActionPredicate<TContext> = boolean | ((context: TContext) => boolean);
|
|
356
|
+
export type ConsoleActionVariant = "default" | "danger";
|
|
357
|
+
/**
|
|
358
|
+
* UI payloads are generic so the core addon SDK does not depend on React.
|
|
359
|
+
* React hosts specialize this type to ReactNode.
|
|
360
|
+
*/
|
|
361
|
+
export interface ConsoleAction<TContext, TUi = unknown> {
|
|
362
|
+
id: string;
|
|
363
|
+
label: TUi;
|
|
364
|
+
ariaLabel?: string;
|
|
365
|
+
icon?: TUi;
|
|
366
|
+
variant?: ConsoleActionVariant;
|
|
367
|
+
separatorBefore?: boolean;
|
|
368
|
+
visible?: ConsoleActionPredicate<TContext>;
|
|
369
|
+
disabled?: ConsoleActionPredicate<TContext>;
|
|
370
|
+
onSelect: (context: TContext) => void | Promise<void>;
|
|
371
|
+
}
|
|
372
|
+
export type ConsolePanelAction<TUi = unknown> = ConsoleAction<ConsoleSurfaceActionContext, TUi>;
|
|
373
|
+
export type ConsoleContextMenuAction<TUi = unknown> = ConsoleAction<ConsoleContextMenuActionContext, TUi>;
|
|
374
|
+
export type ConsoleMessageAction<TUi = unknown> = ConsoleAction<ConsoleMessageActionContext, TUi>;
|
|
375
|
+
export interface ConsoleKeyboardShortcutContext {
|
|
376
|
+
readonly mode: ConsoleMode;
|
|
377
|
+
readonly hasMessages: boolean;
|
|
378
|
+
readonly isEmpty: boolean;
|
|
379
|
+
}
|
|
380
|
+
export interface ConsoleKeyboardShortcut {
|
|
381
|
+
readonly id: string;
|
|
382
|
+
readonly key: string;
|
|
383
|
+
readonly altKey?: boolean;
|
|
384
|
+
readonly ctrlKey?: boolean;
|
|
385
|
+
readonly metaKey?: boolean;
|
|
386
|
+
readonly shiftKey?: boolean;
|
|
387
|
+
readonly allowInEditable?: boolean;
|
|
388
|
+
readonly preventDefault?: boolean;
|
|
389
|
+
readonly stopPropagation?: boolean;
|
|
390
|
+
when?: (context: ConsoleKeyboardShortcutContext) => boolean;
|
|
391
|
+
onTrigger: (context: ConsoleKeyboardShortcutContext) => void | Promise<void>;
|
|
392
|
+
}
|
|
393
|
+
export type ConsolePanelElementPlacement = "header-start" | "header-end" | "before-output" | "after-output" | "footer";
|
|
394
|
+
export interface ConsolePanelElementContext {
|
|
395
|
+
readonly mode: ConsoleMode;
|
|
396
|
+
readonly hasMessages: boolean;
|
|
397
|
+
readonly isEmpty: boolean;
|
|
398
|
+
}
|
|
399
|
+
export interface ConsolePanelElement<TUi = unknown> {
|
|
400
|
+
readonly id: string;
|
|
401
|
+
readonly placement: ConsolePanelElementPlacement;
|
|
402
|
+
render: (context: ConsolePanelElementContext) => TUi | undefined;
|
|
403
|
+
}
|
|
404
|
+
export type ConsoleMessageDecorationPlacement = "gutter" | "before" | "after" | "badge" | "overlay";
|
|
405
|
+
export interface ConsoleMessageDecorationContext {
|
|
406
|
+
readonly message: ConsoleMessageData;
|
|
407
|
+
readonly index: number;
|
|
408
|
+
readonly messages: readonly ConsoleMessageData[];
|
|
409
|
+
readonly placement: ConsoleMessageDecorationPlacement;
|
|
410
|
+
}
|
|
411
|
+
export interface ConsoleMessageDecoration<TUi = unknown> {
|
|
412
|
+
readonly id: string;
|
|
413
|
+
readonly placement: ConsoleMessageDecorationPlacement;
|
|
414
|
+
match?: (context: ConsoleMessageDecorationContext) => boolean;
|
|
415
|
+
render: (context: ConsoleMessageDecorationContext) => TUi | undefined;
|
|
416
|
+
}
|
|
417
|
+
export type ConsoleOutputRendererContext<TUi = unknown> = {
|
|
418
|
+
readonly mode: "console";
|
|
419
|
+
readonly messages: readonly ConsoleMessageData[];
|
|
420
|
+
readonly renderDefault: () => TUi;
|
|
421
|
+
} | {
|
|
422
|
+
readonly mode: "terminal";
|
|
423
|
+
readonly entries: readonly (ConsoleStdoutEntry | string)[];
|
|
424
|
+
readonly renderDefault: () => TUi;
|
|
425
|
+
};
|
|
426
|
+
export interface ConsoleOutputRenderer<TUi = unknown> {
|
|
427
|
+
mode?: ConsoleMode;
|
|
428
|
+
match?: (context: ConsoleOutputRendererContext<TUi>) => boolean;
|
|
429
|
+
render: (context: ConsoleOutputRendererContext<TUi>) => TUi | undefined;
|
|
430
|
+
}
|
|
431
|
+
export type ConsoleOutputEntryDecoratorContext<TUi = unknown> = {
|
|
432
|
+
readonly mode: "console";
|
|
433
|
+
readonly message: ConsoleMessageData;
|
|
434
|
+
readonly index: number;
|
|
435
|
+
readonly id?: string;
|
|
436
|
+
readonly renderDefault: () => TUi;
|
|
437
|
+
} | {
|
|
438
|
+
readonly mode: "terminal";
|
|
439
|
+
readonly entry: ConsoleStdoutEntry;
|
|
440
|
+
readonly index: number;
|
|
441
|
+
readonly id?: string;
|
|
442
|
+
readonly renderDefault: () => TUi;
|
|
443
|
+
};
|
|
444
|
+
/** Wraps one fully rendered output entry, preserving its interactive children. */
|
|
445
|
+
export interface ConsoleOutputEntryDecorator<TUi = unknown> {
|
|
446
|
+
render(context: ConsoleOutputEntryDecoratorContext<TUi>): TUi | undefined;
|
|
447
|
+
}
|
|
448
|
+
export interface ConsoleFrameDecoratorContext<TUi = unknown> {
|
|
449
|
+
readonly mode: ConsoleMode;
|
|
450
|
+
readonly renderDefault: () => TUi;
|
|
451
|
+
}
|
|
452
|
+
export interface ConsoleFrameDecorator<TUi = unknown> {
|
|
453
|
+
render: (context: ConsoleFrameDecoratorContext<TUi>) => TUi | undefined;
|
|
454
|
+
}
|
|
455
|
+
export interface ConsoleEmptyStateRendererContext<TUi = unknown> {
|
|
456
|
+
readonly mode: ConsoleMode;
|
|
457
|
+
readonly hasMessages: boolean;
|
|
458
|
+
readonly message: string;
|
|
459
|
+
readonly renderDefault: () => TUi;
|
|
460
|
+
}
|
|
461
|
+
export interface ConsoleEmptyStateRenderer<TUi = unknown> {
|
|
462
|
+
readonly mode?: ConsoleMode;
|
|
463
|
+
match?: (context: ConsoleEmptyStateRendererContext<TUi>) => boolean;
|
|
464
|
+
render: (context: ConsoleEmptyStateRendererContext<TUi>) => TUi | undefined;
|
|
465
|
+
}
|
|
466
|
+
/** A presentation-only match range within the rendered text (UTF-16 offsets). */
|
|
467
|
+
export interface ConsoleTextHighlightRange {
|
|
468
|
+
readonly start: number;
|
|
469
|
+
readonly end: number;
|
|
470
|
+
readonly active?: boolean;
|
|
471
|
+
}
|
|
472
|
+
/** Optional, reactive addon-provided text highlights. Does not change source output. */
|
|
473
|
+
export interface ConsoleTextHighlightProvider {
|
|
474
|
+
subscribe(listener: () => void): () => void;
|
|
475
|
+
getSnapshot(): unknown;
|
|
476
|
+
getRanges(text: string, context: ConsoleLinkProviderContext): readonly ConsoleTextHighlightRange[];
|
|
477
|
+
}
|
|
478
|
+
export interface ConsoleMessageTextProviderContext {
|
|
479
|
+
readonly message: ConsoleMessageData;
|
|
480
|
+
readonly index: number;
|
|
481
|
+
readonly messages: readonly ConsoleMessageData[];
|
|
482
|
+
}
|
|
483
|
+
export interface ConsoleMessageTextProvider {
|
|
484
|
+
readonly id?: string;
|
|
485
|
+
provideText: (context: ConsoleMessageTextProviderContext) => string | readonly string[] | undefined;
|
|
486
|
+
}
|
|
487
|
+
export interface ConsoleMessageRendererContext<TUi = unknown> {
|
|
488
|
+
readonly message: ConsoleMessageData;
|
|
489
|
+
readonly index: number;
|
|
490
|
+
readonly messages: readonly ConsoleMessageData[];
|
|
491
|
+
readonly renderDefault: () => TUi;
|
|
492
|
+
}
|
|
493
|
+
export interface ConsoleMessageRenderer<TUi = unknown> {
|
|
494
|
+
readonly method?: ConsoleMethod;
|
|
495
|
+
match?: (context: ConsoleMessageRendererContext<TUi>) => boolean;
|
|
496
|
+
render: (context: ConsoleMessageRendererContext<TUi>) => TUi | undefined;
|
|
497
|
+
}
|
|
498
|
+
export interface ConsoleValueRendererContext<TUi = unknown> {
|
|
499
|
+
readonly value: unknown;
|
|
500
|
+
readonly propertyKey?: string;
|
|
501
|
+
readonly depth: number;
|
|
502
|
+
readonly type: string;
|
|
503
|
+
readonly renderDefault: () => TUi;
|
|
504
|
+
}
|
|
505
|
+
export interface ConsoleValueRenderer<TUi = unknown> {
|
|
506
|
+
readonly type?: string;
|
|
507
|
+
match?: (context: ConsoleValueRendererContext<TUi>) => boolean;
|
|
508
|
+
render: (context: ConsoleValueRendererContext<TUi>) => TUi | undefined;
|
|
509
|
+
}
|
|
510
|
+
/** Built-in capabilities understood by the standard console host. */
|
|
511
|
+
export declare const consoleCapabilities: Readonly<{
|
|
512
|
+
react: ConsoleCapability;
|
|
513
|
+
dom: ConsoleCapability;
|
|
514
|
+
structuredMessages: ConsoleCapability;
|
|
515
|
+
processOutput: ConsoleCapability;
|
|
516
|
+
}>;
|
|
517
|
+
/** Shared service tokens used by console hosts and addons. */
|
|
518
|
+
export declare const consoleServices: Readonly<{
|
|
519
|
+
viewport: ConsoleServiceToken<ConsoleViewportService>;
|
|
520
|
+
data: ConsoleServiceToken<ConsoleDataService>;
|
|
521
|
+
}>;
|
|
522
|
+
/** Shared extension-point tokens used by console hosts and addons. */
|
|
523
|
+
/**
|
|
524
|
+
* Built-in extension contracts supported by Console hosts.
|
|
525
|
+
*
|
|
526
|
+
* Each point declares its composition strategy so addon authors can determine
|
|
527
|
+
* whether registration order affects transformation, matching, rendering, or
|
|
528
|
+
* collection behavior directly from IDE hover information.
|
|
529
|
+
*/
|
|
530
|
+
export declare const consoleExtensionPoints: Readonly<{
|
|
531
|
+
/**
|
|
532
|
+
* Parses stateful controls from raw process chunks before CR/newline
|
|
533
|
+
* normalization.
|
|
534
|
+
*
|
|
535
|
+
* @composition pipeline Each parser receives the output of preceding parsers.
|
|
536
|
+
*/
|
|
537
|
+
processControlParser: ConsoleExtensionPoint<ConsoleProcessControlParser>;
|
|
538
|
+
/**
|
|
539
|
+
* Transforms/enriches normalized process output before structured parsing.
|
|
540
|
+
*
|
|
541
|
+
* @composition pipeline Each processor receives accumulated prior output.
|
|
542
|
+
*/
|
|
543
|
+
processOutputProcessor: ConsoleExtensionPoint<ConsoleProcessOutputProcessor>;
|
|
544
|
+
/**
|
|
545
|
+
* Promotes process text to structured values.
|
|
546
|
+
*
|
|
547
|
+
* @composition first-result The first parser returning a value wins.
|
|
548
|
+
*/
|
|
549
|
+
structuredOutputParser: ConsoleExtensionPoint<ConsoleStructuredOutputParser>;
|
|
550
|
+
/**
|
|
551
|
+
* Discovers application-specific interactive link ranges.
|
|
552
|
+
*
|
|
553
|
+
* @composition collect All providers contribute; earlier overlapping ranges win.
|
|
554
|
+
*/
|
|
555
|
+
linkProvider: ConsoleExtensionPoint<ConsoleLinkProvider>;
|
|
556
|
+
/**
|
|
557
|
+
* Replaces the complete output surface.
|
|
558
|
+
*
|
|
559
|
+
* @composition first-result The first renderer returning a value wins.
|
|
560
|
+
*/
|
|
561
|
+
outputRenderer: ConsoleExtensionPoint<ConsoleOutputRenderer<unknown>>;
|
|
562
|
+
/**
|
|
563
|
+
* Structurally wraps the complete Console frame.
|
|
564
|
+
*
|
|
565
|
+
* @composition middleware Earlier contributions become outer wrappers.
|
|
566
|
+
*/
|
|
567
|
+
outputEntryDecorator: ConsoleExtensionPoint<ConsoleOutputEntryDecorator<unknown>>;
|
|
568
|
+
frameDecorator: ConsoleExtensionPoint<ConsoleFrameDecorator<unknown>>;
|
|
569
|
+
/**
|
|
570
|
+
* Customizes the empty-output surface without replacing normal output.
|
|
571
|
+
*
|
|
572
|
+
* @composition first-result The first matching renderer returning a value wins.
|
|
573
|
+
*/
|
|
574
|
+
emptyStateRenderer: ConsoleExtensionPoint<ConsoleEmptyStateRenderer<unknown>>;
|
|
575
|
+
/**
|
|
576
|
+
* Adds persistent addon UI to generic panel placements.
|
|
577
|
+
*
|
|
578
|
+
* @composition collect All matching elements render in resolved order.
|
|
579
|
+
*/
|
|
580
|
+
panelElement: ConsoleExtensionPoint<ConsolePanelElement<unknown>>;
|
|
581
|
+
/**
|
|
582
|
+
* Contributes structured-message visibility predicates.
|
|
583
|
+
*
|
|
584
|
+
* @composition all A message must pass every registered filter.
|
|
585
|
+
*/
|
|
586
|
+
messageFilter: ConsoleExtensionPoint<ConsoleMessageFilter>;
|
|
587
|
+
/**
|
|
588
|
+
* Replaces one structured-message row.
|
|
589
|
+
*
|
|
590
|
+
* @composition first-result The first matching renderer returning a value wins.
|
|
591
|
+
*/
|
|
592
|
+
messageRenderer: ConsoleExtensionPoint<ConsoleMessageRenderer<unknown>>;
|
|
593
|
+
/**
|
|
594
|
+
* Adds UI around a structured message without replacing its renderer.
|
|
595
|
+
*
|
|
596
|
+
* @composition collect All matching decorations render in resolved order.
|
|
597
|
+
*/
|
|
598
|
+
messageDecoration: ConsoleExtensionPoint<ConsoleMessageDecoration<unknown>>;
|
|
599
|
+
/**
|
|
600
|
+
* Contributes logical searchable/plain text for structured messages.
|
|
601
|
+
*
|
|
602
|
+
* @composition collect Text from all providers is accumulated in resolved order.
|
|
603
|
+
*/
|
|
604
|
+
/** A single presentation-only provider for inline text highlighting. */
|
|
605
|
+
textHighlightProvider: ConsoleExtensionPoint<ConsoleTextHighlightProvider>;
|
|
606
|
+
messageTextProvider: ConsoleExtensionPoint<ConsoleMessageTextProvider>;
|
|
607
|
+
/**
|
|
608
|
+
* Replaces rendering for an individual structured value.
|
|
609
|
+
*
|
|
610
|
+
* @composition first-result The first matching renderer returning a value wins.
|
|
611
|
+
*/
|
|
612
|
+
valueRenderer: ConsoleExtensionPoint<ConsoleValueRenderer<unknown>>;
|
|
613
|
+
/**
|
|
614
|
+
* Contributes keyboard commands scoped to the focused Console.
|
|
615
|
+
*
|
|
616
|
+
* @composition first-result The first matching enabled shortcut handles the event.
|
|
617
|
+
*/
|
|
618
|
+
keyboardShortcut: ConsoleExtensionPoint<ConsoleKeyboardShortcut>;
|
|
619
|
+
/**
|
|
620
|
+
* Adds Console-level actions.
|
|
621
|
+
*
|
|
622
|
+
* @composition collect All visible actions are accumulated in resolved order.
|
|
623
|
+
*/
|
|
624
|
+
panelAction: ConsoleExtensionPoint<ConsolePanelAction<unknown>>;
|
|
625
|
+
/**
|
|
626
|
+
* Adds context-menu actions for Console, object, or message targets.
|
|
627
|
+
*
|
|
628
|
+
* @composition collect All visible actions are accumulated in resolved order.
|
|
629
|
+
*/
|
|
630
|
+
contextMenuAction: ConsoleExtensionPoint<ConsoleContextMenuAction<unknown>>;
|
|
631
|
+
/**
|
|
632
|
+
* Adds actions scoped to one structured message.
|
|
633
|
+
*
|
|
634
|
+
* @composition collect All visible actions are accumulated in resolved order.
|
|
635
|
+
*/
|
|
636
|
+
messageAction: ConsoleExtensionPoint<ConsoleMessageAction<unknown>>;
|
|
637
|
+
}>;
|
|
638
|
+
/** Converts rich JavaScript values into a stable JSON-safe representation. */
|
|
639
|
+
export declare function serializeConsoleValue(value: unknown, options?: {
|
|
640
|
+
maxDepth?: number;
|
|
641
|
+
maxEntries?: number;
|
|
642
|
+
}): unknown;
|
|
643
|
+
/** Normalizes a value for readable object-copy output. */
|
|
644
|
+
export declare function normalizeConsoleValue(value: unknown, seen?: WeakSet<object>): unknown;
|
|
645
|
+
/** Formats an inspectable object as readable JSON. */
|
|
646
|
+
export declare function formatConsoleObjectForCopy(value: object): string;
|
|
647
|
+
/** Clipboard helper shared by browser-hosted addons and the React host. */
|
|
648
|
+
export declare function writeClipboardText(value: string): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moyarich/console-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Core addon SDK and runtime contracts for @moyarich/console hosts and addons.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -9,9 +9,14 @@
|
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/index.d.cts",
|
|
18
|
+
"default": "./dist/index.cjs"
|
|
19
|
+
}
|
|
15
20
|
}
|
|
16
21
|
},
|
|
17
22
|
"files": [
|
|
@@ -21,7 +26,7 @@
|
|
|
21
26
|
"registry": "https://npm.pkg.github.com"
|
|
22
27
|
},
|
|
23
28
|
"scripts": {
|
|
24
|
-
"build": "vite build && tsc -p tsconfig.build.json",
|
|
29
|
+
"build": "vite build && tsc -p tsconfig.build.json && node ../../scripts/prepare-cjs-types.mjs",
|
|
25
30
|
"typecheck": "tsc --noEmit",
|
|
26
31
|
"prepack": "node -e \"require('node:fs').copyFileSync('../../README.md', 'README.md')\"",
|
|
27
32
|
"postpack": "node -e \"require('node:fs').rmSync('README.md', { force: true })\""
|
|
@@ -46,5 +51,10 @@
|
|
|
46
51
|
"extensions",
|
|
47
52
|
"developer-tools",
|
|
48
53
|
"typescript"
|
|
49
|
-
]
|
|
54
|
+
],
|
|
55
|
+
"publisher": "moyarich",
|
|
56
|
+
"author": "Moya Richards",
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=24"
|
|
59
|
+
}
|
|
50
60
|
}
|