sb-edit
Version:
Import, edit, and export Scratch project files
66 lines (65 loc) • 2.7 kB
JavaScript
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var Target_1 = require("./Target");
var fromSb3_1 = __importStar(require("./io/sb3/fromSb3"));
var toSb3_1 = __importDefault(require("./io/sb3/toSb3"));
var toLeopard_1 = __importDefault(require("./io/leopard/toLeopard"));
var toScratchblocks_1 = __importDefault(require("./io/scratchblocks/toScratchblocks"));
var Project = /** @class */ (function () {
function Project(options) {
this.toSb3 = toSb3_1.default.bind(null, this);
this.toLeopard = toLeopard_1.default.bind(null, this);
this.toScratchblocks = toScratchblocks_1.default.bind(null, this);
this.stage = new Target_1.Stage();
this.sprites = [];
this.tempo = 60;
this.videoOn = false;
this.videoAlpha = 0.5;
this.textToSpeechLanguage = null;
Object.assign(this, options);
for (var _i = 0, _a = this.sprites; _i < _a.length; _i++) {
var sprite = _a[_i];
sprite.project = this;
}
}
Project.prototype.sprite = function (id) {
switch (typeof id) {
case "string":
return this.sprites.find(function (sprite) { return sprite.name === id; }) || null;
case "number":
return this.sprites[id] || null;
default:
return null;
}
};
Project.fromSb3 = fromSb3_1.default;
Project.fromSb3JSON = fromSb3_1.fromSb3JSON;
return Project;
}());
exports.default = Project;