Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"presets": ["@babel/preset-env"]
}
"presets": [
"@babel/preset-env",
"@babel/preset-typescript"
]
}
8 changes: 8 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
testEnvironment: "node",
transform: {
"^.+\\.[jt]s$": "babel-jest"
},
moduleFileExtensions: ["ts", "js", "json"],
setupFiles: ["./tests/jest.setup.js"]
};
12,343 changes: 6,669 additions & 5,674 deletions npm-shrinkwrap.json

Large diffs are not rendered by default.

27 changes: 14 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"test": "tests"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack --progress --color --watch --env dev",
"build": "webpack --env dev && webpack --env build"
"test": "jest",
"dev": "vite build --watch --mode development",
"build": "vite build --mode development && vite build --mode production"
},
"repository": {
"type": "git",
Expand All @@ -24,18 +24,19 @@
},
"homepage": "https://github.com/RealTimeWeb/blockpy#readme",
"devDependencies": {
"@babel/core": "7.0.0",
"@babel/preset-env": "7.11.0",
"babel-loader": "8.1.0",
"css-loader": "4.2.0",
"@babel/core": "^7.29.7",
"@babel/preset-env": "^7.29.7",
"@babel/preset-typescript": "^7.29.7",
"@rollup/plugin-inject": "^5.0.5",
"babel-jest": "^29.7.0",
"eslint": "5.0.0",
"eslint-loader": "4.0.2",
"jest": "^29.7.0",
"jquery": "3.5.1",
"knockout": "3.5.1",
"mini-css-extract-plugin": "0.9.0",
"path": "0.12.7",
"webpack": "4.44.1",
"webpack-cli": "^4.2.0",
"yargs": "15.4.1"
"typescript": "^5.9.3",
"vite": "^8.1.2"
},
"dependencies": {
"@codemirror/lang-python": "^6.2.1"
}
}
41 changes: 24 additions & 17 deletions src/blockpy.js → src/blockpy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import $ from "jquery";
import {$builtinmodule as imageModule} from "skulpt_modules/image";
import {$builtinmodule as weakrefModule} from "skulpt_modules/weakref";
//import {$builtinmodule as matplotlibModule} from "skulpt_modules/matplotlib2";
import {LocalStorageWrapper} from "storage.js";
import {EditorsEnum} from "editors.js";
import {DisplayModes} from "editor/python.js";
import {StatusState} from "server.js";
import {makeInterface, makeExtraInterfaceSubscriptions, SecondRowSecondPanelOptions} from "interface.js";
import {Editors} from "editors.js";
import {LocalStorageWrapper} from "storage";
import {EditorsEnum} from "editors";
import {DisplayModes} from "editor/python";
import {StatusState} from "server";
import {makeInterface, makeExtraInterfaceSubscriptions, SecondRowSecondPanelOptions} from "interface";
import {Editors} from "editors";
import {
BlockPyFileSystem,
loadConcatenatedFile,
Expand All @@ -23,10 +23,10 @@ import {
UNRENAMABLE_FILES
} from "./files";
import {uploadFile, downloadFile} from "./editor/abstract_editor";
import {BlockPyEngine} from "engine.js";
import {BlockPyEngine} from "engine";
import {AST_DESCRIPTIONS, BlockPyTrace} from "./trace";
import {BlockPyConsole} from "./console";
import {BlockPyFeedback} from "feedback.js";
import {BlockPyFeedback} from "feedback";
import {BlockPyServer} from "./server";
import {BlockPyDialog} from "./dialog";
import {AssigmentType, loadAssignmentSettings, makeAssignmentSettingsModel} from "./editor/assignment_settings";
Expand All @@ -49,12 +49,19 @@ const EDITOR_VERSION = "5.1.2";
* it on an assignment switch.
*/
export class BlockPy {
localSettings_: LocalStorageWrapper;
initialConfiguration_: Record<string, any>;
model: any;
components: any;
utilities: any;
clock: ReturnType<typeof setInterval> | null;

/**
* @param {Object} configuration - User level settings (e.g., what editor mode, whether to mute semantic errors, etc.)
* @param {Object} assignment - Assignment level settings (data about the loaded assignment, user, submission, etc.)
* @param {Object} submission - Includes the source code of any programs to be loaded
*/
constructor(configuration, assignment, submission) {
constructor(configuration: Record<string, any>, assignment?: any, submission?: any) {
this.initModel(configuration);
if (assignment !== undefined) {
this.setAssignment(configuration, assignment, submission);
Expand Down Expand Up @@ -83,7 +90,7 @@ export class BlockPy {
* @param {string} key - the key to look up a value for
* @param {Object} defaultValue - if the key is not found anywhere, use this value
*/
getSetting(key, defaultValue) {
getSetting(key: string, defaultValue: any): any {
if (key in this.initialConfiguration_) {
return this.initialConfiguration_[key];
} else if (this.localSettings_.has(key)) {
Expand All @@ -105,7 +112,7 @@ export class BlockPy {
* * execution: values related to last run (not stored)
* * configuration: constant values related to setup (not stored)
*/
initModel(configuration) {
initModel(configuration: Record<string, any>): void {
// Connect to local storage
this.localSettings_ = new LocalStorageWrapper("localSettings");
this.initialConfiguration_ = configuration;
Expand Down Expand Up @@ -425,24 +432,24 @@ export class BlockPy {
constants.container = $(constants.attachmentPoint).html($(gui));
};

loadAssignment(assignment_id) {
loadAssignment(assignment_id: any): void {
this.components.server.loadAssignment(assignment_id);
}

loadTags(tags) {
loadTags(tags: any[]): void {
// Already a JSON list representing tags
}

loadSampleSubmissions(samples) {
loadSampleSubmissions(samples: any[]): void {
// Already a JSON list representing samples
}

loadNoSubmission(assignment) {
loadNoSubmission(assignment: any): void {
this.model.submission.code(assignment.starting_code);
loadConcatenatedFile(assignment.extra_starting_files, this.model.submission.extraFiles);
}

loadSubmission(submission, assignment) {
loadSubmission(submission: any, assignment: any): boolean {
if (!submission) {
// TODO: Scarier "You are not logged in message"
this.loadNoSubmission(assignment);
Expand All @@ -464,7 +471,7 @@ export class BlockPy {
loadConcatenatedFile(submission.extra_files, this.model.submission.extraFiles);
}

loadAssignmentData_(data) {
loadAssignmentData_(data: any): void {
console.debug(data);
this.resetInterface();
this.components.fileSystem.dismountExtraFiles();
Expand Down
File renamed without changes.
146 changes: 0 additions & 146 deletions src/corgis.js

This file was deleted.

Loading