Converted codemirror languges to new packages where available

Does increase bundle size massively though, Will need to think about
solutions for this.
This commit is contained in:
Dan Brown 2022-08-04 13:33:51 +01:00
parent 97146a6359
commit 4757ed9453
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
3 changed files with 253 additions and 27 deletions

217
package-lock.json generated
View file

@ -6,11 +6,18 @@
"": {
"dependencies": {
"@codemirror/commands": "^6.0.1",
"@codemirror/lang-cpp": "^6.0.1",
"@codemirror/lang-css": "^6.0.0",
"@codemirror/lang-html": "^6.1.0",
"@codemirror/lang-java": "^6.0.0",
"@codemirror/lang-javascript": "^6.0.2",
"@codemirror/lang-json": "^6.0.0",
"@codemirror/lang-markdown": "^6.0.1",
"@codemirror/lang-php": "^6.0.0",
"@codemirror/lang-python": "^6.0.1",
"@codemirror/lang-rust": "^6.0.0",
"@codemirror/lang-sql": "^6.0.0",
"@codemirror/lang-xml": "^6.0.0",
"@codemirror/language": "^6.2.1",
"@codemirror/legacy-modes": "^6.1.0",
"@codemirror/state": "^6.1.0",
@ -60,6 +67,15 @@
"@lezer/common": "^1.0.0"
}
},
"node_modules/@codemirror/lang-cpp": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/@codemirror/lang-cpp/-/lang-cpp-6.0.1.tgz",
"integrity": "sha512-46p3ohfhjzkLWJ3VwvzX0aqlXh8UkEqX1xo2Eds9l6Ql3uDoxI2IZEjR9cgJaGOZTXCkDzQuQH7sfYAxMvzLjA==",
"dependencies": {
"@codemirror/language": "^6.0.0",
"@lezer/cpp": "^1.0.0"
}
},
"node_modules/@codemirror/lang-css": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@codemirror/lang-css/-/lang-css-6.0.0.tgz",
@ -85,6 +101,15 @@
"@lezer/html": "^1.0.0"
}
},
"node_modules/@codemirror/lang-java": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@codemirror/lang-java/-/lang-java-6.0.0.tgz",
"integrity": "sha512-aeWq+ikUS6Eubk6RBbiMgxuBIT4Ih8Asb1qc2pSiMcstrwr4ODbazPXsBHbLBYg3aObvFyOm2bNQncbQJjZ3sQ==",
"dependencies": {
"@codemirror/language": "^6.0.0",
"@lezer/java": "^1.0.0"
}
},
"node_modules/@codemirror/lang-javascript": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.0.2.tgz",
@ -133,6 +158,48 @@
"@lezer/php": "^1.0.0"
}
},
"node_modules/@codemirror/lang-python": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/@codemirror/lang-python/-/lang-python-6.0.1.tgz",
"integrity": "sha512-w2jTSY+LgXnK7iIBLgMxk6xtJhZHkcxcGGveuq9zYmncURmOTFXKnDvBaBClNIHKgjkHXZqGK8ZduCMK23hZPA==",
"dependencies": {
"@codemirror/language": "^6.0.0",
"@lezer/python": "^1.0.0"
}
},
"node_modules/@codemirror/lang-rust": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@codemirror/lang-rust/-/lang-rust-6.0.0.tgz",
"integrity": "sha512-VQql3Qk1BwoXb3SUkeWll/EEwhsgQWc1bpia7CFqqp2PhQBb5A6r4Vj2JCkU/nE6A7TDPSGHTOoqJSG5s/VXtQ==",
"dependencies": {
"@codemirror/language": "^6.0.0",
"@lezer/rust": "^1.0.0"
}
},
"node_modules/@codemirror/lang-sql": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@codemirror/lang-sql/-/lang-sql-6.0.0.tgz",
"integrity": "sha512-mq4NwTDbbo7QZktfgPsS+ms0FmAceH4WM2jLbgf+N28FoKUy0JzGe3XJymgnTewXnNUwujKBxArQzibxSDdVyQ==",
"dependencies": {
"@codemirror/autocomplete": "^6.0.0",
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"node_modules/@codemirror/lang-xml": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@codemirror/lang-xml/-/lang-xml-6.0.0.tgz",
"integrity": "sha512-M/HLWxIiP956xGjtrxkeHkCmDGVQGKu782x8pOH5CLJIMkWtiB1DWfDoDHqpFjdEE9dkfcqPWvYfVi6GbhuXEg==",
"dependencies": {
"@codemirror/autocomplete": "^6.0.0",
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@lezer/common": "^1.0.0",
"@lezer/xml": "^1.0.0"
}
},
"node_modules/@codemirror/language": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.2.1.tgz",
@ -194,6 +261,15 @@
"resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.0.0.tgz",
"integrity": "sha512-ohydQe+Hb+w4oMDvXzs8uuJd2NoA3D8YDcLiuDsLqH+yflDTPEpgCsWI3/6rH5C3BAedtH1/R51dxENldQceEA=="
},
"node_modules/@lezer/cpp": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@lezer/cpp/-/cpp-1.0.0.tgz",
"integrity": "sha512-Klk3/AIEKoptmm6cNm7xTulNXjdTKkD+hVOEcz/NeRg8tIestP5hsGHJeFDR/XtyDTxsjoPjKZRIGohht7zbKw==",
"dependencies": {
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"node_modules/@lezer/css": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.0.0.tgz",
@ -221,6 +297,15 @@
"@lezer/lr": "^1.0.0"
}
},
"node_modules/@lezer/java": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@lezer/java/-/java-1.0.0.tgz",
"integrity": "sha512-z2EA0JHq2WoiKfQy5uOOd4t17PJtq8guh58gPkSzOnNcQ7DNbkrU+Axak+jL8+Noinwyz2tRNOseQFj+Tg+P0A==",
"dependencies": {
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"node_modules/@lezer/javascript": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.0.2.tgz",
@ -265,6 +350,33 @@
"@lezer/lr": "^1.0.0"
}
},
"node_modules/@lezer/python": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@lezer/python/-/python-1.1.0.tgz",
"integrity": "sha512-FVPp2usfj3zZuc+2RidXAY94WAcsHQ3dbKDbXuZgoAwUungAcXwd3EWXiWQvwNqbae+ek51bWi8dwbiQqweWCg==",
"dependencies": {
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"node_modules/@lezer/rust": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@lezer/rust/-/rust-1.0.0.tgz",
"integrity": "sha512-IpGAxIjNxYmX9ra6GfQTSPegdCAWNeq23WNmrsMMQI7YNSvKtYxO4TX5rgZUmbhEucWn0KTBMeDEPXg99YKtTA==",
"dependencies": {
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"node_modules/@lezer/xml": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@lezer/xml/-/xml-1.0.0.tgz",
"integrity": "sha512-73iI9UK8iqSvWtLlOEl/g+50ivwQn8Ge6foHVN66AXUS1RccFnAoc7BYU8b3c8/rP6dfCOGqAGaWLxBzhj60MA==",
"dependencies": {
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"node_modules/ansi-regex": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz",
@ -2186,6 +2298,15 @@
"@lezer/common": "^1.0.0"
}
},
"@codemirror/lang-cpp": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/@codemirror/lang-cpp/-/lang-cpp-6.0.1.tgz",
"integrity": "sha512-46p3ohfhjzkLWJ3VwvzX0aqlXh8UkEqX1xo2Eds9l6Ql3uDoxI2IZEjR9cgJaGOZTXCkDzQuQH7sfYAxMvzLjA==",
"requires": {
"@codemirror/language": "^6.0.0",
"@lezer/cpp": "^1.0.0"
}
},
"@codemirror/lang-css": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@codemirror/lang-css/-/lang-css-6.0.0.tgz",
@ -2211,6 +2332,15 @@
"@lezer/html": "^1.0.0"
}
},
"@codemirror/lang-java": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@codemirror/lang-java/-/lang-java-6.0.0.tgz",
"integrity": "sha512-aeWq+ikUS6Eubk6RBbiMgxuBIT4Ih8Asb1qc2pSiMcstrwr4ODbazPXsBHbLBYg3aObvFyOm2bNQncbQJjZ3sQ==",
"requires": {
"@codemirror/language": "^6.0.0",
"@lezer/java": "^1.0.0"
}
},
"@codemirror/lang-javascript": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.0.2.tgz",
@ -2259,6 +2389,48 @@
"@lezer/php": "^1.0.0"
}
},
"@codemirror/lang-python": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/@codemirror/lang-python/-/lang-python-6.0.1.tgz",
"integrity": "sha512-w2jTSY+LgXnK7iIBLgMxk6xtJhZHkcxcGGveuq9zYmncURmOTFXKnDvBaBClNIHKgjkHXZqGK8ZduCMK23hZPA==",
"requires": {
"@codemirror/language": "^6.0.0",
"@lezer/python": "^1.0.0"
}
},
"@codemirror/lang-rust": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@codemirror/lang-rust/-/lang-rust-6.0.0.tgz",
"integrity": "sha512-VQql3Qk1BwoXb3SUkeWll/EEwhsgQWc1bpia7CFqqp2PhQBb5A6r4Vj2JCkU/nE6A7TDPSGHTOoqJSG5s/VXtQ==",
"requires": {
"@codemirror/language": "^6.0.0",
"@lezer/rust": "^1.0.0"
}
},
"@codemirror/lang-sql": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@codemirror/lang-sql/-/lang-sql-6.0.0.tgz",
"integrity": "sha512-mq4NwTDbbo7QZktfgPsS+ms0FmAceH4WM2jLbgf+N28FoKUy0JzGe3XJymgnTewXnNUwujKBxArQzibxSDdVyQ==",
"requires": {
"@codemirror/autocomplete": "^6.0.0",
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"@codemirror/lang-xml": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@codemirror/lang-xml/-/lang-xml-6.0.0.tgz",
"integrity": "sha512-M/HLWxIiP956xGjtrxkeHkCmDGVQGKu782x8pOH5CLJIMkWtiB1DWfDoDHqpFjdEE9dkfcqPWvYfVi6GbhuXEg==",
"requires": {
"@codemirror/autocomplete": "^6.0.0",
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@lezer/common": "^1.0.0",
"@lezer/xml": "^1.0.0"
}
},
"@codemirror/language": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.2.1.tgz",
@ -2320,6 +2492,15 @@
"resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.0.0.tgz",
"integrity": "sha512-ohydQe+Hb+w4oMDvXzs8uuJd2NoA3D8YDcLiuDsLqH+yflDTPEpgCsWI3/6rH5C3BAedtH1/R51dxENldQceEA=="
},
"@lezer/cpp": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@lezer/cpp/-/cpp-1.0.0.tgz",
"integrity": "sha512-Klk3/AIEKoptmm6cNm7xTulNXjdTKkD+hVOEcz/NeRg8tIestP5hsGHJeFDR/XtyDTxsjoPjKZRIGohht7zbKw==",
"requires": {
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"@lezer/css": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.0.0.tgz",
@ -2347,6 +2528,15 @@
"@lezer/lr": "^1.0.0"
}
},
"@lezer/java": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@lezer/java/-/java-1.0.0.tgz",
"integrity": "sha512-z2EA0JHq2WoiKfQy5uOOd4t17PJtq8guh58gPkSzOnNcQ7DNbkrU+Axak+jL8+Noinwyz2tRNOseQFj+Tg+P0A==",
"requires": {
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"@lezer/javascript": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.0.2.tgz",
@ -2391,6 +2581,33 @@
"@lezer/lr": "^1.0.0"
}
},
"@lezer/python": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@lezer/python/-/python-1.1.0.tgz",
"integrity": "sha512-FVPp2usfj3zZuc+2RidXAY94WAcsHQ3dbKDbXuZgoAwUungAcXwd3EWXiWQvwNqbae+ek51bWi8dwbiQqweWCg==",
"requires": {
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"@lezer/rust": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@lezer/rust/-/rust-1.0.0.tgz",
"integrity": "sha512-IpGAxIjNxYmX9ra6GfQTSPegdCAWNeq23WNmrsMMQI7YNSvKtYxO4TX5rgZUmbhEucWn0KTBMeDEPXg99YKtTA==",
"requires": {
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"@lezer/xml": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@lezer/xml/-/xml-1.0.0.tgz",
"integrity": "sha512-73iI9UK8iqSvWtLlOEl/g+50ivwQn8Ge6foHVN66AXUS1RccFnAoc7BYU8b3c8/rP6dfCOGqAGaWLxBzhj60MA==",
"requires": {
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"ansi-regex": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz",

View file

@ -24,11 +24,18 @@
},
"dependencies": {
"@codemirror/commands": "^6.0.1",
"@codemirror/lang-cpp": "^6.0.1",
"@codemirror/lang-css": "^6.0.0",
"@codemirror/lang-html": "^6.1.0",
"@codemirror/lang-java": "^6.0.0",
"@codemirror/lang-javascript": "^6.0.2",
"@codemirror/lang-json": "^6.0.0",
"@codemirror/lang-markdown": "^6.0.1",
"@codemirror/lang-php": "^6.0.0",
"@codemirror/lang-python": "^6.0.1",
"@codemirror/lang-rust": "^6.0.0",
"@codemirror/lang-sql": "^6.0.0",
"@codemirror/lang-xml": "^6.0.0",
"@codemirror/language": "^6.2.1",
"@codemirror/legacy-modes": "^6.1.0",
"@codemirror/state": "^6.1.0",

View file

@ -1,12 +1,14 @@
import {StreamLanguage} from "@codemirror/language"
import {css} from '@codemirror/legacy-modes/mode/css';
import {c, java, cpp, csharp, kotlin, scala} from '@codemirror/legacy-modes/mode/clike';
import {css} from '@codemirror/lang-css';
import {c, csharp, kotlin, scala} from '@codemirror/legacy-modes/mode/clike';
import {cpp} from '@codemirror/lang-cpp';
import {diff} from '@codemirror/legacy-modes/mode/diff';
import {fortran} from '@codemirror/legacy-modes/mode/fortran';
import {go} from '@codemirror/legacy-modes/mode/go';
import {haskell} from '@codemirror/legacy-modes/mode/haskell';
import {html} from '@codemirror/lang-html';
import {java} from '@codemirror/lang-java';
import {javascript} from '@codemirror/lang-javascript';
import {json} from '@codemirror/lang-json';
import {julia} from '@codemirror/legacy-modes/mode/julia';
@ -19,16 +21,16 @@ import {pascal} from '@codemirror/legacy-modes/mode/pascal';
import {php} from '@codemirror/lang-php';
import {powerShell} from '@codemirror/legacy-modes/mode/powershell';
import {properties} from '@codemirror/legacy-modes/mode/properties';
import {python} from '@codemirror/legacy-modes/mode/python';
import {python} from '@codemirror/lang-python';
import {ruby} from '@codemirror/legacy-modes/mode/ruby';
import {rust} from '@codemirror/legacy-modes/mode/rust';
import {rust} from '@codemirror/lang-rust';
import {shell} from '@codemirror/legacy-modes/mode/shell';
import {sql} from '@codemirror/legacy-modes/mode/sql';
import {sql} from '@codemirror/lang-sql';
import {stex} from '@codemirror/legacy-modes/mode/stex';
import {toml} from '@codemirror/legacy-modes/mode/toml';
import {vb} from '@codemirror/legacy-modes/mode/vb';
import {vbScript} from '@codemirror/legacy-modes/mode/vbscript';
import {xml} from '@codemirror/legacy-modes/mode/xml';
import {xml} from '@codemirror/lang-xml';
import {yaml} from '@codemirror/legacy-modes/mode/yaml';
@ -37,12 +39,9 @@ import {yaml} from '@codemirror/legacy-modes/mode/yaml';
// The function option is used in the event the exact mode could be dynamic depending on the code.
const modeMap = {
bash: () => StreamLanguage.define(shell),
css: () => StreamLanguage.define(css),
c: () => StreamLanguage.define(c),
java: () => StreamLanguage.define(java),
scala: () => StreamLanguage.define(scala),
kotlin: () => StreamLanguage.define(kotlin),
'c++': () => StreamLanguage.define(cpp),
css: () => css(),
'c++': () => cpp(),
'c#': () => StreamLanguage.define(csharp),
csharp: () => StreamLanguage.define(csharp),
diff: () => StreamLanguage.define(diff),
@ -55,47 +54,50 @@ const modeMap = {
hs: () => StreamLanguage.define(haskell),
html: () => html(),
ini: () => StreamLanguage.define(properties),
java: () => java(),
javascript: () => javascript(),
json: () => json(),
js: () => javascript(),
jl: () => StreamLanguage.define(julia),
julia: () => StreamLanguage.define(julia),
kotlin: () => StreamLanguage.define(kotlin),
latex: () => StreamLanguage.define(stex),
lua: () => StreamLanguage.define(lua),
md: () => StreamLanguage.define(markdown),
mdown: () => StreamLanguage.define(markdown),
markdown: () => StreamLanguage.define(markdown),
markdown: () => markdown(),
md: () => markdown(),
mdown: () => markdown(),
ml: () => StreamLanguage.define(sml),
nginx: () => StreamLanguage.define(nginx),
perl: () => StreamLanguage.define(perl),
pl: () => StreamLanguage.define(perl),
powershell: () => StreamLanguage.define(powerShell),
properties: () => StreamLanguage.define(properties),
ocaml: () => StreamLanguage.define(oCaml),
pascal: () => StreamLanguage.define(pascal),
pas: () => StreamLanguage.define(pascal),
pascal: () => StreamLanguage.define(pascal),
perl: () => StreamLanguage.define(perl),
php: (code) => {
const hasTags = code.includes('<?php');
return php({plain: !hasTags});
},
py: () => StreamLanguage.define(python),
python: () => StreamLanguage.define(python),
ruby: () => StreamLanguage.define(ruby),
rust: () => StreamLanguage.define(rust),
pl: () => StreamLanguage.define(perl),
powershell: () => StreamLanguage.define(powerShell),
properties: () => StreamLanguage.define(properties),
ocaml: () => StreamLanguage.define(oCaml),
py: () => python(),
python: () => python(),
rb: () => StreamLanguage.define(ruby),
rs: () => StreamLanguage.define(rust),
rs: () => rust(),
ruby: () => StreamLanguage.define(ruby),
rust: () => rust(),
scala: () => StreamLanguage.define(scala),
shell: () => StreamLanguage.define(shell),
sh: () => StreamLanguage.define(shell),
stext: () => StreamLanguage.define(stex),
toml: () => StreamLanguage.define(toml),
ts: () => javascript({typescript: true}),
typescript: () => javascript({typescript: true}),
sql: () => StreamLanguage.define(sql),
sql: () => sql(),
vbs: () => StreamLanguage.define(vbScript),
vbscript: () => StreamLanguage.define(vbScript),
'vb.net': () => StreamLanguage.define(vb),
vbnet: () => StreamLanguage.define(vb),
xml: () => StreamLanguage.define(xml),
xml: () => xml(),
yaml: () => StreamLanguage.define(yaml),
yml: () => StreamLanguage.define(yaml),
};