@punica/editor 1.0.6 → 1.0.8

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.
Files changed (69) hide show
  1. package/dist/index.bundle.esm.js +2 -1
  2. package/dist/index.bundle.esm.js.map +1 -1
  3. package/dist/index.bundle.umd.js +2 -1
  4. package/dist/index.bundle.umd.js.map +1 -1
  5. package/package.json +28 -3
  6. package/types/index.d.ts +120 -11
  7. package/types/punica.module.bootstrap.d.ts +45 -0
  8. package/types/punica.module.capability.d.ts +359 -0
  9. package/types/punica.module.extensions.api.d.ts +766 -0
  10. package/types/punica.module.extensions.settings.d.ts +106 -0
  11. package/types/punica.module.flow.agent.d.ts +75 -0
  12. package/types/punica.module.flow.api.d.ts +128 -0
  13. package/types/punica.module.flow.d.ts +490 -0
  14. package/types/punica.module.flow.engine.d.ts +228 -0
  15. package/types/punica.module.flow.mcp.d.ts +26 -0
  16. package/types/punica.module.flow.notebook.d.ts +210 -0
  17. package/types/punica.module.flow.primitives.d.ts +700 -0
  18. package/types/punica.module.flow.shell.d.ts +374 -0
  19. package/types/punica.module.kernel.ai.d.ts +462 -0
  20. package/types/punica.module.kernel.commands.d.ts +49 -0
  21. package/types/punica.module.kernel.events.d.ts +274 -0
  22. package/types/punica.module.kernel.history.d.ts +20 -0
  23. package/types/punica.module.kernel.llm.d.ts +343 -0
  24. package/types/punica.module.kernel.notifications.d.ts +64 -0
  25. package/types/punica.module.kernel.policy.d.ts +273 -0
  26. package/types/punica.module.kernel.tasks.d.ts +107 -0
  27. package/types/punica.module.kernel.timeServer.d.ts +16 -0
  28. package/types/punica.module.runtime.api.d.ts +214 -0
  29. package/types/punica.module.runtime.capabilities.d.ts +175 -0
  30. package/types/punica.module.runtime.compute.d.ts +339 -0
  31. package/types/punica.module.runtime.datasets.d.ts +234 -0
  32. package/types/punica.module.runtime.fs.d.ts +385 -0
  33. package/types/punica.module.runtime.harness.d.ts +246 -0
  34. package/types/punica.module.runtime.host.d.ts +272 -0
  35. package/types/punica.module.runtime.inference.d.ts +164 -0
  36. package/types/punica.module.runtime.lifecycle.d.ts +15 -0
  37. package/types/punica.module.runtime.llm.d.ts +470 -0
  38. package/types/punica.module.runtime.mcp.d.ts +139 -0
  39. package/types/punica.module.runtime.modelRuntimes.d.ts +90 -0
  40. package/types/punica.module.runtime.models.d.ts +254 -0
  41. package/types/punica.module.runtime.search.d.ts +59 -0
  42. package/types/punica.module.runtime.secrets.d.ts +26 -0
  43. package/types/punica.module.runtime.tasks.d.ts +27 -0
  44. package/types/punica.module.runtime.vcs.d.ts +67 -0
  45. package/types/punica.module.runtime.vectors.d.ts +74 -0
  46. package/types/punica.module.runtime.workspace.d.ts +134 -0
  47. package/types/punica.module.shell.activityBar.d.ts +42 -0
  48. package/types/punica.module.shell.components.d.ts +87 -0
  49. package/types/punica.module.shell.contentTabs.d.ts +33 -0
  50. package/types/punica.module.shell.dragDrop.d.ts +25 -0
  51. package/types/punica.module.shell.keyboardShortcuts.d.ts +38 -0
  52. package/types/punica.module.shell.layout.d.ts +106 -0
  53. package/types/punica.module.shell.markdown.d.ts +36 -0
  54. package/types/punica.module.shell.panelTabs.d.ts +71 -0
  55. package/types/punica.module.shell.profile.d.ts +278 -0
  56. package/types/punica.module.shell.statusbar.d.ts +26 -0
  57. package/types/punica.module.shell.view.d.ts +455 -0
  58. package/types/punica.module.shell.views.d.ts +150 -0
  59. package/types/punica.module.test.d.ts +562 -0
  60. package/types/punica.module.activityBar.d.ts +0 -21
  61. package/types/punica.module.commands.d.ts +0 -21
  62. package/types/punica.module.dragDrop.d.ts +0 -23
  63. package/types/punica.module.extensions.d.ts +0 -157
  64. package/types/punica.module.history.d.ts +0 -18
  65. package/types/punica.module.keyboardShortcuts.d.ts +0 -29
  66. package/types/punica.module.layout.d.ts +0 -22
  67. package/types/punica.module.statusbar.d.ts +0 -21
  68. package/types/punica.module.timeServer.d.ts +0 -14
  69. 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
+ }