@soeditor/core 0.5.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 +6 -0
- package/dist/commands/command-collection.d.ts +21 -0
- package/dist/commands/command-collection.d.ts.map +1 -0
- package/dist/commands/command-registry.d.ts +2 -0
- package/dist/commands/command-registry.d.ts.map +1 -0
- package/dist/commands/command.d.ts +20 -0
- package/dist/commands/command.d.ts.map +1 -0
- package/dist/config/config.d.ts +16 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/editor/editor.d.ts +75 -0
- package/dist/editor/editor.d.ts.map +1 -0
- package/dist/errors/errors.d.ts +70 -0
- package/dist/errors/errors.d.ts.map +1 -0
- package/dist/events/core-events.d.ts +63 -0
- package/dist/events/core-events.d.ts.map +1 -0
- package/dist/events/event-bus.d.ts +16 -0
- package/dist/events/event-bus.d.ts.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1132 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/value.d.ts +2 -0
- package/dist/internal/value.d.ts.map +1 -0
- package/dist/plugins/plugin-collection.d.ts +13 -0
- package/dist/plugins/plugin-collection.d.ts.map +1 -0
- package/dist/plugins/plugin-manager.d.ts +2 -0
- package/dist/plugins/plugin-manager.d.ts.map +1 -0
- package/dist/plugins/plugin.d.ts +35 -0
- package/dist/plugins/plugin.d.ts.map +1 -0
- package/dist/services/service-collection.d.ts +31 -0
- package/dist/services/service-collection.d.ts.map +1 -0
- package/dist/services/service-registry.d.ts +2 -0
- package/dist/services/service-registry.d.ts.map +1 -0
- package/dist/state/document.d.ts +14 -0
- package/dist/state/document.d.ts.map +1 -0
- package/dist/state/editor-state.d.ts +15 -0
- package/dist/state/editor-state.d.ts.map +1 -0
- package/dist/transaction/operation.d.ts +18 -0
- package/dist/transaction/operation.d.ts.map +1 -0
- package/dist/transaction/transaction.d.ts +36 -0
- package/dist/transaction/transaction.d.ts.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SoEditor contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Command } from './command.js';
|
|
2
|
+
/** Public command capabilities owned by one editor. */
|
|
3
|
+
export interface CommandCollection {
|
|
4
|
+
/** Registers a command and rejects duplicate IDs. */
|
|
5
|
+
register(command: Command): void;
|
|
6
|
+
/** Removes a command and reports whether it existed. */
|
|
7
|
+
unregister(id: string): boolean;
|
|
8
|
+
/** Returns whether a command is registered. */
|
|
9
|
+
has(id: string): boolean;
|
|
10
|
+
/** Gets a command or throws when it is absent. */
|
|
11
|
+
get(id: string): Command;
|
|
12
|
+
/** Returns an immutable insertion-ordered snapshot of command IDs. */
|
|
13
|
+
ids(): readonly string[];
|
|
14
|
+
/** Reports whether a registered command can execute. */
|
|
15
|
+
canExecute(id: string): boolean;
|
|
16
|
+
/** Reports whether a registered command is active. */
|
|
17
|
+
isActive(id: string): boolean;
|
|
18
|
+
/** Executes a registered command with opaque arguments. */
|
|
19
|
+
execute(id: string, ...args: readonly unknown[]): unknown;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=command-collection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-collection.d.ts","sourceRoot":"","sources":["../../src/commands/command-collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,uDAAuD;AACvD,MAAM,WAAW,iBAAiB;IAC9B,qDAAqD;IACrD,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,wDAAwD;IACxD,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,+CAA+C;IAC/C,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,kDAAkD;IAClD,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,sEAAsE;IACtE,GAAG,IAAI,SAAS,MAAM,EAAE,CAAC;IACzB,wDAAwD;IACxD,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,sDAAsD;IACtD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9B,2DAA2D;IAC3D,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC;CAC7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-registry.d.ts","sourceRoot":"","sources":["../../src/commands/command-registry.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Editor } from '../editor/editor.js';
|
|
2
|
+
/** Context supplied whenever a command is queried or executed. */
|
|
3
|
+
export interface CommandContext {
|
|
4
|
+
/** The editor instance executing or querying the command. */
|
|
5
|
+
readonly editor: Editor;
|
|
6
|
+
}
|
|
7
|
+
/** A user-triggerable editor behavior registered under a stable ID. */
|
|
8
|
+
export interface Command {
|
|
9
|
+
/** Stable command identifier, conventionally in namespace.action form. */
|
|
10
|
+
readonly id: string;
|
|
11
|
+
/** Human-readable label for a no-argument command offered to palettes. */
|
|
12
|
+
readonly label?: string;
|
|
13
|
+
/** Executes the command with opaque caller arguments. */
|
|
14
|
+
execute(context: CommandContext, ...args: readonly unknown[]): unknown | PromiseLike<unknown>;
|
|
15
|
+
/** Reports whether the command is currently available. */
|
|
16
|
+
canExecute?(context: CommandContext): boolean;
|
|
17
|
+
/** Reports whether the command currently represents active state. */
|
|
18
|
+
isActive?(context: CommandContext): boolean;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/commands/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC3B,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CAC3B;AAED,uEAAuE;AACvE,MAAM,WAAW,OAAO;IACpB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,yDAAyD;IACzD,OAAO,CACH,OAAO,EAAE,cAAc,EACvB,GAAG,IAAI,EAAE,SAAS,OAAO,EAAE,GAC5B,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAClC,0DAA0D;IAC1D,UAAU,CAAC,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC;IAC9C,qEAAqE;IACrE,QAAQ,CAAC,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC;CAC/C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Immutable instance configuration accepted by an editor. */
|
|
2
|
+
export interface EditorConfig {
|
|
3
|
+
/** Configuration values must be immutable JSON-like plain data. */
|
|
4
|
+
readonly [key: string]: unknown;
|
|
5
|
+
}
|
|
6
|
+
/** Read-only access to an editor instance's defensive config copy. */
|
|
7
|
+
export declare class Config {
|
|
8
|
+
#private;
|
|
9
|
+
/** Creates an immutable defensive copy of supported configuration data. */
|
|
10
|
+
constructor(values?: EditorConfig);
|
|
11
|
+
/** Returns whether a dotted configuration path exists. */
|
|
12
|
+
has(path: string): boolean;
|
|
13
|
+
/** Returns a value at a dotted path, or undefined when absent. */
|
|
14
|
+
get<T = unknown>(path: string): T | undefined;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAEA,8DAA8D;AAC9D,MAAM,WAAW,YAAY;IACzB,mEAAmE;IACnE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACnC;AAED,sEAAsE;AACtE,qBAAa,MAAM;;IAGf,2EAA2E;gBAC/D,MAAM,GAAE,YAAiB;IAIrC,0DAA0D;IAC1D,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,kEAAkE;IAClE,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;CA0BhD"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { CommandCollection } from '../commands/command-collection.js';
|
|
2
|
+
import { Config, type EditorConfig } from '../config/config.js';
|
|
3
|
+
import type { CoreEventMap } from '../events/core-events.js';
|
|
4
|
+
import { type EditorEvents } from '../events/event-bus.js';
|
|
5
|
+
import type { PluginCollection } from '../plugins/plugin-collection.js';
|
|
6
|
+
import type { PluginConstructor } from '../plugins/plugin.js';
|
|
7
|
+
import type { ServiceCollection } from '../services/service-collection.js';
|
|
8
|
+
import { type DocumentFormat } from '../state/document.js';
|
|
9
|
+
import { type EditorMode, type EditorState } from '../state/editor-state.js';
|
|
10
|
+
import { type Transaction, type TransactionOptions } from '../transaction/transaction.js';
|
|
11
|
+
/** Options used to construct an independent editor instance. */
|
|
12
|
+
export interface EditorCreateOptions {
|
|
13
|
+
/** Initial canonical source in the selected document format. */
|
|
14
|
+
readonly data?: string;
|
|
15
|
+
/** Canonical document format. */
|
|
16
|
+
readonly format?: DocumentFormat;
|
|
17
|
+
/** Editing-policy state exposed to future user-facing editing surfaces. */
|
|
18
|
+
readonly readonly?: boolean;
|
|
19
|
+
/** Initial requested document projection. */
|
|
20
|
+
readonly mode?: EditorMode;
|
|
21
|
+
/** Root plugins whose transitive requirements should be loaded. */
|
|
22
|
+
readonly plugins?: readonly PluginConstructor[];
|
|
23
|
+
/** Immutable, JSON-like instance configuration. */
|
|
24
|
+
readonly config?: EditorConfig;
|
|
25
|
+
}
|
|
26
|
+
/** Coordinates immutable state with transactions and per-instance capabilities. */
|
|
27
|
+
export declare class Editor {
|
|
28
|
+
#private;
|
|
29
|
+
/** Commands available to consumers and plugins. */
|
|
30
|
+
readonly commands: CommandCollection;
|
|
31
|
+
/** Immutable instance configuration. */
|
|
32
|
+
readonly config: Config;
|
|
33
|
+
/** Subscription-only access to typed editor events. */
|
|
34
|
+
readonly events: EditorEvents<CoreEventMap>;
|
|
35
|
+
/** Loaded plugin lookup capabilities. */
|
|
36
|
+
readonly plugins: PluginCollection;
|
|
37
|
+
/** Cross-feature service capabilities. */
|
|
38
|
+
readonly services: ServiceCollection;
|
|
39
|
+
private constructor();
|
|
40
|
+
/** The current immutable state snapshot. */
|
|
41
|
+
get state(): EditorState;
|
|
42
|
+
/** Creates and initializes an editor and all requested plugins. */
|
|
43
|
+
static create(options?: EditorCreateOptions): Promise<Editor>;
|
|
44
|
+
/** Creates a mutable transaction owned by the current editor state. */
|
|
45
|
+
createTransaction(options?: TransactionOptions): Transaction;
|
|
46
|
+
/**
|
|
47
|
+
* Applies one owned, current, uncommitted transaction.
|
|
48
|
+
*
|
|
49
|
+
* Synchronous reentrant dispatch is rejected with
|
|
50
|
+
* `ReentrantDispatchError` rather than queued.
|
|
51
|
+
*/
|
|
52
|
+
dispatch(transaction: Transaction): void;
|
|
53
|
+
/** Builds and dispatches one editor-owned transaction. */
|
|
54
|
+
update(callback: (transaction: Transaction) => void, options?: TransactionOptions): void;
|
|
55
|
+
/** Executes a registered command through this editor's command collection. */
|
|
56
|
+
execute(commandId: string, ...args: readonly unknown[]): unknown;
|
|
57
|
+
/** Returns canonical source, including after editor destruction. */
|
|
58
|
+
getData(): string;
|
|
59
|
+
/**
|
|
60
|
+
* Administratively replaces canonical source through a transaction.
|
|
61
|
+
*
|
|
62
|
+
* This remains allowed when `readonly` is true; future user-facing editing
|
|
63
|
+
* surfaces must enforce readonly policy before creating user transactions.
|
|
64
|
+
*/
|
|
65
|
+
setData(source: string): void;
|
|
66
|
+
/** Marks the current state as saved without changing document revision. */
|
|
67
|
+
markClean(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Destroys initialized plugins and clears all owned infrastructure.
|
|
70
|
+
*
|
|
71
|
+
* Calls made while destruction is pending return the same promise.
|
|
72
|
+
*/
|
|
73
|
+
destroy(): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../src/editor/editor.ts"],"names":[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,MAAM,CAAC;IACxB,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;IAC5C,yCAAyC;IACzC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IAerC,OAAO;IAqCP,4CAA4C;IAC5C,IAAI,KAAK,IAAI,WAAW,CAEvB;IAED,mEAAmE;WACtD,MAAM,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC;IA0CvE,uEAAuE;IACvE,iBAAiB,CAAC,OAAO,GAAE,kBAAuB,GAAG,WAAW;IAKhE;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAqBxC,0DAA0D;IAC1D,MAAM,CACF,QAAQ,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,IAAI,EAC5C,OAAO,GAAE,kBAAuB,GACjC,IAAI;IAOP,8EAA8E;IAC9E,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO;IAKhE,oEAAoE;IACpE,OAAO,IAAI,MAAM;IAIjB;;;;;OAKG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAM7B,2EAA2E;IAC3E,SAAS,IAAI,IAAI;IAkBjB;;;;OAIG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CA0K3B"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Base error for failures reported by SoEditor core. */
|
|
2
|
+
export declare class SoEditorError extends Error {
|
|
3
|
+
constructor(message: string, options?: ErrorOptions);
|
|
4
|
+
}
|
|
5
|
+
/** Thrown when a mutating API is called after editor destruction. */
|
|
6
|
+
export declare class EditorDestroyedError extends SoEditorError {
|
|
7
|
+
constructor();
|
|
8
|
+
}
|
|
9
|
+
/** Thrown when destruction aborts editor startup before creation completes. */
|
|
10
|
+
export declare class EditorInitializationAbortedError extends SoEditorError {
|
|
11
|
+
constructor();
|
|
12
|
+
}
|
|
13
|
+
/** Thrown when a listener attempts to dispatch during another dispatch. */
|
|
14
|
+
export declare class ReentrantDispatchError extends SoEditorError {
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
17
|
+
/** Thrown when a transaction belongs to a different editor. */
|
|
18
|
+
export declare class TransactionOwnershipError extends SoEditorError {
|
|
19
|
+
constructor();
|
|
20
|
+
}
|
|
21
|
+
/** Thrown when a transaction has already been dispatched. */
|
|
22
|
+
export declare class TransactionAlreadyCommittedError extends SoEditorError {
|
|
23
|
+
constructor();
|
|
24
|
+
}
|
|
25
|
+
/** Thrown when editor state changed after a transaction was created. */
|
|
26
|
+
export declare class StaleTransactionError extends SoEditorError {
|
|
27
|
+
constructor(baseVersion: number, currentVersion: number);
|
|
28
|
+
}
|
|
29
|
+
/** Thrown when configuration contains a value outside the plain-data contract. */
|
|
30
|
+
export declare class UnsupportedConfigValueError extends SoEditorError {
|
|
31
|
+
constructor(path: string, kind: string);
|
|
32
|
+
}
|
|
33
|
+
/** Thrown when configuration contains a cyclic array or object. */
|
|
34
|
+
export declare class CyclicConfigurationError extends SoEditorError {
|
|
35
|
+
constructor(path: string);
|
|
36
|
+
}
|
|
37
|
+
/** Thrown when Phase 1 is asked to create a non-HTML document. */
|
|
38
|
+
export declare class UnsupportedDocumentFormatError extends SoEditorError {
|
|
39
|
+
constructor(format: string);
|
|
40
|
+
}
|
|
41
|
+
/** Thrown when a command ID is not registered. */
|
|
42
|
+
export declare class CommandNotFoundError extends SoEditorError {
|
|
43
|
+
constructor(id: string);
|
|
44
|
+
}
|
|
45
|
+
/** Thrown when a command ID is registered more than once. */
|
|
46
|
+
export declare class CommandAlreadyRegisteredError extends SoEditorError {
|
|
47
|
+
constructor(id: string);
|
|
48
|
+
}
|
|
49
|
+
/** Thrown when a requested plugin is not loaded. */
|
|
50
|
+
export declare class PluginNotFoundError extends SoEditorError {
|
|
51
|
+
constructor(id: string);
|
|
52
|
+
}
|
|
53
|
+
/** Thrown when different plugin constructors declare the same ID. */
|
|
54
|
+
export declare class PluginDuplicateIdError extends SoEditorError {
|
|
55
|
+
constructor(id: string);
|
|
56
|
+
}
|
|
57
|
+
/** Thrown when plugin requirements contain a dependency cycle. */
|
|
58
|
+
export declare class PluginDependencyCycleError extends SoEditorError {
|
|
59
|
+
readonly path: readonly string[];
|
|
60
|
+
constructor(path: readonly string[]);
|
|
61
|
+
}
|
|
62
|
+
/** Thrown when a service ID is not registered. */
|
|
63
|
+
export declare class ServiceNotFoundError extends SoEditorError {
|
|
64
|
+
constructor(id: string);
|
|
65
|
+
}
|
|
66
|
+
/** Thrown when a service ID is registered more than once. */
|
|
67
|
+
export declare class ServiceAlreadyRegisteredError extends SoEditorError {
|
|
68
|
+
constructor(id: string);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,qBAAa,aAAc,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAItD;AAED,qEAAqE;AACrE,qBAAa,oBAAqB,SAAQ,aAAa;;CAItD;AAED,+EAA+E;AAC/E,qBAAa,gCAAiC,SAAQ,aAAa;;CAMlE;AAED,2EAA2E;AAC3E,qBAAa,sBAAuB,SAAQ,aAAa;;CAMxD;AAED,+DAA+D;AAC/D,qBAAa,yBAA0B,SAAQ,aAAa;;CAI3D;AAED,6DAA6D;AAC7D,qBAAa,gCAAiC,SAAQ,aAAa;;CAIlE;AAED,wEAAwE;AACxE,qBAAa,qBAAsB,SAAQ,aAAa;gBACxC,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;CAK1D;AAED,kFAAkF;AAClF,qBAAa,2BAA4B,SAAQ,aAAa;gBAC9C,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAKzC;AAED,mEAAmE;AACnE,qBAAa,wBAAyB,SAAQ,aAAa;gBAC3C,IAAI,EAAE,MAAM;CAG3B;AAED,kEAAkE;AAClE,qBAAa,8BAA+B,SAAQ,aAAa;gBACjD,MAAM,EAAE,MAAM;CAG7B;AAED,kDAAkD;AAClD,qBAAa,oBAAqB,SAAQ,aAAa;gBACvC,EAAE,EAAE,MAAM;CAGzB;AAED,6DAA6D;AAC7D,qBAAa,6BAA8B,SAAQ,aAAa;gBAChD,EAAE,EAAE,MAAM;CAGzB;AAED,oDAAoD;AACpD,qBAAa,mBAAoB,SAAQ,aAAa;gBACtC,EAAE,EAAE,MAAM;CAGzB;AAED,qEAAqE;AACrE,qBAAa,sBAAuB,SAAQ,aAAa;gBACzC,EAAE,EAAE,MAAM;CAGzB;AAED,kEAAkE;AAClE,qBAAa,0BAA2B,SAAQ,aAAa;IACzD,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;gBAErB,IAAI,EAAE,SAAS,MAAM,EAAE;CAItC;AAED,kDAAkD;AAClD,qBAAa,oBAAqB,SAAQ,aAAa;gBACvC,EAAE,EAAE,MAAM;CAGzB;AAED,6DAA6D;AAC7D,qBAAa,6BAA8B,SAAQ,aAAa;gBAChD,EAAE,EAAE,MAAM;CAGzB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Editor } from '../editor/editor.js';
|
|
2
|
+
import type { EditorDocument } from '../state/document.js';
|
|
3
|
+
import type { EditorMode, EditorState } from '../state/editor-state.js';
|
|
4
|
+
import type { Transaction } from '../transaction/transaction.js';
|
|
5
|
+
/** Payload emitted around a document source change. */
|
|
6
|
+
export interface DocumentChangeEvent {
|
|
7
|
+
readonly previous: EditorDocument;
|
|
8
|
+
readonly current: EditorDocument;
|
|
9
|
+
readonly transaction: Transaction;
|
|
10
|
+
}
|
|
11
|
+
/** Payload emitted for any editor state transition. */
|
|
12
|
+
export interface StateChangeEvent {
|
|
13
|
+
readonly previous: EditorState;
|
|
14
|
+
readonly current: EditorState;
|
|
15
|
+
readonly transaction?: Transaction;
|
|
16
|
+
}
|
|
17
|
+
/** Payload emitted when the active editor mode changes. */
|
|
18
|
+
export interface ModeChangeEvent {
|
|
19
|
+
readonly previous: EditorMode;
|
|
20
|
+
readonly current: EditorMode;
|
|
21
|
+
readonly transaction: Transaction;
|
|
22
|
+
}
|
|
23
|
+
/** Payload emitted before and after command execution. */
|
|
24
|
+
export interface CommandExecutionEvent {
|
|
25
|
+
readonly commandId: string;
|
|
26
|
+
readonly args: readonly unknown[];
|
|
27
|
+
}
|
|
28
|
+
/** Payload emitted when command execution throws or rejects. */
|
|
29
|
+
export interface CommandErrorEvent extends CommandExecutionEvent {
|
|
30
|
+
readonly error: unknown;
|
|
31
|
+
}
|
|
32
|
+
/** A plugin lifecycle phase that can report an error. */
|
|
33
|
+
export type PluginErrorPhase = 'construct' | 'init' | 'ready' | 'destroy';
|
|
34
|
+
/** Payload emitted when a plugin lifecycle hook fails. */
|
|
35
|
+
export interface PluginErrorEvent {
|
|
36
|
+
readonly pluginId: string;
|
|
37
|
+
readonly phase: PluginErrorPhase;
|
|
38
|
+
readonly error: unknown;
|
|
39
|
+
}
|
|
40
|
+
/** Payload used to report a listener failure from a safely emitted event. */
|
|
41
|
+
export interface EventListenerErrorEvent {
|
|
42
|
+
readonly eventName: string;
|
|
43
|
+
readonly error: unknown;
|
|
44
|
+
}
|
|
45
|
+
/** Strongly typed events emitted by an editor instance. */
|
|
46
|
+
export interface CoreEventMap {
|
|
47
|
+
readonly 'editor:ready': {
|
|
48
|
+
readonly editor: Editor;
|
|
49
|
+
};
|
|
50
|
+
readonly 'editor:destroy': {
|
|
51
|
+
readonly editor: Editor;
|
|
52
|
+
};
|
|
53
|
+
readonly 'document:beforeChange': DocumentChangeEvent;
|
|
54
|
+
readonly 'document:change': DocumentChangeEvent;
|
|
55
|
+
readonly 'state:change': StateChangeEvent;
|
|
56
|
+
readonly 'mode:change': ModeChangeEvent;
|
|
57
|
+
readonly 'command:beforeExecute': CommandExecutionEvent;
|
|
58
|
+
readonly 'command:afterExecute': CommandExecutionEvent;
|
|
59
|
+
readonly 'command:error': CommandErrorEvent;
|
|
60
|
+
readonly 'plugin:error': PluginErrorEvent;
|
|
61
|
+
readonly 'event:error': EventListenerErrorEvent;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=core-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-events.d.ts","sourceRoot":"","sources":["../../src/events/core-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEjE,uDAAuD;AACvD,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACrC;AAED,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;CACtC;AAED,2DAA2D;AAC3D,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACrC;AAED,0DAA0D;AAC1D,MAAM,WAAW,qBAAq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Q,CAAC,aAAa,EAAE,uBAAuB,CAAC;CACnD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A synchronous listener for a typed event payload.
|
|
3
|
+
*
|
|
4
|
+
* Returned promises are unsupported, are not awaited, and may produce an
|
|
5
|
+
* unhandled rejection. Event work that must be asynchronous should be started
|
|
6
|
+
* and observed outside the core event pipeline.
|
|
7
|
+
*/
|
|
8
|
+
export type EventListener<Payload> = (payload: Payload) => void;
|
|
9
|
+
/** Subscription-only event capabilities exposed by an editor instance. */
|
|
10
|
+
export interface EditorEvents<Events extends object> {
|
|
11
|
+
/** Registers a listener and returns an idempotent disposer. */
|
|
12
|
+
on<Name extends keyof Events>(name: Name, listener: EventListener<Events[Name]>): () => void;
|
|
13
|
+
/** Registers a listener that is removed before its first invocation. */
|
|
14
|
+
once<Name extends keyof Events>(name: Name, listener: EventListener<Events[Name]>): () => void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=event-bus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-bus.d.ts","sourceRoot":"","sources":["../../src/events/event-bus.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AAEhE,0EAA0E;AAC1E,MAAM,WAAW,YAAY,CAAC,MAAM,SAAS,MAAM;IAC/C,+DAA+D;IAC/D,EAAE,CAAC,IAAI,SAAS,MAAM,MAAM,EACxB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GACtC,MAAM,IAAI,CAAC;IAEd,wEAAwE;IACxE,IAAI,CAAC,IAAI,SAAS,MAAM,MAAM,EAC1B,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GACtC,MAAM,IAAI,CAAC;CACjB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type { CommandCollection } from './commands/command-collection.js';
|
|
2
|
+
export type { Command, CommandContext } from './commands/command.js';
|
|
3
|
+
export { Config } from './config/config.js';
|
|
4
|
+
export type { EditorConfig } from './config/config.js';
|
|
5
|
+
export { Editor } from './editor/editor.js';
|
|
6
|
+
export type { EditorCreateOptions } from './editor/editor.js';
|
|
7
|
+
export { CommandAlreadyRegisteredError, CommandNotFoundError, CyclicConfigurationError, EditorDestroyedError, EditorInitializationAbortedError, PluginDependencyCycleError, PluginDuplicateIdError, PluginNotFoundError, ReentrantDispatchError, ServiceAlreadyRegisteredError, ServiceNotFoundError, SoEditorError, StaleTransactionError, TransactionAlreadyCommittedError, TransactionOwnershipError, UnsupportedConfigValueError, UnsupportedDocumentFormatError, } from './errors/errors.js';
|
|
8
|
+
export type { CommandErrorEvent, CommandExecutionEvent, CoreEventMap, DocumentChangeEvent, EventListenerErrorEvent, ModeChangeEvent, PluginErrorEvent, PluginErrorPhase, StateChangeEvent, } from './events/core-events.js';
|
|
9
|
+
export type { EditorEvents, EventListener } from './events/event-bus.js';
|
|
10
|
+
export type { PluginCollection } from './plugins/plugin-collection.js';
|
|
11
|
+
export { Plugin } from './plugins/plugin.js';
|
|
12
|
+
export type { PluginConstructor, PluginContext } from './plugins/plugin.js';
|
|
13
|
+
export { createServiceToken } from './services/service-collection.js';
|
|
14
|
+
export type { ServiceCollection, ServiceToken, } from './services/service-collection.js';
|
|
15
|
+
export type { DocumentFormat, EditorDocument } from './state/document.js';
|
|
16
|
+
export type { EditorMode, EditorState } from './state/editor-state.js';
|
|
17
|
+
export type { Operation, ReplaceDocumentOperation, SetModeOperation, } from './transaction/operation.js';
|
|
18
|
+
export type { Transaction, TransactionMetadata, TransactionOptions, TransactionOrigin, } from './transaction/transaction.js';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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