@paged-media/plugin-api 0.2.1-canary.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/dist/bundle.d.ts +14 -0
- package/dist/contributions.d.ts +1 -0
- package/dist/editor.d.ts +244 -0
- package/dist/host.d.ts +168 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1 -0
- package/dist/manifest.d.ts +60 -0
- package/dist/mutations.d.ts +1 -0
- package/dist/wire.d.ts +1925 -0
- package/package.json +39 -0
- package/src/manifest.schema.json +157 -0
package/dist/bundle.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BundleHost, Disposable } from "./host";
|
|
2
|
+
import type { PluginManifest } from "./manifest";
|
|
3
|
+
/** Returned by `activate`. The host tracks every facade registration
|
|
4
|
+
* independently, so this handle only needs to release what the
|
|
5
|
+
* bundle allocated OUTSIDE the host (timers, caches) — returning a
|
|
6
|
+
* no-op disposer is legitimate. */
|
|
7
|
+
export type BundleHandle = Disposable;
|
|
8
|
+
/** A loadable plugin bundle: serializable identity + the activation
|
|
9
|
+
* entry point. `defineBundle()` in `@paged-media/plugin-sdk` is the
|
|
10
|
+
* ergonomic constructor. */
|
|
11
|
+
export interface PagedBundle {
|
|
12
|
+
manifest: PluginManifest;
|
|
13
|
+
activate(host: BundleHost): BundleHandle;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ShellRegistries, ToolRegistry, PanelRegistry, CommandRegistry, KeybindingRegistry, OverlayRegistry, ToolContribution, ToolId, ToolGroupId, ToolSectionId, ToolOptionsSpec, ToolOptionField, CursorSpec, CssCursorToken, GestureHandler, CanvasPointerEvent, OverlayContext, OverlayPrimitive, DeactivateReason, PanelContribution, PanelProps, PanelApi, OverlayContribution, OverlayProps, OverlayPageRect, CommandContribution, KeybindingContribution, DockEdge, VisibilityPredicate, PagedEditor, PagedClient, ToolPreviewShape, ToolPreviewPolyline, MarqueeRectPageLocal, } from "./editor";
|
package/dist/editor.d.ts
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import type { CollectionName, ContentSelection, DocumentMeta, ElementGeometryItem, ElementId, MainToWorkerKind, Mutation, PageId, PathAnchorsResult, SelectionMode, WorkerToMain } from "./wire";
|
|
3
|
+
export interface Disposable {
|
|
4
|
+
dispose(): void;
|
|
5
|
+
}
|
|
6
|
+
export type DockEdge = "left" | "right" | "top" | "bottom" | "center";
|
|
7
|
+
/** Enablement/visibility predicate. The string DSL form is inert
|
|
8
|
+
* until the host grows an evaluator; the function form receives the
|
|
9
|
+
* live editor handle. */
|
|
10
|
+
export type VisibilityPredicate = string | ((state: unknown) => boolean);
|
|
11
|
+
export type CssCursorToken = "default" | "crosshair" | "grab" | "grabbing" | "move" | "text" | "pointer" | "not-allowed" | "copy" | "cell" | "zoom-in" | "zoom-out" | "nwse-resize" | "nesw-resize" | "ew-resize" | "ns-resize";
|
|
12
|
+
export type CursorSpec = {
|
|
13
|
+
kind: "css";
|
|
14
|
+
token: CssCursorToken;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "svg";
|
|
17
|
+
src: string;
|
|
18
|
+
hotspot: {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/** Why a handler is being deactivated: a real tool change ("switch")
|
|
24
|
+
* commits/cancels in-flight state; a spring-load push/pop
|
|
25
|
+
* ("suspend") must keep it. */
|
|
26
|
+
export type DeactivateReason = "switch" | "suspend";
|
|
27
|
+
/** A pointer event on the canvas overlay, already page-resolved and
|
|
28
|
+
* camera-inverted by the host — handlers never touch camera math.
|
|
29
|
+
* Coordinates are document points (pt). */
|
|
30
|
+
export interface CanvasPointerEvent {
|
|
31
|
+
/** Page the pointer is over, or null on the pasteboard. */
|
|
32
|
+
pageId: string | null;
|
|
33
|
+
/** Page-local point in pt. null off-page. */
|
|
34
|
+
pagePoint: [number, number] | null;
|
|
35
|
+
/** Page-independent document point in pt. */
|
|
36
|
+
docPoint: [number, number];
|
|
37
|
+
modifiers: {
|
|
38
|
+
shift: boolean;
|
|
39
|
+
alt: boolean;
|
|
40
|
+
cmd: boolean;
|
|
41
|
+
ctrl: boolean;
|
|
42
|
+
};
|
|
43
|
+
/** Largest pointer delta this gesture, CSS px — click-vs-drag. */
|
|
44
|
+
maxDelta: number;
|
|
45
|
+
/** Mouse button (0 = primary). */
|
|
46
|
+
button: number;
|
|
47
|
+
/** Underlying DOM target — handlers may read `data-*` hooks. */
|
|
48
|
+
target: unknown;
|
|
49
|
+
}
|
|
50
|
+
/** Ephemeral overlay primitive published during a gesture. Kept
|
|
51
|
+
* opaque so the contract is stable across host overlay growth. */
|
|
52
|
+
export type OverlayPrimitive = Record<string, unknown>;
|
|
53
|
+
export interface OverlayContext {
|
|
54
|
+
setPreview(primitives: readonly OverlayPrimitive[]): void;
|
|
55
|
+
}
|
|
56
|
+
/** The contract every tool's `gesture()` factory returns. Mutate only
|
|
57
|
+
* through `paged.client` / the document surface — never by reaching
|
|
58
|
+
* into model state. */
|
|
59
|
+
export interface GestureHandler {
|
|
60
|
+
onActivate(paged: PagedEditor): void;
|
|
61
|
+
onDeactivate(reason: DeactivateReason): void;
|
|
62
|
+
onPointerDown(e: CanvasPointerEvent): void;
|
|
63
|
+
onPointerMove(e: CanvasPointerEvent): void;
|
|
64
|
+
onPointerUp(e: CanvasPointerEvent): void;
|
|
65
|
+
onKey?(e: KeyboardEvent): void;
|
|
66
|
+
cursorAt?(e: CanvasPointerEvent): CursorSpec | undefined;
|
|
67
|
+
renderOverlay?(ctx: OverlayContext): void;
|
|
68
|
+
}
|
|
69
|
+
export type ToolId = string;
|
|
70
|
+
export type ToolGroupId = string;
|
|
71
|
+
export type ToolSectionId = "selection" | "drawType" | "transform" | "modNav";
|
|
72
|
+
export type ToolOptionField = {
|
|
73
|
+
kind: "number";
|
|
74
|
+
key: string;
|
|
75
|
+
label: string;
|
|
76
|
+
min?: number;
|
|
77
|
+
max?: number;
|
|
78
|
+
step?: number;
|
|
79
|
+
unit?: string;
|
|
80
|
+
} | {
|
|
81
|
+
kind: "toggle";
|
|
82
|
+
key: string;
|
|
83
|
+
label: string;
|
|
84
|
+
} | {
|
|
85
|
+
kind: "select";
|
|
86
|
+
key: string;
|
|
87
|
+
label: string;
|
|
88
|
+
options: Array<{
|
|
89
|
+
value: string;
|
|
90
|
+
label: string;
|
|
91
|
+
}>;
|
|
92
|
+
};
|
|
93
|
+
export interface ToolOptionsSpec {
|
|
94
|
+
toolId: string;
|
|
95
|
+
fields: ToolOptionField[];
|
|
96
|
+
}
|
|
97
|
+
export interface ToolContribution {
|
|
98
|
+
/** Stable id, `<namespace>.<tool>` — namespace-checked at register. */
|
|
99
|
+
id: ToolId;
|
|
100
|
+
title: string;
|
|
101
|
+
icon: string;
|
|
102
|
+
/** Single-key shortcut (`"p"`, `"shift+c"`). Wire it through the
|
|
103
|
+
* SDK's `contributeTool` so the activation command + guard exist. */
|
|
104
|
+
shortcut?: string;
|
|
105
|
+
/** Flyout group — one rail slot; shared group = shared flyout. */
|
|
106
|
+
group: ToolGroupId;
|
|
107
|
+
section: ToolSectionId;
|
|
108
|
+
order?: number;
|
|
109
|
+
isGroupDefault?: boolean;
|
|
110
|
+
cursor?: CursorSpec;
|
|
111
|
+
/** Handler factory the host mounts when the tool activates. Absent
|
|
112
|
+
* = rail data only (inert). */
|
|
113
|
+
gesture?: () => GestureHandler;
|
|
114
|
+
options?: ToolOptionsSpec;
|
|
115
|
+
when?: VisibilityPredicate;
|
|
116
|
+
}
|
|
117
|
+
export interface PanelApi {
|
|
118
|
+
id: string;
|
|
119
|
+
}
|
|
120
|
+
export interface PanelProps {
|
|
121
|
+
/** The live editor handle (cast to `PagedEditor`). */
|
|
122
|
+
paged: unknown;
|
|
123
|
+
api: PanelApi;
|
|
124
|
+
}
|
|
125
|
+
export interface PanelContribution {
|
|
126
|
+
id: string;
|
|
127
|
+
title: string;
|
|
128
|
+
component: ComponentType<PanelProps>;
|
|
129
|
+
defaultDock?: DockEdge;
|
|
130
|
+
defaultGroup?: string;
|
|
131
|
+
icon?: string;
|
|
132
|
+
when?: VisibilityPredicate;
|
|
133
|
+
closable?: boolean;
|
|
134
|
+
movable?: boolean;
|
|
135
|
+
}
|
|
136
|
+
export interface OverlayPageRect {
|
|
137
|
+
x: number;
|
|
138
|
+
y: number;
|
|
139
|
+
w: number;
|
|
140
|
+
h: number;
|
|
141
|
+
}
|
|
142
|
+
export interface OverlayProps {
|
|
143
|
+
paged: unknown;
|
|
144
|
+
/** Camera snapshot at the current frame. */
|
|
145
|
+
camera: {
|
|
146
|
+
scale: number;
|
|
147
|
+
tx: number;
|
|
148
|
+
ty: number;
|
|
149
|
+
};
|
|
150
|
+
/** Page rectangles in document space, in page-id order. */
|
|
151
|
+
pageRects: ReadonlyMap<PageId, OverlayPageRect>;
|
|
152
|
+
}
|
|
153
|
+
export interface OverlayContribution {
|
|
154
|
+
id: string;
|
|
155
|
+
render: ComponentType<OverlayProps>;
|
|
156
|
+
/** Z-order; higher renders on top. Default 100. */
|
|
157
|
+
z?: number;
|
|
158
|
+
when?: VisibilityPredicate;
|
|
159
|
+
}
|
|
160
|
+
export interface CommandContribution {
|
|
161
|
+
id: string;
|
|
162
|
+
title: string;
|
|
163
|
+
category?: string;
|
|
164
|
+
icon?: string;
|
|
165
|
+
handler: (paged: unknown, payload?: unknown) => unknown | Promise<unknown>;
|
|
166
|
+
when?: VisibilityPredicate;
|
|
167
|
+
}
|
|
168
|
+
export interface KeybindingContribution {
|
|
169
|
+
/** Lowercased combo: `"cmd+shift+h"`, `"p"`, `"escape"`. */
|
|
170
|
+
key: string;
|
|
171
|
+
command: string;
|
|
172
|
+
when?: VisibilityPredicate;
|
|
173
|
+
}
|
|
174
|
+
export interface ToolRegistry {
|
|
175
|
+
register(contribution: ToolContribution): Disposable;
|
|
176
|
+
}
|
|
177
|
+
export interface PanelRegistry {
|
|
178
|
+
register(contribution: PanelContribution): Disposable;
|
|
179
|
+
}
|
|
180
|
+
export interface CommandRegistry {
|
|
181
|
+
register(contribution: CommandContribution): Disposable;
|
|
182
|
+
}
|
|
183
|
+
export interface KeybindingRegistry {
|
|
184
|
+
register(contribution: KeybindingContribution): Disposable;
|
|
185
|
+
}
|
|
186
|
+
export interface OverlayRegistry {
|
|
187
|
+
register(contribution: OverlayContribution): Disposable;
|
|
188
|
+
}
|
|
189
|
+
export interface ShellRegistries {
|
|
190
|
+
tools: ToolRegistry;
|
|
191
|
+
panels: PanelRegistry;
|
|
192
|
+
commands: CommandRegistry;
|
|
193
|
+
keybindings: KeybindingRegistry;
|
|
194
|
+
overlays: OverlayRegistry;
|
|
195
|
+
}
|
|
196
|
+
export interface MarqueeRectPageLocal {
|
|
197
|
+
pageId: PageId;
|
|
198
|
+
/** `[top, left, bottom, right]` in page-local pt. */
|
|
199
|
+
rect: [number, number, number, number];
|
|
200
|
+
}
|
|
201
|
+
export interface ToolPreviewPolyline {
|
|
202
|
+
pageId: PageId;
|
|
203
|
+
points: ReadonlyArray<[number, number]>;
|
|
204
|
+
/** Draw the closing edge (pen/polygon previews). */
|
|
205
|
+
close?: boolean;
|
|
206
|
+
}
|
|
207
|
+
export type ToolPreviewShape = MarqueeRectPageLocal | ToolPreviewPolyline;
|
|
208
|
+
export interface PagedClient {
|
|
209
|
+
mutate(mutation: Mutation): Promise<WorkerToMain>;
|
|
210
|
+
undo(): Promise<WorkerToMain>;
|
|
211
|
+
redo(): Promise<WorkerToMain>;
|
|
212
|
+
collection<T>(name: CollectionName): Promise<readonly T[]>;
|
|
213
|
+
documentMeta(): Promise<DocumentMeta>;
|
|
214
|
+
pathAnchors(id: ElementId): Promise<PathAnchorsResult | null>;
|
|
215
|
+
elementGeometry(ids: ElementId[]): Promise<ElementGeometryItem[]>;
|
|
216
|
+
setElementSelection(ids: ElementId[], mode: SelectionMode): Promise<ElementId[]>;
|
|
217
|
+
send(message: MainToWorkerKind): Promise<WorkerToMain>;
|
|
218
|
+
subscribe(listener: (msg: WorkerToMain) => void): () => void;
|
|
219
|
+
}
|
|
220
|
+
export interface PagedEditor {
|
|
221
|
+
client: PagedClient;
|
|
222
|
+
registries: ShellRegistries;
|
|
223
|
+
selection: {
|
|
224
|
+
elementSelection: ElementId[];
|
|
225
|
+
setElementSelection(ids: ElementId[]): void;
|
|
226
|
+
setElementGeometry(items: ElementGeometryItem[]): void;
|
|
227
|
+
};
|
|
228
|
+
camera: {
|
|
229
|
+
camera: {
|
|
230
|
+
scale: number;
|
|
231
|
+
tx: number;
|
|
232
|
+
ty: number;
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
overlaySignals: {
|
|
236
|
+
setToolPreview(value: ToolPreviewShape | null): void;
|
|
237
|
+
};
|
|
238
|
+
tool: {
|
|
239
|
+
setBaseTool(id: ToolId): void;
|
|
240
|
+
};
|
|
241
|
+
contentSelection: {
|
|
242
|
+
contentSelection: ContentSelection | null;
|
|
243
|
+
};
|
|
244
|
+
}
|
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { CollectionName, DocumentMeta, ElementGeometryItem, ElementId, HitFilter, HitResult, Mutation, PageId, PathAnchorsResult, SceneTreeNode, SelectionMode } from "./wire";
|
|
2
|
+
import type { CommandContribution, KeybindingContribution, OverlayContribution, PagedEditor, PanelContribution, ToolContribution, ToolPreviewShape } from "./editor";
|
|
3
|
+
import type { PluginManifest } from "./manifest";
|
|
4
|
+
/** Everything a bundle registers is disposable; the host ALSO tracks
|
|
5
|
+
* it, so deactivation teardown is structural, not conventional. */
|
|
6
|
+
export interface Disposable {
|
|
7
|
+
dispose(): void;
|
|
8
|
+
}
|
|
9
|
+
/** Namespaced logger; doubles as the console mirror of the
|
|
10
|
+
* diagnostics channel. */
|
|
11
|
+
export interface PluginLogger {
|
|
12
|
+
debug(message: string, ...args: unknown[]): void;
|
|
13
|
+
info(message: string, ...args: unknown[]): void;
|
|
14
|
+
warn(message: string, ...args: unknown[]): void;
|
|
15
|
+
error(message: string, ...args: unknown[]): void;
|
|
16
|
+
}
|
|
17
|
+
/** Reserved (P0 shell work, paged.draw B-02 / paged.web §8): an
|
|
18
|
+
* edit-context claim — double-click entry on a content type, scoped
|
|
19
|
+
* panel/tool sets. Throws PluginApiNotImplemented in v0. */
|
|
20
|
+
export interface EditContextDescriptor {
|
|
21
|
+
type: string;
|
|
22
|
+
entry: "doubleClick" | "command";
|
|
23
|
+
}
|
|
24
|
+
/** Reserved (paged.web §9.1.2): a plugin-defined object type under
|
|
25
|
+
* the metadata-plus-baked-fallback contract. Throws in v0. */
|
|
26
|
+
export interface ObjectTypeDescriptor {
|
|
27
|
+
type: string;
|
|
28
|
+
/** What the baked IDML form degrades to without the plugin. */
|
|
29
|
+
bakedFallback: "group" | "rectangle" | "raster";
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The contribution surface. Every method enforces the namespace rule
|
|
33
|
+
* (ids start with `<manifest.id>.`) and tracks the registration for
|
|
34
|
+
* automatic teardown on deactivate.
|
|
35
|
+
*/
|
|
36
|
+
export interface ContributionSurface {
|
|
37
|
+
tool(contribution: ToolContribution): Disposable;
|
|
38
|
+
panel(contribution: PanelContribution): Disposable;
|
|
39
|
+
command(contribution: CommandContribution): Disposable;
|
|
40
|
+
keybinding(contribution: KeybindingContribution): Disposable;
|
|
41
|
+
overlay(contribution: OverlayContribution): Disposable;
|
|
42
|
+
/** Reserved — throws PluginApiNotImplemented until edit contexts
|
|
43
|
+
* land in the shell. Declared so manifests/docs can reference it. */
|
|
44
|
+
editContext(descriptor: EditContextDescriptor): Disposable;
|
|
45
|
+
/** Reserved — throws PluginApiNotImplemented (paged.web W1). */
|
|
46
|
+
objectType(descriptor: ObjectTypeDescriptor): Disposable;
|
|
47
|
+
}
|
|
48
|
+
/** Expected mutation failures are results, not throws — mirroring the
|
|
49
|
+
* editor's mutate-never-throws convention. */
|
|
50
|
+
export type MutationOutcome = {
|
|
51
|
+
applied: true;
|
|
52
|
+
createdId: ElementId | null;
|
|
53
|
+
pageIds: PageId[];
|
|
54
|
+
} | {
|
|
55
|
+
applied: false;
|
|
56
|
+
error: unknown;
|
|
57
|
+
};
|
|
58
|
+
export interface DocumentChangeEvent {
|
|
59
|
+
kind: "mutationApplied" | "undoApplied" | "redoApplied";
|
|
60
|
+
pageIds: PageId[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Read-broad / write-through-one-door. `mutate` is the single write
|
|
64
|
+
* path; undo/validation/collaboration semantics stay engine-owned.
|
|
65
|
+
* The future write-scope (edit-context subtree) attaches at this same
|
|
66
|
+
* chokepoint.
|
|
67
|
+
*/
|
|
68
|
+
export interface DocumentSurface {
|
|
69
|
+
mutate(mutation: Mutation): Promise<MutationOutcome>;
|
|
70
|
+
undo(): Promise<void>;
|
|
71
|
+
redo(): Promise<void>;
|
|
72
|
+
collection<T>(name: CollectionName): Promise<readonly T[]>;
|
|
73
|
+
meta(): Promise<DocumentMeta>;
|
|
74
|
+
pathAnchors(id: ElementId): Promise<PathAnchorsResult | null>;
|
|
75
|
+
hitTest(pageId: PageId, point: [number, number], filter?: HitFilter): Promise<HitResult | null>;
|
|
76
|
+
elementGeometry(ids: ElementId[]): Promise<ElementGeometryItem[]>;
|
|
77
|
+
tree(): Promise<SceneTreeNode[]>;
|
|
78
|
+
onDidChange(listener: (e: DocumentChangeEvent) => void): Disposable;
|
|
79
|
+
}
|
|
80
|
+
export interface SelectionSurface {
|
|
81
|
+
get(): ElementId[];
|
|
82
|
+
set(ids: ElementId[], mode?: SelectionMode): Promise<ElementId[]>;
|
|
83
|
+
onDidChange(listener: (ids: ElementId[]) => void): Disposable;
|
|
84
|
+
}
|
|
85
|
+
export interface ViewportSurface {
|
|
86
|
+
/** Camera snapshot — scale + translation in CSS px. */
|
|
87
|
+
camera(): {
|
|
88
|
+
scale: number;
|
|
89
|
+
tx: number;
|
|
90
|
+
ty: number;
|
|
91
|
+
};
|
|
92
|
+
/** Screen px → document pt at the current zoom (the constant-
|
|
93
|
+
* screen-tolerance idiom every tool needs). */
|
|
94
|
+
pxToPt(px: number): number;
|
|
95
|
+
}
|
|
96
|
+
/** The v0 overlay channel: the shared tool-preview signal (polyline /
|
|
97
|
+
* rect). Retained plugin scene layers are the P2 channel — reserved,
|
|
98
|
+
* not faked. */
|
|
99
|
+
export interface OverlaySurface {
|
|
100
|
+
setToolPreview(shape: ToolPreviewShape | null): void;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Shell actions the HOST APP injects at `loadBundle` time (the
|
|
104
|
+
* cockpit owns panel placement; the SDK's adapter stays a pure
|
|
105
|
+
* function over the editor handle). When the host app provides no
|
|
106
|
+
* implementation, calls warn and no-op — probe with
|
|
107
|
+
* `host.supports("shell.openPanel@1")`.
|
|
108
|
+
*/
|
|
109
|
+
export interface ShellSurface {
|
|
110
|
+
/** Open a REGISTERED panel as the active dock tab (the
|
|
111
|
+
* Window-menu / panel-rail path). */
|
|
112
|
+
openPanel(panelId: string): void;
|
|
113
|
+
closePanel(panelId: string): void;
|
|
114
|
+
}
|
|
115
|
+
/** Namespaced key-value persistence (`paged.plugin.<id>.*`), JSON
|
|
116
|
+
* values. Backing is host-provided (localStorage in-process;
|
|
117
|
+
* injectable for tests/headless). */
|
|
118
|
+
export interface StorageSurface {
|
|
119
|
+
get<T>(key: string): T | undefined;
|
|
120
|
+
set(key: string, value: unknown): void;
|
|
121
|
+
delete(key: string): void;
|
|
122
|
+
keys(): string[];
|
|
123
|
+
}
|
|
124
|
+
export interface Diagnostic {
|
|
125
|
+
severity: "error" | "warning" | "info";
|
|
126
|
+
message: string;
|
|
127
|
+
/** Free-form origin, e.g. a file/frame/panel identifier. */
|
|
128
|
+
source?: string;
|
|
129
|
+
line?: number;
|
|
130
|
+
column?: number;
|
|
131
|
+
}
|
|
132
|
+
/** The diagnostics channel (paged.web §9.1.4): per-plugin keyed
|
|
133
|
+
* diagnostic sets, console-mirrored in v0; the problems-panel UI
|
|
134
|
+
* consumes the same store later. */
|
|
135
|
+
export interface DiagnosticsSurface {
|
|
136
|
+
set(key: string, diagnostics: Diagnostic[]): void;
|
|
137
|
+
clear(key?: string): void;
|
|
138
|
+
get(key: string): Diagnostic[];
|
|
139
|
+
onDidChange(listener: (key: string) => void): Disposable;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* What `activate(host)` receives. Types from `@paged-media/plugin-api`,
|
|
143
|
+
* values from here — never import host values into a bundle's module
|
|
144
|
+
* graph.
|
|
145
|
+
*/
|
|
146
|
+
export interface BundleHost {
|
|
147
|
+
/** The bundle's own manifest (read-only). */
|
|
148
|
+
readonly manifest: PluginManifest;
|
|
149
|
+
readonly log: PluginLogger;
|
|
150
|
+
readonly contribute: ContributionSurface;
|
|
151
|
+
readonly document: DocumentSurface;
|
|
152
|
+
readonly selection: SelectionSurface;
|
|
153
|
+
readonly viewport: ViewportSurface;
|
|
154
|
+
readonly overlay: OverlaySurface;
|
|
155
|
+
readonly shell: ShellSurface;
|
|
156
|
+
readonly storage: StorageSurface;
|
|
157
|
+
readonly diagnostics: DiagnosticsSurface;
|
|
158
|
+
/** Capability detection over version sniffing: feature strings of
|
|
159
|
+
* the form `"area.member@major"` (see HOST_FEATURES in plugin-sdk). */
|
|
160
|
+
supports(feature: string): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* The marked escape hatch (DESIGN.md §4.9): the raw editor handle,
|
|
163
|
+
* v0-only. Any use not reachable through a facade is a
|
|
164
|
+
* BREAKAGE_LOG entry — and this member does not survive the isolate
|
|
165
|
+
* boundary.
|
|
166
|
+
*/
|
|
167
|
+
readonly editor: PagedEditor;
|
|
168
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { PluginId, PluginManifest, PluginCapabilities, PluginContributions, } from "./manifest";
|
|
2
|
+
export type { BundleHandle, PagedBundle } from "./bundle";
|
|
3
|
+
export type { BundleHost, ContributionSurface, DocumentSurface, SelectionSurface, ViewportSurface, OverlaySurface, ShellSurface, StorageSurface, DiagnosticsSurface, Diagnostic, DocumentChangeEvent, MutationOutcome, Disposable, PluginLogger, EditContextDescriptor, ObjectTypeDescriptor, } from "./host";
|
|
4
|
+
export type * from "./contributions";
|
|
5
|
+
export type * from "./mutations";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** Reverse-DNS plugin identity, e.g. `media.paged.draw`. Doubles as
|
|
2
|
+
* the namespace prefix for every contribution id the bundle
|
|
3
|
+
* registers (`media.paged.draw.tool.pen`). */
|
|
4
|
+
export type PluginId = string;
|
|
5
|
+
export interface PluginManifest {
|
|
6
|
+
id: PluginId;
|
|
7
|
+
/** Human-readable name, e.g. "paged.draw". */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Bundle semver. */
|
|
10
|
+
version: string;
|
|
11
|
+
/** Semver range against `@paged-media/plugin-api`. */
|
|
12
|
+
apiVersion: string;
|
|
13
|
+
publisher?: string;
|
|
14
|
+
capabilities?: PluginCapabilities;
|
|
15
|
+
contributes?: PluginContributions;
|
|
16
|
+
}
|
|
17
|
+
export interface PluginCapabilities {
|
|
18
|
+
/** read-broad / write-scoped is the intended default. */
|
|
19
|
+
document?: {
|
|
20
|
+
read?: "broad" | "scoped";
|
|
21
|
+
write?: "broad" | "scoped";
|
|
22
|
+
};
|
|
23
|
+
/** Render-pipeline surfaces the bundle uses. v0: `overlay` means
|
|
24
|
+
* the shared TS overlay signals (tool previews); `sceneLayer` and
|
|
25
|
+
* a host-side `hitTest` service are reserved for the P2 channel. */
|
|
26
|
+
rendering?: Array<"sceneLayer" | "overlay" | "hitTest">;
|
|
27
|
+
/** Edit-context content types the bundle claims (P0 shell work —
|
|
28
|
+
* reserved, not yet wired). */
|
|
29
|
+
editContext?: string[];
|
|
30
|
+
network?: boolean;
|
|
31
|
+
clipboard?: "none" | "vector" | "full";
|
|
32
|
+
}
|
|
33
|
+
export interface PluginContributions {
|
|
34
|
+
/** Tool ids the bundle registers. Must be namespaced by `id`. */
|
|
35
|
+
tools?: string[];
|
|
36
|
+
/** Panel ids the bundle registers (expert-leaf React in v0) or
|
|
37
|
+
* paths to `*.panel.json` prototypes (design specs, not yet
|
|
38
|
+
* interpreted by the host). */
|
|
39
|
+
panels?: string[];
|
|
40
|
+
/** Command ids the bundle registers. Must be namespaced by `id`. */
|
|
41
|
+
commands?: string[];
|
|
42
|
+
/** Reserved for the P0 edit-context registry. `priority` (decision
|
|
43
|
+
* Q12, 2026-06-06) reserves the multi-plugin contention shape NOW:
|
|
44
|
+
* when two plugins claim one content type, runtime policy (ships
|
|
45
|
+
* at P7) is user choice with a remembered per-content-type
|
|
46
|
+
* default, first-party initially; higher priority orders the
|
|
47
|
+
* choice list. First-installed-wins is rejected — install-order
|
|
48
|
+
* nondeterminism is undebuggable. */
|
|
49
|
+
editContexts?: Array<{
|
|
50
|
+
type: string;
|
|
51
|
+
entry: "doubleClick" | "command";
|
|
52
|
+
priority?: number;
|
|
53
|
+
}>;
|
|
54
|
+
/** Reserved (paged.web §9.1.2): plugin-defined object types under
|
|
55
|
+
* the metadata-plus-baked-fallback contract. */
|
|
56
|
+
objectTypes?: Array<{
|
|
57
|
+
type: string;
|
|
58
|
+
bakedFallback: "group" | "rectangle" | "raster";
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ElementId, PageId, NodeId, NodeSpec, Mutation, Operation, PropertyPath, Value, PathAnchorSpec, PathAnchorTriple, PathAnchorsResult, PathPointAddress, PathPointRole, PathfinderKind, HitFilter, HitResult, CollectionName, DocumentMeta, ElementGeometryItem, SceneTreeNode, SelectionMode, ContentSelection, MainToWorker, MainToWorkerKind, WorkerToMain, GestureType, GestureHandle, GestureModifiers, SwatchSpec, GradientSpec, GradientStopSpec, SwatchSummary, GradientSummary, LayerSummary, } from "./wire";
|