@bhbr/minter 0.0.0-stage → 1.0.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 (327) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -2
  3. package/dist/boards/Board.d.ts +138 -0
  4. package/dist/boards/Board.d.ts.map +1 -0
  5. package/dist/boards/Board.js +1329 -0
  6. package/dist/boards/Board.js.map +1 -0
  7. package/dist/boards/BoardCreator.d.ts +8 -0
  8. package/dist/boards/BoardCreator.d.ts.map +1 -0
  9. package/dist/boards/BoardCreator.js +24 -0
  10. package/dist/boards/BoardCreator.js.map +1 -0
  11. package/dist/boards/EditableLinkHook.d.ts +2 -0
  12. package/dist/boards/EditableLinkHook.d.ts.map +1 -0
  13. package/dist/boards/EditableLinkHook.js +137 -0
  14. package/dist/boards/EditableLinkHook.js.map +1 -0
  15. package/dist/boards/EditableLinkHookView.d.ts +2 -0
  16. package/dist/boards/EditableLinkHookView.d.ts.map +1 -0
  17. package/dist/boards/EditableLinkHookView.js +42 -0
  18. package/dist/boards/EditableLinkHookView.js.map +1 -0
  19. package/dist/boards/ExpandButton.d.ts +17 -0
  20. package/dist/boards/ExpandButton.d.ts.map +1 -0
  21. package/dist/boards/ExpandButton.js +59 -0
  22. package/dist/boards/ExpandButton.js.map +1 -0
  23. package/dist/boards/ExpandedBoardIOList.d.ts +12 -0
  24. package/dist/boards/ExpandedBoardIOList.d.ts.map +1 -0
  25. package/dist/boards/ExpandedBoardIOList.js +35 -0
  26. package/dist/boards/ExpandedBoardIOList.js.map +1 -0
  27. package/dist/boards/ExpandedBoardInputList.d.ts +4 -0
  28. package/dist/boards/ExpandedBoardInputList.d.ts.map +1 -0
  29. package/dist/boards/ExpandedBoardInputList.js +4 -0
  30. package/dist/boards/ExpandedBoardInputList.js.map +1 -0
  31. package/dist/boards/ExpandedBoardOutputList.d.ts +4 -0
  32. package/dist/boards/ExpandedBoardOutputList.d.ts.map +1 -0
  33. package/dist/boards/ExpandedBoardOutputList.js +4 -0
  34. package/dist/boards/ExpandedBoardOutputList.js.map +1 -0
  35. package/dist/boards/constants.d.ts +6 -0
  36. package/dist/boards/constants.d.ts.map +1 -0
  37. package/dist/boards/constants.js +6 -0
  38. package/dist/boards/constants.js.map +1 -0
  39. package/dist/constants.d.ts +14 -0
  40. package/dist/constants.d.ts.map +1 -0
  41. package/dist/constants.js +23 -0
  42. package/dist/constants.js.map +1 -0
  43. package/dist/creators/Creator.d.ts +19 -0
  44. package/dist/creators/Creator.d.ts.map +1 -0
  45. package/dist/creators/Creator.js +54 -0
  46. package/dist/creators/Creator.js.map +1 -0
  47. package/dist/creators/DraggingCreator.d.ts +10 -0
  48. package/dist/creators/DraggingCreator.d.ts.map +1 -0
  49. package/dist/creators/DraggingCreator.js +45 -0
  50. package/dist/creators/DraggingCreator.js.map +1 -0
  51. package/dist/creators/Freehand.d.ts +16 -0
  52. package/dist/creators/Freehand.d.ts.map +1 -0
  53. package/dist/creators/Freehand.js +68 -0
  54. package/dist/creators/Freehand.js.map +1 -0
  55. package/dist/creators/SpanningCreator.d.ts +15 -0
  56. package/dist/creators/SpanningCreator.d.ts.map +1 -0
  57. package/dist/creators/SpanningCreator.js +66 -0
  58. package/dist/creators/SpanningCreator.js.map +1 -0
  59. package/dist/functions/logging.d.ts +4 -0
  60. package/dist/functions/logging.d.ts.map +1 -0
  61. package/dist/functions/logging.js +103 -0
  62. package/dist/functions/logging.js.map +1 -0
  63. package/dist/functions/math.d.ts +9 -0
  64. package/dist/functions/math.d.ts.map +1 -0
  65. package/dist/functions/math.js +85 -0
  66. package/dist/functions/math.js.map +1 -0
  67. package/dist/functions/various.d.ts +4 -0
  68. package/dist/functions/various.d.ts.map +1 -0
  69. package/dist/functions/various.js +54 -0
  70. package/dist/functions/various.js.map +1 -0
  71. package/dist/index.d.ts +77 -0
  72. package/dist/index.d.ts.map +1 -0
  73. package/dist/index.js +79 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/linkables/DependencyLink.d.ts +24 -0
  76. package/dist/linkables/DependencyLink.d.ts.map +1 -0
  77. package/dist/linkables/DependencyLink.js +70 -0
  78. package/dist/linkables/DependencyLink.js.map +1 -0
  79. package/dist/linkables/IOList.d.ts +37 -0
  80. package/dist/linkables/IOList.d.ts.map +1 -0
  81. package/dist/linkables/IOList.js +203 -0
  82. package/dist/linkables/IOList.js.map +1 -0
  83. package/dist/linkables/InputList.d.ts +7 -0
  84. package/dist/linkables/InputList.d.ts.map +1 -0
  85. package/dist/linkables/InputList.js +13 -0
  86. package/dist/linkables/InputList.js.map +1 -0
  87. package/dist/linkables/LinkBullet.d.ts +11 -0
  88. package/dist/linkables/LinkBullet.d.ts.map +1 -0
  89. package/dist/linkables/LinkBullet.js +35 -0
  90. package/dist/linkables/LinkBullet.js.map +1 -0
  91. package/dist/linkables/LinkHook.d.ts +14 -0
  92. package/dist/linkables/LinkHook.d.ts.map +1 -0
  93. package/dist/linkables/LinkHook.js +50 -0
  94. package/dist/linkables/LinkHook.js.map +1 -0
  95. package/dist/linkables/LinkOutlet.d.ts +26 -0
  96. package/dist/linkables/LinkOutlet.d.ts.map +1 -0
  97. package/dist/linkables/LinkOutlet.js +136 -0
  98. package/dist/linkables/LinkOutlet.js.map +1 -0
  99. package/dist/linkables/Linkable.d.ts +55 -0
  100. package/dist/linkables/Linkable.d.ts.map +1 -0
  101. package/dist/linkables/Linkable.js +258 -0
  102. package/dist/linkables/Linkable.js.map +1 -0
  103. package/dist/linkables/OutputList.d.ts +7 -0
  104. package/dist/linkables/OutputList.d.ts.map +1 -0
  105. package/dist/linkables/OutputList.js +16 -0
  106. package/dist/linkables/OutputList.js.map +1 -0
  107. package/dist/linkables/constants.d.ts +12 -0
  108. package/dist/linkables/constants.d.ts.map +1 -0
  109. package/dist/linkables/constants.js +16 -0
  110. package/dist/linkables/constants.js.map +1 -0
  111. package/dist/mobjects/Dependency.d.ts +11 -0
  112. package/dist/mobjects/Dependency.d.ts.map +1 -0
  113. package/dist/mobjects/Dependency.js +19 -0
  114. package/dist/mobjects/Dependency.js.map +1 -0
  115. package/dist/mobjects/MGroup.d.ts +5 -0
  116. package/dist/mobjects/MGroup.d.ts.map +1 -0
  117. package/dist/mobjects/MGroup.js +15 -0
  118. package/dist/mobjects/MGroup.js.map +1 -0
  119. package/dist/mobjects/Mobject.d.ts +138 -0
  120. package/dist/mobjects/Mobject.d.ts.map +1 -0
  121. package/dist/mobjects/Mobject.js +488 -0
  122. package/dist/mobjects/Mobject.js.map +1 -0
  123. package/dist/mobjects/Motor.d.ts +20 -0
  124. package/dist/mobjects/Motor.d.ts.map +1 -0
  125. package/dist/mobjects/Motor.js +118 -0
  126. package/dist/mobjects/Motor.js.map +1 -0
  127. package/dist/mobjects/Sensor.d.ts +112 -0
  128. package/dist/mobjects/Sensor.d.ts.map +1 -0
  129. package/dist/mobjects/Sensor.js +650 -0
  130. package/dist/mobjects/Sensor.js.map +1 -0
  131. package/dist/mobjects/UpdateCall.d.ts +17 -0
  132. package/dist/mobjects/UpdateCall.d.ts.map +1 -0
  133. package/dist/mobjects/UpdateCall.js +67 -0
  134. package/dist/mobjects/UpdateCall.js.map +1 -0
  135. package/dist/mobjects/screen_events.d.ts +38 -0
  136. package/dist/mobjects/screen_events.d.ts.map +1 -0
  137. package/dist/mobjects/screen_events.js +143 -0
  138. package/dist/mobjects/screen_events.js.map +1 -0
  139. package/dist/paper/APILoader.d.ts +10 -0
  140. package/dist/paper/APILoader.d.ts.map +1 -0
  141. package/dist/paper/APILoader.js +18 -0
  142. package/dist/paper/APILoader.js.map +1 -0
  143. package/dist/paper/Paper.d.ts +34 -0
  144. package/dist/paper/Paper.d.ts.map +1 -0
  145. package/dist/paper/Paper.js +210 -0
  146. package/dist/paper/Paper.js.map +1 -0
  147. package/dist/paper/PaperView.d.ts +5 -0
  148. package/dist/paper/PaperView.d.ts.map +1 -0
  149. package/dist/paper/PaperView.js +9 -0
  150. package/dist/paper/PaperView.js.map +1 -0
  151. package/dist/paper/getPaper.d.ts +3 -0
  152. package/dist/paper/getPaper.d.ts.map +1 -0
  153. package/dist/paper/getPaper.js +8 -0
  154. package/dist/paper/getPaper.js.map +1 -0
  155. package/dist/paper/initPaper.d.ts +2 -0
  156. package/dist/paper/initPaper.d.ts.map +1 -0
  157. package/dist/paper/initPaper.js +3 -0
  158. package/dist/paper/initPaper.js.map +1 -0
  159. package/dist/shapes/Circle.d.ts +6 -0
  160. package/dist/shapes/Circle.d.ts.map +1 -0
  161. package/dist/shapes/Circle.js +20 -0
  162. package/dist/shapes/Circle.js.map +1 -0
  163. package/dist/shapes/CircularArc.d.ts +13 -0
  164. package/dist/shapes/CircularArc.d.ts.map +1 -0
  165. package/dist/shapes/CircularArc.js +95 -0
  166. package/dist/shapes/CircularArc.js.map +1 -0
  167. package/dist/shapes/CurvedArrow.d.ts +19 -0
  168. package/dist/shapes/CurvedArrow.d.ts.map +1 -0
  169. package/dist/shapes/CurvedArrow.js +89 -0
  170. package/dist/shapes/CurvedArrow.js.map +1 -0
  171. package/dist/shapes/Line.d.ts +14 -0
  172. package/dist/shapes/Line.d.ts.map +1 -0
  173. package/dist/shapes/Line.js +33 -0
  174. package/dist/shapes/Line.js.map +1 -0
  175. package/dist/shapes/Pill.d.ts +9 -0
  176. package/dist/shapes/Pill.d.ts.map +1 -0
  177. package/dist/shapes/Pill.js +51 -0
  178. package/dist/shapes/Pill.js.map +1 -0
  179. package/dist/shapes/Rectangle.d.ts +14 -0
  180. package/dist/shapes/Rectangle.d.ts.map +1 -0
  181. package/dist/shapes/Rectangle.js +34 -0
  182. package/dist/shapes/Rectangle.js.map +1 -0
  183. package/dist/shapes/RoundedRectangle.d.ts +17 -0
  184. package/dist/shapes/RoundedRectangle.d.ts.map +1 -0
  185. package/dist/shapes/RoundedRectangle.js +86 -0
  186. package/dist/shapes/RoundedRectangle.js.map +1 -0
  187. package/dist/shapes/Square.d.ts +8 -0
  188. package/dist/shapes/Square.d.ts.map +1 -0
  189. package/dist/shapes/Square.js +25 -0
  190. package/dist/shapes/Square.js.map +1 -0
  191. package/dist/sidebar/Sidebar.d.ts +28 -0
  192. package/dist/sidebar/Sidebar.d.ts.map +1 -0
  193. package/dist/sidebar/Sidebar.js +222 -0
  194. package/dist/sidebar/Sidebar.js.map +1 -0
  195. package/dist/sidebar/SidebarView.d.ts +5 -0
  196. package/dist/sidebar/SidebarView.d.ts.map +1 -0
  197. package/dist/sidebar/SidebarView.js +9 -0
  198. package/dist/sidebar/SidebarView.js.map +1 -0
  199. package/dist/sidebar/buttons/BoardButton.d.ts +6 -0
  200. package/dist/sidebar/buttons/BoardButton.d.ts.map +1 -0
  201. package/dist/sidebar/buttons/BoardButton.js +14 -0
  202. package/dist/sidebar/buttons/BoardButton.js.map +1 -0
  203. package/dist/sidebar/buttons/ControlsButton.d.ts +5 -0
  204. package/dist/sidebar/buttons/ControlsButton.d.ts.map +1 -0
  205. package/dist/sidebar/buttons/ControlsButton.js +11 -0
  206. package/dist/sidebar/buttons/ControlsButton.js.map +1 -0
  207. package/dist/sidebar/buttons/CreativeButton.d.ts +13 -0
  208. package/dist/sidebar/buttons/CreativeButton.d.ts.map +1 -0
  209. package/dist/sidebar/buttons/CreativeButton.js +49 -0
  210. package/dist/sidebar/buttons/CreativeButton.js.map +1 -0
  211. package/dist/sidebar/buttons/DragButton.d.ts +5 -0
  212. package/dist/sidebar/buttons/DragButton.d.ts.map +1 -0
  213. package/dist/sidebar/buttons/DragButton.js +10 -0
  214. package/dist/sidebar/buttons/DragButton.js.map +1 -0
  215. package/dist/sidebar/buttons/EraseButton.d.ts +7 -0
  216. package/dist/sidebar/buttons/EraseButton.d.ts.map +1 -0
  217. package/dist/sidebar/buttons/EraseButton.js +34 -0
  218. package/dist/sidebar/buttons/EraseButton.js.map +1 -0
  219. package/dist/sidebar/buttons/LinkButton.d.ts +5 -0
  220. package/dist/sidebar/buttons/LinkButton.d.ts.map +1 -0
  221. package/dist/sidebar/buttons/LinkButton.js +9 -0
  222. package/dist/sidebar/buttons/LinkButton.js.map +1 -0
  223. package/dist/sidebar/buttons/SidebarButton.d.ts +72 -0
  224. package/dist/sidebar/buttons/SidebarButton.d.ts.map +1 -0
  225. package/dist/sidebar/buttons/SidebarButton.js +369 -0
  226. package/dist/sidebar/buttons/SidebarButton.js.map +1 -0
  227. package/dist/sidebar/buttons/SidebarButtonView.d.ts +6 -0
  228. package/dist/sidebar/buttons/SidebarButtonView.d.ts.map +1 -0
  229. package/dist/sidebar/buttons/SidebarButtonView.js +8 -0
  230. package/dist/sidebar/buttons/SidebarButtonView.js.map +1 -0
  231. package/dist/sidebar/buttons/ToggleButton.d.ts +17 -0
  232. package/dist/sidebar/buttons/ToggleButton.d.ts.map +1 -0
  233. package/dist/sidebar/buttons/ToggleButton.js +79 -0
  234. package/dist/sidebar/buttons/ToggleButton.js.map +1 -0
  235. package/dist/sidebar/buttons/button_geometry.d.ts +10 -0
  236. package/dist/sidebar/buttons/button_geometry.d.ts.map +1 -0
  237. package/dist/sidebar/buttons/button_geometry.js +15 -0
  238. package/dist/sidebar/buttons/button_geometry.js.map +1 -0
  239. package/dist/sidebar/getSidebar.d.ts +3 -0
  240. package/dist/sidebar/getSidebar.d.ts.map +1 -0
  241. package/dist/sidebar/getSidebar.js +8 -0
  242. package/dist/sidebar/getSidebar.js.map +1 -0
  243. package/dist/sidebar/initSidebar.d.ts +2 -0
  244. package/dist/sidebar/initSidebar.d.ts.map +1 -0
  245. package/dist/sidebar/initSidebar.js +3 -0
  246. package/dist/sidebar/initSidebar.js.map +1 -0
  247. package/dist/ui/Checkbox.d.ts +20 -0
  248. package/dist/ui/Checkbox.d.ts.map +1 -0
  249. package/dist/ui/Checkbox.js +71 -0
  250. package/dist/ui/Checkbox.js.map +1 -0
  251. package/dist/ui/InputTextBox.d.ts +24 -0
  252. package/dist/ui/InputTextBox.d.ts.map +1 -0
  253. package/dist/ui/InputTextBox.js +104 -0
  254. package/dist/ui/InputTextBox.js.map +1 -0
  255. package/dist/ui/LinkableInputTextBox.d.ts +11 -0
  256. package/dist/ui/LinkableInputTextBox.d.ts.map +1 -0
  257. package/dist/ui/LinkableInputTextBox.js +32 -0
  258. package/dist/ui/LinkableInputTextBox.js.map +1 -0
  259. package/dist/ui/Popover.d.ts +34 -0
  260. package/dist/ui/Popover.d.ts.map +1 -0
  261. package/dist/ui/Popover.js +187 -0
  262. package/dist/ui/Popover.js.map +1 -0
  263. package/dist/ui/RadioButton.d.ts +16 -0
  264. package/dist/ui/RadioButton.d.ts.map +1 -0
  265. package/dist/ui/RadioButton.js +53 -0
  266. package/dist/ui/RadioButton.js.map +1 -0
  267. package/dist/ui/RadioButtonList.d.ts +16 -0
  268. package/dist/ui/RadioButtonList.d.ts.map +1 -0
  269. package/dist/ui/RadioButtonList.js +71 -0
  270. package/dist/ui/RadioButtonList.js.map +1 -0
  271. package/dist/ui/Scroll.d.ts +10 -0
  272. package/dist/ui/Scroll.d.ts.map +1 -0
  273. package/dist/ui/Scroll.js +30 -0
  274. package/dist/ui/Scroll.js.map +1 -0
  275. package/dist/ui/SimpleButton.d.ts +16 -0
  276. package/dist/ui/SimpleButton.d.ts.map +1 -0
  277. package/dist/ui/SimpleButton.js +61 -0
  278. package/dist/ui/SimpleButton.js.map +1 -0
  279. package/dist/ui/TextLabel.d.ts +19 -0
  280. package/dist/ui/TextLabel.d.ts.map +1 -0
  281. package/dist/ui/TextLabel.js +21 -0
  282. package/dist/ui/TextLabel.js.map +1 -0
  283. package/dist/ui/TextLabelView.d.ts +15 -0
  284. package/dist/ui/TextLabelView.d.ts.map +1 -0
  285. package/dist/ui/TextLabelView.js +52 -0
  286. package/dist/ui/TextLabelView.js.map +1 -0
  287. package/dist/views/Color.d.ts +31 -0
  288. package/dist/views/Color.d.ts.map +1 -0
  289. package/dist/views/Color.js +107 -0
  290. package/dist/views/Color.js.map +1 -0
  291. package/dist/views/Frame.d.ts +64 -0
  292. package/dist/views/Frame.d.ts.map +1 -0
  293. package/dist/views/Frame.js +132 -0
  294. package/dist/views/Frame.js.map +1 -0
  295. package/dist/views/ImageView.d.ts +10 -0
  296. package/dist/views/ImageView.d.ts.map +1 -0
  297. package/dist/views/ImageView.js +28 -0
  298. package/dist/views/ImageView.js.map +1 -0
  299. package/dist/views/View.d.ts +45 -0
  300. package/dist/views/View.d.ts.map +1 -0
  301. package/dist/views/View.js +181 -0
  302. package/dist/views/View.js.map +1 -0
  303. package/dist/vmobjects/CurvedLine.d.ts +14 -0
  304. package/dist/vmobjects/CurvedLine.d.ts.map +1 -0
  305. package/dist/vmobjects/CurvedLine.js +66 -0
  306. package/dist/vmobjects/CurvedLine.js.map +1 -0
  307. package/dist/vmobjects/CurvedShape.d.ts +5 -0
  308. package/dist/vmobjects/CurvedShape.d.ts.map +1 -0
  309. package/dist/vmobjects/CurvedShape.js +12 -0
  310. package/dist/vmobjects/CurvedShape.js.map +1 -0
  311. package/dist/vmobjects/Polygon.d.ts +5 -0
  312. package/dist/vmobjects/Polygon.d.ts.map +1 -0
  313. package/dist/vmobjects/Polygon.js +12 -0
  314. package/dist/vmobjects/Polygon.js.map +1 -0
  315. package/dist/vmobjects/PolygonalLine.d.ts +9 -0
  316. package/dist/vmobjects/PolygonalLine.d.ts.map +1 -0
  317. package/dist/vmobjects/PolygonalLine.js +34 -0
  318. package/dist/vmobjects/PolygonalLine.js.map +1 -0
  319. package/dist/vmobjects/VMobject.d.ts +58 -0
  320. package/dist/vmobjects/VMobject.d.ts.map +1 -0
  321. package/dist/vmobjects/VMobject.js +165 -0
  322. package/dist/vmobjects/VMobject.js.map +1 -0
  323. package/dist/vmobjects/VView.d.ts +19 -0
  324. package/dist/vmobjects/VView.d.ts.map +1 -0
  325. package/dist/vmobjects/VView.js +61 -0
  326. package/dist/vmobjects/VView.js.map +1 -0
  327. package/package.json +43 -4
@@ -0,0 +1,1329 @@
1
+ import { Linkable } from '../linkables/Linkable.js';
2
+ import { DependencyLink } from '../linkables/DependencyLink.js';
3
+ import { LinkBullet } from '../linkables/LinkBullet.js';
4
+ import { RoundedRectangle } from '../shapes/RoundedRectangle.js';
5
+ import { vertexOrigin, vertexCopy, vertexAdd, vertexSubtract, vertexIsCloseTo } from '@bhbr/affr2';
6
+ import { remove } from '@bhbr/betray';
7
+ import { Freehand } from '../creators/Freehand.js';
8
+ import { ExpandButton } from './ExpandButton.js';
9
+ //import { EditableLinkHook } from './EditableLinkHook'
10
+ import { Color } from '../views/Color.js';
11
+ import { Creator } from '../creators/Creator.js';
12
+ import { ScreenEventDevice, screenEventDevice, ScreenEventHandler, isTouchDevice, separateSidebar } from '../mobjects/screen_events.js';
13
+ import { convertArrayToString } from '@bhbr/betray';
14
+ import { getPaper } from '../paper/getPaper.js';
15
+ import { ExpandedBoardInputList } from './ExpandedBoardInputList.js';
16
+ import { ExpandedBoardOutputList } from './ExpandedBoardOutputList.js';
17
+ import { HELP_TEXT_LABEL_WIDTH, HELP_TEXT_LABEL_HEIGHT } from './constants.js';
18
+ import { IO_LIST_OFFSET, SNAPPING_DISTANCE } from '../linkables/constants.js';
19
+ import { SIDEBAR_WIDTH } from '../constants.js';
20
+ import { MGroup } from '../mobjects/MGroup.js';
21
+ import { TextLabel } from '../ui/TextLabel.js';
22
+ export class BoardContent extends MGroup {
23
+ }
24
+ export class Board extends Linkable {
25
+ /*
26
+ A board can be expanded into a full screen view, in which
27
+ submobjects ('contentChildren') can be created with a pen
28
+ and custom sidebar buttons.
29
+
30
+ In addition, the content children can be linked (those that
31
+ are linkable) together.
32
+
33
+ The content children can also be dragged and panned.
34
+ */
35
+ defaults() {
36
+ return {
37
+ contentChildren: [],
38
+ focusedChild: null,
39
+ content: new BoardContent(),
40
+ expandButton: new ExpandButton(),
41
+ links: [],
42
+ background: new RoundedRectangle({
43
+ anchor: vertexOrigin(),
44
+ cornerRadius: 15,
45
+ screenEventHandler: ScreenEventHandler.Parent,
46
+ fillColor: (isTouchDevice && separateSidebar) ? Color.clear() : Color.black(),
47
+ fillOpacity: 1.0,
48
+ strokeColor: Color.gray(0.2),
49
+ strokeWidth: 1.0,
50
+ drawShadow: true
51
+ }),
52
+ expandedPadding: 20,
53
+ screenEventHandler: ScreenEventHandler.Self,
54
+ expanded: false,
55
+ compactWidth: 400, // defined below in the section 'expand and contract'
56
+ compactHeight: 300, // idem
57
+ compactAnchor: vertexOrigin(),
58
+ creationConstructors: {},
59
+ buttonNames: [
60
+ 'DragButton'
61
+ ],
62
+ globals: {},
63
+ creationStroke: [],
64
+ creationMode: 'draw',
65
+ creator: null,
66
+ sidebar: null,
67
+ expandedInputList: new ExpandedBoardInputList(),
68
+ expandedOutputList: new ExpandedBoardOutputList(),
69
+ linksEditable: true,
70
+ editingLinkName: false,
71
+ openLink: null,
72
+ openHook: null,
73
+ openBullet: null,
74
+ compatibleHooks: [],
75
+ creationTool: null,
76
+ isShowingLinks: false,
77
+ isShowingControls: false,
78
+ allowingDrag: false,
79
+ helpTextLabel: new TextLabel({
80
+ frameHeight: HELP_TEXT_LABEL_HEIGHT,
81
+ frameWidth: HELP_TEXT_LABEL_WIDTH,
82
+ text: '',
83
+ horizontalAlign: 'center'
84
+ }),
85
+ helpTexts: {
86
+ 'drag': 'Drag objects or pan the board. Slide this button to the right to lock.',
87
+ },
88
+ // zoomStartCenter: [0, 0],
89
+ // zoomStartScale: 1,
90
+ };
91
+ }
92
+ mutabilities() {
93
+ return {
94
+ contentChildren: 'never',
95
+ content: 'never',
96
+ expandButton: 'never',
97
+ linkMap: 'never',
98
+ background: 'never',
99
+ expandedPadding: 'in_subclass'
100
+ };
101
+ }
102
+ setup() {
103
+ super.setup();
104
+ let w = window;
105
+ this.update({
106
+ frameWidth: this.expanded ? this.expandedWidth() : this.compactWidth,
107
+ frameHeight: this.expanded ? this.expandedHeight() : this.compactHeight,
108
+ anchor: this.expanded ? this.expandedAnchor() : vertexCopy(this.compactAnchor)
109
+ });
110
+ this.addDependency('frameWidth', this.background, 'width');
111
+ this.addDependency('frameHeight', this.background, 'height');
112
+ this.content.view.div.style['clip-path'] = 'polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)';
113
+ // TODO: clip at rounded corners as well
114
+ this.add(this.background);
115
+ this.add(this.content);
116
+ this.moveToTop(this.inputList);
117
+ this.moveToTop(this.outputList);
118
+ this.add(this.expandButton);
119
+ // this.expandedInputList.update({
120
+ // height: EXPANDED_IO_LIST_HEIGHT,
121
+ // width: this.expandedWidth() - this.expandButton.view.frame.width - 2 * EXPANDED_IO_LIST_INSET,
122
+ // anchor: [this.expandButton.view.frame.width + EXPANDED_IO_LIST_INSET, EXPANDED_IO_LIST_INSET],
123
+ // mobject: this,
124
+ // outletProperties: this.inputProperties
125
+ // })
126
+ // this.add(this.expandedInputList)
127
+ // this.expandedOutputList.update({
128
+ // height: EXPANDED_IO_LIST_HEIGHT,
129
+ // width: this.expandedWidth() - this.expandButton.view.frame.width - 2 * EXPANDED_IO_LIST_INSET,
130
+ // anchor: [this.expandButton.view.frame.width + EXPANDED_IO_LIST_INSET, this.expandedHeight() - EXPANDED_IO_LIST_INSET - EXPANDED_IO_LIST_HEIGHT],
131
+ // mobject: this,
132
+ // outletProperties: this.outputProperties
133
+ // })
134
+ // this.add(this.expandedOutputList)
135
+ if (this.contracted) {
136
+ this.contractStateChange();
137
+ this.inputList.view.show();
138
+ this.outputList.view.show();
139
+ this.expandedInputList.view.hide();
140
+ this.expandedOutputList.view.hide();
141
+ }
142
+ else {
143
+ this.expandStateChange();
144
+ this.inputList.view.hide();
145
+ this.outputList.view.hide();
146
+ this.expandedInputList.view.show();
147
+ this.expandedOutputList.view.show();
148
+ }
149
+ this.hideLinksOfContent();
150
+ this.setControlsVisibility(false);
151
+ let newAnchor = [0.5 * (this.frameWidth - HELP_TEXT_LABEL_WIDTH - SIDEBAR_WIDTH), 20];
152
+ this.helpTextLabel.update({
153
+ anchor: newAnchor,
154
+ frameWidth: HELP_TEXT_LABEL_WIDTH
155
+ });
156
+ this.add(this.helpTextLabel);
157
+ this.helpTextLabel.view.hide();
158
+ }
159
+ update(args = {}, redraw = true) {
160
+ super.update(args, false);
161
+ this.background.update({
162
+ width: this.view.frame.width,
163
+ height: this.view.frame.height,
164
+ frameWidth: this.view.frame.width,
165
+ frameHeight: this.view.frame.height
166
+ });
167
+ this.content.update({
168
+ width: this.view.frame.width,
169
+ height: this.view.frame.height,
170
+ frameWidth: this.view.frame.width,
171
+ frameHeight: this.view.frame.height
172
+ });
173
+ if (redraw) {
174
+ this.view.redraw();
175
+ }
176
+ }
177
+ expandedAnchor() {
178
+ return [this.expandedPadding, this.expandedPadding];
179
+ }
180
+ expandedWidth() {
181
+ return window.innerWidth - 2 * this.expandedPadding;
182
+ }
183
+ expandedHeight() {
184
+ return window.innerHeight - 2 * this.expandedPadding;
185
+ }
186
+ getCompactWidth() {
187
+ return this.compactWidth;
188
+ }
189
+ getCompactHeight() {
190
+ return this.compactHeight;
191
+ }
192
+ get contracted() {
193
+ return !this.expanded;
194
+ }
195
+ set contracted(newValue) {
196
+ this.expanded = !newValue;
197
+ }
198
+ expandStateChange() {
199
+ if (!this.expanded) {
200
+ this.update({ expanded: true });
201
+ }
202
+ getPaper().expandedMobject = this;
203
+ this.enableContent();
204
+ if (this.parent != undefined) {
205
+ this.parent.moveToTop(this);
206
+ }
207
+ this.expandButton.label.update({
208
+ text: '–'
209
+ });
210
+ for (let link of this.links) {
211
+ this.moveToTop(link);
212
+ }
213
+ this.sidebar = getPaper().sidebar;
214
+ if (this.sidebar === null || this.sidebar === undefined) {
215
+ let sidebarDiv = document.querySelector('#sidebar_id');
216
+ if (sidebarDiv != null) {
217
+ let sidebarView = sidebarDiv['view'];
218
+ if (sidebarView != null) {
219
+ this.sidebar = sidebarView.mobject;
220
+ }
221
+ getPaper().sidebar = this.sidebar;
222
+ }
223
+ }
224
+ }
225
+ expand() {
226
+ this.animate({
227
+ frameWidth: this.expandedWidth(),
228
+ frameHeight: this.expandedHeight(),
229
+ anchor: this.expandedAnchor()
230
+ }, 0.5);
231
+ this.expandStateChange();
232
+ this.initSidebar();
233
+ }
234
+ initSidebar() {
235
+ this.messageSidebar({ 'init': convertArrayToString(this.buttonNames) });
236
+ }
237
+ contractStateChange() {
238
+ this.expanded = false;
239
+ this.disableContent();
240
+ if (this.parent) {
241
+ getPaper().expandedMobject = this.board;
242
+ }
243
+ this.expandButton.label.update({
244
+ text: '+'
245
+ });
246
+ this.expandedInputList.view.hide();
247
+ this.expandedOutputList.view.hide();
248
+ this.inputList.update({
249
+ anchor: [0.5 * (this.compactWidth - this.inputList.view.frame.width), -IO_LIST_OFFSET - this.inputList.view.frame.height]
250
+ }, true);
251
+ this.outputList.update({
252
+ anchor: [0.5 * (this.compactWidth - this.outputList.view.frame.width), IO_LIST_OFFSET]
253
+ }, true);
254
+ if (this.board !== null) {
255
+ this.messageSidebar({ 'init': convertArrayToString(this.board.buttonNames) });
256
+ }
257
+ this.sidebar = null;
258
+ }
259
+ contract() {
260
+ this.animate({
261
+ frameWidth: this.compactWidth,
262
+ frameHeight: this.compactHeight,
263
+ anchor: this.compactAnchor
264
+ }, 0.5);
265
+ this.contractStateChange();
266
+ }
267
+ toggleViewState() {
268
+ if (this.expanded) {
269
+ this.contract();
270
+ }
271
+ else {
272
+ this.expand();
273
+ }
274
+ }
275
+ disableContent() {
276
+ for (let mob of this.contentChildren) {
277
+ if (mob.sensor.screenEventHandler == ScreenEventHandler.Self) {
278
+ mob.disable();
279
+ }
280
+ }
281
+ }
282
+ enableContent() {
283
+ for (let mob of this.contentChildren) {
284
+ if (mob.sensor.savedScreenEventHandler == ScreenEventHandler.Self) {
285
+ mob.enable();
286
+ }
287
+ }
288
+ }
289
+ showShadow() {
290
+ super.showShadow();
291
+ this.background.showShadow();
292
+ }
293
+ hideShadow() {
294
+ super.hideShadow();
295
+ this.background.hideShadow();
296
+ }
297
+ addToContent(mob) {
298
+ this.content.add(mob);
299
+ this.contentChildren.push(mob);
300
+ if (this.contracted) {
301
+ mob.disable();
302
+ }
303
+ if (this.expandButton.view.visible) {
304
+ // exception: Paper
305
+ this.moveToTop(this.expandButton);
306
+ }
307
+ if (mob instanceof Linkable) {
308
+ mob.setLinksVisibility(this.isShowingLinks);
309
+ mob.setControlsVisibility(this.isShowingControls);
310
+ }
311
+ if (mob instanceof Board) {
312
+ if (mob.constructor.name == 'Construction') {
313
+ return;
314
+ }
315
+ mob.background.update({
316
+ fillColor: this.background.view.fillColor.brighten(0.1)
317
+ });
318
+ }
319
+ }
320
+ removeFromContent(mob) {
321
+ remove(this.contentChildren, mob);
322
+ this.content.remove(mob);
323
+ }
324
+ setInternalDragging(value) {
325
+ if (value == this.allowingDrag) {
326
+ return;
327
+ }
328
+ this.allowingDrag = value;
329
+ this.setPanning(value);
330
+ // if (this.isShowingLinks) {
331
+ // log('disable linking, but still show links')
332
+ // this.setLinking(false)
333
+ // this.showLinksOfContent()
334
+ // }
335
+ for (let mob of this.contentChildren) {
336
+ mob.setDragging(value);
337
+ }
338
+ }
339
+ handleMessage(key, value) {
340
+ if (value === '0') {
341
+ value = false;
342
+ }
343
+ if (value === '1') {
344
+ value = true;
345
+ }
346
+ switch (key) {
347
+ case 'drag':
348
+ this.setInternalDragging(value);
349
+ this.helpTextLabel.update({
350
+ text: this.helpTexts['drag']
351
+ });
352
+ if (value) {
353
+ this.helpTextLabel.view.show();
354
+ }
355
+ else {
356
+ this.helpTextLabel.view.hide();
357
+ }
358
+ break;
359
+ case 'link':
360
+ if (value === this.isShowingLinks) {
361
+ break;
362
+ }
363
+ this.setLinking(value);
364
+ this.setControlsVisibility(!value && this.isShowingControls);
365
+ this.helpTextLabel.update({
366
+ text: this.helpTexts['link']
367
+ });
368
+ if (value) {
369
+ this.helpTextLabel.view.show();
370
+ }
371
+ else {
372
+ this.helpTextLabel.view.hide();
373
+ }
374
+ break;
375
+ case 'show controls':
376
+ if (value === this.isShowingControls) {
377
+ return;
378
+ }
379
+ this.helpTextLabel.update({
380
+ text: this.helpTexts['show controls']
381
+ });
382
+ if (value) {
383
+ this.helpTextLabel.view.show();
384
+ }
385
+ else {
386
+ this.helpTextLabel.view.hide();
387
+ }
388
+ this.setControlsVisibility(value);
389
+ this.isShowingControls = value;
390
+ break;
391
+ case 'show help':
392
+ if (value) {
393
+ this.helpTextLabel.view.show();
394
+ }
395
+ else {
396
+ this.helpTextLabel.view.hide();
397
+ }
398
+ break;
399
+ case 'create':
400
+ this.enableContent();
401
+ this.creationMode = value;
402
+ if (this.creator == null) {
403
+ // create a dummy creator just to display the help text
404
+ // little hack, I know
405
+ let dummyCreator = this.createCreator(this.creationMode);
406
+ this.helpTextLabel.update({
407
+ text: dummyCreator.helpText
408
+ });
409
+ if (value) {
410
+ this.helpTextLabel.view.show();
411
+ }
412
+ else {
413
+ this.helpTextLabel.view.hide();
414
+ }
415
+ return;
416
+ }
417
+ this.remove(this.creator);
418
+ this.creator = this.createCreator(this.creationMode);
419
+ this.creator.update({
420
+ anchor: (this.creationMode == 'draw') ? [0, 0] : this.creationStroke[0]
421
+ });
422
+ //this.add(this.creator)
423
+ this.helpTextLabel.update({
424
+ text: this.creator.helpText
425
+ });
426
+ if (value) {
427
+ this.helpTextLabel.view.show();
428
+ }
429
+ else {
430
+ this.helpTextLabel.view.hide();
431
+ }
432
+ break;
433
+ case 'erase':
434
+ this.setEraser(value);
435
+ this.helpTextLabel.update({
436
+ text: this.helpTexts['erase']
437
+ });
438
+ if (value) {
439
+ this.helpTextLabel.view.show();
440
+ }
441
+ else {
442
+ this.helpTextLabel.view.hide();
443
+ }
444
+ break;
445
+ case 'restart':
446
+ if (value) {
447
+ this.restart();
448
+ }
449
+ this.helpTextLabel.update({
450
+ text: this.helpTexts['restart']
451
+ });
452
+ if (!value) { // merely touch down
453
+ this.helpTextLabel.view.show();
454
+ }
455
+ else {
456
+ this.helpTextLabel.view.hide();
457
+ }
458
+ break;
459
+ default:
460
+ break;
461
+ }
462
+ }
463
+ setEraser(erasing) {
464
+ if (erasing && this.creationMode !== 'erase') {
465
+ this.sensor.setMouseMethodsTo(this.startErasing.bind(this), this.erasing.bind(this), this.endErasing.bind(this));
466
+ this.sensor.setPenMethodsTo(this.startErasing.bind(this), this.erasing.bind(this), this.endErasing.bind(this));
467
+ this.sensor.setTouchMethodsTo(this.startErasing.bind(this), this.erasing.bind(this), this.endErasing.bind(this));
468
+ this.sensor.onMouseClick = this.onTap.bind(this);
469
+ this.sensor.onPenTap = this.onTap.bind(this);
470
+ this.sensor.onTouchTap = this.onTap.bind(this);
471
+ this.update({
472
+ creationMode: 'erase'
473
+ });
474
+ }
475
+ else if (!erasing && this.creationMode == 'erase') {
476
+ this.sensor.restoreMouseMethods();
477
+ this.sensor.restorePenMethods();
478
+ this.sensor.restoreTouchMethods();
479
+ this.handleMessage('create', 'draw');
480
+ }
481
+ }
482
+ contentChildrenContaining(p) {
483
+ let mobs = [];
484
+ for (let child of this.contentChildren) {
485
+ if (child.frame.contains(p)) {
486
+ mobs.push(child);
487
+ }
488
+ }
489
+ return mobs;
490
+ }
491
+ firstContentChildContaining(p) {
492
+ for (let child of this.contentChildren) {
493
+ if (child.frame.contains(p, 5)) {
494
+ return child;
495
+ }
496
+ }
497
+ return null;
498
+ }
499
+ ioListContaining(p) {
500
+ let mobs = [];
501
+ for (let child of this.contentChildren) {
502
+ if (!(child instanceof Linkable)) {
503
+ continue;
504
+ }
505
+ let q = vertexSubtract(p, child.anchor);
506
+ if (child.inputList.frame.contains(q)) {
507
+ mobs.push(child.inputList);
508
+ }
509
+ if (child.outputList.frame.contains(q)) {
510
+ mobs.push(child.outputList);
511
+ }
512
+ }
513
+ return mobs;
514
+ }
515
+ firstIOListContaining(p) {
516
+ for (let child of this.contentChildren) {
517
+ if (!(child instanceof Linkable)) {
518
+ continue;
519
+ }
520
+ let q = vertexSubtract(p, child.anchor);
521
+ if (child.inputList.frame.contains(q)) {
522
+ return child.inputList;
523
+ }
524
+ if (child.outputList.frame.contains(q)) {
525
+ return child.outputList;
526
+ }
527
+ }
528
+ return null;
529
+ }
530
+ startErasing(e) {
531
+ this.erasing(e);
532
+ }
533
+ erasing(e) {
534
+ let mob = this.firstContentChildContaining(this.sensor.localEventVertex(e));
535
+ if (mob) {
536
+ this.removeFromContent(mob);
537
+ let linksToBeRemoved = [];
538
+ for (let link of this.links) {
539
+ if (link.startHook.outlet.ioList.mobject == mob || link.endHook.outlet.ioList.mobject == mob) {
540
+ link.startHook.update({
541
+ linked: false
542
+ });
543
+ link.startHook.outlet.removeHook();
544
+ link.endHook.update({
545
+ linked: false
546
+ });
547
+ if (link.dependency.kind == 'action') {
548
+ link.endHook.outlet.removeHook();
549
+ }
550
+ linksToBeRemoved.push(link);
551
+ this.remove(link);
552
+ }
553
+ }
554
+ for (let link of linksToBeRemoved) {
555
+ remove(this.links, link);
556
+ }
557
+ }
558
+ }
559
+ endErasing(e) { }
560
+ restart() {
561
+ this.setEraser(false);
562
+ var child = this.contentChildren.pop();
563
+ while (child !== undefined) {
564
+ this.content.remove(child);
565
+ child = this.contentChildren.pop();
566
+ }
567
+ for (let child of this.children) {
568
+ if (child instanceof Creator) {
569
+ this.remove(child);
570
+ }
571
+ }
572
+ for (let link of this.links) {
573
+ this.content.remove(link);
574
+ }
575
+ if (this.openLink) { // edge case
576
+ this.content.remove(this.openLink);
577
+ }
578
+ }
579
+ setControlsVisibility(visible) {
580
+ for (let mob of this.contentChildren) {
581
+ if (mob instanceof Linkable) {
582
+ mob.setControlsVisibility(visible);
583
+ }
584
+ }
585
+ }
586
+ createCreator(type) {
587
+ switch (type) {
588
+ case 'draw':
589
+ if (this.creationTool == ScreenEventDevice.Finger) {
590
+ return new Creator();
591
+ }
592
+ let fh = new Freehand({
593
+ creationStroke: this.creationStroke
594
+ });
595
+ return fh;
596
+ default:
597
+ let cons = this.creationConstructors[type];
598
+ let cm = new cons({
599
+ creationStroke: this.creationStroke
600
+ });
601
+ if (cm.creation instanceof Linkable) {
602
+ cm.creation.setLinksVisibility(this.isShowingLinks);
603
+ cm.creation.setControlsVisibility(this.isShowingControls);
604
+ }
605
+ return cm;
606
+ }
607
+ }
608
+ onPointerDown(e) {
609
+ if (this.focusedChild) {
610
+ this.focusedChild.blur();
611
+ }
612
+ if (this.creationMode !== 'erase') {
613
+ this.startCreating(e);
614
+ }
615
+ }
616
+ onTap(e) {
617
+ if (this.creationMode == 'erase') {
618
+ this.messageSidebar({ 'buttonUp': 'erase' });
619
+ this.setEraser(false);
620
+ this.update({ creationMode: 'draw' });
621
+ this.sensor.onMouseClick = this.sensor.savedOnMouseClick;
622
+ this.sensor.onPenTap = this.sensor.savedOnPenTap;
623
+ this.sensor.onTouchTap = this.sensor.savedOnTouchTap;
624
+ }
625
+ }
626
+ focusOn(child) {
627
+ this.focusedChild = child;
628
+ getPaper().activeKeyboard = false;
629
+ if (!this.sidebar) {
630
+ return;
631
+ }
632
+ for (let button of this.sidebar.buttons) {
633
+ button.activeKeyboard = false;
634
+ }
635
+ }
636
+ blurFocusedChild() {
637
+ this.focusedChild = null;
638
+ getPaper().activeKeyboard = true;
639
+ if (!this.sidebar) {
640
+ return;
641
+ }
642
+ for (let button of this.sidebar.buttons) {
643
+ button.activeKeyboard = true;
644
+ }
645
+ }
646
+ startCreating(e) {
647
+ this.creationTool = screenEventDevice(e);
648
+ if (this.creationTool == ScreenEventDevice.Finger && this.creationMode == 'draw') {
649
+ return;
650
+ }
651
+ this.creationStroke.push(this.sensor.localEventVertex(e));
652
+ this.creator = this.createCreator(this.creationMode);
653
+ this.add(this.creator);
654
+ }
655
+ onPointerMove(e) {
656
+ if (this.contracted) {
657
+ return;
658
+ }
659
+ if (this.creationStroke.length == 0) {
660
+ return;
661
+ }
662
+ this.creating(e);
663
+ }
664
+ creating(e) {
665
+ if (this.creator === null) {
666
+ return;
667
+ }
668
+ if (this.creationTool == ScreenEventDevice.Finger && this.creationMode == 'draw') {
669
+ return;
670
+ }
671
+ let v = this.sensor.localEventVertex(e);
672
+ this.creationStroke.push(v);
673
+ this.creator.updateFromTip(v);
674
+ }
675
+ onPointerUp(e) {
676
+ if (this.contracted) {
677
+ return;
678
+ }
679
+ this.endCreating(e);
680
+ }
681
+ endCreating(e) {
682
+ this.creationStroke = [];
683
+ this.creationTool = null;
684
+ this.creationMode = 'draw';
685
+ if (this.creator !== null) {
686
+ this.creator.dissolve();
687
+ this.helpTextLabel.view.hide();
688
+ }
689
+ this.messageSidebar({ 'button': 'collapse' });
690
+ }
691
+ startPanning(e) {
692
+ let target = this.sensor.eventTarget;
693
+ // if (e instanceof TouchEvent) {
694
+ // if (e.touches.length == 2) {
695
+ // this.startZooming(e)
696
+ // return
697
+ // }
698
+ // }
699
+ this.panPointStart = this.sensor.localEventVertex(e);
700
+ for (let mob of this.contentChildren) {
701
+ mob.dragAnchorStart = vertexCopy(mob.view.frame.anchor);
702
+ mob.hideShadow();
703
+ }
704
+ }
705
+ panning(e) {
706
+ // if (e instanceof TouchEvent) {
707
+ // log(e.touches.length)
708
+ // if (e.touches.length == 2) {
709
+ // this.zooming(e)
710
+ // return
711
+ // }
712
+ // } else
713
+ if (this.panPointStart == null) {
714
+ this.startPanning(e);
715
+ return;
716
+ }
717
+ let panPoint = this.sensor.localEventVertex(e);
718
+ let dr = vertexSubtract(panPoint, this.panPointStart);
719
+ for (let mob of this.contentChildren) {
720
+ if (mob.dragAnchorStart == null) {
721
+ return;
722
+ }
723
+ let newAnchor = vertexAdd(mob.dragAnchorStart, dr);
724
+ mob.update({ anchor: newAnchor });
725
+ mob.view.div.style.left = `${newAnchor[0]}px`;
726
+ mob.view.div.style.top = `${newAnchor[1]}px`;
727
+ }
728
+ this.updateLinks();
729
+ }
730
+ endPanning(e) {
731
+ this.panPointStart = null;
732
+ for (let mob of this.contentChildren) {
733
+ mob.dragAnchorStart = null;
734
+ mob.showShadow();
735
+ }
736
+ }
737
+ setPanning(flag) {
738
+ if (flag) {
739
+ this.sensor.setTouchMethodsTo(this.startPanning.bind(this), this.panning.bind(this), this.endPanning.bind(this));
740
+ this.sensor.setPenMethodsTo(this.startPanning.bind(this), this.panning.bind(this), this.endPanning.bind(this));
741
+ this.sensor.setMouseMethodsTo(this.startPanning.bind(this), this.panning.bind(this), this.endPanning.bind(this));
742
+ }
743
+ else {
744
+ this.sensor.restoreTouchMethods();
745
+ this.sensor.restorePenMethods();
746
+ this.sensor.restoreMouseMethods();
747
+ }
748
+ }
749
+ linkableChildren() {
750
+ // the content children that are linkable
751
+ // counter-example: points etc. in a construction (for now)
752
+ let arr = [];
753
+ for (let submob of this.contentChildren) {
754
+ if (submob instanceof Linkable) {
755
+ arr.push(submob);
756
+ }
757
+ }
758
+ return arr;
759
+ }
760
+ showLinksOfContent() {
761
+ // toggled by 'link' button in sidebar
762
+ for (let link of this.links) {
763
+ this.add(link);
764
+ }
765
+ for (let submob of this.linkableChildren()) {
766
+ submob.showLinks();
767
+ }
768
+ //this.expandedInputList.view.show()
769
+ //this.expandedOutputList.view.show()
770
+ }
771
+ hideLinksOfContent() {
772
+ // toggled by 'link' button in sidebar
773
+ for (let link of this.links) {
774
+ this.remove(link);
775
+ }
776
+ for (let submob of this.linkableChildren()) {
777
+ submob.hideLinks();
778
+ }
779
+ if (this.openLink) {
780
+ this.content.remove(this.openLink);
781
+ }
782
+ //this.expandedInputList.view.hide()
783
+ //this.expandedOutputList.view.hide()
784
+ this.setControlsVisibility(this.isShowingControls);
785
+ }
786
+ renameLinkableProperty(kind, oldName, newName) {
787
+ super.renameLinkableProperty(kind, oldName, newName);
788
+ let expandedList = (kind == 'input') ? this.expandedInputList : this.expandedOutputList;
789
+ expandedList.renameProperty(oldName, newName);
790
+ }
791
+ setLinking(flag) {
792
+ if (flag === this.isShowingLinks) {
793
+ return;
794
+ }
795
+ if (flag && !this.isShowingLinks) {
796
+ this.showLinksOfContent();
797
+ //this.disableContent()
798
+ this.ungreyAllHooks();
799
+ }
800
+ else if (!flag && this.isShowingLinks) { // if (!this.editingLinkName) {
801
+ this.hideLinksOfContent();
802
+ //this.enableContent()
803
+ }
804
+ this.isShowingLinks = flag;
805
+ if (flag) {
806
+ //this.disableContent()
807
+ this.sensor.setTouchMethodsTo(this.startLinking.bind(this), this.linking.bind(this), this.endLinking.bind(this));
808
+ this.sensor.setPenMethodsTo(this.startLinking.bind(this), this.linking.bind(this), this.endLinking.bind(this));
809
+ this.sensor.setMouseMethodsTo(this.startLinking.bind(this), this.linking.bind(this), this.endLinking.bind(this));
810
+ }
811
+ else {
812
+ //this.enableContent()
813
+ this.sensor.restoreTouchMethods();
814
+ this.sensor.restorePenMethods();
815
+ this.sensor.restoreMouseMethods();
816
+ }
817
+ }
818
+ startLinking(e) {
819
+ let t = this.sensor.eventTarget;
820
+ var p = this.sensor.localEventVertex(e);
821
+ let clickedHook = this.hookAtLocation(p);
822
+ if (clickedHook == null) {
823
+ // if (this.allowingDrag) {
824
+ // log('drag allowed')
825
+ // this.setLinking(false)
826
+ // this.showLinksOfContent()
827
+ // //this.setInternalDragging(true)
828
+ // let t = this.sensor.eventTargetMobject(e)
829
+ // log(`target: ${t.constructor.name}`)
830
+ // t.startDragging(e)
831
+ // return
832
+ // }
833
+ // let l = this.sensor.eventTargetMobjectChain(e).reverse()
834
+ // for (let mob of l) {
835
+ // if (mob instanceof IOList) {
836
+ // return
837
+ // }
838
+ // }
839
+ // let t1 = this.sensor.eventTargetMobject(e)
840
+ // let t2 = this.sensor.eventTarget
841
+ // log(t1)
842
+ // log(t2)
843
+ // if (this.sensor.eventTargetMobject(e) == this) {
844
+ // this.startCreating(e)
845
+ // }
846
+ let l = this.firstIOListContaining(p);
847
+ let mob = this.firstContentChildContaining(p);
848
+ if (l !== null) {
849
+ return;
850
+ }
851
+ if (mob === null) {
852
+ this.sensor.eventTarget = this;
853
+ this.startCreating(e);
854
+ return;
855
+ }
856
+ this.sensor.eventTarget = mob;
857
+ mob.onPointerDown(e);
858
+ return;
859
+ }
860
+ p = this.locationOfHook(clickedHook);
861
+ if (this.isFree(clickedHook)) {
862
+ this.createNewOpenLink(clickedHook);
863
+ }
864
+ else {
865
+ let link = this.linkForHook(clickedHook);
866
+ link.showLine();
867
+ link.dependency.source.removeDependency(link.dependency);
868
+ link.previousHook = clickedHook;
869
+ clickedHook.update({ linked: false });
870
+ remove(this.links, link);
871
+ this.remove(link);
872
+ if (clickedHook.outlet.kind == 'output') {
873
+ this.createNewOpenLink(link.endHook, link.previousHook, link.dependency);
874
+ }
875
+ else {
876
+ this.createNewOpenLink(link.startHook, link.previousHook, link.dependency);
877
+ }
878
+ }
879
+ this.compatibleHooks = this.getCompatibleHooks(this.openHook);
880
+ this.greyOutHooksIncompatibleWithHook(clickedHook);
881
+ }
882
+ locationOfHook(hook) {
883
+ return hook.parent.view.frame.transformLocalPoint(hook.midpoint, this.view.frame);
884
+ }
885
+ linkForHook(hook) {
886
+ for (let link of this.links) {
887
+ if (link.startHook == hook || link.endHook == hook) {
888
+ return link;
889
+ }
890
+ }
891
+ return null;
892
+ }
893
+ isFree(hook) {
894
+ return this.linkForHook(hook) == null;
895
+ }
896
+ createNewOpenLink(hook, previousHook = null, dependency = null) {
897
+ this.hideLinksOfContent();
898
+ hook.outlet.ioList.view.show();
899
+ this.openHook = hook;
900
+ let p = this.locationOfHook(hook);
901
+ let sb = new LinkBullet({ midpoint: p });
902
+ let eb = new LinkBullet({ midpoint: p });
903
+ if (this.openHook.outlet.kind == 'output') {
904
+ this.openLink = new DependencyLink({
905
+ startBullet: sb,
906
+ endBullet: eb,
907
+ startHook: hook,
908
+ previousHook: previousHook,
909
+ dependency: dependency
910
+ });
911
+ this.openBullet = eb;
912
+ }
913
+ else {
914
+ this.openLink = new DependencyLink({
915
+ startBullet: sb,
916
+ endBullet: eb,
917
+ endHook: hook,
918
+ previousHook: previousHook,
919
+ dependency: dependency
920
+ });
921
+ this.openBullet = sb;
922
+ }
923
+ this.add(this.openLink);
924
+ }
925
+ linking(e) {
926
+ if (this.openLink === null) {
927
+ this.creating(e);
928
+ return;
929
+ }
930
+ var p = this.sensor.localEventVertex(e);
931
+ let endHook = this.freeCompatibleHookAtLocation(p);
932
+ if (endHook !== null) {
933
+ p = this.locationOfHook(endHook);
934
+ }
935
+ this.openBullet.update({
936
+ midpoint: p
937
+ });
938
+ this.openBullet.updateDependents();
939
+ for (let child of this.linkableChildren()) {
940
+ child.inputList.view.hide();
941
+ child.outputList.view.hide();
942
+ }
943
+ let linkedHook = this.openLink.startHook ?? this.openLink.endHook;
944
+ linkedHook.outlet.ioList.view.show();
945
+ let child = this.hoveredChild(p);
946
+ let listOfLists = this.hoveredIOLists(p);
947
+ if (!child && listOfLists.length == 0) {
948
+ return;
949
+ }
950
+ let compHooks = this.getCompatibleHooks(this.openLink.startHook ?? this.openLink.endHook);
951
+ if (child && child !== linkedHook.outlet.ioList.mobject && listOfLists.length == 0) {
952
+ if (linkedHook.outlet.kind == 'input' && child.outputProperties.length > 0) {
953
+ child.outputList.view.show();
954
+ }
955
+ else if (linkedHook.outlet.kind == 'output' && child.inputProperties.length > 0) {
956
+ child.inputList.view.show();
957
+ }
958
+ }
959
+ if (child && child !== linkedHook.outlet.ioList.mobject && listOfLists.length > 1) {
960
+ for (let list of listOfLists) {
961
+ if (list.mobject == child) {
962
+ list.view.show();
963
+ return;
964
+ }
965
+ }
966
+ }
967
+ for (let list of listOfLists) {
968
+ if (list.kind !== linkedHook.outlet.kind && list.mobject !== linkedHook.outlet.ioList.mobject && list.linkOutlets.length > 0) {
969
+ list.view.show();
970
+ }
971
+ }
972
+ }
973
+ hoveredChild(p) {
974
+ for (let child of this.linkableChildren()) {
975
+ if (child.anchor[0] <= p[0] && p[0] <= child.anchor[0] + child.view.frameWidth
976
+ && child.anchor[1] <= p[1] && p[1] <= child.anchor[1] + child.view.frameHeight) {
977
+ return child;
978
+ }
979
+ }
980
+ }
981
+ hoveredIOLists(p) {
982
+ let ret = [];
983
+ for (let child of this.linkableChildren()) {
984
+ let minX1 = child.anchor[0] + child.inputList.anchor[0];
985
+ let maxX1 = minX1 + child.inputList.view.frameWidth;
986
+ let minY1 = child.anchor[1] + child.inputList.anchor[1];
987
+ let maxY1 = child.anchor[1];
988
+ if (minX1 <= p[0] && p[0] <= maxX1 && minY1 <= p[1] && p[1] <= maxY1) {
989
+ ret.push(child.inputList);
990
+ }
991
+ let minX2 = child.anchor[0] + child.outputList.anchor[0];
992
+ let maxX2 = minX2 + child.outputList.view.frameWidth;
993
+ let minY2 = child.anchor[1] + child.view.frameHeight;
994
+ let maxY2 = minY2 + child.outputList.view.frameHeight;
995
+ if (minX2 <= p[0] && p[0] <= maxX2 && minY2 <= p[1] && p[1] <= maxY2) {
996
+ ret.push(child.outputList);
997
+ }
998
+ }
999
+ return ret;
1000
+ }
1001
+ endLinking(e) {
1002
+ //this.disableContent()
1003
+ this.ungreyAllHooks();
1004
+ this.showLinksOfContent();
1005
+ if (!this.openLink) {
1006
+ this.endCreating(e);
1007
+ return;
1008
+ }
1009
+ this.showAllHooks();
1010
+ let h = this.freeCompatibleHookAtLocation(this.sensor.localEventVertex(e));
1011
+ if (h === null || h === undefined) {
1012
+ // TODO: remove the possibility of h being undefined
1013
+ //log('aborted link creation or removed existing link')
1014
+ if (this.openLink) {
1015
+ this.remove(this.openLink);
1016
+ if (this.openLink.startHook) {
1017
+ //log('no end hook')
1018
+ this.openLink.startHook.update({ linked: false });
1019
+ if (this.openLink.previousHook) {
1020
+ //log('we had an existing link')
1021
+ if (this.openLink.previousHook == this.openLink.startHook) {
1022
+ //log('previous hook is start hook')
1023
+ }
1024
+ if (this.openLink.previousHook == this.openLink.endHook) {
1025
+ //log('previous hook is end hook')
1026
+ }
1027
+ //log('removing hook at link start')
1028
+ this.openLink.startHook.outlet.removeHook();
1029
+ if (this.openLink.dependency.kind == 'action') {
1030
+ //log('removing previous hook (action)')
1031
+ this.openLink.previousHook.outlet.removeHook();
1032
+ }
1033
+ //log('A')
1034
+ //log('removing output link from mobject at start hook')
1035
+ this.openLink.startHook.outlet.ioList.mobject.removedOutputLink(this.openLink);
1036
+ //log('removing input link from mobject at previous hook')
1037
+ this.openLink.previousHook.outlet.ioList.mobject.removedInputLink(this.openLink);
1038
+ }
1039
+ }
1040
+ else if (this.openLink.endHook) {
1041
+ //log('no start hook')
1042
+ this.openLink.endHook.update({ linked: false });
1043
+ if (this.openLink.previousHook) {
1044
+ //log('we had an existing link')
1045
+ // if (this.openLink.previousHook == this.openLink.startHook) {
1046
+ // log('previous hook is start hook')
1047
+ // }
1048
+ // if (this.openLink.previousHook == this.openLink.endHook) {
1049
+ // log('previous hook is end hook')
1050
+ // }
1051
+ //log('removing hook at previous hook')
1052
+ this.openLink.previousHook.outlet.removeHook();
1053
+ if (this.openLink.dependency.kind == 'action') {
1054
+ //log('removing hook at link end (action)')
1055
+ this.openLink.endHook.outlet.removeHook();
1056
+ }
1057
+ //log('B')
1058
+ //log('removing output link from mobject at previous hook')
1059
+ this.openLink.previousHook.outlet.ioList.mobject.removedOutputLink(this.openLink);
1060
+ //log('removing output link from mobject at end hook')
1061
+ this.openLink.endHook.outlet.ioList.mobject.removedInputLink(this.openLink);
1062
+ }
1063
+ }
1064
+ }
1065
+ this.openLink = null;
1066
+ this.openHook = null;
1067
+ this.openBullet = null;
1068
+ this.compatibleHooks = [];
1069
+ return;
1070
+ }
1071
+ let startHookWasNull = (this.openLink.startHook == null);
1072
+ if (startHookWasNull) {
1073
+ //log('we had no start hook')
1074
+ this.openLink.update({ startHook: h });
1075
+ //log('start hook is new previous hook')
1076
+ }
1077
+ else {
1078
+ //log('we had a start hook')
1079
+ // if (this.openLink.endHook == null) {
1080
+ // log('end hook was null')
1081
+ // }
1082
+ this.openLink.update({ endHook: h });
1083
+ //log('end hook is new previous hook')
1084
+ }
1085
+ this.openLink.startHook.update({ linked: true });
1086
+ this.openLink.endHook.update({ linked: true });
1087
+ this.openLink.view.hide(); //this.openLink.hideLine()
1088
+ this.links.push(this.openLink);
1089
+ this.createNewDependency();
1090
+ if (startHookWasNull) {
1091
+ //log('C')
1092
+ //log('start hook was null')
1093
+ //log('removing output link at mobject of previous hook')
1094
+ this.openLink.previousHook?.outlet.ioList.mobject.removedOutputLink(this.openLink);
1095
+ //this.openLink.startHook.outlet.ioList.mobject.addedOutputLink(this.openLink)
1096
+ this.openLink.previousHook = this.openLink.startHook;
1097
+ }
1098
+ else {
1099
+ //log('D')
1100
+ //log('we had a start hook')
1101
+ // if (this.openLink.endHook == null) {
1102
+ // log('end hook was null')
1103
+ // }
1104
+ // log('removing input link at mobject of previous hook')
1105
+ this.openLink.previousHook?.outlet.ioList.mobject.removedInputLink(this.openLink);
1106
+ //this.openLink.endHook.outlet.ioList.mobject.addedInputLink(this.openLink)
1107
+ this.openLink.previousHook = this.openLink.endHook;
1108
+ }
1109
+ this.openLink.previousHook = null;
1110
+ this.openLink = null;
1111
+ this.openHook = null;
1112
+ this.openBullet = null;
1113
+ this.compatibleHooks = [];
1114
+ }
1115
+ showAllHooks() {
1116
+ for (let mob of this.linkableChildren()) {
1117
+ for (let outlet of mob.inputList.linkOutlets) {
1118
+ outlet.label.update({
1119
+ opacity: 1
1120
+ });
1121
+ for (let hook of outlet.linkHooks) {
1122
+ hook.update({
1123
+ opacity: 1
1124
+ });
1125
+ }
1126
+ }
1127
+ }
1128
+ }
1129
+ greyOutHooksIncompatibleWithHook(baseHook) {
1130
+ for (let mob of this.linkableChildren()) {
1131
+ for (let outlet of mob.inputList.linkOutlets) {
1132
+ for (let hook of outlet.linkHooks) {
1133
+ if (!this.compatibleHooks.includes(hook) && baseHook !== hook) {
1134
+ hook.update({
1135
+ opacity: 0.25
1136
+ });
1137
+ outlet.label.update({
1138
+ opacity: 0.25
1139
+ });
1140
+ }
1141
+ }
1142
+ }
1143
+ }
1144
+ }
1145
+ ungreyAllHooks() {
1146
+ for (let mob of this.linkableChildren()) {
1147
+ for (let outlet of mob.inputList.linkOutlets) {
1148
+ for (let hook of outlet.linkHooks) {
1149
+ hook.update({
1150
+ opacity: 1.0
1151
+ });
1152
+ outlet.label.update({
1153
+ opacity: 1.0
1154
+ });
1155
+ }
1156
+ }
1157
+ }
1158
+ }
1159
+ getCompatibleHooks(startHook) {
1160
+ return this.allHooks().filter((endHook) => this.areCompatibleHooks(startHook, endHook));
1161
+ // TODO: and endHook is not yet occupied!
1162
+ }
1163
+ areCompatibleHooks(startHook, endHook) {
1164
+ if (startHook.outlet.kind == 'output' && endHook.outlet.kind == 'input') {
1165
+ let flag1 = (startHook.outlet.type == endHook.outlet.type)
1166
+ || ((startHook.outlet.type == 'number' || startHook.outlet.type == 'Array<number>')
1167
+ && endHook.outlet.type == 'number|Array<number>')
1168
+ || (startHook.outlet.type == 'number|Array<number>'
1169
+ && (endHook.outlet.type == 'number' || endHook.outlet.type == 'Array<number>'));
1170
+ let flag2 = (startHook.outlet.ioList.mobject !== endHook.outlet.ioList.mobject);
1171
+ let flag3 = (!startHook.outlet.ioList.mobject.dependsOn(endHook.outlet.ioList.mobject));
1172
+ return flag1 && flag2 && flag3;
1173
+ }
1174
+ else if (startHook.outlet.kind == 'input' && endHook.outlet.kind == 'output') {
1175
+ return this.areCompatibleHooks(endHook, startHook);
1176
+ }
1177
+ else {
1178
+ return false;
1179
+ }
1180
+ }
1181
+ updateLinks() {
1182
+ for (let hook of this.allHooks()) {
1183
+ hook.outlet.update();
1184
+ hook.outlet.updateDependents();
1185
+ hook.update();
1186
+ hook.updateDependents(); // this is supposed to update start and end points of links
1187
+ }
1188
+ }
1189
+ createNewDependency() {
1190
+ this.createNewDependencyBetweenHooks(this.openLink.startHook, this.openLink.endHook);
1191
+ }
1192
+ createNewDependencyBetweenHooks(startHook, endHook) {
1193
+ startHook.outlet.ioList.mobject.addDependency(startHook.outlet.name, endHook.outlet.ioList.mobject, endHook.outlet.name);
1194
+ this.openLink.update({
1195
+ startHook: startHook,
1196
+ endHook: endHook,
1197
+ dependency: startHook.outlet.ioList.mobject.dependencies[startHook.outlet.ioList.mobject.dependencies.length - 1]
1198
+ });
1199
+ startHook.addDependency('positionInBoard', this.openLink.startBullet, 'midpoint');
1200
+ endHook.addDependency('positionInBoard', this.openLink.endBullet, 'midpoint');
1201
+ // these should not be necessary
1202
+ startHook.addDependency('positionInBoard', this.openLink.linkLine, 'startPoint');
1203
+ endHook.addDependency('positionInBoard', this.openLink.linkLine, 'endPoint');
1204
+ startHook.addDependency('positionInBoard', this.openLink.borderLinkLine, 'startPoint');
1205
+ endHook.addDependency('positionInBoard', this.openLink.borderLinkLine, 'endPoint');
1206
+ if (startHook == startHook.outlet.linkHooks[startHook.outlet.linkHooks.length - 1]) {
1207
+ startHook.outlet.addHook();
1208
+ }
1209
+ if (endHook == endHook.outlet.linkHooks[endHook.outlet.linkHooks.length - 1] && this.openLink.dependency.kind == 'action') {
1210
+ endHook.outlet.addHook();
1211
+ }
1212
+ startHook.outlet.ioList.mobject.addedOutputLink(this.openLink);
1213
+ endHook.outlet.ioList.mobject.addedInputLink(this.openLink);
1214
+ }
1215
+ removeDependencyBetweenHooks(startHook, endHook) {
1216
+ startHook.outlet.ioList.mobject.removeDependencyBetween(startHook.outlet.name, endHook.outlet.ioList.mobject, endHook.outlet.name);
1217
+ startHook.removeAllDependents();
1218
+ endHook.removeAllDependents();
1219
+ //startHook.outlet.removeHook()
1220
+ if (this.openLink) {
1221
+ startHook.outlet.ioList.mobject.removedOutputLink(this.openLink);
1222
+ endHook.outlet.ioList.mobject.removedInputLink(this.openLink);
1223
+ }
1224
+ }
1225
+ removeDependencyOfLink(link) {
1226
+ let startHook = link.startHook;
1227
+ let endHook = link.endHook;
1228
+ startHook.outlet.ioList.mobject.removeDependencyBetween(startHook.outlet.name, endHook.outlet.ioList.mobject, endHook.outlet.name);
1229
+ startHook.removeAllDependents();
1230
+ endHook.removeAllDependents();
1231
+ //startHook.outlet.removeHook()
1232
+ startHook.outlet.ioList.mobject.removedOutputLink(link);
1233
+ endHook.outlet.ioList.mobject.removedInputLink(link);
1234
+ }
1235
+ removeLink(link) {
1236
+ if (this.openLink) {
1237
+ this.removeDependencyBetweenHooks(link.startHook, link.endHook);
1238
+ }
1239
+ else {
1240
+ this.removeDependencyOfLink(link);
1241
+ }
1242
+ remove(this.links, link);
1243
+ this.remove(link);
1244
+ }
1245
+ removeInputLinkForPropertyAtMobject(prop, mob, index = 0) {
1246
+ let outlet = mob.inputList.outletNamed(prop);
1247
+ if (!outlet) {
1248
+ return;
1249
+ }
1250
+ let hook = outlet.linkHooks[index];
1251
+ if (!hook) {
1252
+ return;
1253
+ }
1254
+ let link = this.linkForHook(hook);
1255
+ if (!link) {
1256
+ return;
1257
+ }
1258
+ this.removeLink(link);
1259
+ link.startHook.update({ linked: false });
1260
+ link.endHook.update({ linked: false });
1261
+ link.startHook.outlet.removeHook();
1262
+ }
1263
+ removeDependencyAtHook(hook) {
1264
+ for (let link of this.links) {
1265
+ if (link.startHook == hook || link.endHook == hook) {
1266
+ this.removeLink(link);
1267
+ return;
1268
+ }
1269
+ }
1270
+ }
1271
+ allHooks() {
1272
+ if (this.contracted) {
1273
+ return super.allHooks();
1274
+ }
1275
+ let ret = [];
1276
+ for (let linkable of this.contentChildren) {
1277
+ if (linkable instanceof Linkable) {
1278
+ ret = ret.concat(linkable.allHooks());
1279
+ }
1280
+ }
1281
+ return ret;
1282
+ }
1283
+ freeHooks() {
1284
+ return this.allHooks().filter((h) => this.isFree(h));
1285
+ }
1286
+ hookAtLocationFromList(p, hookList) {
1287
+ for (let h of hookList) {
1288
+ let boardFrame = this.view.frame;
1289
+ let outletFrame = h.parent.view.frame;
1290
+ let q = outletFrame.transformLocalPoint(h.midpoint, boardFrame);
1291
+ if (vertexIsCloseTo(p, q, SNAPPING_DISTANCE)) {
1292
+ return h;
1293
+ }
1294
+ }
1295
+ return null;
1296
+ }
1297
+ freeCompatibleHooks() {
1298
+ return this.compatibleHooks.filter((h) => this.isFree(h));
1299
+ }
1300
+ hookAtLocation(p) {
1301
+ return this.hookAtLocationFromList(p, this.allHooks());
1302
+ }
1303
+ freeHookAtLocation(p) {
1304
+ return this.hookAtLocationFromList(p, this.freeHooks());
1305
+ }
1306
+ compatibleHookAtLocation(p) {
1307
+ return this.hookAtLocationFromList(p, this.compatibleHooks);
1308
+ }
1309
+ freeCompatibleHookAtLocation(p) {
1310
+ let freeHooks = this.freeCompatibleHooks();
1311
+ let hook = this.hookAtLocationFromList(p, freeHooks);
1312
+ return hook;
1313
+ }
1314
+ //////////////////////////////////////////////////////////
1315
+ // //
1316
+ // MESSAGING //
1317
+ // //
1318
+ //////////////////////////////////////////////////////////
1319
+ messageSidebar(message) {
1320
+ try {
1321
+ let w = window;
1322
+ w.webkit.messageHandlers.handleMessageFromPaper.postMessage(message);
1323
+ }
1324
+ catch {
1325
+ this.sidebar.getMessage(message);
1326
+ }
1327
+ }
1328
+ }
1329
+ //# sourceMappingURL=Board.js.map