@ultrst-armada/floks 1.13.21 → 1.14.1

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 (82) hide show
  1. package/.krusbl-release-attestation.json +3 -3
  2. package/index.d.ts +3 -3
  3. package/package.json +14 -11
  4. package/packages/canvas-ui/dist/MovableSocketView.d.ts +1 -1
  5. package/packages/canvas-ui/dist/NodeCard.d.ts +1 -1
  6. package/packages/canvas-ui/dist/NodeDetailsPanel.d.ts +1 -1
  7. package/packages/canvas-ui/dist/NodeGraphCanvas.d.ts +1 -1
  8. package/packages/canvas-ui/dist/Viewer2DNodes.d.ts +1 -1
  9. package/packages/canvas-ui/dist/WireRenderer.d.ts +1 -1
  10. package/packages/canvas-ui/dist/authoring/UiAuthoringValidationPanel.d.ts +1 -1
  11. package/packages/canvas-ui/dist/{chunk-RH5NINIT.js → chunk-A7BSZ5QO.js} +28 -103
  12. package/packages/canvas-ui/dist/chunk-FPRATI44.js +45 -0
  13. package/packages/canvas-ui/dist/{chunk-ZJXRL74D.js → chunk-KAKAFGVH.js} +22 -16
  14. package/packages/canvas-ui/dist/{chunk-YHEIL67R.js → chunk-SRGVIYC5.js} +6 -6
  15. package/packages/canvas-ui/dist/{chunk-7CYX3B6O.js → chunk-TKOMIUCU.js} +1 -1
  16. package/packages/canvas-ui/dist/{chunk-XVAHT5WE.js → chunk-ZDADZVQ2.js} +363 -59
  17. package/packages/canvas-ui/dist/{chunk-QRYNQ36L.js → chunk-ZSVXR3HU.js} +1 -1
  18. package/packages/canvas-ui/dist/editor/MonacoEditor.d.ts +1 -1
  19. package/packages/canvas-ui/dist/editor/index.js +1 -1
  20. package/packages/canvas-ui/dist/fod/index.js +3 -3
  21. package/packages/canvas-ui/dist/frnl-editable-node-graph/FrnlEditableNodeGraph.d.ts +1 -1
  22. package/packages/canvas-ui/dist/frnl-editable-node-graph/index.js +2 -2
  23. package/packages/canvas-ui/dist/graph-2d/CanvasBackground2D.d.ts +1 -1
  24. package/packages/canvas-ui/dist/graph-2d/MagneticTraces2D.d.ts +2 -2
  25. package/packages/canvas-ui/dist/graph-2d/Node2DBase.d.ts +3 -3
  26. package/packages/canvas-ui/dist/graph-2d/NodeRenderer2D.d.ts +3 -3
  27. package/packages/canvas-ui/dist/graph-2d/RecorderWaveformDisplay.d.ts +1 -1
  28. package/packages/canvas-ui/dist/graph-2d/Socket2D.d.ts +1 -1
  29. package/packages/canvas-ui/dist/graph-2d/Wire2D.d.ts +1 -1
  30. package/packages/canvas-ui/dist/graph-2d/index.js +9 -9
  31. package/packages/canvas-ui/dist/graph-2d/socketCoordinates.d.ts +1 -1
  32. package/packages/canvas-ui/dist/graph-2d/types.d.ts +1 -1
  33. package/packages/canvas-ui/dist/graph-2d/useCanvas2DMagnetic.d.ts +4 -4
  34. package/packages/canvas-ui/dist/index.js +41 -41
  35. package/packages/canvas-ui/dist/node-graph-ui/ghost/GhostNodeCard.d.ts +1 -1
  36. package/packages/canvas-ui/dist/node-graph-ui/ghost/GhostSolidifyBar.d.ts +1 -1
  37. package/packages/canvas-ui/dist/node-graph-ui/ghost/GhostTraceLayer.d.ts +1 -1
  38. package/packages/canvas-ui/dist/node-graph-ui/react-flow/ReactFlowAdapter.d.ts +4 -4
  39. package/packages/canvas-ui/dist/node-graph-ui/toolbar/GraphToolbar.d.ts +1 -1
  40. package/packages/canvas-ui/dist/node-graph-ui/widgets/CanvasContextMenu.d.ts +1 -1
  41. package/packages/canvas-ui/dist/node-graph-ui/widgets/CompatibleNodePicker.d.ts +1 -1
  42. package/packages/canvas-ui/dist/node-graph-ui/widgets/MagneticTraceLayer.d.ts +1 -1
  43. package/packages/canvas-ui/dist/node-graph-ui/widgets/NodeSearchPalette.d.ts +1 -1
  44. package/packages/canvas-ui/dist/predictive/PredictiveGhostNodeCard/PredictiveGhostNodeCard.d.ts +2 -2
  45. package/packages/canvas-ui/dist/predictive/PredictiveGhostNodeCard/types.d.ts +1 -1
  46. package/packages/canvas-ui/dist/predictive/PredictiveGhostNodeCard.d.ts +2 -2
  47. package/packages/canvas-ui/dist/predictive/PredictiveLayer2D.d.ts +1 -2
  48. package/packages/canvas-ui/dist/predictive/index.js +3 -3
  49. package/packages/canvas-ui/dist/predictive/usePredictiveGraph2D.d.ts +4 -5
  50. package/packages/canvas-ui/dist/useGhostRouting.d.ts +1 -1
  51. package/packages/canvas-ui/dist/useNodeGraph.d.ts +1 -1
  52. package/packages/canvas-ui/package.json +5 -6
  53. package/packages/contracts/dist/index.d.ts +396 -1
  54. package/packages/contracts/dist/index.js +201 -1
  55. package/packages/contracts/dist/state-graph.d.ts +456 -0
  56. package/packages/contracts/dist/state-graph.js +282 -0
  57. package/packages/contracts/package.json +6 -1
  58. package/packages/ui/dist/{chunk-YQL4AGPU.js → chunk-OMNGRMJY.js} +59 -136
  59. package/packages/ui/dist/{chunk-3YYPBZS2.js → chunk-W6ENIFEW.js} +3 -3
  60. package/packages/ui/dist/components/auth/LuthAuthClient.d.ts +4 -4
  61. package/packages/ui/dist/components/auth/index.js +1 -1
  62. package/packages/ui/dist/components/auth/luthAuthTypes.d.ts +2 -2
  63. package/packages/ui/dist/components/workspace/WorkspaceCreateDialog.d.ts +15 -18
  64. package/packages/ui/dist/components/workspace/WorkspaceTilesMenu.d.ts +3 -5
  65. package/packages/ui/dist/components/workspace/index.js +1 -1
  66. package/packages/ui/dist/index.js +2 -2
  67. package/packages/ui/dist/palette/ThemeContext.d.ts +1 -1
  68. package/packages/ui/dist/palette/domThemeInjector.d.ts +1 -1
  69. package/packages/ui/dist/palette/index.d.ts +4 -4
  70. package/packages/ui/dist/palette/palettes.d.ts +1 -1
  71. package/packages/ui/dist/palette/palettesBase.d.ts +1 -1
  72. package/packages/ui/dist/palette/palettesExtended.d.ts +1 -1
  73. package/packages/ui/dist/runtime-entrypoint.test.d.ts +1 -0
  74. package/packages/ui/dist/theme/packs/docustack-cyberpunk-neon/index.d.ts +1 -1
  75. package/packages/ui/dist/theme/packs/docustack-cyberpunk-neon/manifest.json +8 -0
  76. package/packages/ui/dist/theme/packs/docustack-dark-gold/index.d.ts +1 -1
  77. package/packages/ui/dist/theme/packs/docustack-dark-gold/manifest.json +8 -0
  78. package/packages/ui/dist/theme/packs/docustack-warm-coffee/index.d.ts +1 -1
  79. package/packages/ui/dist/theme/packs/docustack-warm-coffee/manifest.json +8 -0
  80. package/packages/ui/package.json +3 -3
  81. package/scripts/normalize-package-declarations.mjs +67 -0
  82. package/packages/canvas-ui/dist/chunk-U2SC3RMJ.js +0 -391
@@ -0,0 +1,282 @@
1
+ // src/state-graph.ts
2
+ var SpaceNode = class {
3
+ id;
4
+ type;
5
+ position;
6
+ name;
7
+ label;
8
+ width;
9
+ height;
10
+ radius;
11
+ active;
12
+ socketOffsets;
13
+ inputs;
14
+ outputs;
15
+ constructor(p) {
16
+ Object.assign(this, p);
17
+ this.id = p.id;
18
+ this.type = p.type;
19
+ this.position = p.position;
20
+ }
21
+ };
22
+ var ContainerNode = class extends SpaceNode {
23
+ };
24
+ var ModuleNode = class extends SpaceNode {
25
+ };
26
+ var TriggerNode = class extends SpaceNode {
27
+ intervalBeats;
28
+ };
29
+ var EffectNode = class extends SpaceNode {
30
+ effectType;
31
+ compressorConfig;
32
+ multibandCompressorConfig;
33
+ limiterConfig;
34
+ reverbConfig;
35
+ delayConfig;
36
+ saturationConfig;
37
+ };
38
+ var RecorderNode = class extends SpaceNode {
39
+ isArmed;
40
+ };
41
+ var SIGNAL_TYPES = { audio_stereo: { colorStr: "#00ffff" }, audio_mono: { colorStr: "#38bdf8" }, audio_packet: { colorStr: "#818cf8" }, trigger: { colorStr: "#eab308" }, midi_stream: { colorStr: "#ec4899" }, midi_packet: { colorStr: "#f43f5e" }, curve_stream: { colorStr: "#10b981" }, curve_packet: { colorStr: "#34d399" }, component: { colorStr: "#a855f7" }, AUDIO: { colorStr: "#38bdf8" }, MIDI: { colorStr: "#ec4899" }, TRIGGER: { colorStr: "#eab308" }, DATA: { colorStr: "#10b981" }, DEFAULT: { colorStr: "#60a5fa" } };
42
+ var GraphNodeParent = class {
43
+ static calculateConstrainedSocketOffset(node, _socketId, isOutput, index, total, clearance = 14) {
44
+ const w = node.width ?? 180, h = node.height ?? 120, c = Math.max(1, total), pitch = Math.min(40, Math.max(60, h - 40) / c);
45
+ return { x: isOutput ? w / 2 + Math.max(12, clearance) : -w / 2 - Math.max(12, clearance), y: c === 1 ? 0 : -((c - 1) * pitch) / 2 + index * pitch };
46
+ }
47
+ };
48
+ function getNodeSockets(node) {
49
+ const f = (s) => ({ ...s, socketId: s.socketId ?? s.id, nodeId: node.id });
50
+ return { inputs: (node.inputs ?? []).map(f), outputs: (node.outputs ?? []).map(f) };
51
+ }
52
+ function calculateSocketCoordinates(baseY, o) {
53
+ const c = Math.max(12, o.clearance ?? 14), n = o.nudge ?? { x: 0, y: 0 }, w = o.cardWidth / 2, b = o.isOutput ? w + c : -w - c;
54
+ return { baseX: b, effectiveX: b + n.x, effectiveY: baseY + n.y, nudge: n };
55
+ }
56
+ function getBeamPoints(n, baseW = 5, headW = 1.2) {
57
+ const vx = -n.x, vy = -n.y, d = Math.hypot(vx, vy);
58
+ if (d < 1) return "";
59
+ const px = -vy / d, py = vx / d;
60
+ return `${-px * headW},${-py * headW} ${px * headW},${py * headW} ${vx + px * baseW},${vy + py * baseW} ${vx - px * baseW},${vy - py * baseW}`;
61
+ }
62
+ function describeSvgArc(cx, cy, r, startDeg, endDeg) {
63
+ const rad = (d) => (d - 90) * Math.PI / 180, a = rad(startDeg), b = rad(endDeg), x1 = cx + r * Math.cos(a), y1 = cy + r * Math.sin(a), x2 = cx + r * Math.cos(b), y2 = cy + r * Math.sin(b), large = Math.abs(endDeg - startDeg) <= 180 ? "0" : "1", sweep = endDeg > startDeg ? "1" : "0";
64
+ return `M ${x1} ${y1} A ${r} ${r} 0 ${large} ${sweep} ${x2} ${y2}`;
65
+ }
66
+ function zoomAtPoint(mx, my, delta, v, c = {}) {
67
+ const z = clampZoom(v.zoom + delta, c), gx = (mx - v.panX) / v.zoom, gy = (my - v.panY) / v.zoom;
68
+ return { zoom: z, panX: mx - gx * z, panY: my - gy * z };
69
+ }
70
+ function clampZoom(z, c = {}) {
71
+ return Math.max(c.minZoom ?? 0.25, Math.min(c.maxZoom ?? 2.5, z));
72
+ }
73
+ function canvasToScreen(x, y, v) {
74
+ return { x: x * v.zoom + v.panX, y: y * v.zoom + v.panY };
75
+ }
76
+ function isNodeInCenterDeadZone(n, v, w, h, dz = 80) {
77
+ const p = canvasToScreen(n.position.x, n.position.y, v);
78
+ return Math.abs(p.x - w / 2) < dz && Math.abs(p.y - h / 2) < dz;
79
+ }
80
+ function getCenterPanForNode(n, v, w, h) {
81
+ const p = canvasToScreen(n.position.x, n.position.y, v);
82
+ return { x: v.panX + w / 2 - p.x, y: v.panY + h / 2 - p.y };
83
+ }
84
+ function getNodesInSelection(nodes, s, v) {
85
+ return nodes.filter((n) => {
86
+ const p = canvasToScreen(n.position.x, n.position.y, v);
87
+ return p.x >= s.x && p.x <= s.x + s.width && p.y >= s.y && p.y <= s.y + s.height;
88
+ });
89
+ }
90
+ var ConnectionRuleStore = class {
91
+ static types = /* @__PURE__ */ new Map();
92
+ static registerNodeTypes(d) {
93
+ for (const x of d) this.types.set(x.type, x);
94
+ }
95
+ static listNodeTypes() {
96
+ return [...this.types.values()];
97
+ }
98
+ static getNodeType(t) {
99
+ return this.types.get(t);
100
+ }
101
+ static canConnect(a, b) {
102
+ const x = (a.dataType || "ANY").toUpperCase(), y = (b.dataType || "ANY").toUpperCase();
103
+ return x === "ANY" || y === "ANY" || x === "*" || y === "*" || x === y;
104
+ }
105
+ static resolve(a, b) {
106
+ return { wireType: "DEFAULT", allowed: this.canConnect(a, b) };
107
+ }
108
+ };
109
+ var GhostStore = class _GhostStore {
110
+ static instance = null;
111
+ isActive = false;
112
+ ghostNodes = [];
113
+ ghostTraces = [];
114
+ scenarioIndex = 0;
115
+ hoveredGhostId = null;
116
+ listeners = /* @__PURE__ */ new Set();
117
+ static getInstance() {
118
+ return this.instance ??= new _GhostStore();
119
+ }
120
+ subscribe(f) {
121
+ this.listeners.add(f);
122
+ return () => this.listeners.delete(f);
123
+ }
124
+ setPredictions(n, t) {
125
+ this.ghostNodes = n;
126
+ this.ghostTraces = t;
127
+ this.isActive = n.length > 0;
128
+ this.scenarioIndex = 0;
129
+ this.notify();
130
+ }
131
+ cycleScenario(max = 3) {
132
+ const count = Math.max(max, ...this.ghostNodes.map((n) => n.scenarioIndex + 1));
133
+ this.scenarioIndex = (this.scenarioIndex + 1) % count;
134
+ this.notify();
135
+ }
136
+ setHoveredGhostId(id) {
137
+ this.hoveredGhostId = id;
138
+ this.notify();
139
+ }
140
+ getActiveGhostNodes() {
141
+ return this.ghostNodes.filter((n) => n.scenarioIndex === this.scenarioIndex);
142
+ }
143
+ getActiveGhostTraces() {
144
+ return this.ghostTraces.filter((t) => t.scenarioIndex === this.scenarioIndex);
145
+ }
146
+ clear() {
147
+ this.isActive = false;
148
+ this.ghostNodes = [];
149
+ this.ghostTraces = [];
150
+ this.scenarioIndex = 0;
151
+ this.hoveredGhostId = null;
152
+ this.notify();
153
+ }
154
+ notify() {
155
+ for (const f of this.listeners) f();
156
+ }
157
+ };
158
+ function inferGhostNodes(selected, defs, o = {}) {
159
+ const count = Math.max(1, o.scenarioCount ?? 3), max = o.maxSuggestionsPerNode ?? 2, out = [];
160
+ for (const s of selected) {
161
+ const outputs = s.outputs ?? [];
162
+ if (!outputs.length) continue;
163
+ const scored = defs.filter((d) => d.type !== s.type).map((def) => ({ def, m: outputs.flatMap((x) => {
164
+ const i = def.inputs?.find((y) => ConnectionRuleStore.canConnect(x, y));
165
+ return i ? [{ sourceSocketId: x.id, targetSocketId: i.id, wireType: "DEFAULT" }] : [];
166
+ }) })).filter((x) => x.m.length).sort((a, b) => b.m.length - a.m.length);
167
+ for (let si = 0; si < count; si++) for (const [i, x] of scored.slice(si * max, (si + 1) * max).entries()) out.push({ id: "ghost-" + s.id + "-" + x.def.type + "-" + si + "-" + i, nodeType: x.def.type, label: x.def.label ?? x.def.type, scenarioIndex: si, score: x.m.length * 10, sourceNodeId: s.id, socketMappings: x.m, relativeOffset: { x: 260, y: i * 140 } });
168
+ }
169
+ return out;
170
+ }
171
+ function resolveGhostLayout(cs, nodes, defs) {
172
+ const map = new Map(nodes.map((n) => [n.id, n])), dm = new Map(defs.map((d) => [d.type, d])), occ = nodes.map((n) => ({ x: n.position.x, y: n.position.y, width: n.width ?? 180, height: n.height ?? 120 }));
173
+ return cs.map((c) => {
174
+ const s = map.get(c.sourceNodeId), d = dm.get(c.nodeType), r = { x: (s?.position.x ?? 0) + (s?.width ?? 180) + 80, y: (s?.position.y ?? 0) + c.relativeOffset.y, width: 180, height: 120 };
175
+ occ.push(r);
176
+ return { id: c.id, nodeType: c.nodeType, label: c.label, position: { x: r.x, y: r.y }, size: { width: r.width, height: r.height }, scenarioIndex: c.scenarioIndex, sourceNodeId: c.sourceNodeId, socketMappings: c.socketMappings, inputs: (d?.inputs ?? []).map((h) => ({ id: h.id, label: h.label ?? h.id, type: "input", dataType: h.dataType })), outputs: (d?.outputs ?? []).map((h) => ({ id: h.id, label: h.label ?? h.id, type: "output", dataType: h.dataType })) };
177
+ });
178
+ }
179
+ function buildGhostTraces(gs, nodes) {
180
+ const m = new Map(nodes.map((n) => [n.id, n])), out = [];
181
+ for (const g of gs) {
182
+ const s = m.get(g.sourceNodeId);
183
+ if (!s) continue;
184
+ for (const x of g.socketMappings) out.push({ id: "trace-" + g.id + "-" + x.sourceSocketId, sourceNodeId: s.id, sourceSocketId: x.sourceSocketId, targetGhostNodeId: g.id, targetSocketId: x.targetSocketId, wireType: x.wireType, scenarioIndex: g.scenarioIndex, pathD: "M " + (s.position.x + (s.width ?? 180)) + "," + s.position.y + " L " + g.position.x + "," + g.position.y });
185
+ }
186
+ return out;
187
+ }
188
+ function computePredictiveGraph(nodes, connections, scenarioIndex = 0) {
189
+ const ghosts = [], traces = [], map = /* @__PURE__ */ new Map();
190
+ const connected = new Set(connections.map((c) => c.fromNodeId + ":" + c.toNodeId));
191
+ for (const p of nodes) {
192
+ const cs = nodes.filter((c) => c.id !== p.id && c.type !== p.type).slice(0, 2), pg = [];
193
+ cs.forEach((c, i) => {
194
+ const side = i % 2 === 0 ? 1 : -1, id = "ghost-" + p.id + "-" + c.id + "-" + scenarioIndex + "-" + i, w = SIGNAL_TYPES[signalType(c.type)]?.colorStr ?? SIGNAL_TYPES.DEFAULT.colorStr;
195
+ if (connected.has(p.id + ":" + c.id)) return;
196
+ const g = { id, parentNodeId: p.id, parentSocketId: "predictive-" + (side > 0 ? "output" : "input"), parentSocketPolarity: side > 0 ? "output" : "input", parentSocketSignalType: signalType(c.type), parentSocketLabel: side > 0 ? "Output" : "Input", archetypeId: c.type, category: "browser", label: c.label ?? c.name ?? c.type, description: "Predicted browser-safe graph continuation", iconName: c.type, colorHex: w, badge: "PREDICT", matchingSocketId: "predictive-" + (side > 0 ? "input" : "output"), spawnType: { type: c.type }, worldPosition: [p.position[0] + side * 5, p.position[1], p.position[2] + (i - 0.5) * 2.6], slotIndex: i, candidateIndex: i, totalCandidates: cs.length, prototypeNode: c };
197
+ pg.push(g);
198
+ ghosts.push(g);
199
+ traces.push({ id: "ptrace-" + id, ghostNodeId: id, sourceNodeId: side > 0 ? p.id : id, sourceHandleId: "predictive-output", targetNodeId: side > 0 ? id : p.id, targetHandleId: "predictive-input", wireType: signalType(c.type), isFromGhostToParent: side < 0, color: w });
200
+ });
201
+ if (pg.length) map.set(p.id, pg);
202
+ }
203
+ return { ghostNodes: ghosts, traces, selectedNodesWithGhosts: map };
204
+ }
205
+ function signalType(t) {
206
+ const v = t.toUpperCase();
207
+ return v.includes("AUDIO") ? "AUDIO" : v.includes("MIDI") ? "MIDI" : v.includes("TRIGGER") ? "TRIGGER" : "DATA";
208
+ }
209
+ var MagneticGraphManager = class {
210
+ threshold;
211
+ landmarks = [];
212
+ constructor(t = 320) {
213
+ this.threshold = t;
214
+ }
215
+ computeTraces(nodes) {
216
+ const out = [];
217
+ for (let i = 0; i < nodes.length; i++) for (let j = i + 1; j < nodes.length; j++) {
218
+ const a = nodes[i], b = nodes[j], d = Math.hypot(a.position[0] - b.position[0], a.position[2] - b.position[2]);
219
+ if (d > this.threshold) continue;
220
+ const x = getNodeSockets(a).outputs[0], y = getNodeSockets(b).inputs[0];
221
+ if (x && y) out.push({ id: "trace-" + a.id + "-" + b.id, sourceNodeId: a.id, targetNodeId: b.id, sourceHandleId: x.socketId ?? x.id, targetHandleId: y.socketId ?? y.id, wireType: x.signalType ?? x.dataType ?? "DEFAULT", spatialScore: d });
222
+ }
223
+ return out;
224
+ }
225
+ resolveAutoSolidification(nodes, traces, connections) {
226
+ return traces.filter((t) => !connections.some((c) => c.fromNodeId === t.sourceNodeId && c.toNodeId === t.targetNodeId));
227
+ }
228
+ saveLandmark(name, camera) {
229
+ const x = { id: "landmark-" + Date.now(), name, camera: { ...camera } };
230
+ this.landmarks = [...this.landmarks.filter((l) => l.name !== name), x];
231
+ return x;
232
+ }
233
+ getLandmarks() {
234
+ return [...this.landmarks];
235
+ }
236
+ };
237
+ var GraphWireParent = class {
238
+ id;
239
+ signalType;
240
+ flowSpeedMultiplier;
241
+ constructor(p) {
242
+ this.id = p.id;
243
+ this.signalType = p.signalType ?? "trigger";
244
+ this.flowSpeedMultiplier = p.flowSpeedMultiplier ?? 1;
245
+ }
246
+ calculateCubicBezier2D(p1, p2) {
247
+ const dx = Math.max(Math.abs(p2.x - p1.x) * 0.5, 45), cp1 = { x: p1.x + dx, y: p1.y + (p2.y - p1.y) * 0.25 }, cp2 = { x: p2.x - dx, y: p2.y - (p2.y - p1.y) * 0.25 };
248
+ return { pathD: "M " + p1.x + "," + p1.y + " C " + cp1.x + "," + cp1.y + " " + cp2.x + "," + cp2.y + " " + p2.x + "," + p2.y, cp1, cp2 };
249
+ }
250
+ calculatePulsePoint2D(t, p1, p2, c1, c2) {
251
+ const u = 1 - t;
252
+ return { x: u * u * u * p1.x + 3 * u * u * t * c1.x + 3 * u * t * t * c2.x + t * t * t * p2.x, y: u * u * u * p1.y + 3 * u * u * t * c1.y + 3 * u * t * t * c2.y + t * t * t * p2.y };
253
+ }
254
+ };
255
+ export {
256
+ ConnectionRuleStore,
257
+ ContainerNode,
258
+ EffectNode,
259
+ GhostStore,
260
+ GraphNodeParent,
261
+ GraphWireParent,
262
+ MagneticGraphManager,
263
+ ModuleNode,
264
+ RecorderNode,
265
+ SIGNAL_TYPES,
266
+ SpaceNode,
267
+ TriggerNode,
268
+ buildGhostTraces,
269
+ calculateSocketCoordinates,
270
+ canvasToScreen,
271
+ clampZoom,
272
+ computePredictiveGraph,
273
+ describeSvgArc,
274
+ getBeamPoints,
275
+ getCenterPanForNode,
276
+ getNodeSockets,
277
+ getNodesInSelection,
278
+ inferGhostNodes,
279
+ isNodeInCenterDeadZone,
280
+ resolveGhostLayout,
281
+ zoomAtPoint
282
+ };
@@ -17,10 +17,15 @@
17
17
  "import": "./dist/index.js",
18
18
  "types": "./dist/index.d.ts",
19
19
  "default": "./dist/index.js"
20
+ },
21
+ "./state-graph": {
22
+ "import": "./dist/state-graph.js",
23
+ "types": "./dist/state-graph.d.ts",
24
+ "default": "./dist/state-graph.js"
20
25
  }
21
26
  },
22
27
  "scripts": {
23
- "build": "tsup src/index.ts --format esm --dts --clean --external zod",
28
+ "build": "tsup src/index.ts src/state-graph.ts --format esm --dts --clean --external zod",
24
29
  "typecheck": "tsc --noEmit",
25
30
  "clean": "rm -rf dist"
26
31
  },
@@ -638,6 +638,11 @@ var LOCAL_STORAGE_OPTION = {
638
638
  provider: "local_fs",
639
639
  label: "Local Folder"
640
640
  };
641
+ var NO_STORAGE_OPTION = {
642
+ id: "",
643
+ provider: "__none__",
644
+ label: "No storage provider enabled"
645
+ };
641
646
  var PROVIDER_LABELS = {
642
647
  local_fs: "Local Folder",
643
648
  backblaze_b2: "Backblaze B2",
@@ -660,31 +665,30 @@ function buildWorkspaceCreateInput(name, description, option) {
660
665
  const connectionId = option.id && option.id !== "local_fs" ? option.id : void 0;
661
666
  const localFolderName = provider === "local_fs" ? option.localFolderName || name.trim() : void 0;
662
667
  const b2BucketName = option.b2BucketName || option.bucketName;
663
- const b2Endpoint = option.b2Endpoint || option.endpoint;
664
- const b2Region = option.b2Region || option.region;
665
668
  const storage = {
666
669
  provider,
667
670
  connectionId,
668
671
  localFolderName,
669
672
  localFolderKey: provider === "local_fs" ? option.localFolderKey : void 0,
670
673
  b2BucketName,
671
- b2Endpoint,
672
- b2Region,
673
674
  googleEmail: option.googleEmail,
674
675
  googleRootFolderId: option.googleRootFolderId,
675
676
  googleRootFolderName: option.googleRootFolderName
676
677
  };
677
- const storageConnection = !connectionId ? void 0 : provider === "google_drive" ? {
678
+ const storageConnection = !connectionId ? void 0 : {
678
679
  id: option.id,
679
680
  provider,
680
681
  label: option.label,
681
682
  name: option.name,
682
683
  role: option.role,
683
684
  enabled: option.enabled,
684
- googleEmail: option.googleEmail,
685
- googleRootFolderId: option.googleRootFolderId,
686
- googleRootFolderName: option.googleRootFolderName
687
- } : option;
685
+ ...provider === "backblaze_b2" && b2BucketName ? { b2BucketName } : {},
686
+ ...provider === "google_drive" ? {
687
+ googleEmail: option.googleEmail,
688
+ googleRootFolderId: option.googleRootFolderId,
689
+ googleRootFolderName: option.googleRootFolderName
690
+ } : {}
691
+ };
688
692
  return {
689
693
  name: name.trim(),
690
694
  description: description.trim() || void 0,
@@ -694,77 +698,13 @@ function buildWorkspaceCreateInput(name, description, option) {
694
698
  localFolderName,
695
699
  localFolderKey: storage.localFolderKey,
696
700
  b2BucketName,
697
- b2Endpoint,
698
- b2Region,
699
701
  googleEmail: option.googleEmail,
700
702
  googleRootFolderId: option.googleRootFolderId,
701
703
  googleRootFolderName: option.googleRootFolderName,
702
704
  storageConnection
703
705
  };
704
706
  }
705
- async function fetchStorageConnections(userId) {
706
- const headers = new Headers({ "Content-Type": "application/json", "X-User-Id": userId });
707
- for (const endpoint of ["/api/auth/storage/connections", "/api/storage/connections"]) {
708
- try {
709
- const response = await fetch(endpoint, { headers, credentials: "include" });
710
- if (!response.ok) continue;
711
- const data = await response.json();
712
- const connections = Array.isArray(data?.connections) ? data.connections : Array.isArray(data?.storage_connections) ? data.storage_connections : [];
713
- if (connections.length > 0) {
714
- return connections.filter((item) => item && typeof item.id === "string" && typeof item.provider === "string");
715
- }
716
- } catch {
717
- }
718
- }
719
- return [];
720
- }
721
- async function fetchBackblazeAccounts(userId) {
722
- try {
723
- const response = await fetch("/api/storage/backblaze/accounts?userId=" + encodeURIComponent(userId));
724
- const data = await response.json().catch(() => ({}));
725
- return Array.isArray(data?.accounts) ? data.accounts : [];
726
- } catch {
727
- return [];
728
- }
729
- }
730
- async function fetchBackblazeBuckets(accountId, userId) {
731
- try {
732
- const response = await fetch("/api/storage/backblaze/buckets", {
733
- method: "POST",
734
- headers: { "Content-Type": "application/json" },
735
- body: JSON.stringify({ accountId, userId })
736
- });
737
- const data = await response.json().catch(() => ({}));
738
- return Array.isArray(data?.buckets) ? data.buckets : [];
739
- } catch {
740
- return [];
741
- }
742
- }
743
- async function fetchDefaultStorageOptions(userId) {
744
- const stored = await fetchStorageConnections(userId);
745
- if (stored.length > 0) return stored;
746
- const backblaze = await fetchBackblazeAccounts(userId);
747
- return backblaze.map((account) => {
748
- const credentials = account.credentials || {};
749
- const value = (key, alternate) => {
750
- const item = credentials[key] ?? (alternate ? credentials[alternate] : void 0);
751
- return typeof item === "string" && item.length > 0 ? item : void 0;
752
- };
753
- return {
754
- id: String(account.id),
755
- provider: String(account.provider || account.serviceId || "backblaze_b2"),
756
- label: String(account.label || account.name || account.id),
757
- b2BucketName: value("bucketName", "b2BucketName"),
758
- b2Endpoint: value("endpoint", "b2Endpoint"),
759
- b2Region: value("region", "b2Region")
760
- };
761
- });
762
- }
763
- var defaultWorkspaceStorageService = {
764
- listStorageConnections: fetchDefaultStorageOptions,
765
- listBackblazeAccounts: fetchBackblazeAccounts,
766
- listBackblazeBuckets: fetchBackblazeBuckets
767
- };
707
+ var defaultWorkspaceStorageService = Object.freeze({});
768
708
  function createKloksWorkspaceStorageService(invoker, googleDrive) {
769
709
  const mapStorageConnection = (connection) => {
770
710
  if (!connection || typeof connection.id !== "string" || typeof connection.provider !== "string") return null;
@@ -775,11 +715,7 @@ function createKloksWorkspaceStorageService(invoker, googleDrive) {
775
715
  role: connection.role,
776
716
  enabled: connection.enabled,
777
717
  localFolderName: connection.localFolderName,
778
- localFolderKey: connection.localFolderKey,
779
- localFolderPathHint: connection.localFolderPathHint,
780
718
  b2BucketName: connection.b2BucketName,
781
- b2Endpoint: connection.b2Endpoint,
782
- b2Region: connection.b2Region,
783
719
  googleEmail: connection.googleEmail,
784
720
  googleRootFolderId: connection.googleRootFolderId,
785
721
  googleRootFolderName: connection.googleRootFolderName
@@ -805,7 +741,6 @@ function WorkspaceCreateDialog({
805
741
  storageOptions,
806
742
  storageService = defaultWorkspaceStorageService,
807
743
  visibility,
808
- onManageStorage,
809
744
  onClose,
810
745
  onSubmit
811
746
  }) {
@@ -868,25 +803,27 @@ function WorkspaceCreateDialog({
868
803
  }, [open, effectiveUserId, storageOptions, storageService]);
869
804
  const availableOptions = useMemo(() => {
870
805
  const supplied = storageOptions ?? loadedOptions;
871
- const providers = visibility?.availableStorageProviders;
806
+ const providerOrder = visibility?.storagePolicy?.providers ?? visibility?.availableStorageProviders ?? [];
872
807
  const hidden = new Set(visibility?.hiddenStorageProviders || []);
873
- const isVisible = (provider) => !hidden.has(provider) && (!providers || providers.includes(provider));
874
808
  const enabled = supplied.filter(
875
- (option) => option && option.enabled !== false && typeof option.id === "string" && isVisible(option.provider)
809
+ (option) => option && option.enabled !== false && typeof option.id === "string" && !hidden.has(option.provider)
876
810
  );
877
- const local = enabled.find((option) => option.provider === "local_fs");
878
- const external = enabled.filter((option) => option.provider !== "local_fs");
879
- const driveConnections = [
880
- ...external.filter((option) => option.provider === "google_drive"),
881
- ...connectedDriveOption && connectedDriveOption.enabled !== false ? [connectedDriveOption] : []
882
- ].filter((option, index, items) => items.findIndex((candidate) => candidate.id === option.id) === index);
883
- const connectDriveOption = isVisible("google_drive") && !driveConnections.some((option) => option.id === "google_drive") ? [{ id: "google_drive", provider: "google_drive", label: driveConnections.length ? "Connect another account" : "Connect Google Drive" }] : [];
884
- return [
885
- ...local ? [local] : isVisible("local_fs") ? [LOCAL_STORAGE_OPTION] : [],
886
- ...external.filter((option) => option.provider !== "google_drive"),
887
- ...driveConnections,
888
- ...connectDriveOption
889
- ];
811
+ const forProvider = (provider) => enabled.filter((option) => option.provider === provider);
812
+ return providerOrder.filter((provider, index) => providerOrder.indexOf(provider) === index && !hidden.has(provider)).flatMap((provider) => {
813
+ if (provider === "local_fs") return [forProvider(provider)[0] || LOCAL_STORAGE_OPTION];
814
+ if (provider === "google_drive") {
815
+ const connections = [
816
+ ...forProvider(provider),
817
+ ...connectedDriveOption && connectedDriveOption.enabled !== false ? [connectedDriveOption] : []
818
+ ].filter((option, index, items) => items.findIndex((candidate) => candidate.id === option.id) === index);
819
+ return connections.length > 0 ? connections : [{ id: "google_drive", provider: "google_drive", label: "Connect Google Drive" }];
820
+ }
821
+ if (provider === "backblaze_b2") {
822
+ const connections = forProvider(provider);
823
+ return connections.length > 0 ? connections : [{ id: "backblaze_external", provider: "backblaze_b2", label: "Choose Backblaze account and bucket" }];
824
+ }
825
+ return forProvider(provider);
826
+ });
890
827
  }, [storageOptions, loadedOptions, connectedDriveOption, visibility]);
891
828
  useEffect4(() => {
892
829
  if (!open || loadingStorage || defaultStorageApplied) return;
@@ -904,7 +841,7 @@ function WorkspaceCreateDialog({
904
841
  }
905
842
  }, [open, availableOptions, selectedStorageId, backblazeMode]);
906
843
  if (!open) return null;
907
- const selectedOption = availableOptions.find((option) => option.id === selectedStorageId) || availableOptions[0] || LOCAL_STORAGE_OPTION;
844
+ const selectedOption = availableOptions.find((option) => option.id === selectedStorageId) || availableOptions[0] || NO_STORAGE_OPTION;
908
845
  const googleDriveConnection = selectedOption.provider === "google_drive" && selectedOption.id !== "google_drive" ? selectedOption : void 0;
909
846
  const hiddenFields = new Set(visibility?.hiddenFields || []);
910
847
  const userName = currentUser?.username || currentUser?.name || currentUser?.email?.split("@")[0] || "user";
@@ -973,11 +910,7 @@ function WorkspaceCreateDialog({
973
910
  provider: "backblaze_b2",
974
911
  label: backblazeAccount?.name || "Backblaze B2",
975
912
  b2BucketName: backblazeBucketName,
976
- bucketName: backblazeBucketName,
977
- b2Endpoint: backblazeAccount?.credentials?.endpoint,
978
- endpoint: backblazeAccount?.credentials?.endpoint,
979
- b2Region: backblazeAccount?.credentials?.region,
980
- region: backblazeAccount?.credentials?.region
913
+ bucketName: backblazeBucketName
981
914
  } : selectedOption.provider === "local_fs" ? { ...selectedOption, localFolderName: localFolderName.trim() || selectedOption.localFolderName || name.trim() } : selectedOption.provider === "google_drive" && googleDriveFolder ? {
982
915
  ...selectedOption,
983
916
  googleRootFolderId: googleDriveFolder.id,
@@ -1046,37 +979,27 @@ function WorkspaceCreateDialog({
1046
979
  ] }),
1047
980
  /* @__PURE__ */ jsxs7("div", { className: "space-y-1", children: [
1048
981
  /* @__PURE__ */ jsx7("label", { htmlFor: "floks-workspace-storage", className: "block text-[10px] font-black uppercase", children: "Persistent Storage" }),
1049
- /* @__PURE__ */ jsxs7("div", { className: "flex gap-2", children: [
1050
- /* @__PURE__ */ jsx7(
1051
- "select",
1052
- {
1053
- id: "floks-workspace-storage",
1054
- "aria-label": "Workspace storage",
1055
- value: selectedStorageId,
1056
- onChange: (event) => {
1057
- setBackblazeMode(false);
1058
- setSelectedStorageId(event.target.value);
1059
- },
1060
- disabled: loadingStorage || submitting,
1061
- className: "h-10 min-w-0 flex-1 border px-2 text-xs",
1062
- style: { backgroundColor: background, borderColor: border },
1063
- children: availableOptions.map((option) => /* @__PURE__ */ jsx7("option", { value: option.id, children: providerLabel(option) + " \u2014 " + (option.label || option.name || option.id) }, option.id))
1064
- }
1065
- ),
1066
- !hiddenFields.has("backblaze") && /* @__PURE__ */ jsx7(
1067
- "button",
1068
- {
1069
- type: "button",
1070
- onClick: handleSelectBackblaze,
1071
- disabled: submitting || loadingBackblazeAccounts,
1072
- "aria-pressed": backblazeMode,
1073
- className: "shrink-0 border px-3 text-[10px] font-black uppercase disabled:opacity-50",
1074
- style: { borderColor: backblazeMode ? accent : border, color: backblazeMode ? accent : void 0 },
1075
- children: "Backblaze B2"
1076
- }
1077
- ),
1078
- !hiddenFields.has("manageStorage") && onManageStorage && /* @__PURE__ */ jsx7("button", { type: "button", onClick: onManageStorage, className: "shrink-0 border px-3 text-[10px] font-black uppercase", style: { borderColor: border }, children: "Manage" })
1079
- ] }),
982
+ /* @__PURE__ */ jsx7("div", { className: "flex gap-2", children: /* @__PURE__ */ jsx7(
983
+ "select",
984
+ {
985
+ id: "floks-workspace-storage",
986
+ "aria-label": "Workspace storage",
987
+ value: selectedStorageId,
988
+ onChange: (event) => {
989
+ const nextId = event.target.value;
990
+ if (nextId === "backblaze_external") {
991
+ void handleSelectBackblaze();
992
+ return;
993
+ }
994
+ setBackblazeMode(false);
995
+ setSelectedStorageId(nextId);
996
+ },
997
+ disabled: loadingStorage || submitting,
998
+ className: "h-10 min-w-0 flex-1 border px-2 text-xs",
999
+ style: { backgroundColor: background, borderColor: border },
1000
+ children: availableOptions.map((option) => /* @__PURE__ */ jsx7("option", { value: option.id, children: providerLabel(option) + " \u2014 " + (option.label || option.name || option.id) }, option.id))
1001
+ }
1002
+ ) }),
1080
1003
  !hiddenFields.has("backblaze") && backblazeMode && /* @__PURE__ */ jsxs7("div", { className: "mt-3 space-y-2 border-t pt-3", style: { borderColor: border }, children: [
1081
1004
  /* @__PURE__ */ jsxs7("label", { className: "block space-y-1", children: [
1082
1005
  /* @__PURE__ */ jsx7("span", { className: "text-[10px] font-black uppercase", children: "Backblaze account" }),
@@ -1123,7 +1046,7 @@ function WorkspaceCreateDialog({
1123
1046
  loadingStorage ? /* @__PURE__ */ jsxs7("p", { className: "flex items-center gap-2 text-[10px]", style: { color: muted }, children: [
1124
1047
  /* @__PURE__ */ jsx7(Loader2, { size: 12, className: "animate-spin" }),
1125
1048
  " Loading storage connections\u2026"
1126
- ] }) : availableOptions.length === 1 && availableOptions[0].provider === "local_fs" ? /* @__PURE__ */ jsx7("p", { className: "text-[10px]", style: { color: muted }, children: "No external storage connection is available yet. Connect an external provider or choose an available connection." }) : /* @__PURE__ */ jsx7("p", { className: "text-[10px]", style: { color: muted }, children: "Cloud storage is selected from connections already authorized for this account." })
1049
+ ] }) : availableOptions.length === 0 ? /* @__PURE__ */ jsx7("p", { className: "text-[10px]", style: { color: muted }, children: "This application has not enabled a workspace storage provider." }) : /* @__PURE__ */ jsx7("p", { className: "text-[10px]", style: { color: muted }, children: "Choose from the storage providers explicitly enabled by this application." })
1127
1050
  ] }),
1128
1051
  selectedOption.provider === "google_drive" && /* @__PURE__ */ jsx7(
1129
1052
  GoogleDriveWorkspacePicker,
@@ -1170,7 +1093,7 @@ function WorkspaceCreateDialog({
1170
1093
  ] }),
1171
1094
  /* @__PURE__ */ jsxs7("div", { className: "mt-5 flex justify-end gap-2 border-t pt-3", style: { borderColor: border }, children: [
1172
1095
  /* @__PURE__ */ jsx7("button", { type: "button", onClick: onClose, disabled: submitting, className: "h-9 border px-3 text-xs", style: { borderColor: border }, children: "Cancel" }),
1173
- /* @__PURE__ */ jsx7("button", { type: "submit", disabled: submitting || loadingStorage || loadingBackblazeAccounts || loadingBackblazeBuckets || !name.trim(), className: "h-9 px-4 text-xs font-black uppercase text-black disabled:opacity-50", style: { backgroundColor: accent }, children: submitting ? "Creating\u2026" : "Create Workspace" })
1096
+ /* @__PURE__ */ jsx7("button", { type: "submit", disabled: submitting || loadingStorage || loadingBackblazeAccounts || loadingBackblazeBuckets || !availableOptions.length || !name.trim(), className: "h-9 px-4 text-xs font-black uppercase text-black disabled:opacity-50", style: { backgroundColor: accent }, children: submitting ? "Creating\u2026" : "Create Workspace" })
1174
1097
  ] })
1175
1098
  ]
1176
1099
  }
@@ -1197,7 +1120,7 @@ function WorkspaceTilesMenu({
1197
1120
  userId,
1198
1121
  currentUser,
1199
1122
  storageOptions,
1200
- onManageStorage,
1123
+ visibility,
1201
1124
  activeWorkspaceId = null,
1202
1125
  appName = "Workspaces",
1203
1126
  storageService = defaultWorkspaceStorageService,
@@ -1257,7 +1180,7 @@ function WorkspaceTilesMenu({
1257
1180
  ] })
1258
1181
  }
1259
1182
  ),
1260
- /* @__PURE__ */ jsx8(WorkspaceCreateDialog, { open: creating, userId: effectiveUserId, currentUser, appName, storageOptions, storageService, onManageStorage, onClose: () => setCreating(false), onSubmit: onCreateWorkspace })
1183
+ /* @__PURE__ */ jsx8(WorkspaceCreateDialog, { open: creating, userId: effectiveUserId, currentUser, appName, storageOptions, storageService, visibility, onClose: () => setCreating(false), onSubmit: onCreateWorkspace })
1261
1184
  ] });
1262
1185
  }
1263
1186
 
@@ -280,13 +280,13 @@ import { useCallback, useEffect as useEffect2, useMemo as useMemo2, useRef, useS
280
280
  import {
281
281
  resolveClientOrigin,
282
282
  resolveClientEnvironment
283
- } from "@ultrst-armada/kloks/auth";
283
+ } from "@dinilmusick/gutts/auth";
284
284
  import {
285
285
  DEFAULT_LUTH_URL,
286
286
  LuthAuthClient,
287
287
  createLuthAuthClient
288
- } from "@ultrst-armada/kloks/auth";
289
- import { LuthAuthError } from "@ultrst-armada/kloks/auth";
288
+ } from "@dinilmusick/gutts/auth";
289
+ import { LuthAuthError } from "@dinilmusick/gutts/auth";
290
290
  var resolveLuthOrigin = resolveClientOrigin;
291
291
  var resolveLuthEnvironment = resolveClientEnvironment;
292
292
 
@@ -1,6 +1,6 @@
1
- import { resolveClientOrigin, resolveClientEnvironment } from '@ultrst-armada/kloks/auth';
2
- export { DEFAULT_LUTH_URL, LuthAuthClient, createLuthAuthClient, } from '@ultrst-armada/kloks/auth';
3
- export type { DeploymentEnvironment, EmailSignInCredentials, EmailSignUpData, GoogleSignInOptions, LuthAuthClientConfig, LuthAuthTokenStore, LuthSession, LuthUser, LuthSessionResult, RegisterApplicationResult, } from '@ultrst-armada/kloks/auth';
4
- export { LuthAuthError } from '@ultrst-armada/kloks/auth';
1
+ import { resolveClientOrigin, resolveClientEnvironment } from '@dinilmusick/gutts/auth';
2
+ export { DEFAULT_LUTH_URL, LuthAuthClient, createLuthAuthClient, } from '@dinilmusick/gutts/auth';
3
+ export type { DeploymentEnvironment, EmailSignInCredentials, EmailSignUpData, GoogleSignInOptions, LuthAuthClientConfig, LuthAuthTokenStore, LuthSession, LuthUser, LuthSessionResult, RegisterApplicationResult, } from '@dinilmusick/gutts/auth';
4
+ export { LuthAuthError } from '@dinilmusick/gutts/auth';
5
5
  export declare const resolveLuthOrigin: typeof resolveClientOrigin;
6
6
  export declare const resolveLuthEnvironment: typeof resolveClientEnvironment;
@@ -16,7 +16,7 @@ import {
16
16
  resolveLuthEnvironment,
17
17
  resolveLuthOrigin,
18
18
  useLuthAuth
19
- } from "../../chunk-3YYPBZS2.js";
19
+ } from "../../chunk-W6ENIFEW.js";
20
20
  import "../../chunk-5QDNIDDN.js";
21
21
  import "../../chunk-5ZMXFCD4.js";
22
22
  import "../../chunk-C3L53YN4.js";
@@ -1,2 +1,2 @@
1
- export type { DeploymentEnvironment, LuthAuthClientConfig, LuthAuthTokenStore, RegisterApplicationResult, LuthUser, LuthSession, LuthSessionResult, EmailSignInCredentials, EmailSignUpData, GoogleSignInOptions, } from '@ultrst-armada/kloks/auth';
2
- export { LuthAuthError } from '@ultrst-armada/kloks/auth';
1
+ export type { DeploymentEnvironment, LuthAuthClientConfig, LuthAuthTokenStore, RegisterApplicationResult, LuthUser, LuthSession, LuthSessionResult, EmailSignInCredentials, EmailSignUpData, GoogleSignInOptions, } from '@dinilmusick/gutts/auth';
2
+ export { LuthAuthError } from '@dinilmusick/gutts/auth';