@digipair/skill-web-editor 0.4.2

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,327 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index.cjs2.js');
4
+
5
+ const jsonGenerator = new Blockly.Generator('JSON');
6
+ jsonGenerator.PRECEDENCE = 0;
7
+ jsonGenerator['generic-scene-block'] = function(block) {
8
+ function safeParse(jsonString, defaultValue) {
9
+ try {
10
+ if (jsonString && jsonString.trim() !== '') {
11
+ return JSON.parse(jsonString);
12
+ }
13
+ } catch (e) {
14
+ console.error('JSON parsing error:', e);
15
+ }
16
+ return defaultValue;
17
+ }
18
+ const pinsCode = jsonGenerator.valueToCode(block, 'EXECUTE_PINS', jsonGenerator.PRECEDENCE) || 'null';
19
+ const metadataCode = jsonGenerator.valueToCode(block, 'METADATA_INPUT', jsonGenerator.PRECEDENCE) || '{}';
20
+ const eventsCode = jsonGenerator.valueToCode(block, 'EVENTS_INPUT', jsonGenerator.PRECEDENCE) || '{}';
21
+ const pinsData = safeParse(pinsCode, null);
22
+ const metadata = safeParse(metadataCode, {});
23
+ const events = safeParse(eventsCode, {});
24
+ const objectToSerialize = index._extends({
25
+ type: block.getFieldValue('SCENE_TYPE') || null,
26
+ metadata: metadata
27
+ }, pinsData !== null ? pinsData : {}, {
28
+ events: events
29
+ });
30
+ const serializedCode = JSON.stringify(objectToSerialize);
31
+ return [
32
+ serializedCode,
33
+ jsonGenerator.PRECEDENCE
34
+ ];
35
+ };
36
+ jsonGenerator['logic_null'] = function(block) {
37
+ return [
38
+ 'null',
39
+ jsonGenerator.PRECEDENCE
40
+ ];
41
+ };
42
+ jsonGenerator['text_multiline'] = function(block) {
43
+ const textValue = block.getFieldValue('TEXT');
44
+ const code = `${JSON.stringify(textValue)}`;
45
+ return [
46
+ code,
47
+ jsonGenerator.PRECEDENCE
48
+ ];
49
+ };
50
+ jsonGenerator['math_number'] = function(block) {
51
+ const code = String(block.getFieldValue('NUM'));
52
+ return [
53
+ code,
54
+ jsonGenerator.PRECEDENCE
55
+ ];
56
+ };
57
+ jsonGenerator['logic_boolean'] = function(block) {
58
+ const code = block.getFieldValue('BOOL') === 'TRUE' ? 'true' : 'false';
59
+ return [
60
+ code,
61
+ jsonGenerator.PRECEDENCE
62
+ ];
63
+ };
64
+ jsonGenerator['member'] = function(block) {
65
+ const name = block.getFieldValue('MEMBER_NAME');
66
+ const value = jsonGenerator.valueToCode(block, 'MEMBER_VALUE', jsonGenerator.PRECEDENCE);
67
+ const code = `"${name}": ${value}`;
68
+ return [
69
+ code,
70
+ jsonGenerator.PRECEDENCE
71
+ ];
72
+ };
73
+ jsonGenerator['array-input'] = function(block) {
74
+ const value = jsonGenerator.valueToCode(block, 'MEMBER_VALUE', jsonGenerator.PRECEDENCE);
75
+ const code = `${value}`;
76
+ return [
77
+ code,
78
+ jsonGenerator.PRECEDENCE
79
+ ];
80
+ };
81
+ jsonGenerator['array'] = function(block) {
82
+ const statementMembers = jsonGenerator.customStatementToCode(block, 'MEMBERS');
83
+ const code = '[\n' + statementMembers + '\n]';
84
+ return [
85
+ code,
86
+ jsonGenerator.PRECEDENCE
87
+ ];
88
+ };
89
+ jsonGenerator['object'] = function(block) {
90
+ const statementMembers = jsonGenerator.customStatementToCode(block, 'MEMBERS');
91
+ const code = '{\n' + statementMembers + '\n}';
92
+ return [
93
+ code,
94
+ jsonGenerator.PRECEDENCE
95
+ ];
96
+ };
97
+ jsonGenerator['unknown-format'] = function(block) {
98
+ const code = '"unknown-format"';
99
+ return [
100
+ code,
101
+ jsonGenerator.PRECEDENCE
102
+ ];
103
+ };
104
+ jsonGenerator['unknown-pins'] = function(block) {
105
+ const code = '"unknown-pins"';
106
+ return [
107
+ code,
108
+ jsonGenerator.PRECEDENCE
109
+ ];
110
+ };
111
+ jsonGenerator['unknown-component'] = function(block) {
112
+ const code = '"unknown-component"';
113
+ return [
114
+ code,
115
+ jsonGenerator.PRECEDENCE
116
+ ];
117
+ };
118
+ jsonGenerator.scrub_ = function(block, code, thisOnly) {
119
+ const nextBlock = block.nextConnection && block.nextConnection.targetBlock();
120
+ if (nextBlock && !thisOnly) {
121
+ return code + ',\n' + jsonGenerator.blockToCode(nextBlock);
122
+ }
123
+ return code;
124
+ };
125
+ jsonGenerator.generatePin = function(block) {
126
+ let code = '{\n';
127
+ const elementName = block.type.split('/__PINS__/')[1];
128
+ const libraryName = block.type.split('/__PINS__/')[0];
129
+ code += ` "library": "${libraryName}",`;
130
+ code += `\n "element": "${elementName}",`;
131
+ let propertiesCode = '';
132
+ let eventCode = '';
133
+ for(let i = 0, input; input = block.inputList[i]; i++){
134
+ const inputName = input.name;
135
+ const connectedBlock = input.connection && input.connection.targetBlock();
136
+ if (connectedBlock) {
137
+ if (inputName !== 'pins' && input.type == 3) {
138
+ const inputCode = jsonGenerator.customStatementToCode(block, inputName);
139
+ if (inputName.includes('__EVENT__/')) {
140
+ eventCode += ` "${inputName.split('__EVENT__/')[1]}": [${inputCode}],`;
141
+ } else {
142
+ propertiesCode += ` "${inputName}": [${inputCode}],`;
143
+ }
144
+ } else {
145
+ const codeToAdd = getCodeFromBlock(connectedBlock);
146
+ if (inputName === 'pins') {
147
+ const inputCode = jsonGenerator.customStatementToCode(block, inputName);
148
+ code += ` "${inputName}": [${inputCode}],`;
149
+ } else if (codeToAdd !== 'undefined') {
150
+ propertiesCode += ` "${inputName}": ${codeToAdd},`;
151
+ }
152
+ }
153
+ }
154
+ }
155
+ if (propertiesCode !== '') {
156
+ if (propertiesCode.endsWith(',')) {
157
+ propertiesCode = propertiesCode.slice(0, -1);
158
+ }
159
+ code += '\n"properties": {\n' + propertiesCode + '\n },';
160
+ }
161
+ if (eventCode !== '') {
162
+ if (eventCode.endsWith(',')) {
163
+ eventCode = eventCode.slice(0, -1);
164
+ }
165
+ code += '\n"events": {\n' + eventCode + '\n },';
166
+ }
167
+ if (code.endsWith(',')) {
168
+ code = code.slice(0, -1);
169
+ }
170
+ code += '}';
171
+ return [
172
+ code,
173
+ jsonGenerator.PRECEDENCE
174
+ ];
175
+ };
176
+ jsonGenerator.generateComponent = function(block) {
177
+ let code = '{\n';
178
+ for(let i = 0, input; input = block.inputList[i]; i++){
179
+ const inputName = input.name;
180
+ const connectedBlock = input.connection && input.connection.targetBlock();
181
+ let codeToAdd;
182
+ if (connectedBlock) {
183
+ if (input.type == 3) {
184
+ const code = jsonGenerator.customStatementToCode(block, inputName);
185
+ codeToAdd = '[' + code + ']';
186
+ } else {
187
+ codeToAdd = getCodeFromBlock(connectedBlock);
188
+ }
189
+ if (codeToAdd !== 'undefined') {
190
+ code += ` "${inputName}": ${codeToAdd},`;
191
+ }
192
+ }
193
+ }
194
+ if (code.endsWith(',')) {
195
+ code = code.slice(0, -1);
196
+ }
197
+ code += '\n}';
198
+ return [
199
+ code,
200
+ jsonGenerator.PRECEDENCE
201
+ ];
202
+ };
203
+ Blockly.Generator.prototype.blockToCode = function(block) {
204
+ if (!block) {
205
+ return '';
206
+ }
207
+ if (isPins(block)) {
208
+ return this.generatePin(block);
209
+ } else if (isComponent(block)) {
210
+ return this.generateComponent(block);
211
+ } else if (isSceneBlock(block)) {
212
+ return this.generateSceneBlock(block);
213
+ }
214
+ const func = this[block.type];
215
+ if (typeof func === 'function') {
216
+ const result = func.call(this, block);
217
+ if (Array.isArray(result) && result.length === 2) {
218
+ return result;
219
+ } else {
220
+ console.log('Unexpected result from generator for block type:', block.type, result);
221
+ return [
222
+ '',
223
+ 0
224
+ ];
225
+ }
226
+ }
227
+ };
228
+ jsonGenerator.customStatementToCode = function(block, inputName) {
229
+ let code = '';
230
+ let connectedBlock = block.getInputTargetBlock(inputName);
231
+ while(connectedBlock){
232
+ code += getCodeFromBlock(connectedBlock) + ',';
233
+ connectedBlock = connectedBlock.nextConnection && connectedBlock.nextConnection.targetBlock();
234
+ }
235
+ if (code.endsWith(',')) {
236
+ code = code.slice(0, -1);
237
+ }
238
+ return code;
239
+ };
240
+ function isPins(block) {
241
+ const blockType = block.type;
242
+ if (blockType.includes('/__PINS__/')) {
243
+ return true;
244
+ }
245
+ return false;
246
+ }
247
+ function isComponent(block) {
248
+ const blockType = block.type;
249
+ if (blockType.includes('/__COMPONENTS__/')) {
250
+ return true;
251
+ }
252
+ return false;
253
+ }
254
+ function isSceneBlock(block) {
255
+ const blockType = block.type;
256
+ if (blockType.includes('/__SCENEBLOCK__/')) {
257
+ return true;
258
+ }
259
+ return false;
260
+ }
261
+ jsonGenerator.generateSceneBlock = function(block) {
262
+ function safeParse(jsonString, defaultValue) {
263
+ try {
264
+ if (jsonString && jsonString.trim() !== '') {
265
+ return JSON.parse(jsonString);
266
+ }
267
+ } catch (e) {
268
+ console.error('JSON parsing error:', e);
269
+ }
270
+ return defaultValue;
271
+ }
272
+ const pinsCode = jsonGenerator.customStatementToCode(block, 'EXECUTE_PINS', jsonGenerator.PRECEDENCE) || '';
273
+ const pinsData = safeParse('[' + pinsCode + ']', null);
274
+ const metadata = {};
275
+ const properties = {};
276
+ block.inputList.forEach(function(input) {
277
+ if (input.name !== 'EXECUTE_PINS') {
278
+ const isMetadata = input.name.startsWith('metadata--');
279
+ const target = isMetadata ? metadata : properties;
280
+ const name = isMetadata ? input.name.replace('metadata--', '') : input.name;
281
+ const fieldValue = valueToCode(block, input);
282
+ if (fieldValue) {
283
+ target[name] = safeParse(fieldValue, {});
284
+ }
285
+ }
286
+ });
287
+ const element = block.type.split('/__SCENEBLOCK__/')[1];
288
+ const library = block.type.split('/__SCENEBLOCK__/')[0];
289
+ const objectToSerialize = {
290
+ library,
291
+ element,
292
+ metadata,
293
+ properties,
294
+ pins: pinsData !== null ? pinsData : []
295
+ };
296
+ const serializedCode = JSON.stringify(objectToSerialize);
297
+ return [
298
+ serializedCode,
299
+ jsonGenerator.PRECEDENCE
300
+ ];
301
+ };
302
+ function getCodeFromBlock(block) {
303
+ let code = '';
304
+ if (isPins(block)) {
305
+ const pinCode = jsonGenerator.generatePin(block);
306
+ code += pinCode[0];
307
+ } else if (isComponent(block)) {
308
+ const componentCode = jsonGenerator.generateComponent(block);
309
+ code += componentCode[0];
310
+ } else {
311
+ const generalCode = jsonGenerator[block.type](block);
312
+ code += generalCode[0];
313
+ }
314
+ return code;
315
+ }
316
+ function valueToCode(block, input) {
317
+ let result = '';
318
+ if (input.type === 3) {
319
+ const code = jsonGenerator.customStatementToCode(block, input.name);
320
+ result = '[' + code + ']';
321
+ } else {
322
+ result = jsonGenerator.valueToCode(block, input.name, jsonGenerator.PRECEDENCE);
323
+ }
324
+ return result;
325
+ }
326
+
327
+ exports.jsonGenerator = jsonGenerator;
@@ -0,0 +1,325 @@
1
+ import { _ as _extends } from './index.esm2.js';
2
+
3
+ const jsonGenerator = new Blockly.Generator('JSON');
4
+ jsonGenerator.PRECEDENCE = 0;
5
+ jsonGenerator['generic-scene-block'] = function(block) {
6
+ function safeParse(jsonString, defaultValue) {
7
+ try {
8
+ if (jsonString && jsonString.trim() !== '') {
9
+ return JSON.parse(jsonString);
10
+ }
11
+ } catch (e) {
12
+ console.error('JSON parsing error:', e);
13
+ }
14
+ return defaultValue;
15
+ }
16
+ const pinsCode = jsonGenerator.valueToCode(block, 'EXECUTE_PINS', jsonGenerator.PRECEDENCE) || 'null';
17
+ const metadataCode = jsonGenerator.valueToCode(block, 'METADATA_INPUT', jsonGenerator.PRECEDENCE) || '{}';
18
+ const eventsCode = jsonGenerator.valueToCode(block, 'EVENTS_INPUT', jsonGenerator.PRECEDENCE) || '{}';
19
+ const pinsData = safeParse(pinsCode, null);
20
+ const metadata = safeParse(metadataCode, {});
21
+ const events = safeParse(eventsCode, {});
22
+ const objectToSerialize = _extends({
23
+ type: block.getFieldValue('SCENE_TYPE') || null,
24
+ metadata: metadata
25
+ }, pinsData !== null ? pinsData : {}, {
26
+ events: events
27
+ });
28
+ const serializedCode = JSON.stringify(objectToSerialize);
29
+ return [
30
+ serializedCode,
31
+ jsonGenerator.PRECEDENCE
32
+ ];
33
+ };
34
+ jsonGenerator['logic_null'] = function(block) {
35
+ return [
36
+ 'null',
37
+ jsonGenerator.PRECEDENCE
38
+ ];
39
+ };
40
+ jsonGenerator['text_multiline'] = function(block) {
41
+ const textValue = block.getFieldValue('TEXT');
42
+ const code = `${JSON.stringify(textValue)}`;
43
+ return [
44
+ code,
45
+ jsonGenerator.PRECEDENCE
46
+ ];
47
+ };
48
+ jsonGenerator['math_number'] = function(block) {
49
+ const code = String(block.getFieldValue('NUM'));
50
+ return [
51
+ code,
52
+ jsonGenerator.PRECEDENCE
53
+ ];
54
+ };
55
+ jsonGenerator['logic_boolean'] = function(block) {
56
+ const code = block.getFieldValue('BOOL') === 'TRUE' ? 'true' : 'false';
57
+ return [
58
+ code,
59
+ jsonGenerator.PRECEDENCE
60
+ ];
61
+ };
62
+ jsonGenerator['member'] = function(block) {
63
+ const name = block.getFieldValue('MEMBER_NAME');
64
+ const value = jsonGenerator.valueToCode(block, 'MEMBER_VALUE', jsonGenerator.PRECEDENCE);
65
+ const code = `"${name}": ${value}`;
66
+ return [
67
+ code,
68
+ jsonGenerator.PRECEDENCE
69
+ ];
70
+ };
71
+ jsonGenerator['array-input'] = function(block) {
72
+ const value = jsonGenerator.valueToCode(block, 'MEMBER_VALUE', jsonGenerator.PRECEDENCE);
73
+ const code = `${value}`;
74
+ return [
75
+ code,
76
+ jsonGenerator.PRECEDENCE
77
+ ];
78
+ };
79
+ jsonGenerator['array'] = function(block) {
80
+ const statementMembers = jsonGenerator.customStatementToCode(block, 'MEMBERS');
81
+ const code = '[\n' + statementMembers + '\n]';
82
+ return [
83
+ code,
84
+ jsonGenerator.PRECEDENCE
85
+ ];
86
+ };
87
+ jsonGenerator['object'] = function(block) {
88
+ const statementMembers = jsonGenerator.customStatementToCode(block, 'MEMBERS');
89
+ const code = '{\n' + statementMembers + '\n}';
90
+ return [
91
+ code,
92
+ jsonGenerator.PRECEDENCE
93
+ ];
94
+ };
95
+ jsonGenerator['unknown-format'] = function(block) {
96
+ const code = '"unknown-format"';
97
+ return [
98
+ code,
99
+ jsonGenerator.PRECEDENCE
100
+ ];
101
+ };
102
+ jsonGenerator['unknown-pins'] = function(block) {
103
+ const code = '"unknown-pins"';
104
+ return [
105
+ code,
106
+ jsonGenerator.PRECEDENCE
107
+ ];
108
+ };
109
+ jsonGenerator['unknown-component'] = function(block) {
110
+ const code = '"unknown-component"';
111
+ return [
112
+ code,
113
+ jsonGenerator.PRECEDENCE
114
+ ];
115
+ };
116
+ jsonGenerator.scrub_ = function(block, code, thisOnly) {
117
+ const nextBlock = block.nextConnection && block.nextConnection.targetBlock();
118
+ if (nextBlock && !thisOnly) {
119
+ return code + ',\n' + jsonGenerator.blockToCode(nextBlock);
120
+ }
121
+ return code;
122
+ };
123
+ jsonGenerator.generatePin = function(block) {
124
+ let code = '{\n';
125
+ const elementName = block.type.split('/__PINS__/')[1];
126
+ const libraryName = block.type.split('/__PINS__/')[0];
127
+ code += ` "library": "${libraryName}",`;
128
+ code += `\n "element": "${elementName}",`;
129
+ let propertiesCode = '';
130
+ let eventCode = '';
131
+ for(let i = 0, input; input = block.inputList[i]; i++){
132
+ const inputName = input.name;
133
+ const connectedBlock = input.connection && input.connection.targetBlock();
134
+ if (connectedBlock) {
135
+ if (inputName !== 'pins' && input.type == 3) {
136
+ const inputCode = jsonGenerator.customStatementToCode(block, inputName);
137
+ if (inputName.includes('__EVENT__/')) {
138
+ eventCode += ` "${inputName.split('__EVENT__/')[1]}": [${inputCode}],`;
139
+ } else {
140
+ propertiesCode += ` "${inputName}": [${inputCode}],`;
141
+ }
142
+ } else {
143
+ const codeToAdd = getCodeFromBlock(connectedBlock);
144
+ if (inputName === 'pins') {
145
+ const inputCode = jsonGenerator.customStatementToCode(block, inputName);
146
+ code += ` "${inputName}": [${inputCode}],`;
147
+ } else if (codeToAdd !== 'undefined') {
148
+ propertiesCode += ` "${inputName}": ${codeToAdd},`;
149
+ }
150
+ }
151
+ }
152
+ }
153
+ if (propertiesCode !== '') {
154
+ if (propertiesCode.endsWith(',')) {
155
+ propertiesCode = propertiesCode.slice(0, -1);
156
+ }
157
+ code += '\n"properties": {\n' + propertiesCode + '\n },';
158
+ }
159
+ if (eventCode !== '') {
160
+ if (eventCode.endsWith(',')) {
161
+ eventCode = eventCode.slice(0, -1);
162
+ }
163
+ code += '\n"events": {\n' + eventCode + '\n },';
164
+ }
165
+ if (code.endsWith(',')) {
166
+ code = code.slice(0, -1);
167
+ }
168
+ code += '}';
169
+ return [
170
+ code,
171
+ jsonGenerator.PRECEDENCE
172
+ ];
173
+ };
174
+ jsonGenerator.generateComponent = function(block) {
175
+ let code = '{\n';
176
+ for(let i = 0, input; input = block.inputList[i]; i++){
177
+ const inputName = input.name;
178
+ const connectedBlock = input.connection && input.connection.targetBlock();
179
+ let codeToAdd;
180
+ if (connectedBlock) {
181
+ if (input.type == 3) {
182
+ const code = jsonGenerator.customStatementToCode(block, inputName);
183
+ codeToAdd = '[' + code + ']';
184
+ } else {
185
+ codeToAdd = getCodeFromBlock(connectedBlock);
186
+ }
187
+ if (codeToAdd !== 'undefined') {
188
+ code += ` "${inputName}": ${codeToAdd},`;
189
+ }
190
+ }
191
+ }
192
+ if (code.endsWith(',')) {
193
+ code = code.slice(0, -1);
194
+ }
195
+ code += '\n}';
196
+ return [
197
+ code,
198
+ jsonGenerator.PRECEDENCE
199
+ ];
200
+ };
201
+ Blockly.Generator.prototype.blockToCode = function(block) {
202
+ if (!block) {
203
+ return '';
204
+ }
205
+ if (isPins(block)) {
206
+ return this.generatePin(block);
207
+ } else if (isComponent(block)) {
208
+ return this.generateComponent(block);
209
+ } else if (isSceneBlock(block)) {
210
+ return this.generateSceneBlock(block);
211
+ }
212
+ const func = this[block.type];
213
+ if (typeof func === 'function') {
214
+ const result = func.call(this, block);
215
+ if (Array.isArray(result) && result.length === 2) {
216
+ return result;
217
+ } else {
218
+ console.log('Unexpected result from generator for block type:', block.type, result);
219
+ return [
220
+ '',
221
+ 0
222
+ ];
223
+ }
224
+ }
225
+ };
226
+ jsonGenerator.customStatementToCode = function(block, inputName) {
227
+ let code = '';
228
+ let connectedBlock = block.getInputTargetBlock(inputName);
229
+ while(connectedBlock){
230
+ code += getCodeFromBlock(connectedBlock) + ',';
231
+ connectedBlock = connectedBlock.nextConnection && connectedBlock.nextConnection.targetBlock();
232
+ }
233
+ if (code.endsWith(',')) {
234
+ code = code.slice(0, -1);
235
+ }
236
+ return code;
237
+ };
238
+ function isPins(block) {
239
+ const blockType = block.type;
240
+ if (blockType.includes('/__PINS__/')) {
241
+ return true;
242
+ }
243
+ return false;
244
+ }
245
+ function isComponent(block) {
246
+ const blockType = block.type;
247
+ if (blockType.includes('/__COMPONENTS__/')) {
248
+ return true;
249
+ }
250
+ return false;
251
+ }
252
+ function isSceneBlock(block) {
253
+ const blockType = block.type;
254
+ if (blockType.includes('/__SCENEBLOCK__/')) {
255
+ return true;
256
+ }
257
+ return false;
258
+ }
259
+ jsonGenerator.generateSceneBlock = function(block) {
260
+ function safeParse(jsonString, defaultValue) {
261
+ try {
262
+ if (jsonString && jsonString.trim() !== '') {
263
+ return JSON.parse(jsonString);
264
+ }
265
+ } catch (e) {
266
+ console.error('JSON parsing error:', e);
267
+ }
268
+ return defaultValue;
269
+ }
270
+ const pinsCode = jsonGenerator.customStatementToCode(block, 'EXECUTE_PINS', jsonGenerator.PRECEDENCE) || '';
271
+ const pinsData = safeParse('[' + pinsCode + ']', null);
272
+ const metadata = {};
273
+ const properties = {};
274
+ block.inputList.forEach(function(input) {
275
+ if (input.name !== 'EXECUTE_PINS') {
276
+ const isMetadata = input.name.startsWith('metadata--');
277
+ const target = isMetadata ? metadata : properties;
278
+ const name = isMetadata ? input.name.replace('metadata--', '') : input.name;
279
+ const fieldValue = valueToCode(block, input);
280
+ if (fieldValue) {
281
+ target[name] = safeParse(fieldValue, {});
282
+ }
283
+ }
284
+ });
285
+ const element = block.type.split('/__SCENEBLOCK__/')[1];
286
+ const library = block.type.split('/__SCENEBLOCK__/')[0];
287
+ const objectToSerialize = {
288
+ library,
289
+ element,
290
+ metadata,
291
+ properties,
292
+ pins: pinsData !== null ? pinsData : []
293
+ };
294
+ const serializedCode = JSON.stringify(objectToSerialize);
295
+ return [
296
+ serializedCode,
297
+ jsonGenerator.PRECEDENCE
298
+ ];
299
+ };
300
+ function getCodeFromBlock(block) {
301
+ let code = '';
302
+ if (isPins(block)) {
303
+ const pinCode = jsonGenerator.generatePin(block);
304
+ code += pinCode[0];
305
+ } else if (isComponent(block)) {
306
+ const componentCode = jsonGenerator.generateComponent(block);
307
+ code += componentCode[0];
308
+ } else {
309
+ const generalCode = jsonGenerator[block.type](block);
310
+ code += generalCode[0];
311
+ }
312
+ return code;
313
+ }
314
+ function valueToCode(block, input) {
315
+ let result = '';
316
+ if (input.type === 3) {
317
+ const code = jsonGenerator.customStatementToCode(block, input.name);
318
+ result = '[' + code + ']';
319
+ } else {
320
+ result = jsonGenerator.valueToCode(block, input.name, jsonGenerator.PRECEDENCE);
321
+ }
322
+ return result;
323
+ }
324
+
325
+ export { jsonGenerator };
package/index.cjs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src/index";
package/index.cjs.js ADDED
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var index = require('./index.cjs2.js');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, 'GenericSceneElement', {
10
+ enumerable: true,
11
+ get: function () { return index.GenericSceneElement; }
12
+ });
13
+ exports.error = index.error;
14
+ exports.information = index.information;