diff --git a/samples/esm-monaco-webpack-plugin/index.html b/samples/esm-monaco-webpack-plugin/index.html index 13923c61..1359c88b 100644 --- a/samples/esm-monaco-webpack-plugin/index.html +++ b/samples/esm-monaco-webpack-plugin/index.html @@ -1,18 +1,29 @@ + + + + esm-monaco-webpack-plugin-sample + - - - - esm-monaco-webpack-plugin-sample - - - -

FlinkSQL Demo

-
-
-
- - + +

ESM Monaco Webpack Plugin Demo

+ +
+
+
+ - \ No newline at end of file + diff --git a/samples/esm-monaco-webpack-plugin/package-lock.json b/samples/esm-monaco-webpack-plugin/package-lock.json index cefdf56e..0e6dd23f 100644 --- a/samples/esm-monaco-webpack-plugin/package-lock.json +++ b/samples/esm-monaco-webpack-plugin/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "monaco-editor": "0.31.0", "monaco-editor-webpack-plugin": "7.0.1", - "monaco-sql-languages": "0.12.0-beta.ng.1" + "monaco-sql-languages": "0.12.0-beta.11" }, "devDependencies": { "css-loader": "^6.8.1", @@ -597,17 +597,17 @@ } }, "node_modules/antlr4-c3": { - "version": "3.3.6", - "resolved": "https://registry.npmmirror.com/antlr4-c3/-/antlr4-c3-3.3.6.tgz", - "integrity": "sha512-gheQXG0acgFWKEqfHUxT1bC0tA/wxuy+F6452yhAkPEwkAAYZJWan3VNpvzAe1Fpg3IRiZn1vCRVur+O8MBHCQ==", + "version": "3.3.7", + "resolved": "https://registry.npmmirror.com/antlr4-c3/-/antlr4-c3-3.3.7.tgz", + "integrity": "sha512-F3ndE38wwA6z6AjUbL3heSdEGl4TxulGDPf9xB0/IY4dbRHWBh6XNaqFwur8vHKQk9FS5yNABHeg2wqlqIYO0w==", "dependencies": { - "antlr4ng": "2.0.10" + "antlr4ng": "2.0.11" } }, "node_modules/antlr4ng": { - "version": "2.0.10", - "resolved": "https://registry.npmmirror.com/antlr4ng/-/antlr4ng-2.0.10.tgz", - "integrity": "sha512-cDXmkjum5TSgtgKyKtNN3Zk8ebXeZXOHS7e5pIAnyuKdAQB1r/EzJl+1Vro5JdJCWfgtZ2IqJ3KNvRNuCMjgmQ==", + "version": "2.0.11", + "resolved": "https://registry.npmmirror.com/antlr4ng/-/antlr4ng-2.0.11.tgz", + "integrity": "sha512-9jM91VVtHSqHkAHQsXHaoaiewFETMvUTI1/tXvwTiFw4f7zke3IGlwEyoKN9NS0FqIwDKFvUNW2e1cKPniTkVQ==", "peerDependencies": { "antlr4ng-cli": "1.0.7" } @@ -1266,12 +1266,12 @@ } }, "node_modules/dt-sql-parser": { - "version": "4.0.0-ng.1", - "resolved": "https://registry.npmmirror.com/dt-sql-parser/-/dt-sql-parser-4.0.0-ng.1.tgz", - "integrity": "sha512-C4KqSNwNIGUR02YMFfQh8CwpPB/K4QjSlUkrv4swzQy6/ofrno6EWwOZ/OTo2wPRdk152fQJAQhYtbmmmW2MtQ==", + "version": "4.0.0-beta.4.12", + "resolved": "https://registry.npmmirror.com/dt-sql-parser/-/dt-sql-parser-4.0.0-beta.4.12.tgz", + "integrity": "sha512-kfLRecn+dfdZjrKt3Ovm52ryoh9UGF+dCjNzV2pk8XI5kgF7lgQJhPZdRi+2yn1AU/BWQ1/0E6LnvFYbZ7Wr9Q==", "dependencies": { - "antlr4-c3": "3.3.6", - "antlr4ng": "2.0.10" + "antlr4-c3": "3.3.7", + "antlr4ng": "2.0.11" } }, "node_modules/ee-first": { @@ -2875,11 +2875,11 @@ } }, "node_modules/monaco-sql-languages": { - "version": "0.12.0-beta.ng.1", - "resolved": "https://registry.npmmirror.com/monaco-sql-languages/-/monaco-sql-languages-0.12.0-beta.ng.1.tgz", - "integrity": "sha512-esi5t1Wd4JL7K4xTvEkLyYXMY011wzNSIsCStaORPX5VNgO7Bb6L/Cnj9vPZIyHPyY22Ewveeslhj9iFkaEZOg==", + "version": "0.12.0-beta.11", + "resolved": "https://registry.npmmirror.com/monaco-sql-languages/-/monaco-sql-languages-0.12.0-beta.11.tgz", + "integrity": "sha512-uOLS4cel6ngtU/Eh3nfswVqEapQ11q4Jszw8fNtGmGexjwflgNL4w2Dmn2XTsT1ebzN5vGKIuMljosnY2nKCRA==", "dependencies": { - "dt-sql-parser": "4.0.0-ng.1" + "dt-sql-parser": "4.0.0-beta.4.12" }, "peerDependencies": { "monaco-editor": ">=0.31.0" @@ -5217,17 +5217,17 @@ } }, "antlr4-c3": { - "version": "3.3.6", - "resolved": "https://registry.npmmirror.com/antlr4-c3/-/antlr4-c3-3.3.6.tgz", - "integrity": "sha512-gheQXG0acgFWKEqfHUxT1bC0tA/wxuy+F6452yhAkPEwkAAYZJWan3VNpvzAe1Fpg3IRiZn1vCRVur+O8MBHCQ==", + "version": "3.3.7", + "resolved": "https://registry.npmmirror.com/antlr4-c3/-/antlr4-c3-3.3.7.tgz", + "integrity": "sha512-F3ndE38wwA6z6AjUbL3heSdEGl4TxulGDPf9xB0/IY4dbRHWBh6XNaqFwur8vHKQk9FS5yNABHeg2wqlqIYO0w==", "requires": { - "antlr4ng": "2.0.10" + "antlr4ng": "2.0.11" } }, "antlr4ng": { - "version": "2.0.10", - "resolved": "https://registry.npmmirror.com/antlr4ng/-/antlr4ng-2.0.10.tgz", - "integrity": "sha512-cDXmkjum5TSgtgKyKtNN3Zk8ebXeZXOHS7e5pIAnyuKdAQB1r/EzJl+1Vro5JdJCWfgtZ2IqJ3KNvRNuCMjgmQ==", + "version": "2.0.11", + "resolved": "https://registry.npmmirror.com/antlr4ng/-/antlr4ng-2.0.11.tgz", + "integrity": "sha512-9jM91VVtHSqHkAHQsXHaoaiewFETMvUTI1/tXvwTiFw4f7zke3IGlwEyoKN9NS0FqIwDKFvUNW2e1cKPniTkVQ==", "requires": {} }, "antlr4ng-cli": { @@ -5768,12 +5768,12 @@ } }, "dt-sql-parser": { - "version": "4.0.0-ng.1", - "resolved": "https://registry.npmmirror.com/dt-sql-parser/-/dt-sql-parser-4.0.0-ng.1.tgz", - "integrity": "sha512-C4KqSNwNIGUR02YMFfQh8CwpPB/K4QjSlUkrv4swzQy6/ofrno6EWwOZ/OTo2wPRdk152fQJAQhYtbmmmW2MtQ==", + "version": "4.0.0-beta.4.12", + "resolved": "https://registry.npmmirror.com/dt-sql-parser/-/dt-sql-parser-4.0.0-beta.4.12.tgz", + "integrity": "sha512-kfLRecn+dfdZjrKt3Ovm52ryoh9UGF+dCjNzV2pk8XI5kgF7lgQJhPZdRi+2yn1AU/BWQ1/0E6LnvFYbZ7Wr9Q==", "requires": { - "antlr4-c3": "3.3.6", - "antlr4ng": "2.0.10" + "antlr4-c3": "3.3.7", + "antlr4ng": "2.0.11" } }, "ee-first": { @@ -7034,11 +7034,11 @@ } }, "monaco-sql-languages": { - "version": "0.12.0-beta.ng.1", - "resolved": "https://registry.npmmirror.com/monaco-sql-languages/-/monaco-sql-languages-0.12.0-beta.ng.1.tgz", - "integrity": "sha512-esi5t1Wd4JL7K4xTvEkLyYXMY011wzNSIsCStaORPX5VNgO7Bb6L/Cnj9vPZIyHPyY22Ewveeslhj9iFkaEZOg==", + "version": "0.12.0-beta.11", + "resolved": "https://registry.npmmirror.com/monaco-sql-languages/-/monaco-sql-languages-0.12.0-beta.11.tgz", + "integrity": "sha512-uOLS4cel6ngtU/Eh3nfswVqEapQ11q4Jszw8fNtGmGexjwflgNL4w2Dmn2XTsT1ebzN5vGKIuMljosnY2nKCRA==", "requires": { - "dt-sql-parser": "4.0.0-ng.1" + "dt-sql-parser": "4.0.0-beta.4.12" } }, "morgan": { diff --git a/samples/esm-monaco-webpack-plugin/package.json b/samples/esm-monaco-webpack-plugin/package.json index 093046fd..0da6c21e 100644 --- a/samples/esm-monaco-webpack-plugin/package.json +++ b/samples/esm-monaco-webpack-plugin/package.json @@ -25,6 +25,6 @@ "dependencies": { "monaco-editor": "0.31.0", "monaco-editor-webpack-plugin": "7.0.1", - "monaco-sql-languages": "0.12.0-beta.ng.1" + "monaco-sql-languages": "0.12.0-beta.11" } } diff --git a/samples/esm-monaco-webpack-plugin/src/index.ts b/samples/esm-monaco-webpack-plugin/src/index.ts index 8675967e..433080f0 100644 --- a/samples/esm-monaco-webpack-plugin/src/index.ts +++ b/samples/esm-monaco-webpack-plugin/src/index.ts @@ -1,13 +1,40 @@ import * as monaco from 'monaco-editor'; import { LanguageIdEnum } from 'monaco-sql-languages'; +import './languageSetup'; + +let editorIns: monaco.editor.IStandaloneCodeEditor | null = null; function render() { const container = document.getElementById('container'); if (container) { - monaco.editor.create(container, { - language: LanguageIdEnum.FLINK + editorIns = monaco.editor.create(container, { + language: LanguageIdEnum.TRINO + }); + } +} + +function listenLangChange() { + const langSelect = document.getElementById('lang-select') as HTMLSelectElement; + if (langSelect && editorIns) { + langSelect.addEventListener('change', () => { + if (!editorIns) return; + + const lang = langSelect.options[langSelect.selectedIndex].value; + const model = editorIns.getModel(); + + if (model && model.getLanguageId() !== lang) { + monaco.editor.setModelLanguage(model, lang); + setTimeout(() => { + console.log( + 'language changed, current is: ', + editorIns?.getModel()?.getLanguageId() + ); + }, 200); + } }); } } render(); + +listenLangChange(); diff --git a/samples/esm-monaco-webpack-plugin/src/languageSetup.ts b/samples/esm-monaco-webpack-plugin/src/languageSetup.ts new file mode 100644 index 00000000..36a09944 --- /dev/null +++ b/samples/esm-monaco-webpack-plugin/src/languageSetup.ts @@ -0,0 +1,8 @@ +/** import contribution files */ +import 'monaco-sql-languages/esm/languages/mysql/mysql.contribution'; +import 'monaco-sql-languages/esm/languages/flink/flink.contribution'; +import 'monaco-sql-languages/esm/languages/spark/spark.contribution'; +import 'monaco-sql-languages/esm/languages/hive/hive.contribution'; +import 'monaco-sql-languages/esm/languages/trino/trino.contribution'; +import 'monaco-sql-languages/esm/languages/pgsql/pgsql.contribution'; +import 'monaco-sql-languages/esm/languages/impala/impala.contribution'; diff --git a/samples/esm-monaco-webpack-plugin/webpack.config.js b/samples/esm-monaco-webpack-plugin/webpack.config.js index 9789c61c..07ec3416 100644 --- a/samples/esm-monaco-webpack-plugin/webpack.config.js +++ b/samples/esm-monaco-webpack-plugin/webpack.config.js @@ -34,12 +34,61 @@ module.exports = { features: [], languages: [], customLanguages: [ + // 包含 Monaco SQL Languages 所提供的语言功能 + { + label: 'mysql', + entry: 'monaco-sql-languages/esm/languages/mysql/mysql.contribution', + worker: { + id: '/esm/languages/mysql/', + entry: 'monaco-sql-languages/esm/languages/mysql/mysql.worker' + } + }, { label: 'flinksql', - entry: 'monaco-sql-languages/out/esm/flinksql/flinksql.contribution', + entry: 'monaco-sql-languages/esm/languages/flink/flink.contribution', + worker: { + id: '/esm/languages/flink/', + entry: 'monaco-sql-languages/esm/languages/flink/flink.worker' + } + }, + { + label: 'sparksql', + entry: 'monaco-sql-languages/esm/languages/spark/spark.contribution', + worker: { + id: '/esm/languages/spark/', + entry: 'monaco-sql-languages/esm/languages/spark/spark.worker' + } + }, + { + label: 'hivesql', + entry: 'monaco-sql-languages/esm/languages/hive/hive.contribution', + worker: { + id: '/esm/languages/hive/', + entry: 'monaco-sql-languages/esm/languages/hive/hive.worker' + } + }, + { + label: 'trinosql', + entry: 'monaco-sql-languages/esm/languages/trino/trino.contribution', + worker: { + id: '/esm/languages/trino/', + entry: 'monaco-sql-languages/esm/languages/trino/trino.worker' + } + }, + { + label: 'pgsql', + entry: 'monaco-sql-languages/esm/languages/pgsql/pgsql.contribution', + worker: { + id: '/esm/languages/pgsql/', + entry: 'monaco-sql-languages/esm/languages/pgsql/pgsql.worker' + } + }, + { + label: 'impalasql', + entry: 'monaco-sql-languages/esm/languages/impala/impala.contribution', worker: { - id: 'monaco-sql-languages/out/esm/flinksql/flinkSQLWorker', - entry: 'monaco-sql-languages/out/esm/flinksql/flinksql.worker' + id: '/esm/languages/impala/', + entry: 'monaco-sql-languages/esm/languages/impala/impala.worker' } } ] diff --git a/samples/esm-monaco-webpack-plugin/webpack.prod.config.js b/samples/esm-monaco-webpack-plugin/webpack.prod.config.js index 2b5d6207..a1911b37 100644 --- a/samples/esm-monaco-webpack-plugin/webpack.prod.config.js +++ b/samples/esm-monaco-webpack-plugin/webpack.prod.config.js @@ -4,8 +4,5 @@ delete devConfig.devServer; delete devConfig.devtool; devConfig.mode = 'production'; -devConfig.optimization = { - minimize: false -}; module.exports = devConfig; diff --git a/samples/esm-plain-webpack/index.html b/samples/esm-plain-webpack/index.html index c0268657..91578684 100644 --- a/samples/esm-plain-webpack/index.html +++ b/samples/esm-plain-webpack/index.html @@ -1,18 +1,29 @@ + + + + esm-plain-webpack-sample + - - - - esm-plain-webpack-sample - - - -

FlinkSQL Demo

-
-
-
- - + +

ESM Plain Webpack Demo

+ +
+
+
+ - \ No newline at end of file + diff --git a/samples/esm-plain-webpack/package-lock.json b/samples/esm-plain-webpack/package-lock.json index 0c7d343d..b6b8b5de 100644 --- a/samples/esm-plain-webpack/package-lock.json +++ b/samples/esm-plain-webpack/package-lock.json @@ -10,7 +10,7 @@ "license": "ISC", "dependencies": { "monaco-editor": "0.31.0", - "monaco-sql-languages": "0.12.0-beta.ng.1" + "monaco-sql-languages": "0.12.0-beta.11" }, "devDependencies": { "css-loader": "^6.8.1", @@ -628,17 +628,17 @@ } }, "node_modules/antlr4-c3": { - "version": "3.3.6", - "resolved": "https://registry.npmmirror.com/antlr4-c3/-/antlr4-c3-3.3.6.tgz", - "integrity": "sha512-gheQXG0acgFWKEqfHUxT1bC0tA/wxuy+F6452yhAkPEwkAAYZJWan3VNpvzAe1Fpg3IRiZn1vCRVur+O8MBHCQ==", + "version": "3.3.7", + "resolved": "https://registry.npmmirror.com/antlr4-c3/-/antlr4-c3-3.3.7.tgz", + "integrity": "sha512-F3ndE38wwA6z6AjUbL3heSdEGl4TxulGDPf9xB0/IY4dbRHWBh6XNaqFwur8vHKQk9FS5yNABHeg2wqlqIYO0w==", "dependencies": { - "antlr4ng": "2.0.10" + "antlr4ng": "2.0.11" } }, "node_modules/antlr4ng": { - "version": "2.0.10", - "resolved": "https://registry.npmmirror.com/antlr4ng/-/antlr4ng-2.0.10.tgz", - "integrity": "sha512-cDXmkjum5TSgtgKyKtNN3Zk8ebXeZXOHS7e5pIAnyuKdAQB1r/EzJl+1Vro5JdJCWfgtZ2IqJ3KNvRNuCMjgmQ==", + "version": "2.0.11", + "resolved": "https://registry.npmmirror.com/antlr4ng/-/antlr4ng-2.0.11.tgz", + "integrity": "sha512-9jM91VVtHSqHkAHQsXHaoaiewFETMvUTI1/tXvwTiFw4f7zke3IGlwEyoKN9NS0FqIwDKFvUNW2e1cKPniTkVQ==", "peerDependencies": { "antlr4ng-cli": "1.0.7" } @@ -1294,12 +1294,12 @@ } }, "node_modules/dt-sql-parser": { - "version": "4.0.0-ng.1", - "resolved": "https://registry.npmmirror.com/dt-sql-parser/-/dt-sql-parser-4.0.0-ng.1.tgz", - "integrity": "sha512-C4KqSNwNIGUR02YMFfQh8CwpPB/K4QjSlUkrv4swzQy6/ofrno6EWwOZ/OTo2wPRdk152fQJAQhYtbmmmW2MtQ==", + "version": "4.0.0-beta.4.12", + "resolved": "https://registry.npmmirror.com/dt-sql-parser/-/dt-sql-parser-4.0.0-beta.4.12.tgz", + "integrity": "sha512-kfLRecn+dfdZjrKt3Ovm52ryoh9UGF+dCjNzV2pk8XI5kgF7lgQJhPZdRi+2yn1AU/BWQ1/0E6LnvFYbZ7Wr9Q==", "dependencies": { - "antlr4-c3": "3.3.6", - "antlr4ng": "2.0.10" + "antlr4-c3": "3.3.7", + "antlr4ng": "2.0.11" } }, "node_modules/ee-first": { @@ -2880,11 +2880,11 @@ "integrity": "sha512-H3QmysEwxxY8oxmFhIFcY9JkuwilUDa6txdAxb797cVr7XFZX27a3SDwcGJmTlV9iGPwdh132r3KKCS5aNL4Gg==" }, "node_modules/monaco-sql-languages": { - "version": "0.12.0-beta.ng.1", - "resolved": "https://registry.npmmirror.com/monaco-sql-languages/-/monaco-sql-languages-0.12.0-beta.ng.1.tgz", - "integrity": "sha512-esi5t1Wd4JL7K4xTvEkLyYXMY011wzNSIsCStaORPX5VNgO7Bb6L/Cnj9vPZIyHPyY22Ewveeslhj9iFkaEZOg==", + "version": "0.12.0-beta.11", + "resolved": "https://registry.npmmirror.com/monaco-sql-languages/-/monaco-sql-languages-0.12.0-beta.11.tgz", + "integrity": "sha512-uOLS4cel6ngtU/Eh3nfswVqEapQ11q4Jszw8fNtGmGexjwflgNL4w2Dmn2XTsT1ebzN5vGKIuMljosnY2nKCRA==", "dependencies": { - "dt-sql-parser": "4.0.0-ng.1" + "dt-sql-parser": "4.0.0-beta.4.12" }, "peerDependencies": { "monaco-editor": ">=0.31.0" @@ -5274,17 +5274,17 @@ } }, "antlr4-c3": { - "version": "3.3.6", - "resolved": "https://registry.npmmirror.com/antlr4-c3/-/antlr4-c3-3.3.6.tgz", - "integrity": "sha512-gheQXG0acgFWKEqfHUxT1bC0tA/wxuy+F6452yhAkPEwkAAYZJWan3VNpvzAe1Fpg3IRiZn1vCRVur+O8MBHCQ==", + "version": "3.3.7", + "resolved": "https://registry.npmmirror.com/antlr4-c3/-/antlr4-c3-3.3.7.tgz", + "integrity": "sha512-F3ndE38wwA6z6AjUbL3heSdEGl4TxulGDPf9xB0/IY4dbRHWBh6XNaqFwur8vHKQk9FS5yNABHeg2wqlqIYO0w==", "requires": { - "antlr4ng": "2.0.10" + "antlr4ng": "2.0.11" } }, "antlr4ng": { - "version": "2.0.10", - "resolved": "https://registry.npmmirror.com/antlr4ng/-/antlr4ng-2.0.10.tgz", - "integrity": "sha512-cDXmkjum5TSgtgKyKtNN3Zk8ebXeZXOHS7e5pIAnyuKdAQB1r/EzJl+1Vro5JdJCWfgtZ2IqJ3KNvRNuCMjgmQ==", + "version": "2.0.11", + "resolved": "https://registry.npmmirror.com/antlr4ng/-/antlr4ng-2.0.11.tgz", + "integrity": "sha512-9jM91VVtHSqHkAHQsXHaoaiewFETMvUTI1/tXvwTiFw4f7zke3IGlwEyoKN9NS0FqIwDKFvUNW2e1cKPniTkVQ==", "requires": {} }, "antlr4ng-cli": { @@ -5825,12 +5825,12 @@ } }, "dt-sql-parser": { - "version": "4.0.0-ng.1", - "resolved": "https://registry.npmmirror.com/dt-sql-parser/-/dt-sql-parser-4.0.0-ng.1.tgz", - "integrity": "sha512-C4KqSNwNIGUR02YMFfQh8CwpPB/K4QjSlUkrv4swzQy6/ofrno6EWwOZ/OTo2wPRdk152fQJAQhYtbmmmW2MtQ==", + "version": "4.0.0-beta.4.12", + "resolved": "https://registry.npmmirror.com/dt-sql-parser/-/dt-sql-parser-4.0.0-beta.4.12.tgz", + "integrity": "sha512-kfLRecn+dfdZjrKt3Ovm52ryoh9UGF+dCjNzV2pk8XI5kgF7lgQJhPZdRi+2yn1AU/BWQ1/0E6LnvFYbZ7Wr9Q==", "requires": { - "antlr4-c3": "3.3.6", - "antlr4ng": "2.0.10" + "antlr4-c3": "3.3.7", + "antlr4ng": "2.0.11" } }, "ee-first": { @@ -7084,11 +7084,11 @@ "integrity": "sha512-H3QmysEwxxY8oxmFhIFcY9JkuwilUDa6txdAxb797cVr7XFZX27a3SDwcGJmTlV9iGPwdh132r3KKCS5aNL4Gg==" }, "monaco-sql-languages": { - "version": "0.12.0-beta.ng.1", - "resolved": "https://registry.npmmirror.com/monaco-sql-languages/-/monaco-sql-languages-0.12.0-beta.ng.1.tgz", - "integrity": "sha512-esi5t1Wd4JL7K4xTvEkLyYXMY011wzNSIsCStaORPX5VNgO7Bb6L/Cnj9vPZIyHPyY22Ewveeslhj9iFkaEZOg==", + "version": "0.12.0-beta.11", + "resolved": "https://registry.npmmirror.com/monaco-sql-languages/-/monaco-sql-languages-0.12.0-beta.11.tgz", + "integrity": "sha512-uOLS4cel6ngtU/Eh3nfswVqEapQ11q4Jszw8fNtGmGexjwflgNL4w2Dmn2XTsT1ebzN5vGKIuMljosnY2nKCRA==", "requires": { - "dt-sql-parser": "4.0.0-ng.1" + "dt-sql-parser": "4.0.0-beta.4.12" } }, "morgan": { diff --git a/samples/esm-plain-webpack/package.json b/samples/esm-plain-webpack/package.json index cf9696d5..1d216d3a 100644 --- a/samples/esm-plain-webpack/package.json +++ b/samples/esm-plain-webpack/package.json @@ -24,6 +24,6 @@ }, "dependencies": { "monaco-editor": "0.31.0", - "monaco-sql-languages": "0.12.0-beta.ng.1" + "monaco-sql-languages": "0.12.0-beta.11" } } diff --git a/samples/esm-plain-webpack/src/index.ts b/samples/esm-plain-webpack/src/index.ts index 010f142b..4c518675 100644 --- a/samples/esm-plain-webpack/src/index.ts +++ b/samples/esm-plain-webpack/src/index.ts @@ -2,13 +2,39 @@ import * as monaco from 'monaco-editor'; import { LanguageIdEnum } from 'monaco-sql-languages'; import './languageSetup'; +let editorIns: monaco.editor.IStandaloneCodeEditor | null = null; + function render() { const container = document.getElementById('container'); if (container) { - monaco.editor.create(container, { + editorIns = monaco.editor.create(container, { language: LanguageIdEnum.FLINK }); } } +function listenLangChange() { + const langSelect = document.getElementById('lang-select') as HTMLSelectElement; + if (langSelect) { + langSelect.addEventListener('change', () => { + if (!editorIns) return; + + const lang = langSelect.options[langSelect.selectedIndex].value; + const model = editorIns.getModel(); + + if (model && model.getLanguageId() !== lang) { + monaco.editor.setModelLanguage(model, lang); + setTimeout(() => { + console.log( + 'language changed, current is: ', + editorIns?.getModel()?.getLanguageId() + ); + }, 200); + } + }); + } +} + render(); + +listenLangChange(); diff --git a/samples/esm-plain-webpack/src/languageSetup.ts b/samples/esm-plain-webpack/src/languageSetup.ts index 46c61010..88f0c2dc 100644 --- a/samples/esm-plain-webpack/src/languageSetup.ts +++ b/samples/esm-plain-webpack/src/languageSetup.ts @@ -1,13 +1,38 @@ import { LanguageIdEnum } from 'monaco-sql-languages'; -/** import contribution file */ -import 'monaco-sql-languages/out/esm/flinksql/flinksql.contribution'; + +/** import contribution files */ +import 'monaco-sql-languages/esm/languages/mysql/mysql.contribution'; +import 'monaco-sql-languages/esm/languages/flink/flink.contribution'; +import 'monaco-sql-languages/esm/languages/spark/spark.contribution'; +import 'monaco-sql-languages/esm/languages/hive/hive.contribution'; +import 'monaco-sql-languages/esm/languages/trino/trino.contribution'; +import 'monaco-sql-languages/esm/languages/pgsql/pgsql.contribution'; +import 'monaco-sql-languages/esm/languages/impala/impala.contribution'; /** define MonacoEnvironment.getWorkerUrl */ (globalThis as any).MonacoEnvironment = { - getWorkerUrl: function (_: any, label: string) { + getWorkerUrl: function (_moduleId: string, label: string) { switch (label) { + case LanguageIdEnum.MYSQL: { + return './mysql.worker.js'; + } + case LanguageIdEnum.SPARK: { + return './spark.worker.js'; + } case LanguageIdEnum.FLINK: { - return './flinksql.worker.js'; + return './flink.worker.js'; + } + case LanguageIdEnum.HIVE: { + return './hive.worker.js'; + } + case LanguageIdEnum.TRINO: { + return './trino.worker.js'; + } + case LanguageIdEnum.PG: { + return './pgsql.worker.js'; + } + case LanguageIdEnum.IMPALA: { + return './impala.worker.js'; } default: { return './editor.worker.js'; diff --git a/samples/esm-plain-webpack/webpack.config.js b/samples/esm-plain-webpack/webpack.config.js index e8d7ca89..cc1a1548 100644 --- a/samples/esm-plain-webpack/webpack.config.js +++ b/samples/esm-plain-webpack/webpack.config.js @@ -7,8 +7,14 @@ module.exports = { entry: { index: path.resolve(__dirname, './src/index.ts'), // output worker file as entries - 'editor.worker': 'monaco-editor/esm/vs/editor/editor.worker.js', - 'flinksql.worker': 'monaco-sql-languages/out/esm/flinksql/flinksql.worker.js' + 'mysql.worker': 'monaco-sql-languages/esm/languages/mysql/mysql.worker.js', + 'flink.worker': 'monaco-sql-languages/esm/languages/flink/flink.worker.js', + 'spark.worker': 'monaco-sql-languages/esm/languages/spark/spark.worker.js', + 'hive.worker': 'monaco-sql-languages/esm/languages/hive/hive.worker.js', + 'trino.worker': 'monaco-sql-languages/esm/languages/trino/trino.worker.js', + 'pgsql.worker': 'monaco-sql-languages/esm/languages/pgsql/pgsql.worker.js', + 'impala.worker': 'monaco-sql-languages/esm/languages/impala/impala.worker.js', + 'editor.worker': 'monaco-editor/esm/vs/editor/editor.worker.js' }, output: { path: path.resolve(__dirname, './dist') diff --git a/samples/esm-plain-webpack/webpack.prod.config.js b/samples/esm-plain-webpack/webpack.prod.config.js index 2b5d6207..a1911b37 100644 --- a/samples/esm-plain-webpack/webpack.prod.config.js +++ b/samples/esm-plain-webpack/webpack.prod.config.js @@ -4,8 +4,5 @@ delete devConfig.devServer; delete devConfig.devtool; devConfig.mode = 'production'; -devConfig.optimization = { - minimize: false -}; module.exports = devConfig; diff --git a/samples/esm-vite/package-lock.json b/samples/esm-vite/package-lock.json index 7cd077a7..e549c006 100644 --- a/samples/esm-vite/package-lock.json +++ b/samples/esm-vite/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.0", "dependencies": { "monaco-editor": "0.31.0", - "monaco-sql-languages": "0.12.0-beta.ng.1", + "monaco-sql-languages": "0.12.0-beta.11", "react": "^18.2.0", "react-dom": "^18.2.0" }, @@ -1059,17 +1059,17 @@ } }, "node_modules/antlr4-c3": { - "version": "3.3.6", - "resolved": "https://registry.npmmirror.com/antlr4-c3/-/antlr4-c3-3.3.6.tgz", - "integrity": "sha512-gheQXG0acgFWKEqfHUxT1bC0tA/wxuy+F6452yhAkPEwkAAYZJWan3VNpvzAe1Fpg3IRiZn1vCRVur+O8MBHCQ==", + "version": "3.3.7", + "resolved": "https://registry.npmmirror.com/antlr4-c3/-/antlr4-c3-3.3.7.tgz", + "integrity": "sha512-F3ndE38wwA6z6AjUbL3heSdEGl4TxulGDPf9xB0/IY4dbRHWBh6XNaqFwur8vHKQk9FS5yNABHeg2wqlqIYO0w==", "dependencies": { - "antlr4ng": "2.0.10" + "antlr4ng": "2.0.11" } }, "node_modules/antlr4ng": { - "version": "2.0.10", - "resolved": "https://registry.npmmirror.com/antlr4ng/-/antlr4ng-2.0.10.tgz", - "integrity": "sha512-cDXmkjum5TSgtgKyKtNN3Zk8ebXeZXOHS7e5pIAnyuKdAQB1r/EzJl+1Vro5JdJCWfgtZ2IqJ3KNvRNuCMjgmQ==", + "version": "2.0.11", + "resolved": "https://registry.npmmirror.com/antlr4ng/-/antlr4ng-2.0.11.tgz", + "integrity": "sha512-9jM91VVtHSqHkAHQsXHaoaiewFETMvUTI1/tXvwTiFw4f7zke3IGlwEyoKN9NS0FqIwDKFvUNW2e1cKPniTkVQ==", "peerDependencies": { "antlr4ng-cli": "1.0.7" } @@ -1166,12 +1166,12 @@ } }, "node_modules/dt-sql-parser": { - "version": "4.0.0-ng.1", - "resolved": "https://registry.npmmirror.com/dt-sql-parser/-/dt-sql-parser-4.0.0-ng.1.tgz", - "integrity": "sha512-C4KqSNwNIGUR02YMFfQh8CwpPB/K4QjSlUkrv4swzQy6/ofrno6EWwOZ/OTo2wPRdk152fQJAQhYtbmmmW2MtQ==", + "version": "4.0.0-beta.4.12", + "resolved": "https://registry.npmmirror.com/dt-sql-parser/-/dt-sql-parser-4.0.0-beta.4.12.tgz", + "integrity": "sha512-kfLRecn+dfdZjrKt3Ovm52ryoh9UGF+dCjNzV2pk8XI5kgF7lgQJhPZdRi+2yn1AU/BWQ1/0E6LnvFYbZ7Wr9Q==", "dependencies": { - "antlr4-c3": "3.3.6", - "antlr4ng": "2.0.10" + "antlr4-c3": "3.3.7", + "antlr4ng": "2.0.11" } }, "node_modules/electron-to-chromium": { @@ -1331,11 +1331,11 @@ "integrity": "sha512-H3QmysEwxxY8oxmFhIFcY9JkuwilUDa6txdAxb797cVr7XFZX27a3SDwcGJmTlV9iGPwdh132r3KKCS5aNL4Gg==" }, "node_modules/monaco-sql-languages": { - "version": "0.12.0-beta.ng.1", - "resolved": "https://registry.npmmirror.com/monaco-sql-languages/-/monaco-sql-languages-0.12.0-beta.ng.1.tgz", - "integrity": "sha512-esi5t1Wd4JL7K4xTvEkLyYXMY011wzNSIsCStaORPX5VNgO7Bb6L/Cnj9vPZIyHPyY22Ewveeslhj9iFkaEZOg==", + "version": "0.12.0-beta.11", + "resolved": "https://registry.npmmirror.com/monaco-sql-languages/-/monaco-sql-languages-0.12.0-beta.11.tgz", + "integrity": "sha512-uOLS4cel6ngtU/Eh3nfswVqEapQ11q4Jszw8fNtGmGexjwflgNL4w2Dmn2XTsT1ebzN5vGKIuMljosnY2nKCRA==", "dependencies": { - "dt-sql-parser": "4.0.0-ng.1" + "dt-sql-parser": "4.0.0-beta.4.12" }, "peerDependencies": { "monaco-editor": ">=0.31.0" @@ -2233,17 +2233,17 @@ } }, "antlr4-c3": { - "version": "3.3.6", - "resolved": "https://registry.npmmirror.com/antlr4-c3/-/antlr4-c3-3.3.6.tgz", - "integrity": "sha512-gheQXG0acgFWKEqfHUxT1bC0tA/wxuy+F6452yhAkPEwkAAYZJWan3VNpvzAe1Fpg3IRiZn1vCRVur+O8MBHCQ==", + "version": "3.3.7", + "resolved": "https://registry.npmmirror.com/antlr4-c3/-/antlr4-c3-3.3.7.tgz", + "integrity": "sha512-F3ndE38wwA6z6AjUbL3heSdEGl4TxulGDPf9xB0/IY4dbRHWBh6XNaqFwur8vHKQk9FS5yNABHeg2wqlqIYO0w==", "requires": { - "antlr4ng": "2.0.10" + "antlr4ng": "2.0.11" } }, "antlr4ng": { - "version": "2.0.10", - "resolved": "https://registry.npmmirror.com/antlr4ng/-/antlr4ng-2.0.10.tgz", - "integrity": "sha512-cDXmkjum5TSgtgKyKtNN3Zk8ebXeZXOHS7e5pIAnyuKdAQB1r/EzJl+1Vro5JdJCWfgtZ2IqJ3KNvRNuCMjgmQ==", + "version": "2.0.11", + "resolved": "https://registry.npmmirror.com/antlr4ng/-/antlr4ng-2.0.11.tgz", + "integrity": "sha512-9jM91VVtHSqHkAHQsXHaoaiewFETMvUTI1/tXvwTiFw4f7zke3IGlwEyoKN9NS0FqIwDKFvUNW2e1cKPniTkVQ==", "requires": {} }, "antlr4ng-cli": { @@ -2318,12 +2318,12 @@ } }, "dt-sql-parser": { - "version": "4.0.0-ng.1", - "resolved": "https://registry.npmmirror.com/dt-sql-parser/-/dt-sql-parser-4.0.0-ng.1.tgz", - "integrity": "sha512-C4KqSNwNIGUR02YMFfQh8CwpPB/K4QjSlUkrv4swzQy6/ofrno6EWwOZ/OTo2wPRdk152fQJAQhYtbmmmW2MtQ==", + "version": "4.0.0-beta.4.12", + "resolved": "https://registry.npmmirror.com/dt-sql-parser/-/dt-sql-parser-4.0.0-beta.4.12.tgz", + "integrity": "sha512-kfLRecn+dfdZjrKt3Ovm52ryoh9UGF+dCjNzV2pk8XI5kgF7lgQJhPZdRi+2yn1AU/BWQ1/0E6LnvFYbZ7Wr9Q==", "requires": { - "antlr4-c3": "3.3.6", - "antlr4ng": "2.0.10" + "antlr4-c3": "3.3.7", + "antlr4ng": "2.0.11" } }, "electron-to-chromium": { @@ -2439,11 +2439,11 @@ "integrity": "sha512-H3QmysEwxxY8oxmFhIFcY9JkuwilUDa6txdAxb797cVr7XFZX27a3SDwcGJmTlV9iGPwdh132r3KKCS5aNL4Gg==" }, "monaco-sql-languages": { - "version": "0.12.0-beta.ng.1", - "resolved": "https://registry.npmmirror.com/monaco-sql-languages/-/monaco-sql-languages-0.12.0-beta.ng.1.tgz", - "integrity": "sha512-esi5t1Wd4JL7K4xTvEkLyYXMY011wzNSIsCStaORPX5VNgO7Bb6L/Cnj9vPZIyHPyY22Ewveeslhj9iFkaEZOg==", + "version": "0.12.0-beta.11", + "resolved": "https://registry.npmmirror.com/monaco-sql-languages/-/monaco-sql-languages-0.12.0-beta.11.tgz", + "integrity": "sha512-uOLS4cel6ngtU/Eh3nfswVqEapQ11q4Jszw8fNtGmGexjwflgNL4w2Dmn2XTsT1ebzN5vGKIuMljosnY2nKCRA==", "requires": { - "dt-sql-parser": "4.0.0-ng.1" + "dt-sql-parser": "4.0.0-beta.4.12" } }, "ms": { diff --git a/samples/esm-vite/package.json b/samples/esm-vite/package.json index 873b72cf..95e9fcab 100644 --- a/samples/esm-vite/package.json +++ b/samples/esm-vite/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "monaco-editor": "0.31.0", - "monaco-sql-languages": "0.12.0-beta.ng.1", + "monaco-sql-languages": "0.12.0-beta.11", "react": "^18.2.0", "react-dom": "^18.2.0" }, diff --git a/samples/esm-vite/src/App.tsx b/samples/esm-vite/src/App.tsx index 87795afe..17f5f098 100644 --- a/samples/esm-vite/src/App.tsx +++ b/samples/esm-vite/src/App.tsx @@ -1,22 +1,74 @@ import * as monaco from 'monaco-editor'; -import { useEffect, useRef } from 'react'; +import { useEffect, useRef, useState } from 'react'; import { LanguageIdEnum } from 'monaco-sql-languages'; +import './languageSetup.ts'; const App = () => { const hostRef = useRef(null); const editorRef = useRef(); + const [lang, setLang] = useState(LanguageIdEnum.FLINK); useEffect(() => { if (hostRef.current && !editorRef.current) { editorRef.current = monaco.editor.create(hostRef.current, { - language: LanguageIdEnum.FLINK + language: lang }); } }, []); + useEffect(() => { + const model = editorRef.current?.getModel(); + if (model && model.getLanguageId() !== lang) { + monaco.editor.setModelLanguage(model, lang); + setTimeout(() => { + console.log( + 'language changed, current is: ', + editorRef.current?.getModel()?.getLanguageId() + ); + }, 200); + } + }, [lang]); + return ( <> -

FlinkSQL Demo

+

ESM Vite Demo

+
+ +