Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block serialization compression #32

Merged
252 changes: 171 additions & 81 deletions lib/sb3_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
{"type": "boolean"}
]
},
"stringOrNumber": {
"oneOf": [
{"type": "string"},
{"type": "number"}
]
},
"scalarVal": {
"oneOf": [
{"$ref":"#/definitions/stringOrNumber"},
{"type": "boolean"}
]
},
"assetId": {
"type": "string",
"pattern": "^[a-fA-F0-9]{32}$"
Expand All @@ -29,7 +41,7 @@
},
"dataFormat": {
"type": "string",
"enum": ["png", "PNG", "svg", "SVG", "jpeg", "JPEG", "jpg", "JPG", "bmp", "BMP"]
"enum": ["png", "svg", "jpeg", "jpg", "bmp", "gif"]
},
"md5ext": {
"type": "string",
Expand Down Expand Up @@ -59,15 +71,15 @@
"assetId": { "$ref": "#/definitions/assetId"},
"dataFormat": {
"type": "string",
"enum": ["wav", "WAV", "wave", "WAVE", "mp3", "MP3"]
"enum": ["wav", "wave", "mp3"]
},
"format": {
"type": "string",
"enum": ["", "adpcm"]
},
"md5ext": {
"type": "string",
"pattern": "^[a-fA-F0-9]{32}.[a-zA-Z]+$"
"pattern": "^[a-fA-F0-9]{32}.[a-zA-Z0-9]+$"

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

},
"name": {
"type": "string"
Expand All @@ -87,98 +99,153 @@
]
},
"scalar_variable": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string",
"enum": ["", "scalar"]
},
"value": {
"oneOf": [
{"type": "string"},
{"type": "number"}
]
}
}
"type": "array",
"items": [
{"type": "string", "description": "name of the variable"},
{"$ref":"#/definitions/scalarVal", "description": "value of the variable"}
],
"additionalItems": {"type": "boolean", "enum": [true], "description": "Whether this is a cloud variable"},
"maxItems": 3
},
"list": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string",
"enum": ["list"]
},
"value": {
"type": "array"
"type": "array",
"items": [
{"type":"string", "description": "name of the list"},
{
"type": "array",
"description": "contents of the list",
"items": {"$ref":"#/definitions/scalarVal"}
}
}
],
"additionalItems": false
},
"broadcast_message": {
"type": "object",
"properties": {
"name": {
"type": "string"
"type": "string",
"description": "the message being broadcasted"
},
"num_primitive": {
"type": "array",
"items": [
{
"type": "number",
"enum": [4,5,6,7,8]
},
"type": {
"type": "string",
"enum": ["broadcast_msg"]
{"$ref":"#/definitions/stringOrNumber"}
],
"additionalItems": false
},
"color_primitive": {
"type": "array",
"items": [
{
"type": "number",
"enum": [9]
},
"value": {
{
"type": "string",
"not": {"enum": [""]}
"pattern": "^#[a-fA-F0-9]{6}$"
}
}
],
"additionalItems": false
},
"text_primitive": {
"type": "array",
"items": [
{
"type": "number",
"enum": [10]
},
{"$ref":"#/definitions/stringOrNumber"}
],
"additionalItems": false
},
"broadcast_primitive": {
"type": "array",
"items": [
{
"type": "number",
"enum": [11]
},
{"type": "string", "description": "broadcast message"},
{"type": "string", "description": "broadcast message id"}
],
"additionalItems": false
},
"variable_primitive": {
"type": "array",
"items": [
{
"type": "number",
"enum": [12]
},
{"type": "string", "description": "variable name"},
{"type": "string", "description": "variable id"}
],
"additionalItems": {
"type": "number"
},
"minItems": 3,
"maxItems": 5
},
"list_primitive": {
"type": "array",
"items": [
{
"type": "number",
"enum": [13]
},
{"type": "string", "description": "list name"},
{"type": "string", "description": "list id"}
],
"additionalItems": {
"type": "number"
},
"minItems": 3,
"maxItems": 5
},
"topLevelPrimitive": {
"oneOf": [
{"$ref":"#/definitions/variable_primitive"},
{"$ref":"#/definitions/list_primitive"}
]
},
"inputPrimitive": {
"oneOf": [
{"$ref":"#/definitions/num_primitive"},
{"$ref":"#/definitions/color_primitive"},
{"$ref":"#/definitions/text_primitive"},
{"$ref":"#/definitions/broadcast_primitive"},
{"$ref":"#/definitions/variable_primitive"},
{"$ref":"#/definitions/list_primitive"}
]
},
"block": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"opcode": {
"type": "string"
},
"inputs": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"block": {"$ref":"#/definitions/optionalString"},
"shadow": {"$ref":"#/definitions/optionalString"},
"value": {
"oneOf": [
{"type": "string"},
{"type": "number"}
]
"type": "array",
"items": [
{
"type":"number",
"enum":[1,2,3],
"description": "1 = unobscured shadow, 2 = no shadow, 3 = obscured shadow"
}
],
"additionalItems": {
"oneOf": [
{"$ref":"#/definitions/optionalString"},
{"$ref":"#/definitions/inputPrimitive"}
]
}
}
},
"fields": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"value": {
"oneOf": [
{"type": "string"},
{"type": "number"}
]
}
}
}
"type": "object"
},
"next": {"$ref":"#/definitions/optionalString"},
"topLevel": {
Expand Down Expand Up @@ -216,7 +283,6 @@
}
},
"required": [
"id",
"opcode"
]
},
Expand All @@ -231,8 +297,22 @@
"isStage": {
"type": "boolean",
"enum": [true]
},
"tempo": {
"type": "number"
},
"videoTransparency": {
"type": "number"
},
"videoState": {
"type": "string",
"enum": ["on", "off", "on-flipped"]
}
}
},
"required": [
"name",
"isStage"
]
},
"sprite": {
"type": "object",
Expand Down Expand Up @@ -283,29 +363,39 @@
"minimum": 0
},
"blocks": {
"type": "object",
"additionalProperties": {"$ref":"#/definitions/block"}
},
"variables": {
"type": "object",
"additionalProperties": {
"oneOf": [
{"$ref":"#/definitions/scalar_variable"},
{"$ref":"#/definitions/list"},
{"$ref":"#/definitions/broadcast_message"}
{"$ref":"#/definitions/block"},
{"$ref":"#/definitions/topLevelPrimitive"}
]
}
},
"variables": {
"type": "object",
"additionalProperties": {"$ref":"#/definitions/scalar_variable"}
},
"lists": {
"type": "object",
"additionalProperties": {"$ref":"#/definitions/list"}
},
"broadcasts": {
"type": "object",
"additionalProperties": {"$ref":"#/definitions/broadcast_message"}
},
"costumes": {
"type": "array",
"items": {"$ref":"#/definitions/costume"},
"minItems": 1,
"uniqueItems": true
},
"sounds":{
"sounds": {
"type": "array",
"items": {"$ref":"#/definitions/sound"},
"uniqueItems": true
},
"volume": {
"type": "number"
}
},
"required": [
Expand Down