@lace-cloud/canvas 0.17.0 → 0.19.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 +115 -21
- package/dist/{App-LQX66JSZ.css → App-D7WF3TWZ.css} +9 -3
- package/dist/{DiagnosticsPanel-3UQFOL4T.css → DiagnosticsPanel-HB3JQYSY.css} +6 -0
- package/dist/{ModuleNode-VNODPUHI.css → ModuleNode-OJXMNOL3.css} +28 -0
- package/dist/chunk-S2FFLFOT.mjs +13747 -0
- package/dist/chunk-S2FFLFOT.mjs.map +1 -0
- package/dist/engine/index.cjs +13765 -0
- package/dist/engine/index.cjs.map +1 -0
- package/dist/engine/index.d.mts +26 -0
- package/dist/engine/index.d.ts +26 -0
- package/dist/engine/index.mjs +81 -0
- package/dist/engine/index.mjs.map +1 -0
- package/dist/index.cjs +8724 -7273
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +29 -3338
- package/dist/index.d.ts +29 -3338
- package/dist/index.mjs +1391 -13514
- package/dist/index.mjs.map +1 -1
- package/dist/mapping-BzX6r87C.d.mts +4045 -0
- package/dist/mapping-BzX6r87C.d.ts +4045 -0
- package/package.json +17 -12
- package/dist/AccountPanel-YCG6RHJI.css +0 -32
- package/dist/ChaosPanel-7JZ2KASG.css +0 -18
- package/dist/PreviewPanel-FHSY6FS6.css +0 -18
- package/dist/RegistryPanel-DLIMDBWW.css +0 -33
- package/dist/RunPanel-DHBR5SCC.css +0 -11
- package/dist/StackPicker-ZJQELYQ6.css +0 -10
package/README.md
CHANGED
|
@@ -2,10 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
Lace Cloud's visual canvas — the React + ReactFlow webview UI for
|
|
4
4
|
visually composing Terraform modules. The core renders against
|
|
5
|
-
`CanvasPorts` (`source`, `context`, `viewState`,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
`CanvasPorts` (`source`, `context`, `viewState`, `presenter`, and
|
|
6
|
+
optional `editor`, `commands`); a host wires only the ports it can
|
|
7
|
+
support, and read-only is the absence of `editor` (or a live session
|
|
8
|
+
whose source tf is refused), never a flag.
|
|
9
|
+
|
|
10
|
+
The canvas draws module authoring: the graph, the module and edge
|
|
11
|
+
inspectors, the settings sidebar, Save, Generate, Validate, Convert,
|
|
12
|
+
undo/redo, groups, the diagnostics list, the conflict and refused-tf
|
|
13
|
+
banners, and node badges for the stack its host supplies. The package
|
|
14
|
+
carries more than the canvas draws — the typed command contract, the
|
|
15
|
+
stack and run command bindings with their runner, and the reducers over
|
|
16
|
+
their output — and a host draws that in its own UI (a stacks tree, a
|
|
17
|
+
page section, a command palette) through `@lace-cloud/canvas/engine`.
|
|
9
18
|
|
|
10
19
|
## Install
|
|
11
20
|
|
|
@@ -24,28 +33,71 @@ Code, JetBrains, Storybook, the portal — renders against:
|
|
|
24
33
|
validator of its own.
|
|
25
34
|
- `editor` — `apply` (every IR edit, registry placement included),
|
|
26
35
|
`save` (working IR → `state.lace`), `generate` (`state.lace` → source
|
|
27
|
-
tf), `resolveConflict` (Keep or Reload)
|
|
28
|
-
delay for a host that offers the preference. Its absence is read-only.
|
|
36
|
+
tf), `resolveConflict` (Keep or Reload). Its absence is read-only.
|
|
29
37
|
- `commands` — runs one CLI command in-process (`invoke(path, args,
|
|
30
38
|
signal)`); every canvas feature that isn't an IR edit is a
|
|
31
39
|
contribution bound to a command path in `command-tree.golden`.
|
|
32
|
-
- `
|
|
33
|
-
|
|
34
|
-
- `context`
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
- `presenter` (required) — `notify`, and `confirm` for a host that can
|
|
41
|
+
ask: a binding that confirms first resolves only then.
|
|
42
|
+
- `context` (required) — the authoring root, the session, and the
|
|
43
|
+
stack. The stack is the host's choice and the canvas's one source for
|
|
44
|
+
it: the canvas draws no stack picker, and a host that passes a `ports`
|
|
45
|
+
object with another `context.stack` gets the node badges of the stack
|
|
46
|
+
it chose. The runner is keyed on `commands`, `presenter` and `editor`,
|
|
47
|
+
not on the `ports` object, so that change detaches nothing still
|
|
48
|
+
running.
|
|
49
|
+
- `viewState` (required) — the consumer-owned arrangement (node
|
|
50
|
+
positions, group collapse/label), never transported over the wire.
|
|
51
|
+
|
|
52
|
+
## The data layer a host draws
|
|
53
|
+
|
|
54
|
+
`@lace-cloud/canvas/engine` exports `CORE_COMMAND_ACTIONS` — the
|
|
55
|
+
bindings for `stack apply`, `stack preview`, `stack destroy` (which
|
|
56
|
+
asks for the stack's slug, typed), `stack scan`, `stack create`,
|
|
57
|
+
`stack import`, `run cancel`, `run logs --follow`, `module validate`
|
|
58
|
+
and `module convert` — with `createActionRunner`, the one execution
|
|
59
|
+
path, and `createResultStore`, one slot per result kind (`run`,
|
|
60
|
+
`preview`, `follow`, `report`) folded by pure reducers. A host with no
|
|
61
|
+
canvas builds a runner from `{commands, presenter}` and runs a binding
|
|
62
|
+
over `{root, stack}`:
|
|
37
63
|
|
|
38
|
-
|
|
64
|
+
```ts
|
|
65
|
+
import {
|
|
66
|
+
CORE_COMMAND_ACTIONS,
|
|
67
|
+
createActionRunner,
|
|
68
|
+
createResultStore,
|
|
69
|
+
} from '@lace-cloud/canvas/engine';
|
|
70
|
+
|
|
71
|
+
const results = createResultStore();
|
|
72
|
+
const runner = createActionRunner({ commands, presenter }, results);
|
|
73
|
+
const apply = CORE_COMMAND_ACTIONS.find((a) => a.id === 'apply');
|
|
74
|
+
if (apply) await runner.run(apply, { root, stack }, {});
|
|
75
|
+
// results.getSnapshot().run is the run's phases, last log line and outcome.
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
A host that mounts the canvas can own its result store too: pass it as
|
|
79
|
+
`<App ports={ports} results={results} />` and call `results.bumpTick()`
|
|
80
|
+
when something outside the canvas changed what `stack describe` reports
|
|
81
|
+
(a run the host's own UI started has settled) — the node badges re-read.
|
|
82
|
+
One store may serve several canvases: each one's report is kept under its
|
|
83
|
+
own session, so no canvas shows or clears another's.
|
|
84
|
+
|
|
85
|
+
## The engine mapping
|
|
39
86
|
|
|
40
87
|
`src/adapters/engine/` turns one engine connection into
|
|
41
|
-
`source`/`editor`/`commands` plus `context
|
|
42
|
-
deep imports:
|
|
88
|
+
`source`/`editor`/`commands` plus `context`, or into `commands` alone.
|
|
89
|
+
Two entries, no deep imports: `@lace-cloud/canvas` (the React surface and
|
|
90
|
+
everything below) and `@lace-cloud/canvas/engine` (the React-free entry —
|
|
91
|
+
the mappings, the callers, the command contract, the port types and
|
|
92
|
+
errors (`Action`, the entry of an `editor.apply` batch, among them), the
|
|
93
|
+
runner, the result store and `autosave` — which a host loads outside any
|
|
94
|
+
webview):
|
|
43
95
|
|
|
44
96
|
```ts
|
|
45
|
-
import { connectCaller,
|
|
97
|
+
import { connectCaller, openEngineSession } from '@lace-cloud/canvas/engine';
|
|
46
98
|
|
|
47
99
|
const caller = connectCaller({ baseUrl: 'http://localhost:50051', token });
|
|
48
|
-
const { ports, close } = await
|
|
100
|
+
const { ports, close } = await openEngineSession(caller, { root: '/path/to/authoring/root' });
|
|
49
101
|
```
|
|
50
102
|
|
|
51
103
|
- `connectCaller({baseUrl, token})` reaches a running `lace engine`
|
|
@@ -55,14 +107,56 @@ const { ports, close } = await openEngineCanvas(caller, { root: '/path/to/author
|
|
|
55
107
|
(`@lace-cloud/proto`) to a host process holding the engine
|
|
56
108
|
connection instead — VS Code and JetBrains webviews. The other end
|
|
57
109
|
is `@lace-cloud/host`'s `serveEngineBridge`.
|
|
58
|
-
- `
|
|
59
|
-
(`{root}` | `{ephemeral:{name}}` | `{fixture}`) and subscribes
|
|
60
|
-
exactly once, fanning that stream out to `source` and
|
|
61
|
-
`editor.generate()` call
|
|
62
|
-
|
|
110
|
+
- `openEngineSession(caller, target)` opens the session
|
|
111
|
+
(`{root}` | `{ephemeral:{name}, cwd}` | `{fixture, cwd}`) and subscribes
|
|
112
|
+
exactly once, fanning that stream out to `source` and, by the id each
|
|
113
|
+
`editor.generate()` call chooses, to that call alone: two Generates
|
|
114
|
+
started together each read their own progress, and each closes with
|
|
115
|
+
its own call's outcome — `success`, or `error` with the refusal's
|
|
116
|
+
`reason` when the engine refused it (a session runs one Generate at a
|
|
117
|
+
time). `editor.apply` and `editor.save` resolve, and a Generate's
|
|
118
|
+
`success` is yielded, once `source` has delivered the frame at the
|
|
119
|
+
revision the engine's answer names, so a caller that writes and then
|
|
120
|
+
reads the source reads its own write; a source that stops first
|
|
121
|
+
rejects with `ApplyUnobservedError` (after a Generate's `success`, its
|
|
122
|
+
iterable throws it). Every `source` frame names the
|
|
123
|
+
tree the session last observed (`treeHash`), and a subscriber that
|
|
124
|
+
passes `onCommandResult` receives the result of every command that ran
|
|
125
|
+
in the session's root, the last per command path replayed when it joins
|
|
126
|
+
late — the input of `foldReport`, whose `currentReport` keeps the
|
|
127
|
+
entries about that tree. The stream's end reaches every
|
|
128
|
+
`source` subscriber as `{ kind: 'closed' }` — the session is gone — or
|
|
129
|
+
`{ kind: 'failed', error }` — the stream is gone and the session
|
|
130
|
+
unknown (a consumer overflow, a transport drop, an engine exit); the
|
|
131
|
+
mapping's own `close()` reports nothing. `commands.invoke` runs a CLI
|
|
132
|
+
command over `Invoke`; a command that exits non-zero rejects `events`
|
|
133
|
+
with `CommandExitError`, whose `failure` is the command's failure
|
|
134
|
+
document when it wrote one (`reason`, `message`, and `url`, `tool` or
|
|
135
|
+
`apiCode` as the reason carries them), so a host branches on
|
|
136
|
+
`failure.reason` and never on the stderr text. `reasonWire` spells a
|
|
137
|
+
`Reason` enum value the way a failure document does.
|
|
138
|
+
`Invocation.cancel()` sends `CancelInvoke`
|
|
63
139
|
only and leaves `events` running until the command's own exit — a
|
|
64
140
|
`signal` abort or `close()` detaches the stream instead, without
|
|
65
141
|
cancelling the command's remote effects.
|
|
142
|
+
- `openEngineCommands(caller, { cwd })` is the commands mapping:
|
|
143
|
+
`Initialize` once, `Invoke` per command, no session and no Subscribe.
|
|
144
|
+
- Both mappings name the protocol version this package speaks
|
|
145
|
+
(`ENGINE_PROTOCOL_VERSION`, `@lace-cloud/proto`) on `Initialize`; an
|
|
146
|
+
engine that speaks another refuses the call.
|
|
147
|
+
- Every `Invoke` names the one working directory its command runs in, as
|
|
148
|
+
a terminal invocation has one, and no session: the engine takes the
|
|
149
|
+
Workspace of the session it holds open on that directory when there is
|
|
150
|
+
one, and the disk Workspace otherwise. The directory is the `cwd` the
|
|
151
|
+
call names when it names one: the runner passes the run's root for an
|
|
152
|
+
action that declares `root`, so one runner over one commands port serves
|
|
153
|
+
every authoring root a host holds. A call naming none runs in the port's
|
|
154
|
+
own directory: a session mapping's root, or, for a mapping with no root
|
|
155
|
+
(the commands mapping, an ephemeral or fixture session), the `cwd` its
|
|
156
|
+
host supplies — the developer's home for a host whose commands read none.
|
|
157
|
+
- A session's `ports` always carry `editor` and `commands`
|
|
158
|
+
(`EngineSession`), so a host reads them with no presence check;
|
|
159
|
+
`CanvasPorts` keeps both optional for a host that supplies neither.
|
|
66
160
|
|
|
67
161
|
`snapshotSource` (`src/adapters/snapshot-source.ts`) is the read-only
|
|
68
162
|
`source` a host without a live engine mounts (portal's control-plane
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* App's own layout: the fixed slots every contribution renders
|
|
2
|
-
* into — toolbar (actions, the
|
|
3
|
-
* canvas itself with its bottom tabs,
|
|
4
|
-
* everything. A host's own contributions land in the exact same slots
|
|
2
|
+
* into — toolbar (actions, the status markers, the Settings toggle),
|
|
3
|
+
* sidebar, the canvas itself with its bottom tabs, the inspector, and
|
|
4
|
+
* the banner strip above everything. A host's own contributions land in the exact same slots
|
|
5
5
|
* a core one does; there is no host-specific layout. */
|
|
6
6
|
|
|
7
7
|
.lace-app {
|
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
overflow: hidden;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
/* The root holds focus so the keymap hears keys while no element inside
|
|
15
|
+
does. It is no control, so it draws no focus ring. */
|
|
16
|
+
.lace-app:focus {
|
|
17
|
+
outline: none;
|
|
18
|
+
}
|
|
19
|
+
|
|
14
20
|
.lace-app__banners {
|
|
15
21
|
position: relative;
|
|
16
22
|
z-index: var(--lace-z-chrome);
|
|
@@ -168,3 +168,31 @@
|
|
|
168
168
|
.lace-module-node__pin-row-label--default {
|
|
169
169
|
color: var(--lace-color-neutral-100-alpha-85);
|
|
170
170
|
}
|
|
171
|
+
|
|
172
|
+
/* The node-to-node drag's grip: wholly below the card, clear of the header
|
|
173
|
+
* and both pin rails. */
|
|
174
|
+
.react-flow__handle.lace-module-node__grip {
|
|
175
|
+
bottom: -3px;
|
|
176
|
+
width: 24px;
|
|
177
|
+
height: 6px;
|
|
178
|
+
background: var(--lace-gunmetal);
|
|
179
|
+
border: 1px solid var(--lace-color-accent-alpha-medium);
|
|
180
|
+
border-radius: var(--lace-radius-pill);
|
|
181
|
+
transform: translate(-50%, 100%);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* The card as the drop area for that drag: invisible, outlined while a drag
|
|
185
|
+
* held over it would connect. */
|
|
186
|
+
.react-flow__handle.lace-module-node__drop {
|
|
187
|
+
inset: 0;
|
|
188
|
+
width: auto;
|
|
189
|
+
height: auto;
|
|
190
|
+
background: none;
|
|
191
|
+
border: none;
|
|
192
|
+
border-radius: inherit;
|
|
193
|
+
transform: none;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.react-flow__handle.lace-module-node__drop.connectingto.valid {
|
|
197
|
+
outline: 2px solid var(--lace-color-accent);
|
|
198
|
+
}
|