@xpadev-net/niconicomments 0.2.36 → 0.2.38
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/LICENSE_JP +11 -0
- package/README.en.md +2 -0
- package/README.md +2 -0
- package/dist/bundle.d.ts +273 -180
- package/dist/bundle.js +132 -88
- package/package.json +2 -1
package/LICENSE_JP
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
===============
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2021 xpadev https://xpadev.net
|
|
5
|
+
|
|
6
|
+
以下に定める条件に従い、本ソフトウェアおよび関連文書のファイル(以下「ソフトウェア」)の複製を取得するすべての人に対し、ソフトウェアを無制限に扱うことを無償で許可します。これには、ソフトウェアの複製を使用、複写、変更、結合、掲載、頒布、サブライセンス、および/または販売する権利、およびソフトウェアを提供する相手に同じことを許可する権利も無制限に含まれます。
|
|
7
|
+
|
|
8
|
+
上記の著作権表示および本許諾表示を、ソフトウェアのすべての複製または重要な部分に記載するものとします。
|
|
9
|
+
|
|
10
|
+
ソフトウェアは「現状のまま」で、明示であるか暗黙であるかを問わず、何らの保証もなく提供されます。ここでいう保証とは、商品性、特定の目的への適合性、および権利非侵害についての保証も含みますが、それに限定されるものではありません。
|
|
11
|
+
作者または著作権者は、契約行為、不法行為、またはそれ以外であろうと、ソフトウェアに起因または関連し、あるいはソフトウェアの使用またはその他の扱いによって生じる一切の請求、損害、その他の義務について何らの責任も負わないものとします。
|
package/README.en.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# [niconicomments](https://xpadev.net/niconicomments/)
|
|
2
2
|
[](https://github.com/xpadev-net/niconicomments/blob/master/LICENSE)
|
|
3
|
+
[](https://github.com/xpadev-net/niconicomments/actions/workflows/codeql-analysis.yml)
|
|
4
|
+
[](https://github.com/xpadev-net/niconicomments/actions/workflows/typedoc.yml)
|
|
3
5
|
|
|
4
6
|
[[日本語](https://github.com/xpadev-net/niconicomments/blob/develop/README.md)]
|
|
5
7
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# [niconicomments](https://xpadev.net/niconicomments/)
|
|
2
2
|
[](https://github.com/xpadev-net/niconicomments/blob/master/LICENSE)
|
|
3
|
+
[](https://github.com/xpadev-net/niconicomments/actions/workflows/codeql-analysis.yml)
|
|
4
|
+
[](https://github.com/xpadev-net/niconicomments/actions/workflows/typedoc.yml)
|
|
3
5
|
|
|
4
6
|
[[English](https://github.com/xpadev-net/niconicomments/blob/develop/README.en.md)]
|
|
5
7
|
|
package/dist/bundle.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { IComment } from "@/@types/IComment";
|
|
2
|
+
import type { formattedCommentWithFont, formattedCommentWithSize, measureTextInput, measureTextResult, parsedCommand } from "@/@types/types";
|
|
3
|
+
import type { formattedComment } from "@/@types/format.formatted";
|
|
1
4
|
declare class FlashComment implements IComment {
|
|
2
5
|
private readonly context;
|
|
3
6
|
readonly comment: formattedCommentWithSize;
|
|
@@ -8,7 +11,7 @@ declare class FlashComment implements IComment {
|
|
|
8
11
|
image?: HTMLCanvasElement | null;
|
|
9
12
|
constructor(comment: formattedComment, context: CanvasRenderingContext2D);
|
|
10
13
|
get invisible(): boolean;
|
|
11
|
-
get loc(): commentLoc;
|
|
14
|
+
get loc(): import("@/@types/types").commentLoc;
|
|
12
15
|
get long(): number;
|
|
13
16
|
get vpos(): number;
|
|
14
17
|
get width(): number;
|
|
@@ -27,6 +30,9 @@ declare class FlashComment implements IComment {
|
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
|
|
33
|
+
import type { IComment } from "@/@types/IComment";
|
|
34
|
+
import type { formattedCommentWithFont, formattedCommentWithSize, measureTextInput, measureTextResult } from "@/@types/types";
|
|
35
|
+
import type { formattedComment } from "@/@types/format.formatted";
|
|
30
36
|
declare class HTML5Comment implements IComment {
|
|
31
37
|
private readonly context;
|
|
32
38
|
readonly comment: formattedCommentWithSize;
|
|
@@ -34,7 +40,7 @@ declare class HTML5Comment implements IComment {
|
|
|
34
40
|
image?: HTMLCanvasElement | null;
|
|
35
41
|
constructor(comment: formattedComment, context: CanvasRenderingContext2D);
|
|
36
42
|
get invisible(): boolean;
|
|
37
|
-
get loc(): commentLoc;
|
|
43
|
+
get loc(): import("@/@types/types").commentLoc;
|
|
38
44
|
get long(): number;
|
|
39
45
|
get vpos(): number;
|
|
40
46
|
get width(): number;
|
|
@@ -61,6 +67,7 @@ declare let imageCache: {
|
|
|
61
67
|
declare const resetImageCache: () => void;
|
|
62
68
|
|
|
63
69
|
|
|
70
|
+
import type { nicoScript } from "@/@types/types";
|
|
64
71
|
declare let nicoScripts: nicoScript;
|
|
65
72
|
declare const resetNicoScripts: () => void;
|
|
66
73
|
|
|
@@ -96,13 +103,15 @@ declare const colors: {
|
|
|
96
103
|
};
|
|
97
104
|
|
|
98
105
|
|
|
99
|
-
|
|
106
|
+
import type { BaseConfig } from "@/@types/config";
|
|
107
|
+
import type { BaseOptions } from "@/@types/options";
|
|
108
|
+
declare let defaultConfig: BaseConfig;
|
|
100
109
|
declare const initConfig: () => void;
|
|
101
|
-
declare const defaultOptions:
|
|
102
|
-
declare let config:
|
|
103
|
-
declare let options:
|
|
104
|
-
declare const setConfig: (value:
|
|
105
|
-
declare const setOptions: (value:
|
|
110
|
+
declare const defaultOptions: BaseOptions;
|
|
111
|
+
declare let config: BaseConfig;
|
|
112
|
+
declare let options: BaseOptions;
|
|
113
|
+
declare const setConfig: (value: BaseConfig) => BaseConfig;
|
|
114
|
+
declare const setOptions: (value: BaseOptions) => BaseOptions;
|
|
106
115
|
|
|
107
116
|
|
|
108
117
|
declare const fontTemplates: {
|
|
@@ -211,68 +220,68 @@ declare const fonts: {
|
|
|
211
220
|
};
|
|
212
221
|
|
|
213
222
|
|
|
214
|
-
type configItem<T> = T | { html5: T; flash: T };
|
|
215
|
-
type configSizeItem<T> = { big: T; medium: T; small: T };
|
|
216
|
-
type configResizedItem<T> = { default: T; resized: T };
|
|
217
|
-
|
|
218
|
-
type commentStageSize = { width: number; fullWidth: number; height: number };
|
|
219
|
-
|
|
220
|
-
type flashCharList = {
|
|
221
|
-
[key in "simsunStrong" | "simsunWeak" | "gulim" | "gothic"]: string;
|
|
222
|
-
};
|
|
223
|
-
type flashMode = "xp" | "vista";
|
|
224
|
-
type flashScriptChar = {
|
|
225
|
-
[key in "super" | "sub"]: string;
|
|
226
|
-
};
|
|
227
|
-
type fontList = {
|
|
228
|
-
[key in "gulim" | "simsun"]: string;
|
|
229
|
-
};
|
|
230
|
-
type lineCounts = {
|
|
231
|
-
[key in "default" | "resized" | "doubleResized"]: configSizeItem<number>;
|
|
232
|
-
};
|
|
233
|
-
type typeDoubleResizeMaxWidth = {
|
|
234
|
-
[key in "full" | "normal"]: number;
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
type
|
|
238
|
-
cacheAge: number;
|
|
239
|
-
canvasHeight: number;
|
|
240
|
-
canvasWidth: number;
|
|
241
|
-
collisionRange: { [key in "left" | "right"]: number };
|
|
242
|
-
colors: { [key: string]: string };
|
|
243
|
-
commentDrawPadding: number;
|
|
244
|
-
commentDrawRange: number;
|
|
245
|
-
commentScale: configItem<number>;
|
|
246
|
-
commentStageSize: configItem<commentStageSize>;
|
|
247
|
-
commentYMarginBottom: configSizeItem<number>;
|
|
248
|
-
commentYOffset: configSizeItem<configResizedItem<number>>;
|
|
249
|
-
commentYPaddingTop: configResizedItem<number>;
|
|
250
|
-
contextFillLiveOpacity: number;
|
|
251
|
-
contextLineWidth: number;
|
|
252
|
-
contextStrokeColor: string;
|
|
253
|
-
contextStrokeInversionColor: string;
|
|
254
|
-
contextStrokeOpacity: number;
|
|
255
|
-
doubleResizeMaxWidth: configItem<typeDoubleResizeMaxWidth>;
|
|
256
|
-
flashChar: flashCharList;
|
|
257
|
-
flashMode: flashMode;
|
|
258
|
-
flashScriptChar: flashScriptChar;
|
|
259
|
-
flashThreshold: number;
|
|
260
|
-
font: fontList;
|
|
261
|
-
fonts: platformFont;
|
|
262
|
-
fontSize: configItem<configSizeItem<configResizedItem<number>>>;
|
|
263
|
-
fpsInterval: number;
|
|
264
|
-
hiResCommentCorrection: number;
|
|
265
|
-
lineCounts: configItem<lineCounts>;
|
|
266
|
-
lineHeight: configItem<configSizeItem<configResizedItem<number>>>;
|
|
267
|
-
minFontSize: number;
|
|
268
|
-
sameCAGap: number;
|
|
269
|
-
sameCAMinScore: number;
|
|
270
|
-
sameCARange: number;
|
|
271
|
-
letterSpacing: number;
|
|
272
|
-
scriptCharOffset: number;
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
type
|
|
223
|
+
type configItem<T> = T | { html5: T; flash: T };
|
|
224
|
+
type configSizeItem<T> = { big: T; medium: T; small: T };
|
|
225
|
+
type configResizedItem<T> = { default: T; resized: T };
|
|
226
|
+
|
|
227
|
+
type commentStageSize = { width: number; fullWidth: number; height: number };
|
|
228
|
+
|
|
229
|
+
type flashCharList = {
|
|
230
|
+
[key in "simsunStrong" | "simsunWeak" | "gulim" | "gothic"]: string;
|
|
231
|
+
};
|
|
232
|
+
type flashMode = "xp" | "vista";
|
|
233
|
+
type flashScriptChar = {
|
|
234
|
+
[key in "super" | "sub"]: string;
|
|
235
|
+
};
|
|
236
|
+
type fontList = {
|
|
237
|
+
[key in "gulim" | "simsun"]: string;
|
|
238
|
+
};
|
|
239
|
+
type lineCounts = {
|
|
240
|
+
[key in "default" | "resized" | "doubleResized"]: configSizeItem<number>;
|
|
241
|
+
};
|
|
242
|
+
type typeDoubleResizeMaxWidth = {
|
|
243
|
+
[key in "full" | "normal"]: number;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
type BaseConfig = {
|
|
247
|
+
cacheAge: number;
|
|
248
|
+
canvasHeight: number;
|
|
249
|
+
canvasWidth: number;
|
|
250
|
+
collisionRange: { [key in "left" | "right"]: number };
|
|
251
|
+
colors: { [key: string]: string };
|
|
252
|
+
commentDrawPadding: number;
|
|
253
|
+
commentDrawRange: number;
|
|
254
|
+
commentScale: configItem<number>;
|
|
255
|
+
commentStageSize: configItem<commentStageSize>;
|
|
256
|
+
commentYMarginBottom: configSizeItem<number>;
|
|
257
|
+
commentYOffset: configSizeItem<configResizedItem<number>>;
|
|
258
|
+
commentYPaddingTop: configResizedItem<number>;
|
|
259
|
+
contextFillLiveOpacity: number;
|
|
260
|
+
contextLineWidth: number;
|
|
261
|
+
contextStrokeColor: string;
|
|
262
|
+
contextStrokeInversionColor: string;
|
|
263
|
+
contextStrokeOpacity: number;
|
|
264
|
+
doubleResizeMaxWidth: configItem<typeDoubleResizeMaxWidth>;
|
|
265
|
+
flashChar: flashCharList;
|
|
266
|
+
flashMode: flashMode;
|
|
267
|
+
flashScriptChar: flashScriptChar;
|
|
268
|
+
flashThreshold: number;
|
|
269
|
+
font: fontList;
|
|
270
|
+
fonts: platformFont;
|
|
271
|
+
fontSize: configItem<configSizeItem<configResizedItem<number>>>;
|
|
272
|
+
fpsInterval: number;
|
|
273
|
+
hiResCommentCorrection: number;
|
|
274
|
+
lineCounts: configItem<lineCounts>;
|
|
275
|
+
lineHeight: configItem<configSizeItem<configResizedItem<number>>>;
|
|
276
|
+
minFontSize: number;
|
|
277
|
+
sameCAGap: number;
|
|
278
|
+
sameCAMinScore: number;
|
|
279
|
+
sameCARange: number;
|
|
280
|
+
letterSpacing: number;
|
|
281
|
+
scriptCharOffset: number;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
export type Config = Partial<BaseConfig>;
|
|
276
285
|
|
|
277
286
|
type platform =
|
|
278
287
|
| "win7"
|
|
@@ -292,112 +301,124 @@ type platformFont = {
|
|
|
292
301
|
[key in HTML5Fonts]: FontItem;
|
|
293
302
|
};
|
|
294
303
|
|
|
295
|
-
type formattedComment = {
|
|
296
|
-
id: number;
|
|
297
|
-
vpos: number;
|
|
298
|
-
content: string;
|
|
299
|
-
date: number;
|
|
300
|
-
date_usec: number;
|
|
301
|
-
owner: boolean;
|
|
302
|
-
premium: boolean;
|
|
303
|
-
mail: string[];
|
|
304
|
-
user_id: number;
|
|
305
|
-
layer: number;
|
|
306
|
-
};
|
|
307
|
-
type formattedLegacyComment = {
|
|
308
|
-
id: number;
|
|
309
|
-
vpos: number;
|
|
310
|
-
content: string;
|
|
311
|
-
date: number;
|
|
312
|
-
date_usec: number;
|
|
313
|
-
owner: boolean;
|
|
314
|
-
premium: boolean;
|
|
315
|
-
mail: string[];
|
|
316
|
-
};
|
|
304
|
+
export type formattedComment = {
|
|
305
|
+
id: number;
|
|
306
|
+
vpos: number;
|
|
307
|
+
content: string;
|
|
308
|
+
date: number;
|
|
309
|
+
date_usec: number;
|
|
310
|
+
owner: boolean;
|
|
311
|
+
premium: boolean;
|
|
312
|
+
mail: string[];
|
|
313
|
+
user_id: number;
|
|
314
|
+
layer: number;
|
|
315
|
+
};
|
|
316
|
+
export type formattedLegacyComment = {
|
|
317
|
+
id: number;
|
|
318
|
+
vpos: number;
|
|
319
|
+
content: string;
|
|
320
|
+
date: number;
|
|
321
|
+
date_usec: number;
|
|
322
|
+
owner: boolean;
|
|
323
|
+
premium: boolean;
|
|
324
|
+
mail: string[];
|
|
325
|
+
};
|
|
317
326
|
|
|
318
|
-
type rawApiResponse = {
|
|
319
|
-
[key: string]: apiPing | apiThread | apiLeaf | apiGlobalNumRes | apiChat;
|
|
320
|
-
};
|
|
321
|
-
type apiPing = {
|
|
322
|
-
content: string;
|
|
323
|
-
};
|
|
324
|
-
type apiThread = {
|
|
325
|
-
resultcode: number;
|
|
326
|
-
thread: string;
|
|
327
|
-
server_time: number;
|
|
328
|
-
ticket: string;
|
|
329
|
-
revision: number;
|
|
330
|
-
};
|
|
331
|
-
type apiLeaf = {
|
|
332
|
-
thread: string;
|
|
333
|
-
count: number;
|
|
334
|
-
};
|
|
335
|
-
type apiGlobalNumRes = {
|
|
336
|
-
thread: string;
|
|
337
|
-
num_res: number;
|
|
338
|
-
};
|
|
339
|
-
type apiChat = {
|
|
340
|
-
thread: string;
|
|
341
|
-
no: number;
|
|
342
|
-
vpos: number;
|
|
343
|
-
date: number;
|
|
344
|
-
date_usec: number;
|
|
345
|
-
nicoru: number;
|
|
346
|
-
premium: number;
|
|
347
|
-
anonymity: number;
|
|
348
|
-
user_id: string;
|
|
349
|
-
mail: string;
|
|
350
|
-
content: string;
|
|
351
|
-
deleted: number;
|
|
352
|
-
};
|
|
327
|
+
export type rawApiResponse = {
|
|
328
|
+
[key: string]: apiPing | apiThread | apiLeaf | apiGlobalNumRes | apiChat;
|
|
329
|
+
};
|
|
330
|
+
type apiPing = {
|
|
331
|
+
content: string;
|
|
332
|
+
};
|
|
333
|
+
type apiThread = {
|
|
334
|
+
resultcode: number;
|
|
335
|
+
thread: string;
|
|
336
|
+
server_time: number;
|
|
337
|
+
ticket: string;
|
|
338
|
+
revision: number;
|
|
339
|
+
};
|
|
340
|
+
type apiLeaf = {
|
|
341
|
+
thread: string;
|
|
342
|
+
count: number;
|
|
343
|
+
};
|
|
344
|
+
type apiGlobalNumRes = {
|
|
345
|
+
thread: string;
|
|
346
|
+
num_res: number;
|
|
347
|
+
};
|
|
348
|
+
type apiChat = {
|
|
349
|
+
thread: string;
|
|
350
|
+
no: number;
|
|
351
|
+
vpos: number;
|
|
352
|
+
date: number;
|
|
353
|
+
date_usec: number;
|
|
354
|
+
nicoru: number;
|
|
355
|
+
premium: number;
|
|
356
|
+
anonymity: number;
|
|
357
|
+
user_id: string;
|
|
358
|
+
mail: string;
|
|
359
|
+
content: string;
|
|
360
|
+
deleted: number;
|
|
361
|
+
};
|
|
353
362
|
|
|
354
|
-
type ownerComment = {
|
|
355
|
-
time: string;
|
|
356
|
-
command: string;
|
|
357
|
-
comment: string;
|
|
358
|
-
};
|
|
363
|
+
export type ownerComment = {
|
|
364
|
+
time: string;
|
|
365
|
+
command: string;
|
|
366
|
+
comment: string;
|
|
367
|
+
};
|
|
359
368
|
|
|
360
|
-
type v1Thread = {
|
|
361
|
-
id: string;
|
|
362
|
-
fork: string;
|
|
363
|
-
commentCount: number;
|
|
364
|
-
comments: { [key: string]: v1Comment };
|
|
365
|
-
};
|
|
366
|
-
type v1Comment = {
|
|
367
|
-
id: string;
|
|
368
|
-
no: number;
|
|
369
|
-
vposMs: number;
|
|
370
|
-
body: string;
|
|
371
|
-
commands: string[];
|
|
372
|
-
userId: string;
|
|
373
|
-
isPremium: boolean;
|
|
374
|
-
score: number;
|
|
375
|
-
postedAt: string;
|
|
376
|
-
nicoruCount: number;
|
|
377
|
-
nicoruId: undefined;
|
|
378
|
-
source: string;
|
|
379
|
-
isMyPost: boolean;
|
|
380
|
-
};
|
|
369
|
+
export type v1Thread = {
|
|
370
|
+
id: string;
|
|
371
|
+
fork: string;
|
|
372
|
+
commentCount: number;
|
|
373
|
+
comments: { [key: string]: v1Comment };
|
|
374
|
+
};
|
|
375
|
+
type v1Comment = {
|
|
376
|
+
id: string;
|
|
377
|
+
no: number;
|
|
378
|
+
vposMs: number;
|
|
379
|
+
body: string;
|
|
380
|
+
commands: string[];
|
|
381
|
+
userId: string;
|
|
382
|
+
isPremium: boolean;
|
|
383
|
+
score: number;
|
|
384
|
+
postedAt: string;
|
|
385
|
+
nicoruCount: number;
|
|
386
|
+
nicoruId: undefined;
|
|
387
|
+
source: string;
|
|
388
|
+
isMyPost: boolean;
|
|
389
|
+
};
|
|
381
390
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
391
|
+
import { commentLoc, formattedCommentWithSize } from "@/@types/types";
|
|
392
|
+
|
|
393
|
+
export interface IComment {
|
|
394
|
+
comment: formattedCommentWithSize;
|
|
395
|
+
invisible: boolean;
|
|
396
|
+
loc: commentLoc;
|
|
397
|
+
width: number;
|
|
398
|
+
long: number;
|
|
399
|
+
height: number;
|
|
400
|
+
vpos: number;
|
|
401
|
+
flash: boolean;
|
|
402
|
+
posY: number;
|
|
403
|
+
owner: boolean;
|
|
404
|
+
layer: number;
|
|
405
|
+
mail: string[];
|
|
406
|
+
image?: HTMLCanvasElement | null;
|
|
407
|
+
getTextImage: (vpos: number) => void;
|
|
408
|
+
draw: (vpos: number, showCollision: boolean, isDebug: boolean) => void;
|
|
409
|
+
}
|
|
399
410
|
|
|
400
|
-
|
|
411
|
+
import {
|
|
412
|
+
formattedComment,
|
|
413
|
+
formattedLegacyComment,
|
|
414
|
+
} from "@/@types/format.formatted";
|
|
415
|
+
import { rawApiResponse } from "@/@types/format.legacy";
|
|
416
|
+
import { ownerComment } from "@/@types/format.owner";
|
|
417
|
+
import { v1Thread } from "@/@types/format.v1";
|
|
418
|
+
import { Config } from "@/@types/config";
|
|
419
|
+
|
|
420
|
+
export type inputFormatType =
|
|
421
|
+
| "XMLDocument"
|
|
401
422
|
| "niconicome"
|
|
402
423
|
| "formatted"
|
|
403
424
|
| "legacy"
|
|
@@ -406,7 +427,7 @@ type inputFormatType =
|
|
|
406
427
|
| "v1"
|
|
407
428
|
| "empty"
|
|
408
429
|
| "default";
|
|
409
|
-
type inputFormat =
|
|
430
|
+
export type inputFormat =
|
|
410
431
|
| XMLDocument
|
|
411
432
|
| formattedComment[]
|
|
412
433
|
| formattedLegacyComment[]
|
|
@@ -416,8 +437,8 @@ type inputFormat =
|
|
|
416
437
|
| string
|
|
417
438
|
| undefined;
|
|
418
439
|
type modeType = "default" | "html5" | "flash";
|
|
419
|
-
type
|
|
420
|
-
config:
|
|
440
|
+
type BaseOptions = {
|
|
441
|
+
config: Config;
|
|
421
442
|
debug: boolean;
|
|
422
443
|
enableLegacyPiP: boolean;
|
|
423
444
|
format: inputFormatType;
|
|
@@ -431,8 +452,10 @@ type Options = {
|
|
|
431
452
|
useLegacy: boolean;
|
|
432
453
|
video: HTMLVideoElement | undefined;
|
|
433
454
|
};
|
|
434
|
-
type
|
|
455
|
+
export type Options = Partial<BaseOptions>;
|
|
435
456
|
|
|
457
|
+
import { IComment } from "@/@types/IComment";
|
|
458
|
+
|
|
436
459
|
type formattedCommentWithFont = {
|
|
437
460
|
id: number;
|
|
438
461
|
vpos: number;
|
|
@@ -448,6 +471,7 @@ type formattedCommentWithFont = {
|
|
|
448
471
|
fontSize: number;
|
|
449
472
|
font: commentFont;
|
|
450
473
|
color: string;
|
|
474
|
+
strokeColor?: string;
|
|
451
475
|
full: boolean;
|
|
452
476
|
ender: boolean;
|
|
453
477
|
_live: boolean;
|
|
@@ -548,6 +572,7 @@ type parsedCommand = {
|
|
|
548
572
|
size: commentSize | undefined;
|
|
549
573
|
fontSize: number | undefined;
|
|
550
574
|
color: string | undefined;
|
|
575
|
+
strokeColor?: string;
|
|
551
576
|
font: commentFont | undefined;
|
|
552
577
|
full: boolean;
|
|
553
578
|
ender: boolean;
|
|
@@ -581,9 +606,13 @@ type measureInput = {
|
|
|
581
606
|
lineCount: number;
|
|
582
607
|
};
|
|
583
608
|
|
|
609
|
+
import type { inputFormatType } from "@/@types/options";
|
|
610
|
+
import type { formattedComment } from "@/@types/format.formatted";
|
|
584
611
|
declare const convert2formattedComment: (data: unknown, type: inputFormatType) => formattedComment[];
|
|
585
612
|
|
|
586
613
|
|
|
614
|
+
import type { inputFormat, Options } from "@/@types/options";
|
|
615
|
+
import type { formattedComment } from "@/@types/format.formatted";
|
|
587
616
|
declare class NiconiComments {
|
|
588
617
|
enableLegacyPiP: boolean;
|
|
589
618
|
showCollision: boolean;
|
|
@@ -595,7 +624,59 @@ declare class NiconiComments {
|
|
|
595
624
|
private readonly collision;
|
|
596
625
|
private readonly context;
|
|
597
626
|
private readonly timeline;
|
|
598
|
-
|
|
627
|
+
static typeGuard: {
|
|
628
|
+
formatted: {
|
|
629
|
+
comment: (i: unknown) => i is formattedComment;
|
|
630
|
+
comments: (i: unknown) => i is formattedComment[];
|
|
631
|
+
legacyComment: (i: unknown) => i is import("@/@types/format.formatted").formattedLegacyComment;
|
|
632
|
+
legacyComments: (i: unknown) => i is import("@/@types/format.formatted").formattedLegacyComment[];
|
|
633
|
+
};
|
|
634
|
+
legacy: {
|
|
635
|
+
rawApiResponses: (i: unknown) => i is import("./@types/format.legacy").rawApiResponse[];
|
|
636
|
+
apiChat: (i: unknown) => i is import("./@types/format.legacy").apiChat;
|
|
637
|
+
apiGlobalNumRes: (i: unknown) => i is import("./@types/format.legacy").apiGlobalNumRes;
|
|
638
|
+
apiLeaf: (i: unknown) => i is import("./@types/format.legacy").apiLeaf;
|
|
639
|
+
apiPing: (i: unknown) => i is import("./@types/format.legacy").apiPing;
|
|
640
|
+
apiThread: (i: unknown) => i is import("./@types/format.legacy").apiThread;
|
|
641
|
+
};
|
|
642
|
+
xmlDocument: (i: unknown) => i is XMLDocument;
|
|
643
|
+
legacyOwner: {
|
|
644
|
+
comments: (i: unknown) => i is string;
|
|
645
|
+
};
|
|
646
|
+
owner: {
|
|
647
|
+
comment: (i: unknown) => i is import("./@types/format.owner").ownerComment;
|
|
648
|
+
comments: (i: unknown) => i is import("./@types/format.owner").ownerComment[];
|
|
649
|
+
};
|
|
650
|
+
v1: {
|
|
651
|
+
comment: (i: unknown) => i is import("./@types/format.v1").v1Comment;
|
|
652
|
+
thread: (i: unknown) => i is import("./@types/format.v1").v1Thread;
|
|
653
|
+
threads: (i: unknown) => i is import("./@types/format.v1").v1Thread[];
|
|
654
|
+
};
|
|
655
|
+
nicoScript: {
|
|
656
|
+
range: {
|
|
657
|
+
target: (i: unknown) => i is import("@/@types/types").nicoScriptReverseTarget;
|
|
658
|
+
};
|
|
659
|
+
replace: {
|
|
660
|
+
range: (i: unknown) => i is import("@/@types/types").nicoScriptReplaceRange;
|
|
661
|
+
target: (i: unknown) => i is import("@/@types/types").nicoScriptReplaceTarget;
|
|
662
|
+
condition: (i: unknown) => i is import("@/@types/types").nicoScriptReplaceCondition;
|
|
663
|
+
};
|
|
664
|
+
};
|
|
665
|
+
comment: {
|
|
666
|
+
font: (i: unknown) => i is import("@/@types/types").commentFont;
|
|
667
|
+
loc: (i: unknown) => i is import("@/@types/types").commentLoc;
|
|
668
|
+
size: (i: unknown) => i is import("@/@types/types").commentSize;
|
|
669
|
+
command: {
|
|
670
|
+
key: (i: unknown) => i is "full" | "ender" | "_live" | "invisible";
|
|
671
|
+
};
|
|
672
|
+
color: (i: unknown) => i is "white" | "red" | "pink" | "orange" | "yellow" | "green" | "cyan" | "blue" | "purple" | "black" | "white2" | "niconicowhite" | "red2" | "truered" | "pink2" | "orange2" | "passionorange" | "yellow2" | "madyellow" | "green2" | "elementalgreen" | "cyan2" | "blue2" | "marinblue" | "purple2" | "nobleviolet" | "black2";
|
|
673
|
+
colorCode: (i: unknown) => i is string;
|
|
674
|
+
};
|
|
675
|
+
config: {
|
|
676
|
+
initOptions: (item: unknown) => item is Partial<import("@/@types/options").BaseOptions>;
|
|
677
|
+
};
|
|
678
|
+
};
|
|
679
|
+
constructor(canvas: HTMLCanvasElement, data: inputFormat, initOptions?: Options);
|
|
599
680
|
private preRendering;
|
|
600
681
|
private getCommentPos;
|
|
601
682
|
private sortComment;
|
|
@@ -605,6 +686,7 @@ declare class NiconiComments {
|
|
|
605
686
|
}
|
|
606
687
|
|
|
607
688
|
|
|
689
|
+
import type { commentSize, measureInput } from "@/@types/types";
|
|
608
690
|
declare const getLineHeight: (fontSize: commentSize, isFlash: boolean, resized?: boolean) => number;
|
|
609
691
|
declare const getCharSize: (fontSize: commentSize, isFlash: boolean) => number;
|
|
610
692
|
declare const measure: (comment: measureInput, context: CanvasRenderingContext2D) => {
|
|
@@ -619,6 +701,11 @@ declare const getFontSizeAndScale: (charSize: number) => {
|
|
|
619
701
|
};
|
|
620
702
|
|
|
621
703
|
|
|
704
|
+
import type { formattedComment, formattedLegacyComment } from "@/@types/format.formatted";
|
|
705
|
+
import type { apiChat, apiGlobalNumRes, apiLeaf, apiPing, apiThread, rawApiResponse } from "@/@types/format.legacy";
|
|
706
|
+
import type { ownerComment } from "@/@types/format.owner";
|
|
707
|
+
import type { v1Comment, v1Thread } from "@/@types/format.v1";
|
|
708
|
+
import type { commentFont, commentLoc, commentSize, nicoScriptReplaceCondition, nicoScriptReplaceRange, nicoScriptReplaceTarget, nicoScriptReverseTarget } from "@/@types/types";
|
|
622
709
|
declare const typeGuard: {
|
|
623
710
|
formatted: {
|
|
624
711
|
comment: (i: unknown) => i is formattedComment;
|
|
@@ -634,9 +721,7 @@ declare const typeGuard: {
|
|
|
634
721
|
apiPing: (i: unknown) => i is apiPing;
|
|
635
722
|
apiThread: (i: unknown) => i is apiThread;
|
|
636
723
|
};
|
|
637
|
-
|
|
638
|
-
xmlDocument: (i: unknown) => i is XMLDocument;
|
|
639
|
-
};
|
|
724
|
+
xmlDocument: (i: unknown) => i is XMLDocument;
|
|
640
725
|
legacyOwner: {
|
|
641
726
|
comments: (i: unknown) => i is string;
|
|
642
727
|
};
|
|
@@ -666,13 +751,19 @@ declare const typeGuard: {
|
|
|
666
751
|
command: {
|
|
667
752
|
key: (i: unknown) => i is "full" | "ender" | "_live" | "invisible";
|
|
668
753
|
};
|
|
754
|
+
color: (i: unknown) => i is "white" | "red" | "pink" | "orange" | "yellow" | "green" | "cyan" | "blue" | "purple" | "black" | "white2" | "niconicowhite" | "red2" | "truered" | "pink2" | "orange2" | "passionorange" | "yellow2" | "madyellow" | "green2" | "elementalgreen" | "cyan2" | "blue2" | "marinblue" | "purple2" | "nobleviolet" | "black2";
|
|
755
|
+
colorCode: (i: unknown) => i is string;
|
|
669
756
|
};
|
|
670
757
|
config: {
|
|
671
|
-
initOptions: (item: unknown) => item is Partial<
|
|
758
|
+
initOptions: (item: unknown) => item is Partial<import("@/@types/options").BaseOptions>;
|
|
672
759
|
};
|
|
673
760
|
};
|
|
674
761
|
|
|
675
762
|
|
|
763
|
+
import type { configItem } from "@/@types/config";
|
|
764
|
+
import type { IComment } from "@/@types/IComment";
|
|
765
|
+
import type { commentFont, formattedCommentWithFont, formattedCommentWithSize } from "@/@types/types";
|
|
766
|
+
import type { formattedComment } from "@/@types/format.formatted";
|
|
676
767
|
declare const getPosY: (currentPos: number, targetComment: IComment, collision: IComment[] | undefined) => {
|
|
677
768
|
currentPos: number;
|
|
678
769
|
isChanged: boolean;
|
|
@@ -684,11 +775,13 @@ declare const arrayPush: (array: {
|
|
|
684
775
|
[key: number]: IComment[];
|
|
685
776
|
}, key: string | number, push: IComment) => void;
|
|
686
777
|
declare const hex2rgb: (hex: string) => number[];
|
|
778
|
+
declare const hex2rgba: (hex: string) => number[];
|
|
687
779
|
declare const replaceAll: (string: string, target: string, replace: string) => string;
|
|
688
780
|
declare const changeCALayer: (rawData: formattedComment[]) => formattedComment[];
|
|
689
781
|
declare const getConfig: <T>(input: configItem<T>, isFlash?: boolean) => T;
|
|
690
782
|
declare const isFlashComment: (comment: formattedComment) => boolean;
|
|
691
783
|
declare const parseCommandAndNicoScript: (comment: formattedComment) => formattedCommentWithFont;
|
|
784
|
+
declare const getStrokeColor: (comment: formattedCommentWithSize) => string;
|
|
692
785
|
|
|
693
786
|
|
|
694
787
|
export default NiconiComments;
|
package/dist/bundle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
niconicomments.js v0.2.
|
|
2
|
+
niconicomments.js v0.2.38
|
|
3
3
|
(c) 2021 xpadev-net https://xpadev.net
|
|
4
4
|
Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -9,6 +9,36 @@
|
|
|
9
9
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.NiconiComments = factory());
|
|
10
10
|
})(this, (function () { 'use strict';
|
|
11
11
|
|
|
12
|
+
var colors = {
|
|
13
|
+
white: "#FFFFFF",
|
|
14
|
+
red: "#FF0000",
|
|
15
|
+
pink: "#FF8080",
|
|
16
|
+
orange: "#FFC000",
|
|
17
|
+
yellow: "#FFFF00",
|
|
18
|
+
green: "#00FF00",
|
|
19
|
+
cyan: "#00FFFF",
|
|
20
|
+
blue: "#0000FF",
|
|
21
|
+
purple: "#C000FF",
|
|
22
|
+
black: "#000000",
|
|
23
|
+
white2: "#CCCC99",
|
|
24
|
+
niconicowhite: "#CCCC99",
|
|
25
|
+
red2: "#CC0033",
|
|
26
|
+
truered: "#CC0033",
|
|
27
|
+
pink2: "#FF33CC",
|
|
28
|
+
orange2: "#FF6600",
|
|
29
|
+
passionorange: "#FF6600",
|
|
30
|
+
yellow2: "#999900",
|
|
31
|
+
madyellow: "#999900",
|
|
32
|
+
green2: "#00CC66",
|
|
33
|
+
elementalgreen: "#00CC66",
|
|
34
|
+
cyan2: "#00CCCC",
|
|
35
|
+
blue2: "#3399FF",
|
|
36
|
+
marinblue: "#3399FF",
|
|
37
|
+
purple2: "#6633CC",
|
|
38
|
+
nobleviolet: "#6633CC",
|
|
39
|
+
black2: "#666666",
|
|
40
|
+
};
|
|
41
|
+
|
|
12
42
|
var isBoolean = function (i) { return typeof i === "boolean"; };
|
|
13
43
|
var isNumber = function (i) { return typeof i === "number"; };
|
|
14
44
|
var isObject = function (i) { return typeof i === "object"; };
|
|
@@ -101,47 +131,28 @@
|
|
|
101
131
|
]);
|
|
102
132
|
},
|
|
103
133
|
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
134
|
+
xmlDocument: function (i) {
|
|
135
|
+
if (!i.documentElement ||
|
|
136
|
+
i.documentElement.nodeName !== "packet")
|
|
137
|
+
return false;
|
|
138
|
+
if (!i.documentElement.children)
|
|
139
|
+
return false;
|
|
140
|
+
for (var index = 0; index < i.documentElement.children.length; index++) {
|
|
141
|
+
var value = i.documentElement.children[index];
|
|
142
|
+
if (!value)
|
|
143
|
+
continue;
|
|
144
|
+
if (value.nodeName === "chat" &&
|
|
145
|
+
!typeAttributeVerify(value, [
|
|
146
|
+
"no",
|
|
147
|
+
"vpos",
|
|
148
|
+
"date",
|
|
149
|
+
"date_usec",
|
|
150
|
+
"mail",
|
|
151
|
+
"premium",
|
|
152
|
+
]))
|
|
110
153
|
return false;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (!value)
|
|
114
|
-
continue;
|
|
115
|
-
if (index === 0) {
|
|
116
|
-
if (value.nodeName !== "thread" ||
|
|
117
|
-
!typeAttributeVerify(value, [
|
|
118
|
-
"resultcode",
|
|
119
|
-
"thread",
|
|
120
|
-
"server_time",
|
|
121
|
-
"last_res",
|
|
122
|
-
"revision",
|
|
123
|
-
]))
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
if (value.nodeName !== "chat" ||
|
|
128
|
-
!typeAttributeVerify(value, [
|
|
129
|
-
"thread",
|
|
130
|
-
"no",
|
|
131
|
-
"vpos",
|
|
132
|
-
"date",
|
|
133
|
-
"date_usec",
|
|
134
|
-
"anonymity",
|
|
135
|
-
"mail",
|
|
136
|
-
"leaf",
|
|
137
|
-
"premium",
|
|
138
|
-
"score",
|
|
139
|
-
]))
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return true;
|
|
144
|
-
},
|
|
154
|
+
}
|
|
155
|
+
return true;
|
|
145
156
|
},
|
|
146
157
|
legacyOwner: {
|
|
147
158
|
comments: function (i) {
|
|
@@ -214,19 +225,20 @@
|
|
|
214
225
|
nicoScript: {
|
|
215
226
|
range: {
|
|
216
227
|
target: function (i) {
|
|
217
|
-
return typeof i === "string" && !!i.match(/^(
|
|
228
|
+
return typeof i === "string" && !!i.match(/^(?:\u6295?\u30b3\u30e1|\u5168)$/);
|
|
218
229
|
},
|
|
219
230
|
},
|
|
220
231
|
replace: {
|
|
221
232
|
range: function (i) {
|
|
222
|
-
return typeof i === "string" && !!i.match(/^(
|
|
233
|
+
return typeof i === "string" && !!i.match(/^(?:\u5358|\u5168)$/);
|
|
223
234
|
},
|
|
224
235
|
target: function (i) {
|
|
225
236
|
return typeof i === "string" &&
|
|
226
|
-
!!i.match(/^(
|
|
237
|
+
!!i.match(/^(?:\u30b3\u30e1|\u6295\u30b3\u30e1|\u5168|\u542b\u3080|\u542b\u307e\u306a\u3044)$/);
|
|
227
238
|
},
|
|
228
239
|
condition: function (i) {
|
|
229
|
-
return typeof i === "string" &&
|
|
240
|
+
return typeof i === "string" &&
|
|
241
|
+
!!i.match(/^(?:\u90e8\u5206\u4e00\u81f4|\u5b8c\u5168\u4e00\u81f4)$/);
|
|
230
242
|
},
|
|
231
243
|
},
|
|
232
244
|
},
|
|
@@ -245,6 +257,13 @@
|
|
|
245
257
|
return typeof i === "string" && !!i.match(/^(?:full|ender|_live|invisible)$/);
|
|
246
258
|
},
|
|
247
259
|
},
|
|
260
|
+
color: function (i) {
|
|
261
|
+
return typeof i === "string" && Object.keys(colors).includes(i);
|
|
262
|
+
},
|
|
263
|
+
colorCode: function (i) {
|
|
264
|
+
return typeof i === "string" &&
|
|
265
|
+
!!i.match(/^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/);
|
|
266
|
+
},
|
|
248
267
|
},
|
|
249
268
|
config: {
|
|
250
269
|
initOptions: function (item) {
|
|
@@ -307,8 +326,9 @@
|
|
|
307
326
|
if (type === "empty" && data === undefined) {
|
|
308
327
|
return [];
|
|
309
328
|
}
|
|
310
|
-
else if (type === "
|
|
311
|
-
|
|
329
|
+
else if ((type === "XMLDocument" || type === "niconicome") &&
|
|
330
|
+
typeGuard.xmlDocument(data)) {
|
|
331
|
+
result = fromXMLDocument(data);
|
|
312
332
|
}
|
|
313
333
|
else if (type === "formatted" && typeGuard.formatted.legacyComments(data)) {
|
|
314
334
|
result = fromFormatted(data);
|
|
@@ -330,7 +350,7 @@
|
|
|
330
350
|
}
|
|
331
351
|
return sort(result);
|
|
332
352
|
};
|
|
333
|
-
var
|
|
353
|
+
var fromXMLDocument = function (data) {
|
|
334
354
|
var _a;
|
|
335
355
|
var data_ = [], userList = [];
|
|
336
356
|
for (var _i = 0, _b = Array.from(data.documentElement.children); _i < _b.length; _i++) {
|
|
@@ -724,36 +744,6 @@
|
|
|
724
744
|
},
|
|
725
745
|
};
|
|
726
746
|
|
|
727
|
-
var colors = {
|
|
728
|
-
white: "#FFFFFF",
|
|
729
|
-
red: "#FF0000",
|
|
730
|
-
pink: "#FF8080",
|
|
731
|
-
orange: "#FFC000",
|
|
732
|
-
yellow: "#FFFF00",
|
|
733
|
-
green: "#00FF00",
|
|
734
|
-
cyan: "#00FFFF",
|
|
735
|
-
blue: "#0000FF",
|
|
736
|
-
purple: "#C000FF",
|
|
737
|
-
black: "#000000",
|
|
738
|
-
white2: "#CCCC99",
|
|
739
|
-
niconicowhite: "#CCCC99",
|
|
740
|
-
red2: "#CC0033",
|
|
741
|
-
truered: "#CC0033",
|
|
742
|
-
pink2: "#FF33CC",
|
|
743
|
-
orange2: "#FF6600",
|
|
744
|
-
passionorange: "#FF6600",
|
|
745
|
-
yellow2: "#999900",
|
|
746
|
-
madyellow: "#999900",
|
|
747
|
-
green2: "#00CC66",
|
|
748
|
-
elementalgreen: "#00CC66",
|
|
749
|
-
cyan2: "#00CCCC",
|
|
750
|
-
blue2: "#3399FF",
|
|
751
|
-
marinblue: "#3399FF",
|
|
752
|
-
purple2: "#6633CC",
|
|
753
|
-
nobleviolet: "#6633CC",
|
|
754
|
-
black2: "#666666",
|
|
755
|
-
};
|
|
756
|
-
|
|
757
747
|
var defaultConfig;
|
|
758
748
|
var initConfig = function () {
|
|
759
749
|
var platform = (function (ua) {
|
|
@@ -1021,6 +1011,30 @@
|
|
|
1021
1011
|
return parseInt(str, 16);
|
|
1022
1012
|
});
|
|
1023
1013
|
};
|
|
1014
|
+
var hex2rgba = function (hex) {
|
|
1015
|
+
if (hex.slice(0, 1) === "#")
|
|
1016
|
+
hex = hex.slice(1);
|
|
1017
|
+
if (hex.length === 4)
|
|
1018
|
+
hex =
|
|
1019
|
+
hex.slice(0, 1) +
|
|
1020
|
+
hex.slice(0, 1) +
|
|
1021
|
+
hex.slice(1, 2) +
|
|
1022
|
+
hex.slice(1, 2) +
|
|
1023
|
+
hex.slice(2, 3) +
|
|
1024
|
+
hex.slice(2, 3) +
|
|
1025
|
+
hex.slice(3, 4) +
|
|
1026
|
+
hex.slice(3, 4);
|
|
1027
|
+
return [
|
|
1028
|
+
hex.slice(0, 2),
|
|
1029
|
+
hex.slice(2, 4),
|
|
1030
|
+
hex.slice(4, 6),
|
|
1031
|
+
hex.slice(4, 6),
|
|
1032
|
+
].map(function (str, index) {
|
|
1033
|
+
if (index === 3)
|
|
1034
|
+
return parseInt(str, 16) / 256;
|
|
1035
|
+
return parseInt(str, 16);
|
|
1036
|
+
});
|
|
1037
|
+
};
|
|
1024
1038
|
var replaceAll = function (string, target, replace) {
|
|
1025
1039
|
while (string.indexOf(target) !== -1) {
|
|
1026
1040
|
string = string.replace(target, replace);
|
|
@@ -1282,6 +1296,7 @@
|
|
|
1282
1296
|
size: undefined,
|
|
1283
1297
|
fontSize: undefined,
|
|
1284
1298
|
color: undefined,
|
|
1299
|
+
strokeColor: undefined,
|
|
1285
1300
|
font: undefined,
|
|
1286
1301
|
full: false,
|
|
1287
1302
|
ender: false,
|
|
@@ -1292,10 +1307,19 @@
|
|
|
1292
1307
|
for (var _i = 0, metadata_1 = metadata; _i < metadata_1.length; _i++) {
|
|
1293
1308
|
var command = metadata_1[_i];
|
|
1294
1309
|
command = command.toLowerCase();
|
|
1295
|
-
var match =
|
|
1296
|
-
if (match && match[1]) {
|
|
1310
|
+
var match = void 0;
|
|
1311
|
+
if ((match = command.match(/^(?:@|\uff20)([0-9.]+)/)) && match[1]) {
|
|
1297
1312
|
result.long = Number(match[1]);
|
|
1298
1313
|
}
|
|
1314
|
+
else if (result.strokeColor === undefined &&
|
|
1315
|
+
(match = command.match(/^nico:stroke:(.+)$/))) {
|
|
1316
|
+
if (typeGuard.comment.color(match[1])) {
|
|
1317
|
+
result.strokeColor = colors[match[1]];
|
|
1318
|
+
}
|
|
1319
|
+
else if (typeGuard.comment.colorCode(match[1])) {
|
|
1320
|
+
result.strokeColor = match[1].slice(1);
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1299
1323
|
else if (result.loc === undefined && typeGuard.comment.loc(command)) {
|
|
1300
1324
|
result.loc = command;
|
|
1301
1325
|
}
|
|
@@ -1327,6 +1351,20 @@
|
|
|
1327
1351
|
}
|
|
1328
1352
|
}
|
|
1329
1353
|
return result;
|
|
1354
|
+
};
|
|
1355
|
+
var getStrokeColor = function (comment) {
|
|
1356
|
+
if (comment.strokeColor) {
|
|
1357
|
+
var length_1 = comment.strokeColor.length;
|
|
1358
|
+
if (length_1 === 3 || length_1 === 6) {
|
|
1359
|
+
return "rgba(".concat(hex2rgb(comment.strokeColor).join(","), ",").concat(config.contextStrokeOpacity, ")");
|
|
1360
|
+
}
|
|
1361
|
+
else if (length_1 === 4 || length_1 === 8) {
|
|
1362
|
+
return "rgba(".concat(hex2rgba(comment.strokeColor).join(","), ")");
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
return "rgba(".concat(hex2rgb(comment.color === "#000000"
|
|
1366
|
+
? config.contextStrokeInversionColor
|
|
1367
|
+
: config.contextStrokeColor).join(","), ",").concat(config.contextStrokeOpacity, ")");
|
|
1330
1368
|
};
|
|
1331
1369
|
|
|
1332
1370
|
var getLineHeight = function (fontSize, isFlash, resized) {
|
|
@@ -1577,6 +1615,9 @@
|
|
|
1577
1615
|
item.width = itemWidth[i];
|
|
1578
1616
|
}
|
|
1579
1617
|
comment.fontSize = (comment.charSize || 0) * 0.8;
|
|
1618
|
+
var charScale = getFontSizeAndScale(comment.charSize || 0);
|
|
1619
|
+
if (charScale.scale < 1)
|
|
1620
|
+
height *= 1.01;
|
|
1580
1621
|
return {
|
|
1581
1622
|
width: width * scale,
|
|
1582
1623
|
height: height * scale,
|
|
@@ -1674,6 +1715,7 @@
|
|
|
1674
1715
|
this.context.strokeRect(posX, posY, this.comment.width, this.comment.height);
|
|
1675
1716
|
for (var i = 0; i < this.comment.lineCount; i++) {
|
|
1676
1717
|
var linePosY = (this.comment.lineHeight * (i + 1) +
|
|
1718
|
+
(this.comment.charSize - this.comment.lineHeight) / 2 +
|
|
1677
1719
|
this.comment.lineHeight * -0.16 +
|
|
1678
1720
|
(((_a = config.fonts[this.comment.font]) === null || _a === void 0 ? void 0 : _a.offset) ||
|
|
1679
1721
|
0)) *
|
|
@@ -1696,7 +1738,9 @@
|
|
|
1696
1738
|
var _this = this;
|
|
1697
1739
|
var _a;
|
|
1698
1740
|
if (this.comment.invisible ||
|
|
1699
|
-
(this.comment.lineCount === 1 && this.comment.width === 0)
|
|
1741
|
+
(this.comment.lineCount === 1 && this.comment.width === 0) ||
|
|
1742
|
+
this.comment.height - (this.comment.charSize - this.comment.lineHeight) <=
|
|
1743
|
+
0)
|
|
1700
1744
|
return null;
|
|
1701
1745
|
var cacheKey = JSON.stringify(this.comment.content) +
|
|
1702
1746
|
"@@HTML5@@" +
|
|
@@ -1721,9 +1765,7 @@
|
|
|
1721
1765
|
var context = image.getContext("2d");
|
|
1722
1766
|
if (!context)
|
|
1723
1767
|
throw new Error("Fail to get CanvasRenderingContext2D");
|
|
1724
|
-
context.strokeStyle =
|
|
1725
|
-
? config.contextStrokeInversionColor
|
|
1726
|
-
: config.contextStrokeColor).join(","), ",").concat(config.contextStrokeOpacity, ")");
|
|
1768
|
+
context.strokeStyle = getStrokeColor(this.comment);
|
|
1727
1769
|
context.textAlign = "start";
|
|
1728
1770
|
context.textBaseline = "alphabetic";
|
|
1729
1771
|
context.lineWidth = config.contextLineWidth;
|
|
@@ -1747,6 +1789,7 @@
|
|
|
1747
1789
|
if (line === undefined)
|
|
1748
1790
|
continue;
|
|
1749
1791
|
var posY = (this.comment.lineHeight * (lineCount + 1 + paddingTop) +
|
|
1792
|
+
(this.comment.charSize - this.comment.lineHeight) / 2 +
|
|
1750
1793
|
this.comment.lineHeight * -0.16 +
|
|
1751
1794
|
(((_a = config.fonts[this.comment.font]) === null || _a === void 0 ? void 0 : _a.offset) ||
|
|
1752
1795
|
0)) /
|
|
@@ -2244,7 +2287,9 @@
|
|
|
2244
2287
|
FlashComment.prototype.getTextImage = function () {
|
|
2245
2288
|
var _this = this;
|
|
2246
2289
|
if (this.comment.invisible ||
|
|
2247
|
-
(this.comment.lineCount === 1 && this.comment.width === 0)
|
|
2290
|
+
(this.comment.lineCount === 1 && this.comment.width === 0) ||
|
|
2291
|
+
this.comment.height - (this.comment.charSize - this.comment.lineHeight) <=
|
|
2292
|
+
0)
|
|
2248
2293
|
return null;
|
|
2249
2294
|
var cacheKey = JSON.stringify(this.comment.content) +
|
|
2250
2295
|
"@@FLASH@@" +
|
|
@@ -2266,9 +2311,7 @@
|
|
|
2266
2311
|
var context = image.getContext("2d");
|
|
2267
2312
|
if (!context)
|
|
2268
2313
|
throw new Error("Fail to get CanvasRenderingContext2D");
|
|
2269
|
-
context.strokeStyle =
|
|
2270
|
-
? config.contextStrokeInversionColor
|
|
2271
|
-
: config.contextStrokeColor).join(","), ",").concat(config.contextStrokeOpacity, ")");
|
|
2314
|
+
context.strokeStyle = getStrokeColor(this.comment);
|
|
2272
2315
|
context.textAlign = "start";
|
|
2273
2316
|
context.textBaseline = "alphabetic";
|
|
2274
2317
|
context.lineWidth = 4;
|
|
@@ -2700,6 +2743,7 @@
|
|
|
2700
2743
|
NiconiComments.prototype.clear = function () {
|
|
2701
2744
|
this.context.clearRect(0, 0, config.canvasWidth, config.canvasHeight);
|
|
2702
2745
|
};
|
|
2746
|
+
NiconiComments.typeGuard = typeGuard;
|
|
2703
2747
|
return NiconiComments;
|
|
2704
2748
|
}());
|
|
2705
2749
|
var logger = function (msg) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpadev-net/niconicomments",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.38",
|
|
4
4
|
"description": "NiconiComments is a comment drawing library that is somewhat compatible with the official Nico Nico Douga player.",
|
|
5
5
|
"main": "dist/bundle.js",
|
|
6
6
|
"types": "dist/bundle.d.ts",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"prettier": "2.7.1",
|
|
60
60
|
"rimraf": "^3.0.2",
|
|
61
61
|
"rollup": "^3.3.0",
|
|
62
|
+
"tslib": "^2.4.1",
|
|
62
63
|
"typedoc": "^0.23.21",
|
|
63
64
|
"typedoc-plugin-missing-exports": "^1.0.0",
|
|
64
65
|
"typescript": "^4.9.3"
|