@xpadev-net/niconicomments 0.2.50 → 0.2.51
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 +21 -21
- package/README.en.md +53 -53
- package/README.md +53 -53
- package/dist/bundle.d.ts +708 -455
- package/dist/bundle.js +361 -222
- package/package.json +19 -18
package/dist/bundle.d.ts
CHANGED
|
@@ -1,11 +1,211 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2020 lynweklm@gmail.com
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*
|
|
25
|
+
* original source: @napi-rs/canvas
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
declare class NodeCanvas {
|
|
29
|
+
constructor(width: number, height: number, flag?: SvgExportFlag);
|
|
30
|
+
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
getContext(
|
|
34
|
+
contextType: "2d",
|
|
35
|
+
contextAttributes?: ContextAttributes
|
|
36
|
+
): NodeContext;
|
|
37
|
+
encodeSync(format: "webp" | "jpeg", quality?: number): Buffer;
|
|
38
|
+
encodeSync(format: "png"): Buffer;
|
|
39
|
+
encodeSync(format: "avif", cfg?: AvifConfig): Buffer;
|
|
40
|
+
encode(format: "webp" | "jpeg", quality?: number): Promise<Buffer>;
|
|
41
|
+
encode(format: "png"): Promise<Buffer>;
|
|
42
|
+
encode(format: "avif", cfg?: AvifConfig): Promise<Buffer>;
|
|
43
|
+
|
|
44
|
+
toBuffer(mime: "image/png"): Buffer;
|
|
45
|
+
toBuffer(mime: "image/jpeg" | "image/webp", quality?: number): Buffer;
|
|
46
|
+
toBuffer(mime: "image/avif", cfg?: AvifConfig): Buffer;
|
|
47
|
+
// raw pixels
|
|
48
|
+
data(): Buffer;
|
|
49
|
+
toDataURL(mime?: "image/png"): string;
|
|
50
|
+
toDataURL(mime: "image/jpeg" | "image/webp", quality?: number): string;
|
|
51
|
+
toDataURL(
|
|
52
|
+
mime?: "image/jpeg" | "image/webp" | "image/png",
|
|
53
|
+
quality?: number
|
|
54
|
+
): string;
|
|
55
|
+
toDataURL(mime?: "image/avif", cfg?: AvifConfig): string;
|
|
56
|
+
|
|
57
|
+
toDataURLAsync(mime?: "image/png"): Promise<string>;
|
|
58
|
+
toDataURLAsync(
|
|
59
|
+
mime: "image/jpeg" | "image/webp",
|
|
60
|
+
quality?: number
|
|
61
|
+
): Promise<string>;
|
|
62
|
+
toDataURLAsync(
|
|
63
|
+
mime?: "image/jpeg" | "image/webp" | "image/png",
|
|
64
|
+
quality?: number
|
|
65
|
+
): Promise<string>;
|
|
66
|
+
toDataURLAsync(mime?: "image/avif", cfg?: AvifConfig): Promise<string>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare enum SvgExportFlag {
|
|
70
|
+
ConvertTextToPaths = 0x01,
|
|
71
|
+
NoPrettyXML = 0x02,
|
|
72
|
+
RelativePathEncoding = 0x04,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface AvifConfig {
|
|
76
|
+
/** 0-100 scale, 100 is lossless */
|
|
77
|
+
quality?: number;
|
|
78
|
+
/** 0-100 scale */
|
|
79
|
+
alphaQuality?: number;
|
|
80
|
+
/** rav1e preset 1 (slow) 10 (fast but crappy), default is 4 */
|
|
81
|
+
speed?: number;
|
|
82
|
+
/** How many threads should be used (0 = match core count) */
|
|
83
|
+
threads?: number;
|
|
84
|
+
/** set to '4:2:0' to use chroma subsampling, default '4:4:4' */
|
|
85
|
+
chromaSubsampling?: ChromaSubsampling;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* https://en.wikipedia.org/wiki/Chroma_subsampling#Types_of_sampling_and_subsampling
|
|
89
|
+
* https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_concepts
|
|
90
|
+
*/
|
|
91
|
+
declare enum ChromaSubsampling {
|
|
92
|
+
/**
|
|
93
|
+
* Each of the three Y'CbCr components has the same sample rate, thus there is no chroma subsampling. This scheme is sometimes used in high-end film scanners and cinematic post-production.
|
|
94
|
+
* Note that "4:4:4" may instead be wrongly referring to R'G'B' color space, which implicitly also does not have any chroma subsampling (except in JPEG R'G'B' can be subsampled).
|
|
95
|
+
* Formats such as HDCAM SR can record 4:4:4 R'G'B' over dual-link HD-SDI.
|
|
96
|
+
*/
|
|
97
|
+
Yuv444 = 0,
|
|
98
|
+
/**
|
|
99
|
+
* The two chroma components are sampled at half the horizontal sample rate of luma: the horizontal chroma resolution is halved. This reduces the bandwidth of an uncompressed video signal by one-third.
|
|
100
|
+
* Many high-end digital video formats and interfaces use this scheme:
|
|
101
|
+
* - [AVC-Intra 100](https://en.wikipedia.org/wiki/AVC-Intra)
|
|
102
|
+
* - [Digital Betacam](https://en.wikipedia.org/wiki/Betacam#Digital_Betacam)
|
|
103
|
+
* - [Betacam SX](https://en.wikipedia.org/wiki/Betacam#Betacam_SX)
|
|
104
|
+
* - [DVCPRO50](https://en.wikipedia.org/wiki/DV#DVCPRO) and [DVCPRO HD](https://en.wikipedia.org/wiki/DV#DVCPRO_HD)
|
|
105
|
+
* - [Digital-S](https://en.wikipedia.org/wiki/Digital-S)
|
|
106
|
+
* - [CCIR 601](https://en.wikipedia.org/wiki/Rec._601) / [Serial Digital Interface](https://en.wikipedia.org/wiki/Serial_digital_interface) / [D1](https://en.wikipedia.org/wiki/D-1_(Sony))
|
|
107
|
+
* - [ProRes (HQ, 422, LT, and Proxy)](https://en.wikipedia.org/wiki/Apple_ProRes)
|
|
108
|
+
* - [XDCAM HD422](https://en.wikipedia.org/wiki/XDCAM)
|
|
109
|
+
* - [Canon MXF HD422](https://en.wikipedia.org/wiki/Canon_XF-300)
|
|
110
|
+
*/
|
|
111
|
+
Yuv422 = 1,
|
|
112
|
+
/**
|
|
113
|
+
* n 4:2:0, the horizontal sampling is doubled compared to 4:1:1,
|
|
114
|
+
* but as the **Cb** and **Cr** channels are only sampled on each alternate line in this scheme, the vertical resolution is halved.
|
|
115
|
+
* The data rate is thus the same.
|
|
116
|
+
* This fits reasonably well with the PAL color encoding system, since this has only half the vertical chrominance resolution of [NTSC](https://en.wikipedia.org/wiki/NTSC).
|
|
117
|
+
* It would also fit extremely well with the [SECAM](https://en.wikipedia.org/wiki/SECAM) color encoding system,
|
|
118
|
+
* since like that format, 4:2:0 only stores and transmits one color channel per line (the other channel being recovered from the previous line).
|
|
119
|
+
* However, little equipment has actually been produced that outputs a SECAM analogue video signal.
|
|
120
|
+
* In general, SECAM territories either have to use a PAL-capable display or a [transcoder](https://en.wikipedia.org/wiki/Transcoding) to convert the PAL signal to SECAM for display.
|
|
121
|
+
*/
|
|
122
|
+
Yuv420 = 2,
|
|
123
|
+
/**
|
|
124
|
+
* What if the chroma subsampling model is 4:0:0?
|
|
125
|
+
* That says to use every pixel of luma data, but that each row has 0 chroma samples applied to it. The resulting image, then, is comprised solely of the luminance data—a greyscale image.
|
|
126
|
+
*/
|
|
127
|
+
Yuv400 = 3,
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
interface ContextAttributes {
|
|
131
|
+
alpha?: boolean;
|
|
132
|
+
colorSpace?: ColorSpace;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
interface NodeContext
|
|
136
|
+
extends Omit<
|
|
137
|
+
CanvasRenderingContext2D,
|
|
138
|
+
| "drawImage"
|
|
139
|
+
| "createPattern"
|
|
140
|
+
| "getTransform"
|
|
141
|
+
| "drawFocusIfNeeded"
|
|
142
|
+
| "scrollPathIntoView"
|
|
143
|
+
| "canvas"
|
|
144
|
+
> {
|
|
145
|
+
canvas: NodeCanvas;
|
|
146
|
+
/**
|
|
147
|
+
* @param startAngle The angle at which to begin the gradient, in radians. Angle measurements start vertically above the centre and move around clockwise.
|
|
148
|
+
* @param x The x-axis coordinate of the centre of the gradient.
|
|
149
|
+
* @param y The y-axis coordinate of the centre of the gradient.
|
|
150
|
+
*/
|
|
151
|
+
createConicGradient(startAngle: number, x: number, y: number): CanvasGradient;
|
|
152
|
+
drawImage(image: Image | NodeCanvas, dx: number, dy: number): void;
|
|
153
|
+
drawImage(
|
|
154
|
+
image: Image | NodeCanvas,
|
|
155
|
+
dx: number,
|
|
156
|
+
dy: number,
|
|
157
|
+
dw: number,
|
|
158
|
+
dh: number
|
|
159
|
+
): void;
|
|
160
|
+
drawImage(
|
|
161
|
+
image: Image | NodeCanvas,
|
|
162
|
+
sx: number,
|
|
163
|
+
sy: number,
|
|
164
|
+
sw: number,
|
|
165
|
+
sh: number,
|
|
166
|
+
dx: number,
|
|
167
|
+
dy: number,
|
|
168
|
+
dw: number,
|
|
169
|
+
dh: number
|
|
170
|
+
): void;
|
|
171
|
+
createPattern(
|
|
172
|
+
image: Image | ImageData,
|
|
173
|
+
repeat: "repeat" | "repeat-x" | "repeat-y" | "no-repeat" | null
|
|
174
|
+
): CanvasPattern;
|
|
175
|
+
getContextAttributes(): { alpha: boolean; desynchronized: boolean };
|
|
176
|
+
getTransform(): DOMMatrix;
|
|
177
|
+
}
|
|
178
|
+
declare class Image {
|
|
179
|
+
constructor();
|
|
180
|
+
// attrs only affects SVG
|
|
181
|
+
constructor(
|
|
182
|
+
width: number,
|
|
183
|
+
height: number,
|
|
184
|
+
attrs?: { colorSpace?: ColorSpace }
|
|
185
|
+
);
|
|
186
|
+
width: number;
|
|
187
|
+
height: number;
|
|
188
|
+
readonly naturalWidth: number;
|
|
189
|
+
readonly naturalHeight: number;
|
|
190
|
+
readonly complete: boolean;
|
|
191
|
+
alt: string;
|
|
192
|
+
src: Buffer;
|
|
193
|
+
onload?(): void;
|
|
194
|
+
onerror?(err: Error): void;
|
|
195
|
+
}
|
|
196
|
+
type ColorSpace = "srgb" | "display-p3";
|
|
197
|
+
|
|
198
|
+
type Canvas = NodeCanvas | HTMLCanvasElement;
|
|
199
|
+
type Context2D = NodeContext | CanvasRenderingContext2D;
|
|
200
|
+
|
|
1
201
|
declare class BaseComment implements IComment {
|
|
2
|
-
protected readonly context:
|
|
3
|
-
protected
|
|
202
|
+
protected readonly context: Context2D;
|
|
203
|
+
protected cacheKey: string;
|
|
4
204
|
comment: FormattedCommentWithSize;
|
|
5
205
|
posY: number;
|
|
6
206
|
readonly pluginName: string;
|
|
7
|
-
image?:
|
|
8
|
-
constructor(comment: FormattedComment, context:
|
|
207
|
+
image?: Canvas | null;
|
|
208
|
+
constructor(comment: FormattedComment, context: Context2D);
|
|
9
209
|
get invisible(): boolean;
|
|
10
210
|
get loc(): CommentLoc;
|
|
11
211
|
get long(): number;
|
|
@@ -16,8 +216,11 @@ declare class BaseComment implements IComment {
|
|
|
16
216
|
get layer(): number;
|
|
17
217
|
get owner(): boolean;
|
|
18
218
|
get mail(): string[];
|
|
219
|
+
get content(): string;
|
|
220
|
+
set content(_: string);
|
|
19
221
|
protected getCommentSize(parsedData: FormattedCommentWithFont): FormattedCommentWithSize;
|
|
20
222
|
protected parseCommandAndNicoscript(comment: FormattedComment): FormattedCommentWithFont;
|
|
223
|
+
protected parseContent(comment: string): ParseContentResult;
|
|
21
224
|
protected measureText(comment: MeasureTextInput): MeasureTextResult;
|
|
22
225
|
protected convertComment(comment: FormattedComment): FormattedCommentWithSize;
|
|
23
226
|
draw(vpos: number, showCollision: boolean, debug: boolean): void;
|
|
@@ -25,12 +228,12 @@ declare class BaseComment implements IComment {
|
|
|
25
228
|
protected _drawRectColor(posX: number, posY: number): void;
|
|
26
229
|
protected _drawDebugInfo(posX: number, posY: number, debug: boolean): void;
|
|
27
230
|
protected _drawCollision(posX: number, posY: number, showCollision: boolean): void;
|
|
28
|
-
protected getTextImage():
|
|
29
|
-
protected _generateTextImage():
|
|
30
|
-
protected _cacheImage(image:
|
|
231
|
+
protected getTextImage(): Canvas | null;
|
|
232
|
+
protected _generateTextImage(): Canvas;
|
|
233
|
+
protected _cacheImage(image: Canvas): void;
|
|
31
234
|
protected createCanvas(): {
|
|
32
|
-
image:
|
|
33
|
-
context:
|
|
235
|
+
image: Canvas;
|
|
236
|
+
context: Context2D;
|
|
34
237
|
};
|
|
35
238
|
}
|
|
36
239
|
|
|
@@ -39,26 +242,41 @@ declare class FlashComment extends BaseComment {
|
|
|
39
242
|
private scale;
|
|
40
243
|
private scaleX;
|
|
41
244
|
readonly pluginName: string;
|
|
42
|
-
constructor(comment: FormattedComment, context:
|
|
245
|
+
constructor(comment: FormattedComment, context: Context2D);
|
|
246
|
+
get content(): string;
|
|
247
|
+
set content(input: string);
|
|
43
248
|
convertComment(comment: FormattedComment): FormattedCommentWithSize;
|
|
44
249
|
getCommentSize(parsedData: FormattedCommentWithFont): FormattedCommentWithSize;
|
|
45
250
|
parseCommandAndNicoscript(comment: FormattedComment): FormattedCommentWithFont;
|
|
251
|
+
parseContent(input: string): {
|
|
252
|
+
content: CommentContentItem[];
|
|
253
|
+
lineCount: number;
|
|
254
|
+
lineOffset: number;
|
|
255
|
+
};
|
|
46
256
|
measureText(comment: MeasureTextInput): MeasureTextResult;
|
|
257
|
+
private _measureContent;
|
|
47
258
|
_drawCollision(posX: number, posY: number, showCollision: boolean): void;
|
|
48
|
-
_generateTextImage():
|
|
259
|
+
_generateTextImage(): Canvas;
|
|
49
260
|
}
|
|
50
261
|
|
|
51
262
|
declare class HTML5Comment extends BaseComment {
|
|
52
263
|
readonly pluginName: string;
|
|
53
|
-
constructor(comment: FormattedComment, context:
|
|
264
|
+
constructor(comment: FormattedComment, context: Context2D);
|
|
265
|
+
get content(): string;
|
|
266
|
+
set content(input: string);
|
|
54
267
|
convertComment(comment: FormattedComment): FormattedCommentWithSize;
|
|
55
268
|
getCommentSize(parsedData: FormattedCommentWithFont): FormattedCommentWithSize;
|
|
56
269
|
parseCommandAndNicoscript(comment: FormattedComment): FormattedCommentWithFont;
|
|
270
|
+
parseContent(input: string): {
|
|
271
|
+
content: CommentContentItem[];
|
|
272
|
+
lineCount: number;
|
|
273
|
+
lineOffset: number;
|
|
274
|
+
};
|
|
57
275
|
measureText(comment: MeasureTextInput): MeasureTextResult;
|
|
58
276
|
private _measureComment;
|
|
59
277
|
private _processResizeX;
|
|
60
278
|
_drawCollision(posX: number, posY: number, showCollision: boolean): void;
|
|
61
|
-
_generateTextImage():
|
|
279
|
+
_generateTextImage(): Canvas;
|
|
62
280
|
}
|
|
63
281
|
|
|
64
282
|
type index_d$3_BaseComment = BaseComment;
|
|
@@ -75,81 +293,81 @@ declare namespace index_d$3 {
|
|
|
75
293
|
};
|
|
76
294
|
}
|
|
77
295
|
|
|
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
|
-
|
|
296
|
+
type ConfigItem<T> = T | { html5: T; flash: T };
|
|
297
|
+
type ConfigSizeItem<T> = { big: T; medium: T; small: T };
|
|
298
|
+
type ConfigResizedItem<T> = { default: T; resized: T };
|
|
299
|
+
|
|
300
|
+
type CommentStageSize = {
|
|
301
|
+
width: number;
|
|
302
|
+
fullWidth: number;
|
|
303
|
+
height: number;
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
type FlashCharList = {
|
|
307
|
+
[key in "simsunStrong" | "simsunWeak" | "gulim" | "gothic"]: string;
|
|
308
|
+
};
|
|
309
|
+
type FlashMode = "xp" | "vista";
|
|
310
|
+
type FlashScriptChar = {
|
|
311
|
+
[key in "super" | "sub"]: string;
|
|
312
|
+
};
|
|
313
|
+
type FontList = {
|
|
314
|
+
[key in "gulim" | "simsun"]: string;
|
|
315
|
+
};
|
|
316
|
+
type LineCounts = {
|
|
317
|
+
[key in "default" | "resized" | "doubleResized"]: ConfigSizeItem<number>;
|
|
318
|
+
};
|
|
319
|
+
type TypeDoubleResizeMaxWidth = {
|
|
320
|
+
[key in "full" | "normal"]: number;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
type BaseConfig = {
|
|
324
|
+
cacheAge: number;
|
|
325
|
+
canvasHeight: number;
|
|
326
|
+
canvasWidth: number;
|
|
327
|
+
collisionRange: { [key in "left" | "right"]: number };
|
|
328
|
+
colors: { [key: string]: string };
|
|
329
|
+
commentDrawPadding: number;
|
|
330
|
+
commentDrawRange: number;
|
|
331
|
+
commentScale: ConfigItem<number>;
|
|
332
|
+
CommentStageSize: ConfigItem<CommentStageSize>;
|
|
333
|
+
commentYMarginBottom: ConfigSizeItem<number>;
|
|
334
|
+
commentYOffset: ConfigSizeItem<ConfigResizedItem<number>>;
|
|
335
|
+
commentYPaddingTop: ConfigResizedItem<number>;
|
|
336
|
+
contextFillLiveOpacity: number;
|
|
337
|
+
contextLineWidth: number;
|
|
338
|
+
contextStrokeColor: string;
|
|
339
|
+
contextStrokeInversionColor: string;
|
|
340
|
+
contextStrokeOpacity: number;
|
|
341
|
+
doubleResizeMaxWidth: ConfigItem<TypeDoubleResizeMaxWidth>;
|
|
342
|
+
flashChar: FlashCharList;
|
|
343
|
+
FlashMode: FlashMode;
|
|
344
|
+
FlashScriptChar: FlashScriptChar;
|
|
345
|
+
flashThreshold: number;
|
|
346
|
+
font: FontList;
|
|
347
|
+
fonts: PlatformFont;
|
|
348
|
+
fontSize: ConfigItem<ConfigSizeItem<ConfigResizedItem<number>>>;
|
|
349
|
+
fpsInterval: number;
|
|
350
|
+
hiResCommentCorrection: number;
|
|
351
|
+
lineCounts: ConfigItem<LineCounts>;
|
|
352
|
+
lineHeight: ConfigItem<ConfigSizeItem<ConfigResizedItem<number>>>;
|
|
353
|
+
minFontSize: number;
|
|
354
|
+
sameCAGap: number;
|
|
355
|
+
sameCAMinScore: number;
|
|
356
|
+
sameCARange: number;
|
|
357
|
+
sameCATimestampRange: number;
|
|
358
|
+
letterSpacing: number;
|
|
359
|
+
scriptCharOffset: number;
|
|
360
|
+
plugins: IPluginConstructor[];
|
|
361
|
+
commentPlugins: {
|
|
362
|
+
class: typeof BaseComment;
|
|
363
|
+
condition: (comment: FormattedComment) => boolean;
|
|
364
|
+
}[];
|
|
365
|
+
commentLimit: number | undefined;
|
|
366
|
+
hideCommentOrder: "asc" | "desc";
|
|
367
|
+
lineBreakCount: { [key in CommentSize]: number };
|
|
368
|
+
nakaCommentSpeedOffset: number;
|
|
369
|
+
};
|
|
370
|
+
|
|
153
371
|
type Config = Partial<BaseConfig>;
|
|
154
372
|
|
|
155
373
|
interface CommentEventBase {
|
|
@@ -215,381 +433,403 @@ interface CommentEventMap {
|
|
|
215
433
|
jump: JumpEvent;
|
|
216
434
|
}
|
|
217
435
|
|
|
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;
|
|
436
|
+
type Platform =
|
|
437
|
+
| "win7"
|
|
438
|
+
| "win8_1"
|
|
439
|
+
| "win"
|
|
440
|
+
| "mac10_9"
|
|
441
|
+
| "mac10_11"
|
|
442
|
+
| "mac"
|
|
443
|
+
| "other";
|
|
444
|
+
type HTML5Fonts = "gothic" | "mincho" | "defont";
|
|
445
|
+
type FontItem = {
|
|
446
|
+
font: string;
|
|
447
|
+
offset: number;
|
|
448
|
+
weight: number;
|
|
449
|
+
};
|
|
450
|
+
type PlatformFont = {
|
|
451
|
+
[key in HTML5Fonts]: FontItem;
|
|
234
452
|
};
|
|
235
453
|
|
|
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
|
-
*/
|
|
454
|
+
type FormattedComment = {
|
|
455
|
+
id: number;
|
|
456
|
+
vpos: number;
|
|
457
|
+
content: string;
|
|
458
|
+
date: number;
|
|
459
|
+
date_usec: number;
|
|
460
|
+
owner: boolean;
|
|
461
|
+
premium: boolean;
|
|
462
|
+
mail: string[];
|
|
463
|
+
user_id: number;
|
|
464
|
+
layer: number;
|
|
465
|
+
};
|
|
466
|
+
type FormattedLegacyComment = {
|
|
467
|
+
id: number;
|
|
468
|
+
vpos: number;
|
|
469
|
+
content: string;
|
|
470
|
+
date: number;
|
|
471
|
+
date_usec: number;
|
|
472
|
+
owner: boolean;
|
|
473
|
+
premium: boolean;
|
|
474
|
+
mail: string[];
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* @deprecated
|
|
479
|
+
*/
|
|
480
|
+
type formattedComment = FormattedComment;
|
|
481
|
+
/**
|
|
482
|
+
* @deprecated
|
|
483
|
+
*/
|
|
266
484
|
type formattedLegacyComment = FormattedLegacyComment;
|
|
267
485
|
|
|
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
|
-
*/
|
|
486
|
+
type RawApiResponse = {
|
|
487
|
+
[key: string]: ApiPing | ApiThread | ApiLeaf | ApiGlobalNumRes | ApiChat;
|
|
488
|
+
};
|
|
489
|
+
type ApiPing = {
|
|
490
|
+
content: string;
|
|
491
|
+
};
|
|
492
|
+
type ApiThread = {
|
|
493
|
+
resultcode: number;
|
|
494
|
+
thread: string;
|
|
495
|
+
server_time: number;
|
|
496
|
+
ticket: string;
|
|
497
|
+
revision: number;
|
|
498
|
+
};
|
|
499
|
+
type ApiLeaf = {
|
|
500
|
+
thread: string;
|
|
501
|
+
count: number;
|
|
502
|
+
};
|
|
503
|
+
type ApiGlobalNumRes = {
|
|
504
|
+
thread: string;
|
|
505
|
+
num_res: number;
|
|
506
|
+
};
|
|
507
|
+
type ApiChat = {
|
|
508
|
+
thread: string;
|
|
509
|
+
no: number;
|
|
510
|
+
vpos: number;
|
|
511
|
+
date: number;
|
|
512
|
+
date_usec: number;
|
|
513
|
+
nicoru: number;
|
|
514
|
+
premium: number;
|
|
515
|
+
anonymity: number;
|
|
516
|
+
user_id: string;
|
|
517
|
+
mail: string;
|
|
518
|
+
content: string;
|
|
519
|
+
deleted: number;
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* @deprecated
|
|
524
|
+
*/
|
|
307
525
|
type rawApiResponse = RawApiResponse;
|
|
308
526
|
|
|
309
|
-
type OwnerComment = {
|
|
310
|
-
time: string;
|
|
311
|
-
command: string;
|
|
312
|
-
comment: string;
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* @deprecated
|
|
317
|
-
*/
|
|
527
|
+
type OwnerComment = {
|
|
528
|
+
time: string;
|
|
529
|
+
command: string;
|
|
530
|
+
comment: string;
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* @deprecated
|
|
535
|
+
*/
|
|
318
536
|
type ownerComment = OwnerComment;
|
|
319
537
|
|
|
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
|
-
*/
|
|
538
|
+
type V1Thread = {
|
|
539
|
+
id: string;
|
|
540
|
+
fork: string;
|
|
541
|
+
commentCount: number;
|
|
542
|
+
comments: V1Comment[];
|
|
543
|
+
};
|
|
544
|
+
type V1Comment = {
|
|
545
|
+
id: string;
|
|
546
|
+
no: number;
|
|
547
|
+
vposMs: number;
|
|
548
|
+
body: string;
|
|
549
|
+
commands: string[];
|
|
550
|
+
userId: string;
|
|
551
|
+
isPremium: boolean;
|
|
552
|
+
score: number;
|
|
553
|
+
postedAt: string;
|
|
554
|
+
nicoruCount: number;
|
|
555
|
+
nicoruId: undefined;
|
|
556
|
+
source: string;
|
|
557
|
+
isMyPost: boolean;
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* @deprecated
|
|
562
|
+
*/
|
|
345
563
|
type v1Thread = V1Thread;
|
|
346
564
|
|
|
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
|
-
|
|
361
|
-
|
|
565
|
+
interface IComment {
|
|
566
|
+
comment: FormattedCommentWithSize;
|
|
567
|
+
invisible: boolean;
|
|
568
|
+
loc: CommentLoc;
|
|
569
|
+
width: number;
|
|
570
|
+
long: number;
|
|
571
|
+
height: number;
|
|
572
|
+
vpos: number;
|
|
573
|
+
flash: boolean;
|
|
574
|
+
posY: number;
|
|
575
|
+
owner: boolean;
|
|
576
|
+
layer: number;
|
|
577
|
+
mail: string[];
|
|
578
|
+
content: string;
|
|
579
|
+
image?: Canvas | null;
|
|
580
|
+
draw: (vpos: number, showCollision: boolean, isDebug: boolean) => void;
|
|
362
581
|
}
|
|
363
582
|
|
|
364
|
-
interface IPluginConstructor {
|
|
365
|
-
id: string;
|
|
366
|
-
new (Canvas:
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
interface IPlugin {
|
|
370
|
-
draw(vpos: number): void;
|
|
371
|
-
addComments(comments: FormattedComment[]): void;
|
|
583
|
+
interface IPluginConstructor {
|
|
584
|
+
id: string;
|
|
585
|
+
new (Canvas: Canvas, comments: IComment[]): IPlugin;
|
|
372
586
|
}
|
|
373
587
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
| "
|
|
381
|
-
| "
|
|
382
|
-
| "
|
|
383
|
-
| "
|
|
384
|
-
|
|
385
|
-
|
|
|
386
|
-
|
|
|
387
|
-
|
|
|
388
|
-
|
|
|
389
|
-
|
|
390
|
-
|
|
|
391
|
-
|
|
|
392
|
-
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
type
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
588
|
+
interface IPlugin {
|
|
589
|
+
draw(vpos: number): void;
|
|
590
|
+
addComments(comments: IComment[]): void;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
type InputFormatType =
|
|
594
|
+
| "XMLDocument"
|
|
595
|
+
| "niconicome"
|
|
596
|
+
| "formatted"
|
|
597
|
+
| "legacy"
|
|
598
|
+
| "legacyOwner"
|
|
599
|
+
| "owner"
|
|
600
|
+
| "v1"
|
|
601
|
+
| "empty"
|
|
602
|
+
| "default";
|
|
603
|
+
type InputFormat =
|
|
604
|
+
| XMLDocument
|
|
605
|
+
| FormattedComment[]
|
|
606
|
+
| FormattedLegacyComment[]
|
|
607
|
+
| RawApiResponse[]
|
|
608
|
+
| OwnerComment[]
|
|
609
|
+
| V1Thread[]
|
|
610
|
+
| string
|
|
611
|
+
| undefined;
|
|
612
|
+
type ModeType = "default" | "html5" | "flash";
|
|
613
|
+
type BaseOptions = {
|
|
614
|
+
config: Config;
|
|
615
|
+
debug: boolean;
|
|
616
|
+
enableLegacyPiP: boolean;
|
|
617
|
+
format: InputFormatType;
|
|
618
|
+
formatted: boolean;
|
|
619
|
+
keepCA: boolean;
|
|
620
|
+
mode: ModeType;
|
|
621
|
+
scale: number;
|
|
622
|
+
showCollision: boolean;
|
|
623
|
+
showCommentCount: boolean;
|
|
624
|
+
showFPS: boolean;
|
|
625
|
+
useLegacy: boolean;
|
|
626
|
+
video: HTMLVideoElement | undefined;
|
|
627
|
+
};
|
|
628
|
+
type Options = Partial<BaseOptions>;
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* @deprecated
|
|
632
|
+
*/
|
|
633
|
+
type inputFormatType = InputFormatType;
|
|
634
|
+
/**
|
|
635
|
+
* @deprecated
|
|
636
|
+
*/
|
|
418
637
|
type inputFormat = InputFormat;
|
|
419
638
|
|
|
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
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
};
|
|
463
|
-
type
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
type
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
};
|
|
496
|
-
type
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
type
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
type
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
color: string | undefined;
|
|
532
|
-
size: CommentSize | undefined;
|
|
533
|
-
font: CommentFont | undefined;
|
|
534
|
-
loc: CommentLoc | undefined;
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
font: CommentFont | undefined;
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
639
|
+
type FormattedCommentWithFont = {
|
|
640
|
+
id: number;
|
|
641
|
+
vpos: number;
|
|
642
|
+
date: number;
|
|
643
|
+
date_usec: number;
|
|
644
|
+
owner: boolean;
|
|
645
|
+
premium: boolean;
|
|
646
|
+
mail: string[];
|
|
647
|
+
user_id: number;
|
|
648
|
+
layer: number;
|
|
649
|
+
loc: CommentLoc;
|
|
650
|
+
size: CommentSize;
|
|
651
|
+
fontSize: number;
|
|
652
|
+
font: CommentFont;
|
|
653
|
+
color: string;
|
|
654
|
+
strokeColor?: string;
|
|
655
|
+
wakuColor?: string;
|
|
656
|
+
full: boolean;
|
|
657
|
+
ender: boolean;
|
|
658
|
+
_live: boolean;
|
|
659
|
+
long: number;
|
|
660
|
+
invisible: boolean;
|
|
661
|
+
content: CommentContentItem[];
|
|
662
|
+
rawContent: string;
|
|
663
|
+
flash: boolean;
|
|
664
|
+
lineCount: number;
|
|
665
|
+
lineOffset: number;
|
|
666
|
+
};
|
|
667
|
+
type FormattedCommentWithSize = FormattedCommentWithFont & {
|
|
668
|
+
height: number;
|
|
669
|
+
width: number;
|
|
670
|
+
lineHeight: number;
|
|
671
|
+
resized: boolean;
|
|
672
|
+
resizedX: boolean;
|
|
673
|
+
resizedY: boolean;
|
|
674
|
+
content: CommentMeasuredContentItem[];
|
|
675
|
+
charSize: number;
|
|
676
|
+
};
|
|
677
|
+
type ParseContentResult = {
|
|
678
|
+
content: CommentContentItem[];
|
|
679
|
+
lineCount: number;
|
|
680
|
+
lineOffset: number;
|
|
681
|
+
};
|
|
682
|
+
type ParseCommandAndNicoScriptResult = {
|
|
683
|
+
flash: boolean;
|
|
684
|
+
loc: CommentLoc;
|
|
685
|
+
size: CommentSize;
|
|
686
|
+
fontSize: number;
|
|
687
|
+
color: string;
|
|
688
|
+
strokeColor?: string;
|
|
689
|
+
wakuColor?: string;
|
|
690
|
+
font: CommentFont;
|
|
691
|
+
full: boolean;
|
|
692
|
+
ender: boolean;
|
|
693
|
+
_live: boolean;
|
|
694
|
+
invisible: boolean;
|
|
695
|
+
long: number;
|
|
696
|
+
};
|
|
697
|
+
type CommentContentItem = {
|
|
698
|
+
content: string;
|
|
699
|
+
slicedContent: string[];
|
|
700
|
+
font?: CommentFlashFont;
|
|
701
|
+
width?: number[];
|
|
702
|
+
};
|
|
703
|
+
type CommentMeasuredContentItem = CommentContentItem & {
|
|
704
|
+
width: number[];
|
|
705
|
+
};
|
|
706
|
+
type CommentContentIndex = {
|
|
707
|
+
index: number;
|
|
708
|
+
font: "gothic" | "gulim" | "simsunStrong" | "simsunWeak";
|
|
709
|
+
};
|
|
710
|
+
type CommentFont = "defont" | "mincho" | "gothic" | "gulim" | "simsun";
|
|
711
|
+
type CommentFlashFont = "defont" | "gulim" | "simsun";
|
|
712
|
+
type CommentSize = "big" | "medium" | "small";
|
|
713
|
+
type CommentLoc = "ue" | "naka" | "shita";
|
|
714
|
+
type Collision = { [key in CollisionPos]: CollisionItem };
|
|
715
|
+
type Timeline = { [key: number]: IComment[] };
|
|
716
|
+
type CollisionPos = "ue" | "shita" | "right" | "left";
|
|
717
|
+
type CollisionItem = { [p: number]: IComment[] };
|
|
718
|
+
type NicoScript = {
|
|
719
|
+
reverse: NicoScriptReverse[];
|
|
720
|
+
ban: NicoScriptBan[];
|
|
721
|
+
default: NicoScriptDefault[];
|
|
722
|
+
replace: NicoScriptReplace[];
|
|
723
|
+
seekDisable: NicoScriptSeekDisable[];
|
|
724
|
+
jump: NicoScriptJump[];
|
|
725
|
+
};
|
|
726
|
+
type NicoScriptSeekDisable = {
|
|
727
|
+
start: number;
|
|
728
|
+
end: number;
|
|
729
|
+
};
|
|
730
|
+
type NicoScriptJump = {
|
|
731
|
+
start: number;
|
|
732
|
+
end?: number;
|
|
733
|
+
to: string;
|
|
734
|
+
message?: string;
|
|
735
|
+
};
|
|
736
|
+
type NicoScriptReverse = {
|
|
737
|
+
target: NicoScriptReverseTarget;
|
|
738
|
+
start: number;
|
|
739
|
+
end: number;
|
|
740
|
+
};
|
|
741
|
+
type NicoScriptReverseTarget = "コメ" | "投コメ" | "全";
|
|
742
|
+
type NicoScriptReplace = {
|
|
743
|
+
start: number;
|
|
744
|
+
long: number | undefined;
|
|
745
|
+
keyword: string;
|
|
746
|
+
replace: string;
|
|
747
|
+
range: NicoScriptReplaceRange;
|
|
748
|
+
target: NicoScriptReplaceTarget;
|
|
749
|
+
condition: NicoScriptReplaceCondition;
|
|
750
|
+
color: string | undefined;
|
|
751
|
+
size: CommentSize | undefined;
|
|
752
|
+
font: CommentFont | undefined;
|
|
753
|
+
loc: CommentLoc | undefined;
|
|
754
|
+
no: number;
|
|
755
|
+
};
|
|
756
|
+
type NicoScriptReplaceRange = "単" | "全";
|
|
757
|
+
type NicoScriptReplaceTarget =
|
|
758
|
+
| "コメ"
|
|
759
|
+
| "投コメ"
|
|
760
|
+
| "全"
|
|
761
|
+
| "含まない"
|
|
762
|
+
| "含む";
|
|
763
|
+
type NicoScriptReplaceCondition = "完全一致" | "部分一致";
|
|
764
|
+
type NicoScriptBan = {
|
|
765
|
+
start: number;
|
|
766
|
+
end: number;
|
|
767
|
+
};
|
|
768
|
+
type NicoScriptDefault = {
|
|
769
|
+
start: number;
|
|
770
|
+
long: number | undefined;
|
|
771
|
+
color: string | undefined;
|
|
772
|
+
size: CommentSize | undefined;
|
|
773
|
+
font: CommentFont | undefined;
|
|
774
|
+
loc: CommentLoc | undefined;
|
|
775
|
+
};
|
|
776
|
+
type MeasureTextResult = {
|
|
777
|
+
width: number;
|
|
778
|
+
height: number;
|
|
779
|
+
resized: boolean;
|
|
780
|
+
resizedX: boolean;
|
|
781
|
+
resizedY: boolean;
|
|
782
|
+
fontSize: number;
|
|
783
|
+
lineHeight: number;
|
|
784
|
+
content: CommentMeasuredContentItem[];
|
|
785
|
+
charSize: number;
|
|
786
|
+
};
|
|
787
|
+
type ParsedCommand = {
|
|
788
|
+
loc: CommentLoc | undefined;
|
|
789
|
+
size: CommentSize | undefined;
|
|
790
|
+
fontSize: number | undefined;
|
|
791
|
+
color: string | undefined;
|
|
792
|
+
strokeColor?: string;
|
|
793
|
+
wakuColor?: string;
|
|
794
|
+
font: CommentFont | undefined;
|
|
795
|
+
full: boolean;
|
|
796
|
+
ender: boolean;
|
|
797
|
+
_live: boolean;
|
|
798
|
+
invisible: boolean;
|
|
799
|
+
long: number | undefined;
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
type MeasureTextInput = {
|
|
803
|
+
content: CommentContentItem[];
|
|
804
|
+
resized?: boolean;
|
|
805
|
+
ender: boolean;
|
|
806
|
+
size: CommentSize;
|
|
807
|
+
fontSize: number;
|
|
808
|
+
resizedY?: boolean;
|
|
809
|
+
resizedX?: boolean;
|
|
810
|
+
font: CommentFont;
|
|
811
|
+
loc: CommentLoc;
|
|
812
|
+
full: boolean;
|
|
813
|
+
flash: boolean;
|
|
814
|
+
lineCount: number;
|
|
815
|
+
lineHeight?: number;
|
|
816
|
+
charSize?: number;
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
type MeasureInput = {
|
|
820
|
+
font: CommentFont;
|
|
821
|
+
content: CommentContentItem[];
|
|
822
|
+
lineHeight: number;
|
|
823
|
+
charSize: number;
|
|
824
|
+
lineCount: number;
|
|
825
|
+
};
|
|
826
|
+
|
|
587
827
|
type ValueOf<T> = T[keyof T];
|
|
588
828
|
|
|
589
829
|
declare let imageCache: {
|
|
590
830
|
[key: string]: {
|
|
591
|
-
image:
|
|
592
|
-
timeout: number;
|
|
831
|
+
image: Canvas;
|
|
832
|
+
timeout: number | NodeJS.Timeout;
|
|
593
833
|
};
|
|
594
834
|
};
|
|
595
835
|
declare const resetImageCache: () => void;
|
|
@@ -659,8 +899,8 @@ declare const updateConfig: (config: BaseConfig) => void;
|
|
|
659
899
|
declare const defaultOptions: BaseOptions;
|
|
660
900
|
declare let config: BaseConfig;
|
|
661
901
|
declare let options: BaseOptions;
|
|
662
|
-
declare const setConfig: (value: BaseConfig) =>
|
|
663
|
-
declare const setOptions: (value: BaseOptions) =>
|
|
902
|
+
declare const setConfig: (value: BaseConfig) => void;
|
|
903
|
+
declare const setOptions: (value: BaseOptions) => void;
|
|
664
904
|
|
|
665
905
|
declare const config$1_config: typeof config;
|
|
666
906
|
declare const config$1_defaultConfig: typeof defaultConfig;
|
|
@@ -922,6 +1162,10 @@ declare const typeGuard: {
|
|
|
922
1162
|
config: {
|
|
923
1163
|
initOptions: (item: unknown) => item is Partial<BaseOptions>;
|
|
924
1164
|
};
|
|
1165
|
+
canvas: {
|
|
1166
|
+
nodeCanvas: (_: Canvas) => _ is NodeCanvas;
|
|
1167
|
+
nodeContext: (_: Context2D) => _ is NodeContext;
|
|
1168
|
+
};
|
|
925
1169
|
};
|
|
926
1170
|
|
|
927
1171
|
declare namespace typeGuard_d {
|
|
@@ -939,14 +1183,16 @@ declare const hex2rgb: (hex: string) => number[];
|
|
|
939
1183
|
declare const hex2rgba: (hex: string) => number[];
|
|
940
1184
|
declare const getStrokeColor: (comment: FormattedCommentWithSize) => string;
|
|
941
1185
|
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
loc: CommentLoc | undefined;
|
|
1186
|
+
type DefaultCommand = {
|
|
1187
|
+
color?: string;
|
|
1188
|
+
size?: CommentSize;
|
|
1189
|
+
font?: CommentFont;
|
|
1190
|
+
loc?: CommentLoc;
|
|
948
1191
|
};
|
|
949
|
-
|
|
1192
|
+
|
|
1193
|
+
declare const isLineBreakResize: (comment: MeasureTextInput) => boolean;
|
|
1194
|
+
declare const getDefaultCommand: (vpos: number) => DefaultCommand;
|
|
1195
|
+
declare const parseCommandAndNicoScript: (comment: FormattedComment) => ParseCommandAndNicoScriptResult;
|
|
950
1196
|
declare const isFlashComment: (comment: FormattedComment) => boolean;
|
|
951
1197
|
declare const isReverseActive: (vpos: number, isOwner: boolean) => boolean;
|
|
952
1198
|
declare const isBanActive: (vpos: number) => boolean;
|
|
@@ -966,10 +1212,11 @@ declare const getConfig: <T>(input: ConfigItem<T>, isFlash?: boolean) => T;
|
|
|
966
1212
|
|
|
967
1213
|
declare const getFlashFontIndex: (part: string) => CommentContentIndex[];
|
|
968
1214
|
declare const getFlashFontName: (font: string) => CommentFlashFont;
|
|
1215
|
+
declare const parseContent: (content: string) => CommentContentItem[];
|
|
969
1216
|
|
|
970
1217
|
declare const getLineHeight: (fontSize: CommentSize, isFlash: boolean, resized?: boolean) => number;
|
|
971
1218
|
declare const getCharSize: (fontSize: CommentSize, isFlash: boolean) => number;
|
|
972
|
-
declare const measure: (comment: MeasureInput, context:
|
|
1219
|
+
declare const measure: (comment: MeasureInput, context: Context2D) => {
|
|
973
1220
|
height: number;
|
|
974
1221
|
width: number;
|
|
975
1222
|
lineWidth: number[];
|
|
@@ -1004,6 +1251,7 @@ declare const index_d_isReverseActive: typeof isReverseActive;
|
|
|
1004
1251
|
declare const index_d_measure: typeof measure;
|
|
1005
1252
|
declare const index_d_nativeSort: typeof nativeSort;
|
|
1006
1253
|
declare const index_d_parseCommandAndNicoScript: typeof parseCommandAndNicoScript;
|
|
1254
|
+
declare const index_d_parseContent: typeof parseContent;
|
|
1007
1255
|
declare const index_d_parseFont: typeof parseFont;
|
|
1008
1256
|
declare const index_d_processFixedComment: typeof processFixedComment;
|
|
1009
1257
|
declare const index_d_processMovableComment: typeof processMovableComment;
|
|
@@ -1031,6 +1279,7 @@ declare namespace index_d {
|
|
|
1031
1279
|
index_d_measure as measure,
|
|
1032
1280
|
index_d_nativeSort as nativeSort,
|
|
1033
1281
|
index_d_parseCommandAndNicoScript as parseCommandAndNicoScript,
|
|
1282
|
+
index_d_parseContent as parseContent,
|
|
1034
1283
|
index_d_parseFont as parseFont,
|
|
1035
1284
|
index_d_processFixedComment as processFixedComment,
|
|
1036
1285
|
index_d_processMovableComment as processMovableComment,
|
|
@@ -1121,6 +1370,10 @@ declare class NiconiComments {
|
|
|
1121
1370
|
config: {
|
|
1122
1371
|
initOptions: (item: unknown) => item is Partial<BaseOptions>;
|
|
1123
1372
|
};
|
|
1373
|
+
canvas: {
|
|
1374
|
+
nodeCanvas: (_: Canvas) => _ is NodeCanvas;
|
|
1375
|
+
nodeContext: (_: Context2D) => _ is NodeContext;
|
|
1376
|
+
};
|
|
1124
1377
|
};
|
|
1125
1378
|
static default: typeof NiconiComments;
|
|
1126
1379
|
static FlashComment: {
|
|
@@ -1128,7 +1381,7 @@ declare class NiconiComments {
|
|
|
1128
1381
|
class: typeof FlashComment;
|
|
1129
1382
|
};
|
|
1130
1383
|
static internal: typeof internal;
|
|
1131
|
-
constructor(canvas:
|
|
1384
|
+
constructor(canvas: Canvas, data: InputFormat, initOptions?: Options);
|
|
1132
1385
|
private preRendering;
|
|
1133
1386
|
private getCommentPos;
|
|
1134
1387
|
private sortComment;
|
|
@@ -1144,4 +1397,4 @@ declare class NiconiComments {
|
|
|
1144
1397
|
clear(): void;
|
|
1145
1398
|
}
|
|
1146
1399
|
|
|
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 };
|
|
1400
|
+
export { ApiChat, ApiGlobalNumRes, ApiLeaf, ApiPing, ApiThread, AvifConfig, BaseConfig, BaseOptions, Canvas, ChromaSubsampling, Collision, CollisionItem, CollisionPos, ColorSpace, CommentContentIndex, CommentContentItem, CommentDisableEvent, CommentDisableEventHandler, CommentEnableEvent, CommentEnableEventHandler, CommentEventBase, CommentEventHandler, CommentEventHandlerMap, CommentEventMap, CommentEventName, CommentFlashFont, CommentFont, CommentLoc, CommentMeasuredContentItem, CommentSize, CommentStageSize, Config, ConfigItem, Context2D, ContextAttributes, FlashMode, FlashScriptChar, FontItem, FormattedComment, FormattedCommentWithFont, FormattedCommentWithSize, FormattedLegacyComment, HTML5Fonts, IComment, IPlugin, IPluginConstructor, Image, InputFormat, InputFormatType, JumpEvent, JumpEventHandler, MeasureInput, MeasureTextInput, MeasureTextResult, NicoScript, NicoScriptReplace, NicoScriptReplaceCondition, NicoScriptReplaceRange, NicoScriptReplaceTarget, NicoScriptReverseTarget, NodeCanvas, NodeContext, Options, OwnerComment, ParseCommandAndNicoScriptResult, ParseContentResult, ParsedCommand, Platform, PlatformFont, RawApiResponse, SeekDisableEvent, SeekDisableEventHandler, SeekEnableEvent, SeekEnableEventHandler, SvgExportFlag, Timeline, V1Comment, V1Thread, ValueOf, NiconiComments as default, formattedComment, formattedLegacyComment, inputFormat, inputFormatType, ownerComment, rawApiResponse, v1Thread };
|