@kabel-project/kabel 1.0.7 → 1.0.9

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 (273) hide show
  1. package/dist/comment-renderer/renderer.d.ts +32 -0
  2. package/dist/comment-renderer/renderer.d.ts.map +1 -0
  3. package/dist/controllers/base.d.ts +39 -0
  4. package/dist/controllers/base.d.ts.map +1 -0
  5. package/dist/controllers/wasd.d.ts +33 -0
  6. package/dist/controllers/wasd.d.ts.map +1 -0
  7. package/dist/events/comment-drag-handle.d.ts +2 -0
  8. package/dist/events/comment-drag-handle.d.ts.map +1 -0
  9. package/dist/events/comment-input.d.ts +4 -0
  10. package/dist/events/comment-input.d.ts.map +1 -0
  11. package/dist/events/connection-line.d.ts +2 -0
  12. package/dist/events/connection-line.d.ts.map +1 -0
  13. package/dist/events/connector.d.ts +2 -0
  14. package/dist/events/connector.d.ts.map +1 -0
  15. package/dist/events/draggable.d.ts +2 -0
  16. package/dist/events/draggable.d.ts.map +1 -0
  17. package/{events/events.ts → dist/events/events.d.ts} +8 -7
  18. package/dist/events/events.d.ts.map +1 -0
  19. package/dist/events/input-box.d.ts +2 -0
  20. package/dist/events/input-box.d.ts.map +1 -0
  21. package/dist/events/node-x-btn.d.ts +2 -0
  22. package/dist/events/node-x-btn.d.ts.map +1 -0
  23. package/dist/kabel.js +2 -0
  24. package/dist/kabel.js.map +1 -0
  25. package/dist/renderers/apollo/apollo.d.ts +12 -0
  26. package/dist/renderers/apollo/apollo.d.ts.map +1 -0
  27. package/dist/renderers/apollo/constants.d.ts +21 -0
  28. package/dist/renderers/apollo/constants.d.ts.map +1 -0
  29. package/dist/renderers/apollo/renderer.d.ts +97 -0
  30. package/dist/renderers/apollo/renderer.d.ts.map +1 -0
  31. package/{renderers/atlas/atlas.ts → dist/renderers/atlas/atlas.d.ts} +6 -15
  32. package/dist/renderers/atlas/atlas.d.ts.map +1 -0
  33. package/dist/renderers/constants.d.ts +51 -0
  34. package/dist/renderers/constants.d.ts.map +1 -0
  35. package/dist/renderers/renderer.d.ts +470 -0
  36. package/dist/renderers/renderer.d.ts.map +1 -0
  37. package/dist/renderers/representer-node.d.ts +27 -0
  38. package/dist/renderers/representer-node.d.ts.map +1 -0
  39. package/dist/renderers/representer.d.ts +13 -0
  40. package/dist/renderers/representer.d.ts.map +1 -0
  41. package/dist/src/category.d.ts +48 -0
  42. package/dist/src/category.d.ts.map +1 -0
  43. package/{src/colors.ts → dist/src/colors.d.ts} +21 -20
  44. package/dist/src/colors.d.ts.map +1 -0
  45. package/dist/src/comment.d.ts +88 -0
  46. package/dist/src/comment.d.ts.map +1 -0
  47. package/dist/src/connection.d.ts +52 -0
  48. package/dist/src/connection.d.ts.map +1 -0
  49. package/dist/src/context-menu.d.ts +76 -0
  50. package/dist/src/context-menu.d.ts.map +1 -0
  51. package/dist/src/coordinates.d.ts +52 -0
  52. package/dist/src/coordinates.d.ts.map +1 -0
  53. package/dist/src/core.d.ts +153 -0
  54. package/dist/src/core.d.ts.map +1 -0
  55. package/dist/src/ctx-menu-registry.d.ts +22 -0
  56. package/dist/src/ctx-menu-registry.d.ts.map +1 -0
  57. package/dist/src/dropdown-menu.d.ts +87 -0
  58. package/dist/src/dropdown-menu.d.ts.map +1 -0
  59. package/dist/src/field.d.ts +305 -0
  60. package/dist/src/field.d.ts.map +1 -0
  61. package/dist/src/flyout.d.ts +41 -0
  62. package/dist/src/flyout.d.ts.map +1 -0
  63. package/dist/src/fonts-manager.d.ts +6 -0
  64. package/dist/src/fonts-manager.d.ts.map +1 -0
  65. package/dist/src/grid.d.ts +60 -0
  66. package/dist/src/grid.d.ts.map +1 -0
  67. package/dist/src/headless-node.d.ts +11 -0
  68. package/dist/src/headless-node.d.ts.map +1 -0
  69. package/dist/src/index.d.ts +38 -0
  70. package/dist/src/index.d.ts.map +1 -0
  71. package/dist/src/inject-headless.d.ts +4 -0
  72. package/dist/src/inject-headless.d.ts.map +1 -0
  73. package/{src/inject.ts → dist/src/inject.d.ts} +142 -213
  74. package/dist/src/inject.d.ts.map +1 -0
  75. package/{src/main-workspace.ts → dist/src/main-workspace.d.ts} +31 -51
  76. package/dist/src/main-workspace.d.ts.map +1 -0
  77. package/dist/src/mutator.d.ts +2 -0
  78. package/dist/src/mutator.d.ts.map +1 -0
  79. package/{src/node-types.ts → dist/src/node-types.d.ts} +26 -27
  80. package/dist/src/node-types.d.ts.map +1 -0
  81. package/dist/src/nodesvg.d.ts +266 -0
  82. package/dist/src/nodesvg.d.ts.map +1 -0
  83. package/{src/prototypes.ts → dist/src/prototypes.d.ts} +10 -9
  84. package/dist/src/prototypes.d.ts.map +1 -0
  85. package/{src/renderer-map.ts → dist/src/renderer-map.d.ts} +51 -86
  86. package/dist/src/renderer-map.d.ts.map +1 -0
  87. package/dist/src/toolbox.d.ts +51 -0
  88. package/dist/src/toolbox.d.ts.map +1 -0
  89. package/{src/types.ts → dist/src/types.d.ts} +159 -205
  90. package/dist/src/types.d.ts.map +1 -0
  91. package/dist/src/undo-redo.d.ts +15 -0
  92. package/dist/src/undo-redo.d.ts.map +1 -0
  93. package/{src/visual-types.ts → dist/src/visual-types.d.ts} +34 -29
  94. package/dist/src/visual-types.d.ts.map +1 -0
  95. package/dist/src/widget-prototypes.d.ts +10 -0
  96. package/dist/src/widget-prototypes.d.ts.map +1 -0
  97. package/dist/src/widget.d.ts +62 -0
  98. package/dist/src/widget.d.ts.map +1 -0
  99. package/{src/workspace-coords.ts → dist/src/workspace-coords.d.ts} +10 -14
  100. package/dist/src/workspace-coords.d.ts.map +1 -0
  101. package/dist/src/workspace-svg.d.ts +371 -0
  102. package/dist/src/workspace-svg.d.ts.map +1 -0
  103. package/dist/src/workspace.d.ts +50 -0
  104. package/dist/src/workspace.d.ts.map +1 -0
  105. package/dist/themes/dark.d.ts +4 -0
  106. package/dist/themes/dark.d.ts.map +1 -0
  107. package/dist/themes/default.d.ts +4 -0
  108. package/dist/themes/default.d.ts.map +1 -0
  109. package/dist/themes/themes.d.ts +6 -0
  110. package/dist/themes/themes.d.ts.map +1 -0
  111. package/dist/util/emitter.d.ts +10 -0
  112. package/dist/util/emitter.d.ts.map +1 -0
  113. package/dist/util/env.d.ts +7 -0
  114. package/dist/util/env.d.ts.map +1 -0
  115. package/{util/escape-html.ts → dist/util/escape-html.d.ts} +16 -22
  116. package/dist/util/escape-html.d.ts.map +1 -0
  117. package/dist/util/eventer.d.ts +29 -0
  118. package/dist/util/eventer.d.ts.map +1 -0
  119. package/dist/util/has-prop.d.ts +2 -0
  120. package/dist/util/has-prop.d.ts.map +1 -0
  121. package/dist/util/parse-color.d.ts +6 -0
  122. package/dist/util/parse-color.d.ts.map +1 -0
  123. package/dist/util/path.d.ts +25 -0
  124. package/dist/util/path.d.ts.map +1 -0
  125. package/dist/util/styler.d.ts +12 -0
  126. package/dist/util/styler.d.ts.map +1 -0
  127. package/dist/util/uid.d.ts +42 -0
  128. package/dist/util/uid.d.ts.map +1 -0
  129. package/{util/unescape-html.ts → dist/util/unescape-html.d.ts} +16 -22
  130. package/dist/util/unescape-html.d.ts.map +1 -0
  131. package/dist/util/user-state.d.ts +37 -0
  132. package/dist/util/user-state.d.ts.map +1 -0
  133. package/{util/wait-anim-frames.ts → dist/util/wait-anim-frames.d.ts} +11 -24
  134. package/dist/util/wait-anim-frames.d.ts.map +1 -0
  135. package/dist/util/window-listeners.d.ts +8 -0
  136. package/dist/util/window-listeners.d.ts.map +1 -0
  137. package/package.json +5 -2
  138. package/(1.0.7)kabel.md +0 -18
  139. package/_READ_ME_MEDIA_/documentation/docs.md +0 -293
  140. package/_READ_ME_MEDIA_/workspace.png +0 -0
  141. package/comment-renderer/renderer.ts +0 -228
  142. package/controllers/base.ts +0 -186
  143. package/controllers/wasd.ts +0 -132
  144. package/docs/README.md +0 -98
  145. package/docs/_media/docs.md +0 -289
  146. package/docs/_media/workspace.png +0 -0
  147. package/docs/classes/CommentModel.md +0 -271
  148. package/docs/classes/CommentRenderer.md +0 -457
  149. package/docs/classes/ConnectableField.md +0 -597
  150. package/docs/classes/Connection.md +0 -191
  151. package/docs/classes/ContextMenuHTML.md +0 -163
  152. package/docs/classes/Coordinates.md +0 -187
  153. package/docs/classes/DropdownContainer.md +0 -300
  154. package/docs/classes/DummyField.md +0 -393
  155. package/docs/classes/Eventer.md +0 -185
  156. package/docs/classes/Field.md +0 -461
  157. package/docs/classes/InjectMsg.md +0 -85
  158. package/docs/classes/NodeSvg.md +0 -1011
  159. package/docs/classes/NumberField.md +0 -559
  160. package/docs/classes/OptConnectField.md +0 -624
  161. package/docs/classes/Renderer.md +0 -1636
  162. package/docs/classes/RendererConstants.md +0 -343
  163. package/docs/classes/Representer.md +0 -95
  164. package/docs/classes/RepresenterNode.md +0 -175
  165. package/docs/classes/TextField.md +0 -559
  166. package/docs/classes/Toolbox.md +0 -172
  167. package/docs/classes/WASDController.md +0 -616
  168. package/docs/classes/Widget.md +0 -195
  169. package/docs/classes/WorkspaceController.md +0 -385
  170. package/docs/classes/WorkspaceCoords.md +0 -218
  171. package/docs/classes/WorkspaceSvg.md +0 -1380
  172. package/docs/functions/clearMainWorkspace.md +0 -20
  173. package/docs/functions/getMainWorkspace.md +0 -19
  174. package/docs/functions/inject.md +0 -35
  175. package/docs/functions/setMainWorkspace.md +0 -28
  176. package/docs/globals.md +0 -95
  177. package/docs/interfaces/ColorStyle.md +0 -43
  178. package/docs/interfaces/ConnectorToFrom.md +0 -57
  179. package/docs/interfaces/DrawState.md +0 -81
  180. package/docs/interfaces/FieldConnectionData.md +0 -25
  181. package/docs/interfaces/FieldOptions.md +0 -63
  182. package/docs/interfaces/FieldRawBoxData.md +0 -25
  183. package/docs/interfaces/FieldVisualInfo.md +0 -65
  184. package/docs/interfaces/GridOptions.md +0 -61
  185. package/docs/interfaces/InjectOptions.md +0 -133
  186. package/docs/interfaces/InputFieldJson.md +0 -50
  187. package/docs/interfaces/KabelCommentRendering.md +0 -31
  188. package/docs/interfaces/KabelInterface.md +0 -469
  189. package/docs/interfaces/KabelNodeRendering.md +0 -77
  190. package/docs/interfaces/KabelUIX.md +0 -105
  191. package/docs/interfaces/KabelUtils.md +0 -215
  192. package/docs/interfaces/NodeEvents.md +0 -42
  193. package/docs/interfaces/NodeJson.md +0 -104
  194. package/docs/interfaces/NodePrototype.md +0 -82
  195. package/docs/interfaces/RegisteredEl.md +0 -53
  196. package/docs/interfaces/SerializedNode.md +0 -128
  197. package/docs/interfaces/TblxCategoryStruct.md +0 -41
  198. package/docs/interfaces/TblxFieldStruct.md +0 -28
  199. package/docs/interfaces/TblxNodeStruct.md +0 -35
  200. package/docs/interfaces/WidgetOptions.md +0 -115
  201. package/docs/interfaces/WidgetPrototypeList.md +0 -15
  202. package/docs/type-aliases/AnyField.md +0 -13
  203. package/docs/type-aliases/AnyFieldCls.md +0 -13
  204. package/docs/type-aliases/Color.md +0 -13
  205. package/docs/type-aliases/Connectable.md +0 -13
  206. package/docs/type-aliases/EventArgs.md +0 -11
  207. package/docs/type-aliases/EventSetupFn.md +0 -25
  208. package/docs/type-aliases/Hex.md +0 -13
  209. package/docs/type-aliases/RGBObject.md +0 -37
  210. package/docs/type-aliases/RGBString.md +0 -13
  211. package/docs/type-aliases/RGBTuple.md +0 -13
  212. package/docs/type-aliases/TblxObjStruct.md +0 -52
  213. package/docs/variables/CategoryColors.md +0 -29
  214. package/docs/variables/FieldMap.md +0 -41
  215. package/docs/variables/NodePrototypes.md +0 -18
  216. package/docs/variables/default.md +0 -11
  217. package/events/comment-drag-handle.ts +0 -61
  218. package/events/comment-input.ts +0 -291
  219. package/events/connection-line.ts +0 -68
  220. package/events/connector.ts +0 -116
  221. package/events/draggable.ts +0 -119
  222. package/events/input-box.ts +0 -213
  223. package/events/node-x-btn.ts +0 -25
  224. package/index.d.ts +0 -4
  225. package/renderers/apollo/apollo.ts +0 -21
  226. package/renderers/apollo/constants.ts +0 -40
  227. package/renderers/apollo/renderer.ts +0 -331
  228. package/renderers/constants.ts +0 -87
  229. package/renderers/renderer.ts +0 -1288
  230. package/renderers/representer-node.ts +0 -52
  231. package/renderers/representer.ts +0 -25
  232. package/src/category.ts +0 -107
  233. package/src/comment.ts +0 -142
  234. package/src/connection.ts +0 -114
  235. package/src/context-menu.ts +0 -194
  236. package/src/coordinates.ts +0 -74
  237. package/src/core.ts +0 -202
  238. package/src/ctx-menu-registry.ts +0 -143
  239. package/src/dropdown-menu.ts +0 -215
  240. package/src/field.ts +0 -595
  241. package/src/flyout.ts +0 -165
  242. package/src/fonts-manager.ts +0 -38
  243. package/src/grid.ts +0 -162
  244. package/src/headless-node.ts +0 -27
  245. package/src/index.ts +0 -115
  246. package/src/inject-headless.ts +0 -18
  247. package/src/mutator.ts +0 -40
  248. package/src/nodesvg.ts +0 -756
  249. package/src/styles.css +0 -224
  250. package/src/toolbox.ts +0 -125
  251. package/src/undo-redo.ts +0 -87
  252. package/src/widget-prototypes.ts +0 -11
  253. package/src/widget.ts +0 -139
  254. package/src/workspace-svg.ts +0 -736
  255. package/src/workspace.ts +0 -155
  256. package/test-server.js +0 -61
  257. package/themes/dark.ts +0 -32
  258. package/themes/default.ts +0 -28
  259. package/themes/themes.ts +0 -9
  260. package/tsconfig.json +0 -25
  261. package/typedoc.json +0 -10
  262. package/util/emitter.ts +0 -33
  263. package/util/env.ts +0 -11
  264. package/util/eventer.ts +0 -108
  265. package/util/has-prop.ts +0 -4
  266. package/util/parse-color.ts +0 -42
  267. package/util/path.ts +0 -99
  268. package/util/styler.ts +0 -41
  269. package/util/uid.ts +0 -184
  270. package/util/user-state.ts +0 -68
  271. package/util/window-listeners.ts +0 -62
  272. package/webpack.config.js +0 -80
  273. /package/{docs/_media → dist}/index.html +0 -0
@@ -1,213 +1,142 @@
1
- import WorkspaceController from "../controllers/base";
2
- import Renderer from "../renderers/renderer";
3
- import { clearMainWorkspace, getMainWorkspace, setMainWorkspace } from "./main-workspace";
4
- import WorkspaceSvg, { WSTheme } from "./workspace-svg";
5
- import NodePrototypes from "./prototypes"; // Object
6
- import { FieldOptions } from "./field";
7
- import { Color, Hex } from "./visual-types";
8
- import styler from '../util/styler';
9
- // @ts-ignore
10
- import _kabelStyles from './styles.css';
11
- import env from "../util/env";
12
-
13
- const kabelStyles: string = _kabelStyles;
14
-
15
- /**
16
- * Represents a field in a toolbox node.
17
- * Can contain any extra properties as needed by the field type.
18
- */
19
- export interface TblxFieldStruct {
20
- /** Field value */
21
- value: any;
22
-
23
- /** Additional field-specific properties */
24
- [key: string]: any;
25
- }
26
-
27
- /**
28
- * Represents a node in a toolbox.
29
- */
30
- export interface TblxNodeStruct {
31
- /** Node type (matches NodePrototypes key or arbitrary string) */
32
- type: keyof typeof NodePrototypes | string;
33
-
34
- /** Map of field names to field data */
35
- arguments: {
36
- [key: string]: TblxFieldStruct;
37
- };
38
- }
39
-
40
- /**
41
- * Represents a category in the toolbox, which contains multiple nodes.
42
- */
43
- export interface TblxCategoryStruct {
44
- /** Category name */
45
- name: string;
46
-
47
- /** Category color */
48
- color: Color;
49
-
50
- /** Nodes contained in this category */
51
- contents: TblxNodeStruct[];
52
- }
53
-
54
- /**
55
- * Discriminated union type representing possible toolbox structures.
56
- * Can be a flyout (list of nodes) or a categorized toolbox.
57
- */
58
- export type TblxObjStruct =
59
- | {
60
- /** Flyout toolbox type */
61
- type: 'flyout';
62
- contents: TblxNodeStruct[];
63
- }
64
- | {
65
- /** Categorized toolbox type */
66
- type?: 'category';
67
- contents: TblxCategoryStruct[];
68
- }
69
- | {
70
- /** When type is omitted, defaults to categories */
71
- type?: undefined;
72
- contents: TblxCategoryStruct[];
73
- };
74
- export interface GridOptions {
75
- /**
76
- * The grid's type.
77
- * 'celled' - The grid is celled.
78
- * 'dotted' - The grid is dotted.
79
- */
80
- type: 'celled' | 'dotted';
81
- /**
82
- * Spacing, optional. Default is 40.
83
- */
84
- spacing?: number;
85
- /**
86
- * Dot size for 'dotted' grid type.
87
- */
88
- dotSize?: number;
89
- /**
90
- * stroke width for 'celled' grid type.
91
- */
92
- strokeWidth?: number;
93
- /**
94
- * Option color for any grid type. Color is #bebebeff by default.
95
- */
96
- color?: Hex
97
- }
98
- /**
99
- * Options used when injecting a new workspace.
100
- */
101
- export interface InjectOptions {
102
- /** Optional renderer overrides */
103
- rendererOverrides?: { [key: string]: any };
104
- /** Theme for the workspace */
105
- theme?: string|WSTheme;
106
- /** Optional custom controller class */
107
- Controller?: typeof WorkspaceController;
108
- /** Init the workspace's undo state for you, or not. */
109
- initUndoRedo?: boolean;
110
- /** Optional controls configuration */
111
- controls?: {
112
- zoomSpeed?: number;
113
- minZoom?: number;
114
- maxZoom?: number;
115
- wasd?: boolean;
116
- wasdSmooth?: boolean;
117
- wasdAccelerate?: number;
118
- wasdFriction?: number;
119
- };
120
-
121
- /** Optional toolbox structure */
122
- toolbox?: TblxObjStruct;
123
-
124
- /** Optional movement speed of the workspace */
125
- moveSpeed?: number;
126
-
127
- /** Optional renderer: name string or class */
128
- renderer?: string | typeof Renderer;
129
- /**
130
- * Optional grid settings.
131
- */
132
- grid?: GridOptions;
133
- }
134
-
135
- /**
136
- * Utility class for logging injection messages in a structured way.
137
- */
138
- export class InjectMsg {
139
- /** Message content */
140
- msg: string;
141
-
142
- /**
143
- * Creates a new InjectMsg instance.
144
- * @param msg - Message text
145
- */
146
- constructor(msg: string) {
147
- this.msg = msg;
148
- }
149
-
150
- /** Log as error */
151
- err() {
152
- console.error(`Failed to inject workspace: ${this.msg}`);
153
- }
154
-
155
- /** Log as warning */
156
- wrn() {
157
- console.warn(`Inject warning: ${this.msg}`);
158
- }
159
-
160
- /** Log as info */
161
- info() {
162
- console.info(`Inject info: ${this.msg}`);
163
- }
164
- }
165
-
166
- /**
167
- * Injects a new Kabel workspace into the document.
168
- * Appends the workspace container to the given element (or element ID) and
169
- * sets it as the main workspace.
170
- *
171
- * @param element - HTMLElement or string ID to attach the workspace to
172
- * @param options - Optional InjectOptions to configure the workspace
173
- * @returns The newly created WorkspaceSvg instance, or undefined if injection failed
174
- */
175
- export default function inject(
176
- element: HTMLElement | string,
177
- options: InjectOptions = {}
178
- ): WorkspaceSvg | undefined {
179
- if (!env.isBrowser) {
180
- new InjectMsg(`Cannot inject workspace-svg in non-browser environment (use Kabel.injectHeadless).`).err();
181
- return;
182
- }
183
- // Apply global Kabel styles
184
- styler.appendStyles('KabelStyles', kabelStyles);
185
-
186
- const root =
187
- typeof element === 'string'
188
- ? document.querySelector(`#${element}`) as HTMLElement
189
- : element as HTMLElement;
190
-
191
- if (!root) {
192
- new InjectMsg(`Document does not contain root element (Check element ID).`).err();
193
- return;
194
- }
195
-
196
- if (!document.contains(root)) {
197
- new InjectMsg(`Document does not contain root element.`).err();
198
- return;
199
- }
200
-
201
- // Create workspace wrapper element
202
- const wsTop = document.createElement('div');
203
- wsTop.className = `KabelWorkspaceWrapper`;
204
- root.appendChild(wsTop);
205
-
206
- // Initialize workspace
207
- const ws = new WorkspaceSvg(root, wsTop, options);
208
-
209
- // Set as the main workspace globally
210
- setMainWorkspace(ws);
211
-
212
- return ws;
213
- }
1
+ import WorkspaceController from "../controllers/base";
2
+ import Renderer from "../renderers/renderer";
3
+ import WorkspaceSvg, { WSTheme } from "./workspace-svg";
4
+ import NodePrototypes from "./prototypes";
5
+ import { Color, Hex } from "./visual-types";
6
+ /**
7
+ * Represents a field in a toolbox node.
8
+ * Can contain any extra properties as needed by the field type.
9
+ */
10
+ export interface TblxFieldStruct {
11
+ /** Field value */
12
+ value: any;
13
+ /** Additional field-specific properties */
14
+ [key: string]: any;
15
+ }
16
+ /**
17
+ * Represents a node in a toolbox.
18
+ */
19
+ export interface TblxNodeStruct {
20
+ /** Node type (matches NodePrototypes key or arbitrary string) */
21
+ type: keyof typeof NodePrototypes | string;
22
+ /** Map of field names to field data */
23
+ arguments: {
24
+ [key: string]: TblxFieldStruct;
25
+ };
26
+ }
27
+ /**
28
+ * Represents a category in the toolbox, which contains multiple nodes.
29
+ */
30
+ export interface TblxCategoryStruct {
31
+ /** Category name */
32
+ name: string;
33
+ /** Category color */
34
+ color: Color;
35
+ /** Nodes contained in this category */
36
+ contents: TblxNodeStruct[];
37
+ }
38
+ /**
39
+ * Discriminated union type representing possible toolbox structures.
40
+ * Can be a flyout (list of nodes) or a categorized toolbox.
41
+ */
42
+ export type TblxObjStruct = {
43
+ /** Flyout toolbox type */
44
+ type: 'flyout';
45
+ contents: TblxNodeStruct[];
46
+ } | {
47
+ /** Categorized toolbox type */
48
+ type?: 'category';
49
+ contents: TblxCategoryStruct[];
50
+ } | {
51
+ /** When type is omitted, defaults to categories */
52
+ type?: undefined;
53
+ contents: TblxCategoryStruct[];
54
+ };
55
+ export interface GridOptions {
56
+ /**
57
+ * The grid's type.
58
+ * 'celled' - The grid is celled.
59
+ * 'dotted' - The grid is dotted.
60
+ */
61
+ type: 'celled' | 'dotted';
62
+ /**
63
+ * Spacing, optional. Default is 40.
64
+ */
65
+ spacing?: number;
66
+ /**
67
+ * Dot size for 'dotted' grid type.
68
+ */
69
+ dotSize?: number;
70
+ /**
71
+ * stroke width for 'celled' grid type.
72
+ */
73
+ strokeWidth?: number;
74
+ /**
75
+ * Option color for any grid type. Color is #bebebeff by default.
76
+ */
77
+ color?: Hex;
78
+ }
79
+ /**
80
+ * Options used when injecting a new workspace.
81
+ */
82
+ export interface InjectOptions {
83
+ /** Optional renderer overrides */
84
+ rendererOverrides?: {
85
+ [key: string]: any;
86
+ };
87
+ /** Theme for the workspace */
88
+ theme?: string | WSTheme;
89
+ /** Optional custom controller class */
90
+ Controller?: typeof WorkspaceController;
91
+ /** Init the workspace's undo state for you, or not. */
92
+ initUndoRedo?: boolean;
93
+ /** Optional controls configuration */
94
+ controls?: {
95
+ zoomSpeed?: number;
96
+ minZoom?: number;
97
+ maxZoom?: number;
98
+ wasd?: boolean;
99
+ wasdSmooth?: boolean;
100
+ wasdAccelerate?: number;
101
+ wasdFriction?: number;
102
+ };
103
+ /** Optional toolbox structure */
104
+ toolbox?: TblxObjStruct;
105
+ /** Optional movement speed of the workspace */
106
+ moveSpeed?: number;
107
+ /** Optional renderer: name string or class */
108
+ renderer?: string | typeof Renderer;
109
+ /**
110
+ * Optional grid settings.
111
+ */
112
+ grid?: GridOptions;
113
+ }
114
+ /**
115
+ * Utility class for logging injection messages in a structured way.
116
+ */
117
+ export declare class InjectMsg {
118
+ /** Message content */
119
+ msg: string;
120
+ /**
121
+ * Creates a new InjectMsg instance.
122
+ * @param msg - Message text
123
+ */
124
+ constructor(msg: string);
125
+ /** Log as error */
126
+ err(): void;
127
+ /** Log as warning */
128
+ wrn(): void;
129
+ /** Log as info */
130
+ info(): void;
131
+ }
132
+ /**
133
+ * Injects a new Kabel workspace into the document.
134
+ * Appends the workspace container to the given element (or element ID) and
135
+ * sets it as the main workspace.
136
+ *
137
+ * @param element - HTMLElement or string ID to attach the workspace to
138
+ * @param options - Optional InjectOptions to configure the workspace
139
+ * @returns The newly created WorkspaceSvg instance, or undefined if injection failed
140
+ */
141
+ export default function inject(element: HTMLElement | string, options?: InjectOptions): WorkspaceSvg | undefined;
142
+ //# sourceMappingURL=inject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inject.d.ts","sourceRoot":"","sources":["../../src/inject.ts"],"names":[],"mappings":"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"}
@@ -1,51 +1,31 @@
1
- import Workspace from "./workspace";
2
- import WorkspaceSvg from "./workspace-svg";
3
-
4
- /**
5
- * Holds a reference to the main WorkspaceSvg instance.
6
- * Mimics Blockly's getMainWorkspace API for Kabel.
7
- */
8
- let mainws: WorkspaceSvg | Workspace | null = null;
9
-
10
- /**
11
- * Returns the current main workspace instance.
12
- *
13
- * @returns The main WorkspaceSvg or null if none is set.
14
- */
15
- function getMainWorkspace(): WorkspaceSvg | Workspace | null {
16
- return mainws;
17
- }
18
-
19
- /**
20
- * Sets the main workspace reference.
21
- * Calling this updates the global "main workspace" for Kabel.
22
- *
23
- * @param ws - The WorkspaceSvg instance to set as main, or null to clear.
24
- * @returns The workspace that was set.
25
- */
26
- function setMainWorkspace(ws: WorkspaceSvg | Workspace | null) {
27
- return (mainws = ws);
28
- }
29
-
30
- /**
31
- * Clears the main workspace reference.
32
- * After calling, getMainWorkspace() will return null.
33
- *
34
- * @returns Always returns null.
35
- */
36
- function clearMainWorkspace() {
37
- return (mainws = null);
38
- }
39
-
40
- export {
41
- getMainWorkspace,
42
- setMainWorkspace,
43
- clearMainWorkspace
44
- };
45
-
46
- /**
47
- * Note:
48
- * This mimics the Blockly.getMainWorkspace API.
49
- * When you inject a new workspace in Kabel, calling setMainWorkspace
50
- * sets the global main workspace reference, so you can easily retrieve it later.
51
- */
1
+ import Workspace from "./workspace";
2
+ import WorkspaceSvg from "./workspace-svg";
3
+ /**
4
+ * Returns the current main workspace instance.
5
+ *
6
+ * @returns The main WorkspaceSvg or null if none is set.
7
+ */
8
+ declare function getMainWorkspace(): WorkspaceSvg | Workspace | null;
9
+ /**
10
+ * Sets the main workspace reference.
11
+ * Calling this updates the global "main workspace" for Kabel.
12
+ *
13
+ * @param ws - The WorkspaceSvg instance to set as main, or null to clear.
14
+ * @returns The workspace that was set.
15
+ */
16
+ declare function setMainWorkspace(ws: WorkspaceSvg | Workspace | null): WorkspaceSvg | Workspace | null;
17
+ /**
18
+ * Clears the main workspace reference.
19
+ * After calling, getMainWorkspace() will return null.
20
+ *
21
+ * @returns Always returns null.
22
+ */
23
+ declare function clearMainWorkspace(): null;
24
+ export { getMainWorkspace, setMainWorkspace, clearMainWorkspace };
25
+ /**
26
+ * Note:
27
+ * This mimics the Blockly.getMainWorkspace API.
28
+ * When you inject a new workspace in Kabel, calling setMainWorkspace
29
+ * sets the global main workspace reference, so you can easily retrieve it later.
30
+ */
31
+ //# sourceMappingURL=main-workspace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main-workspace.d.ts","sourceRoot":"","sources":["../../src/main-workspace.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAQ3C;;;;GAIG;AACH,iBAAS,gBAAgB,IAAI,YAAY,GAAG,SAAS,GAAG,IAAI,CAE3D;AAED;;;;;;GAMG;AACH,iBAAS,gBAAgB,CAAC,EAAE,EAAE,YAAY,GAAG,SAAS,GAAG,IAAI,mCAE5D;AAED;;;;;GAKG;AACH,iBAAS,kBAAkB,SAE1B;AAED,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EACrB,CAAC;AAEF;;;;;GAKG"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mutator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutator.d.ts","sourceRoot":"","sources":["../../src/mutator.ts"],"names":[],"mappings":""}
@@ -1,27 +1,26 @@
1
- import NodeSvg from "./nodesvg";
2
-
3
- /**
4
- * Represents a prototype definition for a NodeSvg.
5
- * Prototypes define behavior for initialization and removal of nodes.
6
- */
7
- export interface NodePrototype {
8
- /**
9
- * Called when a node is initialized.
10
- * Use this to set up fields, connections, or any runtime state for the node.
11
- *
12
- * @param this - The NodeSvg instance being initialized
13
- * @param prototype - The prototype object itself
14
- * @param block - The NodeSvg instance (same as `this`) for convenience
15
- */
16
- init: (this: NodeSvg, prototype: NodePrototype, block: NodeSvg) => void;
17
-
18
- /**
19
- * Called when a node is being removed from the workspace.
20
- * Use this to clean up references, event listeners, or related resources.
21
- *
22
- * @param this - The NodeSvg instance being removed
23
- * @param prototype - The prototype object itself
24
- * @param block - The NodeSvg instance (same as `this`) for convenience
25
- */
26
- removed: (this: NodeSvg, prototype: NodePrototype, block: NodeSvg) => void;
27
- }
1
+ import NodeSvg from "./nodesvg";
2
+ /**
3
+ * Represents a prototype definition for a NodeSvg.
4
+ * Prototypes define behavior for initialization and removal of nodes.
5
+ */
6
+ export interface NodePrototype {
7
+ /**
8
+ * Called when a node is initialized.
9
+ * Use this to set up fields, connections, or any runtime state for the node.
10
+ *
11
+ * @param this - The NodeSvg instance being initialized
12
+ * @param prototype - The prototype object itself
13
+ * @param block - The NodeSvg instance (same as `this`) for convenience
14
+ */
15
+ init: (this: NodeSvg, prototype: NodePrototype, block: NodeSvg) => void;
16
+ /**
17
+ * Called when a node is being removed from the workspace.
18
+ * Use this to clean up references, event listeners, or related resources.
19
+ *
20
+ * @param this - The NodeSvg instance being removed
21
+ * @param prototype - The prototype object itself
22
+ * @param block - The NodeSvg instance (same as `this`) for convenience
23
+ */
24
+ removed: (this: NodeSvg, prototype: NodePrototype, block: NodeSvg) => void;
25
+ }
26
+ //# sourceMappingURL=node-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-types.d.ts","sourceRoot":"","sources":["../../src/node-types.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B;;;;;;;OAOG;IACH,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAExE;;;;;;;OAOG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9E"}