@punica/editor 1.0.6 → 1.0.7
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/index.bundle.esm.js +1 -1
- package/dist/index.bundle.esm.js.map +1 -1
- package/dist/index.bundle.umd.js +1 -1
- package/dist/index.bundle.umd.js.map +1 -1
- package/package.json +28 -3
- package/types/index.d.ts +120 -11
- package/types/punica.module.bootstrap.d.ts +45 -0
- package/types/punica.module.capability.d.ts +359 -0
- package/types/punica.module.extensions.api.d.ts +740 -0
- package/types/punica.module.extensions.settings.d.ts +106 -0
- package/types/punica.module.flow.agent.d.ts +75 -0
- package/types/punica.module.flow.api.d.ts +128 -0
- package/types/punica.module.flow.d.ts +490 -0
- package/types/punica.module.flow.engine.d.ts +228 -0
- package/types/punica.module.flow.mcp.d.ts +26 -0
- package/types/punica.module.flow.notebook.d.ts +210 -0
- package/types/punica.module.flow.primitives.d.ts +700 -0
- package/types/punica.module.flow.shell.d.ts +374 -0
- package/types/punica.module.kernel.ai.d.ts +462 -0
- package/types/punica.module.kernel.commands.d.ts +49 -0
- package/types/punica.module.kernel.events.d.ts +274 -0
- package/types/punica.module.kernel.history.d.ts +20 -0
- package/types/punica.module.kernel.llm.d.ts +343 -0
- package/types/punica.module.kernel.notifications.d.ts +64 -0
- package/types/punica.module.kernel.policy.d.ts +273 -0
- package/types/punica.module.kernel.tasks.d.ts +107 -0
- package/types/punica.module.kernel.timeServer.d.ts +16 -0
- package/types/punica.module.runtime.api.d.ts +214 -0
- package/types/punica.module.runtime.capabilities.d.ts +175 -0
- package/types/punica.module.runtime.compute.d.ts +339 -0
- package/types/punica.module.runtime.datasets.d.ts +234 -0
- package/types/punica.module.runtime.fs.d.ts +385 -0
- package/types/punica.module.runtime.harness.d.ts +246 -0
- package/types/punica.module.runtime.host.d.ts +272 -0
- package/types/punica.module.runtime.inference.d.ts +164 -0
- package/types/punica.module.runtime.lifecycle.d.ts +15 -0
- package/types/punica.module.runtime.llm.d.ts +470 -0
- package/types/punica.module.runtime.mcp.d.ts +139 -0
- package/types/punica.module.runtime.modelRuntimes.d.ts +90 -0
- package/types/punica.module.runtime.models.d.ts +254 -0
- package/types/punica.module.runtime.search.d.ts +59 -0
- package/types/punica.module.runtime.secrets.d.ts +26 -0
- package/types/punica.module.runtime.tasks.d.ts +27 -0
- package/types/punica.module.runtime.vcs.d.ts +67 -0
- package/types/punica.module.runtime.vectors.d.ts +74 -0
- package/types/punica.module.runtime.workspace.d.ts +134 -0
- package/types/punica.module.shell.activityBar.d.ts +42 -0
- package/types/punica.module.shell.components.d.ts +87 -0
- package/types/punica.module.shell.contentTabs.d.ts +33 -0
- package/types/punica.module.shell.dragDrop.d.ts +25 -0
- package/types/punica.module.shell.keyboardShortcuts.d.ts +38 -0
- package/types/punica.module.shell.layout.d.ts +106 -0
- package/types/punica.module.shell.markdown.d.ts +36 -0
- package/types/punica.module.shell.panelTabs.d.ts +48 -0
- package/types/punica.module.shell.profile.d.ts +278 -0
- package/types/punica.module.shell.statusbar.d.ts +26 -0
- package/types/punica.module.shell.view.d.ts +455 -0
- package/types/punica.module.shell.views.d.ts +150 -0
- package/types/punica.module.test.d.ts +562 -0
- package/types/punica.module.activityBar.d.ts +0 -21
- package/types/punica.module.commands.d.ts +0 -21
- package/types/punica.module.dragDrop.d.ts +0 -23
- package/types/punica.module.extensions.d.ts +0 -157
- package/types/punica.module.history.d.ts +0 -18
- package/types/punica.module.keyboardShortcuts.d.ts +0 -29
- package/types/punica.module.layout.d.ts +0 -22
- package/types/punica.module.statusbar.d.ts +0 -21
- package/types/punica.module.timeServer.d.ts +0 -14
- package/types/punica.module.view.d.ts +0 -8
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
declare module 'punica' {
|
|
2
|
+
export namespace flow {
|
|
3
|
+
export namespace shell {
|
|
4
|
+
/**
|
|
5
|
+
* Flow node position in the canvas.
|
|
6
|
+
*/
|
|
7
|
+
export interface FlowViewNodePosition {
|
|
8
|
+
id: string;
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Flow node in the graph.
|
|
15
|
+
*/
|
|
16
|
+
export interface FlowNode {
|
|
17
|
+
id: string;
|
|
18
|
+
position: { x: number; y: number };
|
|
19
|
+
label?: string;
|
|
20
|
+
data?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Flow edge connecting two nodes.
|
|
25
|
+
*/
|
|
26
|
+
export interface FlowEdge {
|
|
27
|
+
id: string;
|
|
28
|
+
source: string;
|
|
29
|
+
target: string;
|
|
30
|
+
sourceHandle?: string;
|
|
31
|
+
targetHandle?: string;
|
|
32
|
+
data?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Complete flow graph with nodes, edges, and viewport.
|
|
37
|
+
*/
|
|
38
|
+
export interface FlowGraph {
|
|
39
|
+
nodes: FlowNode[];
|
|
40
|
+
edges: FlowEdge[];
|
|
41
|
+
viewport?: FlowViewport;
|
|
42
|
+
metadata?: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface FlowViewSnapshot {
|
|
46
|
+
nodes: FlowViewNodePosition[];
|
|
47
|
+
viewport: FlowViewport;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface ViewportControllerOptions {
|
|
51
|
+
container: HTMLElement;
|
|
52
|
+
viewport?: FlowViewport;
|
|
53
|
+
minZoom?: number;
|
|
54
|
+
maxZoom?: number;
|
|
55
|
+
zoomStep?: number;
|
|
56
|
+
shouldStartPan?: (event: PointerEvent) => boolean;
|
|
57
|
+
onViewportChange?: (viewport: FlowViewport) => void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Viewport state for pan/zoom.
|
|
62
|
+
*/
|
|
63
|
+
export interface FlowViewport {
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
66
|
+
zoom: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Substrate-shipped contract for the viewport controller
|
|
71
|
+
* (flow shell renderer). Substrate used to ship a concrete
|
|
72
|
+
* `ViewportController` class; the constitutional decision (D1)
|
|
73
|
+
* moves DOM-bound implementation to extension territory. The
|
|
74
|
+
* substrate now ships the interface + a `FlowRendererProvider`
|
|
75
|
+
* injection seam — hosts/extensions implement the real DOM
|
|
76
|
+
* controller and inject it via `setRendererProvider(...)`.
|
|
77
|
+
*/
|
|
78
|
+
export interface ViewportController {
|
|
79
|
+
attach(): void;
|
|
80
|
+
detach(): void;
|
|
81
|
+
getViewport(): FlowViewport;
|
|
82
|
+
setViewport(viewport: Partial<FlowViewport>): void;
|
|
83
|
+
registerDraggableNode(
|
|
84
|
+
id: string,
|
|
85
|
+
element: HTMLElement,
|
|
86
|
+
getPosition: () => { x: number; y: number },
|
|
87
|
+
setPosition: (pos: { x: number; y: number }) => void
|
|
88
|
+
): void;
|
|
89
|
+
unregisterDraggableNode(id: string): void;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface ZoomControlOptions {
|
|
93
|
+
/**
|
|
94
|
+
* Container that hosts the main flow canvas. The zoom control will be
|
|
95
|
+
* rendered as an absolutely positioned overlay inside this container.
|
|
96
|
+
*/
|
|
97
|
+
container: HTMLElement;
|
|
98
|
+
/**
|
|
99
|
+
* Optional position of the zoom control overlay. Defaults to 'bottom-right'.
|
|
100
|
+
*/
|
|
101
|
+
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
102
|
+
/**
|
|
103
|
+
* Optional function to format the zoom value for display. Receives the
|
|
104
|
+
* current zoom factor (e.g. 1.0, 0.5, 2.0) and should return a string
|
|
105
|
+
* (e.g. "100%", "50%").
|
|
106
|
+
*/
|
|
107
|
+
labelFormatter?: (zoom: number) => string;
|
|
108
|
+
/**
|
|
109
|
+
* Optional minimum and maximum zoom applied when interacting via the
|
|
110
|
+
* +/- buttons. If omitted, defaults to the same bounds as the default
|
|
111
|
+
* ViewportController (0.25 .. 3).
|
|
112
|
+
*/
|
|
113
|
+
minZoom?: number;
|
|
114
|
+
maxZoom?: number;
|
|
115
|
+
/**
|
|
116
|
+
* Zoom step multiplier for +/- buttons. Defaults to 1.05.
|
|
117
|
+
*/
|
|
118
|
+
zoomStep?: number;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface ZoomControlHandle {
|
|
122
|
+
/** Root DOM element that contains the zoom control UI. */
|
|
123
|
+
element: HTMLElement;
|
|
124
|
+
/**
|
|
125
|
+
* Updates the visual label based on the given viewport.
|
|
126
|
+
* Call this from your viewport change handler.
|
|
127
|
+
*/
|
|
128
|
+
update(viewport: FlowViewport): void;
|
|
129
|
+
/** Removes all listeners and DOM nodes created by the control. */
|
|
130
|
+
dispose(): void;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Attaches a reusable zoom control ( - [zoom%] + ) to a flow canvas container.
|
|
135
|
+
* The control operates on the given ViewportController instance.
|
|
136
|
+
*/
|
|
137
|
+
export function attachZoomControl(
|
|
138
|
+
controller: ViewportController,
|
|
139
|
+
options: ZoomControlOptions
|
|
140
|
+
): ZoomControlHandle;
|
|
141
|
+
|
|
142
|
+
export interface MinimapNode {
|
|
143
|
+
id: string;
|
|
144
|
+
x: number;
|
|
145
|
+
y: number;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface MinimapOptions {
|
|
149
|
+
/**
|
|
150
|
+
* Container that hosts the main flow canvas. The minimap will be
|
|
151
|
+
* rendered as an absolutely positioned overlay inside this container.
|
|
152
|
+
*/
|
|
153
|
+
container: HTMLElement;
|
|
154
|
+
/**
|
|
155
|
+
* Returns the current set of nodes that should be considered when
|
|
156
|
+
* computing the flow's bounding box in the minimap.
|
|
157
|
+
*/
|
|
158
|
+
getNodes: () => MinimapNode[];
|
|
159
|
+
/**
|
|
160
|
+
* Optional position of the minimap overlay. Defaults to 'bottom-left'.
|
|
161
|
+
*/
|
|
162
|
+
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface MinimapHandle {
|
|
166
|
+
/** Root DOM element that contains the minimap UI. */
|
|
167
|
+
element: HTMLElement;
|
|
168
|
+
/**
|
|
169
|
+
* Recomputes and redraws the minimap based on the latest viewport
|
|
170
|
+
* and node positions. Call this from your viewport change handler.
|
|
171
|
+
*/
|
|
172
|
+
update(viewport: FlowViewport): void;
|
|
173
|
+
/** Removes all listeners and DOM nodes created by the minimap. */
|
|
174
|
+
dispose(): void;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Attaches a reusable minimap overlay to a flow canvas container. The minimap
|
|
179
|
+
* visualises the bounding box of the flow graph and a neutral block that
|
|
180
|
+
* represents the current canvas transform. Users can click/tap on the minimap
|
|
181
|
+
* to re-centre the viewport around a given point.
|
|
182
|
+
*/
|
|
183
|
+
export function attachMinimap(
|
|
184
|
+
controller: ViewportController,
|
|
185
|
+
options: MinimapOptions
|
|
186
|
+
): MinimapHandle;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Merge a view snapshot (viewport + node positions) into an IPython notebook's
|
|
190
|
+
* metadata.ivy.view namespace, returning a new notebook object.
|
|
191
|
+
*/
|
|
192
|
+
export function mergeViewSnapshotIntoNotebook(
|
|
193
|
+
notebook: import('punica').IPythonNotebook,
|
|
194
|
+
snapshot: FlowViewSnapshot
|
|
195
|
+
): import('punica').IPythonNotebook;
|
|
196
|
+
|
|
197
|
+
/** Input node for the automatic layered layout (port counts drive the
|
|
198
|
+
* estimated card height used for overlap-free vertical stacking). */
|
|
199
|
+
export interface FlowLayoutNode {
|
|
200
|
+
id: string;
|
|
201
|
+
inputCount?: number;
|
|
202
|
+
outputCount?: number;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface FlowLayoutEdge {
|
|
206
|
+
source: string;
|
|
207
|
+
target: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export interface FlowLayoutOptions {
|
|
211
|
+
cardWidth?: number;
|
|
212
|
+
horizontalGap?: number;
|
|
213
|
+
verticalGap?: number;
|
|
214
|
+
marginX?: number;
|
|
215
|
+
marginY?: number;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Dependency-free deterministic layered (Sugiyama-lite) layout — the
|
|
220
|
+
* single choke point canvas adapters use when a document has no
|
|
221
|
+
* persisted view positions. Ranks by longest path from sources
|
|
222
|
+
* (left→right, matching port sides), reduces crossings with barycenter
|
|
223
|
+
* sweeps, stacks layers around a common midline. Cyclic graphs fall
|
|
224
|
+
* back to the legacy grid. Pure data utility (no DOM, D1-compliant).
|
|
225
|
+
* Exposed at `punica.flow.shell.computeFlowLayout`.
|
|
226
|
+
*/
|
|
227
|
+
export function computeFlowLayout(
|
|
228
|
+
input: { nodes: FlowLayoutNode[]; edges: FlowLayoutEdge[] },
|
|
229
|
+
options?: FlowLayoutOptions
|
|
230
|
+
): Record<string, { x: number; y: number }>;
|
|
231
|
+
|
|
232
|
+
/** Legacy 6-column grid position — the pre-layout fallback formula
|
|
233
|
+
* (single home; also used internally as the cycle fallback). */
|
|
234
|
+
export function gridFallbackPosition(index: number): {
|
|
235
|
+
x: number;
|
|
236
|
+
y: number;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Options for creating a flow canvas renderer.
|
|
241
|
+
*/
|
|
242
|
+
export interface FlowRendererOptions {
|
|
243
|
+
/**
|
|
244
|
+
* Container element that will host the flow canvas.
|
|
245
|
+
*/
|
|
246
|
+
container: HTMLElement;
|
|
247
|
+
/**
|
|
248
|
+
* Flow graph to render (nodes, edges, viewport).
|
|
249
|
+
*/
|
|
250
|
+
graph: FlowGraph;
|
|
251
|
+
/**
|
|
252
|
+
* Optional node size configuration.
|
|
253
|
+
*/
|
|
254
|
+
nodeSize?: { width: number };
|
|
255
|
+
/**
|
|
256
|
+
* Optional callback when viewport or node positions change.
|
|
257
|
+
*/
|
|
258
|
+
onViewUpdate?: (snapshot: {
|
|
259
|
+
nodes: Array<{ id: string; x: number; y: number }>;
|
|
260
|
+
viewport: FlowViewport;
|
|
261
|
+
}) => void;
|
|
262
|
+
/**
|
|
263
|
+
* Optional callback when a node is selected.
|
|
264
|
+
*/
|
|
265
|
+
onNodeSelect?: (
|
|
266
|
+
nodeId: string,
|
|
267
|
+
data: { label?: string; inputs?: unknown[]; outputs?: unknown[] }
|
|
268
|
+
) => void;
|
|
269
|
+
/**
|
|
270
|
+
* Whether to attach zoom control widget. Defaults to true.
|
|
271
|
+
*/
|
|
272
|
+
attachZoomControl?: boolean;
|
|
273
|
+
/**
|
|
274
|
+
* Whether to attach minimap widget. Defaults to true.
|
|
275
|
+
*/
|
|
276
|
+
attachMinimap?: boolean;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Handle returned by createFlowRenderer for managing the renderer instance.
|
|
281
|
+
*/
|
|
282
|
+
export interface FlowRendererHandle {
|
|
283
|
+
/**
|
|
284
|
+
* Update the graph being rendered.
|
|
285
|
+
*/
|
|
286
|
+
updateGraph(graph: FlowGraph): void;
|
|
287
|
+
/**
|
|
288
|
+
* Get current viewport.
|
|
289
|
+
*/
|
|
290
|
+
getViewport(): FlowViewport;
|
|
291
|
+
/**
|
|
292
|
+
* Set viewport.
|
|
293
|
+
*/
|
|
294
|
+
setViewport(viewport: Partial<FlowViewport>): void;
|
|
295
|
+
/**
|
|
296
|
+
* Dispose the renderer and clean up all resources.
|
|
297
|
+
*/
|
|
298
|
+
dispose(): void;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Creates a flow canvas renderer.
|
|
303
|
+
*
|
|
304
|
+
* This is the core renderer provider that extensions should use
|
|
305
|
+
* instead of implementing their own canvas rendering logic.
|
|
306
|
+
*
|
|
307
|
+
* @param options - Renderer configuration options
|
|
308
|
+
* @returns Handle for managing the renderer instance
|
|
309
|
+
*/
|
|
310
|
+
export function createFlowRenderer(
|
|
311
|
+
options: FlowRendererOptions
|
|
312
|
+
): FlowRendererHandle;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Substrate-shipped renderer provider contract (flow shell renderer).
|
|
316
|
+
*
|
|
317
|
+
* D1: substrate ships the interface; the DOM-bound renderer
|
|
318
|
+
* implementation lives in extension/host territory. Hosts
|
|
319
|
+
* inject a provider via `setRendererProvider(...)`; substrate
|
|
320
|
+
* `createFlowRenderer` / `attachZoomControl` / `attachMinimap`
|
|
321
|
+
* delegate through the active provider and throw loudly when
|
|
322
|
+
* none has been injected.
|
|
323
|
+
*
|
|
324
|
+
* Mirrors the data plane / FS providers `FileSystemProvider` pattern: substrate
|
|
325
|
+
* defines the contract, host owns the impl, substrate refuses
|
|
326
|
+
* to ship the DOM impl itself.
|
|
327
|
+
*/
|
|
328
|
+
export interface FlowRendererProvider {
|
|
329
|
+
createRenderer(options: FlowRendererOptions): FlowRendererHandle;
|
|
330
|
+
createViewportController(
|
|
331
|
+
options: ViewportControllerOptions
|
|
332
|
+
): ViewportController;
|
|
333
|
+
attachZoomControl(
|
|
334
|
+
controller: ViewportController,
|
|
335
|
+
options: ZoomControlOptions
|
|
336
|
+
): ZoomControlHandle;
|
|
337
|
+
attachMinimap(
|
|
338
|
+
controller: ViewportController,
|
|
339
|
+
options: MinimapOptions
|
|
340
|
+
): MinimapHandle;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Host-injection façade exposed at `punica.flow.shell.rendererProvider`.
|
|
345
|
+
* `undefined` until a host calls `setRendererProvider(...)` —
|
|
346
|
+
* substrate intentionally does NOT ship a default DOM impl
|
|
347
|
+
* (D1 + ApplicationProfile prep).
|
|
348
|
+
*/
|
|
349
|
+
export const rendererProvider: FlowRendererProvider | undefined;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Install a host-provided renderer. Substrate validates the
|
|
353
|
+
* shape defensively and refuses incomplete providers — every
|
|
354
|
+
* factory method must be present so downstream `createFlowRenderer`
|
|
355
|
+
* / `attachZoomControl` / `attachMinimap` invocations cannot
|
|
356
|
+
* partially route through `undefined`.
|
|
357
|
+
*/
|
|
358
|
+
export function setRendererProvider(provider: FlowRendererProvider): void;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Drop any installed renderer provider. Tests + hosts that
|
|
362
|
+
* disable rendering at runtime use this to restore the
|
|
363
|
+
* substrate's "no renderer injected" default.
|
|
364
|
+
*/
|
|
365
|
+
export function resetRendererProvider(): void;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// Module-level exports for convenience
|
|
370
|
+
export type FlowNode = flow.shell.FlowNode;
|
|
371
|
+
export type FlowEdge = flow.shell.FlowEdge;
|
|
372
|
+
export type FlowGraph = flow.shell.FlowGraph;
|
|
373
|
+
export type FlowViewport = flow.shell.FlowViewport;
|
|
374
|
+
}
|