diff --git a/lib/sb3_definitions.json b/lib/sb3_definitions.json index 128e2c67..08aca332 100644 --- a/lib/sb3_definitions.json +++ b/lib/sb3_definitions.json @@ -29,12 +29,7 @@ {"type": "number"} ] }, - "scalarVal": { - "oneOf": [ - {"$ref":"#/definitions/stringOrNumber"}, - {"type": "boolean"} - ] - }, + "scalarVal": {}, "assetId": { "type": "string", "pattern": "^[a-fA-F0-9]{32}$" diff --git a/test/fixtures/tw_non_scalar_variables.json b/test/fixtures/tw_non_scalar_variables.json new file mode 100644 index 00000000..89a4e242 --- /dev/null +++ b/test/fixtures/tw_non_scalar_variables.json @@ -0,0 +1,95 @@ +{ + "targets": [ + { + "isStage": true, + "name": "Stage", + "variables": { + "8Ct!xBe$u3!.nz_Bh/]#": [ + "object", + { + "hello": "world" + } + ] + }, + "lists": { + "u(}PhnFj*Oe*`Ka~{hhc": [ + "list of objects", + [ + { + "a": 1 + }, + { + "b": 2 + } + ] + ] + }, + "broadcasts": {}, + "blocks": {}, + "comments": {}, + "currentCostume": 0, + "costumes": [ + { + "name": "backdrop1", + "dataFormat": "svg", + "assetId": "cd21514d0531fdffb22204e0ec5ed84a", + "md5ext": "cd21514d0531fdffb22204e0ec5ed84a.svg", + "rotationCenterX": 240, + "rotationCenterY": 180 + } + ], + "sounds": [], + "volume": 100, + "layerOrder": 0, + "tempo": 60, + "videoTransparency": 50, + "videoState": "on", + "textToSpeechLanguage": null + } + ], + "monitors": [ + { + "id": "8Ct!xBe$u3!.nz_Bh/]#", + "mode": "default", + "opcode": "data_variable", + "params": { + "VARIABLE": "object" + }, + "spriteName": null, + "value": 0, + "width": 0, + "height": 0, + "x": 5, + "y": 5, + "visible": true, + "sliderMin": 0, + "sliderMax": 100, + "isDiscrete": true + }, + { + "id": "u(}PhnFj*Oe*`Ka~{hhc", + "mode": "list", + "opcode": "data_listcontents", + "params": { + "LIST": "list of objects" + }, + "spriteName": null, + "value": [], + "width": 0, + "height": 0, + "x": 5, + "y": 32, + "visible": true + } + ], + "extensions": [], + "meta": { + "semver": "3.0.0", + "vm": "0.2.0", + "agent": "", + "platform": { + "name": "TurboWarp", + "url": "https://turbowarp.org/" + } + } +} \ No newline at end of file diff --git a/test/integration/tw_non_scalar_variables.js b/test/integration/tw_non_scalar_variables.js new file mode 100644 index 00000000..333a1abd --- /dev/null +++ b/test/integration/tw_non_scalar_variables.js @@ -0,0 +1,23 @@ +const test = require('tap').test; +const fs = require('fs'); +const path = require('path'); +const parser = require('../../index'); + +test('non scalar variables', function (t) { + const fixture = fs.readFileSync(path.join(__dirname, '../fixtures/tw_non_scalar_variables.json'), 'utf-8'); + parser(fixture, false, function (err, result) { + t.equal(err, null); + t.same(result[0].targets[0].variables['8Ct!xBe$u3!.nz_Bh/]#'][1], { + hello: 'world' + }); + t.same(result[0].targets[0].lists['u(}PhnFj*Oe*`Ka~{hhc'][1], [ + { + a: 1 + }, + { + b: 2 + } + ]); + t.end(); + }); +});