@xpadev-net/niconicomments 0.2.50 → 0.2.52

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/dist/bundle.d.ts CHANGED
@@ -1,11 +1,15 @@
1
+ /// <reference types="node" />
2
+ type Canvas = HTMLCanvasElement;
3
+ type Context2D = CanvasRenderingContext2D;
4
+
1
5
  declare class BaseComment implements IComment {
2
- protected readonly context: CanvasRenderingContext2D;
3
- protected readonly cacheKey: string;
6
+ protected readonly context: Context2D;
7
+ protected cacheKey: string;
4
8
  comment: FormattedCommentWithSize;
5
9
  posY: number;
6
10
  readonly pluginName: string;
7
- image?: HTMLCanvasElement | null;
8
- constructor(comment: FormattedComment, context: CanvasRenderingContext2D);
11
+ image?: Canvas | null;
12
+ constructor(comment: FormattedComment, context: Context2D);
9
13
  get invisible(): boolean;
10
14
  get loc(): CommentLoc;
11
15
  get long(): number;
@@ -16,8 +20,11 @@ declare class BaseComment implements IComment {
16
20
  get layer(): number;
17
21
  get owner(): boolean;
18
22
  get mail(): string[];
23
+ get content(): string;
24
+ set content(_: string);
19
25
  protected getCommentSize(parsedData: FormattedCommentWithFont): FormattedCommentWithSize;
20
26
  protected parseCommandAndNicoscript(comment: FormattedComment): FormattedCommentWithFont;
27
+ protected parseContent(comment: string): ParseContentResult;
21
28
  protected measureText(comment: MeasureTextInput): MeasureTextResult;
22
29
  protected convertComment(comment: FormattedComment): FormattedCommentWithSize;
23
30
  draw(vpos: number, showCollision: boolean, debug: boolean): void;
@@ -25,12 +32,12 @@ declare class BaseComment implements IComment {
25
32
  protected _drawRectColor(posX: number, posY: number): void;
26
33
  protected _drawDebugInfo(posX: number, posY: number, debug: boolean): void;
27
34
  protected _drawCollision(posX: number, posY: number, showCollision: boolean): void;
28
- protected getTextImage(): HTMLCanvasElement | null;
29
- protected _generateTextImage(): HTMLCanvasElement;
30
- protected _cacheImage(image: HTMLCanvasElement): void;
35
+ protected getTextImage(): Canvas | null;
36
+ protected _generateTextImage(): Canvas;
37
+ protected _cacheImage(image: Canvas): void;
31
38
  protected createCanvas(): {
32
- image: HTMLCanvasElement;
33
- context: CanvasRenderingContext2D;
39
+ image: Canvas;
40
+ context: Context2D;
34
41
  };
35
42
  }
36
43
 
@@ -39,26 +46,41 @@ declare class FlashComment extends BaseComment {
39
46
  private scale;
40
47
  private scaleX;
41
48
  readonly pluginName: string;
42
- constructor(comment: FormattedComment, context: CanvasRenderingContext2D);
49
+ constructor(comment: FormattedComment, context: Context2D);
50
+ get content(): string;
51
+ set content(input: string);
43
52
  convertComment(comment: FormattedComment): FormattedCommentWithSize;
44
53
  getCommentSize(parsedData: FormattedCommentWithFont): FormattedCommentWithSize;
45
54
  parseCommandAndNicoscript(comment: FormattedComment): FormattedCommentWithFont;
55
+ parseContent(input: string): {
56
+ content: CommentContentItem[];
57
+ lineCount: number;
58
+ lineOffset: number;
59
+ };
46
60
  measureText(comment: MeasureTextInput): MeasureTextResult;
61
+ private _measureContent;
47
62
  _drawCollision(posX: number, posY: number, showCollision: boolean): void;
48
- _generateTextImage(): HTMLCanvasElement;
63
+ _generateTextImage(): Canvas;
49
64
  }
50
65
 
51
66
  declare class HTML5Comment extends BaseComment {
52
67
  readonly pluginName: string;
53
- constructor(comment: FormattedComment, context: CanvasRenderingContext2D);
68
+ constructor(comment: FormattedComment, context: Context2D);
69
+ get content(): string;
70
+ set content(input: string);
54
71
  convertComment(comment: FormattedComment): FormattedCommentWithSize;
55
72
  getCommentSize(parsedData: FormattedCommentWithFont): FormattedCommentWithSize;
56
73
  parseCommandAndNicoscript(comment: FormattedComment): FormattedCommentWithFont;
74
+ parseContent(input: string): {
75
+ content: CommentContentItem[];
76
+ lineCount: number;
77
+ lineOffset: number;
78
+ };
57
79
  measureText(comment: MeasureTextInput): MeasureTextResult;
58
80
  private _measureComment;
59
81
  private _processResizeX;
60
82
  _drawCollision(posX: number, posY: number, showCollision: boolean): void;
61
- _generateTextImage(): HTMLCanvasElement;
83
+ _generateTextImage(): Canvas;
62
84
  }
63
85
 
64
86
  type index_d$3_BaseComment = BaseComment;
@@ -75,81 +97,81 @@ declare namespace index_d$3 {
75
97
  };
76
98
  }
77
99
 
78
- type ConfigItem<T> = T | { html5: T; flash: T };
79
- type ConfigSizeItem<T> = { big: T; medium: T; small: T };
80
- type ConfigResizedItem<T> = { default: T; resized: T };
81
-
82
- type CommentStageSize = {
83
- width: number;
84
- fullWidth: number;
85
- height: number;
86
- };
87
-
88
- type FlashCharList = {
89
- [key in "simsunStrong" | "simsunWeak" | "gulim" | "gothic"]: string;
90
- };
91
- type FlashMode = "xp" | "vista";
92
- type FlashScriptChar = {
93
- [key in "super" | "sub"]: string;
94
- };
95
- type FontList = {
96
- [key in "gulim" | "simsun"]: string;
97
- };
98
- type LineCounts = {
99
- [key in "default" | "resized" | "doubleResized"]: ConfigSizeItem<number>;
100
- };
101
- type TypeDoubleResizeMaxWidth = {
102
- [key in "full" | "normal"]: number;
103
- };
104
-
105
- type BaseConfig = {
106
- cacheAge: number;
107
- canvasHeight: number;
108
- canvasWidth: number;
109
- collisionRange: { [key in "left" | "right"]: number };
110
- colors: { [key: string]: string };
111
- commentDrawPadding: number;
112
- commentDrawRange: number;
113
- commentScale: ConfigItem<number>;
114
- CommentStageSize: ConfigItem<CommentStageSize>;
115
- commentYMarginBottom: ConfigSizeItem<number>;
116
- commentYOffset: ConfigSizeItem<ConfigResizedItem<number>>;
117
- commentYPaddingTop: ConfigResizedItem<number>;
118
- contextFillLiveOpacity: number;
119
- contextLineWidth: number;
120
- contextStrokeColor: string;
121
- contextStrokeInversionColor: string;
122
- contextStrokeOpacity: number;
123
- doubleResizeMaxWidth: ConfigItem<TypeDoubleResizeMaxWidth>;
124
- flashChar: FlashCharList;
125
- FlashMode: FlashMode;
126
- FlashScriptChar: FlashScriptChar;
127
- flashThreshold: number;
128
- font: FontList;
129
- fonts: PlatformFont;
130
- fontSize: ConfigItem<ConfigSizeItem<ConfigResizedItem<number>>>;
131
- fpsInterval: number;
132
- hiResCommentCorrection: number;
133
- lineCounts: ConfigItem<LineCounts>;
134
- lineHeight: ConfigItem<ConfigSizeItem<ConfigResizedItem<number>>>;
135
- minFontSize: number;
136
- sameCAGap: number;
137
- sameCAMinScore: number;
138
- sameCARange: number;
139
- sameCATimestampRange: number;
140
- letterSpacing: number;
141
- scriptCharOffset: number;
142
- plugins: IPluginConstructor[];
143
- commentPlugins: {
144
- class: typeof BaseComment;
145
- condition: (comment: FormattedComment) => boolean;
146
- }[];
147
- commentLimit: number | undefined;
148
- hideCommentOrder: "asc" | "desc";
149
- lineBreakCount: { [key in CommentSize]: number };
150
- nakaCommentSpeedOffset: number;
151
- };
152
-
100
+ type ConfigItem<T> = T | { html5: T; flash: T };
101
+ type ConfigSizeItem<T> = { big: T; medium: T; small: T };
102
+ type ConfigResizedItem<T> = { default: T; resized: T };
103
+
104
+ type CommentStageSize = {
105
+ width: number;
106
+ fullWidth: number;
107
+ height: number;
108
+ };
109
+
110
+ type FlashCharList = {
111
+ [key in "simsunStrong" | "simsunWeak" | "gulim" | "gothic"]: string;
112
+ };
113
+ type FlashMode = "xp" | "vista";
114
+ type FlashScriptChar = {
115
+ [key in "super" | "sub"]: string;
116
+ };
117
+ type FontList = {
118
+ [key in "gulim" | "simsun"]: string;
119
+ };
120
+ type LineCounts = {
121
+ [key in "default" | "resized" | "doubleResized"]: ConfigSizeItem<number>;
122
+ };
123
+ type TypeDoubleResizeMaxWidth = {
124
+ [key in "full" | "normal"]: number;
125
+ };
126
+
127
+ type BaseConfig = {
128
+ cacheAge: number;
129
+ canvasHeight: number;
130
+ canvasWidth: number;
131
+ collisionRange: { [key in "left" | "right"]: number };
132
+ colors: { [key: string]: string };
133
+ commentDrawPadding: number;
134
+ commentDrawRange: number;
135
+ commentScale: ConfigItem<number>;
136
+ CommentStageSize: ConfigItem<CommentStageSize>;
137
+ commentYMarginBottom: ConfigSizeItem<number>;
138
+ commentYOffset: ConfigSizeItem<ConfigResizedItem<number>>;
139
+ commentYPaddingTop: ConfigResizedItem<number>;
140
+ contextFillLiveOpacity: number;
141
+ contextLineWidth: number;
142
+ contextStrokeColor: string;
143
+ contextStrokeInversionColor: string;
144
+ contextStrokeOpacity: number;
145
+ doubleResizeMaxWidth: ConfigItem<TypeDoubleResizeMaxWidth>;
146
+ flashChar: FlashCharList;
147
+ FlashMode: FlashMode;
148
+ FlashScriptChar: FlashScriptChar;
149
+ flashThreshold: number;
150
+ font: FontList;
151
+ fonts: PlatformFont;
152
+ fontSize: ConfigItem<ConfigSizeItem<ConfigResizedItem<number>>>;
153
+ fpsInterval: number;
154
+ hiResCommentCorrection: number;
155
+ lineCounts: ConfigItem<LineCounts>;
156
+ lineHeight: ConfigItem<ConfigSizeItem<ConfigResizedItem<number>>>;
157
+ minFontSize: number;
158
+ sameCAGap: number;
159
+ sameCAMinScore: number;
160
+ sameCARange: number;
161
+ sameCATimestampRange: number;
162
+ letterSpacing: number;
163
+ scriptCharOffset: number;
164
+ plugins: IPluginConstructor[];
165
+ commentPlugins: {
166
+ class: typeof BaseComment;
167
+ condition: (comment: FormattedComment) => boolean;
168
+ }[];
169
+ commentLimit: number | undefined;
170
+ hideCommentOrder: "asc" | "desc";
171
+ lineBreakCount: { [key in CommentSize]: number };
172
+ nakaCommentSpeedOffset: number;
173
+ };
174
+
153
175
  type Config = Partial<BaseConfig>;
154
176
 
155
177
  interface CommentEventBase {
@@ -215,381 +237,403 @@ interface CommentEventMap {
215
237
  jump: JumpEvent;
216
238
  }
217
239
 
218
- type Platform =
219
- | "win7"
220
- | "win8_1"
221
- | "win"
222
- | "mac10_9"
223
- | "mac10_11"
224
- | "mac"
225
- | "other";
226
- type HTML5Fonts = "gothic" | "mincho" | "defont";
227
- type FontItem = {
228
- font: string;
229
- offset: number;
230
- weight: number;
231
- };
232
- type PlatformFont = {
233
- [key in HTML5Fonts]: FontItem;
240
+ type Platform =
241
+ | "win7"
242
+ | "win8_1"
243
+ | "win"
244
+ | "mac10_9"
245
+ | "mac10_11"
246
+ | "mac"
247
+ | "other";
248
+ type HTML5Fonts = "gothic" | "mincho" | "defont";
249
+ type FontItem = {
250
+ font: string;
251
+ offset: number;
252
+ weight: number;
253
+ };
254
+ type PlatformFont = {
255
+ [key in HTML5Fonts]: FontItem;
234
256
  };
235
257
 
236
- type FormattedComment = {
237
- id: number;
238
- vpos: number;
239
- content: string;
240
- date: number;
241
- date_usec: number;
242
- owner: boolean;
243
- premium: boolean;
244
- mail: string[];
245
- user_id: number;
246
- layer: number;
247
- };
248
- type FormattedLegacyComment = {
249
- id: number;
250
- vpos: number;
251
- content: string;
252
- date: number;
253
- date_usec: number;
254
- owner: boolean;
255
- premium: boolean;
256
- mail: string[];
257
- };
258
-
259
- /**
260
- * @deprecated
261
- */
262
- type formattedComment = FormattedComment;
263
- /**
264
- * @deprecated
265
- */
258
+ type FormattedComment = {
259
+ id: number;
260
+ vpos: number;
261
+ content: string;
262
+ date: number;
263
+ date_usec: number;
264
+ owner: boolean;
265
+ premium: boolean;
266
+ mail: string[];
267
+ user_id: number;
268
+ layer: number;
269
+ };
270
+ type FormattedLegacyComment = {
271
+ id: number;
272
+ vpos: number;
273
+ content: string;
274
+ date: number;
275
+ date_usec: number;
276
+ owner: boolean;
277
+ premium: boolean;
278
+ mail: string[];
279
+ };
280
+
281
+ /**
282
+ * @deprecated
283
+ */
284
+ type formattedComment = FormattedComment;
285
+ /**
286
+ * @deprecated
287
+ */
266
288
  type formattedLegacyComment = FormattedLegacyComment;
267
289
 
268
- type RawApiResponse = {
269
- [key: string]: ApiPing | ApiThread | ApiLeaf | ApiGlobalNumRes | ApiChat;
270
- };
271
- type ApiPing = {
272
- content: string;
273
- };
274
- type ApiThread = {
275
- resultcode: number;
276
- thread: string;
277
- server_time: number;
278
- ticket: string;
279
- revision: number;
280
- };
281
- type ApiLeaf = {
282
- thread: string;
283
- count: number;
284
- };
285
- type ApiGlobalNumRes = {
286
- thread: string;
287
- num_res: number;
288
- };
289
- type ApiChat = {
290
- thread: string;
291
- no: number;
292
- vpos: number;
293
- date: number;
294
- date_usec: number;
295
- nicoru: number;
296
- premium: number;
297
- anonymity: number;
298
- user_id: string;
299
- mail: string;
300
- content: string;
301
- deleted: number;
302
- };
303
-
304
- /**
305
- * @deprecated
306
- */
290
+ type RawApiResponse = {
291
+ [key: string]: ApiPing | ApiThread | ApiLeaf | ApiGlobalNumRes | ApiChat;
292
+ };
293
+ type ApiPing = {
294
+ content: string;
295
+ };
296
+ type ApiThread = {
297
+ resultcode: number;
298
+ thread: string;
299
+ server_time: number;
300
+ ticket: string;
301
+ revision: number;
302
+ };
303
+ type ApiLeaf = {
304
+ thread: string;
305
+ count: number;
306
+ };
307
+ type ApiGlobalNumRes = {
308
+ thread: string;
309
+ num_res: number;
310
+ };
311
+ type ApiChat = {
312
+ thread: string;
313
+ no: number;
314
+ vpos: number;
315
+ date: number;
316
+ date_usec: number;
317
+ nicoru: number;
318
+ premium: number;
319
+ anonymity: number;
320
+ user_id: string;
321
+ mail: string;
322
+ content: string;
323
+ deleted: number;
324
+ };
325
+
326
+ /**
327
+ * @deprecated
328
+ */
307
329
  type rawApiResponse = RawApiResponse;
308
330
 
309
- type OwnerComment = {
310
- time: string;
311
- command: string;
312
- comment: string;
313
- };
314
-
315
- /**
316
- * @deprecated
317
- */
331
+ type OwnerComment = {
332
+ time: string;
333
+ command: string;
334
+ comment: string;
335
+ };
336
+
337
+ /**
338
+ * @deprecated
339
+ */
318
340
  type ownerComment = OwnerComment;
319
341
 
320
- type V1Thread = {
321
- id: string;
322
- fork: string;
323
- commentCount: number;
324
- comments: V1Comment[];
325
- };
326
- type V1Comment = {
327
- id: string;
328
- no: number;
329
- vposMs: number;
330
- body: string;
331
- commands: string[];
332
- userId: string;
333
- isPremium: boolean;
334
- score: number;
335
- postedAt: string;
336
- nicoruCount: number;
337
- nicoruId: undefined;
338
- source: string;
339
- isMyPost: boolean;
340
- };
341
-
342
- /**
343
- * @deprecated
344
- */
342
+ type V1Thread = {
343
+ id: string;
344
+ fork: string;
345
+ commentCount: number;
346
+ comments: V1Comment[];
347
+ };
348
+ type V1Comment = {
349
+ id: string;
350
+ no: number;
351
+ vposMs: number;
352
+ body: string;
353
+ commands: string[];
354
+ userId: string;
355
+ isPremium: boolean;
356
+ score: number;
357
+ postedAt: string;
358
+ nicoruCount: number;
359
+ nicoruId: undefined;
360
+ source: string;
361
+ isMyPost: boolean;
362
+ };
363
+
364
+ /**
365
+ * @deprecated
366
+ */
345
367
  type v1Thread = V1Thread;
346
368
 
347
- interface IComment {
348
- comment: FormattedCommentWithSize;
349
- invisible: boolean;
350
- loc: CommentLoc;
351
- width: number;
352
- long: number;
353
- height: number;
354
- vpos: number;
355
- flash: boolean;
356
- posY: number;
357
- owner: boolean;
358
- layer: number;
359
- mail: string[];
360
- image?: HTMLCanvasElement | null;
361
- draw: (vpos: number, showCollision: boolean, isDebug: boolean) => void;
369
+ interface IComment {
370
+ comment: FormattedCommentWithSize;
371
+ invisible: boolean;
372
+ loc: CommentLoc;
373
+ width: number;
374
+ long: number;
375
+ height: number;
376
+ vpos: number;
377
+ flash: boolean;
378
+ posY: number;
379
+ owner: boolean;
380
+ layer: number;
381
+ mail: string[];
382
+ content: string;
383
+ image?: Canvas | null;
384
+ draw: (vpos: number, showCollision: boolean, isDebug: boolean) => void;
385
+ }
386
+
387
+ interface IPluginConstructor {
388
+ id: string;
389
+ new (Canvas: Canvas, comments: IComment[]): IPlugin;
362
390
  }
363
391
 
364
- interface IPluginConstructor {
365
- id: string;
366
- new (Canvas: HTMLCanvasElement, comments: FormattedComment[]): IPlugin;
367
- }
368
-
369
- interface IPlugin {
370
- draw(vpos: number): void;
371
- addComments(comments: FormattedComment[]): void;
392
+ interface IPlugin {
393
+ draw(vpos: number): void;
394
+ addComments(comments: IComment[]): void;
372
395
  }
373
396
 
374
- type InputFormatType =
375
- | "XMLDocument"
376
- | "niconicome"
377
- | "formatted"
378
- | "legacy"
379
- | "legacyOwner"
380
- | "owner"
381
- | "v1"
382
- | "empty"
383
- | "default";
384
- type InputFormat =
385
- | XMLDocument
386
- | FormattedComment[]
387
- | FormattedLegacyComment[]
388
- | RawApiResponse[]
389
- | OwnerComment[]
390
- | V1Thread[]
391
- | string
392
- | undefined;
393
- type ModeType = "default" | "html5" | "flash";
394
- type BaseOptions = {
395
- config: Config;
396
- debug: boolean;
397
- enableLegacyPiP: boolean;
398
- format: InputFormatType;
399
- formatted: boolean;
400
- keepCA: boolean;
401
- mode: ModeType;
402
- scale: number;
403
- showCollision: boolean;
404
- showCommentCount: boolean;
405
- showFPS: boolean;
406
- useLegacy: boolean;
407
- video: HTMLVideoElement | undefined;
408
- };
409
- type Options = Partial<BaseOptions>;
410
-
411
- /**
412
- * @deprecated
413
- */
414
- type inputFormatType = InputFormatType;
415
- /**
416
- * @deprecated
417
- */
397
+ type InputFormatType =
398
+ | "XMLDocument"
399
+ | "niconicome"
400
+ | "formatted"
401
+ | "legacy"
402
+ | "legacyOwner"
403
+ | "owner"
404
+ | "v1"
405
+ | "empty"
406
+ | "default";
407
+ type InputFormat =
408
+ | XMLDocument
409
+ | FormattedComment[]
410
+ | FormattedLegacyComment[]
411
+ | RawApiResponse[]
412
+ | OwnerComment[]
413
+ | V1Thread[]
414
+ | string
415
+ | undefined;
416
+ type ModeType = "default" | "html5" | "flash";
417
+ type BaseOptions = {
418
+ config: Config;
419
+ debug: boolean;
420
+ enableLegacyPiP: boolean;
421
+ format: InputFormatType;
422
+ formatted: boolean;
423
+ keepCA: boolean;
424
+ mode: ModeType;
425
+ scale: number;
426
+ showCollision: boolean;
427
+ showCommentCount: boolean;
428
+ showFPS: boolean;
429
+ useLegacy: boolean;
430
+ video: HTMLVideoElement | undefined;
431
+ };
432
+ type Options = Partial<BaseOptions>;
433
+
434
+ /**
435
+ * @deprecated
436
+ */
437
+ type inputFormatType = InputFormatType;
438
+ /**
439
+ * @deprecated
440
+ */
418
441
  type inputFormat = InputFormat;
419
442
 
420
- type FormattedCommentWithFont = {
421
- id: number;
422
- vpos: number;
423
- date: number;
424
- date_usec: number;
425
- owner: boolean;
426
- premium: boolean;
427
- mail: string[];
428
- user_id: number;
429
- layer: number;
430
- loc: CommentLoc;
431
- size: CommentSize;
432
- fontSize: number;
433
- font: CommentFont;
434
- color: string;
435
- strokeColor?: string;
436
- wakuColor?: string;
437
- full: boolean;
438
- ender: boolean;
439
- _live: boolean;
440
- long: number;
441
- invisible: boolean;
442
- content: CommentContentItem[];
443
- flash: boolean;
444
- lineCount: number;
445
- lineOffset: number;
446
- };
447
- type FormattedCommentWithSize = FormattedCommentWithFont & {
448
- height: number;
449
- width: number;
450
- lineHeight: number;
451
- resized: boolean;
452
- resizedX: boolean;
453
- resizedY: boolean;
454
- content: CommentMeasuredContentItem[];
455
- charSize: number;
456
- };
457
- type CommentContentItem = {
458
- content: string;
459
- slicedContent: string[];
460
- font?: CommentFlashFont;
461
- width?: number[];
462
- };
463
- type CommentMeasuredContentItem = CommentContentItem & {
464
- width: number[];
465
- };
466
- type CommentContentIndex = {
467
- index: number;
468
- font: "gothic" | "gulim" | "simsunStrong" | "simsunWeak";
469
- };
470
- type CommentFont = "defont" | "mincho" | "gothic" | "gulim" | "simsun";
471
- type CommentFlashFont = "defont" | "gulim" | "simsun";
472
- type CommentSize = "big" | "medium" | "small";
473
- type CommentLoc = "ue" | "naka" | "shita";
474
- type Collision = { [key in CollisionPos]: CollisionItem };
475
- type Timeline = { [key: number]: IComment[] };
476
- type CollisionPos = "ue" | "shita" | "right" | "left";
477
- type CollisionItem = { [p: number]: IComment[] };
478
- type NicoScript = {
479
- reverse: NicoScriptReverse[];
480
- ban: NicoScriptBan[];
481
- default: NicoScriptDefault[];
482
- replace: NicoScriptReplace[];
483
- seekDisable: NicoScriptSeekDisable[];
484
- jump: NicoScriptJump[];
485
- };
486
- type NicoScriptSeekDisable = {
487
- start: number;
488
- end: number;
489
- };
490
- type NicoScriptJump = {
491
- start: number;
492
- end?: number;
493
- to: string;
494
- message?: string;
495
- };
496
- type NicoScriptReverse = {
497
- target: NicoScriptReverseTarget;
498
- start: number;
499
- end: number;
500
- };
501
- type NicoScriptReverseTarget = "コメ" | "投コメ" | "全";
502
- type NicoScriptReplace = {
503
- start: number;
504
- long: number | undefined;
505
- keyword: string;
506
- replace: string;
507
- range: NicoScriptReplaceRange;
508
- target: NicoScriptReplaceTarget;
509
- condition: NicoScriptReplaceCondition;
510
- color: string | undefined;
511
- size: CommentSize | undefined;
512
- font: CommentFont | undefined;
513
- loc: CommentLoc | undefined;
514
- no: number;
515
- };
516
- type NicoScriptReplaceRange = "単" | "全";
517
- type NicoScriptReplaceTarget =
518
- | "コメ"
519
- | "投コメ"
520
- | "全"
521
- | "含まない"
522
- | "含む";
523
- type NicoScriptReplaceCondition = "完全一致" | "部分一致";
524
- type NicoScriptBan = {
525
- start: number;
526
- end: number;
527
- };
528
- type NicoScriptDefault = {
529
- start: number;
530
- long: number | undefined;
531
- color: string | undefined;
532
- size: CommentSize | undefined;
533
- font: CommentFont | undefined;
534
- loc: CommentLoc | undefined;
535
- };
536
- type MeasureTextResult = {
537
- width: number;
538
- height: number;
539
- resized: boolean;
540
- resizedX: boolean;
541
- resizedY: boolean;
542
- fontSize: number;
543
- lineHeight: number;
544
- content: CommentMeasuredContentItem[];
545
- charSize: number;
546
- };
547
- type ParsedCommand = {
548
- loc: CommentLoc | undefined;
549
- size: CommentSize | undefined;
550
- fontSize: number | undefined;
551
- color: string | undefined;
552
- strokeColor?: string;
553
- wakuColor?: string;
554
- font: CommentFont | undefined;
555
- full: boolean;
556
- ender: boolean;
557
- _live: boolean;
558
- invisible: boolean;
559
- long: number | undefined;
560
- };
561
-
562
- type MeasureTextInput = {
563
- content: CommentContentItem[];
564
- resized?: boolean;
565
- ender: boolean;
566
- size: CommentSize;
567
- fontSize: number;
568
- resizedY?: boolean;
569
- resizedX?: boolean;
570
- font: CommentFont;
571
- loc: CommentLoc;
572
- full: boolean;
573
- flash: boolean;
574
- lineCount: number;
575
- lineHeight?: number;
576
- charSize?: number;
577
- };
578
-
579
- type MeasureInput = {
580
- font: CommentFont;
581
- content: CommentContentItem[];
582
- lineHeight: number;
583
- charSize: number;
584
- lineCount: number;
585
- };
586
-
443
+ type FormattedCommentWithFont = {
444
+ id: number;
445
+ vpos: number;
446
+ date: number;
447
+ date_usec: number;
448
+ owner: boolean;
449
+ premium: boolean;
450
+ mail: string[];
451
+ user_id: number;
452
+ layer: number;
453
+ loc: CommentLoc;
454
+ size: CommentSize;
455
+ fontSize: number;
456
+ font: CommentFont;
457
+ color: string;
458
+ strokeColor?: string;
459
+ wakuColor?: string;
460
+ full: boolean;
461
+ ender: boolean;
462
+ _live: boolean;
463
+ long: number;
464
+ invisible: boolean;
465
+ content: CommentContentItem[];
466
+ rawContent: string;
467
+ flash: boolean;
468
+ lineCount: number;
469
+ lineOffset: number;
470
+ };
471
+ type FormattedCommentWithSize = FormattedCommentWithFont & {
472
+ height: number;
473
+ width: number;
474
+ lineHeight: number;
475
+ resized: boolean;
476
+ resizedX: boolean;
477
+ resizedY: boolean;
478
+ content: CommentMeasuredContentItem[];
479
+ charSize: number;
480
+ };
481
+ type ParseContentResult = {
482
+ content: CommentContentItem[];
483
+ lineCount: number;
484
+ lineOffset: number;
485
+ };
486
+ type ParseCommandAndNicoScriptResult = {
487
+ flash: boolean;
488
+ loc: CommentLoc;
489
+ size: CommentSize;
490
+ fontSize: number;
491
+ color: string;
492
+ strokeColor?: string;
493
+ wakuColor?: string;
494
+ font: CommentFont;
495
+ full: boolean;
496
+ ender: boolean;
497
+ _live: boolean;
498
+ invisible: boolean;
499
+ long: number;
500
+ };
501
+ type CommentContentItem = {
502
+ content: string;
503
+ slicedContent: string[];
504
+ font?: CommentFlashFont;
505
+ width?: number[];
506
+ };
507
+ type CommentMeasuredContentItem = CommentContentItem & {
508
+ width: number[];
509
+ };
510
+ type CommentContentIndex = {
511
+ index: number;
512
+ font: "gothic" | "gulim" | "simsunStrong" | "simsunWeak";
513
+ };
514
+ type CommentFont = "defont" | "mincho" | "gothic" | "gulim" | "simsun";
515
+ type CommentFlashFont = "defont" | "gulim" | "simsun";
516
+ type CommentSize = "big" | "medium" | "small";
517
+ type CommentLoc = "ue" | "naka" | "shita";
518
+ type Collision = { [key in CollisionPos]: CollisionItem };
519
+ type Timeline = { [key: number]: IComment[] };
520
+ type CollisionPos = "ue" | "shita" | "right" | "left";
521
+ type CollisionItem = { [p: number]: IComment[] };
522
+ type NicoScript = {
523
+ reverse: NicoScriptReverse[];
524
+ ban: NicoScriptBan[];
525
+ default: NicoScriptDefault[];
526
+ replace: NicoScriptReplace[];
527
+ seekDisable: NicoScriptSeekDisable[];
528
+ jump: NicoScriptJump[];
529
+ };
530
+ type NicoScriptSeekDisable = {
531
+ start: number;
532
+ end: number;
533
+ };
534
+ type NicoScriptJump = {
535
+ start: number;
536
+ end?: number;
537
+ to: string;
538
+ message?: string;
539
+ };
540
+ type NicoScriptReverse = {
541
+ target: NicoScriptReverseTarget;
542
+ start: number;
543
+ end: number;
544
+ };
545
+ type NicoScriptReverseTarget = "コメ" | "投コメ" | "全";
546
+ type NicoScriptReplace = {
547
+ start: number;
548
+ long: number | undefined;
549
+ keyword: string;
550
+ replace: string;
551
+ range: NicoScriptReplaceRange;
552
+ target: NicoScriptReplaceTarget;
553
+ condition: NicoScriptReplaceCondition;
554
+ color: string | undefined;
555
+ size: CommentSize | undefined;
556
+ font: CommentFont | undefined;
557
+ loc: CommentLoc | undefined;
558
+ no: number;
559
+ };
560
+ type NicoScriptReplaceRange = "単" | "全";
561
+ type NicoScriptReplaceTarget =
562
+ | "コメ"
563
+ | "投コメ"
564
+ | "全"
565
+ | "含まない"
566
+ | "含む";
567
+ type NicoScriptReplaceCondition = "完全一致" | "部分一致";
568
+ type NicoScriptBan = {
569
+ start: number;
570
+ end: number;
571
+ };
572
+ type NicoScriptDefault = {
573
+ start: number;
574
+ long: number | undefined;
575
+ color: string | undefined;
576
+ size: CommentSize | undefined;
577
+ font: CommentFont | undefined;
578
+ loc: CommentLoc | undefined;
579
+ };
580
+ type MeasureTextResult = {
581
+ width: number;
582
+ height: number;
583
+ resized: boolean;
584
+ resizedX: boolean;
585
+ resizedY: boolean;
586
+ fontSize: number;
587
+ lineHeight: number;
588
+ content: CommentMeasuredContentItem[];
589
+ charSize: number;
590
+ };
591
+ type ParsedCommand = {
592
+ loc: CommentLoc | undefined;
593
+ size: CommentSize | undefined;
594
+ fontSize: number | undefined;
595
+ color: string | undefined;
596
+ strokeColor?: string;
597
+ wakuColor?: string;
598
+ font: CommentFont | undefined;
599
+ full: boolean;
600
+ ender: boolean;
601
+ _live: boolean;
602
+ invisible: boolean;
603
+ long: number | undefined;
604
+ };
605
+
606
+ type MeasureTextInput = {
607
+ content: CommentContentItem[];
608
+ resized?: boolean;
609
+ ender: boolean;
610
+ size: CommentSize;
611
+ fontSize: number;
612
+ resizedY?: boolean;
613
+ resizedX?: boolean;
614
+ font: CommentFont;
615
+ loc: CommentLoc;
616
+ full: boolean;
617
+ flash: boolean;
618
+ lineCount: number;
619
+ lineHeight?: number;
620
+ charSize?: number;
621
+ };
622
+
623
+ type MeasureInput = {
624
+ font: CommentFont;
625
+ content: CommentContentItem[];
626
+ lineHeight: number;
627
+ charSize: number;
628
+ lineCount: number;
629
+ };
630
+
587
631
  type ValueOf<T> = T[keyof T];
588
632
 
589
633
  declare let imageCache: {
590
634
  [key: string]: {
591
- image: HTMLCanvasElement;
592
- timeout: number;
635
+ image: Canvas;
636
+ timeout: number | NodeJS.Timeout;
593
637
  };
594
638
  };
595
639
  declare const resetImageCache: () => void;
@@ -659,8 +703,8 @@ declare const updateConfig: (config: BaseConfig) => void;
659
703
  declare const defaultOptions: BaseOptions;
660
704
  declare let config: BaseConfig;
661
705
  declare let options: BaseOptions;
662
- declare const setConfig: (value: BaseConfig) => BaseConfig;
663
- declare const setOptions: (value: BaseOptions) => BaseOptions;
706
+ declare const setConfig: (value: BaseConfig) => void;
707
+ declare const setOptions: (value: BaseOptions) => void;
664
708
 
665
709
  declare const config$1_config: typeof config;
666
710
  declare const config$1_defaultConfig: typeof defaultConfig;
@@ -939,14 +983,16 @@ declare const hex2rgb: (hex: string) => number[];
939
983
  declare const hex2rgba: (hex: string) => number[];
940
984
  declare const getStrokeColor: (comment: FormattedCommentWithSize) => string;
941
985
 
942
- declare const isLineBreakResize: (comment: MeasureTextInput) => boolean;
943
- declare const getDefaultCommand: (vpos: number) => {
944
- color: string | undefined;
945
- size: CommentSize | undefined;
946
- font: CommentFont | undefined;
947
- loc: CommentLoc | undefined;
986
+ type DefaultCommand = {
987
+ color?: string;
988
+ size?: CommentSize;
989
+ font?: CommentFont;
990
+ loc?: CommentLoc;
948
991
  };
949
- declare const parseCommandAndNicoScript: (comment: FormattedComment) => FormattedCommentWithFont;
992
+
993
+ declare const isLineBreakResize: (comment: MeasureTextInput) => boolean;
994
+ declare const getDefaultCommand: (vpos: number) => DefaultCommand;
995
+ declare const parseCommandAndNicoScript: (comment: FormattedComment) => ParseCommandAndNicoScriptResult;
950
996
  declare const isFlashComment: (comment: FormattedComment) => boolean;
951
997
  declare const isReverseActive: (vpos: number, isOwner: boolean) => boolean;
952
998
  declare const isBanActive: (vpos: number) => boolean;
@@ -966,10 +1012,11 @@ declare const getConfig: <T>(input: ConfigItem<T>, isFlash?: boolean) => T;
966
1012
 
967
1013
  declare const getFlashFontIndex: (part: string) => CommentContentIndex[];
968
1014
  declare const getFlashFontName: (font: string) => CommentFlashFont;
1015
+ declare const parseContent: (content: string) => CommentContentItem[];
969
1016
 
970
1017
  declare const getLineHeight: (fontSize: CommentSize, isFlash: boolean, resized?: boolean) => number;
971
1018
  declare const getCharSize: (fontSize: CommentSize, isFlash: boolean) => number;
972
- declare const measure: (comment: MeasureInput, context: CanvasRenderingContext2D) => {
1019
+ declare const measure: (comment: MeasureInput, context: Context2D) => {
973
1020
  height: number;
974
1021
  width: number;
975
1022
  lineWidth: number[];
@@ -1004,6 +1051,7 @@ declare const index_d_isReverseActive: typeof isReverseActive;
1004
1051
  declare const index_d_measure: typeof measure;
1005
1052
  declare const index_d_nativeSort: typeof nativeSort;
1006
1053
  declare const index_d_parseCommandAndNicoScript: typeof parseCommandAndNicoScript;
1054
+ declare const index_d_parseContent: typeof parseContent;
1007
1055
  declare const index_d_parseFont: typeof parseFont;
1008
1056
  declare const index_d_processFixedComment: typeof processFixedComment;
1009
1057
  declare const index_d_processMovableComment: typeof processMovableComment;
@@ -1031,6 +1079,7 @@ declare namespace index_d {
1031
1079
  index_d_measure as measure,
1032
1080
  index_d_nativeSort as nativeSort,
1033
1081
  index_d_parseCommandAndNicoScript as parseCommandAndNicoScript,
1082
+ index_d_parseContent as parseContent,
1034
1083
  index_d_parseFont as parseFont,
1035
1084
  index_d_processFixedComment as processFixedComment,
1036
1085
  index_d_processMovableComment as processMovableComment,
@@ -1128,7 +1177,7 @@ declare class NiconiComments {
1128
1177
  class: typeof FlashComment;
1129
1178
  };
1130
1179
  static internal: typeof internal;
1131
- constructor(canvas: HTMLCanvasElement, data: InputFormat, initOptions?: Options);
1180
+ constructor(canvas: Canvas, data: InputFormat, initOptions?: Options);
1132
1181
  private preRendering;
1133
1182
  private getCommentPos;
1134
1183
  private sortComment;
@@ -1144,4 +1193,4 @@ declare class NiconiComments {
1144
1193
  clear(): void;
1145
1194
  }
1146
1195
 
1147
- export { ApiChat, ApiGlobalNumRes, ApiLeaf, ApiPing, ApiThread, BaseConfig, BaseOptions, Collision, CollisionItem, CollisionPos, CommentContentIndex, CommentContentItem, CommentDisableEvent, CommentDisableEventHandler, CommentEnableEvent, CommentEnableEventHandler, CommentEventBase, CommentEventHandler, CommentEventHandlerMap, CommentEventMap, CommentEventName, CommentFlashFont, CommentFont, CommentLoc, CommentMeasuredContentItem, CommentSize, CommentStageSize, Config, ConfigItem, FlashMode, FlashScriptChar, FontItem, FormattedComment, FormattedCommentWithFont, FormattedCommentWithSize, FormattedLegacyComment, HTML5Fonts, IComment, IPlugin, IPluginConstructor, InputFormat, InputFormatType, JumpEvent, JumpEventHandler, MeasureInput, MeasureTextInput, MeasureTextResult, NicoScript, NicoScriptReplace, NicoScriptReplaceCondition, NicoScriptReplaceRange, NicoScriptReplaceTarget, NicoScriptReverseTarget, Options, OwnerComment, ParsedCommand, Platform, PlatformFont, RawApiResponse, SeekDisableEvent, SeekDisableEventHandler, SeekEnableEvent, SeekEnableEventHandler, Timeline, V1Comment, V1Thread, ValueOf, NiconiComments as default, formattedComment, formattedLegacyComment, inputFormat, inputFormatType, ownerComment, rawApiResponse, v1Thread };
1196
+ export { ApiChat, ApiGlobalNumRes, ApiLeaf, ApiPing, ApiThread, BaseConfig, BaseOptions, Canvas, Collision, CollisionItem, CollisionPos, CommentContentIndex, CommentContentItem, CommentDisableEvent, CommentDisableEventHandler, CommentEnableEvent, CommentEnableEventHandler, CommentEventBase, CommentEventHandler, CommentEventHandlerMap, CommentEventMap, CommentEventName, CommentFlashFont, CommentFont, CommentLoc, CommentMeasuredContentItem, CommentSize, CommentStageSize, Config, ConfigItem, Context2D, FlashMode, FlashScriptChar, FontItem, FormattedComment, FormattedCommentWithFont, FormattedCommentWithSize, FormattedLegacyComment, HTML5Fonts, IComment, IPlugin, IPluginConstructor, InputFormat, InputFormatType, JumpEvent, JumpEventHandler, MeasureInput, MeasureTextInput, MeasureTextResult, NicoScript, NicoScriptReplace, NicoScriptReplaceCondition, NicoScriptReplaceRange, NicoScriptReplaceTarget, NicoScriptReverseTarget, Options, OwnerComment, ParseCommandAndNicoScriptResult, ParseContentResult, ParsedCommand, Platform, PlatformFont, RawApiResponse, SeekDisableEvent, SeekDisableEventHandler, SeekEnableEvent, SeekEnableEventHandler, Timeline, V1Comment, V1Thread, ValueOf, NiconiComments as default, formattedComment, formattedLegacyComment, inputFormat, inputFormatType, ownerComment, rawApiResponse, v1Thread };