aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/code/package-lock.json11
-rw-r--r--editors/code/package.json2
-rw-r--r--editors/code/src/highlighting.ts25
-rw-r--r--editors/code/tsconfig.json3
4 files changed, 23 insertions, 18 deletions
diff --git a/editors/code/package-lock.json b/editors/code/package-lock.json
index 712153c34..0760f870c 100644
--- a/editors/code/package-lock.json
+++ b/editors/code/package-lock.json
@@ -98,12 +98,6 @@
98 "@types/node": "*" 98 "@types/node": "*"
99 } 99 }
100 }, 100 },
101 "@types/seedrandom": {
102 "version": "2.4.28",
103 "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-2.4.28.tgz",
104 "integrity": "sha512-SMA+fUwULwK7sd/ZJicUztiPs8F1yCPwF3O23Z9uQ32ME5Ha0NmDK9+QTsYE4O2tHXChzXomSWWeIhCnoN1LqA==",
105 "dev": true
106 },
107 "@types/vscode": { 101 "@types/vscode": {
108 "version": "1.41.0", 102 "version": "1.41.0",
109 "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.41.0.tgz", 103 "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.41.0.tgz",
@@ -691,11 +685,6 @@
691 "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", 685 "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==",
692 "dev": true 686 "dev": true
693 }, 687 },
694 "seedrandom": {
695 "version": "3.0.5",
696 "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-3.0.5.tgz",
697 "integrity": "sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg=="
698 },
699 "semver": { 688 "semver": {
700 "version": "6.3.0", 689 "version": "6.3.0",
701 "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", 690 "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
diff --git a/editors/code/package.json b/editors/code/package.json
index 06aa747fe..a46b0a82b 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -25,7 +25,6 @@
25 }, 25 },
26 "dependencies": { 26 "dependencies": {
27 "jsonc-parser": "^2.1.0", 27 "jsonc-parser": "^2.1.0",
28 "seedrandom": "^3.0.5",
29 "vscode-languageclient": "^6.1.0" 28 "vscode-languageclient": "^6.1.0"
30 }, 29 },
31 "devDependencies": { 30 "devDependencies": {
@@ -33,7 +32,6 @@
33 "@rollup/plugin-node-resolve": "^6.1.0", 32 "@rollup/plugin-node-resolve": "^6.1.0",
34 "@rollup/plugin-typescript": "^2.0.0", 33 "@rollup/plugin-typescript": "^2.0.0",
35 "@types/node": "^12.12.25", 34 "@types/node": "^12.12.25",
36 "@types/seedrandom": "^2.4.28",
37 "@types/vscode": "^1.41.0", 35 "@types/vscode": "^1.41.0",
38 "rollup": "^1.30.1", 36 "rollup": "^1.30.1",
39 "tslib": "^1.10.0", 37 "tslib": "^1.10.0",
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts
index 3d190c3ad..66216e0fc 100644
--- a/editors/code/src/highlighting.ts
+++ b/editors/code/src/highlighting.ts
@@ -1,6 +1,5 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient'; 2import * as lc from 'vscode-languageclient';
3import seedrandom from 'seedrandom';
4 3
5import { ColorTheme, TextMateRuleSettings } from './color_theme'; 4import { ColorTheme, TextMateRuleSettings } from './color_theme';
6 5
@@ -70,9 +69,9 @@ interface Decoration {
70 69
71// Based on this HSL-based color generator: https://gist.github.com/bendc/76c48ce53299e6078a76 70// Based on this HSL-based color generator: https://gist.github.com/bendc/76c48ce53299e6078a76
72function fancify(seed: string, shade: 'light' | 'dark') { 71function fancify(seed: string, shade: 'light' | 'dark') {
73 const random = seedrandom(seed); 72 const random = randomU32Numbers(hashString(seed))
74 const randomInt = (min: number, max: number) => { 73 const randomInt = (min: number, max: number) => {
75 return Math.floor(random() * (max - min + 1)) + min; 74 return Math.abs(random()) % (max - min + 1) + min;
76 }; 75 };
77 76
78 const h = randomInt(0, 360); 77 const h = randomInt(0, 360);
@@ -246,3 +245,23 @@ const TAG_TO_SCOPES = new Map<string, string[]>([
246 ["keyword.unsafe", ["keyword.other.unsafe"]], 245 ["keyword.unsafe", ["keyword.other.unsafe"]],
247 ["keyword.control", ["keyword.control"]], 246 ["keyword.control", ["keyword.control"]],
248]); 247]);
248
249function randomU32Numbers(seed: number) {
250 let random = seed | 0;
251 return () => {
252 random ^= random << 13;
253 random ^= random >> 17;
254 random ^= random << 5;
255 random |= 0;
256 return random
257 }
258}
259
260function hashString(str: string): number {
261 let res = 0;
262 for (let i = 0; i < str.length; ++i) {
263 const c = str.codePointAt(i)!!;
264 res = (res * 31 + c) & ~0;
265 }
266 return res;
267}
diff --git a/editors/code/tsconfig.json b/editors/code/tsconfig.json
index d74169c29..e60eb8e5e 100644
--- a/editors/code/tsconfig.json
+++ b/editors/code/tsconfig.json
@@ -13,8 +13,7 @@
13 "noUnusedParameters": true, 13 "noUnusedParameters": true,
14 "noImplicitReturns": true, 14 "noImplicitReturns": true,
15 "noFallthroughCasesInSwitch": true, 15 "noFallthroughCasesInSwitch": true,
16 "newLine": "LF", 16 "newLine": "LF"
17 "esModuleInterop": true
18 }, 17 },
19 "exclude": [ 18 "exclude": [
20 "node_modules" 19 "node_modules"