@digipair/skill-web-editor 0.4.9 → 0.4.11

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.
@@ -130,6 +130,7 @@ jsonGenerator.generatePin = function(block) {
130
130
  code += `\n "element": "${elementName}",`;
131
131
  let propertiesCode = '';
132
132
  let eventCode = '';
133
+ let conditionCode = '';
133
134
  for(let i = 0, input; input = block.inputList[i]; i++){
134
135
  const inputName = input.name;
135
136
  const connectedBlock = input.connection && input.connection.targetBlock();
@@ -138,6 +139,8 @@ jsonGenerator.generatePin = function(block) {
138
139
  const inputCode = jsonGenerator.customStatementToCode(block, inputName);
139
140
  if (inputName.includes('__EVENT__/')) {
140
141
  eventCode += ` "${inputName.split('__EVENT__/')[1]}": [${inputCode}],`;
142
+ } else if (inputName.includes('__CONDITION__/')) {
143
+ conditionCode += ` "${inputName.split('__CONDITION__/')[1]}": [${inputCode}],`;
141
144
  } else {
142
145
  propertiesCode += ` "${inputName}": [${inputCode}],`;
143
146
  }
@@ -164,6 +167,12 @@ jsonGenerator.generatePin = function(block) {
164
167
  }
165
168
  code += '\n"events": {\n' + eventCode + '\n },';
166
169
  }
170
+ if (conditionCode !== '') {
171
+ if (conditionCode.endsWith(',')) {
172
+ conditionCode = conditionCode.slice(0, -1);
173
+ }
174
+ code += '\n"conditions": {\n' + conditionCode + '\n },';
175
+ }
167
176
  if (code.endsWith(',')) {
168
177
  code = code.slice(0, -1);
169
178
  }
@@ -128,6 +128,7 @@ jsonGenerator.generatePin = function(block) {
128
128
  code += `\n "element": "${elementName}",`;
129
129
  let propertiesCode = '';
130
130
  let eventCode = '';
131
+ let conditionCode = '';
131
132
  for(let i = 0, input; input = block.inputList[i]; i++){
132
133
  const inputName = input.name;
133
134
  const connectedBlock = input.connection && input.connection.targetBlock();
@@ -136,6 +137,8 @@ jsonGenerator.generatePin = function(block) {
136
137
  const inputCode = jsonGenerator.customStatementToCode(block, inputName);
137
138
  if (inputName.includes('__EVENT__/')) {
138
139
  eventCode += ` "${inputName.split('__EVENT__/')[1]}": [${inputCode}],`;
140
+ } else if (inputName.includes('__CONDITION__/')) {
141
+ conditionCode += ` "${inputName.split('__CONDITION__/')[1]}": [${inputCode}],`;
139
142
  } else {
140
143
  propertiesCode += ` "${inputName}": [${inputCode}],`;
141
144
  }
@@ -162,6 +165,12 @@ jsonGenerator.generatePin = function(block) {
162
165
  }
163
166
  code += '\n"events": {\n' + eventCode + '\n },';
164
167
  }
168
+ if (conditionCode !== '') {
169
+ if (conditionCode.endsWith(',')) {
170
+ conditionCode = conditionCode.slice(0, -1);
171
+ }
172
+ code += '\n"conditions": {\n' + conditionCode + '\n },';
173
+ }
165
174
  if (code.endsWith(',')) {
166
175
  code = code.slice(0, -1);
167
176
  }
package/index.cjs2.js CHANGED
@@ -2652,11 +2652,8 @@ function generateBlockFromPins(pinsSettings, workspace) {
2652
2652
  connectBlock(pinsBlock, pinsConnection);
2653
2653
  }
2654
2654
  }
2655
- if (!pinsSettings || !pinsSettings.properties) {
2656
- return pinsBlock;
2657
- }
2658
2655
  for (const parameter of pinsDefinition.parameters){
2659
- if (!Object.prototype.hasOwnProperty.call(pinsSettings.properties, parameter.name)) {
2656
+ if (!pinsSettings.properties || !Object.prototype.hasOwnProperty.call(pinsSettings.properties, parameter.name)) {
2660
2657
  continue;
2661
2658
  }
2662
2659
  const valueToLoad = pinsSettings.properties[parameter.name];
@@ -2673,7 +2670,7 @@ function generateBlockFromPins(pinsSettings, workspace) {
2673
2670
  connectBlock(parameterBlock, sceneInputConnection);
2674
2671
  }
2675
2672
  }
2676
- for (const event of pinsDefinition['x-events']){
2673
+ for (const event of pinsDefinition['x-events'] || []){
2677
2674
  if (!pinsSettings.events || !Object.prototype.hasOwnProperty.call(pinsSettings.events, event.name)) {
2678
2675
  continue;
2679
2676
  }
@@ -2920,6 +2917,20 @@ function itemListFromPinsSettings(pinsSettings, pinsDefinition) {
2920
2917
  });
2921
2918
  }
2922
2919
  }
2920
+ if (pinsSettings.conditions) {
2921
+ if (pinsSettings.conditions.if) {
2922
+ inputArray.push({
2923
+ id: '__CONDITION__/if',
2924
+ name: '/if/'
2925
+ });
2926
+ }
2927
+ if (pinsSettings.conditions.each) {
2928
+ inputArray.push({
2929
+ id: '__CONDITION__/each',
2930
+ name: '/for each/'
2931
+ });
2932
+ }
2933
+ }
2923
2934
  return inputArray;
2924
2935
  }
2925
2936
  function itemListFromComponentSettings(componentSettings, componentDefinition) {
@@ -2951,6 +2962,321 @@ function itemListFromSceneSettings(sceneSettings, sceneDefinition) {
2951
2962
  return inputArray;
2952
2963
  }
2953
2964
 
2965
+ const schemas = {
2966
+ openapi: '3.0.0',
2967
+ info: {
2968
+ title: 'web',
2969
+ summary: 'Web: bases',
2970
+ description: 'description de la librairie de pins web',
2971
+ version: '1.0.11',
2972
+ 'x-icon': '🌐'
2973
+ },
2974
+ paths: {
2975
+ '/section': {
2976
+ post: {
2977
+ tags: [
2978
+ 'needPins',
2979
+ 'web'
2980
+ ],
2981
+ summary: 'Section',
2982
+ parameters: [
2983
+ {
2984
+ name: 'class',
2985
+ in: 'query',
2986
+ description: '',
2987
+ schema: {
2988
+ type: 'string'
2989
+ }
2990
+ },
2991
+ {
2992
+ name: 'textContent',
2993
+ in: 'query',
2994
+ description: '',
2995
+ schema: {
2996
+ type: 'string'
2997
+ }
2998
+ }
2999
+ ]
3000
+ }
3001
+ },
3002
+ '/h1': {
3003
+ post: {
3004
+ tags: [
3005
+ 'web'
3006
+ ],
3007
+ summary: 'h1',
3008
+ parameters: [
3009
+ {
3010
+ name: 'textContent',
3011
+ in: 'query',
3012
+ description: '',
3013
+ schema: {
3014
+ type: 'string'
3015
+ }
3016
+ }
3017
+ ]
3018
+ }
3019
+ },
3020
+ '/nav': {
3021
+ post: {
3022
+ tags: [
3023
+ 'needPins',
3024
+ 'web'
3025
+ ],
3026
+ summary: 'nav',
3027
+ parameters: [
3028
+ {
3029
+ name: 'class',
3030
+ in: 'query',
3031
+ description: '',
3032
+ schema: {
3033
+ type: 'string'
3034
+ }
3035
+ }
3036
+ ]
3037
+ }
3038
+ },
3039
+ '/a': {
3040
+ post: {
3041
+ tags: [
3042
+ 'needPins',
3043
+ 'web'
3044
+ ],
3045
+ summary: 'a',
3046
+ parameters: [
3047
+ {
3048
+ name: 'class',
3049
+ in: 'query',
3050
+ description: '',
3051
+ schema: {
3052
+ type: 'string'
3053
+ }
3054
+ },
3055
+ {
3056
+ name: 'href',
3057
+ in: 'query',
3058
+ description: '',
3059
+ schema: {
3060
+ type: 'string'
3061
+ }
3062
+ },
3063
+ {
3064
+ name: 'textContent',
3065
+ in: 'query',
3066
+ description: '',
3067
+ schema: {
3068
+ type: 'string'
3069
+ }
3070
+ },
3071
+ {
3072
+ name: 'id',
3073
+ in: 'query',
3074
+ description: '',
3075
+ schema: {
3076
+ type: 'string'
3077
+ }
3078
+ },
3079
+ {
3080
+ name: 'role',
3081
+ in: 'query',
3082
+ description: '',
3083
+ schema: {
3084
+ type: 'string'
3085
+ }
3086
+ },
3087
+ {
3088
+ name: 'data-toggle',
3089
+ in: 'query',
3090
+ description: '',
3091
+ schema: {
3092
+ type: 'string'
3093
+ }
3094
+ },
3095
+ {
3096
+ name: 'aria-haspopup',
3097
+ in: 'query',
3098
+ description: '',
3099
+ schema: {
3100
+ type: 'string'
3101
+ }
3102
+ },
3103
+ {
3104
+ name: 'aria-expanded',
3105
+ in: 'query',
3106
+ description: '',
3107
+ schema: {
3108
+ type: 'string'
3109
+ }
3110
+ }
3111
+ ]
3112
+ }
3113
+ },
3114
+ '/button': {
3115
+ post: {
3116
+ tags: [
3117
+ 'needPins',
3118
+ 'web'
3119
+ ],
3120
+ summary: 'button',
3121
+ parameters: [
3122
+ {
3123
+ name: 'class',
3124
+ in: 'query',
3125
+ description: '',
3126
+ schema: {
3127
+ type: 'string'
3128
+ }
3129
+ },
3130
+ {
3131
+ name: 'type',
3132
+ in: 'query',
3133
+ description: '',
3134
+ schema: {
3135
+ type: 'string'
3136
+ }
3137
+ },
3138
+ {
3139
+ name: 'data-toggle',
3140
+ in: 'query',
3141
+ description: '',
3142
+ schema: {
3143
+ type: 'string'
3144
+ }
3145
+ },
3146
+ {
3147
+ name: 'data-target',
3148
+ in: 'query',
3149
+ description: '',
3150
+ schema: {
3151
+ type: 'string'
3152
+ }
3153
+ },
3154
+ {
3155
+ name: 'aria-controls',
3156
+ in: 'query',
3157
+ description: '',
3158
+ schema: {
3159
+ type: 'string'
3160
+ }
3161
+ },
3162
+ {
3163
+ name: 'aria-expanded',
3164
+ in: 'query',
3165
+ description: '',
3166
+ schema: {
3167
+ type: 'string'
3168
+ }
3169
+ },
3170
+ {
3171
+ name: 'aria-label',
3172
+ in: 'query',
3173
+ description: '',
3174
+ schema: {
3175
+ type: 'string'
3176
+ }
3177
+ }
3178
+ ]
3179
+ }
3180
+ },
3181
+ '/span': {
3182
+ post: {
3183
+ tags: [
3184
+ 'needPins',
3185
+ 'web'
3186
+ ],
3187
+ summary: 'span',
3188
+ parameters: [
3189
+ {
3190
+ name: 'class',
3191
+ in: 'query',
3192
+ description: '',
3193
+ schema: {
3194
+ type: 'string'
3195
+ }
3196
+ }
3197
+ ]
3198
+ }
3199
+ },
3200
+ '/div': {
3201
+ post: {
3202
+ tags: [
3203
+ 'needPins',
3204
+ 'web'
3205
+ ],
3206
+ summary: 'div',
3207
+ parameters: [
3208
+ {
3209
+ name: 'class',
3210
+ in: 'query',
3211
+ description: '',
3212
+ schema: {
3213
+ type: 'string'
3214
+ }
3215
+ },
3216
+ {
3217
+ name: 'id',
3218
+ in: 'query',
3219
+ description: '',
3220
+ schema: {
3221
+ type: 'string'
3222
+ }
3223
+ },
3224
+ {
3225
+ name: 'aria-labelledby',
3226
+ in: 'query',
3227
+ description: '',
3228
+ schema: {
3229
+ type: 'string'
3230
+ }
3231
+ }
3232
+ ]
3233
+ }
3234
+ },
3235
+ '/ul': {
3236
+ post: {
3237
+ tags: [
3238
+ 'needPins',
3239
+ 'web'
3240
+ ],
3241
+ summary: 'ul',
3242
+ parameters: [
3243
+ {
3244
+ name: 'class',
3245
+ in: 'query',
3246
+ description: '',
3247
+ schema: {
3248
+ type: 'string'
3249
+ }
3250
+ }
3251
+ ]
3252
+ }
3253
+ },
3254
+ '/li': {
3255
+ post: {
3256
+ tags: [
3257
+ 'needPins',
3258
+ 'web'
3259
+ ],
3260
+ summary: 'li',
3261
+ parameters: [
3262
+ {
3263
+ name: 'class',
3264
+ in: 'query',
3265
+ description: '',
3266
+ schema: {
3267
+ type: 'string'
3268
+ }
3269
+ }
3270
+ ]
3271
+ }
3272
+ }
3273
+ },
3274
+ components: {
3275
+ schemas: {}
3276
+ },
3277
+ 'x-scene-blocks': {}
3278
+ };
3279
+
2954
3280
  const Toastify$1 = toastify;
2955
3281
  const BASE_URL = 'https://cdn.jsdelivr.net/npm';
2956
3282
  const BLOCKLY_VERSION = '10.4.3';
@@ -3000,32 +3326,9 @@ class GenericSceneElement extends s {
3000
3326
  setTimeout(()=>this.loadScene(this.digipair, this.reasoning), 1);
3001
3327
  this.addEventListener('setReasoning', ({ detail })=>this.loadReasoning(detail));
3002
3328
  }
3003
- loadReasoning(detail) {
3004
- const scene = _extends({}, detail, {
3005
- properties: _extends({}, (detail.properties.trigger || []).reduce((acc, { name, value })=>_extends({}, acc, {
3006
- [name]: value
3007
- }), {}), {
3008
- actions: detail.properties.actions.map((action)=>{
3009
- var _action_properties;
3010
- return _extends({}, action, {
3011
- properties: (_action_properties = action.properties) == null ? void 0 : _action_properties.reduce((acc, { name, value })=>_extends({}, acc, {
3012
- [name]: value
3013
- }), {})
3014
- });
3015
- }),
3016
- conditions: detail.properties.conditions.map((action)=>{
3017
- var _action_properties;
3018
- return _extends({}, action, {
3019
- properties: (_action_properties = action.properties) == null ? void 0 : _action_properties.reduce((acc, { name, value })=>_extends({}, acc, {
3020
- [name]: value
3021
- }), {})
3022
- });
3023
- }),
3024
- pins: []
3025
- })
3026
- });
3329
+ loadReasoning(reasoning) {
3027
3330
  Blockly.Events.disable();
3028
- initializeWorkspaceFromPinsAndLibraries(scene, this.workspace, this.librariesToLoad);
3331
+ initializeWorkspaceFromPinsAndLibraries(reasoning, this.workspace, this.librariesToLoad);
3029
3332
  Blockly.Events.enable();
3030
3333
  }
3031
3334
  async getReasoning(digipair, reasoning) {
@@ -3043,7 +3346,10 @@ class GenericSceneElement extends s {
3043
3346
  return content;
3044
3347
  }
3045
3348
  async getLibraries(libraries) {
3046
- const list = await Promise.all(Object.keys(libraries).map(async (library, i)=>fetch(`${BASE_URL}/${library}@${libraries[library]}/schema.json`).then((res)=>res.json())));
3349
+ const list = [
3350
+ schemas,
3351
+ ...await Promise.all(Object.keys(libraries).map(async (library, i)=>fetch(`${BASE_URL}/${library}@${libraries[library]}/schema.json`).then((res)=>res.json())))
3352
+ ];
3047
3353
  return list;
3048
3354
  }
3049
3355
  async loadScene(digipair, reasoning) {
@@ -3091,10 +3397,12 @@ class GenericSceneElement extends s {
3091
3397
  }
3092
3398
  }
3093
3399
  loadBlockly(scene) {
3400
+ var _this_librariesToLoad_find_xsceneblocks_, _this_librariesToLoad_find_xsceneblocks, _this_librariesToLoad_find;
3094
3401
  initializeMutator();
3095
3402
  const generatedBlocks = generateBlocklyBlockFromLibraries(this.librariesToLoad, blocksLegacy);
3096
3403
  this.blocks = Blockly.common.createBlockDefinitionsFromJsonArray(generatedBlocks);
3097
- this.toolbox = generateToolboxFromLibraries(this.librariesToLoad);
3404
+ const tags = ((_this_librariesToLoad_find = this.librariesToLoad.find((library)=>library.info.title === scene.library)) == null ? void 0 : (_this_librariesToLoad_find_xsceneblocks = _this_librariesToLoad_find['x-scene-blocks']) == null ? void 0 : (_this_librariesToLoad_find_xsceneblocks_ = _this_librariesToLoad_find_xsceneblocks[`/${scene.element}`]) == null ? void 0 : _this_librariesToLoad_find_xsceneblocks_.tags) || [];
3405
+ this.toolbox = generateToolboxFromLibraries(this.librariesToLoad, tags);
3098
3406
  Blockly.common.defineBlocks(this.blocks);
3099
3407
  const container = this.renderRoot.querySelector('[data-scene]');
3100
3408
  this.workspace = Blockly.inject(container, {
package/index.esm2.js CHANGED
@@ -2650,11 +2650,8 @@ function generateBlockFromPins(pinsSettings, workspace) {
2650
2650
  connectBlock(pinsBlock, pinsConnection);
2651
2651
  }
2652
2652
  }
2653
- if (!pinsSettings || !pinsSettings.properties) {
2654
- return pinsBlock;
2655
- }
2656
2653
  for (const parameter of pinsDefinition.parameters){
2657
- if (!Object.prototype.hasOwnProperty.call(pinsSettings.properties, parameter.name)) {
2654
+ if (!pinsSettings.properties || !Object.prototype.hasOwnProperty.call(pinsSettings.properties, parameter.name)) {
2658
2655
  continue;
2659
2656
  }
2660
2657
  const valueToLoad = pinsSettings.properties[parameter.name];
@@ -2671,7 +2668,7 @@ function generateBlockFromPins(pinsSettings, workspace) {
2671
2668
  connectBlock(parameterBlock, sceneInputConnection);
2672
2669
  }
2673
2670
  }
2674
- for (const event of pinsDefinition['x-events']){
2671
+ for (const event of pinsDefinition['x-events'] || []){
2675
2672
  if (!pinsSettings.events || !Object.prototype.hasOwnProperty.call(pinsSettings.events, event.name)) {
2676
2673
  continue;
2677
2674
  }
@@ -2918,6 +2915,20 @@ function itemListFromPinsSettings(pinsSettings, pinsDefinition) {
2918
2915
  });
2919
2916
  }
2920
2917
  }
2918
+ if (pinsSettings.conditions) {
2919
+ if (pinsSettings.conditions.if) {
2920
+ inputArray.push({
2921
+ id: '__CONDITION__/if',
2922
+ name: '/if/'
2923
+ });
2924
+ }
2925
+ if (pinsSettings.conditions.each) {
2926
+ inputArray.push({
2927
+ id: '__CONDITION__/each',
2928
+ name: '/for each/'
2929
+ });
2930
+ }
2931
+ }
2921
2932
  return inputArray;
2922
2933
  }
2923
2934
  function itemListFromComponentSettings(componentSettings, componentDefinition) {
@@ -2949,6 +2960,321 @@ function itemListFromSceneSettings(sceneSettings, sceneDefinition) {
2949
2960
  return inputArray;
2950
2961
  }
2951
2962
 
2963
+ const schemas = {
2964
+ openapi: '3.0.0',
2965
+ info: {
2966
+ title: 'web',
2967
+ summary: 'Web: bases',
2968
+ description: 'description de la librairie de pins web',
2969
+ version: '1.0.11',
2970
+ 'x-icon': '🌐'
2971
+ },
2972
+ paths: {
2973
+ '/section': {
2974
+ post: {
2975
+ tags: [
2976
+ 'needPins',
2977
+ 'web'
2978
+ ],
2979
+ summary: 'Section',
2980
+ parameters: [
2981
+ {
2982
+ name: 'class',
2983
+ in: 'query',
2984
+ description: '',
2985
+ schema: {
2986
+ type: 'string'
2987
+ }
2988
+ },
2989
+ {
2990
+ name: 'textContent',
2991
+ in: 'query',
2992
+ description: '',
2993
+ schema: {
2994
+ type: 'string'
2995
+ }
2996
+ }
2997
+ ]
2998
+ }
2999
+ },
3000
+ '/h1': {
3001
+ post: {
3002
+ tags: [
3003
+ 'web'
3004
+ ],
3005
+ summary: 'h1',
3006
+ parameters: [
3007
+ {
3008
+ name: 'textContent',
3009
+ in: 'query',
3010
+ description: '',
3011
+ schema: {
3012
+ type: 'string'
3013
+ }
3014
+ }
3015
+ ]
3016
+ }
3017
+ },
3018
+ '/nav': {
3019
+ post: {
3020
+ tags: [
3021
+ 'needPins',
3022
+ 'web'
3023
+ ],
3024
+ summary: 'nav',
3025
+ parameters: [
3026
+ {
3027
+ name: 'class',
3028
+ in: 'query',
3029
+ description: '',
3030
+ schema: {
3031
+ type: 'string'
3032
+ }
3033
+ }
3034
+ ]
3035
+ }
3036
+ },
3037
+ '/a': {
3038
+ post: {
3039
+ tags: [
3040
+ 'needPins',
3041
+ 'web'
3042
+ ],
3043
+ summary: 'a',
3044
+ parameters: [
3045
+ {
3046
+ name: 'class',
3047
+ in: 'query',
3048
+ description: '',
3049
+ schema: {
3050
+ type: 'string'
3051
+ }
3052
+ },
3053
+ {
3054
+ name: 'href',
3055
+ in: 'query',
3056
+ description: '',
3057
+ schema: {
3058
+ type: 'string'
3059
+ }
3060
+ },
3061
+ {
3062
+ name: 'textContent',
3063
+ in: 'query',
3064
+ description: '',
3065
+ schema: {
3066
+ type: 'string'
3067
+ }
3068
+ },
3069
+ {
3070
+ name: 'id',
3071
+ in: 'query',
3072
+ description: '',
3073
+ schema: {
3074
+ type: 'string'
3075
+ }
3076
+ },
3077
+ {
3078
+ name: 'role',
3079
+ in: 'query',
3080
+ description: '',
3081
+ schema: {
3082
+ type: 'string'
3083
+ }
3084
+ },
3085
+ {
3086
+ name: 'data-toggle',
3087
+ in: 'query',
3088
+ description: '',
3089
+ schema: {
3090
+ type: 'string'
3091
+ }
3092
+ },
3093
+ {
3094
+ name: 'aria-haspopup',
3095
+ in: 'query',
3096
+ description: '',
3097
+ schema: {
3098
+ type: 'string'
3099
+ }
3100
+ },
3101
+ {
3102
+ name: 'aria-expanded',
3103
+ in: 'query',
3104
+ description: '',
3105
+ schema: {
3106
+ type: 'string'
3107
+ }
3108
+ }
3109
+ ]
3110
+ }
3111
+ },
3112
+ '/button': {
3113
+ post: {
3114
+ tags: [
3115
+ 'needPins',
3116
+ 'web'
3117
+ ],
3118
+ summary: 'button',
3119
+ parameters: [
3120
+ {
3121
+ name: 'class',
3122
+ in: 'query',
3123
+ description: '',
3124
+ schema: {
3125
+ type: 'string'
3126
+ }
3127
+ },
3128
+ {
3129
+ name: 'type',
3130
+ in: 'query',
3131
+ description: '',
3132
+ schema: {
3133
+ type: 'string'
3134
+ }
3135
+ },
3136
+ {
3137
+ name: 'data-toggle',
3138
+ in: 'query',
3139
+ description: '',
3140
+ schema: {
3141
+ type: 'string'
3142
+ }
3143
+ },
3144
+ {
3145
+ name: 'data-target',
3146
+ in: 'query',
3147
+ description: '',
3148
+ schema: {
3149
+ type: 'string'
3150
+ }
3151
+ },
3152
+ {
3153
+ name: 'aria-controls',
3154
+ in: 'query',
3155
+ description: '',
3156
+ schema: {
3157
+ type: 'string'
3158
+ }
3159
+ },
3160
+ {
3161
+ name: 'aria-expanded',
3162
+ in: 'query',
3163
+ description: '',
3164
+ schema: {
3165
+ type: 'string'
3166
+ }
3167
+ },
3168
+ {
3169
+ name: 'aria-label',
3170
+ in: 'query',
3171
+ description: '',
3172
+ schema: {
3173
+ type: 'string'
3174
+ }
3175
+ }
3176
+ ]
3177
+ }
3178
+ },
3179
+ '/span': {
3180
+ post: {
3181
+ tags: [
3182
+ 'needPins',
3183
+ 'web'
3184
+ ],
3185
+ summary: 'span',
3186
+ parameters: [
3187
+ {
3188
+ name: 'class',
3189
+ in: 'query',
3190
+ description: '',
3191
+ schema: {
3192
+ type: 'string'
3193
+ }
3194
+ }
3195
+ ]
3196
+ }
3197
+ },
3198
+ '/div': {
3199
+ post: {
3200
+ tags: [
3201
+ 'needPins',
3202
+ 'web'
3203
+ ],
3204
+ summary: 'div',
3205
+ parameters: [
3206
+ {
3207
+ name: 'class',
3208
+ in: 'query',
3209
+ description: '',
3210
+ schema: {
3211
+ type: 'string'
3212
+ }
3213
+ },
3214
+ {
3215
+ name: 'id',
3216
+ in: 'query',
3217
+ description: '',
3218
+ schema: {
3219
+ type: 'string'
3220
+ }
3221
+ },
3222
+ {
3223
+ name: 'aria-labelledby',
3224
+ in: 'query',
3225
+ description: '',
3226
+ schema: {
3227
+ type: 'string'
3228
+ }
3229
+ }
3230
+ ]
3231
+ }
3232
+ },
3233
+ '/ul': {
3234
+ post: {
3235
+ tags: [
3236
+ 'needPins',
3237
+ 'web'
3238
+ ],
3239
+ summary: 'ul',
3240
+ parameters: [
3241
+ {
3242
+ name: 'class',
3243
+ in: 'query',
3244
+ description: '',
3245
+ schema: {
3246
+ type: 'string'
3247
+ }
3248
+ }
3249
+ ]
3250
+ }
3251
+ },
3252
+ '/li': {
3253
+ post: {
3254
+ tags: [
3255
+ 'needPins',
3256
+ 'web'
3257
+ ],
3258
+ summary: 'li',
3259
+ parameters: [
3260
+ {
3261
+ name: 'class',
3262
+ in: 'query',
3263
+ description: '',
3264
+ schema: {
3265
+ type: 'string'
3266
+ }
3267
+ }
3268
+ ]
3269
+ }
3270
+ }
3271
+ },
3272
+ components: {
3273
+ schemas: {}
3274
+ },
3275
+ 'x-scene-blocks': {}
3276
+ };
3277
+
2952
3278
  const Toastify$1 = toastify;
2953
3279
  const BASE_URL = 'https://cdn.jsdelivr.net/npm';
2954
3280
  const BLOCKLY_VERSION = '10.4.3';
@@ -2998,32 +3324,9 @@ class GenericSceneElement extends s {
2998
3324
  setTimeout(()=>this.loadScene(this.digipair, this.reasoning), 1);
2999
3325
  this.addEventListener('setReasoning', ({ detail })=>this.loadReasoning(detail));
3000
3326
  }
3001
- loadReasoning(detail) {
3002
- const scene = _extends({}, detail, {
3003
- properties: _extends({}, (detail.properties.trigger || []).reduce((acc, { name, value })=>_extends({}, acc, {
3004
- [name]: value
3005
- }), {}), {
3006
- actions: detail.properties.actions.map((action)=>{
3007
- var _action_properties;
3008
- return _extends({}, action, {
3009
- properties: (_action_properties = action.properties) == null ? void 0 : _action_properties.reduce((acc, { name, value })=>_extends({}, acc, {
3010
- [name]: value
3011
- }), {})
3012
- });
3013
- }),
3014
- conditions: detail.properties.conditions.map((action)=>{
3015
- var _action_properties;
3016
- return _extends({}, action, {
3017
- properties: (_action_properties = action.properties) == null ? void 0 : _action_properties.reduce((acc, { name, value })=>_extends({}, acc, {
3018
- [name]: value
3019
- }), {})
3020
- });
3021
- }),
3022
- pins: []
3023
- })
3024
- });
3327
+ loadReasoning(reasoning) {
3025
3328
  Blockly.Events.disable();
3026
- initializeWorkspaceFromPinsAndLibraries(scene, this.workspace, this.librariesToLoad);
3329
+ initializeWorkspaceFromPinsAndLibraries(reasoning, this.workspace, this.librariesToLoad);
3027
3330
  Blockly.Events.enable();
3028
3331
  }
3029
3332
  async getReasoning(digipair, reasoning) {
@@ -3041,7 +3344,10 @@ class GenericSceneElement extends s {
3041
3344
  return content;
3042
3345
  }
3043
3346
  async getLibraries(libraries) {
3044
- const list = await Promise.all(Object.keys(libraries).map(async (library, i)=>fetch(`${BASE_URL}/${library}@${libraries[library]}/schema.json`).then((res)=>res.json())));
3347
+ const list = [
3348
+ schemas,
3349
+ ...await Promise.all(Object.keys(libraries).map(async (library, i)=>fetch(`${BASE_URL}/${library}@${libraries[library]}/schema.json`).then((res)=>res.json())))
3350
+ ];
3045
3351
  return list;
3046
3352
  }
3047
3353
  async loadScene(digipair, reasoning) {
@@ -3089,10 +3395,12 @@ class GenericSceneElement extends s {
3089
3395
  }
3090
3396
  }
3091
3397
  loadBlockly(scene) {
3398
+ var _this_librariesToLoad_find_xsceneblocks_, _this_librariesToLoad_find_xsceneblocks, _this_librariesToLoad_find;
3092
3399
  initializeMutator();
3093
3400
  const generatedBlocks = generateBlocklyBlockFromLibraries(this.librariesToLoad, blocksLegacy);
3094
3401
  this.blocks = Blockly.common.createBlockDefinitionsFromJsonArray(generatedBlocks);
3095
- this.toolbox = generateToolboxFromLibraries(this.librariesToLoad);
3402
+ const tags = ((_this_librariesToLoad_find = this.librariesToLoad.find((library)=>library.info.title === scene.library)) == null ? void 0 : (_this_librariesToLoad_find_xsceneblocks = _this_librariesToLoad_find['x-scene-blocks']) == null ? void 0 : (_this_librariesToLoad_find_xsceneblocks_ = _this_librariesToLoad_find_xsceneblocks[`/${scene.element}`]) == null ? void 0 : _this_librariesToLoad_find_xsceneblocks_.tags) || [];
3403
+ this.toolbox = generateToolboxFromLibraries(this.librariesToLoad, tags);
3096
3404
  Blockly.common.defineBlocks(this.blocks);
3097
3405
  const container = this.renderRoot.querySelector('[data-scene]');
3098
3406
  this.workspace = Blockly.inject(container, {
@@ -1,4 +1,4 @@
1
- export declare function generateToolboxFromLibraries(libraries: any[]): {
1
+ export declare function generateToolboxFromLibraries(libraries: any[], tags: string[]): {
2
2
  kind: string;
3
3
  contents: {
4
4
  kind: string;
@@ -0,0 +1,142 @@
1
+ export declare const schemas: {
2
+ openapi: string;
3
+ info: {
4
+ title: string;
5
+ summary: string;
6
+ description: string;
7
+ version: string;
8
+ 'x-icon': string;
9
+ };
10
+ paths: {
11
+ '/section': {
12
+ post: {
13
+ tags: string[];
14
+ summary: string;
15
+ parameters: {
16
+ name: string;
17
+ in: string;
18
+ description: string;
19
+ schema: {
20
+ type: string;
21
+ };
22
+ }[];
23
+ };
24
+ };
25
+ '/h1': {
26
+ post: {
27
+ tags: string[];
28
+ summary: string;
29
+ parameters: {
30
+ name: string;
31
+ in: string;
32
+ description: string;
33
+ schema: {
34
+ type: string;
35
+ };
36
+ }[];
37
+ };
38
+ };
39
+ '/nav': {
40
+ post: {
41
+ tags: string[];
42
+ summary: string;
43
+ parameters: {
44
+ name: string;
45
+ in: string;
46
+ description: string;
47
+ schema: {
48
+ type: string;
49
+ };
50
+ }[];
51
+ };
52
+ };
53
+ '/a': {
54
+ post: {
55
+ tags: string[];
56
+ summary: string;
57
+ parameters: {
58
+ name: string;
59
+ in: string;
60
+ description: string;
61
+ schema: {
62
+ type: string;
63
+ };
64
+ }[];
65
+ };
66
+ };
67
+ '/button': {
68
+ post: {
69
+ tags: string[];
70
+ summary: string;
71
+ parameters: {
72
+ name: string;
73
+ in: string;
74
+ description: string;
75
+ schema: {
76
+ type: string;
77
+ };
78
+ }[];
79
+ };
80
+ };
81
+ '/span': {
82
+ post: {
83
+ tags: string[];
84
+ summary: string;
85
+ parameters: {
86
+ name: string;
87
+ in: string;
88
+ description: string;
89
+ schema: {
90
+ type: string;
91
+ };
92
+ }[];
93
+ };
94
+ };
95
+ '/div': {
96
+ post: {
97
+ tags: string[];
98
+ summary: string;
99
+ parameters: {
100
+ name: string;
101
+ in: string;
102
+ description: string;
103
+ schema: {
104
+ type: string;
105
+ };
106
+ }[];
107
+ };
108
+ };
109
+ '/ul': {
110
+ post: {
111
+ tags: string[];
112
+ summary: string;
113
+ parameters: {
114
+ name: string;
115
+ in: string;
116
+ description: string;
117
+ schema: {
118
+ type: string;
119
+ };
120
+ }[];
121
+ };
122
+ };
123
+ '/li': {
124
+ post: {
125
+ tags: string[];
126
+ summary: string;
127
+ parameters: {
128
+ name: string;
129
+ in: string;
130
+ description: string;
131
+ schema: {
132
+ type: string;
133
+ };
134
+ }[];
135
+ };
136
+ };
137
+ };
138
+ components: {
139
+ schemas: {};
140
+ };
141
+ 'x-scene-blocks': {};
142
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-web-editor",
3
- "version": "0.4.9",
3
+ "version": "0.4.11",
4
4
  "dependencies": {},
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js"
@@ -169,7 +169,7 @@ function getComponentBlockDefinition(library, componentName, methodData, compone
169
169
  }
170
170
  return blockDefinition;
171
171
  }
172
- function generateToolboxFromLibraries(libraries) {
172
+ function generateToolboxFromLibraries(libraries, tags) {
173
173
  const sortedLibraries = libraries.sort((a, b)=>{
174
174
  var _a_info_summary;
175
175
  const title1 = (_a_info_summary = a.info.summary) != null ? _a_info_summary : a.info.title;
@@ -231,19 +231,19 @@ function generateToolboxFromLibraries(libraries) {
231
231
  kind: 'category',
232
232
  name: library.info['x-icon'] + ' ' + ((_library_info_summary = library.info.summary) != null ? _library_info_summary : library.info.title),
233
233
  contents: [
234
- ...library.paths ? Object.entries(library.paths).sort((a, b)=>a[0].localeCompare(b[0])) // Tri alphabétique par path
234
+ ...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
235
  .map(([path, _pins])=>({
236
236
  kind: 'block',
237
237
  type: library.info.title + '/__PINS__' + path
238
238
  })) : [],
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])=>({
239
+ ...((_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
240
+ .map(([componentName])=>({
241
241
  kind: 'block',
242
242
  type: library.info.title + '/__COMPONENTS__/' + componentName
243
243
  })) : []
244
244
  ]
245
245
  };
246
- })
246
+ }).filter((library)=>library.contents.length > 0)
247
247
  ]
248
248
  };
249
249
  return toolbox;
@@ -167,7 +167,7 @@ function getComponentBlockDefinition(library, componentName, methodData, compone
167
167
  }
168
168
  return blockDefinition;
169
169
  }
170
- function generateToolboxFromLibraries(libraries) {
170
+ function generateToolboxFromLibraries(libraries, tags) {
171
171
  const sortedLibraries = libraries.sort((a, b)=>{
172
172
  var _a_info_summary;
173
173
  const title1 = (_a_info_summary = a.info.summary) != null ? _a_info_summary : a.info.title;
@@ -229,19 +229,19 @@ function generateToolboxFromLibraries(libraries) {
229
229
  kind: 'category',
230
230
  name: library.info['x-icon'] + ' ' + ((_library_info_summary = library.info.summary) != null ? _library_info_summary : library.info.title),
231
231
  contents: [
232
- ...library.paths ? Object.entries(library.paths).sort((a, b)=>a[0].localeCompare(b[0])) // Tri alphabétique par path
232
+ ...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
233
  .map(([path, _pins])=>({
234
234
  kind: 'block',
235
235
  type: library.info.title + '/__PINS__' + path
236
236
  })) : [],
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])=>({
237
+ ...((_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
238
+ .map(([componentName])=>({
239
239
  kind: 'block',
240
240
  type: library.info.title + '/__COMPONENTS__/' + componentName
241
241
  })) : []
242
242
  ]
243
243
  };
244
- })
244
+ }).filter((library)=>library.contents.length > 0)
245
245
  ]
246
246
  };
247
247
  return toolbox;
package/schema.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "paths": {
10
10
  "/digipair-editor": {
11
11
  "post": {
12
- "tags": [],
12
+ "tags": ["web"],
13
13
  "summary": "Editeur de raisonnements",
14
14
  "description": "Editeur no-code de raisonnements IA",
15
15
  "parameters": [
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "/information": {
52
52
  "post": {
53
- "tags": [],
53
+ "tags": ["web"],
54
54
  "summary": "Affiche des information",
55
55
  "description": "Affiche des informations sur l'editeur de raisonnements",
56
56
  "parameters": [
@@ -69,7 +69,7 @@
69
69
  },
70
70
  "/error": {
71
71
  "post": {
72
- "tags": [],
72
+ "tags": ["web"],
73
73
  "summary": "Affiche une erreurs",
74
74
  "description": "Affiche une erreur sur l'editeur de raisonnements",
75
75
  "parameters": [