From 84cd8a549b3a1c9b1edc756db2fb909658e3087c Mon Sep 17 00:00:00 2001 From: Tim Kurvers Date: Sun, 21 Jan 2024 00:13:51 +0100 Subject: [PATCH] refactor: use TypeScript + Node 20 + vite --- .eslintrc | 20 - .eslintrc.cjs | 25 + commitlint.config.js => commitlint.config.cjs | 0 husky.config.js => husky.config.cjs | 0 src/index.html => index.html | 3 + jest.config.cjs | 12 + jest.config.js | 14 - lint-staged.config.cjs | 3 + lint-staged.config.js | 3 - package-lock.json | 29782 ++++++++++------ package.json | 32 +- spec/{index.spec.mjs => index.spec.js} | 0 src/{Client.mjs => Client.ts} | 4 +- src/gfx/{Color.mjs => Color.ts} | 0 src/gfx/{Device/index.mjs => Device.ts} | 2 +- src/gfx/{Screen/index.mjs => Screen.ts} | 6 +- src/gfx/{Screen/Layer.mjs => ScreenLayer.ts} | 4 +- src/gfx/{Shader/index.mjs => Shader.ts} | 4 +- .../Registry.mjs => ShaderRegistry.ts} | 4 +- src/gfx/{Texture/index.mjs => Texture.ts} | 0 src/gfx/{TextureFlags.mjs => TextureFlags.ts} | 0 .../Registry.mjs => TextureRegistry.ts} | 4 +- .../{WebGL2Device.mjs => WebGL2Device.ts} | 2 +- .../webgl2/{constants.mjs => constants.ts} | 0 .../{WebGPUDevice.mjs => WebGPUDevice.ts} | 0 src/gfx/{types.mjs => types.ts} | 0 src/{index.mjs => index.ts} | 0 src/math/{EdgeRect.mjs => EdgeRect.ts} | 0 src/math/{Rect.mjs => Rect.ts} | 0 src/math/{index.mjs => index.ts} | 0 .../{DrawLayerType.mjs => DrawLayerType.ts} | 0 ...mplateRegistry.mjs => TemplateRegistry.ts} | 0 src/ui/{Context.mjs => UIContext.ts} | 8 +- src/ui/{xml/Node.mjs => XMLNode.ts} | 2 +- .../components/{Backdrop.mjs => Backdrop.ts} | 2 +- ...FactoryRegistry.mjs => FactoryRegistry.ts} | 0 src/ui/components/{Root.mjs => UIRoot.ts} | 4 +- .../{FramePoint/index.mjs => FramePoint.ts} | 4 +- .../Type.mjs => FramePointType.ts} | 0 .../{FrameStrata/index.mjs => FrameStrata.ts} | 7 +- .../Level.mjs => FrameStrataLevel.ts} | 8 +- .../Type.mjs => FrameStrataType.ts} | 0 .../{LayoutFrame/index.mjs => LayoutFrame.ts} | 10 +- .../script.mjs => ScriptObject.script.ts} | 4 +- .../index.mjs => ScriptObject.ts} | 4 +- .../script.mjs => ScriptRegion.script.ts} | 6 +- .../index.mjs => ScriptRegion.ts} | 12 +- src/ui/components/{index.mjs => index.ts} | 0 .../{Button/script.mjs => Button.script.ts} | 6 +- .../simple/{Button/index.mjs => Button.ts} | 12 +- .../{Button/State.mjs => ButtonState.ts} | 0 .../script.mjs => CheckBox.script.ts} | 0 .../{CheckBox/index.mjs => CheckBox.ts} | 4 +- .../{EditBox/script.mjs => EditBox.script.ts} | 0 .../simple/{EditBox/index.mjs => EditBox.ts} | 6 +- .../script.mjs => FontString.script.ts} | 0 .../{FontString/index.mjs => FontString.ts} | 4 +- .../{Frame/script.mjs => Frame.script.ts} | 4 +- .../simple/{Frame/index.mjs => Frame.ts} | 36 +- .../simple/{Frame/Flag.mjs => FrameFlag.ts} | 0 .../{HTML/script.mjs => HTML.script.ts} | 0 .../simple/{HTML/index.mjs => HTML.ts} | 4 +- .../{Model/script.mjs => Model.script.ts} | 0 .../simple/{Model/index.mjs => Model.ts} | 4 +- .../simple/{Region/index.mjs => Region.ts} | 4 +- .../script.mjs => ScrollFrame.script.ts} | 2 +- .../{ScrollFrame/index.mjs => ScrollFrame.ts} | 8 +- .../{Slider/script.mjs => Slider.script.ts} | 4 +- .../simple/{Slider/index.mjs => Slider.ts} | 6 +- .../{Texture/script.mjs => Texture.script.ts} | 0 .../simple/{Texture/index.mjs => Texture.ts} | 22 +- .../ImageMode.mjs => TextureImageMode.ts} | 0 .../singletons/{ModelFFX.mjs => ModelFFX.ts} | 0 .../{RenderBatch.mjs => RenderBatch.ts} | 0 .../{RenderMesh.mjs => RenderMesh.ts} | 0 .../rendering/{Renderer.mjs => Renderer.ts} | 4 +- ...eScriptObject.mjs => FrameScriptObject.ts} | 4 +- .../scripting/{Script/index.mjs => Script.ts} | 4 +- .../Registry.mjs => ScriptRegistry.ts} | 2 +- .../{Context.mjs => ScriptingContext.ts} | 0 .../scripting/globals/{extra.mjs => extra.ts} | 2 +- .../scripting/globals/{frame.mjs => frame.ts} | 4 +- ...aracter-create.mjs => character-create.ts} | 0 ...aracter-select.mjs => character-select.ts} | 0 .../globals/glue/{index.mjs => index.ts} | 0 .../globals/glue/{shared.mjs => shared.ts} | 0 .../globals/{shared.mjs => shared.ts} | 0 .../scripting/globals/{sound.mjs => sound.ts} | 0 .../globals/{system.mjs => system.ts} | 0 src/ui/scripting/{lua.mjs => lua.ts} | 0 src/ui/{utils.mjs => utils.ts} | 2 +- src/utils/{coordinates.mjs => coordinates.ts} | 0 .../{HashMap.mjs => HashMap.ts} | 0 .../{LinkedList/index.mjs => LinkedList.ts} | 2 +- .../Link.mjs => LinkedListLink.ts} | 0 .../Node.mjs => LinkedListNode.ts} | 2 +- .../datastructures/{index.mjs => index.ts} | 4 +- src/utils/{dimensions.mjs => dimensions.ts} | 0 src/utils/{fetch.mjs => fetch.ts} | 0 src/utils/{index.mjs => index.ts} | 0 src/utils/{inheritance.mjs => inheritance.ts} | 0 src/utils/{logging.mjs => logging.ts} | 0 src/utils/{lua.mjs => lua.ts} | 0 src/utils/{path.mjs => path.ts} | 0 src/utils/{strings.mjs => strings.ts} | 0 tsconfig.json | 23 + vite-env.d.ts | 1 + vite.config.js | 23 + webpack.config.js | 40 - 109 files changed, 19682 insertions(+), 10556 deletions(-) delete mode 100644 .eslintrc create mode 100644 .eslintrc.cjs rename commitlint.config.js => commitlint.config.cjs (100%) rename husky.config.js => husky.config.cjs (100%) rename src/index.html => index.html (86%) create mode 100644 jest.config.cjs delete mode 100644 jest.config.js create mode 100644 lint-staged.config.cjs delete mode 100644 lint-staged.config.js rename spec/{index.spec.mjs => index.spec.js} (100%) rename src/{Client.mjs => Client.ts} (87%) rename src/gfx/{Color.mjs => Color.ts} (100%) rename src/gfx/{Device/index.mjs => Device.ts} (86%) rename src/gfx/{Screen/index.mjs => Screen.ts} (97%) rename src/gfx/{Screen/Layer.mjs => ScreenLayer.ts} (81%) rename src/gfx/{Shader/index.mjs => Shader.ts} (88%) rename src/gfx/{Shader/Registry.mjs => ShaderRegistry.ts} (86%) rename src/gfx/{Texture/index.mjs => Texture.ts} (100%) rename src/gfx/{TextureFlags.mjs => TextureFlags.ts} (100%) rename src/gfx/{Texture/Registry.mjs => TextureRegistry.ts} (82%) rename src/gfx/apis/webgl2/{WebGL2Device.mjs => WebGL2Device.ts} (94%) rename src/gfx/apis/webgl2/{constants.mjs => constants.ts} (100%) rename src/gfx/apis/webgpu/{WebGPUDevice.mjs => WebGPUDevice.ts} (100%) rename src/gfx/{types.mjs => types.ts} (100%) rename src/{index.mjs => index.ts} (100%) rename src/math/{EdgeRect.mjs => EdgeRect.ts} (100%) rename src/math/{Rect.mjs => Rect.ts} (100%) rename src/math/{index.mjs => index.ts} (100%) rename src/ui/{DrawLayerType.mjs => DrawLayerType.ts} (100%) rename src/ui/{TemplateRegistry.mjs => TemplateRegistry.ts} (100%) rename src/ui/{Context.mjs => UIContext.ts} (96%) rename src/ui/{xml/Node.mjs => XMLNode.ts} (95%) rename src/ui/components/{Backdrop.mjs => Backdrop.ts} (99%) rename src/ui/components/{FactoryRegistry.mjs => FactoryRegistry.ts} (100%) rename src/ui/components/{Root.mjs => UIRoot.ts} (97%) rename src/ui/components/abstract/{FramePoint/index.mjs => FramePoint.ts} (97%) rename src/ui/components/abstract/{FramePoint/Type.mjs => FramePointType.ts} (100%) rename src/ui/components/abstract/{FrameStrata/index.mjs => FrameStrata.ts} (93%) rename src/ui/components/abstract/{FrameStrata/Level.mjs => FrameStrataLevel.ts} (90%) rename src/ui/components/abstract/{FrameStrata/Type.mjs => FrameStrataType.ts} (100%) rename src/ui/components/abstract/{LayoutFrame/index.mjs => LayoutFrame.ts} (98%) rename src/ui/components/abstract/{ScriptObject/script.mjs => ScriptObject.script.ts} (90%) rename src/ui/components/abstract/{ScriptObject/index.mjs => ScriptObject.ts} (90%) rename src/ui/components/abstract/{ScriptRegion/script.mjs => ScriptRegion.script.ts} (96%) rename src/ui/components/abstract/{ScriptRegion/index.mjs => ScriptRegion.ts} (75%) rename src/ui/components/{index.mjs => index.ts} (100%) rename src/ui/components/simple/{Button/script.mjs => Button.script.ts} (96%) rename src/ui/components/simple/{Button/index.mjs => Button.ts} (91%) rename src/ui/components/simple/{Button/State.mjs => ButtonState.ts} (100%) rename src/ui/components/simple/{CheckBox/script.mjs => CheckBox.script.ts} (100%) rename src/ui/components/simple/{CheckBox/index.mjs => CheckBox.ts} (67%) rename src/ui/components/simple/{EditBox/script.mjs => EditBox.script.ts} (100%) rename src/ui/components/simple/{EditBox/index.mjs => EditBox.ts} (85%) rename src/ui/components/simple/{FontString/script.mjs => FontString.script.ts} (100%) rename src/ui/components/simple/{FontString/index.mjs => FontString.ts} (77%) rename src/ui/components/simple/{Frame/script.mjs => Frame.script.ts} (98%) rename src/ui/components/simple/{Frame/index.mjs => Frame.ts} (95%) rename src/ui/components/simple/{Frame/Flag.mjs => FrameFlag.ts} (100%) rename src/ui/components/simple/{HTML/script.mjs => HTML.script.ts} (100%) rename src/ui/components/simple/{HTML/index.mjs => HTML.ts} (68%) rename src/ui/components/simple/{Model/script.mjs => Model.script.ts} (100%) rename src/ui/components/simple/{Model/index.mjs => Model.ts} (68%) rename src/ui/components/simple/{Region/index.mjs => Region.ts} (94%) rename src/ui/components/simple/{ScrollFrame/script.mjs => ScrollFrame.script.ts} (91%) rename src/ui/components/simple/{ScrollFrame/index.mjs => ScrollFrame.ts} (84%) rename src/ui/components/simple/{Slider/script.mjs => Slider.script.ts} (90%) rename src/ui/components/simple/{Slider/index.mjs => Slider.ts} (75%) rename src/ui/components/simple/{Texture/script.mjs => Texture.script.ts} (100%) rename src/ui/components/simple/{Texture/index.mjs => Texture.ts} (93%) rename src/ui/components/simple/{Texture/ImageMode.mjs => TextureImageMode.ts} (100%) rename src/ui/components/singletons/{ModelFFX.mjs => ModelFFX.ts} (100%) rename src/ui/rendering/{RenderBatch.mjs => RenderBatch.ts} (100%) rename src/ui/rendering/{RenderMesh.mjs => RenderMesh.ts} (100%) rename src/ui/rendering/{Renderer.mjs => Renderer.ts} (98%) rename src/ui/scripting/{FrameScriptObject.mjs => FrameScriptObject.ts} (97%) rename src/ui/scripting/{Script/index.mjs => Script.ts} (95%) rename src/ui/scripting/{Script/Registry.mjs => ScriptRegistry.ts} (81%) rename src/ui/scripting/{Context.mjs => ScriptingContext.ts} (100%) rename src/ui/scripting/globals/{extra.mjs => extra.ts} (97%) rename src/ui/scripting/globals/{frame.mjs => frame.ts} (97%) rename src/ui/scripting/globals/glue/{character-create.mjs => character-create.ts} (100%) rename src/ui/scripting/globals/glue/{character-select.mjs => character-select.ts} (100%) rename src/ui/scripting/globals/glue/{index.mjs => index.ts} (100%) rename src/ui/scripting/globals/glue/{shared.mjs => shared.ts} (100%) rename src/ui/scripting/globals/{shared.mjs => shared.ts} (100%) rename src/ui/scripting/globals/{sound.mjs => sound.ts} (100%) rename src/ui/scripting/globals/{system.mjs => system.ts} (100%) rename src/ui/scripting/{lua.mjs => lua.ts} (100%) rename src/ui/{utils.mjs => utils.ts} (82%) rename src/utils/{coordinates.mjs => coordinates.ts} (100%) rename src/utils/datastructures/{HashMap.mjs => HashMap.ts} (100%) rename src/utils/datastructures/{LinkedList/index.mjs => LinkedList.ts} (97%) rename src/utils/datastructures/{LinkedList/Link.mjs => LinkedListLink.ts} (100%) rename src/utils/datastructures/{LinkedList/Node.mjs => LinkedListNode.ts} (72%) rename src/utils/datastructures/{index.mjs => index.ts} (50%) rename src/utils/{dimensions.mjs => dimensions.ts} (100%) rename src/utils/{fetch.mjs => fetch.ts} (100%) rename src/utils/{index.mjs => index.ts} (100%) rename src/utils/{inheritance.mjs => inheritance.ts} (100%) rename src/utils/{logging.mjs => logging.ts} (100%) rename src/utils/{lua.mjs => lua.ts} (100%) rename src/utils/{path.mjs => path.ts} (100%) rename src/utils/{strings.mjs => strings.ts} (100%) create mode 100644 tsconfig.json create mode 100644 vite-env.d.ts create mode 100644 vite.config.js delete mode 100644 webpack.config.js diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index d36d46a..0000000 --- a/.eslintrc +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "@wowserhq/eslint-config", - "env": { - "browser": true, - "es6": true, - "node": true - }, - "rules": { - "camelcase": "off", - "import/order": ["error"], - "no-console": "off", - "no-unused-vars": ["error", { - "argsIgnorePattern": "^_", - "varsIgnorePattern": "^_" - }], - "quotes": ["error", "single", { - "avoidEscape": true - }] - } -} diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 0000000..2b7b004 --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,25 @@ +// TODO: Expand @wowserhq/eslint-config with TypeScript variant +module.exports = { + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:import/recommended', + 'plugin:import/typescript', + ], + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + root: true, + env: { browser: true, node: true }, + rules: { + 'camelcase': 'off', + 'no-console': 'off', + 'no-unused-vars': ['error', { + 'argsIgnorePattern': '^_', + 'varsIgnorePattern': '^_' + }], + 'quotes': ['error', 'single', { + 'avoidEscape': true + }], + 'semi': ['warn'], + }, +}; diff --git a/commitlint.config.js b/commitlint.config.cjs similarity index 100% rename from commitlint.config.js rename to commitlint.config.cjs diff --git a/husky.config.js b/husky.config.cjs similarity index 100% rename from husky.config.js rename to husky.config.cjs diff --git a/src/index.html b/index.html similarity index 86% rename from src/index.html rename to index.html index adeb48d..f432d3c 100644 --- a/src/index.html +++ b/index.html @@ -1,7 +1,9 @@ + Wowser +