From c323ada8ac51f2144bf6a40e448b21d3871fb664 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 2 Nov 2024 21:21:44 +0100 Subject: [PATCH 01/10] TS frontend: separate mocha configuration --- frontend/.mocharc.json | 16 ++++++++++++++++ frontend/mocha.env | 1 + frontend/package.json | 15 --------------- 3 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 frontend/.mocharc.json create mode 100644 frontend/mocha.env diff --git a/frontend/.mocharc.json b/frontend/.mocharc.json new file mode 100644 index 000000000..0773558c4 --- /dev/null +++ b/frontend/.mocharc.json @@ -0,0 +1,16 @@ +{ + "diff": true, + "extension": [ + "ts" + ], + "reporter": "spec", + "slow": 75, + "timeout": 200000, + "ui": "bdd", + "require": [ + "mocha.env", + "ts-node/register", + "jsdom-global/register" + ], + "spec": "tests/**/*.spec.ts" +} diff --git a/frontend/mocha.env b/frontend/mocha.env new file mode 100644 index 000000000..40b8c1a1e --- /dev/null +++ b/frontend/mocha.env @@ -0,0 +1 @@ +process.env.TS_NODE_PROJECT = 'tsconfig.json' diff --git a/frontend/package.json b/frontend/package.json index 689600a91..73f42fed4 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -147,20 +147,5 @@ "src/index.ts" ] }, - "mocha": { - "diff": true, - "extension": [ - "ts" - ], - "reporter": "spec", - "slow": 75, - "timeout": 200000, - "ui": "bdd", - "require": [ - "ts-node/register", - "jsdom-global/register" - ], - "spec": "tests/**/*.spec.ts" - }, "packageManager": "yarn@4.4.0" } From d553b158ed7ff3ffaf50591cf642a7c808504b47 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 2 Nov 2024 22:44:26 +0100 Subject: [PATCH 02/10] Widget: use explicit .ts extension in imports --- frontend/src/ts/areas.ts | 4 ++-- frontend/src/ts/download.ts | 2 +- frontend/src/ts/server-types.ts | 2 +- frontend/src/ts/server.ts | 2 +- frontend/src/ts/widget.ts | 16 ++++++++-------- frontend/tests/ts/areas.spec.ts | 6 +++--- frontend/tests/ts/dom-utils.spec.ts | 2 +- frontend/tests/ts/download.spec.ts | 4 ++-- frontend/tests/ts/editor.spec.ts | 4 ++-- frontend/tests/ts/scrolltop.spec.ts | 2 +- frontend/tests/ts/server.spec.ts | 4 ++-- frontend/tests/ts/widget.spec.ts | 12 ++++++------ frontend/tsconfig.json | 1 + 13 files changed, 31 insertions(+), 30 deletions(-) diff --git a/frontend/src/ts/areas.ts b/frontend/src/ts/areas.ts index 66458ddc0..409bc520f 100644 --- a/frontend/src/ts/areas.ts +++ b/frontend/src/ts/areas.ts @@ -1,5 +1,5 @@ -import * as Strings from './strings'; -import {CheckOutput} from './server-types'; +import * as Strings from './strings.ts'; +import {CheckOutput} from './server-types.ts'; /** Class representing an Area */ export class Area { diff --git a/frontend/src/ts/download.ts b/frontend/src/ts/download.ts index a0856a7dd..ef249dba1 100644 --- a/frontend/src/ts/download.ts +++ b/frontend/src/ts/download.ts @@ -1,6 +1,6 @@ import JSZip from 'jszip'; import FileSaver from 'file-saver'; -import {ResourceList} from './resource'; +import {ResourceList} from './resource.ts'; const COMMON_ADC = `pragma Restrictions (No_Specification_of_Aspect => Import); pragma Restrictions (No_Use_Of_Pragma => Import); diff --git a/frontend/src/ts/server-types.ts b/frontend/src/ts/server-types.ts index 0478b7d24..7b1de8fd5 100644 --- a/frontend/src/ts/server-types.ts +++ b/frontend/src/ts/server-types.ts @@ -1,6 +1,6 @@ /* eslint-disable */ -import {ResourceList} from './resource'; +import {ResourceList} from './resource.ts'; // FS - From Server // TS - To Server diff --git a/frontend/src/ts/server.ts b/frontend/src/ts/server.ts index 67d3ddb60..85ad699bc 100644 --- a/frontend/src/ts/server.ts +++ b/frontend/src/ts/server.ts @@ -1,4 +1,4 @@ -import {RunProgram, CheckOutput} from './server-types'; +import {RunProgram, CheckOutput} from './server-types.ts'; /** * Worker class for server REST sequence diff --git a/frontend/src/ts/widget.ts b/frontend/src/ts/widget.ts index 5fb011cdf..2860de3ae 100644 --- a/frontend/src/ts/widget.ts +++ b/frontend/src/ts/widget.ts @@ -1,15 +1,15 @@ import cookies from 'typescript-cookies'; -import {Area, OutputArea, LabContainer} from './areas'; -import {Editor, EditorTheme} from './editor'; +import {Area, OutputArea, LabContainer} from './areas.ts'; +import {Editor, EditorTheme} from './editor.ts'; import {getElemsByClass, getElemById, getElemsByTag} - from './dom-utils'; + from './dom-utils.ts'; import {downloadProject, UnparsedSwitches, - getUnparsedSwitches} from './download'; -import {Resource, ResourceList} from './resource'; -import {ServerWorker} from './server'; -import {RunProgram, CheckOutput} from './server-types'; -import * as Strings from './strings'; + getUnparsedSwitches} from './download.ts'; +import {Resource, ResourceList} from './resource.ts'; +import {ServerWorker} from './server.ts'; +import {RunProgram, CheckOutput} from './server-types.ts'; +import * as Strings from './strings.ts'; interface EditorView { readonly header: HTMLButtonElement; diff --git a/frontend/tests/ts/areas.spec.ts b/frontend/tests/ts/areas.spec.ts index 0938fdd27..8dcd1bbc0 100644 --- a/frontend/tests/ts/areas.spec.ts +++ b/frontend/tests/ts/areas.spec.ts @@ -5,9 +5,9 @@ chai.use(chaiDom); // Import package under test import {Area, OutputArea, LabArea, makeLabArea, LabContainer} - from '../../src/ts/areas'; -import * as Strings from '../../src/ts/strings'; -import {CheckOutput} from '../../src/ts/server-types'; + from '../../src/ts/areas.ts'; +import * as Strings from '../../src/ts/strings.ts'; +import {CheckOutput} from '../../src/ts/server-types.ts'; describe('Area', () => { let parent: HTMLDivElement; diff --git a/frontend/tests/ts/dom-utils.spec.ts b/frontend/tests/ts/dom-utils.spec.ts index c2649f1f8..af7f477c5 100644 --- a/frontend/tests/ts/dom-utils.spec.ts +++ b/frontend/tests/ts/dom-utils.spec.ts @@ -5,7 +5,7 @@ import chaiDom from 'chai-dom'; chai.use(chaiDom); import {getElemById, getElemsByClass, getElemsByTag} - from '../../src/ts/dom-utils'; + from '../../src/ts/dom-utils.ts'; describe('getElemById()', () => { const id = 'test-div'; diff --git a/frontend/tests/ts/download.spec.ts b/frontend/tests/ts/download.spec.ts index 35f96a6e6..3044353a0 100644 --- a/frontend/tests/ts/download.spec.ts +++ b/frontend/tests/ts/download.spec.ts @@ -8,8 +8,8 @@ import { findMains, getMain, getGprContents, -} from '../../src/ts/download'; -import {ResourceList} from '../../src/ts/resource'; +} from '../../src/ts/download.ts'; +import {ResourceList} from '../../src/ts/resource.ts'; describe('Download', () => { describe('#getLanguages()', () => { diff --git a/frontend/tests/ts/editor.spec.ts b/frontend/tests/ts/editor.spec.ts index 55182a6b5..c6a95abde 100644 --- a/frontend/tests/ts/editor.spec.ts +++ b/frontend/tests/ts/editor.spec.ts @@ -6,8 +6,8 @@ chai.use(chaiDom); import ace from 'brace'; -import {Editor, EditorTheme} from '../../src/ts/editor'; -import {Resource} from '../../src/ts/resource'; +import {Editor, EditorTheme} from '../../src/ts/editor.ts'; +import {Resource} from '../../src/ts/resource.ts'; describe('Editor', () => { let inTest: Editor; diff --git a/frontend/tests/ts/scrolltop.spec.ts b/frontend/tests/ts/scrolltop.spec.ts index f57232baf..13db18ce9 100644 --- a/frontend/tests/ts/scrolltop.spec.ts +++ b/frontend/tests/ts/scrolltop.spec.ts @@ -4,7 +4,7 @@ import chaiDom from 'chai-dom'; chai.use(chaiDom); -import {scrollTop} from '../../src/ts/scrolltop'; +import {scrollTop} from '../../src/ts/scrolltop.ts'; /** * Helper function to trigger window event diff --git a/frontend/tests/ts/server.spec.ts b/frontend/tests/ts/server.spec.ts index 25c2a8f7c..b20a2d382 100644 --- a/frontend/tests/ts/server.spec.ts +++ b/frontend/tests/ts/server.spec.ts @@ -5,8 +5,8 @@ chai.use(chaiAsPromised); import {Server, WebSocket} from 'mock-socket'; -import {ServerWorker} from '../../src/ts/server'; -import {CheckOutput, RunProgram} from '../../src/ts/server-types'; +import {ServerWorker} from '../../src/ts/server.ts'; +import {CheckOutput, RunProgram} from '../../src/ts/server-types.ts'; global.WebSocket = WebSocket; diff --git a/frontend/tests/ts/widget.spec.ts b/frontend/tests/ts/widget.spec.ts index 371057391..410284219 100644 --- a/frontend/tests/ts/widget.spec.ts +++ b/frontend/tests/ts/widget.spec.ts @@ -11,14 +11,14 @@ import {resolve} from 'path'; import ace from 'brace'; -import {OutputArea} from '../../src/ts/areas'; -import * as Strings from '../../src/ts/strings'; +import {OutputArea} from '../../src/ts/areas.ts'; +import * as Strings from '../../src/ts/strings.ts'; -import {widgetFactory} from '../../src/ts/widget'; -import {ServerWorker} from '../../src/ts/server'; -import {CheckOutput, RunProgram} from '../../src/ts/server-types'; +import {widgetFactory} from '../../src/ts/widget.ts'; +import {ServerWorker} from '../../src/ts/server.ts'; +import {CheckOutput, RunProgram} from '../../src/ts/server-types.ts'; import {getElemsByTag, getElemById, getElemsByClass} - from '../../src/ts/dom-utils'; + from '../../src/ts/dom-utils.ts'; global.WebSocket = WebSocket; diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index ef292ae51..b4cdf0a7a 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "allowSyntheticDefaultImports": true, + "allowImportingTsExtensions": true, "sourceMap": true, "allowJs": true, "target": "es2022", From 211c053ea6ae40f7b5055f7810b282a8ff8fd9ab Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 2 Nov 2024 22:45:11 +0100 Subject: [PATCH 03/10] Widget: use const object for cookies --- frontend/src/ts/widget.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/ts/widget.ts b/frontend/src/ts/widget.ts index 2860de3ae..569d67821 100644 --- a/frontend/src/ts/widget.ts +++ b/frontend/src/ts/widget.ts @@ -1,4 +1,4 @@ -import cookies from 'typescript-cookies'; +import {Cookies} from 'typescript-cookies' import {Area, OutputArea, LabContainer} from './areas.ts'; import {Editor, EditorTheme} from './editor.ts'; @@ -18,6 +18,12 @@ interface EditorView { type EditorMap = Map; +const cookies = new Cookies({ + path: '/', + secure: true, + samesite: 'none', +}) + /** * Defines the widget behavior * @class Widget From 8e13d09722c439d0c019d196aca9c3450eb28017 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 2 Nov 2024 23:04:39 +0100 Subject: [PATCH 04/10] Widget: fixes for Chai (ESM) --- frontend/tests/ts/areas.spec.ts | 5 +++-- frontend/tests/ts/dom-utils.spec.ts | 5 ++--- frontend/tests/ts/download.spec.ts | 6 ++++-- frontend/tests/ts/editor.spec.ts | 4 ++-- frontend/tests/ts/scrolltop.spec.ts | 4 ++-- frontend/tests/ts/server.spec.ts | 7 ++++--- frontend/tests/ts/widget.spec.ts | 7 ++++--- 7 files changed, 21 insertions(+), 17 deletions(-) diff --git a/frontend/tests/ts/areas.spec.ts b/frontend/tests/ts/areas.spec.ts index 8dcd1bbc0..84f59a247 100644 --- a/frontend/tests/ts/areas.spec.ts +++ b/frontend/tests/ts/areas.spec.ts @@ -1,7 +1,8 @@ // Import testing libs -import chai, {expect} from 'chai'; +import { expect, use } from 'chai'; import chaiDom from 'chai-dom'; -chai.use(chaiDom); + +const chai = use(chaiDom); // Import package under test import {Area, OutputArea, LabArea, makeLabArea, LabContainer} diff --git a/frontend/tests/ts/dom-utils.spec.ts b/frontend/tests/ts/dom-utils.spec.ts index af7f477c5..ead4604a5 100644 --- a/frontend/tests/ts/dom-utils.spec.ts +++ b/frontend/tests/ts/dom-utils.spec.ts @@ -1,8 +1,7 @@ // Import testing libs -import chai, {expect} from 'chai'; +import { expect, use } from 'chai'; import chaiDom from 'chai-dom'; - -chai.use(chaiDom); +const chai = use(chaiDom); import {getElemById, getElemsByClass, getElemsByTag} from '../../src/ts/dom-utils.ts'; diff --git a/frontend/tests/ts/download.spec.ts b/frontend/tests/ts/download.spec.ts index 3044353a0..88993ae6a 100644 --- a/frontend/tests/ts/download.spec.ts +++ b/frontend/tests/ts/download.spec.ts @@ -1,6 +1,8 @@ -import chai, {expect} from 'chai'; +import { expect, use } from 'chai'; +import chaiDom from 'chai-dom'; import chaiAsPromised from 'chai-as-promised'; -chai.use(chaiAsPromised); + +const chai = use(chaiDom); import { getLanguages, diff --git a/frontend/tests/ts/editor.spec.ts b/frontend/tests/ts/editor.spec.ts index c6a95abde..1345e8996 100644 --- a/frontend/tests/ts/editor.spec.ts +++ b/frontend/tests/ts/editor.spec.ts @@ -1,8 +1,8 @@ // Import testing libs -import chai, {expect} from 'chai'; +import { expect, use } from 'chai'; import chaiDom from 'chai-dom'; -chai.use(chaiDom); +const chai = use(chaiDom); import ace from 'brace'; diff --git a/frontend/tests/ts/scrolltop.spec.ts b/frontend/tests/ts/scrolltop.spec.ts index 13db18ce9..e533229b3 100644 --- a/frontend/tests/ts/scrolltop.spec.ts +++ b/frontend/tests/ts/scrolltop.spec.ts @@ -1,8 +1,8 @@ // Import testing libs -import chai, {expect} from 'chai'; +import { expect, use } from 'chai'; import chaiDom from 'chai-dom'; -chai.use(chaiDom); +const chai = use(chaiDom); import {scrollTop} from '../../src/ts/scrolltop.ts'; diff --git a/frontend/tests/ts/server.spec.ts b/frontend/tests/ts/server.spec.ts index b20a2d382..cfe2bb44e 100644 --- a/frontend/tests/ts/server.spec.ts +++ b/frontend/tests/ts/server.spec.ts @@ -1,7 +1,8 @@ // Import testing libs -import chai, {expect} from 'chai'; -import chaiAsPromised from 'chai-as-promised'; -chai.use(chaiAsPromised); +import { expect, use } from 'chai'; +import chaiDom from 'chai-dom'; + +const chai = use(chaiDom); import {Server, WebSocket} from 'mock-socket'; diff --git a/frontend/tests/ts/widget.spec.ts b/frontend/tests/ts/widget.spec.ts index 410284219..16472308e 100644 --- a/frontend/tests/ts/widget.spec.ts +++ b/frontend/tests/ts/widget.spec.ts @@ -1,10 +1,11 @@ // Import testing libs -import chai, {expect} from 'chai'; +import { expect, use } from 'chai'; import chaiAsPromised from 'chai-as-promised'; import chaiDom from 'chai-dom'; import {Client, Server, WebSocket} from 'mock-socket'; -chai.use(chaiDom); -chai.use(chaiAsPromised); + +// const chai = use(chaiDom); +const chai = use(chaiAsPromised); import {readFileSync} from 'fs'; import {resolve} from 'path'; From 5ba773db22485d08d99e2ee961fe8e21bc5f2b42 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 2 Nov 2024 23:05:13 +0100 Subject: [PATCH 05/10] Widget: fix for __dirname in module --- frontend/tests/ts/widget.spec.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/tests/ts/widget.spec.ts b/frontend/tests/ts/widget.spec.ts index 16472308e..4f6d25c7b 100644 --- a/frontend/tests/ts/widget.spec.ts +++ b/frontend/tests/ts/widget.spec.ts @@ -23,6 +23,12 @@ import {getElemsByTag, getElemById, getElemsByClass} global.WebSocket = WebSocket; +import { fileURLToPath } from 'url'; +import { dirname } from 'path'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + /** * Helper function to fill DOM from a file * From f1c73857ddd7fdcb576b86f97b6785635ca7869f Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 2 Nov 2024 23:06:19 +0100 Subject: [PATCH 06/10] Widget: update to Node.js ESM (ECMAScript Modules) --- frontend/.mocharc.json | 5 +++++ frontend/package.json | 1 + frontend/tsconfig.json | 8 ++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/.mocharc.json b/frontend/.mocharc.json index 0773558c4..3950d9cae 100644 --- a/frontend/.mocharc.json +++ b/frontend/.mocharc.json @@ -12,5 +12,10 @@ "ts-node/register", "jsdom-global/register" ], + "node-option": [ + "disable-warning=ExperimentalWarning", + "experimental-specifier-resolution=node", + "loader=ts-node/esm" + ], "spec": "tests/**/*.spec.ts" } diff --git a/frontend/package.json b/frontend/package.json index 73f42fed4..7782ad525 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,7 @@ { "name": "learn", "version": "1.0.0", + "type": "module", "description": "", "private": true, "dependencies": { diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index b4cdf0a7a..7bfe8ee2a 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -4,13 +4,13 @@ "allowImportingTsExtensions": true, "sourceMap": true, "allowJs": true, - "target": "es2022", "esModuleInterop": true, "downlevelIteration": true, "strict": true, - "lib": ["es2022"], - "module": "CommonJS", - "moduleResolution": "node" + "lib": ["es2023"], + "module": "node16", + "target": "es2022", + "moduleResolution": "node16" }, "include": [ "./src/**/*" From 9e5393421d9565e12e631905a9db680134f92dde Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sun, 3 Nov 2024 00:37:39 +0100 Subject: [PATCH 07/10] Frontend: upgrade to Chai 5.x - Upgrade: Chai 4.5 => 5.1 - Upgrade: chai-as-promised 7.1 => 8.0 Also: - Upgrade: @types/chai, @types/chai-as-promised - Update: @babel/cli --- frontend/package.json | 10 +-- frontend/yarn.lock | 151 +++++++++++++++++------------------------- 2 files changed, 67 insertions(+), 94 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 7782ad525..703750147 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -17,13 +17,13 @@ "whatwg-fetch": "^3.6.20" }, "devDependencies": { - "@babel/cli": "^7.24.8", + "@babel/cli": "^7.25.9", "@babel/core": "^7.25.2", "@babel/preset-env": "^7.25.4", "@istanbuljs/nyc-config-typescript": "^1.0.2", "@types/ace": "0.0.52", - "@types/chai": "^4.3.17", - "@types/chai-as-promised": "^7.1.8", + "@types/chai": "^5.0.1", + "@types/chai-as-promised": "^8.0.1", "@types/chai-dom": "^1.11.3", "@types/file-saver": "^2.0.7", "@types/js-cookie": "^3.0.6", @@ -36,8 +36,8 @@ "amd-loader": "^0.0.8", "autoprefixer": "^10.4.20", "babel-loader": "^9.1.3", - "chai": "^4.5.0", - "chai-as-promised": "^7.1.2", + "chai": "^5.1.2", + "chai-as-promised": "^8.0.0", "chai-dom": "^1.12.0", "chunks-2-json-webpack-plugin": "^1.0.4", "clean-webpack-plugin": "^4.0.0", diff --git a/frontend/yarn.lock b/frontend/yarn.lock index cb9b7930c..44c09848f 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -22,13 +22,13 @@ __metadata: languageName: node linkType: hard -"@babel/cli@npm:^7.24.8": - version: 7.24.8 - resolution: "@babel/cli@npm:7.24.8" +"@babel/cli@npm:^7.25.9": + version: 7.25.9 + resolution: "@babel/cli@npm:7.25.9" dependencies: "@jridgewell/trace-mapping": "npm:^0.3.25" "@nicolo-ribaudo/chokidar-2": "npm:2.1.8-no-fsevents.3" - chokidar: "npm:^3.4.0" + chokidar: "npm:^3.6.0" commander: "npm:^6.2.0" convert-source-map: "npm:^2.0.0" fs-readdir-recursive: "npm:^1.1.0" @@ -45,7 +45,7 @@ __metadata: bin: babel: ./bin/babel.js babel-external-helpers: ./bin/babel-external-helpers.js - checksum: 10c0/b7f464ccb00db60aed63d71e980df823900d20c740bc2d9eb36c3abd4b3e2402cc438818382344085ef6603aeea2e6ee19af8f0ecb934966eccf077b87af7c7c + checksum: 10c0/2e8228c3715e220fa902888c643ce1a89c4ee90be3d9f7a31218d5bb2500456e0cef12cb90fd5877ab3e5a4498df8f27670425d346422a3eb52052fd3184d520 languageName: node linkType: hard @@ -2659,12 +2659,12 @@ __metadata: languageName: node linkType: hard -"@types/chai-as-promised@npm:^7.1.8": - version: 7.1.8 - resolution: "@types/chai-as-promised@npm:7.1.8" +"@types/chai-as-promised@npm:^8.0.1": + version: 8.0.1 + resolution: "@types/chai-as-promised@npm:8.0.1" dependencies: "@types/chai": "npm:*" - checksum: 10c0/c0a19cffe8d3f406b2cb9ba17f5f0efe318b14f27896d807b3199cc2231c16a4b5b6c464fdf2a939214de481de58cffd46c240539d3d4ece18659277d71ccc23 + checksum: 10c0/706edb801e8327a09a78f00629f3ae92ec567465338c0114f1586f84daf26911ca05979ec8d5b62f857e7b5a9163c7aaf2f4415903e0ff57b3bfc47785088dd5 languageName: node linkType: hard @@ -2684,10 +2684,12 @@ __metadata: languageName: node linkType: hard -"@types/chai@npm:^4.3.17": - version: 4.3.17 - resolution: "@types/chai@npm:4.3.17" - checksum: 10c0/322a74489cdfde9c301b593d086c539584924c4c92689a858e0930708895a5ab229c31c64ac26b137615ef3ffbff1866851c280c093e07b3d3de05983d3793e0 +"@types/chai@npm:^5.0.1": + version: 5.0.1 + resolution: "@types/chai@npm:5.0.1" + dependencies: + "@types/deep-eql": "npm:*" + checksum: 10c0/82cb718101d37698e35fb03e2a983a442303065bfcb9b9e8b50b49fdad2fa5759c14dabfa5cb4a4bfa5c6aff1f05377d6ab4310bae0cfbf7d3138f94c969f441 languageName: node linkType: hard @@ -2710,6 +2712,13 @@ __metadata: languageName: node linkType: hard +"@types/deep-eql@npm:*": + version: 4.0.2 + resolution: "@types/deep-eql@npm:4.0.2" + checksum: 10c0/bf3f811843117900d7084b9d0c852da9a044d12eb40e6de73b552598a6843c21291a8a381b0532644574beecd5e3491c5ff3a0365ab86b15d59862c025384844 + languageName: node + linkType: hard + "@types/eslint@npm:^8.56.10": version: 8.56.10 resolution: "@types/eslint@npm:8.56.10" @@ -3878,10 +3887,10 @@ __metadata: languageName: node linkType: hard -"assertion-error@npm:^1.1.0": - version: 1.1.0 - resolution: "assertion-error@npm:1.1.0" - checksum: 10c0/25456b2aa333250f01143968e02e4884a34588a8538fbbf65c91a637f1dbfb8069249133cd2f4e530f10f624d206a664e7df30207830b659e9f5298b00a4099b +"assertion-error@npm:^2.0.1": + version: 2.0.1 + resolution: "assertion-error@npm:2.0.1" + checksum: 10c0/bbbcb117ac6480138f8c93cf7f535614282dea9dc828f540cdece85e3c665e8f78958b96afac52f29ff883c72638e6a87d469ecc9fe5bc902df03ed24a55dba8 languageName: node linkType: hard @@ -4535,14 +4544,14 @@ __metadata: languageName: node linkType: hard -"chai-as-promised@npm:^7.1.2": - version: 7.1.2 - resolution: "chai-as-promised@npm:7.1.2" +"chai-as-promised@npm:^8.0.0": + version: 8.0.0 + resolution: "chai-as-promised@npm:8.0.0" dependencies: - check-error: "npm:^1.0.2" + check-error: "npm:^2.0.0" peerDependencies: chai: ">= 2.1.2 < 6" - checksum: 10c0/ee20ed75296d8cbf828b2f3c9ad64627cee67b1a38b8e906ca59fe788fb6965ddb10f702ae66645ed88f15a905ade4f2d9f8540029e92e2d59b229c9f912273f + checksum: 10c0/60200ea9cdac24394a97e768edd7d0cd8962097a02e3e6158932c13f7e9d89489d20e6a2e540e80dbe845c71362e7a7a311672fd16a2eab4214a6952fd0db804 languageName: node linkType: hard @@ -4555,18 +4564,16 @@ __metadata: languageName: node linkType: hard -"chai@npm:^4.5.0": - version: 4.5.0 - resolution: "chai@npm:4.5.0" +"chai@npm:^5.1.2": + version: 5.1.2 + resolution: "chai@npm:5.1.2" dependencies: - assertion-error: "npm:^1.1.0" - check-error: "npm:^1.0.3" - deep-eql: "npm:^4.1.3" - get-func-name: "npm:^2.0.2" - loupe: "npm:^2.3.6" - pathval: "npm:^1.1.1" - type-detect: "npm:^4.1.0" - checksum: 10c0/b8cb596bd1aece1aec659e41a6e479290c7d9bee5b3ad63d2898ad230064e5b47889a3bc367b20100a0853b62e026e2dc514acf25a3c9385f936aa3614d4ab4d + assertion-error: "npm:^2.0.1" + check-error: "npm:^2.1.1" + deep-eql: "npm:^5.0.1" + loupe: "npm:^3.1.0" + pathval: "npm:^2.0.0" + checksum: 10c0/6c04ff8495b6e535df9c1b062b6b094828454e9a3c9493393e55b2f4dbff7aa2a29a4645133cad160fb00a16196c4dc03dc9bb37e1f4ba9df3b5f50d7533a736 languageName: node linkType: hard @@ -4621,12 +4628,10 @@ __metadata: languageName: node linkType: hard -"check-error@npm:^1.0.2, check-error@npm:^1.0.3": - version: 1.0.3 - resolution: "check-error@npm:1.0.3" - dependencies: - get-func-name: "npm:^2.0.2" - checksum: 10c0/94aa37a7315c0e8a83d0112b5bfb5a8624f7f0f81057c73e4707729cdd8077166c6aefb3d8e2b92c63ee130d4a2ff94bad46d547e12f3238cc1d78342a973841 +"check-error@npm:^2.0.0, check-error@npm:^2.1.1": + version: 2.1.1 + resolution: "check-error@npm:2.1.1" + checksum: 10c0/979f13eccab306cf1785fa10941a590b4e7ea9916ea2a4f8c87f0316fc3eab07eabefb6e587424ef0f88cbcd3805791f172ea739863ca3d7ce2afc54641c7f0e languageName: node linkType: hard @@ -4637,7 +4642,7 @@ __metadata: languageName: node linkType: hard -"chokidar@npm:>=3.0.0 <4.0.0, chokidar@npm:^3.4.0": +"chokidar@npm:>=3.0.0 <4.0.0": version: 3.5.2 resolution: "chokidar@npm:3.5.2" dependencies: @@ -5491,12 +5496,10 @@ __metadata: languageName: node linkType: hard -"deep-eql@npm:^4.1.3": - version: 4.1.3 - resolution: "deep-eql@npm:4.1.3" - dependencies: - type-detect: "npm:^4.0.0" - checksum: 10c0/ff34e8605d8253e1bf9fe48056e02c6f347b81d9b5df1c6650a1b0f6f847b4a86453b16dc226b34f853ef14b626e85d04e081b022e20b00cd7d54f079ce9bbdd +"deep-eql@npm:^5.0.1": + version: 5.0.2 + resolution: "deep-eql@npm:5.0.2" + checksum: 10c0/7102cf3b7bb719c6b9c0db2e19bf0aa9318d141581befe8c7ce8ccd39af9eaa4346e5e05adef7f9bd7015da0f13a3a25dcfe306ef79dc8668aedbecb658dd247 languageName: node linkType: hard @@ -7138,20 +7141,6 @@ __metadata: languageName: node linkType: hard -"get-func-name@npm:^2.0.0": - version: 2.0.0 - resolution: "get-func-name@npm:2.0.0" - checksum: 10c0/ed8791f7ba92cfd747259dff7ec8b6cc42734cebd031fb58c99a6e71d24d3532d84b46ad7806cafad6ad21784dd04ae1808a002d2b21001425e21f5f394c34e7 - languageName: node - linkType: hard - -"get-func-name@npm:^2.0.2": - version: 2.0.2 - resolution: "get-func-name@npm:2.0.2" - checksum: 10c0/89830fd07623fa73429a711b9daecdb304386d237c71268007f788f113505ef1d4cc2d0b9680e072c5082490aec9df5d7758bf5ac6f1c37062855e8e3dc0b9df - languageName: node - linkType: hard - "get-intrinsic@npm:^1.1.3, get-intrinsic@npm:^1.2.4": version: 1.2.4 resolution: "get-intrinsic@npm:1.2.4" @@ -8966,13 +8955,13 @@ __metadata: version: 0.0.0-use.local resolution: "learn@workspace:." dependencies: - "@babel/cli": "npm:^7.24.8" + "@babel/cli": "npm:^7.25.9" "@babel/core": "npm:^7.25.2" "@babel/preset-env": "npm:^7.25.4" "@istanbuljs/nyc-config-typescript": "npm:^1.0.2" "@types/ace": "npm:0.0.52" - "@types/chai": "npm:^4.3.17" - "@types/chai-as-promised": "npm:^7.1.8" + "@types/chai": "npm:^5.0.1" + "@types/chai-as-promised": "npm:^8.0.1" "@types/chai-dom": "npm:^1.11.3" "@types/file-saver": "npm:^2.0.7" "@types/js-cookie": "npm:^3.0.6" @@ -8987,8 +8976,8 @@ __metadata: autoprefixer: "npm:^10.4.20" babel-loader: "npm:^9.1.3" brace: "npm:^0.11.1" - chai: "npm:^4.5.0" - chai-as-promised: "npm:^7.1.2" + chai: "npm:^5.1.2" + chai-as-promised: "npm:^8.0.0" chai-dom: "npm:^1.12.0" chunks-2-json-webpack-plugin: "npm:^1.0.4" clean-webpack-plugin: "npm:^4.0.0" @@ -9247,12 +9236,10 @@ __metadata: languageName: node linkType: hard -"loupe@npm:^2.3.6": - version: 2.3.6 - resolution: "loupe@npm:2.3.6" - dependencies: - get-func-name: "npm:^2.0.0" - checksum: 10c0/a974841ce94ef2a35aac7144e7f9e789e3887f82286cd9ffe7ff00f2ac9d117481989948657465e2b0b102f23136d89ae0a18fd4a32d9015012cd64464453289 +"loupe@npm:^3.1.0": + version: 3.1.2 + resolution: "loupe@npm:3.1.2" + checksum: 10c0/b13c02e3ddd6a9d5f8bf84133b3242de556512d824dddeea71cce2dbd6579c8f4d672381c4e742d45cf4423d0701765b4a6e5fbc24701def16bc2b40f8daa96a languageName: node linkType: hard @@ -11017,10 +11004,10 @@ __metadata: languageName: node linkType: hard -"pathval@npm:^1.1.1": - version: 1.1.1 - resolution: "pathval@npm:1.1.1" - checksum: 10c0/f63e1bc1b33593cdf094ed6ff5c49c1c0dc5dc20a646ca9725cc7fe7cd9995002d51d5685b9b2ec6814342935748b711bafa840f84c0bb04e38ff40a335c94dc +"pathval@npm:^2.0.0": + version: 2.0.0 + resolution: "pathval@npm:2.0.0" + checksum: 10c0/602e4ee347fba8a599115af2ccd8179836a63c925c23e04bd056d0674a64b39e3a081b643cc7bc0b84390517df2d800a46fcc5598d42c155fe4977095c2f77c5 languageName: node linkType: hard @@ -13885,20 +13872,6 @@ __metadata: languageName: node linkType: hard -"type-detect@npm:^4.0.0": - version: 4.0.8 - resolution: "type-detect@npm:4.0.8" - checksum: 10c0/8fb9a51d3f365a7de84ab7f73b653534b61b622aa6800aecdb0f1095a4a646d3f5eb295322127b6573db7982afcd40ab492d038cf825a42093a58b1e1353e0bd - languageName: node - linkType: hard - -"type-detect@npm:^4.1.0": - version: 4.1.0 - resolution: "type-detect@npm:4.1.0" - checksum: 10c0/df8157ca3f5d311edc22885abc134e18ff8ffbc93d6a9848af5b682730ca6a5a44499259750197250479c5331a8a75b5537529df5ec410622041650a7f293e2a - languageName: node - linkType: hard - "type-fest@npm:^0.18.0": version: 0.18.1 resolution: "type-fest@npm:0.18.1" From 92b201652c087e1f7449a8eb3da806b5a2a611a4 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sun, 3 Nov 2024 01:06:43 +0100 Subject: [PATCH 08/10] TS frontend: rename files using '.csj' file extension - Indicating that these files are still CommonJS modules. - Fixing issue with ESM system. --- frontend/package.json | 6 +++--- frontend/{webpack.common.js => webpack.common.cjs} | 0 frontend/{webpack.dev.js => webpack.dev.cjs} | 2 +- frontend/{webpack.prod.js => webpack.prod.cjs} | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename frontend/{webpack.common.js => webpack.common.cjs} (100%) rename frontend/{webpack.dev.js => webpack.dev.cjs} (96%) rename frontend/{webpack.prod.js => webpack.prod.cjs} (94%) diff --git a/frontend/package.json b/frontend/package.json index 703750147..cf371a35e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -90,11 +90,11 @@ "whatwg-url": "^14" }, "scripts": { - "dev": "webpack serve --open --config webpack.dev.js", + "dev": "webpack serve --open --config webpack.dev.cjs", "tsc": "tsc --noEmit", "eslint": "eslint --ext .ts src/ tests/", - "sandbox": "webpack --env sandbox --config webpack.prod.js", - "production": "webpack --config webpack.prod.js", + "sandbox": "webpack --env sandbox --config webpack.prod.cjs", + "production": "webpack --config webpack.prod.cjs", "test": "TS_NODE_COMPILER_OPTIONS='{\"strict\":false}' mocha --exit", "cover": "nyc yarn run test", "doc": "typedoc src --out docs" diff --git a/frontend/webpack.common.js b/frontend/webpack.common.cjs similarity index 100% rename from frontend/webpack.common.js rename to frontend/webpack.common.cjs diff --git a/frontend/webpack.dev.js b/frontend/webpack.dev.cjs similarity index 96% rename from frontend/webpack.dev.js rename to frontend/webpack.dev.cjs index d22acae91..bd8b9727e 100644 --- a/frontend/webpack.dev.js +++ b/frontend/webpack.dev.cjs @@ -3,7 +3,7 @@ const { merge } = require('webpack-merge'); const exec = require('child_process').exec; const WatchPlugin = require('webpack-watch-files-plugin').default; const ShellPlugin = require('webpack-shell-plugin-next'); -const common = require('./webpack.common.js'); +const common = require('./webpack.common.cjs'); module.exports = function(env) { const common_config = common(env); diff --git a/frontend/webpack.prod.js b/frontend/webpack.prod.cjs similarity index 94% rename from frontend/webpack.prod.js rename to frontend/webpack.prod.cjs index 66f26ee6a..53223e4d0 100644 --- a/frontend/webpack.prod.js +++ b/frontend/webpack.prod.cjs @@ -1,7 +1,7 @@ const { merge } = require('webpack-merge'); const CssMinimizerPlugin = require("css-minimizer-webpack-plugin"); const TerserPlugin = require('terser-webpack-plugin'); -const common = require('./webpack.common.js'); +const common = require('./webpack.common.cjs'); const terser_config = function(env) { const staging = (env && env.staging); From cd4c57e173902374079e84b2f1fe89ed479a43ba Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sun, 3 Nov 2024 01:55:11 +0100 Subject: [PATCH 09/10] Revert "Widget: use explicit .ts extension in imports" This reverts commit d553b158ed7ff3ffaf50591cf642a7c808504b47. --- frontend/src/ts/areas.ts | 4 ++-- frontend/src/ts/download.ts | 2 +- frontend/src/ts/server-types.ts | 2 +- frontend/src/ts/server.ts | 2 +- frontend/src/ts/widget.ts | 16 ++++++++-------- frontend/tests/ts/areas.spec.ts | 6 +++--- frontend/tests/ts/dom-utils.spec.ts | 2 +- frontend/tests/ts/download.spec.ts | 4 ++-- frontend/tests/ts/editor.spec.ts | 4 ++-- frontend/tests/ts/scrolltop.spec.ts | 2 +- frontend/tests/ts/server.spec.ts | 4 ++-- frontend/tests/ts/widget.spec.ts | 12 ++++++------ frontend/tsconfig.json | 1 - 13 files changed, 30 insertions(+), 31 deletions(-) diff --git a/frontend/src/ts/areas.ts b/frontend/src/ts/areas.ts index 409bc520f..66458ddc0 100644 --- a/frontend/src/ts/areas.ts +++ b/frontend/src/ts/areas.ts @@ -1,5 +1,5 @@ -import * as Strings from './strings.ts'; -import {CheckOutput} from './server-types.ts'; +import * as Strings from './strings'; +import {CheckOutput} from './server-types'; /** Class representing an Area */ export class Area { diff --git a/frontend/src/ts/download.ts b/frontend/src/ts/download.ts index ef249dba1..a0856a7dd 100644 --- a/frontend/src/ts/download.ts +++ b/frontend/src/ts/download.ts @@ -1,6 +1,6 @@ import JSZip from 'jszip'; import FileSaver from 'file-saver'; -import {ResourceList} from './resource.ts'; +import {ResourceList} from './resource'; const COMMON_ADC = `pragma Restrictions (No_Specification_of_Aspect => Import); pragma Restrictions (No_Use_Of_Pragma => Import); diff --git a/frontend/src/ts/server-types.ts b/frontend/src/ts/server-types.ts index 7b1de8fd5..0478b7d24 100644 --- a/frontend/src/ts/server-types.ts +++ b/frontend/src/ts/server-types.ts @@ -1,6 +1,6 @@ /* eslint-disable */ -import {ResourceList} from './resource.ts'; +import {ResourceList} from './resource'; // FS - From Server // TS - To Server diff --git a/frontend/src/ts/server.ts b/frontend/src/ts/server.ts index 85ad699bc..67d3ddb60 100644 --- a/frontend/src/ts/server.ts +++ b/frontend/src/ts/server.ts @@ -1,4 +1,4 @@ -import {RunProgram, CheckOutput} from './server-types.ts'; +import {RunProgram, CheckOutput} from './server-types'; /** * Worker class for server REST sequence diff --git a/frontend/src/ts/widget.ts b/frontend/src/ts/widget.ts index 569d67821..ea536cd47 100644 --- a/frontend/src/ts/widget.ts +++ b/frontend/src/ts/widget.ts @@ -1,15 +1,15 @@ import {Cookies} from 'typescript-cookies' -import {Area, OutputArea, LabContainer} from './areas.ts'; -import {Editor, EditorTheme} from './editor.ts'; +import {Area, OutputArea, LabContainer} from './areas'; +import {Editor, EditorTheme} from './editor'; import {getElemsByClass, getElemById, getElemsByTag} - from './dom-utils.ts'; + from './dom-utils'; import {downloadProject, UnparsedSwitches, - getUnparsedSwitches} from './download.ts'; -import {Resource, ResourceList} from './resource.ts'; -import {ServerWorker} from './server.ts'; -import {RunProgram, CheckOutput} from './server-types.ts'; -import * as Strings from './strings.ts'; + getUnparsedSwitches} from './download'; +import {Resource, ResourceList} from './resource'; +import {ServerWorker} from './server'; +import {RunProgram, CheckOutput} from './server-types'; +import * as Strings from './strings'; interface EditorView { readonly header: HTMLButtonElement; diff --git a/frontend/tests/ts/areas.spec.ts b/frontend/tests/ts/areas.spec.ts index 84f59a247..982a01a25 100644 --- a/frontend/tests/ts/areas.spec.ts +++ b/frontend/tests/ts/areas.spec.ts @@ -6,9 +6,9 @@ const chai = use(chaiDom); // Import package under test import {Area, OutputArea, LabArea, makeLabArea, LabContainer} - from '../../src/ts/areas.ts'; -import * as Strings from '../../src/ts/strings.ts'; -import {CheckOutput} from '../../src/ts/server-types.ts'; + from '../../src/ts/areas'; +import * as Strings from '../../src/ts/strings'; +import {CheckOutput} from '../../src/ts/server-types'; describe('Area', () => { let parent: HTMLDivElement; diff --git a/frontend/tests/ts/dom-utils.spec.ts b/frontend/tests/ts/dom-utils.spec.ts index ead4604a5..ef806e08f 100644 --- a/frontend/tests/ts/dom-utils.spec.ts +++ b/frontend/tests/ts/dom-utils.spec.ts @@ -4,7 +4,7 @@ import chaiDom from 'chai-dom'; const chai = use(chaiDom); import {getElemById, getElemsByClass, getElemsByTag} - from '../../src/ts/dom-utils.ts'; + from '../../src/ts/dom-utils'; describe('getElemById()', () => { const id = 'test-div'; diff --git a/frontend/tests/ts/download.spec.ts b/frontend/tests/ts/download.spec.ts index 88993ae6a..1e586851c 100644 --- a/frontend/tests/ts/download.spec.ts +++ b/frontend/tests/ts/download.spec.ts @@ -10,8 +10,8 @@ import { findMains, getMain, getGprContents, -} from '../../src/ts/download.ts'; -import {ResourceList} from '../../src/ts/resource.ts'; +} from '../../src/ts/download'; +import {ResourceList} from '../../src/ts/resource'; describe('Download', () => { describe('#getLanguages()', () => { diff --git a/frontend/tests/ts/editor.spec.ts b/frontend/tests/ts/editor.spec.ts index 1345e8996..fa83796d8 100644 --- a/frontend/tests/ts/editor.spec.ts +++ b/frontend/tests/ts/editor.spec.ts @@ -6,8 +6,8 @@ const chai = use(chaiDom); import ace from 'brace'; -import {Editor, EditorTheme} from '../../src/ts/editor.ts'; -import {Resource} from '../../src/ts/resource.ts'; +import {Editor, EditorTheme} from '../../src/ts/editor'; +import {Resource} from '../../src/ts/resource'; describe('Editor', () => { let inTest: Editor; diff --git a/frontend/tests/ts/scrolltop.spec.ts b/frontend/tests/ts/scrolltop.spec.ts index e533229b3..8ea0a5beb 100644 --- a/frontend/tests/ts/scrolltop.spec.ts +++ b/frontend/tests/ts/scrolltop.spec.ts @@ -4,7 +4,7 @@ import chaiDom from 'chai-dom'; const chai = use(chaiDom); -import {scrollTop} from '../../src/ts/scrolltop.ts'; +import {scrollTop} from '../../src/ts/scrolltop'; /** * Helper function to trigger window event diff --git a/frontend/tests/ts/server.spec.ts b/frontend/tests/ts/server.spec.ts index cfe2bb44e..08c6c03e6 100644 --- a/frontend/tests/ts/server.spec.ts +++ b/frontend/tests/ts/server.spec.ts @@ -6,8 +6,8 @@ const chai = use(chaiDom); import {Server, WebSocket} from 'mock-socket'; -import {ServerWorker} from '../../src/ts/server.ts'; -import {CheckOutput, RunProgram} from '../../src/ts/server-types.ts'; +import {ServerWorker} from '../../src/ts/server'; +import {CheckOutput, RunProgram} from '../../src/ts/server-types'; global.WebSocket = WebSocket; diff --git a/frontend/tests/ts/widget.spec.ts b/frontend/tests/ts/widget.spec.ts index 4f6d25c7b..f9d519d49 100644 --- a/frontend/tests/ts/widget.spec.ts +++ b/frontend/tests/ts/widget.spec.ts @@ -12,14 +12,14 @@ import {resolve} from 'path'; import ace from 'brace'; -import {OutputArea} from '../../src/ts/areas.ts'; -import * as Strings from '../../src/ts/strings.ts'; +import {OutputArea} from '../../src/ts/areas'; +import * as Strings from '../../src/ts/strings'; -import {widgetFactory} from '../../src/ts/widget.ts'; -import {ServerWorker} from '../../src/ts/server.ts'; -import {CheckOutput, RunProgram} from '../../src/ts/server-types.ts'; +import {widgetFactory} from '../../src/ts/widget'; +import {ServerWorker} from '../../src/ts/server'; +import {CheckOutput, RunProgram} from '../../src/ts/server-types'; import {getElemsByTag, getElemById, getElemsByClass} - from '../../src/ts/dom-utils.ts'; + from '../../src/ts/dom-utils'; global.WebSocket = WebSocket; diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 7bfe8ee2a..a19febc40 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -1,7 +1,6 @@ { "compilerOptions": { "allowSyntheticDefaultImports": true, - "allowImportingTsExtensions": true, "sourceMap": true, "allowJs": true, "esModuleInterop": true, From 65f414c095bd6d9f91253feb31ed34c2d946229e Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sun, 3 Nov 2024 02:12:39 +0100 Subject: [PATCH 10/10] TS frontend: correcting config for webpack build --- frontend/tsconfig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index a19febc40..bcc253462 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -7,9 +7,9 @@ "downlevelIteration": true, "strict": true, "lib": ["es2023"], - "module": "node16", + "module": "es2020", "target": "es2022", - "moduleResolution": "node16" + "moduleResolution": "bundler" }, "include": [ "./src/**/*"