Skip to content

Commit 79d5b8f

Browse files
authored
Merge pull request #32 from kchadha/block-serialization-compression
Block serialization compression
2 parents 225d9a6 + 61a0694 commit 79d5b8f

File tree

1 file changed

+171
-81
lines changed

1 file changed

+171
-81
lines changed

lib/sb3_schema.json

+171-81
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@
1616
{"type": "boolean"}
1717
]
1818
},
19+
"stringOrNumber": {
20+
"oneOf": [
21+
{"type": "string"},
22+
{"type": "number"}
23+
]
24+
},
25+
"scalarVal": {
26+
"oneOf": [
27+
{"$ref":"#/definitions/stringOrNumber"},
28+
{"type": "boolean"}
29+
]
30+
},
1931
"assetId": {
2032
"type": "string",
2133
"pattern": "^[a-fA-F0-9]{32}$"
@@ -29,7 +41,7 @@
2941
},
3042
"dataFormat": {
3143
"type": "string",
32-
"enum": ["png", "PNG", "svg", "SVG", "jpeg", "JPEG", "jpg", "JPG", "bmp", "BMP"]
44+
"enum": ["png", "svg", "jpeg", "jpg", "bmp", "gif"]
3345
},
3446
"md5ext": {
3547
"type": "string",
@@ -59,15 +71,15 @@
5971
"assetId": { "$ref": "#/definitions/assetId"},
6072
"dataFormat": {
6173
"type": "string",
62-
"enum": ["wav", "WAV", "wave", "WAVE", "mp3", "MP3"]
74+
"enum": ["wav", "wave", "mp3"]
6375
},
6476
"format": {
6577
"type": "string",
6678
"enum": ["", "adpcm"]
6779
},
6880
"md5ext": {
6981
"type": "string",
70-
"pattern": "^[a-fA-F0-9]{32}.[a-zA-Z]+$"
82+
"pattern": "^[a-fA-F0-9]{32}.[a-zA-Z0-9]+$"
7183
},
7284
"name": {
7385
"type": "string"
@@ -87,98 +99,153 @@
8799
]
88100
},
89101
"scalar_variable": {
90-
"type": "object",
91-
"properties": {
92-
"name": {
93-
"type": "string"
94-
},
95-
"type": {
96-
"type": "string",
97-
"enum": ["", "scalar"]
98-
},
99-
"value": {
100-
"oneOf": [
101-
{"type": "string"},
102-
{"type": "number"}
103-
]
104-
}
105-
}
102+
"type": "array",
103+
"items": [
104+
{"type": "string", "description": "name of the variable"},
105+
{"$ref":"#/definitions/scalarVal", "description": "value of the variable"}
106+
],
107+
"additionalItems": {"type": "boolean", "enum": [true], "description": "Whether this is a cloud variable"},
108+
"maxItems": 3
106109
},
107110
"list": {
108-
"type": "object",
109-
"properties": {
110-
"name": {
111-
"type": "string"
112-
},
113-
"type": {
114-
"type": "string",
115-
"enum": ["list"]
116-
},
117-
"value": {
118-
"type": "array"
111+
"type": "array",
112+
"items": [
113+
{"type":"string", "description": "name of the list"},
114+
{
115+
"type": "array",
116+
"description": "contents of the list",
117+
"items": {"$ref":"#/definitions/scalarVal"}
119118
}
120-
}
119+
],
120+
"additionalItems": false
121121
},
122122
"broadcast_message": {
123-
"type": "object",
124-
"properties": {
125-
"name": {
126-
"type": "string"
123+
"type": "string",
124+
"description": "the message being broadcasted"
125+
},
126+
"num_primitive": {
127+
"type": "array",
128+
"items": [
129+
{
130+
"type": "number",
131+
"enum": [4,5,6,7,8]
127132
},
128-
"type": {
129-
"type": "string",
130-
"enum": ["broadcast_msg"]
133+
{"$ref":"#/definitions/stringOrNumber"}
134+
],
135+
"additionalItems": false
136+
},
137+
"color_primitive": {
138+
"type": "array",
139+
"items": [
140+
{
141+
"type": "number",
142+
"enum": [9]
131143
},
132-
"value": {
144+
{
133145
"type": "string",
134-
"not": {"enum": [""]}
146+
"pattern": "^#[a-fA-F0-9]{6}$"
135147
}
136-
}
148+
],
149+
"additionalItems": false
150+
},
151+
"text_primitive": {
152+
"type": "array",
153+
"items": [
154+
{
155+
"type": "number",
156+
"enum": [10]
157+
},
158+
{"$ref":"#/definitions/stringOrNumber"}
159+
],
160+
"additionalItems": false
161+
},
162+
"broadcast_primitive": {
163+
"type": "array",
164+
"items": [
165+
{
166+
"type": "number",
167+
"enum": [11]
168+
},
169+
{"type": "string", "description": "broadcast message"},
170+
{"type": "string", "description": "broadcast message id"}
171+
],
172+
"additionalItems": false
173+
},
174+
"variable_primitive": {
175+
"type": "array",
176+
"items": [
177+
{
178+
"type": "number",
179+
"enum": [12]
180+
},
181+
{"type": "string", "description": "variable name"},
182+
{"type": "string", "description": "variable id"}
183+
],
184+
"additionalItems": {
185+
"type": "number"
186+
},
187+
"minItems": 3,
188+
"maxItems": 5
189+
},
190+
"list_primitive": {
191+
"type": "array",
192+
"items": [
193+
{
194+
"type": "number",
195+
"enum": [13]
196+
},
197+
{"type": "string", "description": "list name"},
198+
{"type": "string", "description": "list id"}
199+
],
200+
"additionalItems": {
201+
"type": "number"
202+
},
203+
"minItems": 3,
204+
"maxItems": 5
205+
},
206+
"topLevelPrimitive": {
207+
"oneOf": [
208+
{"$ref":"#/definitions/variable_primitive"},
209+
{"$ref":"#/definitions/list_primitive"}
210+
]
211+
},
212+
"inputPrimitive": {
213+
"oneOf": [
214+
{"$ref":"#/definitions/num_primitive"},
215+
{"$ref":"#/definitions/color_primitive"},
216+
{"$ref":"#/definitions/text_primitive"},
217+
{"$ref":"#/definitions/broadcast_primitive"},
218+
{"$ref":"#/definitions/variable_primitive"},
219+
{"$ref":"#/definitions/list_primitive"}
220+
]
137221
},
138222
"block": {
139223
"type": "object",
140224
"properties": {
141-
"id": {
142-
"type": "string"
143-
},
144225
"opcode": {
145226
"type": "string"
146227
},
147228
"inputs": {
148229
"type": "object",
149230
"additionalProperties": {
150-
"type": "object",
151-
"properties": {
152-
"name": {
153-
"type": "string"
154-
},
155-
"block": {"$ref":"#/definitions/optionalString"},
156-
"shadow": {"$ref":"#/definitions/optionalString"},
157-
"value": {
158-
"oneOf": [
159-
{"type": "string"},
160-
{"type": "number"}
161-
]
231+
"type": "array",
232+
"items": [
233+
{
234+
"type":"number",
235+
"enum":[1,2,3],
236+
"description": "1 = unobscured shadow, 2 = no shadow, 3 = obscured shadow"
162237
}
238+
],
239+
"additionalItems": {
240+
"oneOf": [
241+
{"$ref":"#/definitions/optionalString"},
242+
{"$ref":"#/definitions/inputPrimitive"}
243+
]
163244
}
164245
}
165246
},
166247
"fields": {
167-
"type": "object",
168-
"additionalProperties": {
169-
"type": "object",
170-
"properties": {
171-
"name": {
172-
"type": "string"
173-
},
174-
"value": {
175-
"oneOf": [
176-
{"type": "string"},
177-
{"type": "number"}
178-
]
179-
}
180-
}
181-
}
248+
"type": "object"
182249
},
183250
"next": {"$ref":"#/definitions/optionalString"},
184251
"topLevel": {
@@ -216,7 +283,6 @@
216283
}
217284
},
218285
"required": [
219-
"id",
220286
"opcode"
221287
]
222288
},
@@ -231,8 +297,22 @@
231297
"isStage": {
232298
"type": "boolean",
233299
"enum": [true]
300+
},
301+
"tempo": {
302+
"type": "number"
303+
},
304+
"videoTransparency": {
305+
"type": "number"
306+
},
307+
"videoState": {
308+
"type": "string",
309+
"enum": ["on", "off", "on-flipped"]
234310
}
235-
}
311+
},
312+
"required": [
313+
"name",
314+
"isStage"
315+
]
236316
},
237317
"sprite": {
238318
"type": "object",
@@ -283,29 +363,39 @@
283363
"minimum": 0
284364
},
285365
"blocks": {
286-
"type": "object",
287-
"additionalProperties": {"$ref":"#/definitions/block"}
288-
},
289-
"variables": {
290366
"type": "object",
291367
"additionalProperties": {
292368
"oneOf": [
293-
{"$ref":"#/definitions/scalar_variable"},
294-
{"$ref":"#/definitions/list"},
295-
{"$ref":"#/definitions/broadcast_message"}
369+
{"$ref":"#/definitions/block"},
370+
{"$ref":"#/definitions/topLevelPrimitive"}
296371
]
297372
}
298373
},
374+
"variables": {
375+
"type": "object",
376+
"additionalProperties": {"$ref":"#/definitions/scalar_variable"}
377+
},
378+
"lists": {
379+
"type": "object",
380+
"additionalProperties": {"$ref":"#/definitions/list"}
381+
},
382+
"broadcasts": {
383+
"type": "object",
384+
"additionalProperties": {"$ref":"#/definitions/broadcast_message"}
385+
},
299386
"costumes": {
300387
"type": "array",
301388
"items": {"$ref":"#/definitions/costume"},
302389
"minItems": 1,
303390
"uniqueItems": true
304391
},
305-
"sounds":{
392+
"sounds": {
306393
"type": "array",
307394
"items": {"$ref":"#/definitions/sound"},
308395
"uniqueItems": true
396+
},
397+
"volume": {
398+
"type": "number"
309399
}
310400
},
311401
"required": [

0 commit comments

Comments
 (0)