@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.
- package/blockly-to-json.cjs.js +12 -1
- package/blockly-to-json.esm.js +12 -1
- package/index.cjs2.js +433 -37
- package/index.esm2.js +433 -37
- package/libs/skill-web-editor/src/lib/generator/pins-to-blockly.d.ts +1 -1
- package/libs/skill-web-editor/src/lib/schemas/web.schema.d.ts +142 -0
- package/package.json +1 -1
- package/pins-to-blockly.cjs.js +37 -15
- package/pins-to-blockly.esm.js +37 -15
package/blockly-to-json.cjs.js
CHANGED
|
@@ -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,14 +139,18 @@ 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
|
}
|
|
144
147
|
} else {
|
|
145
148
|
const codeToAdd = getCodeFromBlock(connectedBlock);
|
|
149
|
+
const inputCode = jsonGenerator.customStatementToCode(block, inputName);
|
|
146
150
|
if (inputName === 'pins') {
|
|
147
|
-
const inputCode = jsonGenerator.customStatementToCode(block, inputName);
|
|
148
151
|
code += ` "${inputName}": [${inputCode}],`;
|
|
152
|
+
} else if (inputName.includes('__CONDITION__/')) {
|
|
153
|
+
conditionCode += ` "${inputName.split('__CONDITION__/')[1]}": ${inputCode},`;
|
|
149
154
|
} else if (codeToAdd !== 'undefined') {
|
|
150
155
|
propertiesCode += ` "${inputName}": ${codeToAdd},`;
|
|
151
156
|
}
|
|
@@ -164,6 +169,12 @@ jsonGenerator.generatePin = function(block) {
|
|
|
164
169
|
}
|
|
165
170
|
code += '\n"events": {\n' + eventCode + '\n },';
|
|
166
171
|
}
|
|
172
|
+
if (conditionCode !== '') {
|
|
173
|
+
if (conditionCode.endsWith(',')) {
|
|
174
|
+
conditionCode = conditionCode.slice(0, -1);
|
|
175
|
+
}
|
|
176
|
+
code += '\n"conditions": {\n' + conditionCode + '\n },';
|
|
177
|
+
}
|
|
167
178
|
if (code.endsWith(',')) {
|
|
168
179
|
code = code.slice(0, -1);
|
|
169
180
|
}
|
package/blockly-to-json.esm.js
CHANGED
|
@@ -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,14 +137,18 @@ 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
|
}
|
|
142
145
|
} else {
|
|
143
146
|
const codeToAdd = getCodeFromBlock(connectedBlock);
|
|
147
|
+
const inputCode = jsonGenerator.customStatementToCode(block, inputName);
|
|
144
148
|
if (inputName === 'pins') {
|
|
145
|
-
const inputCode = jsonGenerator.customStatementToCode(block, inputName);
|
|
146
149
|
code += ` "${inputName}": [${inputCode}],`;
|
|
150
|
+
} else if (inputName.includes('__CONDITION__/')) {
|
|
151
|
+
conditionCode += ` "${inputName.split('__CONDITION__/')[1]}": ${inputCode},`;
|
|
147
152
|
} else if (codeToAdd !== 'undefined') {
|
|
148
153
|
propertiesCode += ` "${inputName}": ${codeToAdd},`;
|
|
149
154
|
}
|
|
@@ -162,6 +167,12 @@ jsonGenerator.generatePin = function(block) {
|
|
|
162
167
|
}
|
|
163
168
|
code += '\n"events": {\n' + eventCode + '\n },';
|
|
164
169
|
}
|
|
170
|
+
if (conditionCode !== '') {
|
|
171
|
+
if (conditionCode.endsWith(',')) {
|
|
172
|
+
conditionCode = conditionCode.slice(0, -1);
|
|
173
|
+
}
|
|
174
|
+
code += '\n"conditions": {\n' + conditionCode + '\n },';
|
|
175
|
+
}
|
|
165
176
|
if (code.endsWith(',')) {
|
|
166
177
|
code = code.slice(0, -1);
|
|
167
178
|
}
|
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];
|
|
@@ -2664,16 +2661,16 @@ function generateBlockFromPins(pinsSettings, workspace) {
|
|
|
2664
2661
|
const parameterType = getParameterType(parameter.schema.items);
|
|
2665
2662
|
for (const propertyValue of valueToLoad.reverse()){
|
|
2666
2663
|
const parameterBlock = parameterType === 'component' ? generateBlockFromComponent(propertyValue, workspace, library, parameter.schema.items.$ref) : generateBlockFromPins(propertyValue, workspace);
|
|
2667
|
-
const
|
|
2668
|
-
connectBlock(parameterBlock,
|
|
2664
|
+
const inputConnection = pinsBlock.getInput(parameter.name).connection;
|
|
2665
|
+
connectBlock(parameterBlock, inputConnection);
|
|
2669
2666
|
}
|
|
2670
2667
|
} else {
|
|
2671
2668
|
const parameterBlock = generateParameterBlock(parameter.schema, valueToLoad, workspace, library);
|
|
2672
|
-
const
|
|
2673
|
-
connectBlock(parameterBlock,
|
|
2669
|
+
const inputConnection = pinsBlock.getInput(parameter.name).connection;
|
|
2670
|
+
connectBlock(parameterBlock, inputConnection);
|
|
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
|
}
|
|
@@ -2684,6 +2681,42 @@ function generateBlockFromPins(pinsSettings, workspace) {
|
|
|
2684
2681
|
connectBlock(parameterBlock, inputConnection);
|
|
2685
2682
|
}
|
|
2686
2683
|
}
|
|
2684
|
+
const conditions = [
|
|
2685
|
+
{
|
|
2686
|
+
name: 'if',
|
|
2687
|
+
schema: {
|
|
2688
|
+
type: 'boolean'
|
|
2689
|
+
}
|
|
2690
|
+
},
|
|
2691
|
+
{
|
|
2692
|
+
name: 'each',
|
|
2693
|
+
schema: {
|
|
2694
|
+
type: 'array',
|
|
2695
|
+
items: {
|
|
2696
|
+
type: 'object'
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
];
|
|
2701
|
+
for (const parameter of conditions){
|
|
2702
|
+
var _parameter_schema_items;
|
|
2703
|
+
if (!pinsSettings.conditions || !Object.prototype.hasOwnProperty.call(pinsSettings.conditions, parameter.name)) {
|
|
2704
|
+
continue;
|
|
2705
|
+
}
|
|
2706
|
+
const valueToLoad = pinsSettings.conditions[parameter.name];
|
|
2707
|
+
if (parameter.schema.type === 'array' && ((_parameter_schema_items = parameter.schema.items) == null ? void 0 : _parameter_schema_items.$ref)) {
|
|
2708
|
+
const parameterType = getParameterType(parameter.schema.items);
|
|
2709
|
+
for (const propertyValue of valueToLoad.reverse()){
|
|
2710
|
+
const parameterBlock = parameterType === 'component' ? generateBlockFromComponent(propertyValue, workspace, library, parameter.schema.items.$ref) : generateBlockFromPins(propertyValue, workspace);
|
|
2711
|
+
const inputConnection = pinsBlock.getInput('__CONDITION__/' + parameter.name).connection;
|
|
2712
|
+
connectBlock(parameterBlock, inputConnection);
|
|
2713
|
+
}
|
|
2714
|
+
} else {
|
|
2715
|
+
const parameterBlock = generateParameterBlock(parameter.schema, valueToLoad, workspace, library);
|
|
2716
|
+
const inputConnection = pinsBlock.getInput('__CONDITION__/' + parameter.name).connection;
|
|
2717
|
+
connectBlock(parameterBlock, inputConnection);
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2687
2720
|
return pinsBlock;
|
|
2688
2721
|
}
|
|
2689
2722
|
function generateBlockFromComponent(componentSettings, workspace, library, component$ref) {
|
|
@@ -2920,6 +2953,20 @@ function itemListFromPinsSettings(pinsSettings, pinsDefinition) {
|
|
|
2920
2953
|
});
|
|
2921
2954
|
}
|
|
2922
2955
|
}
|
|
2956
|
+
if (pinsSettings.conditions) {
|
|
2957
|
+
if (pinsSettings.conditions.if) {
|
|
2958
|
+
inputArray.push({
|
|
2959
|
+
id: '__CONDITION__/if',
|
|
2960
|
+
name: '#if'
|
|
2961
|
+
});
|
|
2962
|
+
}
|
|
2963
|
+
if (pinsSettings.conditions.each) {
|
|
2964
|
+
inputArray.push({
|
|
2965
|
+
id: '__CONDITION__/each',
|
|
2966
|
+
name: '#each'
|
|
2967
|
+
});
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2923
2970
|
return inputArray;
|
|
2924
2971
|
}
|
|
2925
2972
|
function itemListFromComponentSettings(componentSettings, componentDefinition) {
|
|
@@ -2951,6 +2998,321 @@ function itemListFromSceneSettings(sceneSettings, sceneDefinition) {
|
|
|
2951
2998
|
return inputArray;
|
|
2952
2999
|
}
|
|
2953
3000
|
|
|
3001
|
+
const schemas = {
|
|
3002
|
+
openapi: '3.0.0',
|
|
3003
|
+
info: {
|
|
3004
|
+
title: 'web',
|
|
3005
|
+
summary: 'Web: bases',
|
|
3006
|
+
description: 'description de la librairie de pins web',
|
|
3007
|
+
version: '1.0.11',
|
|
3008
|
+
'x-icon': '🌐'
|
|
3009
|
+
},
|
|
3010
|
+
paths: {
|
|
3011
|
+
'/section': {
|
|
3012
|
+
post: {
|
|
3013
|
+
tags: [
|
|
3014
|
+
'needPins',
|
|
3015
|
+
'web'
|
|
3016
|
+
],
|
|
3017
|
+
summary: 'Section',
|
|
3018
|
+
parameters: [
|
|
3019
|
+
{
|
|
3020
|
+
name: 'class',
|
|
3021
|
+
in: 'query',
|
|
3022
|
+
description: '',
|
|
3023
|
+
schema: {
|
|
3024
|
+
type: 'string'
|
|
3025
|
+
}
|
|
3026
|
+
},
|
|
3027
|
+
{
|
|
3028
|
+
name: 'textContent',
|
|
3029
|
+
in: 'query',
|
|
3030
|
+
description: '',
|
|
3031
|
+
schema: {
|
|
3032
|
+
type: 'string'
|
|
3033
|
+
}
|
|
3034
|
+
}
|
|
3035
|
+
]
|
|
3036
|
+
}
|
|
3037
|
+
},
|
|
3038
|
+
'/h1': {
|
|
3039
|
+
post: {
|
|
3040
|
+
tags: [
|
|
3041
|
+
'web'
|
|
3042
|
+
],
|
|
3043
|
+
summary: 'h1',
|
|
3044
|
+
parameters: [
|
|
3045
|
+
{
|
|
3046
|
+
name: 'textContent',
|
|
3047
|
+
in: 'query',
|
|
3048
|
+
description: '',
|
|
3049
|
+
schema: {
|
|
3050
|
+
type: 'string'
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
]
|
|
3054
|
+
}
|
|
3055
|
+
},
|
|
3056
|
+
'/nav': {
|
|
3057
|
+
post: {
|
|
3058
|
+
tags: [
|
|
3059
|
+
'needPins',
|
|
3060
|
+
'web'
|
|
3061
|
+
],
|
|
3062
|
+
summary: 'nav',
|
|
3063
|
+
parameters: [
|
|
3064
|
+
{
|
|
3065
|
+
name: 'class',
|
|
3066
|
+
in: 'query',
|
|
3067
|
+
description: '',
|
|
3068
|
+
schema: {
|
|
3069
|
+
type: 'string'
|
|
3070
|
+
}
|
|
3071
|
+
}
|
|
3072
|
+
]
|
|
3073
|
+
}
|
|
3074
|
+
},
|
|
3075
|
+
'/a': {
|
|
3076
|
+
post: {
|
|
3077
|
+
tags: [
|
|
3078
|
+
'needPins',
|
|
3079
|
+
'web'
|
|
3080
|
+
],
|
|
3081
|
+
summary: 'a',
|
|
3082
|
+
parameters: [
|
|
3083
|
+
{
|
|
3084
|
+
name: 'class',
|
|
3085
|
+
in: 'query',
|
|
3086
|
+
description: '',
|
|
3087
|
+
schema: {
|
|
3088
|
+
type: 'string'
|
|
3089
|
+
}
|
|
3090
|
+
},
|
|
3091
|
+
{
|
|
3092
|
+
name: 'href',
|
|
3093
|
+
in: 'query',
|
|
3094
|
+
description: '',
|
|
3095
|
+
schema: {
|
|
3096
|
+
type: 'string'
|
|
3097
|
+
}
|
|
3098
|
+
},
|
|
3099
|
+
{
|
|
3100
|
+
name: 'textContent',
|
|
3101
|
+
in: 'query',
|
|
3102
|
+
description: '',
|
|
3103
|
+
schema: {
|
|
3104
|
+
type: 'string'
|
|
3105
|
+
}
|
|
3106
|
+
},
|
|
3107
|
+
{
|
|
3108
|
+
name: 'id',
|
|
3109
|
+
in: 'query',
|
|
3110
|
+
description: '',
|
|
3111
|
+
schema: {
|
|
3112
|
+
type: 'string'
|
|
3113
|
+
}
|
|
3114
|
+
},
|
|
3115
|
+
{
|
|
3116
|
+
name: 'role',
|
|
3117
|
+
in: 'query',
|
|
3118
|
+
description: '',
|
|
3119
|
+
schema: {
|
|
3120
|
+
type: 'string'
|
|
3121
|
+
}
|
|
3122
|
+
},
|
|
3123
|
+
{
|
|
3124
|
+
name: 'data-toggle',
|
|
3125
|
+
in: 'query',
|
|
3126
|
+
description: '',
|
|
3127
|
+
schema: {
|
|
3128
|
+
type: 'string'
|
|
3129
|
+
}
|
|
3130
|
+
},
|
|
3131
|
+
{
|
|
3132
|
+
name: 'aria-haspopup',
|
|
3133
|
+
in: 'query',
|
|
3134
|
+
description: '',
|
|
3135
|
+
schema: {
|
|
3136
|
+
type: 'string'
|
|
3137
|
+
}
|
|
3138
|
+
},
|
|
3139
|
+
{
|
|
3140
|
+
name: 'aria-expanded',
|
|
3141
|
+
in: 'query',
|
|
3142
|
+
description: '',
|
|
3143
|
+
schema: {
|
|
3144
|
+
type: 'string'
|
|
3145
|
+
}
|
|
3146
|
+
}
|
|
3147
|
+
]
|
|
3148
|
+
}
|
|
3149
|
+
},
|
|
3150
|
+
'/button': {
|
|
3151
|
+
post: {
|
|
3152
|
+
tags: [
|
|
3153
|
+
'needPins',
|
|
3154
|
+
'web'
|
|
3155
|
+
],
|
|
3156
|
+
summary: 'button',
|
|
3157
|
+
parameters: [
|
|
3158
|
+
{
|
|
3159
|
+
name: 'class',
|
|
3160
|
+
in: 'query',
|
|
3161
|
+
description: '',
|
|
3162
|
+
schema: {
|
|
3163
|
+
type: 'string'
|
|
3164
|
+
}
|
|
3165
|
+
},
|
|
3166
|
+
{
|
|
3167
|
+
name: 'type',
|
|
3168
|
+
in: 'query',
|
|
3169
|
+
description: '',
|
|
3170
|
+
schema: {
|
|
3171
|
+
type: 'string'
|
|
3172
|
+
}
|
|
3173
|
+
},
|
|
3174
|
+
{
|
|
3175
|
+
name: 'data-toggle',
|
|
3176
|
+
in: 'query',
|
|
3177
|
+
description: '',
|
|
3178
|
+
schema: {
|
|
3179
|
+
type: 'string'
|
|
3180
|
+
}
|
|
3181
|
+
},
|
|
3182
|
+
{
|
|
3183
|
+
name: 'data-target',
|
|
3184
|
+
in: 'query',
|
|
3185
|
+
description: '',
|
|
3186
|
+
schema: {
|
|
3187
|
+
type: 'string'
|
|
3188
|
+
}
|
|
3189
|
+
},
|
|
3190
|
+
{
|
|
3191
|
+
name: 'aria-controls',
|
|
3192
|
+
in: 'query',
|
|
3193
|
+
description: '',
|
|
3194
|
+
schema: {
|
|
3195
|
+
type: 'string'
|
|
3196
|
+
}
|
|
3197
|
+
},
|
|
3198
|
+
{
|
|
3199
|
+
name: 'aria-expanded',
|
|
3200
|
+
in: 'query',
|
|
3201
|
+
description: '',
|
|
3202
|
+
schema: {
|
|
3203
|
+
type: 'string'
|
|
3204
|
+
}
|
|
3205
|
+
},
|
|
3206
|
+
{
|
|
3207
|
+
name: 'aria-label',
|
|
3208
|
+
in: 'query',
|
|
3209
|
+
description: '',
|
|
3210
|
+
schema: {
|
|
3211
|
+
type: 'string'
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
]
|
|
3215
|
+
}
|
|
3216
|
+
},
|
|
3217
|
+
'/span': {
|
|
3218
|
+
post: {
|
|
3219
|
+
tags: [
|
|
3220
|
+
'needPins',
|
|
3221
|
+
'web'
|
|
3222
|
+
],
|
|
3223
|
+
summary: 'span',
|
|
3224
|
+
parameters: [
|
|
3225
|
+
{
|
|
3226
|
+
name: 'class',
|
|
3227
|
+
in: 'query',
|
|
3228
|
+
description: '',
|
|
3229
|
+
schema: {
|
|
3230
|
+
type: 'string'
|
|
3231
|
+
}
|
|
3232
|
+
}
|
|
3233
|
+
]
|
|
3234
|
+
}
|
|
3235
|
+
},
|
|
3236
|
+
'/div': {
|
|
3237
|
+
post: {
|
|
3238
|
+
tags: [
|
|
3239
|
+
'needPins',
|
|
3240
|
+
'web'
|
|
3241
|
+
],
|
|
3242
|
+
summary: 'div',
|
|
3243
|
+
parameters: [
|
|
3244
|
+
{
|
|
3245
|
+
name: 'class',
|
|
3246
|
+
in: 'query',
|
|
3247
|
+
description: '',
|
|
3248
|
+
schema: {
|
|
3249
|
+
type: 'string'
|
|
3250
|
+
}
|
|
3251
|
+
},
|
|
3252
|
+
{
|
|
3253
|
+
name: 'id',
|
|
3254
|
+
in: 'query',
|
|
3255
|
+
description: '',
|
|
3256
|
+
schema: {
|
|
3257
|
+
type: 'string'
|
|
3258
|
+
}
|
|
3259
|
+
},
|
|
3260
|
+
{
|
|
3261
|
+
name: 'aria-labelledby',
|
|
3262
|
+
in: 'query',
|
|
3263
|
+
description: '',
|
|
3264
|
+
schema: {
|
|
3265
|
+
type: 'string'
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
]
|
|
3269
|
+
}
|
|
3270
|
+
},
|
|
3271
|
+
'/ul': {
|
|
3272
|
+
post: {
|
|
3273
|
+
tags: [
|
|
3274
|
+
'needPins',
|
|
3275
|
+
'web'
|
|
3276
|
+
],
|
|
3277
|
+
summary: 'ul',
|
|
3278
|
+
parameters: [
|
|
3279
|
+
{
|
|
3280
|
+
name: 'class',
|
|
3281
|
+
in: 'query',
|
|
3282
|
+
description: '',
|
|
3283
|
+
schema: {
|
|
3284
|
+
type: 'string'
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
]
|
|
3288
|
+
}
|
|
3289
|
+
},
|
|
3290
|
+
'/li': {
|
|
3291
|
+
post: {
|
|
3292
|
+
tags: [
|
|
3293
|
+
'needPins',
|
|
3294
|
+
'web'
|
|
3295
|
+
],
|
|
3296
|
+
summary: 'li',
|
|
3297
|
+
parameters: [
|
|
3298
|
+
{
|
|
3299
|
+
name: 'class',
|
|
3300
|
+
in: 'query',
|
|
3301
|
+
description: '',
|
|
3302
|
+
schema: {
|
|
3303
|
+
type: 'string'
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
]
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
},
|
|
3310
|
+
components: {
|
|
3311
|
+
schemas: {}
|
|
3312
|
+
},
|
|
3313
|
+
'x-scene-blocks': {}
|
|
3314
|
+
};
|
|
3315
|
+
|
|
2954
3316
|
const Toastify$1 = toastify;
|
|
2955
3317
|
const BASE_URL = 'https://cdn.jsdelivr.net/npm';
|
|
2956
3318
|
const BLOCKLY_VERSION = '10.4.3';
|
|
@@ -3000,32 +3362,9 @@ class GenericSceneElement extends s {
|
|
|
3000
3362
|
setTimeout(()=>this.loadScene(this.digipair, this.reasoning), 1);
|
|
3001
3363
|
this.addEventListener('setReasoning', ({ detail })=>this.loadReasoning(detail));
|
|
3002
3364
|
}
|
|
3003
|
-
loadReasoning(
|
|
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
|
-
});
|
|
3365
|
+
loadReasoning(reasoning) {
|
|
3027
3366
|
Blockly.Events.disable();
|
|
3028
|
-
initializeWorkspaceFromPinsAndLibraries(
|
|
3367
|
+
initializeWorkspaceFromPinsAndLibraries(reasoning, this.workspace, this.librariesToLoad);
|
|
3029
3368
|
Blockly.Events.enable();
|
|
3030
3369
|
}
|
|
3031
3370
|
async getReasoning(digipair, reasoning) {
|
|
@@ -3043,7 +3382,10 @@ class GenericSceneElement extends s {
|
|
|
3043
3382
|
return content;
|
|
3044
3383
|
}
|
|
3045
3384
|
async getLibraries(libraries) {
|
|
3046
|
-
const list =
|
|
3385
|
+
const list = [
|
|
3386
|
+
schemas,
|
|
3387
|
+
...await Promise.all(Object.keys(libraries).map(async (library, i)=>fetch(`${BASE_URL}/${library}@${libraries[library]}/schema.json`).then((res)=>res.json())))
|
|
3388
|
+
];
|
|
3047
3389
|
return list;
|
|
3048
3390
|
}
|
|
3049
3391
|
async loadScene(digipair, reasoning) {
|
|
@@ -3091,10 +3433,12 @@ class GenericSceneElement extends s {
|
|
|
3091
3433
|
}
|
|
3092
3434
|
}
|
|
3093
3435
|
loadBlockly(scene) {
|
|
3436
|
+
var _this_librariesToLoad_find_xsceneblocks_, _this_librariesToLoad_find_xsceneblocks, _this_librariesToLoad_find;
|
|
3094
3437
|
initializeMutator();
|
|
3095
3438
|
const generatedBlocks = generateBlocklyBlockFromLibraries(this.librariesToLoad, blocksLegacy);
|
|
3096
3439
|
this.blocks = Blockly.common.createBlockDefinitionsFromJsonArray(generatedBlocks);
|
|
3097
|
-
|
|
3440
|
+
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) || [];
|
|
3441
|
+
this.toolbox = generateToolboxFromLibraries(this.librariesToLoad, tags);
|
|
3098
3442
|
Blockly.common.defineBlocks(this.blocks);
|
|
3099
3443
|
const container = this.renderRoot.querySelector('[data-scene]');
|
|
3100
3444
|
this.workspace = Blockly.inject(container, {
|
|
@@ -3106,7 +3450,51 @@ class GenericSceneElement extends s {
|
|
|
3106
3450
|
scrollbars: true,
|
|
3107
3451
|
drag: true,
|
|
3108
3452
|
wheel: true
|
|
3109
|
-
}
|
|
3453
|
+
},
|
|
3454
|
+
theme: Blockly.Theme.defineTheme('modest', {
|
|
3455
|
+
blockStyles: {
|
|
3456
|
+
logic_blocks: {
|
|
3457
|
+
colourPrimary: '#D1C4E9',
|
|
3458
|
+
colourSecondary: '#EDE7F6',
|
|
3459
|
+
colorTertiary: '#B39DDB'
|
|
3460
|
+
},
|
|
3461
|
+
loop_blocks: {
|
|
3462
|
+
colourPrimary: '#A5D6A7',
|
|
3463
|
+
colourSecondary: '#E8F5E9',
|
|
3464
|
+
colorTertiary: '#66BB6A'
|
|
3465
|
+
},
|
|
3466
|
+
math_blocks: {
|
|
3467
|
+
colourPrimary: '#2196F3',
|
|
3468
|
+
colourSecondary: '#1E88E5',
|
|
3469
|
+
colorTertiary: '#0D47A1'
|
|
3470
|
+
},
|
|
3471
|
+
text_blocks: {
|
|
3472
|
+
colourPrimary: '#FFCA28',
|
|
3473
|
+
colourSecondary: '#FFF8E1',
|
|
3474
|
+
colorTertiary: '#FF8F00'
|
|
3475
|
+
},
|
|
3476
|
+
list_blocks: {
|
|
3477
|
+
colourPrimary: '#4DB6AC',
|
|
3478
|
+
colourSecondary: '#B2DFDB',
|
|
3479
|
+
colorTertiary: '#009688'
|
|
3480
|
+
},
|
|
3481
|
+
variable_blocks: {
|
|
3482
|
+
colourPrimary: '#EF9A9A',
|
|
3483
|
+
colourSecondary: '#FFEBEE',
|
|
3484
|
+
colorTertiary: '#EF5350'
|
|
3485
|
+
},
|
|
3486
|
+
variable_dynamic_blocks: {
|
|
3487
|
+
colourPrimary: '#EF9A9A',
|
|
3488
|
+
colourSecondary: '#FFEBEE',
|
|
3489
|
+
colorTertiary: '#EF5350'
|
|
3490
|
+
},
|
|
3491
|
+
procedure_blocks: {
|
|
3492
|
+
colourPrimary: '#D7CCC8',
|
|
3493
|
+
colourSecondary: '#EFEBE9',
|
|
3494
|
+
colorTertiary: '#BCAAA4'
|
|
3495
|
+
}
|
|
3496
|
+
}
|
|
3497
|
+
})
|
|
3110
3498
|
});
|
|
3111
3499
|
this.workspace.addChangeListener((e)=>{
|
|
3112
3500
|
if (e.isUiEvent || e.type == Blockly.Events.FINISHED_LOADING) {
|
|
@@ -3157,6 +3545,14 @@ class GenericSceneElement extends s {
|
|
|
3157
3545
|
height: 30px;
|
|
3158
3546
|
line-height: 30px;
|
|
3159
3547
|
}
|
|
3548
|
+
|
|
3549
|
+
.blocklyPath {
|
|
3550
|
+
stroke: #fff;
|
|
3551
|
+
}
|
|
3552
|
+
|
|
3553
|
+
.blocklyPathDark {
|
|
3554
|
+
fill: #fff;
|
|
3555
|
+
}
|
|
3160
3556
|
</style>
|
|
3161
3557
|
|
|
3162
3558
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
|