securemark 0.280.7 → 0.280.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/design.md +1 -1
- package/dist/index.js +1215 -1823
- package/package.json +25 -23
- package/src/parser/api/cache.ts +22 -4
- package/src/parser/processor/note.ts +26 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "securemark",
|
|
3
|
-
"version": "0.280.
|
|
3
|
+
"version": "0.280.9",
|
|
4
4
|
"description": "Secure markdown renderer working on browsers for user input data.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/falsandtru/securemark",
|
|
@@ -27,37 +27,39 @@
|
|
|
27
27
|
"NOTICE",
|
|
28
28
|
"LICENSE"
|
|
29
29
|
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"spica": "0.0.781"
|
|
32
|
+
},
|
|
30
33
|
"devDependencies": {
|
|
31
|
-
"@types/dompurify": "3.0.
|
|
32
|
-
"@types/jquery": "3.5.
|
|
33
|
-
"@types/mathjax": "0.0.
|
|
34
|
-
"@types/mocha": "10.0.
|
|
35
|
-
"@types/power-assert": "1.5.
|
|
36
|
-
"@types/prismjs": "1.26.
|
|
37
|
-
"@typescript-eslint/parser": "^
|
|
38
|
-
"babel-loader": "^9.1.
|
|
34
|
+
"@types/dompurify": "3.0.5",
|
|
35
|
+
"@types/jquery": "3.5.29",
|
|
36
|
+
"@types/mathjax": "0.0.40",
|
|
37
|
+
"@types/mocha": "10.0.6",
|
|
38
|
+
"@types/power-assert": "1.5.12",
|
|
39
|
+
"@types/prismjs": "1.26.3",
|
|
40
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
41
|
+
"babel-loader": "^9.1.3",
|
|
39
42
|
"babel-plugin-unassert": "^3.2.0",
|
|
40
|
-
"concurrently": "^8.
|
|
41
|
-
"eslint": "^8.
|
|
43
|
+
"concurrently": "^8.2.2",
|
|
44
|
+
"eslint": "^8.56.0",
|
|
42
45
|
"eslint-plugin-redos": "^4.4.5",
|
|
43
46
|
"eslint-webpack-plugin": "^4.0.1",
|
|
44
|
-
"glob": "^10.
|
|
47
|
+
"glob": "^10.3.10",
|
|
45
48
|
"karma": "^6.4.2",
|
|
46
49
|
"karma-chrome-launcher": "^3.2.0",
|
|
47
|
-
"karma-coverage": "^2.2.
|
|
50
|
+
"karma-coverage": "^2.2.1",
|
|
48
51
|
"karma-firefox-launcher": "^2.1.2",
|
|
49
52
|
"karma-mocha": "^2.0.1",
|
|
50
53
|
"karma-power-assert": "^1.0.0",
|
|
51
|
-
"mocha": "^10.
|
|
52
|
-
"npm-check-updates": "^16.
|
|
53
|
-
"semver": "^7.
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"webpack": "^5.
|
|
59
|
-
"webpack-
|
|
60
|
-
"webpack-merge": "^5.9.0"
|
|
54
|
+
"mocha": "^10.3.0",
|
|
55
|
+
"npm-check-updates": "^16.14.15",
|
|
56
|
+
"semver": "^7.6.0",
|
|
57
|
+
"ts-loader": "^9.5.1",
|
|
58
|
+
"typed-dom": "0.0.348",
|
|
59
|
+
"typescript": "5.3.3",
|
|
60
|
+
"webpack": "^5.90.1",
|
|
61
|
+
"webpack-cli": "^5.1.4",
|
|
62
|
+
"webpack-merge": "^5.10.0"
|
|
61
63
|
},
|
|
62
64
|
"scripts": {
|
|
63
65
|
"update": "ncu -u && npm i --no-shrinkwrap && bundle update",
|
package/src/parser/api/cache.ts
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import { Caches } from '../../..';
|
|
2
|
-
import {
|
|
2
|
+
import { Clock } from 'spica/clock';
|
|
3
|
+
import { TLRU } from 'spica/tlru';
|
|
3
4
|
|
|
4
5
|
// For rerendering in editing.
|
|
5
6
|
|
|
7
|
+
/*
|
|
8
|
+
同一文書内で複数回使用される可能性が低いデータ: Clock
|
|
9
|
+
同一文書内で複数回使用される可能性が高いデータ: TLRU
|
|
10
|
+
|
|
11
|
+
編集時の再描画高速化が主目的であるためブロックを周期とするループおよび
|
|
12
|
+
異なるブロックへのジャンプに適したアルゴリズムを使用。
|
|
13
|
+
キャッシュサイズはブロック内の全データをキャッシュできなければならない。
|
|
14
|
+
キャッシュサイズは100あれば足りるが10,000までは速度低下しないようなので
|
|
15
|
+
データサイズを加味して100から1,000とする。
|
|
16
|
+
遠くで少数の同じデータを高速描画してもあまり意味はない。
|
|
17
|
+
タイムラインとスレッドのmediaにおいても多数の同一データが長周期で複数回表示
|
|
18
|
+
される適切な状況はないと思われる。
|
|
19
|
+
同一投稿は頻繁に再送されてはならずスパムは削除されなければならず
|
|
20
|
+
ジャーゴンは考慮に値しない。
|
|
21
|
+
|
|
22
|
+
*/
|
|
23
|
+
|
|
6
24
|
export const caches: Caches = {
|
|
7
|
-
code: new
|
|
8
|
-
math: new
|
|
9
|
-
media: new
|
|
25
|
+
code: new Clock<string, HTMLElement>(1000),
|
|
26
|
+
math: new TLRU<string, HTMLElement>(1000),
|
|
27
|
+
media: new Clock<string, HTMLElement>(100),
|
|
10
28
|
} as const;
|
|
@@ -180,37 +180,37 @@ function build(
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
+
}
|
|
183
184
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
while (length > size) {
|
|
194
|
-
const node = children[count - 1] as HTMLLIElement;
|
|
195
|
-
if (equal(node, def)) continue I;
|
|
196
|
-
yield note.removeChild(node);
|
|
197
|
-
--length;
|
|
198
|
-
assert(children.length === length);
|
|
199
|
-
}
|
|
200
|
-
const node = count <= length
|
|
201
|
-
? children[count - 1]
|
|
202
|
-
: null;
|
|
203
|
-
if (node && equal(node, def)) continue;
|
|
204
|
-
assert(def.parentNode !== note);
|
|
205
|
-
yield note.insertBefore(def, node);
|
|
206
|
-
++length;
|
|
207
|
-
assert(children.length === length);
|
|
208
|
-
}
|
|
185
|
+
function* proc(defs: Map<string, HTMLLIElement>, note: HTMLOListElement): Generator<HTMLLIElement | undefined, undefined, undefined> {
|
|
186
|
+
const { children } = note;
|
|
187
|
+
const size = defs.size;
|
|
188
|
+
let count = 0;
|
|
189
|
+
let length = children.length;
|
|
190
|
+
I:
|
|
191
|
+
for (const [key, def] of defs) {
|
|
192
|
+
defs.delete(key);
|
|
193
|
+
++count;
|
|
209
194
|
while (length > size) {
|
|
210
|
-
|
|
195
|
+
const node = children[count - 1] as HTMLLIElement;
|
|
196
|
+
if (equal(node, def)) continue I;
|
|
197
|
+
yield note.removeChild(node);
|
|
211
198
|
--length;
|
|
212
199
|
assert(children.length === length);
|
|
213
200
|
}
|
|
201
|
+
const node = count <= length
|
|
202
|
+
? children[count - 1]
|
|
203
|
+
: null;
|
|
204
|
+
if (node && equal(node, def)) continue;
|
|
205
|
+
assert(def.parentNode !== note);
|
|
206
|
+
yield note.insertBefore(def, node);
|
|
207
|
+
++length;
|
|
208
|
+
assert(children.length === length);
|
|
209
|
+
}
|
|
210
|
+
while (length > size) {
|
|
211
|
+
yield note.removeChild(children[size] as HTMLLIElement);
|
|
212
|
+
--length;
|
|
213
|
+
assert(children.length === length);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
|