@simten/ui 0.1.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 (307) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +41 -0
  3. package/dist/canvas/CircuitCanvas.d.ts +45 -0
  4. package/dist/canvas/CircuitCanvas.d.ts.map +1 -0
  5. package/dist/canvas/CircuitCanvas.js +293 -0
  6. package/dist/canvas/CircuitCanvas.js.map +1 -0
  7. package/dist/canvas/ClockControls.d.ts +31 -0
  8. package/dist/canvas/ClockControls.d.ts.map +1 -0
  9. package/dist/canvas/ClockControls.js +33 -0
  10. package/dist/canvas/ClockControls.js.map +1 -0
  11. package/dist/canvas/CompositeInspectorDialog.d.ts +24 -0
  12. package/dist/canvas/CompositeInspectorDialog.d.ts.map +1 -0
  13. package/dist/canvas/CompositeInspectorDialog.js +290 -0
  14. package/dist/canvas/CompositeInspectorDialog.js.map +1 -0
  15. package/dist/canvas/dagre-layout.d.ts +40 -0
  16. package/dist/canvas/dagre-layout.d.ts.map +1 -0
  17. package/dist/canvas/dagre-layout.js +86 -0
  18. package/dist/canvas/dagre-layout.js.map +1 -0
  19. package/dist/canvas/drill-down-view.d.ts +35 -0
  20. package/dist/canvas/drill-down-view.d.ts.map +1 -0
  21. package/dist/canvas/drill-down-view.js +134 -0
  22. package/dist/canvas/drill-down-view.js.map +1 -0
  23. package/dist/canvas/hooks/useDetectTheme.d.ts +6 -0
  24. package/dist/canvas/hooks/useDetectTheme.d.ts.map +1 -0
  25. package/dist/canvas/hooks/useDetectTheme.js +20 -0
  26. package/dist/canvas/hooks/useDetectTheme.js.map +1 -0
  27. package/dist/canvas/hooks/useIsMobile.d.ts +2 -0
  28. package/dist/canvas/hooks/useIsMobile.d.ts.map +1 -0
  29. package/dist/canvas/hooks/useIsMobile.js +20 -0
  30. package/dist/canvas/hooks/useIsMobile.js.map +1 -0
  31. package/dist/canvas/hooks/useSimulationSession.d.ts +23 -0
  32. package/dist/canvas/hooks/useSimulationSession.d.ts.map +1 -0
  33. package/dist/canvas/hooks/useSimulationSession.js +41 -0
  34. package/dist/canvas/hooks/useSimulationSession.js.map +1 -0
  35. package/dist/canvas/index.d.ts +22 -0
  36. package/dist/canvas/index.d.ts.map +1 -0
  37. package/dist/canvas/index.js +17 -0
  38. package/dist/canvas/index.js.map +1 -0
  39. package/dist/canvas/label-utils.d.ts +10 -0
  40. package/dist/canvas/label-utils.d.ts.map +1 -0
  41. package/dist/canvas/label-utils.js +32 -0
  42. package/dist/canvas/label-utils.js.map +1 -0
  43. package/dist/canvas/node-types.d.ts +10 -0
  44. package/dist/canvas/node-types.d.ts.map +1 -0
  45. package/dist/canvas/node-types.js +29 -0
  46. package/dist/canvas/node-types.js.map +1 -0
  47. package/dist/canvas/projection.d.ts +19 -0
  48. package/dist/canvas/projection.d.ts.map +1 -0
  49. package/dist/canvas/projection.js +317 -0
  50. package/dist/canvas/projection.js.map +1 -0
  51. package/dist/canvas/types.d.ts +56 -0
  52. package/dist/canvas/types.d.ts.map +1 -0
  53. package/dist/canvas/types.js +6 -0
  54. package/dist/canvas/types.js.map +1 -0
  55. package/dist/canvas/useLayout.d.ts +21 -0
  56. package/dist/canvas/useLayout.d.ts.map +1 -0
  57. package/dist/canvas/useLayout.js +26 -0
  58. package/dist/canvas/useLayout.js.map +1 -0
  59. package/dist/editor/components/CircuitSelector.d.ts +9 -0
  60. package/dist/editor/components/CircuitSelector.d.ts.map +1 -0
  61. package/dist/editor/components/CircuitSelector.js +20 -0
  62. package/dist/editor/components/CircuitSelector.js.map +1 -0
  63. package/dist/editor/components/CircuitTabBar.d.ts +8 -0
  64. package/dist/editor/components/CircuitTabBar.d.ts.map +1 -0
  65. package/dist/editor/components/CircuitTabBar.js +23 -0
  66. package/dist/editor/components/CircuitTabBar.js.map +1 -0
  67. package/dist/editor/components/ClockControls.d.ts +6 -0
  68. package/dist/editor/components/ClockControls.d.ts.map +1 -0
  69. package/dist/editor/components/ClockControls.js +7 -0
  70. package/dist/editor/components/ClockControls.js.map +1 -0
  71. package/dist/editor/components/ComponentTooltip.d.ts +25 -0
  72. package/dist/editor/components/ComponentTooltip.d.ts.map +1 -0
  73. package/dist/editor/components/ComponentTooltip.js +82 -0
  74. package/dist/editor/components/ComponentTooltip.js.map +1 -0
  75. package/dist/editor/components/ConflictResolutionModal.d.ts +19 -0
  76. package/dist/editor/components/ConflictResolutionModal.d.ts.map +1 -0
  77. package/dist/editor/components/ConflictResolutionModal.js +20 -0
  78. package/dist/editor/components/ConflictResolutionModal.js.map +1 -0
  79. package/dist/editor/components/HierarchyBreadcrumb.d.ts +9 -0
  80. package/dist/editor/components/HierarchyBreadcrumb.d.ts.map +1 -0
  81. package/dist/editor/components/HierarchyBreadcrumb.js +32 -0
  82. package/dist/editor/components/HierarchyBreadcrumb.js.map +1 -0
  83. package/dist/editor/components/LabelEditor.d.ts +17 -0
  84. package/dist/editor/components/LabelEditor.d.ts.map +1 -0
  85. package/dist/editor/components/LabelEditor.js +40 -0
  86. package/dist/editor/components/LabelEditor.js.map +1 -0
  87. package/dist/editor/components/SignalOutputPanel.d.ts +11 -0
  88. package/dist/editor/components/SignalOutputPanel.d.ts.map +1 -0
  89. package/dist/editor/components/SignalOutputPanel.js +34 -0
  90. package/dist/editor/components/SignalOutputPanel.js.map +1 -0
  91. package/dist/editor/components/index.d.ts +9 -0
  92. package/dist/editor/components/index.d.ts.map +1 -0
  93. package/dist/editor/components/index.js +9 -0
  94. package/dist/editor/components/index.js.map +1 -0
  95. package/dist/editor/hooks/index.d.ts +1 -0
  96. package/dist/editor/hooks/index.d.ts.map +1 -0
  97. package/dist/editor/hooks/index.js +2 -0
  98. package/dist/editor/hooks/index.js.map +1 -0
  99. package/dist/editor/index.d.ts +5 -0
  100. package/dist/editor/index.d.ts.map +1 -0
  101. package/dist/editor/index.js +5 -0
  102. package/dist/editor/index.js.map +1 -0
  103. package/dist/editor/lib/simulation/index.d.ts +7 -0
  104. package/dist/editor/lib/simulation/index.d.ts.map +1 -0
  105. package/dist/editor/lib/simulation/index.js +8 -0
  106. package/dist/editor/lib/simulation/index.js.map +1 -0
  107. package/dist/editor/lib/utils/circuit-flattener.d.ts +29 -0
  108. package/dist/editor/lib/utils/circuit-flattener.d.ts.map +1 -0
  109. package/dist/editor/lib/utils/circuit-flattener.js +230 -0
  110. package/dist/editor/lib/utils/circuit-flattener.js.map +1 -0
  111. package/dist/editor/lib/utils/component-utils.d.ts +28 -0
  112. package/dist/editor/lib/utils/component-utils.d.ts.map +1 -0
  113. package/dist/editor/lib/utils/component-utils.js +72 -0
  114. package/dist/editor/lib/utils/component-utils.js.map +1 -0
  115. package/dist/editor/lib/utils/index.d.ts +3 -0
  116. package/dist/editor/lib/utils/index.d.ts.map +1 -0
  117. package/dist/editor/lib/utils/index.js +3 -0
  118. package/dist/editor/lib/utils/index.js.map +1 -0
  119. package/dist/editor/lib/visualization/index.d.ts +2 -0
  120. package/dist/editor/lib/visualization/index.d.ts.map +1 -0
  121. package/dist/editor/lib/visualization/index.js +2 -0
  122. package/dist/editor/lib/visualization/index.js.map +1 -0
  123. package/dist/editor/lib/visualization/vcd-generator.d.ts +63 -0
  124. package/dist/editor/lib/visualization/vcd-generator.d.ts.map +1 -0
  125. package/dist/editor/lib/visualization/vcd-generator.js +269 -0
  126. package/dist/editor/lib/visualization/vcd-generator.js.map +1 -0
  127. package/dist/editor/stores/circuit-library-store.d.ts +25 -0
  128. package/dist/editor/stores/circuit-library-store.d.ts.map +1 -0
  129. package/dist/editor/stores/circuit-library-store.js +51 -0
  130. package/dist/editor/stores/circuit-library-store.js.map +1 -0
  131. package/dist/editor/stores/circuit-preview-store.d.ts +687 -0
  132. package/dist/editor/stores/circuit-preview-store.d.ts.map +1 -0
  133. package/dist/editor/stores/circuit-preview-store.js +226 -0
  134. package/dist/editor/stores/circuit-preview-store.js.map +1 -0
  135. package/dist/editor/stores/circuit-store.d.ts +354 -0
  136. package/dist/editor/stores/circuit-store.d.ts.map +1 -0
  137. package/dist/editor/stores/circuit-store.js +227 -0
  138. package/dist/editor/stores/circuit-store.js.map +1 -0
  139. package/dist/editor/stores/index.d.ts +11 -0
  140. package/dist/editor/stores/index.d.ts.map +1 -0
  141. package/dist/editor/stores/index.js +8 -0
  142. package/dist/editor/stores/index.js.map +1 -0
  143. package/dist/editor/stores/ui-store.d.ts +96 -0
  144. package/dist/editor/stores/ui-store.d.ts.map +1 -0
  145. package/dist/editor/stores/ui-store.js +101 -0
  146. package/dist/editor/stores/ui-store.js.map +1 -0
  147. package/dist/editor/types/circuit.d.ts +207 -0
  148. package/dist/editor/types/circuit.d.ts.map +1 -0
  149. package/dist/editor/types/circuit.js +62 -0
  150. package/dist/editor/types/circuit.js.map +1 -0
  151. package/dist/editor/types/index.d.ts +12 -0
  152. package/dist/editor/types/index.d.ts.map +1 -0
  153. package/dist/editor/types/index.js +11 -0
  154. package/dist/editor/types/index.js.map +1 -0
  155. package/dist/editor/types/testbench.d.ts +150 -0
  156. package/dist/editor/types/testbench.d.ts.map +1 -0
  157. package/dist/editor/types/testbench.js +85 -0
  158. package/dist/editor/types/testbench.js.map +1 -0
  159. package/dist/editor/types/testing.d.ts +88 -0
  160. package/dist/editor/types/testing.d.ts.map +1 -0
  161. package/dist/editor/types/testing.js +6 -0
  162. package/dist/editor/types/testing.js.map +1 -0
  163. package/dist/editor/types/ui-model.d.ts +68 -0
  164. package/dist/editor/types/ui-model.d.ts.map +1 -0
  165. package/dist/editor/types/ui-model.js +66 -0
  166. package/dist/editor/types/ui-model.js.map +1 -0
  167. package/dist/editor/types/ui.d.ts +33 -0
  168. package/dist/editor/types/ui.d.ts.map +1 -0
  169. package/dist/editor/types/ui.js +8 -0
  170. package/dist/editor/types/ui.js.map +1 -0
  171. package/dist/editor/types/visual.d.ts +45 -0
  172. package/dist/editor/types/visual.d.ts.map +1 -0
  173. package/dist/editor/types/visual.js +23 -0
  174. package/dist/editor/types/visual.js.map +1 -0
  175. package/dist/editor/utils/index.d.ts +5 -0
  176. package/dist/editor/utils/index.d.ts.map +1 -0
  177. package/dist/editor/utils/index.js +6 -0
  178. package/dist/editor/utils/index.js.map +1 -0
  179. package/dist/index.d.ts +11 -0
  180. package/dist/index.d.ts.map +1 -0
  181. package/dist/index.js +12 -0
  182. package/dist/index.js.map +1 -0
  183. package/dist/lib/utils.d.ts +3 -0
  184. package/dist/lib/utils.d.ts.map +1 -0
  185. package/dist/lib/utils.js +6 -0
  186. package/dist/lib/utils.js.map +1 -0
  187. package/dist/nodes/BaseNode.d.ts +20 -0
  188. package/dist/nodes/BaseNode.d.ts.map +1 -0
  189. package/dist/nodes/BaseNode.js +26 -0
  190. package/dist/nodes/BaseNode.js.map +1 -0
  191. package/dist/nodes/CompositeBadge.d.ts +6 -0
  192. package/dist/nodes/CompositeBadge.d.ts.map +1 -0
  193. package/dist/nodes/CompositeBadge.js +10 -0
  194. package/dist/nodes/CompositeBadge.js.map +1 -0
  195. package/dist/nodes/ConsoleNode.d.ts +8 -0
  196. package/dist/nodes/ConsoleNode.d.ts.map +1 -0
  197. package/dist/nodes/ConsoleNode.js +16 -0
  198. package/dist/nodes/ConsoleNode.js.map +1 -0
  199. package/dist/nodes/EmbedConsoleNode.d.ts +8 -0
  200. package/dist/nodes/EmbedConsoleNode.d.ts.map +1 -0
  201. package/dist/nodes/EmbedConsoleNode.js +24 -0
  202. package/dist/nodes/EmbedConsoleNode.js.map +1 -0
  203. package/dist/nodes/EmbedScreenNode.d.ts +8 -0
  204. package/dist/nodes/EmbedScreenNode.d.ts.map +1 -0
  205. package/dist/nodes/EmbedScreenNode.js +24 -0
  206. package/dist/nodes/EmbedScreenNode.js.map +1 -0
  207. package/dist/nodes/EthFrameInputNode.d.ts +8 -0
  208. package/dist/nodes/EthFrameInputNode.d.ts.map +1 -0
  209. package/dist/nodes/EthFrameInputNode.js +14 -0
  210. package/dist/nodes/EthFrameInputNode.js.map +1 -0
  211. package/dist/nodes/InputNode.d.ts +8 -0
  212. package/dist/nodes/InputNode.d.ts.map +1 -0
  213. package/dist/nodes/InputNode.js +57 -0
  214. package/dist/nodes/InputNode.js.map +1 -0
  215. package/dist/nodes/LogicGateNode.d.ts +8 -0
  216. package/dist/nodes/LogicGateNode.d.ts.map +1 -0
  217. package/dist/nodes/LogicGateNode.js +51 -0
  218. package/dist/nodes/LogicGateNode.js.map +1 -0
  219. package/dist/nodes/NicFifoNode.d.ts +8 -0
  220. package/dist/nodes/NicFifoNode.d.ts.map +1 -0
  221. package/dist/nodes/NicFifoNode.js +10 -0
  222. package/dist/nodes/NicFifoNode.js.map +1 -0
  223. package/dist/nodes/NodeData.d.ts +34 -0
  224. package/dist/nodes/NodeData.d.ts.map +1 -0
  225. package/dist/nodes/NodeData.js +2 -0
  226. package/dist/nodes/NodeData.js.map +1 -0
  227. package/dist/nodes/NumericInputNode.d.ts +8 -0
  228. package/dist/nodes/NumericInputNode.d.ts.map +1 -0
  229. package/dist/nodes/NumericInputNode.js +47 -0
  230. package/dist/nodes/NumericInputNode.js.map +1 -0
  231. package/dist/nodes/OutputNode.d.ts +8 -0
  232. package/dist/nodes/OutputNode.d.ts.map +1 -0
  233. package/dist/nodes/OutputNode.js +32 -0
  234. package/dist/nodes/OutputNode.js.map +1 -0
  235. package/dist/nodes/RAMNode.d.ts +8 -0
  236. package/dist/nodes/RAMNode.d.ts.map +1 -0
  237. package/dist/nodes/RAMNode.js +23 -0
  238. package/dist/nodes/RAMNode.js.map +1 -0
  239. package/dist/nodes/ROMNode.d.ts +8 -0
  240. package/dist/nodes/ROMNode.d.ts.map +1 -0
  241. package/dist/nodes/ROMNode.js +23 -0
  242. package/dist/nodes/ROMNode.js.map +1 -0
  243. package/dist/nodes/RV32IInstrMemNode.d.ts +16 -0
  244. package/dist/nodes/RV32IInstrMemNode.d.ts.map +1 -0
  245. package/dist/nodes/RV32IInstrMemNode.js +183 -0
  246. package/dist/nodes/RV32IInstrMemNode.js.map +1 -0
  247. package/dist/nodes/RasterDisplayNode.d.ts +8 -0
  248. package/dist/nodes/RasterDisplayNode.d.ts.map +1 -0
  249. package/dist/nodes/RasterDisplayNode.js +14 -0
  250. package/dist/nodes/RasterDisplayNode.js.map +1 -0
  251. package/dist/nodes/RegisterNode.d.ts +8 -0
  252. package/dist/nodes/RegisterNode.d.ts.map +1 -0
  253. package/dist/nodes/RegisterNode.js +14 -0
  254. package/dist/nodes/RegisterNode.js.map +1 -0
  255. package/dist/nodes/ScreenNode.d.ts +8 -0
  256. package/dist/nodes/ScreenNode.d.ts.map +1 -0
  257. package/dist/nodes/ScreenNode.js +16 -0
  258. package/dist/nodes/ScreenNode.js.map +1 -0
  259. package/dist/nodes/UartTxNode.d.ts +8 -0
  260. package/dist/nodes/UartTxNode.d.ts.map +1 -0
  261. package/dist/nodes/UartTxNode.js +16 -0
  262. package/dist/nodes/UartTxNode.js.map +1 -0
  263. package/dist/nodes/index.d.ts +27 -0
  264. package/dist/nodes/index.d.ts.map +1 -0
  265. package/dist/nodes/index.js +30 -0
  266. package/dist/nodes/index.js.map +1 -0
  267. package/dist/primitives/button.d.ts +12 -0
  268. package/dist/primitives/button.d.ts.map +1 -0
  269. package/dist/primitives/button.js +32 -0
  270. package/dist/primitives/button.js.map +1 -0
  271. package/dist/primitives/index.d.ts +4 -0
  272. package/dist/primitives/index.d.ts.map +1 -0
  273. package/dist/primitives/index.js +4 -0
  274. package/dist/primitives/index.js.map +1 -0
  275. package/dist/primitives/sheet.d.ts +15 -0
  276. package/dist/primitives/sheet.d.ts.map +1 -0
  277. package/dist/primitives/sheet.js +40 -0
  278. package/dist/primitives/sheet.js.map +1 -0
  279. package/dist/primitives/tooltip.d.ts +8 -0
  280. package/dist/primitives/tooltip.d.ts.map +1 -0
  281. package/dist/primitives/tooltip.js +17 -0
  282. package/dist/primitives/tooltip.js.map +1 -0
  283. package/dist/sandbox/SandboxProvider.d.ts +13 -0
  284. package/dist/sandbox/SandboxProvider.d.ts.map +1 -0
  285. package/dist/sandbox/SandboxProvider.js +34 -0
  286. package/dist/sandbox/SandboxProvider.js.map +1 -0
  287. package/dist/sandbox/index.d.ts +4 -0
  288. package/dist/sandbox/index.d.ts.map +1 -0
  289. package/dist/sandbox/index.js +3 -0
  290. package/dist/sandbox/index.js.map +1 -0
  291. package/dist/sandbox/useSandbox.d.ts +197 -0
  292. package/dist/sandbox/useSandbox.d.ts.map +1 -0
  293. package/dist/sandbox/useSandbox.js +250 -0
  294. package/dist/sandbox/useSandbox.js.map +1 -0
  295. package/dist/share/encode-source.d.ts +13 -0
  296. package/dist/share/encode-source.d.ts.map +1 -0
  297. package/dist/share/encode-source.js +31 -0
  298. package/dist/share/encode-source.js.map +1 -0
  299. package/dist/share/index.d.ts +2 -0
  300. package/dist/share/index.d.ts.map +1 -0
  301. package/dist/share/index.js +2 -0
  302. package/dist/share/index.js.map +1 -0
  303. package/dist/waveform/WaveformViewer.d.ts +30 -0
  304. package/dist/waveform/WaveformViewer.d.ts.map +1 -0
  305. package/dist/waveform/WaveformViewer.js +356 -0
  306. package/dist/waveform/WaveformViewer.js.map +1 -0
  307. package/package.json +110 -0
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # @simten/ui
2
+
3
+ React components for the Simten circuit editor, canvas, and sandbox — the building blocks used to construct simten.dev's own editor UI.
4
+
5
+ This is the low-level UI kit. If you just want to embed a runnable circuit in a page, use **[`@simten/embed`](https://www.npmjs.com/package/@simten/embed)** instead — it wraps `@simten/ui`'s primitives in a turn-key component.
6
+
7
+ Use `@simten/ui` directly when you need to build a custom editor, a non-standard canvas layout, or your own variant of the sandbox harness.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @simten/ui @simten/core react react-dom
13
+ ```
14
+
15
+ ## What's in it
16
+
17
+ | Subpath | Purpose |
18
+ |---|---|
19
+ | `@simten/ui/canvas` | `CircuitCanvas` — the React Flow-based visual canvas |
20
+ | `@simten/ui/nodes` | Node renderers for primitives (gates, registers, peripherals, …) |
21
+ | `@simten/ui/editor` | `EditorWorkspace` and code-editor surface |
22
+ | `@simten/ui/editor/stores` | Zustand stores backing the editor |
23
+ | `@simten/ui/editor/hooks` | Hooks: `useCircuitSimulator`, history, compile pipeline |
24
+ | `@simten/ui/waveform` | `WaveformViewer` for VCD playback |
25
+ | `@simten/ui/sandbox` | Cross-origin sandbox primitives for running untrusted circuit code |
26
+ | `@simten/ui/share` | Encode/decode share links |
27
+
28
+ Each subpath has its own entry point with full TypeScript types — pick the smallest set you need.
29
+
30
+ ## Peer dependencies
31
+
32
+ - React 18 or 19
33
+ - `@simten/core`
34
+
35
+ ## Docs
36
+
37
+ Component API and integration examples at <https://simten.dev/docs>. Source: <https://github.com/simtenHQ/simten>.
38
+
39
+ ## License
40
+
41
+ Apache-2.0
@@ -0,0 +1,45 @@
1
+ import { type EdgeTypes, type NodeTypes } from "@xyflow/react";
2
+ import "@xyflow/react/dist/style.css";
3
+ import { type ReactNode } from "react";
4
+ import type { Circuit, CircuitLibrary, FlatPortValueMap, FlatSequentialState } from "@simten/core";
5
+ import type { NodeData } from "../nodes";
6
+ import type { CircuitLayout } from "./types";
7
+ export interface CircuitCanvasProps {
8
+ circuit?: Circuit | null;
9
+ componentLibrary?: CircuitLibrary;
10
+ portValues?: FlatPortValueMap | null;
11
+ sequentialState?: FlatSequentialState | null;
12
+ draggable?: boolean;
13
+ /**
14
+ * Pre-computed node positions keyed by node label (or id, as fallback).
15
+ * When provided, the layout engine is skipped entirely.
16
+ * When absent, positions are computed by the layout engine on mount.
17
+ */
18
+ layout?: CircuitLayout;
19
+ onToggleNode?: (nodeId: string) => void;
20
+ onSetNodeValue?: (nodeId: string, value: number) => void;
21
+ onLoadMemory?: (nodeId: string, data: Map<number, number>) => void;
22
+ onNodeDoubleClick?: (nodeData: NodeData) => void;
23
+ height?: number | string;
24
+ focus?: string | string[];
25
+ className?: string;
26
+ renderEmptyState?: () => ReactNode;
27
+ renderOverlay?: () => ReactNode;
28
+ nodeTypes?: NodeTypes;
29
+ edgeTypes?: EdgeTypes;
30
+ showControls?: boolean;
31
+ showPortLabels?: boolean;
32
+ onPortClick?: (nodeLabel: string, portName: string, portType: "input" | "output") => void;
33
+ glowUnconnected?: boolean;
34
+ /** Theme for the canvas. Defaults to "dark". */
35
+ theme?: "light" | "dark";
36
+ /**
37
+ * Allow single-finger pan on mobile. Default false — inline embeds need
38
+ * the page to scroll naturally over them. Set to true inside modal/full-
39
+ * screen contexts (drill-down inspector, fullscreen mode) where there's
40
+ * no page scroll to compete with.
41
+ */
42
+ panOnMobile?: boolean;
43
+ }
44
+ export declare function CircuitCanvas(props: CircuitCanvasProps): import("react/jsx-runtime").JSX.Element;
45
+ //# sourceMappingURL=CircuitCanvas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CircuitCanvas.d.ts","sourceRoot":"","sources":["../../src/canvas/CircuitCanvas.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E,MAAM,SAAS,CAAC;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,CACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,OAAO,GAAG,QAAQ,KACzB,IAAI,CAAC;IACV,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gDAAgD;IAChD,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAiZD,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAetD"}
@@ -0,0 +1,293 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { applyNodeChanges, Background, BackgroundVariant, Panel, ReactFlow, ReactFlowProvider, useReactFlow, useUpdateNodeInternals, } from "@xyflow/react";
3
+ import "@xyflow/react/dist/style.css";
4
+ import { useCallback, useLayoutEffect, useRef, useMemo, useState, } from "react";
5
+ import { cleanCircuitLabels } from "./label-utils";
6
+ import { EDGE_TYPES, NODE_TYPES } from "./node-types";
7
+ import { projectCircuitToReactFlow } from "./projection";
8
+ import { useLayout } from "./useLayout";
9
+ import { useIsMobile } from "./hooks/useIsMobile";
10
+ import { useDetectTheme } from "./hooks/useDetectTheme";
11
+ import { CompositeInspectorDialog } from "./CompositeInspectorDialog";
12
+ function CanvasControls() {
13
+ const { fitView, zoomIn, zoomOut } = useReactFlow();
14
+ const btn = "bg-[var(--embed-bg-tertiary)] hover:opacity-80 text-[var(--embed-text-secondary)] p-1.5 rounded border border-[var(--embed-border)] transition-colors";
15
+ return (_jsxs("div", { className: "flex items-center gap-1", children: [_jsx("button", { onClick: () => zoomOut(), className: btn, title: "Zoom out", "aria-label": "Zoom out", children: _jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", strokeWidth: 1.5, children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 12h14" }) }) }), _jsx("button", { onClick: () => zoomIn(), className: btn, title: "Zoom in", "aria-label": "Zoom in", children: _jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", strokeWidth: 1.5, children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 5v14M5 12h14" }) }) }), _jsx("button", { onClick: () => fitView({ padding: 0.3 }), className: btn, title: "Fit view", "aria-label": "Fit view", children: _jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", strokeWidth: 1.5, children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15" }) }) })] }));
16
+ }
17
+ // Default library — created once, reused
18
+ let _defaultLibrary = null;
19
+ function getDefaultLibrary() {
20
+ if (!_defaultLibrary) {
21
+ const circuitMap = new Map();
22
+ _defaultLibrary = {
23
+ resolveCircuit: (name) => circuitMap.get(name),
24
+ getAllPrimitiveNames: () => [...circuitMap.entries()].filter(([, c]) => c.implementation.kind === 'primitive').map(([n]) => n),
25
+ addCircuit: (c) => { circuitMap.set(c.name, c); },
26
+ };
27
+ }
28
+ return _defaultLibrary;
29
+ }
30
+ function CircuitCanvasInner({ circuit, componentLibrary, portValues, sequentialState, draggable = true, layout, onToggleNode, onSetNodeValue, onLoadMemory, onNodeDoubleClick: onNodeDoubleClickProp, height = "100%", focus, className, renderEmptyState, renderOverlay, nodeTypes: nodeTypesOverride, edgeTypes: edgeTypesOverride, showControls = true, showPortLabels, onPortClick: onPortClickProp, glowUnconnected, theme: themeProp, panOnMobile = false, onRequestRemount, }) {
31
+ const detectedTheme = useDetectTheme();
32
+ const theme = themeProp ?? detectedTheme;
33
+ const isMobile = useIsMobile();
34
+ const resolvedNodeTypes = nodeTypesOverride ?? NODE_TYPES;
35
+ const resolvedEdgeTypes = edgeTypesOverride ?? EDGE_TYPES;
36
+ const library = componentLibrary ?? getDefaultLibrary();
37
+ const focusLabels = useMemo(() => {
38
+ if (!focus)
39
+ return null;
40
+ return new Set(Array.isArray(focus) ? focus : [focus]);
41
+ }, [focus]);
42
+ const cleanedCircuit = useMemo(() => {
43
+ return circuit ? cleanCircuitLabels(circuit) : null;
44
+ }, [circuit]);
45
+ // Run engine only when no layout is provided.
46
+ const { metadata: computedMetadata } = useLayout(layout ? null : cleanedCircuit);
47
+ const metadata = useMemo(() => {
48
+ if (!cleanedCircuit)
49
+ return { components: {}, connections: {} };
50
+ if (!layout)
51
+ return computedMetadata;
52
+ // Build MetadataState from the user-provided layout. Try label first, fall
53
+ // back to id. Nodes missing from the layout get no position.
54
+ const components = {};
55
+ for (const node of cleanedCircuit.nodes) {
56
+ const labelKey = node.label || node.id;
57
+ const pos = layout[labelKey] ?? layout[node.id];
58
+ if (pos) {
59
+ components[node.id] = { id: node.id, position: pos };
60
+ }
61
+ }
62
+ return { components, connections: {} };
63
+ }, [cleanedCircuit, computedMetadata, layout]);
64
+ const { projectedNodes, projectedEdges } = useMemo(() => {
65
+ if (!cleanedCircuit)
66
+ return { projectedNodes: [], projectedEdges: [] };
67
+ const projected = projectCircuitToReactFlow(cleanedCircuit, metadata, library, portValues ?? undefined, sequentialState ?? undefined);
68
+ const nodesWithHandlers = projected.nodes.map((node) => {
69
+ const nodeData = node.data;
70
+ const componentRef = nodeData?.componentRef;
71
+ const data = { ...node.data };
72
+ if (showPortLabels)
73
+ data.showPortLabels = true;
74
+ if (glowUnconnected)
75
+ data.glowUnconnected = true;
76
+ if (onPortClickProp) {
77
+ const label = nodeData.label || nodeData.componentRef;
78
+ data.onPortClick = (portName, portType) => onPortClickProp(label, portName, portType);
79
+ }
80
+ if (componentRef === "Input" && onSetNodeValue) {
81
+ data.onValueChange = (value) => onSetNodeValue(node.id, value);
82
+ }
83
+ if (onToggleNode &&
84
+ (componentRef === "Switch" || componentRef === "Button")) {
85
+ data.onToggle = () => onToggleNode(node.id);
86
+ }
87
+ if (onLoadMemory && (componentRef === "RV32I_InstrMem" || componentRef === "DualPortROM")) {
88
+ data.onLoadMemory = (memData) => onLoadMemory(node.id, memData);
89
+ }
90
+ return { ...node, data };
91
+ });
92
+ if (focusLabels) {
93
+ const focusedNodeIds = new Set();
94
+ for (const node of nodesWithHandlers) {
95
+ const label = node.data?.label ?? node.id;
96
+ if (focusLabels.has(label))
97
+ focusedNodeIds.add(node.id);
98
+ }
99
+ return {
100
+ projectedNodes: nodesWithHandlers.map((node) => {
101
+ const label = node.data?.label ?? node.id;
102
+ return {
103
+ ...node,
104
+ style: {
105
+ ...node.style,
106
+ opacity: focusLabels.has(label) ? 1 : 0.15,
107
+ transition: "opacity 0.2s",
108
+ },
109
+ };
110
+ }),
111
+ projectedEdges: projected.edges.map((edge) => ({
112
+ ...edge,
113
+ style: {
114
+ ...edge.style,
115
+ opacity: focusedNodeIds.has(edge.source) || focusedNodeIds.has(edge.target)
116
+ ? 1
117
+ : 0.15,
118
+ transition: "opacity 0.2s",
119
+ },
120
+ })),
121
+ };
122
+ }
123
+ return {
124
+ projectedNodes: nodesWithHandlers,
125
+ projectedEdges: projected.edges,
126
+ };
127
+ }, [
128
+ cleanedCircuit,
129
+ metadata,
130
+ library,
131
+ portValues,
132
+ sequentialState,
133
+ onToggleNode,
134
+ onSetNodeValue,
135
+ onLoadMemory,
136
+ focusLabels,
137
+ showPortLabels,
138
+ onPortClickProp,
139
+ glowUnconnected,
140
+ ]);
141
+ const [nodes, setNodes] = useState([]);
142
+ const [edges, setEdges] = useState([]);
143
+ const { fitView } = useReactFlow();
144
+ const updateNodeInternals = useUpdateNodeInternals();
145
+ const prevCircuitIdRef = useRef(null);
146
+ const prevNodeIdSetRef = useRef(new Set());
147
+ const prevPortShapeRef = useRef(new Map());
148
+ const prevNodeCountRef = useRef(0);
149
+ useLayoutEffect(() => {
150
+ const prevName = prevCircuitIdRef.current;
151
+ const prevIdSet = prevNodeIdSetRef.current;
152
+ const prevPortShape = prevPortShapeRef.current;
153
+ const newName = cleanedCircuit?.name ?? null;
154
+ const newIdSet = new Set(projectedNodes.map((n) => n.id));
155
+ // Per-node port shape signature, computed synchronously so the
156
+ // updateNodeInternals call below doesn't depend on React's setState
157
+ // batching to populate change lists.
158
+ const newPortShape = new Map();
159
+ for (const node of projectedNodes) {
160
+ const d = node.data;
161
+ const sig = `${(d.inputNames ?? []).join("|")}>${(d.outputNames ?? []).join("|")}`;
162
+ newPortShape.set(node.id, sig);
163
+ }
164
+ prevCircuitIdRef.current = newName;
165
+ prevNodeIdSetRef.current = newIdSet;
166
+ prevPortShapeRef.current = newPortShape;
167
+ const nameChanged = newName !== prevName;
168
+ // Surviving fraction = |prev ∩ new| / max(|prev|, |new|). Topology is
169
+ // considered "replaced" if less than half the node ids survive on
170
+ // either side of the change. Using max() makes the signal symmetric:
171
+ // a small→big swap (e.g. cmd-z restoring a larger circuit) scores
172
+ // the same as the matching big→small swap, so the position-merge
173
+ // path doesn't preserve stale dagre positions for the few survivors
174
+ // while new nodes land in the fresh layout — that mismatch is what
175
+ // produced overlapping switches on undo. Single/double renames stay
176
+ // above the threshold so #111's position preservation still applies.
177
+ // Guards the 0/0 case on first mount — wasBlank handles it.
178
+ let survived = 0;
179
+ for (const id of newIdSet)
180
+ if (prevIdSet.has(id))
181
+ survived++;
182
+ const denom = Math.max(prevIdSet.size, newIdSet.size);
183
+ const topologyReplaced = denom > 0 && survived / denom < 0.5;
184
+ const fullReset = nameChanged || topologyReplaced;
185
+ // Ids whose port set changed, computed synchronously from the ref.
186
+ const idsToUpdate = [];
187
+ if (!fullReset) {
188
+ for (const [id, sig] of newPortShape) {
189
+ const prevSig = prevPortShape.get(id);
190
+ if (prevSig !== undefined && prevSig !== sig)
191
+ idsToUpdate.push(id);
192
+ }
193
+ }
194
+ const wasBlank = prevNodeCountRef.current === 0;
195
+ prevNodeCountRef.current = projectedNodes.length;
196
+ setNodes((currentNodes) => {
197
+ const prevById = new Map(currentNodes.map((n) => [n.id, n]));
198
+ return projectedNodes.map((node) => {
199
+ const prev = prevById.get(node.id);
200
+ if (prev && !fullReset) {
201
+ // Light edit — keep React Flow's internal fields (measured handles)
202
+ // and the user-dragged position; only refresh data/type from projection.
203
+ return {
204
+ ...prev,
205
+ type: node.type,
206
+ data: node.data,
207
+ selectable: node.selectable,
208
+ deletable: node.deletable,
209
+ };
210
+ }
211
+ return node;
212
+ });
213
+ });
214
+ // Edges must be set in the same commit as nodes so a key-bump remount
215
+ // mounts the new React Flow with both fresh — otherwise the remount
216
+ // happens with stale edges still in state and the in-place edge update
217
+ // arrives on the next render (the bug this fix exists to avoid).
218
+ setEdges(projectedEdges);
219
+ // Topology replacement: ask the outer wrapper to remount the entire
220
+ // <ReactFlowProvider>. Keying only <ReactFlow> leaves the provider's
221
+ // Zustand store intact and stale handle ids from the previous circuit
222
+ // survive, producing bent wires when paste-over shares node ids with
223
+ // the previous circuit. Skipped on first mount (prevIdSet empty).
224
+ if (fullReset && prevIdSet.size > 0) {
225
+ onRequestRemount?.();
226
+ }
227
+ else if (idsToUpdate.length > 0) {
228
+ // Light edit with handle changes — refresh just those nodes.
229
+ requestAnimationFrame(() => updateNodeInternals(idsToUpdate));
230
+ }
231
+ // After a paste-over the remount handles fitView via React Flow's
232
+ // own `fitView` prop. The remaining case is wasBlank without a
233
+ // remount (nodes appeared after an empty state on a stable canvas).
234
+ if (projectedNodes.length > 0 && wasBlank && !fullReset) {
235
+ requestAnimationFrame(() => fitView({ padding: 0.3 }));
236
+ }
237
+ }, [projectedNodes, projectedEdges]);
238
+ const onNodesChange = useCallback((changes) => {
239
+ setNodes((nds) => applyNodeChanges(changes, nds));
240
+ }, []);
241
+ // ── Inspector stack for automatic drill-down ──
242
+ const [inspectorStack, setInspectorStack] = useState([]);
243
+ const pushInspectorLevel = useCallback((name, def, label) => {
244
+ setInspectorStack((prev) => [...prev, { componentName: name, componentDef: def, nodeLabel: label }]);
245
+ }, []);
246
+ const popInspectorLevel = useCallback(() => {
247
+ setInspectorStack((prev) => prev.slice(0, -1));
248
+ }, []);
249
+ const closeInspector = useCallback(() => {
250
+ setInspectorStack([]);
251
+ }, []);
252
+ const navigateInspector = useCallback((index) => {
253
+ setInspectorStack((prev) => prev.slice(0, index + 1));
254
+ }, []);
255
+ // Default double-click handler: opens inspector for composites
256
+ const defaultNodeDoubleClick = useCallback((nodeData) => {
257
+ if (!nodeData.isComposite)
258
+ return;
259
+ const componentDef = library.resolveCircuit(nodeData.componentRef);
260
+ if (!componentDef)
261
+ return;
262
+ if (componentDef.implementation.kind === "composite" && componentDef.nodes.length > 0) {
263
+ setInspectorStack([{ componentName: nodeData.componentRef, componentDef, nodeLabel: nodeData.label ?? nodeData.componentRef }]);
264
+ }
265
+ }, [library]);
266
+ // Use caller's handler if provided, otherwise use built-in inspector
267
+ const effectiveNodeDoubleClick = onNodeDoubleClickProp ?? defaultNodeDoubleClick;
268
+ const handleNodeDoubleClick = useCallback((_event, node) => {
269
+ effectiveNodeDoubleClick(node.data);
270
+ }, [effectiveNodeDoubleClick]);
271
+ return (_jsxs("div", { "data-embed-theme": theme, className: `bg-[var(--embed-bg-primary)] overflow-hidden relative ${className ?? ""}`, style: { height }, "aria-label": "Circuit diagram", children: [_jsxs(ReactFlow, { nodes: nodes, edges: edges, nodeTypes: resolvedNodeTypes, edgeTypes: resolvedEdgeTypes, onNodesChange: onNodesChange, onNodeDoubleClick: handleNodeDoubleClick, fitView: true, minZoom: 0.1, maxZoom: 3, fitViewOptions: {
272
+ padding: 0.3,
273
+ ...(focusLabels && {
274
+ nodes: nodes.filter((n) => {
275
+ const label = n.data?.label ?? n.id;
276
+ return focusLabels.has(label);
277
+ }),
278
+ }),
279
+ }, nodesDraggable: draggable && !isMobile, nodesConnectable: false, elementsSelectable: true, selectionOnDrag: false, panOnDrag: isMobile && !panOnMobile ? false : [1, 2], zoomOnScroll: true, zoomOnPinch: true, zoomOnDoubleClick: false, preventScrolling: false, proOptions: { hideAttribution: true }, deleteKeyCode: null, panActivationKeyCode: null, children: [_jsx(Background, { variant: BackgroundVariant.Dots, gap: 20, size: 1, color: "var(--embed-dot-color)" }), showControls && (_jsx(Panel, { position: "bottom-left", children: _jsx(CanvasControls, {}) }))] }), renderOverlay?.(), !circuit && (renderEmptyState ? renderEmptyState() : (_jsx("div", { className: "absolute inset-0 flex items-center justify-center text-[var(--embed-text-muted)]", children: "No circuit" }))), !onNodeDoubleClickProp && inspectorStack.length > 0 && (_jsx(CompositeInspectorDialog, { stack: inspectorStack, componentLibrary: library, theme: theme, onClose: closeInspector, onPopLevel: popInspectorLevel, onPushLevel: pushInspectorLevel, onNavigate: navigateInspector }))] }));
280
+ }
281
+ export function CircuitCanvas(props) {
282
+ // Keyed at the provider level so a topology-replacement remount also wipes
283
+ // React Flow's Zustand store (handle registry, cached edge routes). Keying
284
+ // <ReactFlow> alone leaves the store intact and stale handle ids from the
285
+ // previous circuit survive, which is what was producing the bent wires
286
+ // when paste-over shared input/output names with the previous circuit.
287
+ const [resetGeneration, setResetGeneration] = useState(0);
288
+ const requestRemount = useCallback(() => {
289
+ setResetGeneration((g) => g + 1);
290
+ }, []);
291
+ return (_jsx(ReactFlowProvider, { children: _jsx(CircuitCanvasInner, { ...props, onRequestRemount: requestRemount }) }, resetGeneration));
292
+ }
293
+ //# sourceMappingURL=CircuitCanvas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CircuitCanvas.js","sourceRoot":"","sources":["../../src/canvas/CircuitCanvas.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,KAAK,EACL,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,sBAAsB,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.
3
+ *
4
+ * Icon buttons (Step, Play/Pause, Reset) + cycle counter + time-travel.
5
+ * Optional: speed slider, scrubber.
6
+ * Floating style — position via parent container.
7
+ */
8
+ export interface ClockControlsProps {
9
+ cycle: number;
10
+ historyLength: number;
11
+ historyIndex: number;
12
+ isRunning: boolean;
13
+ isViewingPast: boolean;
14
+ onStep: () => void;
15
+ onRun: () => void;
16
+ onPause: () => void;
17
+ onReset: () => void;
18
+ onStepBack: () => void;
19
+ onStepForward: () => void;
20
+ onSeek?: (index: number) => void;
21
+ onSpeedChange?: (speed: number) => void;
22
+ speed?: number;
23
+ maxSpeed?: number;
24
+ showScrubber?: boolean;
25
+ /** Render as a floating pill (inspector/canvas overlay) vs inline bar (editor/embed bottom bar) */
26
+ floating?: boolean;
27
+ /** Drop the inner border + background when the parent already provides them */
28
+ chromeless?: boolean;
29
+ }
30
+ export declare function ClockControls({ cycle, historyLength, historyIndex, isRunning, isViewingPast, onStep, onRun, onPause, onReset, onStepBack, onStepForward, onSeek, onSpeedChange, speed, maxSpeed, showScrubber, floating, chromeless, }: ClockControlsProps): import("react/jsx-runtime").JSX.Element;
31
+ //# sourceMappingURL=ClockControls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClockControls.d.ts","sourceRoot":"","sources":["../../src/canvas/ClockControls.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsDH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mGAAmG;IACnG,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,aAAa,EACb,YAAY,EACZ,SAAS,EACT,aAAa,EACb,MAAM,EACN,KAAK,EACL,OAAO,EACP,OAAO,EACP,UAAU,EACV,aAAa,EACb,MAAM,EACN,aAAa,EACb,KAAS,EACT,QAAc,EACd,YAAY,EACZ,QAAQ,EACR,UAAU,GACX,EAAE,kBAAkB,2CAsFpB"}