@digipair/skill-web-editor 0.4.10 → 0.4.12

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.
@@ -11,7 +11,7 @@ function getPinsBlockDefinition(library, methodData, pinsId) {
11
11
  args2: [],
12
12
  message3: '',
13
13
  args3: [],
14
- colour: '#1e2835',
14
+ colour: '#4285f4',
15
15
  tooltip: 'library : ' + library.info.title,
16
16
  inputsInline: false,
17
17
  previousStatement: null,
@@ -32,7 +32,11 @@ function getPinsBlockDefinition(library, methodData, pinsId) {
32
32
  });
33
33
  }
34
34
  requiredFields.push('');
35
- const mutatorToolbox = parameters.map((param)=>param.name).filter((name)=>!requiredFields.includes(name));
35
+ const mutatorToolbox = [
36
+ ...parameters.map((param)=>param.name).filter((name)=>!requiredFields.includes(name)),
37
+ '__CONDITION__/if',
38
+ '__CONDITION__/each'
39
+ ];
36
40
  if (methodData.tags) {
37
41
  if (methodData.tags.includes('needPins') && !methodData.tags.includes('requirePins')) {
38
42
  mutatorToolbox.push('pins');
@@ -114,11 +118,11 @@ function getPinsBlockDefinition(library, methodData, pinsId) {
114
118
  function getComponentBlockDefinition(library, componentName, methodData, componentId) {
115
119
  const blockDefinition = {
116
120
  type: componentId,
117
- message0: library.info['x-icon'] + ' ' + componentName,
121
+ message0: library.info['x-icon'] + ' ' + (methodData.summary || componentName),
118
122
  args0: [],
119
123
  message1: '',
120
124
  args1: [],
121
- colour: '#74dc04',
125
+ colour: '#ffca28',
122
126
  tooltip: 'library : ' + library.info.title,
123
127
  inputsInline: false,
124
128
  previousStatement: null,
@@ -130,19 +134,19 @@ function getComponentBlockDefinition(library, componentName, methodData, compone
130
134
  const mutatorToolbox = [];
131
135
  const parameters = Object.keys(properties).map((propertyName)=>({
132
136
  name: propertyName,
137
+ summary: properties[propertyName].summary || propertyName,
133
138
  schema: properties[propertyName]
134
139
  }));
135
140
  let messageIndex = 0;
136
141
  parameters.forEach((parameter, _index)=>{
137
- const propertyName = parameter.name;
138
- if (!requiredFields.includes(propertyName)) {
139
- mutatorToolbox.push(propertyName);
142
+ if (!requiredFields.includes(parameter.name)) {
143
+ mutatorToolbox.push(parameter.name);
140
144
  } else {
141
145
  var _parameter_schema, _parameter_schema1, _parameter_schema2;
142
146
  blockDefinition['args1'].push({
143
147
  type: 'field_label',
144
148
  name: 'NAME_INPUT',
145
- text: propertyName + '*'
149
+ text: parameter.summary + '*'
146
150
  });
147
151
  if (((_parameter_schema = parameter.schema) == null ? void 0 : _parameter_schema.type) === 'array' && (((_parameter_schema1 = parameter.schema) == null ? void 0 : _parameter_schema1.items.$ref) === 'https://www.pinser.world/schemas/pinsSettings' || ((_parameter_schema2 = parameter.schema) == null ? void 0 : _parameter_schema2.items.$ref.includes('#/components/schemas/')))) {
148
152
  blockDefinition['message1'] += ' %' + (messageIndex * 2 + 1) + ' %' + (messageIndex * 2 + 2) + ' %' + (messageIndex * 2 + 3);
@@ -169,7 +173,7 @@ function getComponentBlockDefinition(library, componentName, methodData, compone
169
173
  }
170
174
  return blockDefinition;
171
175
  }
172
- function generateToolboxFromLibraries(libraries) {
176
+ function generateToolboxFromLibraries(libraries, tags) {
173
177
  const sortedLibraries = libraries.sort((a, b)=>{
174
178
  var _a_info_summary;
175
179
  const title1 = (_a_info_summary = a.info.summary) != null ? _a_info_summary : a.info.title;
@@ -231,19 +235,19 @@ function generateToolboxFromLibraries(libraries) {
231
235
  kind: 'category',
232
236
  name: library.info['x-icon'] + ' ' + ((_library_info_summary = library.info.summary) != null ? _library_info_summary : library.info.title),
233
237
  contents: [
234
- ...library.paths ? Object.entries(library.paths).sort((a, b)=>a[0].localeCompare(b[0])) // Tri alphabétique par path
238
+ ...library.paths ? Object.entries(library.paths).filter(([_path, pins])=>pins.post.tags.some((tag)=>tags.includes(tag))).sort((a, b)=>a[0].localeCompare(b[0])) // Tri alphabétique par path
235
239
  .map(([path, _pins])=>({
236
240
  kind: 'block',
237
241
  type: library.info.title + '/__PINS__' + path
238
242
  })) : [],
239
- ...((_library_components = library.components) == null ? void 0 : _library_components.schemas) ? Object.entries(library.components.schemas).sort((a, b)=>a[0].localeCompare(b[0])) // Tri alphabétique par componentName
240
- .map(([componentName, _componentSchema])=>({
243
+ ...((_library_components = library.components) == null ? void 0 : _library_components.schemas) ? Object.entries(library.components.schemas).filter(([_componentName, schema])=>schema.tags.some((tag)=>tags.includes(tag))).sort((a, b)=>a[0].localeCompare(b[0])) // Tri alphabétique par componentName
244
+ .map(([componentName])=>({
241
245
  kind: 'block',
242
246
  type: library.info.title + '/__COMPONENTS__/' + componentName
243
247
  })) : []
244
248
  ]
245
249
  };
246
- })
250
+ }).filter((library)=>library.contents.length > 0)
247
251
  ]
248
252
  };
249
253
  return toolbox;
@@ -323,12 +327,30 @@ function initializeMutator() {
323
327
  }
324
328
  };
325
329
  }
326
- function generateMutator(mutatorName, toolboxItem, requiredFields, parameters) {
330
+ function generateMutator(mutatorName, toolboxItem, requiredFields, originParameters) {
331
+ const parameters = [
332
+ ...originParameters,
333
+ {
334
+ name: '__CONDITION__/if',
335
+ schema: {
336
+ type: 'boolean'
337
+ }
338
+ },
339
+ {
340
+ name: '__CONDITION__/each',
341
+ schema: {
342
+ type: 'array',
343
+ items: {
344
+ type: 'object'
345
+ }
346
+ }
347
+ }
348
+ ];
327
349
  const toolboxList = [];
328
350
  for (const item of toolboxItem){
329
351
  Blockly.Blocks[mutatorName + '/' + item] = {
330
352
  init: function() {
331
- this.appendDummyInput(item).appendField(item.includes('__EVENT__/') ? item.replace('__EVENT__/', '@') : item);
353
+ this.appendDummyInput(item).appendField(item.includes('__EVENT__/') ? item.replace('__EVENT__/', '@') : item.includes('__CONDITION__/') ? item.replace('__CONDITION__/', '#') : item);
332
354
  this.setPreviousStatement(true);
333
355
  this.setNextStatement(true);
334
356
  this.setColour(0);
@@ -9,7 +9,7 @@ function getPinsBlockDefinition(library, methodData, pinsId) {
9
9
  args2: [],
10
10
  message3: '',
11
11
  args3: [],
12
- colour: '#1e2835',
12
+ colour: '#4285f4',
13
13
  tooltip: 'library : ' + library.info.title,
14
14
  inputsInline: false,
15
15
  previousStatement: null,
@@ -30,7 +30,11 @@ function getPinsBlockDefinition(library, methodData, pinsId) {
30
30
  });
31
31
  }
32
32
  requiredFields.push('');
33
- const mutatorToolbox = parameters.map((param)=>param.name).filter((name)=>!requiredFields.includes(name));
33
+ const mutatorToolbox = [
34
+ ...parameters.map((param)=>param.name).filter((name)=>!requiredFields.includes(name)),
35
+ '__CONDITION__/if',
36
+ '__CONDITION__/each'
37
+ ];
34
38
  if (methodData.tags) {
35
39
  if (methodData.tags.includes('needPins') && !methodData.tags.includes('requirePins')) {
36
40
  mutatorToolbox.push('pins');
@@ -112,11 +116,11 @@ function getPinsBlockDefinition(library, methodData, pinsId) {
112
116
  function getComponentBlockDefinition(library, componentName, methodData, componentId) {
113
117
  const blockDefinition = {
114
118
  type: componentId,
115
- message0: library.info['x-icon'] + ' ' + componentName,
119
+ message0: library.info['x-icon'] + ' ' + (methodData.summary || componentName),
116
120
  args0: [],
117
121
  message1: '',
118
122
  args1: [],
119
- colour: '#74dc04',
123
+ colour: '#ffca28',
120
124
  tooltip: 'library : ' + library.info.title,
121
125
  inputsInline: false,
122
126
  previousStatement: null,
@@ -128,19 +132,19 @@ function getComponentBlockDefinition(library, componentName, methodData, compone
128
132
  const mutatorToolbox = [];
129
133
  const parameters = Object.keys(properties).map((propertyName)=>({
130
134
  name: propertyName,
135
+ summary: properties[propertyName].summary || propertyName,
131
136
  schema: properties[propertyName]
132
137
  }));
133
138
  let messageIndex = 0;
134
139
  parameters.forEach((parameter, _index)=>{
135
- const propertyName = parameter.name;
136
- if (!requiredFields.includes(propertyName)) {
137
- mutatorToolbox.push(propertyName);
140
+ if (!requiredFields.includes(parameter.name)) {
141
+ mutatorToolbox.push(parameter.name);
138
142
  } else {
139
143
  var _parameter_schema, _parameter_schema1, _parameter_schema2;
140
144
  blockDefinition['args1'].push({
141
145
  type: 'field_label',
142
146
  name: 'NAME_INPUT',
143
- text: propertyName + '*'
147
+ text: parameter.summary + '*'
144
148
  });
145
149
  if (((_parameter_schema = parameter.schema) == null ? void 0 : _parameter_schema.type) === 'array' && (((_parameter_schema1 = parameter.schema) == null ? void 0 : _parameter_schema1.items.$ref) === 'https://www.pinser.world/schemas/pinsSettings' || ((_parameter_schema2 = parameter.schema) == null ? void 0 : _parameter_schema2.items.$ref.includes('#/components/schemas/')))) {
146
150
  blockDefinition['message1'] += ' %' + (messageIndex * 2 + 1) + ' %' + (messageIndex * 2 + 2) + ' %' + (messageIndex * 2 + 3);
@@ -167,7 +171,7 @@ function getComponentBlockDefinition(library, componentName, methodData, compone
167
171
  }
168
172
  return blockDefinition;
169
173
  }
170
- function generateToolboxFromLibraries(libraries) {
174
+ function generateToolboxFromLibraries(libraries, tags) {
171
175
  const sortedLibraries = libraries.sort((a, b)=>{
172
176
  var _a_info_summary;
173
177
  const title1 = (_a_info_summary = a.info.summary) != null ? _a_info_summary : a.info.title;
@@ -229,19 +233,19 @@ function generateToolboxFromLibraries(libraries) {
229
233
  kind: 'category',
230
234
  name: library.info['x-icon'] + ' ' + ((_library_info_summary = library.info.summary) != null ? _library_info_summary : library.info.title),
231
235
  contents: [
232
- ...library.paths ? Object.entries(library.paths).sort((a, b)=>a[0].localeCompare(b[0])) // Tri alphabétique par path
236
+ ...library.paths ? Object.entries(library.paths).filter(([_path, pins])=>pins.post.tags.some((tag)=>tags.includes(tag))).sort((a, b)=>a[0].localeCompare(b[0])) // Tri alphabétique par path
233
237
  .map(([path, _pins])=>({
234
238
  kind: 'block',
235
239
  type: library.info.title + '/__PINS__' + path
236
240
  })) : [],
237
- ...((_library_components = library.components) == null ? void 0 : _library_components.schemas) ? Object.entries(library.components.schemas).sort((a, b)=>a[0].localeCompare(b[0])) // Tri alphabétique par componentName
238
- .map(([componentName, _componentSchema])=>({
241
+ ...((_library_components = library.components) == null ? void 0 : _library_components.schemas) ? Object.entries(library.components.schemas).filter(([_componentName, schema])=>schema.tags.some((tag)=>tags.includes(tag))).sort((a, b)=>a[0].localeCompare(b[0])) // Tri alphabétique par componentName
242
+ .map(([componentName])=>({
239
243
  kind: 'block',
240
244
  type: library.info.title + '/__COMPONENTS__/' + componentName
241
245
  })) : []
242
246
  ]
243
247
  };
244
- })
248
+ }).filter((library)=>library.contents.length > 0)
245
249
  ]
246
250
  };
247
251
  return toolbox;
@@ -321,12 +325,30 @@ function initializeMutator() {
321
325
  }
322
326
  };
323
327
  }
324
- function generateMutator(mutatorName, toolboxItem, requiredFields, parameters) {
328
+ function generateMutator(mutatorName, toolboxItem, requiredFields, originParameters) {
329
+ const parameters = [
330
+ ...originParameters,
331
+ {
332
+ name: '__CONDITION__/if',
333
+ schema: {
334
+ type: 'boolean'
335
+ }
336
+ },
337
+ {
338
+ name: '__CONDITION__/each',
339
+ schema: {
340
+ type: 'array',
341
+ items: {
342
+ type: 'object'
343
+ }
344
+ }
345
+ }
346
+ ];
325
347
  const toolboxList = [];
326
348
  for (const item of toolboxItem){
327
349
  Blockly.Blocks[mutatorName + '/' + item] = {
328
350
  init: function() {
329
- this.appendDummyInput(item).appendField(item.includes('__EVENT__/') ? item.replace('__EVENT__/', '@') : item);
351
+ this.appendDummyInput(item).appendField(item.includes('__EVENT__/') ? item.replace('__EVENT__/', '@') : item.includes('__CONDITION__/') ? item.replace('__CONDITION__/', '#') : item);
330
352
  this.setPreviousStatement(true);
331
353
  this.setNextStatement(true);
332
354
  this.setColour(0);