@dxos/react-ui-canvas-compute 0.13.0 → 0.14.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.
Files changed (244) hide show
  1. package/dist/lib/chunk-types.mjs +142 -0
  2. package/dist/lib/chunk-types.mjs.map +1 -0
  3. package/dist/lib/index.mjs +526 -430
  4. package/dist/lib/index.mjs.map +1 -1
  5. package/dist/lib/types.mjs +2 -0
  6. package/dist/types/src/graph/controller.d.ts +1 -1
  7. package/dist/types/src/graph/controller.d.ts.map +1 -1
  8. package/dist/types/src/hooks/compute-context.d.ts +5 -4
  9. package/dist/types/src/hooks/compute-context.d.ts.map +1 -1
  10. package/dist/types/src/hooks/index.d.ts +0 -1
  11. package/dist/types/src/hooks/index.d.ts.map +1 -1
  12. package/dist/types/src/hooks/useGraphMonitor.d.ts +18 -1
  13. package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
  14. package/dist/types/src/index.d.ts +1 -1
  15. package/dist/types/src/index.d.ts.map +1 -1
  16. package/dist/types/src/registry.d.ts +5 -8
  17. package/dist/types/src/registry.d.ts.map +1 -1
  18. package/dist/types/src/scene/compute.stories.d.ts.map +1 -1
  19. package/dist/types/src/scene/echo-store.d.ts +1 -1
  20. package/dist/types/src/scene/echo-store.d.ts.map +1 -1
  21. package/dist/types/src/scene/index.d.ts +0 -3
  22. package/dist/types/src/scene/index.d.ts.map +1 -1
  23. package/dist/types/src/scene/projection.d.ts.map +1 -1
  24. package/dist/types/src/scene/scene.d.ts +2 -2
  25. package/dist/types/src/scene/scene.d.ts.map +1 -1
  26. package/dist/types/src/shapes/Append.d.ts +2 -2
  27. package/dist/types/src/shapes/Append.d.ts.map +1 -1
  28. package/dist/types/src/shapes/Array.d.ts +3 -3
  29. package/dist/types/src/shapes/Array.d.ts.map +1 -1
  30. package/dist/types/src/shapes/Audio.d.ts +2 -2
  31. package/dist/types/src/shapes/Audio.d.ts.map +1 -1
  32. package/dist/types/src/shapes/Beacon.d.ts +2 -2
  33. package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
  34. package/dist/types/src/shapes/Boolean.d.ts +4 -52
  35. package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
  36. package/dist/types/src/shapes/Chat.d.ts +3 -3
  37. package/dist/types/src/shapes/Chat.d.ts.map +1 -1
  38. package/dist/types/src/shapes/Constant.d.ts +3 -4
  39. package/dist/types/src/shapes/Constant.d.ts.map +1 -1
  40. package/dist/types/src/shapes/Database.d.ts +2 -2
  41. package/dist/types/src/shapes/Database.d.ts.map +1 -1
  42. package/dist/types/src/shapes/Feed.d.ts +2 -2
  43. package/dist/types/src/shapes/Feed.d.ts.map +1 -1
  44. package/dist/types/src/shapes/Function.d.ts +3 -5
  45. package/dist/types/src/shapes/Function.d.ts.map +1 -1
  46. package/dist/types/src/shapes/Gpt.d.ts +2 -2
  47. package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
  48. package/dist/types/src/shapes/GptRealtime.d.ts +2 -2
  49. package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
  50. package/dist/types/src/shapes/Json.d.ts +5 -5
  51. package/dist/types/src/shapes/Json.d.ts.map +1 -1
  52. package/dist/types/src/shapes/Logic.d.ts +5 -5
  53. package/dist/types/src/shapes/Logic.d.ts.map +1 -1
  54. package/dist/types/src/shapes/RNG.d.ts +2 -2
  55. package/dist/types/src/shapes/RNG.d.ts.map +1 -1
  56. package/dist/types/src/shapes/Scope.d.ts +2 -2
  57. package/dist/types/src/shapes/Scope.d.ts.map +1 -1
  58. package/dist/types/src/shapes/Surface.d.ts +2 -2
  59. package/dist/types/src/shapes/Surface.d.ts.map +1 -1
  60. package/dist/types/src/shapes/Switch.d.ts +2 -2
  61. package/dist/types/src/shapes/Switch.d.ts.map +1 -1
  62. package/dist/types/src/shapes/Table.d.ts +2 -2
  63. package/dist/types/src/shapes/Table.d.ts.map +1 -1
  64. package/dist/types/src/shapes/Template.d.ts +2 -2
  65. package/dist/types/src/shapes/Template.d.ts.map +1 -1
  66. package/dist/types/src/shapes/Text.d.ts +2 -2
  67. package/dist/types/src/shapes/Text.d.ts.map +1 -1
  68. package/dist/types/src/shapes/TextToImage.d.ts +2 -2
  69. package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
  70. package/dist/types/src/shapes/Thread.d.ts +2 -2
  71. package/dist/types/src/shapes/Thread.d.ts.map +1 -1
  72. package/dist/types/src/shapes/Trigger.d.ts +3 -3
  73. package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
  74. package/dist/types/src/shapes/append-def.d.ts +1 -2
  75. package/dist/types/src/shapes/append-def.d.ts.map +1 -1
  76. package/dist/types/src/shapes/array-def.d.ts +2 -3
  77. package/dist/types/src/shapes/array-def.d.ts.map +1 -1
  78. package/dist/types/src/shapes/audio-def.d.ts +1 -2
  79. package/dist/types/src/shapes/audio-def.d.ts.map +1 -1
  80. package/dist/types/src/shapes/beacon-def.d.ts +1 -2
  81. package/dist/types/src/shapes/beacon-def.d.ts.map +1 -1
  82. package/dist/types/src/shapes/chat-def.d.ts +1 -2
  83. package/dist/types/src/shapes/chat-def.d.ts.map +1 -1
  84. package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
  85. package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
  86. package/dist/types/src/shapes/common/TextBox.d.ts +26 -0
  87. package/dist/types/src/shapes/common/TextBox.d.ts.map +1 -0
  88. package/dist/types/src/shapes/common/index.d.ts +3 -1
  89. package/dist/types/src/shapes/common/index.d.ts.map +1 -1
  90. package/dist/types/src/shapes/common/node-def.d.ts +24 -0
  91. package/dist/types/src/shapes/common/node-def.d.ts.map +1 -0
  92. package/dist/types/src/shapes/common/ports.d.ts +33 -0
  93. package/dist/types/src/shapes/common/ports.d.ts.map +1 -0
  94. package/dist/types/src/shapes/constant-def.d.ts +1 -2
  95. package/dist/types/src/shapes/constant-def.d.ts.map +1 -1
  96. package/dist/types/src/shapes/database-def.d.ts +1 -2
  97. package/dist/types/src/shapes/database-def.d.ts.map +1 -1
  98. package/dist/types/src/shapes/defs.d.ts +7 -2
  99. package/dist/types/src/shapes/defs.d.ts.map +1 -1
  100. package/dist/types/src/shapes/feed-def.d.ts +1 -2
  101. package/dist/types/src/shapes/feed-def.d.ts.map +1 -1
  102. package/dist/types/src/shapes/function-def.d.ts +1 -2
  103. package/dist/types/src/shapes/function-def.d.ts.map +1 -1
  104. package/dist/types/src/shapes/gpt-def.d.ts +1 -2
  105. package/dist/types/src/shapes/gpt-def.d.ts.map +1 -1
  106. package/dist/types/src/shapes/gpt-realtime-def.d.ts +1 -2
  107. package/dist/types/src/shapes/gpt-realtime-def.d.ts.map +1 -1
  108. package/dist/types/src/shapes/json-def.d.ts +2 -3
  109. package/dist/types/src/shapes/json-def.d.ts.map +1 -1
  110. package/dist/types/src/shapes/logic-def.d.ts +2 -3
  111. package/dist/types/src/shapes/logic-def.d.ts.map +1 -1
  112. package/dist/types/src/shapes/ports.test.d.ts +2 -0
  113. package/dist/types/src/shapes/ports.test.d.ts.map +1 -0
  114. package/dist/types/src/shapes/rng-def.d.ts +1 -2
  115. package/dist/types/src/shapes/rng-def.d.ts.map +1 -1
  116. package/dist/types/src/shapes/scope-def.d.ts +1 -2
  117. package/dist/types/src/shapes/scope-def.d.ts.map +1 -1
  118. package/dist/types/src/shapes/surface-def.d.ts +1 -2
  119. package/dist/types/src/shapes/surface-def.d.ts.map +1 -1
  120. package/dist/types/src/shapes/switch-def.d.ts +1 -2
  121. package/dist/types/src/shapes/switch-def.d.ts.map +1 -1
  122. package/dist/types/src/shapes/table-def.d.ts +1 -2
  123. package/dist/types/src/shapes/table-def.d.ts.map +1 -1
  124. package/dist/types/src/shapes/template-def.d.ts +1 -2
  125. package/dist/types/src/shapes/template-def.d.ts.map +1 -1
  126. package/dist/types/src/shapes/text-def.d.ts +1 -2
  127. package/dist/types/src/shapes/text-def.d.ts.map +1 -1
  128. package/dist/types/src/shapes/text-to-image-def.d.ts +1 -2
  129. package/dist/types/src/shapes/text-to-image-def.d.ts.map +1 -1
  130. package/dist/types/src/shapes/thread-def.d.ts +1 -2
  131. package/dist/types/src/shapes/thread-def.d.ts.map +1 -1
  132. package/dist/types/src/shapes/trigger-def.d.ts +1 -2
  133. package/dist/types/src/shapes/trigger-def.d.ts.map +1 -1
  134. package/dist/types/src/testing/circuits.d.ts +1 -1
  135. package/dist/types/src/testing/circuits.d.ts.map +1 -1
  136. package/dist/types/src/types/canvas-board.test.d.ts +2 -0
  137. package/dist/types/src/types/canvas-board.test.d.ts.map +1 -0
  138. package/dist/types/src/types/index.d.ts +4 -0
  139. package/dist/types/src/types/index.d.ts.map +1 -0
  140. package/dist/types/src/types/model.d.ts +10 -0
  141. package/dist/types/src/types/model.d.ts.map +1 -0
  142. package/dist/types/src/types/schema.d.ts +66 -0
  143. package/dist/types/src/types/schema.d.ts.map +1 -0
  144. package/dist/types/src/types/shapes.d.ts +114 -0
  145. package/dist/types/src/types/shapes.d.ts.map +1 -0
  146. package/dist/types/tsconfig.tsbuildinfo +1 -1
  147. package/package.json +43 -35
  148. package/src/graph/controller.ts +1 -1
  149. package/src/hooks/compute-context.ts +7 -4
  150. package/src/hooks/index.ts +0 -1
  151. package/src/hooks/useGraphMonitor.ts +10 -1
  152. package/src/index.ts +1 -1
  153. package/src/playwright/scene.spec.ts +3 -3
  154. package/src/registry.ts +63 -91
  155. package/src/scene/compute.stories.tsx +3 -6
  156. package/src/scene/echo-store.test.ts +18 -7
  157. package/src/scene/echo-store.ts +7 -10
  158. package/src/scene/index.ts +0 -3
  159. package/src/scene/projection.ts +2 -3
  160. package/src/scene/scene.test.ts +4 -4
  161. package/src/scene/scene.ts +6 -4
  162. package/src/schema.test.ts +7 -36
  163. package/src/shapes/Append.tsx +2 -3
  164. package/src/shapes/Array.tsx +3 -4
  165. package/src/shapes/Audio.tsx +2 -2
  166. package/src/shapes/Beacon.tsx +2 -2
  167. package/src/shapes/Boolean.tsx +32 -29
  168. package/src/shapes/Chat.tsx +5 -10
  169. package/src/shapes/Constant.tsx +19 -12
  170. package/src/shapes/Database.tsx +2 -4
  171. package/src/shapes/Feed.tsx +2 -3
  172. package/src/shapes/Function.tsx +4 -10
  173. package/src/shapes/Gpt.tsx +2 -3
  174. package/src/shapes/GptRealtime.tsx +2 -2
  175. package/src/shapes/Json.tsx +5 -6
  176. package/src/shapes/Logic.tsx +5 -6
  177. package/src/shapes/RNG.tsx +2 -2
  178. package/src/shapes/Scope.tsx +2 -2
  179. package/src/shapes/Surface.tsx +9 -6
  180. package/src/shapes/Switch.tsx +10 -12
  181. package/src/shapes/Table.tsx +2 -4
  182. package/src/shapes/Template.tsx +10 -9
  183. package/src/shapes/Text.tsx +2 -3
  184. package/src/shapes/TextToImage.tsx +2 -4
  185. package/src/shapes/Thread.tsx +2 -3
  186. package/src/shapes/Trigger.tsx +3 -4
  187. package/src/shapes/append-def.ts +8 -7
  188. package/src/shapes/array-def.ts +8 -8
  189. package/src/shapes/audio-def.ts +8 -7
  190. package/src/shapes/beacon-def.ts +9 -8
  191. package/src/shapes/chat-def.tsx +8 -8
  192. package/src/shapes/common/Box.tsx +7 -4
  193. package/src/shapes/common/FunctionBody.tsx +13 -26
  194. package/src/shapes/common/TextBox.tsx +137 -0
  195. package/src/shapes/common/index.ts +3 -1
  196. package/src/shapes/common/node-def.tsx +117 -0
  197. package/src/shapes/common/ports.ts +107 -0
  198. package/src/shapes/constant-def.tsx +8 -8
  199. package/src/shapes/database-def.ts +8 -8
  200. package/src/shapes/defs.ts +21 -6
  201. package/src/shapes/feed-def.ts +8 -7
  202. package/src/shapes/function-def.ts +8 -7
  203. package/src/shapes/gpt-def.ts +8 -7
  204. package/src/shapes/gpt-realtime-def.ts +10 -10
  205. package/src/shapes/json-def.ts +15 -13
  206. package/src/shapes/logic-def.ts +14 -11
  207. package/src/shapes/ports.test.ts +23 -0
  208. package/src/shapes/rng-def.ts +8 -7
  209. package/src/shapes/scope-def.ts +8 -7
  210. package/src/shapes/surface-def.ts +8 -8
  211. package/src/shapes/switch-def.ts +8 -7
  212. package/src/shapes/table-def.ts +7 -7
  213. package/src/shapes/template-def.ts +8 -7
  214. package/src/shapes/text-def.ts +8 -8
  215. package/src/shapes/text-to-image-def.ts +8 -8
  216. package/src/shapes/thread-def.ts +8 -7
  217. package/src/shapes/trigger-def.ts +11 -8
  218. package/src/testing/circuits.ts +21 -7
  219. package/src/types/canvas-board.test.ts +84 -0
  220. package/src/types/index.ts +7 -0
  221. package/src/types/model.ts +63 -0
  222. package/src/types/schema.ts +73 -0
  223. package/src/types/shapes.ts +73 -0
  224. package/dist/types/src/compute-layout.d.ts +0 -9
  225. package/dist/types/src/compute-layout.d.ts.map +0 -1
  226. package/dist/types/src/compute.stories.d.ts +0 -58
  227. package/dist/types/src/compute.stories.d.ts.map +0 -1
  228. package/dist/types/src/hooks/useComputeGraphController.d.ts +0 -10
  229. package/dist/types/src/hooks/useComputeGraphController.d.ts.map +0 -1
  230. package/dist/types/src/scene/NodeView.d.ts +0 -11
  231. package/dist/types/src/scene/NodeView.d.ts.map +0 -1
  232. package/dist/types/src/scene/defs.d.ts +0 -5
  233. package/dist/types/src/scene/defs.d.ts.map +0 -1
  234. package/dist/types/src/scene/ports.d.ts +0 -5
  235. package/dist/types/src/scene/ports.d.ts.map +0 -1
  236. package/dist/types/src/shapes/common/function-anchors.d.ts +0 -12
  237. package/dist/types/src/shapes/common/function-anchors.d.ts.map +0 -1
  238. package/src/compute-layout.ts +0 -37
  239. package/src/compute.stories.tsx +0 -302
  240. package/src/hooks/useComputeGraphController.ts +0 -65
  241. package/src/scene/NodeView.tsx +0 -42
  242. package/src/scene/defs.ts +0 -158
  243. package/src/scene/ports.ts +0 -30
  244. package/src/shapes/common/function-anchors.ts +0 -44
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-canvas-compute",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "A compute graph extension for the canvas editor component.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -17,6 +17,11 @@
17
17
  "source": "./src/index.ts",
18
18
  "types": "./dist/types/src/index.d.ts",
19
19
  "import": "./dist/lib/index.mjs"
20
+ },
21
+ "./types": {
22
+ "source": "./src/types/index.ts",
23
+ "types": "./dist/types/src/types/index.d.ts",
24
+ "import": "./dist/lib/types.mjs"
20
25
  }
21
26
  },
22
27
  "types": "dist/types/src/index.d.ts",
@@ -25,29 +30,33 @@
25
30
  "src"
26
31
  ],
27
32
  "dependencies": {
28
- "@dxos/ai": "0.13.0",
29
- "@dxos/app-framework": "0.13.0",
30
- "@dxos/app-toolkit": "0.13.0",
31
- "@dxos/async": "0.13.0",
32
- "@dxos/compute": "0.13.0",
33
- "@dxos/conductor": "0.13.0",
34
- "@dxos/context": "0.13.0",
35
- "@dxos/debug": "0.13.0",
36
- "@dxos/echo": "0.13.0",
37
- "@dxos/echo-react": "0.13.0",
38
- "@dxos/effect": "0.13.0",
39
- "@dxos/graph": "0.13.0",
40
- "@dxos/invariant": "0.13.0",
41
- "@dxos/keys": "0.13.0",
42
- "@dxos/log": "0.13.0",
43
- "@dxos/react-client": "0.13.0",
44
- "@dxos/react-ui-audio": "0.13.0",
45
- "@dxos/react-ui-canvas": "0.13.0",
46
- "@dxos/react-ui-canvas-editor": "0.13.0",
47
- "@dxos/react-ui-experimental": "0.13.0",
48
- "@dxos/react-ui-syntax-highlighter": "0.13.0",
49
- "@dxos/types": "0.13.0",
50
- "@dxos/util": "0.13.0"
33
+ "@codemirror/lang-json": "^6.0.2",
34
+ "@codemirror/state": "^6.7.6",
35
+ "@codemirror/view": "^6.43.13",
36
+ "@dxos/ai": "0.14.0",
37
+ "@dxos/app-framework": "0.14.0",
38
+ "@dxos/app-toolkit": "0.14.0",
39
+ "@dxos/async": "0.14.0",
40
+ "@dxos/compute": "0.14.0",
41
+ "@dxos/conductor": "0.14.0",
42
+ "@dxos/context": "0.14.0",
43
+ "@dxos/debug": "0.14.0",
44
+ "@dxos/echo": "0.14.0",
45
+ "@dxos/echo-react": "0.14.0",
46
+ "@dxos/effect": "0.14.0",
47
+ "@dxos/graph": "0.14.0",
48
+ "@dxos/invariant": "0.14.0",
49
+ "@dxos/keys": "0.14.0",
50
+ "@dxos/log": "0.14.0",
51
+ "@dxos/react-client": "0.14.0",
52
+ "@dxos/react-ui-audio": "0.14.0",
53
+ "@dxos/react-ui-canvas": "0.14.0",
54
+ "@dxos/react-ui-editor": "0.14.0",
55
+ "@dxos/react-ui-experimental": "0.14.0",
56
+ "@dxos/react-ui-syntax-highlighter": "0.14.0",
57
+ "@dxos/types": "0.14.0",
58
+ "@dxos/ui-editor": "0.14.0",
59
+ "@dxos/util": "0.14.0"
51
60
  },
52
61
  "devDependencies": {
53
62
  "@effect/atom-react": "4.0.0",
@@ -59,22 +68,21 @@
59
68
  "react": "~19.2.7",
60
69
  "react-dom": "~19.2.7",
61
70
  "vite": "^8.2.2",
62
- "@dxos/app-framework": "0.13.0",
63
- "@dxos/assistant": "0.13.0",
64
- "@dxos/assistant-toolkit": "0.13.0",
65
- "@dxos/compute-runtime": "0.13.0",
66
- "@dxos/react-ui": "0.13.0",
67
- "@dxos/react-ui-attention": "0.13.0",
68
- "@dxos/react-ui-form": "0.13.0",
69
- "@dxos/test-utils": "0.13.0",
70
- "@dxos/ui-theme": "0.13.0"
71
+ "@dxos/app-framework": "0.14.0",
72
+ "@dxos/assistant": "0.14.0",
73
+ "@dxos/assistant-toolkit": "0.14.0",
74
+ "@dxos/compute-runtime": "0.14.0",
75
+ "@dxos/react-ui": "0.14.0",
76
+ "@dxos/react-ui-attention": "0.14.0",
77
+ "@dxos/test-utils": "0.14.0",
78
+ "@dxos/ui-theme": "0.14.0"
71
79
  },
72
80
  "peerDependencies": {
73
81
  "effect": "4.0.0",
74
82
  "react": "~19.2.7",
75
83
  "react-dom": "~19.2.7",
76
- "@dxos/react-ui": "^0.13.0",
77
- "@dxos/ui-theme": "^0.13.0"
84
+ "@dxos/react-ui": "^0.14.0",
85
+ "@dxos/ui-theme": "^0.14.0"
78
86
  },
79
87
  "publishConfig": {
80
88
  "access": "public"
@@ -35,11 +35,11 @@ import { Resource } from '@dxos/context';
35
35
  import type { Database, Registry } from '@dxos/echo';
36
36
  import * as EffectEx from '@dxos/effect/EffectEx';
37
37
  import { log } from '@dxos/log';
38
- import { type CanvasGraphModel } from '@dxos/react-ui-canvas-editor';
39
38
  import { type ContentBlock } from '@dxos/types';
40
39
 
41
40
  import { createComputeGraph } from '../hooks/index.ts';
42
41
  import { type ComputeShape } from '../shapes/index.ts';
42
+ import { type CanvasGraphModel } from '../types/index.ts';
43
43
  import { resolveComputeNode } from './node-defs.ts';
44
44
 
45
45
  // TODO(burdon): API package for conductor.
@@ -5,16 +5,14 @@
5
5
  import { createContext, useContext } from 'react';
6
6
 
7
7
  import { raise } from '@dxos/debug';
8
- import { type ShapeRegistry } from '@dxos/react-ui-canvas-editor';
8
+ import { type NodeDef } from '@dxos/react-ui-canvas/scene';
9
9
 
10
10
  import type { ComputeGraphController } from '../graph/index.ts';
11
11
 
12
12
  export type ComputeContextType = {
13
13
  controller: ComputeGraphController;
14
- /** Shape definitions for the frame chrome (icon, name, openable); the editor's own registry is the fallback. */
15
- registry?: ShapeRegistry;
16
14
  debug?: boolean;
17
- /** Grows or shrinks a shape by `delta` px (a function body opening); absent, the frame's element is resized. */
15
+ /** Grows or shrinks a shape by `delta` px (a function body opening); absent, the body opens in place. */
18
16
  resize?: (id: string, delta: number) => void;
19
17
  };
20
18
 
@@ -23,3 +21,8 @@ export const ComputeContext = createContext<ComputeContextType | null>(null);
23
21
  export const useComputeContext = () => {
24
22
  return useContext(ComputeContext) ?? raise(new Error('Missing ComputeContext'));
25
23
  };
24
+
25
+ /** The definition of the node being rendered, from the registry the scene renders with, for the frame chrome. */
26
+ export const ComputeNodeDefContext = createContext<NodeDef | undefined>(undefined);
27
+
28
+ export const useComputeNodeDef = () => useContext(ComputeNodeDefContext);
@@ -3,7 +3,6 @@
3
3
  //
4
4
 
5
5
  export * from './compute-context.ts';
6
- export * from './useComputeGraphController.ts';
7
6
  export * from './useComputeNodeState.ts';
8
7
  export * from './useGraphMonitor.ts';
9
8
  export * from './useControllerUpdates.ts';
@@ -6,10 +6,19 @@ import { useMemo } from 'react';
6
6
 
7
7
  import { type ComputeEdge, ComputeGraphModel, DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';
8
8
  import { invariant } from '@dxos/invariant';
9
- import { type CanvasBoard, type CanvasGraphModel, type GraphMonitor } from '@dxos/react-ui-canvas-editor';
10
9
 
11
10
  import { deleteTriggerObjects, syncCreate, syncDelete, syncLink } from '../graph/index.ts';
12
11
  import { type ComputeShape } from '../shapes/index.ts';
12
+ import { type CanvasBoard, type CanvasGraphModel } from '../types/index.ts';
13
+
14
+ /**
15
+ * Model callback.
16
+ */
17
+ export interface GraphMonitor<S extends CanvasBoard.Shape = CanvasBoard.Shape> {
18
+ onCreate: (props: { graph: CanvasGraphModel<S>; node: S }) => void;
19
+ onLink: (props: { graph: CanvasGraphModel<S>; edge: CanvasBoard.Connection }) => void;
20
+ onDelete: (props: { graph: CanvasGraphModel<S>; subgraph: CanvasGraphModel<S> }) => void;
21
+ }
13
22
 
14
23
  /**
15
24
  * Map canvas edge to compute edge.
package/src/index.ts CHANGED
@@ -7,4 +7,4 @@ export * from './hooks/index.ts';
7
7
  export * from './registry.ts';
8
8
  export * from './scene/index.ts';
9
9
  export * from './shapes/index.ts';
10
- export * from './compute-layout.ts';
10
+ export * from './types/index.ts';
@@ -7,9 +7,9 @@ import { type Page, expect, test } from '@playwright/test';
7
7
  import { setupPage, storybookUrl } from '@dxos/test-utils/playwright';
8
8
 
9
9
  const PORT = 9007;
10
- const TRANSFORM_URL = storybookUrl('ui-react-ui-canvas-compute-scene--transform', PORT);
11
- const LOGIC_URL = storybookUrl('ui-react-ui-canvas-compute-scene--logic', PORT);
12
- const TEMPLATE_URL = storybookUrl('ui-react-ui-canvas-compute-scene--template', PORT);
10
+ const TRANSFORM_URL = storybookUrl('ui-react-ui-canvas-compute-circuits--transform', PORT);
11
+ const LOGIC_URL = storybookUrl('ui-react-ui-canvas-compute-circuits--logic', PORT);
12
+ const TEMPLATE_URL = storybookUrl('ui-react-ui-canvas-compute-circuits--template', PORT);
13
13
 
14
14
  /** The die a `random` shape draws; its icon name changes as it spins, so match the family. */
15
15
  const DICE = 'svg:has(use[href*="dice"])';
package/src/registry.ts CHANGED
@@ -2,99 +2,71 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import type { ShapeDef } from '@dxos/react-ui-canvas-editor';
6
- import { noteShape } from '@dxos/react-ui-canvas-editor';
5
+ import { type NodeDef, type NodeRegistry, defaultNodeRegistry } from '@dxos/react-ui-canvas/scene';
7
6
 
8
7
  import {
9
- andShape,
10
- appendShape,
11
- audioShape,
12
- beaconShape,
13
- chatShape,
14
- constantShape,
15
- databaseShape,
16
- feedShape,
17
- functionShape,
18
- gptRealtimeShape,
19
- gptShape,
20
- ifElseShape,
21
- ifShape,
22
- jsonShape,
23
- jsonTransformShape,
24
- notShape,
25
- orShape,
26
- randomShape,
27
- reducerShape,
28
- scopeShape,
29
- surfaceShape,
30
- switchShape,
31
- templateShape,
32
- textShape,
33
- textToImageShape,
34
- threadShape,
35
- triggerShape,
8
+ andNodeDef,
9
+ appendNodeDef,
10
+ audioNodeDef,
11
+ beaconNodeDef,
12
+ chatNodeDef,
13
+ constantNodeDef,
14
+ databaseNodeDef,
15
+ feedNodeDef,
16
+ functionNodeDef,
17
+ gptNodeDef,
18
+ gptRealtimeNodeDef,
19
+ ifElseNodeDef,
20
+ ifNodeDef,
21
+ jsonNodeDef,
22
+ jsonTransformNodeDef,
23
+ notNodeDef,
24
+ orNodeDef,
25
+ randomNodeDef,
26
+ reducerNodeDef,
27
+ scopeNodeDef,
28
+ surfaceNodeDef,
29
+ switchNodeDef,
30
+ templateNodeDef,
31
+ textNodeDef,
32
+ textToImageNodeDef,
33
+ threadNodeDef,
34
+ triggerNodeDef,
36
35
  } from './shapes/index.ts';
37
36
 
38
- /**
39
- * Order used by toolbar.
40
- */
41
- export const computeShapes: { title: string; shapes: ShapeDef[] }[] = [
42
- {
43
- title: 'Inputs',
44
- shapes: [
45
- //
46
- constantShape,
47
- templateShape,
48
- chatShape,
49
- switchShape,
50
- audioShape,
51
- triggerShape,
52
- randomShape,
53
- ],
54
- },
55
- {
56
- title: 'Transform',
57
- shapes: [
58
- //
59
- gptShape,
60
- gptRealtimeShape,
61
- functionShape,
62
- databaseShape,
63
- textToImageShape,
64
- appendShape,
65
- ],
66
- },
67
- {
68
- title: 'Operations',
69
- shapes: [
70
- //
71
- ifShape,
72
- ifElseShape,
73
- andShape,
74
- orShape,
75
- notShape,
76
- reducerShape,
77
- jsonTransformShape,
78
- ],
79
- },
80
- {
81
- title: 'Outputs',
82
- shapes: [
83
- //
84
- jsonShape,
85
- feedShape,
86
- threadShape,
87
- textShape,
88
- surfaceShape,
89
- beaconShape,
90
- scopeShape,
91
- ],
92
- },
93
- {
94
- title: 'Misc',
95
- shapes: [
96
- //
97
- noteShape,
98
- ],
99
- },
37
+ /** The compute types in palette order, each under its group (Inputs, Transform, Operations, Outputs). */
38
+ export const computeNodeDefs: NodeDef[] = [
39
+ constantNodeDef,
40
+ templateNodeDef,
41
+ chatNodeDef,
42
+ switchNodeDef,
43
+ audioNodeDef,
44
+ triggerNodeDef,
45
+ randomNodeDef,
46
+ gptNodeDef,
47
+ gptRealtimeNodeDef,
48
+ functionNodeDef,
49
+ databaseNodeDef,
50
+ textToImageNodeDef,
51
+ appendNodeDef,
52
+ ifNodeDef,
53
+ ifElseNodeDef,
54
+ andNodeDef,
55
+ orNodeDef,
56
+ notNodeDef,
57
+ reducerNodeDef,
58
+ jsonTransformNodeDef,
59
+ jsonNodeDef,
60
+ feedNodeDef,
61
+ threadNodeDef,
62
+ textNodeDef,
63
+ surfaceNodeDef,
64
+ beaconNodeDef,
65
+ scopeNodeDef,
100
66
  ];
67
+
68
+ /** The compute types plus the engine's note under a `Misc` group. */
69
+ export const computeNodeRegistry: NodeRegistry = {
70
+ ...Object.fromEntries(computeNodeDefs.map((def) => [def.type, def])),
71
+ note: { ...defaultNodeRegistry.note, group: 'Misc' },
72
+ };
@@ -11,7 +11,6 @@ import { capabilities } from '@dxos/assistant-toolkit/testing';
11
11
  import { type GraphDiagnostic } from '@dxos/conductor';
12
12
  import { withClientProvider } from '@dxos/react-client/testing';
13
13
  import { withAttention } from '@dxos/react-ui-attention/testing';
14
- import { ShapeRegistry } from '@dxos/react-ui-canvas-editor';
15
14
  import {
16
15
  type FreehandProjectionOptions,
17
16
  SceneView,
@@ -28,7 +27,7 @@ import * as Toolbar from '@dxos/react-ui/Toolbar';
28
27
  import { DiagnosticOverlay } from '../components/index.ts';
29
28
  import { type ComputeGraphController, createComputeGraphController } from '../graph/index.ts';
30
29
  import { ComputeContext } from '../hooks/index.ts';
31
- import { computeShapes } from '../registry.ts';
30
+ import { computeNodeRegistry } from '../registry.ts';
32
31
  import {
33
32
  createArtifactCircuit,
34
33
  createAudioCircuit,
@@ -43,7 +42,6 @@ import {
43
42
  } from '../testing/index.ts';
44
43
  import { createStoryRuntime } from '../testing/services.ts';
45
44
  import { Bullets } from './Bullets.tsx';
46
- import { computeNodeRegistry } from './defs.ts';
47
45
  import { createComputeProjection } from './projection.ts';
48
46
  import { sceneFromCircuit } from './scene.ts';
49
47
 
@@ -71,7 +69,6 @@ const DefaultStory = ({ controller, circuit, sidebar: sidebarProp }: StoryProps)
71
69
  [controller],
72
70
  );
73
71
  const projection = useSceneProjection({ store, atoms, createProjection });
74
- const shapeRegistry = useMemo(() => new ShapeRegistry(computeShapes), []);
75
72
  // A function body opening grows its node through the model, so links re-route with it.
76
73
  const resize = useCallback(
77
74
  (id: string, delta: number) => {
@@ -103,7 +100,7 @@ const DefaultStory = ({ controller, circuit, sidebar: sidebarProp }: StoryProps)
103
100
 
104
101
  return (
105
102
  <div className='grid grid-cols-[1fr_360px] dx-fill'>
106
- <ComputeContext.Provider value={{ controller, registry: shapeRegistry, resize }}>
103
+ <ComputeContext.Provider value={{ controller, resize }}>
107
104
  <div className={sidebar ? 'relative flex overflow-hidden' : 'relative flex overflow-hidden col-span-2'}>
108
105
  <SceneView.Root
109
106
  store={store}
@@ -188,7 +185,7 @@ const SidebarJson = ({
188
185
  };
189
186
 
190
187
  const meta = {
191
- title: 'ui/react-ui-canvas-compute/scene',
188
+ title: 'ui/react-ui-canvas-compute/Circuits',
192
189
  render: DefaultStory,
193
190
  decorators: [
194
191
  withRegistry,
@@ -5,15 +5,25 @@
5
5
  import { describe, test } from 'vitest';
6
6
 
7
7
  import { DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';
8
- import { type CanvasBoard, type Polygon } from '@dxos/react-ui-canvas-editor';
9
- import { type Link, type Node, type Scene, reduceIntent, sortByZ } from '@dxos/react-ui-canvas/scene';
8
+ import { type Link, type Node, type NodeStyle, type Scene, reduceIntent, sortByZ } from '@dxos/react-ui-canvas/scene';
10
9
 
10
+ import { type ComputeShape } from '../shapes/index.ts';
11
+ import { type CanvasBoard } from '../types/index.ts';
11
12
  import { applySceneToLayout, sceneFromLayout } from './echo-store.ts';
12
13
 
13
- type Layout = { nodes: Polygon[]; edges: CanvasBoard.Connection[] };
14
+ type Layout = { nodes: ComputeShape[]; edges: CanvasBoard.Connection[] };
14
15
 
15
- const shape = (id: string, x: number, rest: Record<string, unknown> = {}): Polygon =>
16
- ({ id, type: 'constant', center: { x, y: 0 }, size: { width: 64, height: 32 }, ...rest }) as Polygon;
16
+ const shape = (
17
+ id: string,
18
+ x: number,
19
+ rest: Partial<ComputeShape> & { style?: NodeStyle } = {},
20
+ ): ComputeShape & { style?: NodeStyle } => ({
21
+ id,
22
+ type: 'constant',
23
+ center: { x, y: 0 },
24
+ size: { width: 64, height: 32 },
25
+ ...rest,
26
+ });
17
27
 
18
28
  const edge = (id: string, source: string, target: string, rest: Record<string, unknown> = {}) =>
19
29
  ({ id, source, target, ...rest }) as CanvasBoard.Connection;
@@ -54,10 +64,11 @@ describe('echo store', () => {
54
64
  nodes: [shape('a', 0, { guide: true, classNames: 'text-red-500' }), shape('b', 1, { style: { hue: 'sky' } })],
55
65
  edges: [],
56
66
  });
57
- expect(scene.nodes.a.style).toEqual({ guide: true, className: 'text-red-500' });
67
+ expect(scene.nodes.a.style).toEqual({ guide: true });
58
68
  expect(scene.nodes.b.style).toEqual({ hue: 'sky' });
59
69
  expect('guide' in scene.nodes.a).toBe(false);
60
- expect('classNames' in scene.nodes.a).toBe(false);
70
+ // The old editor's classes ride through untouched; the engine draws none.
71
+ expect(Reflect.get(scene.nodes.a, 'classNames')).toBe('text-red-500');
61
72
  });
62
73
 
63
74
  test('a move writes back the node and nothing else', ({ expect }) => {
@@ -18,7 +18,6 @@ import * as Atom from 'effect/reactivity/Atom';
18
18
 
19
19
  import { DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';
20
20
  import { Obj } from '@dxos/echo';
21
- import { CanvasBoard } from '@dxos/react-ui-canvas-editor';
22
21
  import {
23
22
  type Link,
24
23
  LINK_TYPES,
@@ -34,6 +33,7 @@ import {
34
33
  } from '@dxos/react-ui-canvas/scene';
35
34
 
36
35
  import { createAnchorId, parseAnchorId } from '../shapes/defs.ts';
36
+ import { type CanvasBoard } from '../types/index.ts';
37
37
 
38
38
  /** A board's layout as both representations see it: the arrays, whether live (ECHO) or plain. */
39
39
  type Layout = { nodes: CanvasBoard.Shape[]; edges: CanvasBoard.Connection[] };
@@ -72,7 +72,8 @@ export const sceneFromLayout = (id: SceneId, layout: Partial<Layout> | undefined
72
72
  };
73
73
 
74
74
  const nodeFromShape = (shape: CanvasBoard.Shape, z: string): Node => {
75
- const { guide: _guide, classNames: _classNames, ...rest } = shape as CanvasBoard.Shape & { style?: NodeStyle };
75
+ // `classNames` rides through on the node untouched: the old editor reads it, the engine draws no host classes.
76
+ const { guide: _guide, ...rest } = shape as CanvasBoard.Shape & { style?: NodeStyle };
76
77
  const style = styleFromShape(shape);
77
78
  return {
78
79
  ...(rest as unknown as Node),
@@ -81,13 +82,10 @@ const nodeFromShape = (shape: CanvasBoard.Shape, z: string): Node => {
81
82
  };
82
83
  };
83
84
 
84
- /** A shape's look: its own `style` when the engine wrote one, else the editor's two top-level fields. */
85
+ /** A shape's look: its own `style` when the engine wrote one, else the editor's top-level `guide`. */
85
86
  const styleFromShape = (shape: CanvasBoard.Shape): NodeStyle | undefined => {
86
- const { style, guide, classNames } = shape as CanvasBoard.Shape & { style?: NodeStyle };
87
- const legacy: NodeStyle = {
88
- ...(guide !== undefined ? { guide } : {}),
89
- ...(classNames !== undefined ? { className: classNames } : {}),
90
- };
87
+ const { style, guide } = shape as CanvasBoard.Shape & { style?: NodeStyle };
88
+ const legacy: NodeStyle = guide !== undefined ? { guide } : {};
91
89
  const merged = { ...legacy, ...style };
92
90
  return Object.keys(merged).length > 0 ? merged : undefined;
93
91
  };
@@ -165,9 +163,8 @@ const shapeFromNode = (node: Node): CanvasBoard.Shape => {
165
163
  return {
166
164
  ...(rest as unknown as CanvasBoard.Shape),
167
165
  ...(style ? { style } : {}),
168
- // The old editor reads these two, so a board stays readable by it (M5 retires them with the package).
166
+ // The old editor reads `guide`, so a board stays readable by it (M5 retires it with the package).
169
167
  ...(style?.guide !== undefined ? { guide: style.guide } : {}),
170
- ...(style?.className !== undefined ? { classNames: style.className } : {}),
171
168
  } as CanvasBoard.Shape;
172
169
  };
173
170
 
@@ -3,9 +3,6 @@
3
3
  //
4
4
 
5
5
  export * from './Bullets.tsx';
6
- export * from './defs.ts';
7
6
  export * from './echo-store.ts';
8
- export * from './NodeView.tsx';
9
- export * from './ports.ts';
10
7
  export * from './projection.ts';
11
8
  export * from './scene.ts';
@@ -34,8 +34,7 @@ import {
34
34
  syncDelete,
35
35
  syncLink,
36
36
  } from '../graph/index.ts';
37
- import { type ComputeShape, createFunctionAnchors, parseAnchorId } from '../shapes/index.ts';
38
- import { anchorsToPorts } from './ports.ts';
37
+ import { type ComputeShape, createFunctionPorts, parseAnchorId } from '../shapes/index.ts';
39
38
 
40
39
  /** What the projection needs of the controller: the graph it mirrors into and the runtime's change event. */
41
40
  export type ComputeGraphSource = Pick<ComputeGraphController, 'graph' | 'update'>;
@@ -235,7 +234,7 @@ const withRuntimePorts = (controller: ComputeGraphSource, node: Node): Node => {
235
234
  }
236
235
  const inputSchema = computeNode.inputSchema ? JsonSchema.toEffectSchema(computeNode.inputSchema) : DefaultInput;
237
236
  const outputSchema = computeNode.outputSchema ? JsonSchema.toEffectSchema(computeNode.outputSchema) : DefaultOutput;
238
- return { ...node, ports: anchorsToPorts(createFunctionAnchors(node, inputSchema, outputSchema), node.size) };
237
+ return { ...node, ports: createFunctionPorts(node.size, inputSchema, outputSchema) };
239
238
  };
240
239
 
241
240
  const model = (controller: ComputeGraphSource) => controller.graph;
@@ -11,9 +11,9 @@ import { DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';
11
11
  import { type Link, type Node, createMemoryStore, createSceneSchema, nodePorts } from '@dxos/react-ui-canvas/scene';
12
12
 
13
13
  import { createComputeGraph } from '../hooks/index.ts';
14
+ import { computeNodeDefs, computeNodeRegistry } from '../registry.ts';
15
+ import { createRowPorts } from '../shapes/index.ts';
14
16
  import { createControlCircuit, createTemplateCircuit, createTransformCircuit } from '../testing/index.ts';
15
- import { computeNodeDefs, computeNodeRegistry } from './defs.ts';
16
- import { anchorsToPorts } from './ports.ts';
17
17
  import { createComputeProjection } from './projection.ts';
18
18
  import { sceneFromCircuit } from './scene.ts';
19
19
 
@@ -81,7 +81,7 @@ describe('compute scene', () => {
81
81
  const plain = Object.values(scene.links).find(
82
82
  (link) => 'port' in link.target && link.target.port === `input.${DEFAULT_INPUT}`,
83
83
  );
84
- expect(plain?.directed).toBe(true);
84
+ expect(plain?.ends).toEqual({ end: 'arrow' });
85
85
  });
86
86
 
87
87
  test('ports follow the anchors: stacked inputs on the west side, outputs east, exact offsets', ({ expect }) => {
@@ -98,7 +98,7 @@ describe('compute scene', () => {
98
98
  // Rows keep their order down the side.
99
99
  const offsets = inputs.map((port) => port.offset);
100
100
  expect([...offsets].sort((left, right) => left - right)).toEqual(offsets);
101
- expect(anchorsToPorts({}, { width: 10, height: 10 })).toEqual([]);
101
+ expect(createRowPorts({ size: { width: 10, height: 10 }, inputs: [], outputs: [] })).toEqual([]);
102
102
  });
103
103
  });
104
104
 
@@ -8,14 +8,16 @@
8
8
  // and `createComputeGraph` stay as they are; this is the seam the M4 store migration builds on.
9
9
  //
10
10
 
11
+ import * as Schema from 'effect/Schema';
12
+
11
13
  import { DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';
12
- import { type CanvasGraphModel, isPolygon } from '@dxos/react-ui-canvas-editor';
13
14
  import { type Link, type Node, type Scene, initialKeys } from '@dxos/react-ui-canvas/scene';
14
15
 
15
- import { type ComputeShape, createAnchorId } from '../shapes/index.ts';
16
+ import { ComputeShape, createAnchorId } from '../shapes/index.ts';
17
+ import { type CanvasGraphModel } from '../types/index.ts';
16
18
 
17
19
  export const sceneFromCircuit = (model: CanvasGraphModel<ComputeShape>, id = 'circuit', name?: string): Scene => {
18
- const shapes = model.nodes.filter(isPolygon);
20
+ const shapes = model.nodes.filter(Schema.is(ComputeShape));
19
21
  const keys = initialKeys(shapes.length + model.edges.length);
20
22
  const nodes: Record<string, Node> = {};
21
23
  shapes.forEach((shape, index) => {
@@ -33,7 +35,7 @@ export const sceneFromCircuit = (model: CanvasGraphModel<ComputeShape>, id = 'ci
33
35
  z: keys[shapes.length + index],
34
36
  source: { node: edge.source, port: createAnchorId('output', edge.output ?? DEFAULT_OUTPUT) },
35
37
  target: { node: edge.target, port: createAnchorId('input', edge.input ?? DEFAULT_INPUT) },
36
- directed: true,
38
+ ends: { end: 'arrow' },
37
39
  };
38
40
  });
39
41
  return { id, ...(name ? { name } : {}), nodes, links };