From 5c30f8fa6784b5a213c3845f16ec28bc4bf93038 Mon Sep 17 00:00:00 2001 From: Matthew Kilgore Date: Tue, 4 Aug 2020 19:10:50 -0400 Subject: [PATCH] Setup Mithril 2 --- js/package-lock.json | 11 ++++++++--- js/package.json | 3 ++- js/shims.d.ts | 7 +++++++ js/tsconfig.json | 4 ++++ js/webpack-config-shims.d.ts | 17 +++++++++++++++++ js/webpack-config-tsconfig.json | 22 ++++++++++++++++++++++ 6 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 js/shims.d.ts create mode 100644 js/tsconfig.json create mode 100644 js/webpack-config-shims.d.ts create mode 100644 js/webpack-config-tsconfig.json diff --git a/js/package-lock.json b/js/package-lock.json index 9e788e9d1..a39b216f4 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -1075,6 +1075,11 @@ "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", "dev": true }, + "@types/mithril": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/mithril/-/mithril-2.0.3.tgz", + "integrity": "sha512-cZHOdO2IiXYeyjeDYdbOisSdfaJRzfmRo3zVzgu33IWTMA0KEQObp9fdvqcuYdPz93iJ1yCl19GcEjo/9yv+yA==" + }, "@types/parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", @@ -3807,9 +3812,9 @@ } }, "mithril": { - "version": "0.2.8", - "resolved": "https://registry.npmjs.org/mithril/-/mithril-0.2.8.tgz", - "integrity": "sha512-9XuGnVmS2OyFexUuP/CcJFFJjHLM+RGYBxyVRNyQ6khbMfDJIF/xyZ4zq18ZRfPagpFmWUFpjHd5ZqPULGZyNg==" + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/mithril/-/mithril-2.0.4.tgz", + "integrity": "sha512-mgw+DMZlhMS4PpprF6dl7ZoeZq5GGcAuWnrg5e12MvaGauc4jzWsDZtVGRCktsiQczOEUr2K5teKbE5k44RlOg==" }, "mixin-deep": { "version": "1.3.2", diff --git a/js/package.json b/js/package.json index 96a521dc9..f4c0af8a2 100644 --- a/js/package.json +++ b/js/package.json @@ -3,6 +3,7 @@ "name": "@flarum/core", "dependencies": { "@babel/preset-typescript": "^7.10.1", + "@types/mithril": "^2.0.3", "bootstrap": "^3.4.1", "classnames": "^2.2.5", "color-thief-browser": "^2.0.2", @@ -13,7 +14,7 @@ "jquery.hotkeys": "^0.1.0", "lodash-es": "^4.17.14", "m.attrs.bidi": "github:tobscure/m.attrs.bidi", - "mithril": "^0.2.8", + "mithril": "^2.0.4", "punycode": "^2.1.1", "spin.js": "^3.1.0", "webpack": "^4.43.0", diff --git a/js/shims.d.ts b/js/shims.d.ts new file mode 100644 index 000000000..f640d5616 --- /dev/null +++ b/js/shims.d.ts @@ -0,0 +1,7 @@ +export * from './webpack-config-shims'; + +import Application from './src/common/Application'; + +declare global { + const app: Application; +} \ No newline at end of file diff --git a/js/tsconfig.json b/js/tsconfig.json new file mode 100644 index 000000000..62af46121 --- /dev/null +++ b/js/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "./webpack-flarum-tsconfig" + } + \ No newline at end of file diff --git a/js/webpack-config-shims.d.ts b/js/webpack-config-shims.d.ts new file mode 100644 index 000000000..527d3eb53 --- /dev/null +++ b/js/webpack-config-shims.d.ts @@ -0,0 +1,17 @@ +import * as Mithril from 'mithril'; +import Stream from 'mithril/stream'; + +import * as _dayjs from 'dayjs'; + +interface m extends Mithril.Static { + prop: typeof Stream; +} + +declare global { + const m: m; + const dayjs: typeof _dayjs; +} + +export as namespace Mithril; + +export {}; \ No newline at end of file diff --git a/js/webpack-config-tsconfig.json b/js/webpack-config-tsconfig.json new file mode 100644 index 000000000..67744af8b --- /dev/null +++ b/js/webpack-config-tsconfig.json @@ -0,0 +1,22 @@ +{ + "include": ["src/**/*.ts"], + "files": ["shims.d.ts"], + "compilerOptions": { + "allowUmdGlobalAccess": true, + "outDir": "dist", + "sourceMap": true, + "strict": true, + "noImplicitReturns": false, + "noImplicitAny": false, + "module": "es2015", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "esModuleInterop": true, + "moduleResolution": "node", + "target": "es6", + "jsx": "preserve", + "lib": ["es2015", "es2017", "dom"], + "allowSyntheticDefaultImports": true + } +} + \ No newline at end of file