@tvolden/block-code-editor 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ import type { BlockDefinition } from './types';
2
+ export interface PackageInfo {
3
+ id: string;
4
+ name: string;
5
+ description: string;
6
+ url: string;
7
+ builtIn: boolean;
8
+ }
9
+ export interface LoadedPackage {
10
+ info: PackageInfo;
11
+ blockIds: string[];
12
+ conflictIds: string[];
13
+ }
14
+ /** Fetch a package JSON and merge its blocks into the registry (first-registered wins). */
15
+ export declare function loadPackage(info: PackageInfo): Promise<LoadedPackage>;
16
+ /** Remove all blocks that belong to a package. No-op if not loaded. */
17
+ export declare function unloadPackage(packageId: string): void;
18
+ /** All currently-loaded packages in load order. */
19
+ export declare function getLoadedPackages(): LoadedPackage[];
20
+ /** Which package owns a block ID (undefined if unknown). */
21
+ export declare function getBlockPackageId(blockId: string): string | undefined;
22
+ export declare function getDefinition(id: string): BlockDefinition;
23
+ export declare function tryGetDefinition(id: string): BlockDefinition | undefined;
24
+ export declare function getAllDefinitions(): BlockDefinition[];
25
+ export declare function getCategories(): string[];
26
+ /** Register block definitions directly (no URL fetch). First-registered wins on conflicts. */
27
+ export declare function loadInlinePackage(info: PackageInfo, defs: BlockDefinition[]): LoadedPackage;
28
+ /** Load the initial/core block set. Clears all prior registry state first. */
29
+ export declare function loadBlockRegistry(url: string): Promise<void>;
@@ -0,0 +1,367 @@
1
+ [
2
+ {
3
+ "id": "when-played",
4
+ "name": "When Played",
5
+ "blockType": "start",
6
+ "params": [],
7
+ "category": "Events",
8
+ "color": "#FFAB19"
9
+ },
10
+ {
11
+ "id": "when-active",
12
+ "name": "When Active",
13
+ "blockType": "start",
14
+ "params": [],
15
+ "category": "Events",
16
+ "color": "#FFAB19"
17
+ },
18
+ {
19
+ "id": "when-drawn",
20
+ "name": "When Drawn",
21
+ "blockType": "start",
22
+ "params": [],
23
+ "category": "Events",
24
+ "color": "#FFAB19"
25
+ },
26
+ {
27
+ "id": "move",
28
+ "name": "Move",
29
+ "blockType": "command",
30
+ "params": [
31
+ {
32
+ "name": "steps",
33
+ "type": "number"
34
+ }
35
+ ],
36
+ "category": "Motion",
37
+ "color": "#4C97FF"
38
+ },
39
+ {
40
+ "id": "turn-cw",
41
+ "name": "Turn CW",
42
+ "blockType": "command",
43
+ "params": [
44
+ {
45
+ "name": "degrees",
46
+ "type": "number"
47
+ }
48
+ ],
49
+ "category": "Motion",
50
+ "color": "#4C97FF"
51
+ },
52
+ {
53
+ "id": "go-to",
54
+ "name": "Go To",
55
+ "blockType": "command",
56
+ "params": [
57
+ {
58
+ "name": "x",
59
+ "type": "number"
60
+ },
61
+ {
62
+ "name": "y",
63
+ "type": "number"
64
+ }
65
+ ],
66
+ "category": "Motion",
67
+ "color": "#4C97FF"
68
+ },
69
+ {
70
+ "id": "point-dir",
71
+ "name": "Point Dir",
72
+ "blockType": "command",
73
+ "params": [
74
+ {
75
+ "name": "dir",
76
+ "type": "number"
77
+ }
78
+ ],
79
+ "category": "Motion",
80
+ "color": "#4C97FF"
81
+ },
82
+ {
83
+ "id": "say",
84
+ "name": "Say",
85
+ "blockType": "command",
86
+ "params": [
87
+ {
88
+ "name": "message",
89
+ "type": "string"
90
+ }
91
+ ],
92
+ "category": "Looks",
93
+ "color": "#9966FF"
94
+ },
95
+ {
96
+ "id": "show",
97
+ "name": "Show",
98
+ "blockType": "command",
99
+ "params": [],
100
+ "category": "Looks",
101
+ "color": "#9966FF"
102
+ },
103
+ {
104
+ "id": "hide",
105
+ "name": "Hide",
106
+ "blockType": "command",
107
+ "params": [],
108
+ "category": "Looks",
109
+ "color": "#9966FF"
110
+ },
111
+ {
112
+ "id": "set-color",
113
+ "name": "Set Color",
114
+ "blockType": "command",
115
+ "params": [
116
+ {
117
+ "name": "color",
118
+ "type": "string"
119
+ }
120
+ ],
121
+ "category": "Looks",
122
+ "color": "#9966FF"
123
+ },
124
+ {
125
+ "id": "wait",
126
+ "name": "Wait",
127
+ "blockType": "command",
128
+ "params": [
129
+ {
130
+ "name": "secs",
131
+ "type": "number"
132
+ }
133
+ ],
134
+ "category": "Control",
135
+ "color": "#FFAB19"
136
+ },
137
+ {
138
+ "id": "repeat",
139
+ "name": "Repeat",
140
+ "blockType": "command",
141
+ "params": [
142
+ {
143
+ "name": "times",
144
+ "type": "number"
145
+ }
146
+ ],
147
+ "category": "Control",
148
+ "color": "#FFAB19"
149
+ },
150
+ {
151
+ "id": "if",
152
+ "name": "If",
153
+ "blockType": "command",
154
+ "params": [
155
+ {
156
+ "name": "cond",
157
+ "type": "boolean"
158
+ }
159
+ ],
160
+ "category": "Control",
161
+ "color": "#FFAB19"
162
+ },
163
+ {
164
+ "id": "x-position",
165
+ "name": "X Position",
166
+ "blockType": "query",
167
+ "returnType": "number",
168
+ "params": [],
169
+ "category": "Sensing",
170
+ "color": "#5CB1D6"
171
+ },
172
+ {
173
+ "id": "y-position",
174
+ "name": "Y Position",
175
+ "blockType": "query",
176
+ "returnType": "number",
177
+ "params": [],
178
+ "category": "Sensing",
179
+ "color": "#5CB1D6"
180
+ },
181
+ {
182
+ "id": "direction",
183
+ "name": "Direction",
184
+ "blockType": "query",
185
+ "returnType": "number",
186
+ "params": [],
187
+ "category": "Sensing",
188
+ "color": "#5CB1D6"
189
+ },
190
+ {
191
+ "id": "timer",
192
+ "name": "Timer",
193
+ "blockType": "query",
194
+ "returnType": "number",
195
+ "params": [],
196
+ "category": "Sensing",
197
+ "color": "#5CB1D6"
198
+ },
199
+ {
200
+ "id": "is-touching",
201
+ "name": "Is Touching",
202
+ "blockType": "query",
203
+ "returnType": "boolean",
204
+ "params": [
205
+ {
206
+ "name": "obj",
207
+ "type": "object"
208
+ }
209
+ ],
210
+ "category": "Sensing",
211
+ "color": "#5CB1D6"
212
+ },
213
+ {
214
+ "id": "key-pressed",
215
+ "name": "Key Pressed",
216
+ "blockType": "query",
217
+ "returnType": "boolean",
218
+ "params": [
219
+ {
220
+ "name": "key",
221
+ "type": "string"
222
+ }
223
+ ],
224
+ "category": "Sensing",
225
+ "color": "#5CB1D6"
226
+ },
227
+ {
228
+ "id": "get-name",
229
+ "name": "Get Name",
230
+ "blockType": "query",
231
+ "returnType": "string",
232
+ "params": [],
233
+ "category": "Sensing",
234
+ "color": "#5CB1D6"
235
+ },
236
+ {
237
+ "id": "get-self",
238
+ "name": "Get Self",
239
+ "blockType": "query",
240
+ "returnType": "object",
241
+ "params": [],
242
+ "category": "Sensing",
243
+ "color": "#5CB1D6"
244
+ },
245
+ {
246
+ "id": "add",
247
+ "name": "Add",
248
+ "blockType": "query",
249
+ "returnType": "number",
250
+ "params": [
251
+ {
252
+ "name": "a",
253
+ "type": "number"
254
+ },
255
+ {
256
+ "name": "b",
257
+ "type": "number"
258
+ }
259
+ ],
260
+ "category": "Operators",
261
+ "color": "#59C059"
262
+ },
263
+ {
264
+ "id": "subtract",
265
+ "name": "Subtract",
266
+ "blockType": "query",
267
+ "returnType": "number",
268
+ "params": [
269
+ {
270
+ "name": "a",
271
+ "type": "number"
272
+ },
273
+ {
274
+ "name": "b",
275
+ "type": "number"
276
+ }
277
+ ],
278
+ "category": "Operators",
279
+ "color": "#59C059"
280
+ },
281
+ {
282
+ "id": "multiply",
283
+ "name": "Multiply",
284
+ "blockType": "query",
285
+ "returnType": "number",
286
+ "params": [
287
+ {
288
+ "name": "a",
289
+ "type": "number"
290
+ },
291
+ {
292
+ "name": "b",
293
+ "type": "number"
294
+ }
295
+ ],
296
+ "category": "Operators",
297
+ "color": "#59C059"
298
+ },
299
+ {
300
+ "id": "and",
301
+ "name": "And",
302
+ "blockType": "query",
303
+ "returnType": "boolean",
304
+ "params": [
305
+ {
306
+ "name": "a",
307
+ "type": "boolean"
308
+ },
309
+ {
310
+ "name": "b",
311
+ "type": "boolean"
312
+ }
313
+ ],
314
+ "category": "Operators",
315
+ "color": "#59C059"
316
+ },
317
+ {
318
+ "id": "or",
319
+ "name": "Or",
320
+ "blockType": "query",
321
+ "returnType": "boolean",
322
+ "params": [
323
+ {
324
+ "name": "a",
325
+ "type": "boolean"
326
+ },
327
+ {
328
+ "name": "b",
329
+ "type": "boolean"
330
+ }
331
+ ],
332
+ "category": "Operators",
333
+ "color": "#59C059"
334
+ },
335
+ {
336
+ "id": "not",
337
+ "name": "Not",
338
+ "blockType": "query",
339
+ "returnType": "boolean",
340
+ "params": [
341
+ {
342
+ "name": "cond",
343
+ "type": "boolean"
344
+ }
345
+ ],
346
+ "category": "Operators",
347
+ "color": "#59C059"
348
+ },
349
+ {
350
+ "id": "join",
351
+ "name": "Join",
352
+ "blockType": "query",
353
+ "returnType": "string",
354
+ "params": [
355
+ {
356
+ "name": "a",
357
+ "type": "string"
358
+ },
359
+ {
360
+ "name": "b",
361
+ "type": "string"
362
+ }
363
+ ],
364
+ "category": "Operators",
365
+ "color": "#59C059"
366
+ }
367
+ ]
@@ -0,0 +1,161 @@
1
+ [
2
+ {
3
+ "id": "when-played",
4
+ "name": "When Played",
5
+ "blockType": "start",
6
+ "params": [],
7
+ "category": "Events",
8
+ "color": "#7A1C2A"
9
+ },
10
+ {
11
+ "id": "when-active",
12
+ "name": "When Active",
13
+ "blockType": "start",
14
+ "params": [],
15
+ "category": "Events",
16
+ "color": "#7A1C2A"
17
+ },
18
+ {
19
+ "id": "when-drawn",
20
+ "name": "When Drawn",
21
+ "blockType": "start",
22
+ "params": [],
23
+ "category": "Events",
24
+ "color": "#7A1C2A"
25
+ },
26
+ {
27
+ "id": "DrawCard",
28
+ "name": "Draw Card",
29
+ "blockType": "command",
30
+ "params": [
31
+ { "name": "deck", "type": "Deck" },
32
+ { "name": "hand", "type": "string" }
33
+ ],
34
+ "category": "Actions",
35
+ "color": "#1C3A7A"
36
+ },
37
+ {
38
+ "id": "PlayCard",
39
+ "name": "Play Card",
40
+ "blockType": "command",
41
+ "params": [
42
+ { "name": "card", "type": "Card" },
43
+ { "name": "target", "type": "Player" }
44
+ ],
45
+ "category": "Actions",
46
+ "color": "#1C3A7A"
47
+ },
48
+ {
49
+ "id": "GainMana",
50
+ "name": "Gain Mana",
51
+ "blockType": "command",
52
+ "params": [
53
+ { "name": "amount", "type": "number" }
54
+ ],
55
+ "category": "Actions",
56
+ "color": "#1C3A7A"
57
+ },
58
+ {
59
+ "id": "SelfPlayer",
60
+ "name": "Self",
61
+ "blockType": "query",
62
+ "returnType": "Player",
63
+ "params": [],
64
+ "category": "Player",
65
+ "color": "#1C6B3A"
66
+ },
67
+ {
68
+ "id": "TargetPlayer",
69
+ "name": "Target Player",
70
+ "blockType": "query",
71
+ "returnType": "Player",
72
+ "params": [],
73
+ "category": "Player",
74
+ "color": "#1C6B3A"
75
+ },
76
+ {
77
+ "id": "PlayerHand",
78
+ "name": "Player Hand",
79
+ "blockType": "query",
80
+ "returnType": "string",
81
+ "params": [
82
+ { "name": "player", "type": "Player" }
83
+ ],
84
+ "category": "Player",
85
+ "color": "#1C6B3A"
86
+ },
87
+ {
88
+ "id": "HandSize",
89
+ "name": "Hand Size",
90
+ "blockType": "query",
91
+ "returnType": "number",
92
+ "params": [
93
+ { "name": "player", "type": "Player" }
94
+ ],
95
+ "category": "Player",
96
+ "color": "#1C6B3A"
97
+ },
98
+ {
99
+ "id": "MainDeck",
100
+ "name": "Main Deck",
101
+ "blockType": "query",
102
+ "returnType": "Deck",
103
+ "params": [],
104
+ "category": "Deck",
105
+ "color": "#7A561C"
106
+ },
107
+ {
108
+ "id": "DiscardPile",
109
+ "name": "Discard Pile",
110
+ "blockType": "query",
111
+ "returnType": "Deck",
112
+ "params": [],
113
+ "category": "Deck",
114
+ "color": "#7A561C"
115
+ },
116
+ {
117
+ "id": "DeckSize",
118
+ "name": "Deck Size",
119
+ "blockType": "query",
120
+ "returnType": "number",
121
+ "params": [
122
+ { "name": "deck", "type": "Deck" }
123
+ ],
124
+ "category": "Deck",
125
+ "color": "#7A561C"
126
+ },
127
+ {
128
+ "id": "TopCard",
129
+ "name": "Top Card",
130
+ "blockType": "query",
131
+ "returnType": "Card",
132
+ "params": [
133
+ { "name": "deck", "type": "Deck" }
134
+ ],
135
+ "category": "Card",
136
+ "color": "#5A1C7A"
137
+ },
138
+ {
139
+ "id": "CardAtIndex",
140
+ "name": "Card At",
141
+ "blockType": "query",
142
+ "returnType": "Card",
143
+ "params": [
144
+ { "name": "deck", "type": "Deck" },
145
+ { "name": "index", "type": "number" }
146
+ ],
147
+ "category": "Card",
148
+ "color": "#5A1C7A"
149
+ },
150
+ {
151
+ "id": "CardCost",
152
+ "name": "Card Cost",
153
+ "blockType": "query",
154
+ "returnType": "number",
155
+ "params": [
156
+ { "name": "card", "type": "Card" }
157
+ ],
158
+ "category": "Card",
159
+ "color": "#5A1C7A"
160
+ }
161
+ ]
@@ -0,0 +1,10 @@
1
+ import type { CardDesign } from './cardDesignTypes';
2
+ interface Props {
3
+ design: CardDesign;
4
+ selectedId: string | null;
5
+ onSelect: (id: string | null) => void;
6
+ onMove: (id: string, x: number, y: number) => void;
7
+ onResize: (id: string, x: number, y: number, w: number, h: number) => void;
8
+ }
9
+ export default function CardCanvas({ design, selectedId, onSelect, onMove, onResize }: Props): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import type { Theme, ThemeId } from '../theme';
3
+ import type { CardDesign } from './cardDesignTypes';
4
+ interface Props {
5
+ onThemeChange?: (t: Theme) => void;
6
+ navTabs?: React.ReactNode;
7
+ /**
8
+ * When provided, the designer syncs its theme to the platform's theme and
9
+ * sets up its own ThemeContext.Provider (enabling standalone use outside
10
+ * of the editor's App shell).
11
+ */
12
+ themeId?: ThemeId;
13
+ /** When true, the built-in title bar is not rendered. */
14
+ hideTitleBar?: boolean;
15
+ /**
16
+ * When true, only the left meta panel is rendered (no card canvas or
17
+ * element-properties panel). Width shrinks to match the panel.
18
+ */
19
+ compactMode?: boolean;
20
+ /**
21
+ * When true, only the canvas and element-properties panel are rendered
22
+ * (no title bar, no meta panel). The component expands to fill available
23
+ * space. Combine with compactMode on a sibling instance and shared
24
+ * controlled state to split the designer into a persistent left panel and
25
+ * a tab-conditional workspace.
26
+ */
27
+ workspaceOnly?: boolean;
28
+ /** External design state. When provided the component is controlled. */
29
+ design?: CardDesign;
30
+ onDesignChange?: (design: CardDesign) => void;
31
+ /** External selection state. Used together with design for controlled mode. */
32
+ selectedId?: string | null;
33
+ onSelectedIdChange?: (id: string | null) => void;
34
+ /**
35
+ * When provided, replaces the built-in JSON export with a custom handler
36
+ * (e.g. YAML export with combined block-program state from the platform).
37
+ */
38
+ onExport?: () => void;
39
+ /**
40
+ * When provided, replaces the built-in JSON import with a custom handler.
41
+ * The handler is responsible for opening a file picker and calling
42
+ * onDesignChange with the loaded design.
43
+ */
44
+ onImport?: () => void;
45
+ }
46
+ export default function CardDesigner({ onThemeChange, navTabs, themeId, hideTitleBar, compactMode, workspaceOnly, design: externalDesign, onDesignChange, selectedId: externalSelectedId, onSelectedIdChange, onExport, onImport, }: Props): import("react/jsx-runtime").JSX.Element;
47
+ export {};
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { CardDesign } from './cardDesignTypes';
3
+ interface Props {
4
+ design: CardDesign;
5
+ /** Unique string used to scope SVG filter/clip IDs — pass the card's id. */
6
+ uid: string;
7
+ style?: React.CSSProperties;
8
+ className?: string;
9
+ }
10
+ export default function CardPreview({ design, uid, style, className }: Props): import("react/jsx-runtime").JSX.Element;
11
+ export {};