@xpadev-net/niconicomments 0.2.48 → 0.2.49
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 +781 -619
- package/dist/bundle.js +2969 -2826
- package/package.json +71 -67
- package/LICENSE_JP +0 -11
package/dist/bundle.d.ts
CHANGED
|
@@ -1,294 +1,368 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
get
|
|
14
|
-
get
|
|
15
|
-
get
|
|
16
|
-
get
|
|
17
|
-
get
|
|
18
|
-
get
|
|
19
|
-
get
|
|
20
|
-
get
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
import type { formattedComment, formattedCommentWithSize, IComment } from "@/@types/";
|
|
2
|
+
import { formattedCommentWithFont, measureTextInput, measureTextResult } from "@/@types/";
|
|
3
|
+
declare class BaseComment implements IComment {
|
|
4
|
+
protected readonly context: CanvasRenderingContext2D;
|
|
5
|
+
protected readonly cacheKey: string;
|
|
6
|
+
comment: formattedCommentWithSize;
|
|
7
|
+
posY: number;
|
|
8
|
+
readonly pluginName: string;
|
|
9
|
+
image?: HTMLCanvasElement | null;
|
|
10
|
+
constructor(comment: formattedComment, context: CanvasRenderingContext2D);
|
|
11
|
+
get invisible(): boolean;
|
|
12
|
+
get loc(): commentLoc;
|
|
13
|
+
get long(): number;
|
|
14
|
+
get vpos(): number;
|
|
15
|
+
get width(): number;
|
|
16
|
+
get height(): number;
|
|
17
|
+
get flash(): boolean;
|
|
18
|
+
get layer(): number;
|
|
19
|
+
get owner(): boolean;
|
|
20
|
+
get mail(): string[];
|
|
21
|
+
protected getCommentSize(parsedData: formattedCommentWithFont): formattedCommentWithSize;
|
|
22
|
+
protected parseCommandAndNicoscript(comment: formattedComment): formattedCommentWithFont;
|
|
23
|
+
protected measureText(comment: measureTextInput): measureTextResult;
|
|
24
|
+
protected convertComment(comment: formattedComment): formattedCommentWithSize;
|
|
25
|
+
draw(vpos: number, showCollision: boolean, debug: boolean): void;
|
|
26
|
+
protected _draw(posX: number, posY: number): void;
|
|
27
|
+
protected _drawRectColor(posX: number, posY: number): void;
|
|
28
|
+
protected _drawDebugInfo(posX: number, posY: number, debug: boolean): void;
|
|
29
|
+
protected _drawCollision(posX: number, posY: number, showCollision: boolean): void;
|
|
30
|
+
protected getTextImage(): HTMLCanvasElement | null;
|
|
31
|
+
protected _generateTextImage(): HTMLCanvasElement;
|
|
32
|
+
protected _cacheImage(image: HTMLCanvasElement): void;
|
|
33
|
+
protected createCanvas(): {
|
|
34
|
+
image: HTMLCanvasElement;
|
|
35
|
+
context: CanvasRenderingContext2D;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
31
38
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
declare class HTML5Comment implements IComment {
|
|
36
|
-
private readonly context;
|
|
37
|
-
readonly comment: formattedCommentWithSize;
|
|
38
|
-
posY: number;
|
|
39
|
-
image?: HTMLCanvasElement | null;
|
|
40
|
-
constructor(comment: formattedComment, context: CanvasRenderingContext2D);
|
|
41
|
-
get invisible(): boolean;
|
|
42
|
-
get loc(): commentLoc;
|
|
43
|
-
get long(): number;
|
|
44
|
-
get vpos(): number;
|
|
45
|
-
get width(): number;
|
|
46
|
-
get height(): number;
|
|
47
|
-
get flash(): boolean;
|
|
48
|
-
get layer(): number;
|
|
49
|
-
get owner(): boolean;
|
|
50
|
-
get mail(): string[];
|
|
51
|
-
get lineCount(): number;
|
|
52
|
-
parseCommandAndNicoscript(comment: formattedComment): formattedCommentWithFont;
|
|
53
|
-
measureText(comment: measureTextInput): measureTextResult;
|
|
54
|
-
getCommentSize(parsedData: formattedCommentWithFont): formattedCommentWithSize;
|
|
55
|
-
draw(vpos: number, showCollision: boolean, debug: boolean): void;
|
|
56
|
-
getTextImage(): HTMLCanvasElement | null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
39
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
40
|
+
import type { formattedComment, formattedCommentWithFont, formattedCommentWithSize, measureTextInput, measureTextResult } from "@/@types/";
|
|
41
|
+
import { BaseComment } from "./BaseComment";
|
|
42
|
+
declare class FlashComment extends BaseComment {
|
|
43
|
+
private _globalScale;
|
|
44
|
+
private scale;
|
|
45
|
+
private scaleX;
|
|
46
|
+
readonly pluginName: string;
|
|
47
|
+
constructor(comment: formattedComment, context: CanvasRenderingContext2D);
|
|
48
|
+
convertComment(comment: formattedComment): formattedCommentWithSize;
|
|
49
|
+
getCommentSize(parsedData: formattedCommentWithFont): formattedCommentWithSize;
|
|
50
|
+
parseCommandAndNicoscript(comment: formattedComment): formattedCommentWithFont;
|
|
51
|
+
measureText(comment: measureTextInput): measureTextResult;
|
|
52
|
+
_drawCollision(posX: number, posY: number, showCollision: boolean): void;
|
|
53
|
+
_generateTextImage(): HTMLCanvasElement;
|
|
54
|
+
}
|
|
68
55
|
|
|
69
|
-
|
|
70
|
-
declare let nicoScripts: nicoScript;
|
|
71
|
-
declare const resetNicoScripts: () => void;
|
|
72
|
-
|
|
73
56
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
declare
|
|
77
|
-
|
|
57
|
+
import type { formattedComment, formattedCommentWithFont, formattedCommentWithSize, measureTextInput, measureTextResult } from "@/@types/";
|
|
58
|
+
import { BaseComment } from "./BaseComment";
|
|
59
|
+
declare class HTML5Comment extends BaseComment {
|
|
60
|
+
readonly pluginName: string;
|
|
61
|
+
constructor(comment: formattedComment, context: CanvasRenderingContext2D);
|
|
62
|
+
convertComment(comment: formattedComment): formattedCommentWithSize;
|
|
63
|
+
getCommentSize(parsedData: formattedCommentWithFont): formattedCommentWithSize;
|
|
64
|
+
parseCommandAndNicoscript(comment: formattedComment): formattedCommentWithFont;
|
|
65
|
+
measureText(comment: measureTextInput): measureTextResult;
|
|
66
|
+
private _measureComment;
|
|
67
|
+
private _processResizeX;
|
|
68
|
+
_drawCollision(posX: number, posY: number, showCollision: boolean): void;
|
|
69
|
+
_generateTextImage(): HTMLCanvasElement;
|
|
70
|
+
}
|
|
78
71
|
|
|
79
|
-
declare const colors: {
|
|
80
|
-
white: string;
|
|
81
|
-
red: string;
|
|
82
|
-
pink: string;
|
|
83
|
-
orange: string;
|
|
84
|
-
yellow: string;
|
|
85
|
-
green: string;
|
|
86
|
-
cyan: string;
|
|
87
|
-
blue: string;
|
|
88
|
-
purple: string;
|
|
89
|
-
black: string;
|
|
90
|
-
white2: string;
|
|
91
|
-
niconicowhite: string;
|
|
92
|
-
red2: string;
|
|
93
|
-
truered: string;
|
|
94
|
-
pink2: string;
|
|
95
|
-
orange2: string;
|
|
96
|
-
passionorange: string;
|
|
97
|
-
yellow2: string;
|
|
98
|
-
madyellow: string;
|
|
99
|
-
green2: string;
|
|
100
|
-
elementalgreen: string;
|
|
101
|
-
cyan2: string;
|
|
102
|
-
blue2: string;
|
|
103
|
-
marinblue: string;
|
|
104
|
-
purple2: string;
|
|
105
|
-
nobleviolet: string;
|
|
106
|
-
black2: string;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
72
|
|
|
73
|
+
export * from "./BaseComment";
|
|
74
|
+
export * from "./FlashComment";
|
|
75
|
+
export * from "./HTML5Comment";
|
|
76
|
+
|
|
77
|
+
import type {
|
|
78
|
+
commentSize,
|
|
79
|
+
formattedComment,
|
|
80
|
+
IPluginConstructor,
|
|
81
|
+
platformFont,
|
|
82
|
+
} from "@/@types/";
|
|
83
|
+
import { BaseComment } from "@/comments/";
|
|
110
84
|
|
|
85
|
+
type configItem<T> = T | { html5: T; flash: T };
|
|
86
|
+
type configSizeItem<T> = { big: T; medium: T; small: T };
|
|
87
|
+
type configResizedItem<T> = { default: T; resized: T };
|
|
111
88
|
|
|
112
|
-
|
|
113
|
-
declare const initConfig: () => void;
|
|
114
|
-
declare const defaultOptions: BaseOptions;
|
|
115
|
-
declare let config: BaseConfig;
|
|
116
|
-
declare let options: BaseOptions;
|
|
117
|
-
declare const setConfig: (value: BaseConfig) => BaseConfig;
|
|
118
|
-
declare const setOptions: (value: BaseOptions) => BaseOptions;
|
|
89
|
+
type commentStageSize = { width: number; fullWidth: number; height: number };
|
|
119
90
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
font: string;
|
|
184
|
-
offset: number;
|
|
185
|
-
weight: number;
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
declare const fonts: {
|
|
189
|
-
win7: {
|
|
190
|
-
defont: FontItem;
|
|
191
|
-
gothic: FontItem;
|
|
192
|
-
mincho: FontItem;
|
|
193
|
-
};
|
|
194
|
-
win8_1: {
|
|
195
|
-
defont: FontItem;
|
|
196
|
-
gothic: FontItem;
|
|
197
|
-
mincho: FontItem;
|
|
198
|
-
};
|
|
199
|
-
win: {
|
|
200
|
-
defont: FontItem;
|
|
201
|
-
gothic: FontItem;
|
|
202
|
-
mincho: FontItem;
|
|
203
|
-
};
|
|
204
|
-
mac10_9: {
|
|
205
|
-
defont: FontItem;
|
|
206
|
-
gothic: FontItem;
|
|
207
|
-
mincho: FontItem;
|
|
208
|
-
};
|
|
209
|
-
mac10_11: {
|
|
210
|
-
defont: FontItem;
|
|
211
|
-
gothic: FontItem;
|
|
212
|
-
mincho: FontItem;
|
|
213
|
-
};
|
|
214
|
-
mac: {
|
|
215
|
-
defont: FontItem;
|
|
216
|
-
gothic: FontItem;
|
|
217
|
-
mincho: FontItem;
|
|
218
|
-
};
|
|
219
|
-
other: {
|
|
220
|
-
defont: FontItem;
|
|
221
|
-
gothic: FontItem;
|
|
222
|
-
mincho: FontItem;
|
|
223
|
-
};
|
|
91
|
+
type flashCharList = {
|
|
92
|
+
[key in "simsunStrong" | "simsunWeak" | "gulim" | "gothic"]: string;
|
|
93
|
+
};
|
|
94
|
+
type flashMode = "xp" | "vista";
|
|
95
|
+
type flashScriptChar = {
|
|
96
|
+
[key in "super" | "sub"]: string;
|
|
97
|
+
};
|
|
98
|
+
type fontList = {
|
|
99
|
+
[key in "gulim" | "simsun"]: string;
|
|
100
|
+
};
|
|
101
|
+
type lineCounts = {
|
|
102
|
+
[key in "default" | "resized" | "doubleResized"]: configSizeItem<number>;
|
|
103
|
+
};
|
|
104
|
+
type typeDoubleResizeMaxWidth = {
|
|
105
|
+
[key in "full" | "normal"]: number;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
type BaseConfig = {
|
|
109
|
+
cacheAge: number;
|
|
110
|
+
canvasHeight: number;
|
|
111
|
+
canvasWidth: number;
|
|
112
|
+
collisionRange: { [key in "left" | "right"]: number };
|
|
113
|
+
colors: { [key: string]: string };
|
|
114
|
+
commentDrawPadding: number;
|
|
115
|
+
commentDrawRange: number;
|
|
116
|
+
commentScale: configItem<number>;
|
|
117
|
+
commentStageSize: configItem<commentStageSize>;
|
|
118
|
+
commentYMarginBottom: configSizeItem<number>;
|
|
119
|
+
commentYOffset: configSizeItem<configResizedItem<number>>;
|
|
120
|
+
commentYPaddingTop: configResizedItem<number>;
|
|
121
|
+
contextFillLiveOpacity: number;
|
|
122
|
+
contextLineWidth: number;
|
|
123
|
+
contextStrokeColor: string;
|
|
124
|
+
contextStrokeInversionColor: string;
|
|
125
|
+
contextStrokeOpacity: number;
|
|
126
|
+
doubleResizeMaxWidth: configItem<typeDoubleResizeMaxWidth>;
|
|
127
|
+
flashChar: flashCharList;
|
|
128
|
+
flashMode: flashMode;
|
|
129
|
+
flashScriptChar: flashScriptChar;
|
|
130
|
+
flashThreshold: number;
|
|
131
|
+
font: fontList;
|
|
132
|
+
fonts: platformFont;
|
|
133
|
+
fontSize: configItem<configSizeItem<configResizedItem<number>>>;
|
|
134
|
+
fpsInterval: number;
|
|
135
|
+
hiResCommentCorrection: number;
|
|
136
|
+
lineCounts: configItem<lineCounts>;
|
|
137
|
+
lineHeight: configItem<configSizeItem<configResizedItem<number>>>;
|
|
138
|
+
minFontSize: number;
|
|
139
|
+
sameCAGap: number;
|
|
140
|
+
sameCAMinScore: number;
|
|
141
|
+
sameCARange: number;
|
|
142
|
+
sameCATimestampRange: number;
|
|
143
|
+
letterSpacing: number;
|
|
144
|
+
scriptCharOffset: number;
|
|
145
|
+
plugins: IPluginConstructor[];
|
|
146
|
+
commentPlugins: {
|
|
147
|
+
class: typeof BaseComment;
|
|
148
|
+
condition: (comment: formattedComment) => boolean;
|
|
149
|
+
}[];
|
|
150
|
+
commentLimit: number | undefined;
|
|
151
|
+
hideCommentOrder: "asc" | "desc";
|
|
152
|
+
lineBreakCount: { [key in commentSize]: number };
|
|
153
|
+
nakaCommentSpeedOffset: number;
|
|
224
154
|
};
|
|
225
155
|
|
|
156
|
+
export type Config = Partial<BaseConfig>;
|
|
226
157
|
|
|
158
|
+
declare let imageCache: {
|
|
159
|
+
[key: string]: {
|
|
160
|
+
image: HTMLCanvasElement;
|
|
161
|
+
timeout: number;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
declare const resetImageCache: () => void;
|
|
227
165
|
|
|
228
166
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
167
|
+
export * from "./cache";
|
|
168
|
+
export * from "./nicoscript";
|
|
169
|
+
export * from "./plugins";
|
|
232
170
|
|
|
233
|
-
type
|
|
171
|
+
import type { nicoScript } from "@/@types/";
|
|
172
|
+
declare let nicoScripts: nicoScript;
|
|
173
|
+
declare const resetNicoScripts: () => void;
|
|
234
174
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
175
|
+
|
|
176
|
+
import type { IPlugin } from "@/@types/";
|
|
177
|
+
declare let plugins: IPlugin[];
|
|
178
|
+
declare const setPlugins: (input: IPlugin[]) => void;
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
declare const colors: {
|
|
182
|
+
white: string;
|
|
183
|
+
red: string;
|
|
184
|
+
pink: string;
|
|
185
|
+
orange: string;
|
|
186
|
+
yellow: string;
|
|
187
|
+
green: string;
|
|
188
|
+
cyan: string;
|
|
189
|
+
blue: string;
|
|
190
|
+
purple: string;
|
|
191
|
+
black: string;
|
|
192
|
+
white2: string;
|
|
193
|
+
niconicowhite: string;
|
|
194
|
+
red2: string;
|
|
195
|
+
truered: string;
|
|
196
|
+
pink2: string;
|
|
197
|
+
orange2: string;
|
|
198
|
+
passionorange: string;
|
|
199
|
+
yellow2: string;
|
|
200
|
+
madyellow: string;
|
|
201
|
+
green2: string;
|
|
202
|
+
elementalgreen: string;
|
|
203
|
+
cyan2: string;
|
|
204
|
+
blue2: string;
|
|
205
|
+
marinblue: string;
|
|
206
|
+
purple2: string;
|
|
207
|
+
nobleviolet: string;
|
|
208
|
+
black2: string;
|
|
244
209
|
};
|
|
245
|
-
|
|
246
|
-
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
import type { BaseConfig, BaseOptions } from "@/@types/";
|
|
213
|
+
declare let defaultConfig: BaseConfig;
|
|
214
|
+
declare const updateConfig: (config: BaseConfig) => void;
|
|
215
|
+
declare const defaultOptions: BaseOptions;
|
|
216
|
+
declare let config: BaseConfig;
|
|
217
|
+
declare let options: BaseOptions;
|
|
218
|
+
declare const setConfig: (value: BaseConfig) => BaseConfig;
|
|
219
|
+
declare const setOptions: (value: BaseOptions) => BaseOptions;
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
import { FontItem } from "@/@types";
|
|
223
|
+
declare const fontTemplates: {
|
|
224
|
+
arial: {
|
|
225
|
+
font: string;
|
|
226
|
+
offset: number;
|
|
227
|
+
weight: number;
|
|
228
|
+
};
|
|
229
|
+
gothic: {
|
|
230
|
+
font: string;
|
|
231
|
+
offset: number;
|
|
232
|
+
weight: number;
|
|
233
|
+
};
|
|
234
|
+
gulim: {
|
|
235
|
+
font: string;
|
|
236
|
+
offset: number;
|
|
237
|
+
weight: number;
|
|
238
|
+
};
|
|
239
|
+
mincho: {
|
|
240
|
+
font: string;
|
|
241
|
+
offset: number;
|
|
242
|
+
weight: number;
|
|
243
|
+
};
|
|
244
|
+
simsun: {
|
|
245
|
+
font: string;
|
|
246
|
+
offset: number;
|
|
247
|
+
weight: number;
|
|
248
|
+
};
|
|
249
|
+
macGothicPro6: {
|
|
250
|
+
font: string;
|
|
251
|
+
offset: number;
|
|
252
|
+
weight: number;
|
|
253
|
+
};
|
|
254
|
+
macGothicPro3: {
|
|
255
|
+
font: string;
|
|
256
|
+
offset: number;
|
|
257
|
+
weight: number;
|
|
258
|
+
};
|
|
259
|
+
macMincho: {
|
|
260
|
+
font: string;
|
|
261
|
+
offset: number;
|
|
262
|
+
weight: number;
|
|
263
|
+
};
|
|
264
|
+
macGothic1: {
|
|
265
|
+
font: string;
|
|
266
|
+
offset: number;
|
|
267
|
+
weight: number;
|
|
268
|
+
};
|
|
269
|
+
macGothic2: {
|
|
270
|
+
font: string;
|
|
271
|
+
offset: number;
|
|
272
|
+
weight: number;
|
|
273
|
+
};
|
|
274
|
+
sansSerif600: {
|
|
275
|
+
font: string;
|
|
276
|
+
offset: number;
|
|
277
|
+
weight: number;
|
|
278
|
+
};
|
|
279
|
+
sansSerif400: {
|
|
280
|
+
font: string;
|
|
281
|
+
offset: number;
|
|
282
|
+
weight: number;
|
|
283
|
+
};
|
|
284
|
+
serif: {
|
|
285
|
+
font: string;
|
|
286
|
+
offset: number;
|
|
287
|
+
weight: number;
|
|
288
|
+
};
|
|
247
289
|
};
|
|
248
|
-
|
|
249
|
-
|
|
290
|
+
declare const fonts: {
|
|
291
|
+
win7: {
|
|
292
|
+
defont: FontItem;
|
|
293
|
+
gothic: FontItem;
|
|
294
|
+
mincho: FontItem;
|
|
295
|
+
};
|
|
296
|
+
win8_1: {
|
|
297
|
+
defont: FontItem;
|
|
298
|
+
gothic: FontItem;
|
|
299
|
+
mincho: FontItem;
|
|
300
|
+
};
|
|
301
|
+
win: {
|
|
302
|
+
defont: FontItem;
|
|
303
|
+
gothic: FontItem;
|
|
304
|
+
mincho: FontItem;
|
|
305
|
+
};
|
|
306
|
+
mac10_9: {
|
|
307
|
+
defont: FontItem;
|
|
308
|
+
gothic: FontItem;
|
|
309
|
+
mincho: FontItem;
|
|
310
|
+
};
|
|
311
|
+
mac10_11: {
|
|
312
|
+
defont: FontItem;
|
|
313
|
+
gothic: FontItem;
|
|
314
|
+
mincho: FontItem;
|
|
315
|
+
};
|
|
316
|
+
mac: {
|
|
317
|
+
defont: FontItem;
|
|
318
|
+
gothic: FontItem;
|
|
319
|
+
mincho: FontItem;
|
|
320
|
+
};
|
|
321
|
+
other: {
|
|
322
|
+
defont: FontItem;
|
|
323
|
+
gothic: FontItem;
|
|
324
|
+
mincho: FontItem;
|
|
325
|
+
};
|
|
250
326
|
};
|
|
251
327
|
|
|
252
|
-
type BaseConfig = {
|
|
253
|
-
cacheAge: number;
|
|
254
|
-
canvasHeight: number;
|
|
255
|
-
canvasWidth: number;
|
|
256
|
-
collisionRange: { [key in "left" | "right"]: number };
|
|
257
|
-
colors: { [key: string]: string };
|
|
258
|
-
commentDrawPadding: number;
|
|
259
|
-
commentDrawRange: number;
|
|
260
|
-
commentScale: configItem<number>;
|
|
261
|
-
commentStageSize: configItem<commentStageSize>;
|
|
262
|
-
commentYMarginBottom: configSizeItem<number>;
|
|
263
|
-
commentYOffset: configSizeItem<configResizedItem<number>>;
|
|
264
|
-
commentYPaddingTop: configResizedItem<number>;
|
|
265
|
-
contextFillLiveOpacity: number;
|
|
266
|
-
contextLineWidth: number;
|
|
267
|
-
contextStrokeColor: string;
|
|
268
|
-
contextStrokeInversionColor: string;
|
|
269
|
-
contextStrokeOpacity: number;
|
|
270
|
-
doubleResizeMaxWidth: configItem<typeDoubleResizeMaxWidth>;
|
|
271
|
-
flashChar: flashCharList;
|
|
272
|
-
flashMode: flashMode;
|
|
273
|
-
flashScriptChar: flashScriptChar;
|
|
274
|
-
flashThreshold: number;
|
|
275
|
-
font: fontList;
|
|
276
|
-
fonts: platformFont;
|
|
277
|
-
fontSize: configItem<configSizeItem<configResizedItem<number>>>;
|
|
278
|
-
fpsInterval: number;
|
|
279
|
-
hiResCommentCorrection: number;
|
|
280
|
-
lineCounts: configItem<lineCounts>;
|
|
281
|
-
lineHeight: configItem<configSizeItem<configResizedItem<number>>>;
|
|
282
|
-
minFontSize: number;
|
|
283
|
-
sameCAGap: number;
|
|
284
|
-
sameCAMinScore: number;
|
|
285
|
-
sameCARange: number;
|
|
286
|
-
letterSpacing: number;
|
|
287
|
-
scriptCharOffset: number;
|
|
288
|
-
plugins: IPluginConstructor[];
|
|
289
|
-
};
|
|
290
328
|
|
|
291
|
-
|
|
329
|
+
declare const initConfig: () => void;
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
declare class CanvasRenderingContext2DError extends Error {
|
|
333
|
+
constructor(options?: {
|
|
334
|
+
[key: string]: unknown;
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
export * from "./CanvasRenderingContext2DError";
|
|
340
|
+
export * from "./InvalidFormatError";
|
|
341
|
+
export * from "./InvalidOptionError";
|
|
342
|
+
export * from "./NotImplementedError";
|
|
343
|
+
|
|
344
|
+
declare class InvalidFormatError extends Error {
|
|
345
|
+
constructor(options?: {
|
|
346
|
+
[key: string]: unknown;
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
declare class InvalidOptionError extends Error {
|
|
352
|
+
constructor(options?: {
|
|
353
|
+
[key: string]: unknown;
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
declare class NotImplementedError extends Error {
|
|
359
|
+
pluginName: string;
|
|
360
|
+
methodName: string;
|
|
361
|
+
constructor(pluginName: string, methodName: string, options?: {
|
|
362
|
+
[key: string]: unknown;
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
|
|
292
366
|
|
|
293
367
|
export interface CommentEventBase {
|
|
294
368
|
type: CommentEventName;
|
|
@@ -332,6 +406,12 @@ export type CommentEventName =
|
|
|
332
406
|
| "commentDisable"
|
|
333
407
|
| "commentEnable"
|
|
334
408
|
| "jump";
|
|
409
|
+
export type CommentEventHandler =
|
|
410
|
+
| SeekDisableEventHandler
|
|
411
|
+
| SeekEnableEventHandler
|
|
412
|
+
| CommentDisableEventHandler
|
|
413
|
+
| CommentEnableEventHandler
|
|
414
|
+
| JumpEventHandler;
|
|
335
415
|
export interface CommentEventHandlerMap {
|
|
336
416
|
seekDisable: SeekDisableEventHandler;
|
|
337
417
|
seekEnable: SeekEnableEventHandler;
|
|
@@ -347,187 +427,377 @@ export interface CommentEventMap {
|
|
|
347
427
|
jump: JumpEvent;
|
|
348
428
|
}
|
|
349
429
|
|
|
350
|
-
type
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
| "mac10_9"
|
|
355
|
-
| "mac10_11"
|
|
356
|
-
| "mac"
|
|
357
|
-
| "other";
|
|
358
|
-
type HTML5Fonts = "gothic" | "mincho" | "defont";
|
|
359
|
-
type FontItem = {
|
|
360
|
-
font: string;
|
|
361
|
-
offset: number;
|
|
362
|
-
weight: number;
|
|
363
|
-
};
|
|
364
|
-
type platformFont = {
|
|
365
|
-
[key in HTML5Fonts]: FontItem;
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
export type formattedComment = {
|
|
369
|
-
id: number;
|
|
370
|
-
vpos: number;
|
|
371
|
-
content: string;
|
|
372
|
-
date: number;
|
|
373
|
-
date_usec: number;
|
|
374
|
-
owner: boolean;
|
|
375
|
-
premium: boolean;
|
|
376
|
-
mail: string[];
|
|
377
|
-
user_id: number;
|
|
378
|
-
layer: number;
|
|
379
|
-
};
|
|
380
|
-
export type formattedLegacyComment = {
|
|
381
|
-
id: number;
|
|
382
|
-
vpos: number;
|
|
383
|
-
content: string;
|
|
384
|
-
date: number;
|
|
385
|
-
date_usec: number;
|
|
386
|
-
owner: boolean;
|
|
387
|
-
premium: boolean;
|
|
388
|
-
mail: string[];
|
|
389
|
-
};
|
|
430
|
+
import type { CommentEventHandlerMap } from "@/@types/";
|
|
431
|
+
declare const registerHandler: <K extends keyof CommentEventHandlerMap>(eventName: K, handler: CommentEventHandlerMap[K]) => void;
|
|
432
|
+
declare const removeHandler: <K extends keyof CommentEventHandlerMap>(eventName: K, handler: CommentEventHandlerMap[K]) => void;
|
|
433
|
+
declare const triggerHandler: (vpos: number, lastVpos: number) => void;
|
|
390
434
|
|
|
391
|
-
export type rawApiResponse = {
|
|
392
|
-
[key: string]: apiPing | apiThread | apiLeaf | apiGlobalNumRes | apiChat;
|
|
393
|
-
};
|
|
394
|
-
type apiPing = {
|
|
395
|
-
content: string;
|
|
396
|
-
};
|
|
397
|
-
type apiThread = {
|
|
398
|
-
resultcode: number;
|
|
399
|
-
thread: string;
|
|
400
|
-
server_time: number;
|
|
401
|
-
ticket: string;
|
|
402
|
-
revision: number;
|
|
403
|
-
};
|
|
404
|
-
type apiLeaf = {
|
|
405
|
-
thread: string;
|
|
406
|
-
count: number;
|
|
407
|
-
};
|
|
408
|
-
type apiGlobalNumRes = {
|
|
409
|
-
thread: string;
|
|
410
|
-
num_res: number;
|
|
411
|
-
};
|
|
412
|
-
type apiChat = {
|
|
413
|
-
thread: string;
|
|
414
|
-
no: number;
|
|
415
|
-
vpos: number;
|
|
416
|
-
date: number;
|
|
417
|
-
date_usec: number;
|
|
418
|
-
nicoru: number;
|
|
419
|
-
premium: number;
|
|
420
|
-
anonymity: number;
|
|
421
|
-
user_id: string;
|
|
422
|
-
mail: string;
|
|
423
|
-
content: string;
|
|
424
|
-
deleted: number;
|
|
425
|
-
};
|
|
426
435
|
|
|
427
|
-
export type
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
436
|
+
export type platform =
|
|
437
|
+
| "win7"
|
|
438
|
+
| "win8_1"
|
|
439
|
+
| "win"
|
|
440
|
+
| "mac10_9"
|
|
441
|
+
| "mac10_11"
|
|
442
|
+
| "mac"
|
|
443
|
+
| "other";
|
|
444
|
+
export type HTML5Fonts = "gothic" | "mincho" | "defont";
|
|
445
|
+
export type FontItem = {
|
|
446
|
+
font: string;
|
|
447
|
+
offset: number;
|
|
448
|
+
weight: number;
|
|
449
|
+
};
|
|
450
|
+
export type platformFont = {
|
|
451
|
+
[key in HTML5Fonts]: FontItem;
|
|
452
|
+
};
|
|
432
453
|
|
|
433
|
-
export type
|
|
434
|
-
id:
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
+
export 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
|
+
export 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
|
+
};
|
|
454
476
|
|
|
477
|
+
export type rawApiResponse = {
|
|
478
|
+
[key: string]: apiPing | apiThread | apiLeaf | apiGlobalNumRes | apiChat;
|
|
479
|
+
};
|
|
480
|
+
type apiPing = {
|
|
481
|
+
content: string;
|
|
482
|
+
};
|
|
483
|
+
type apiThread = {
|
|
484
|
+
resultcode: number;
|
|
485
|
+
thread: string;
|
|
486
|
+
server_time: number;
|
|
487
|
+
ticket: string;
|
|
488
|
+
revision: number;
|
|
489
|
+
};
|
|
490
|
+
type apiLeaf = {
|
|
491
|
+
thread: string;
|
|
492
|
+
count: number;
|
|
493
|
+
};
|
|
494
|
+
type apiGlobalNumRes = {
|
|
495
|
+
thread: string;
|
|
496
|
+
num_res: number;
|
|
497
|
+
};
|
|
498
|
+
type apiChat = {
|
|
499
|
+
thread: string;
|
|
500
|
+
no: number;
|
|
501
|
+
vpos: number;
|
|
502
|
+
date: number;
|
|
503
|
+
date_usec: number;
|
|
504
|
+
nicoru: number;
|
|
505
|
+
premium: number;
|
|
506
|
+
anonymity: number;
|
|
507
|
+
user_id: string;
|
|
508
|
+
mail: string;
|
|
509
|
+
content: string;
|
|
510
|
+
deleted: number;
|
|
511
|
+
};
|
|
455
512
|
|
|
513
|
+
export type ownerComment = {
|
|
514
|
+
time: string;
|
|
515
|
+
command: string;
|
|
516
|
+
comment: string;
|
|
517
|
+
};
|
|
456
518
|
|
|
457
|
-
export
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
519
|
+
export type v1Thread = {
|
|
520
|
+
id: string;
|
|
521
|
+
fork: string;
|
|
522
|
+
commentCount: number;
|
|
523
|
+
comments: v1Comment[];
|
|
524
|
+
};
|
|
525
|
+
type v1Comment = {
|
|
526
|
+
id: string;
|
|
527
|
+
no: number;
|
|
528
|
+
vposMs: number;
|
|
529
|
+
body: string;
|
|
530
|
+
commands: string[];
|
|
531
|
+
userId: string;
|
|
532
|
+
isPremium: boolean;
|
|
533
|
+
score: number;
|
|
534
|
+
postedAt: string;
|
|
535
|
+
nicoruCount: number;
|
|
536
|
+
nicoruId: undefined;
|
|
537
|
+
source: string;
|
|
538
|
+
isMyPost: boolean;
|
|
539
|
+
};
|
|
474
540
|
|
|
541
|
+
import type { commentLoc, formattedCommentWithSize } from "@/@types/";
|
|
542
|
+
|
|
543
|
+
export interface IComment {
|
|
544
|
+
comment: formattedCommentWithSize;
|
|
545
|
+
invisible: boolean;
|
|
546
|
+
loc: commentLoc;
|
|
547
|
+
width: number;
|
|
548
|
+
long: number;
|
|
549
|
+
height: number;
|
|
550
|
+
vpos: number;
|
|
551
|
+
flash: boolean;
|
|
552
|
+
posY: number;
|
|
553
|
+
owner: boolean;
|
|
554
|
+
layer: number;
|
|
555
|
+
mail: string[];
|
|
556
|
+
image?: HTMLCanvasElement | null;
|
|
557
|
+
draw: (vpos: number, showCollision: boolean, isDebug: boolean) => void;
|
|
558
|
+
}
|
|
475
559
|
|
|
560
|
+
export * from "./config";
|
|
561
|
+
export * from "./event";
|
|
562
|
+
export * from "./fonts";
|
|
563
|
+
export * from "./format.formatted";
|
|
564
|
+
export * from "./format.legacy";
|
|
565
|
+
export * from "./format.owner";
|
|
566
|
+
export * from "./format.v1";
|
|
567
|
+
export * from "./IComment";
|
|
568
|
+
export * from "./IPlugins";
|
|
569
|
+
export * from "./options";
|
|
570
|
+
export * from "./types";
|
|
476
571
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
new (Canvas: HTMLCanvasElement, comments: formattedComment[]): IPlugin;
|
|
480
|
-
}
|
|
572
|
+
import type { formattedComment, inputFormatType } from "@/@types/";
|
|
573
|
+
declare const convert2formattedComment: (data: unknown, type: inputFormatType) => formattedComment[];
|
|
481
574
|
|
|
482
|
-
export interface IPlugin {
|
|
483
|
-
draw(vpos: number): void;
|
|
484
|
-
addComments(comments: formattedComment[]): void;
|
|
485
|
-
}
|
|
486
575
|
|
|
576
|
+
import type * as types from "@/@types/";
|
|
577
|
+
import * as comments from "@/comments";
|
|
578
|
+
import * as contexts from "@/contexts";
|
|
579
|
+
import * as colors from "@/definition/colors";
|
|
580
|
+
import * as config from "@/definition/config";
|
|
581
|
+
import * as fonts from "@/definition/fonts";
|
|
582
|
+
import * as initConfig from "@/definition/initConfig";
|
|
583
|
+
import * as errors from "@/errors";
|
|
584
|
+
import * as eventHandler from "@/eventHandler";
|
|
585
|
+
import * as inputParser from "@/inputParser";
|
|
586
|
+
import * as typeGuard from "@/typeGuard";
|
|
587
|
+
import * as utils from "@/utils";
|
|
588
|
+
declare const definition: {
|
|
589
|
+
colors: typeof colors;
|
|
590
|
+
config: typeof config;
|
|
591
|
+
fonts: typeof fonts;
|
|
592
|
+
initConfig: typeof initConfig;
|
|
593
|
+
};
|
|
487
594
|
|
|
488
595
|
|
|
596
|
+
import type { formattedComment } from "@/@types/";
|
|
597
|
+
|
|
598
|
+
export interface IPluginConstructor {
|
|
599
|
+
id: string;
|
|
600
|
+
new (Canvas: HTMLCanvasElement, comments: formattedComment[]): IPlugin;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
export interface IPlugin {
|
|
604
|
+
draw(vpos: number): void;
|
|
605
|
+
addComments(comments: formattedComment[]): void;
|
|
606
|
+
}
|
|
489
607
|
|
|
608
|
+
import type { CommentEventHandlerMap, formattedComment, inputFormat, Options } from "@/@types/";
|
|
609
|
+
import { FlashComment } from "@/comments/";
|
|
610
|
+
import * as internal from "./internal";
|
|
611
|
+
declare class NiconiComments {
|
|
612
|
+
enableLegacyPiP: boolean;
|
|
613
|
+
showCollision: boolean;
|
|
614
|
+
showFPS: boolean;
|
|
615
|
+
showCommentCount: boolean;
|
|
616
|
+
video: HTMLVideoElement | undefined;
|
|
617
|
+
private lastVpos;
|
|
618
|
+
private readonly canvas;
|
|
619
|
+
private readonly collision;
|
|
620
|
+
private readonly context;
|
|
621
|
+
private readonly timeline;
|
|
622
|
+
static typeGuard: {
|
|
623
|
+
formatted: {
|
|
624
|
+
comment: (i: unknown) => i is formattedComment;
|
|
625
|
+
comments: (i: unknown) => i is formattedComment[];
|
|
626
|
+
legacyComment: (i: unknown) => i is internal.types.formattedLegacyComment;
|
|
627
|
+
legacyComments: (i: unknown) => i is internal.types.formattedLegacyComment[];
|
|
628
|
+
};
|
|
629
|
+
legacy: {
|
|
630
|
+
rawApiResponses: (i: unknown) => i is internal.types.rawApiResponse[];
|
|
631
|
+
apiChat: (i: unknown) => i is internal.types.apiChat;
|
|
632
|
+
apiGlobalNumRes: (i: unknown) => i is internal.types.apiGlobalNumRes;
|
|
633
|
+
apiLeaf: (i: unknown) => i is internal.types.apiLeaf;
|
|
634
|
+
apiPing: (i: unknown) => i is internal.types.apiPing;
|
|
635
|
+
apiThread: (i: unknown) => i is internal.types.apiThread;
|
|
636
|
+
};
|
|
637
|
+
xmlDocument: (i: unknown) => i is XMLDocument;
|
|
638
|
+
legacyOwner: {
|
|
639
|
+
comments: (i: unknown) => i is string;
|
|
640
|
+
};
|
|
641
|
+
owner: {
|
|
642
|
+
comment: (i: unknown) => i is internal.types.ownerComment;
|
|
643
|
+
comments: (i: unknown) => i is internal.types.ownerComment[];
|
|
644
|
+
};
|
|
645
|
+
v1: {
|
|
646
|
+
comment: (i: unknown) => i is internal.types.v1Comment;
|
|
647
|
+
thread: (i: unknown) => i is internal.types.v1Thread;
|
|
648
|
+
threads: (i: unknown) => i is internal.types.v1Thread[];
|
|
649
|
+
};
|
|
650
|
+
nicoScript: {
|
|
651
|
+
range: {
|
|
652
|
+
target: (i: unknown) => i is internal.types.nicoScriptReverseTarget;
|
|
653
|
+
};
|
|
654
|
+
replace: {
|
|
655
|
+
range: (i: unknown) => i is internal.types.nicoScriptReplaceRange;
|
|
656
|
+
target: (i: unknown) => i is internal.types.nicoScriptReplaceTarget;
|
|
657
|
+
condition: (i: unknown) => i is internal.types.nicoScriptReplaceCondition;
|
|
658
|
+
};
|
|
659
|
+
};
|
|
660
|
+
comment: {
|
|
661
|
+
font: (i: unknown) => i is internal.types.commentFont;
|
|
662
|
+
loc: (i: unknown) => i is internal.types.commentLoc;
|
|
663
|
+
size: (i: unknown) => i is internal.types.commentSize;
|
|
664
|
+
command: {
|
|
665
|
+
key: (i: unknown) => i is "full" | "ender" | "_live" | "invisible";
|
|
666
|
+
};
|
|
667
|
+
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";
|
|
668
|
+
colorCode: (i: unknown) => i is string;
|
|
669
|
+
colorCodeAllowAlpha: (i: unknown) => i is string;
|
|
670
|
+
};
|
|
671
|
+
config: {
|
|
672
|
+
initOptions: (item: unknown) => item is Partial<internal.types.BaseOptions>;
|
|
673
|
+
};
|
|
674
|
+
};
|
|
675
|
+
static default: typeof NiconiComments;
|
|
676
|
+
static FlashComment: {
|
|
677
|
+
condition: (comment: formattedComment) => boolean;
|
|
678
|
+
class: typeof FlashComment;
|
|
679
|
+
};
|
|
680
|
+
static internal: typeof internal;
|
|
681
|
+
constructor(canvas: HTMLCanvasElement, data: inputFormat, initOptions?: Options);
|
|
682
|
+
private preRendering;
|
|
683
|
+
private getCommentPos;
|
|
684
|
+
private sortComment;
|
|
685
|
+
addComments(...rawComments: formattedComment[]): void;
|
|
686
|
+
drawCanvas(vpos: number, forceRendering?: boolean): boolean;
|
|
687
|
+
private _drawVideo;
|
|
688
|
+
private _drawComments;
|
|
689
|
+
private _drawCollision;
|
|
690
|
+
private _drawFPS;
|
|
691
|
+
private _drawCommentCount;
|
|
692
|
+
addEventListener<K extends keyof CommentEventHandlerMap>(eventName: K, handler: CommentEventHandlerMap[K]): void;
|
|
693
|
+
removeEventListener<K extends keyof CommentEventHandlerMap>(eventName: K, handler: CommentEventHandlerMap[K]): void;
|
|
694
|
+
clear(): void;
|
|
695
|
+
}
|
|
490
696
|
|
|
491
697
|
|
|
698
|
+
import type {
|
|
699
|
+
Config,
|
|
700
|
+
formattedComment,
|
|
701
|
+
formattedLegacyComment,
|
|
702
|
+
ownerComment,
|
|
703
|
+
rawApiResponse,
|
|
704
|
+
v1Thread,
|
|
705
|
+
} from "@/@types/";
|
|
706
|
+
|
|
707
|
+
export type inputFormatType =
|
|
708
|
+
| "XMLDocument"
|
|
709
|
+
| "niconicome"
|
|
710
|
+
| "formatted"
|
|
711
|
+
| "legacy"
|
|
712
|
+
| "legacyOwner"
|
|
713
|
+
| "owner"
|
|
714
|
+
| "v1"
|
|
715
|
+
| "empty"
|
|
716
|
+
| "default";
|
|
717
|
+
export type inputFormat =
|
|
718
|
+
| XMLDocument
|
|
719
|
+
| formattedComment[]
|
|
720
|
+
| formattedLegacyComment[]
|
|
721
|
+
| rawApiResponse[]
|
|
722
|
+
| ownerComment[]
|
|
723
|
+
| v1Thread[]
|
|
724
|
+
| string
|
|
725
|
+
| undefined;
|
|
726
|
+
type modeType = "default" | "html5" | "flash";
|
|
727
|
+
type BaseOptions = {
|
|
728
|
+
config: Config;
|
|
729
|
+
debug: boolean;
|
|
730
|
+
enableLegacyPiP: boolean;
|
|
731
|
+
format: inputFormatType;
|
|
732
|
+
formatted: boolean;
|
|
733
|
+
keepCA: boolean;
|
|
734
|
+
mode: modeType;
|
|
735
|
+
scale: number;
|
|
736
|
+
showCollision: boolean;
|
|
737
|
+
showCommentCount: boolean;
|
|
738
|
+
showFPS: boolean;
|
|
739
|
+
useLegacy: boolean;
|
|
740
|
+
video: HTMLVideoElement | undefined;
|
|
741
|
+
};
|
|
742
|
+
export type Options = Partial<BaseOptions>;
|
|
492
743
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
744
|
+
import type { apiChat, apiGlobalNumRes, apiLeaf, apiPing, apiThread, commentFont, commentLoc, commentSize, formattedComment, formattedLegacyComment, nicoScriptReplaceCondition, nicoScriptReplaceRange, nicoScriptReplaceTarget, nicoScriptReverseTarget, ownerComment, rawApiResponse, v1Comment, v1Thread } from "@/@types/";
|
|
745
|
+
declare const typeGuard: {
|
|
746
|
+
formatted: {
|
|
747
|
+
comment: (i: unknown) => i is formattedComment;
|
|
748
|
+
comments: (i: unknown) => i is formattedComment[];
|
|
749
|
+
legacyComment: (i: unknown) => i is formattedLegacyComment;
|
|
750
|
+
legacyComments: (i: unknown) => i is formattedLegacyComment[];
|
|
751
|
+
};
|
|
752
|
+
legacy: {
|
|
753
|
+
rawApiResponses: (i: unknown) => i is rawApiResponse[];
|
|
754
|
+
apiChat: (i: unknown) => i is apiChat;
|
|
755
|
+
apiGlobalNumRes: (i: unknown) => i is apiGlobalNumRes;
|
|
756
|
+
apiLeaf: (i: unknown) => i is apiLeaf;
|
|
757
|
+
apiPing: (i: unknown) => i is apiPing;
|
|
758
|
+
apiThread: (i: unknown) => i is apiThread;
|
|
759
|
+
};
|
|
760
|
+
xmlDocument: (i: unknown) => i is XMLDocument;
|
|
761
|
+
legacyOwner: {
|
|
762
|
+
comments: (i: unknown) => i is string;
|
|
763
|
+
};
|
|
764
|
+
owner: {
|
|
765
|
+
comment: (i: unknown) => i is ownerComment;
|
|
766
|
+
comments: (i: unknown) => i is ownerComment[];
|
|
767
|
+
};
|
|
768
|
+
v1: {
|
|
769
|
+
comment: (i: unknown) => i is v1Comment;
|
|
770
|
+
thread: (i: unknown) => i is v1Thread;
|
|
771
|
+
threads: (i: unknown) => i is v1Thread[];
|
|
772
|
+
};
|
|
773
|
+
nicoScript: {
|
|
774
|
+
range: {
|
|
775
|
+
target: (i: unknown) => i is nicoScriptReverseTarget;
|
|
776
|
+
};
|
|
777
|
+
replace: {
|
|
778
|
+
range: (i: unknown) => i is nicoScriptReplaceRange;
|
|
779
|
+
target: (i: unknown) => i is nicoScriptReplaceTarget;
|
|
780
|
+
condition: (i: unknown) => i is nicoScriptReplaceCondition;
|
|
781
|
+
};
|
|
782
|
+
};
|
|
783
|
+
comment: {
|
|
784
|
+
font: (i: unknown) => i is commentFont;
|
|
785
|
+
loc: (i: unknown) => i is commentLoc;
|
|
786
|
+
size: (i: unknown) => i is commentSize;
|
|
787
|
+
command: {
|
|
788
|
+
key: (i: unknown) => i is "full" | "ender" | "_live" | "invisible";
|
|
789
|
+
};
|
|
790
|
+
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";
|
|
791
|
+
colorCode: (i: unknown) => i is string;
|
|
792
|
+
colorCodeAllowAlpha: (i: unknown) => i is string;
|
|
793
|
+
};
|
|
794
|
+
config: {
|
|
795
|
+
initOptions: (item: unknown) => item is Partial<BaseOptions>;
|
|
796
|
+
};
|
|
527
797
|
};
|
|
528
|
-
export type Options = Partial<BaseOptions>;
|
|
529
798
|
|
|
530
|
-
|
|
799
|
+
|
|
800
|
+
import type { IComment } from "@/@types/";
|
|
531
801
|
|
|
532
802
|
type formattedCommentWithFont = {
|
|
533
803
|
id: number;
|
|
@@ -572,6 +842,7 @@ type parsedComment = formattedCommentWithSize & {
|
|
|
572
842
|
};
|
|
573
843
|
type commentContentItem = {
|
|
574
844
|
content: string;
|
|
845
|
+
slicedContent: string[];
|
|
575
846
|
font?: commentFlashFont;
|
|
576
847
|
width?: number[];
|
|
577
848
|
};
|
|
@@ -587,6 +858,7 @@ type commentFlashFont = "defont" | "gulim" | "simsun";
|
|
|
587
858
|
type commentSize = "big" | "medium" | "small";
|
|
588
859
|
type commentLoc = "ue" | "naka" | "shita";
|
|
589
860
|
type collision = { [key in collisionPos]: collisionItem };
|
|
861
|
+
type Timeline = { [key: number]: IComment[] };
|
|
590
862
|
type collisionPos = "ue" | "shita" | "right" | "left";
|
|
591
863
|
type collisionItem = { [p: number]: IComment[] };
|
|
592
864
|
type nicoScript = {
|
|
@@ -695,197 +967,87 @@ type measureInput = {
|
|
|
695
967
|
|
|
696
968
|
type valueOf<T> = T[keyof T];
|
|
697
969
|
|
|
698
|
-
|
|
699
|
-
declare const
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
970
|
+
import type { IComment } from "@/@types";
|
|
971
|
+
declare const ArrayPush: (array: {
|
|
972
|
+
[key: number]: IComment[];
|
|
973
|
+
}, key: string | number, push: IComment) => void;
|
|
974
|
+
declare const ArrayEqual: (a: unknown[], b: unknown[]) => boolean;
|
|
703
975
|
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
declare const convert2formattedComment: (data: unknown, type: inputFormatType) => formattedComment[];
|
|
707
|
-
|
|
708
976
|
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
declare
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
drawCanvas(vpos: number, forceRendering?: boolean): boolean;
|
|
782
|
-
addEventListener<K extends keyof CommentEventHandlerMap>(eventName: K, handler: CommentEventHandlerMap[K]): void;
|
|
783
|
-
removeEventListener<K extends keyof CommentEventHandlerMap>(eventName: K, handler: CommentEventHandlerMap[K]): void;
|
|
784
|
-
clear(): void;
|
|
785
|
-
}
|
|
786
|
-
|
|
977
|
+
import { formattedCommentWithSize } from "@/@types";
|
|
978
|
+
declare const hex2rgb: (hex: string) => number[];
|
|
979
|
+
declare const hex2rgba: (hex: string) => number[];
|
|
980
|
+
declare const getStrokeColor: (comment: formattedCommentWithSize) => string;
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
import type { collision, commentFont, commentLoc, commentSize, formattedComment, formattedCommentWithFont, formattedCommentWithSize, measureTextInput } from "@/@types/";
|
|
984
|
+
import { collisionItem, IComment, Timeline } from "@/@types/";
|
|
985
|
+
declare const isLineBreakResize: (comment: measureTextInput) => boolean;
|
|
986
|
+
declare const getDefaultCommand: (vpos: number) => {
|
|
987
|
+
color: string | undefined;
|
|
988
|
+
size: commentSize | undefined;
|
|
989
|
+
font: commentFont | undefined;
|
|
990
|
+
loc: commentLoc | undefined;
|
|
991
|
+
};
|
|
992
|
+
declare const parseCommandAndNicoScript: (comment: formattedComment) => formattedCommentWithFont;
|
|
993
|
+
declare const isFlashComment: (comment: formattedComment) => boolean;
|
|
994
|
+
declare const isReverseActive: (vpos: number, isOwner: boolean) => boolean;
|
|
995
|
+
declare const isBanActive: (vpos: number) => boolean;
|
|
996
|
+
declare const processFixedComment: (comment: IComment, collision: collisionItem, timeline: Timeline) => void;
|
|
997
|
+
declare const processMovableComment: (comment: IComment, collision: collision, timeline: Timeline) => void;
|
|
998
|
+
declare const getPosY: (currentPos: number, targetComment: IComment, collision: IComment[] | undefined) => {
|
|
999
|
+
currentPos: number;
|
|
1000
|
+
isChanged: boolean;
|
|
1001
|
+
isBreak: boolean;
|
|
1002
|
+
};
|
|
1003
|
+
declare const getPosX: (comment: formattedCommentWithSize, vpos: number, isReverse?: boolean) => number;
|
|
1004
|
+
declare const parseFont: (font: commentFont, size: string | number) => string;
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
import { formattedComment } from "@/@types";
|
|
1008
|
+
declare const changeCALayer: (rawData: formattedComment[]) => formattedComment[];
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
import { configItem } from "@/@types";
|
|
1012
|
+
declare const getConfig: <T>(input: configItem<T>, isFlash?: boolean) => T;
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
import type { commentContentIndex, commentFlashFont } from "@/@types";
|
|
1016
|
+
declare const getFlashFontIndex: (part: string) => commentContentIndex[];
|
|
1017
|
+
declare const getFlashFontName: (font: string) => commentFlashFont;
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
export * from "./array";
|
|
1021
|
+
export * from "./color";
|
|
1022
|
+
export * from "./comment";
|
|
1023
|
+
export * from "./commentArt";
|
|
1024
|
+
export * from "./config";
|
|
1025
|
+
export * from "./flash";
|
|
1026
|
+
export * from "./niconico";
|
|
1027
|
+
export * from "./sort";
|
|
1028
|
+
|
|
1029
|
+
import type { commentSize, measureInput } from "@/@types";
|
|
1030
|
+
declare const getLineHeight: (fontSize: commentSize, isFlash: boolean, resized?: boolean) => number;
|
|
1031
|
+
declare const getCharSize: (fontSize: commentSize, isFlash: boolean) => number;
|
|
1032
|
+
declare const measure: (comment: measureInput, context: CanvasRenderingContext2D) => {
|
|
1033
|
+
height: number;
|
|
1034
|
+
width: number;
|
|
1035
|
+
lineWidth: number[];
|
|
1036
|
+
itemWidth: number[][];
|
|
1037
|
+
};
|
|
1038
|
+
declare const getFontSizeAndScale: (charSize: number) => {
|
|
1039
|
+
scale: number;
|
|
1040
|
+
fontSize: number;
|
|
1041
|
+
};
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
import { formattedComment } from "@/@types";
|
|
1045
|
+
declare const createCommentInstance: (comment: formattedComment, context: CanvasRenderingContext2D) => BaseComment;
|
|
1046
|
+
|
|
1047
|
+
|
|
1048
|
+
declare const nativeSort: <T>(getter: (input: T) => number) => (a: T, b: T) => 1 | 0 | -1;
|
|
787
1049
|
|
|
788
|
-
|
|
789
|
-
declare const getLineHeight: (fontSize: commentSize, isFlash: boolean, resized?: boolean) => number;
|
|
790
|
-
declare const getCharSize: (fontSize: commentSize, isFlash: boolean) => number;
|
|
791
|
-
declare const measure: (comment: measureInput, context: CanvasRenderingContext2D) => {
|
|
792
|
-
height: number;
|
|
793
|
-
width: number;
|
|
794
|
-
lineWidth: number[];
|
|
795
|
-
itemWidth: number[][];
|
|
796
|
-
};
|
|
797
|
-
declare const getFontSizeAndScale: (charSize: number) => {
|
|
798
|
-
scale: number;
|
|
799
|
-
fontSize: number;
|
|
800
|
-
};
|
|
801
|
-
|
|
802
1050
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
declare const typeGuard: {
|
|
809
|
-
formatted: {
|
|
810
|
-
comment: (i: unknown) => i is formattedComment;
|
|
811
|
-
comments: (i: unknown) => i is formattedComment[];
|
|
812
|
-
legacyComment: (i: unknown) => i is formattedLegacyComment;
|
|
813
|
-
legacyComments: (i: unknown) => i is formattedLegacyComment[];
|
|
814
|
-
};
|
|
815
|
-
legacy: {
|
|
816
|
-
rawApiResponses: (i: unknown) => i is rawApiResponse[];
|
|
817
|
-
apiChat: (i: unknown) => i is apiChat;
|
|
818
|
-
apiGlobalNumRes: (i: unknown) => i is apiGlobalNumRes;
|
|
819
|
-
apiLeaf: (i: unknown) => i is apiLeaf;
|
|
820
|
-
apiPing: (i: unknown) => i is apiPing;
|
|
821
|
-
apiThread: (i: unknown) => i is apiThread;
|
|
822
|
-
};
|
|
823
|
-
xmlDocument: (i: unknown) => i is XMLDocument;
|
|
824
|
-
legacyOwner: {
|
|
825
|
-
comments: (i: unknown) => i is string;
|
|
826
|
-
};
|
|
827
|
-
owner: {
|
|
828
|
-
comment: (i: unknown) => i is ownerComment;
|
|
829
|
-
comments: (i: unknown) => i is ownerComment[];
|
|
830
|
-
};
|
|
831
|
-
v1: {
|
|
832
|
-
comment: (i: unknown) => i is v1Comment;
|
|
833
|
-
thread: (i: unknown) => i is v1Thread;
|
|
834
|
-
threads: (i: unknown) => i is v1Thread[];
|
|
835
|
-
};
|
|
836
|
-
nicoScript: {
|
|
837
|
-
range: {
|
|
838
|
-
target: (i: unknown) => i is nicoScriptReverseTarget;
|
|
839
|
-
};
|
|
840
|
-
replace: {
|
|
841
|
-
range: (i: unknown) => i is nicoScriptReplaceRange;
|
|
842
|
-
target: (i: unknown) => i is nicoScriptReplaceTarget;
|
|
843
|
-
condition: (i: unknown) => i is nicoScriptReplaceCondition;
|
|
844
|
-
};
|
|
845
|
-
};
|
|
846
|
-
comment: {
|
|
847
|
-
font: (i: unknown) => i is commentFont;
|
|
848
|
-
loc: (i: unknown) => i is commentLoc;
|
|
849
|
-
size: (i: unknown) => i is commentSize;
|
|
850
|
-
command: {
|
|
851
|
-
key: (i: unknown) => i is "full" | "ender" | "_live" | "invisible";
|
|
852
|
-
};
|
|
853
|
-
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";
|
|
854
|
-
colorCode: (i: unknown) => i is string;
|
|
855
|
-
};
|
|
856
|
-
config: {
|
|
857
|
-
initOptions: (item: unknown) => item is Partial<BaseOptions>;
|
|
858
|
-
};
|
|
859
|
-
};
|
|
860
|
-
|
|
861
1051
|
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
declare const getPosY: (currentPos: number, targetComment: IComment, collision: IComment[] | undefined) => {
|
|
868
|
-
currentPos: number;
|
|
869
|
-
isChanged: boolean;
|
|
870
|
-
isBreak: boolean;
|
|
871
|
-
};
|
|
872
|
-
declare const getPosX: (width: number, vpos: number, long: number) => number;
|
|
873
|
-
declare const parseFont: (font: commentFont, size: string | number) => string;
|
|
874
|
-
declare const arrayPush: (array: {
|
|
875
|
-
[key: number]: IComment[];
|
|
876
|
-
}, key: string | number, push: IComment) => void;
|
|
877
|
-
declare const hex2rgb: (hex: string) => number[];
|
|
878
|
-
declare const hex2rgba: (hex: string) => number[];
|
|
879
|
-
declare const changeCALayer: (rawData: formattedComment[]) => formattedComment[];
|
|
880
|
-
declare const getConfig: <T>(input: configItem<T>, isFlash?: boolean) => T;
|
|
881
|
-
declare const isFlashComment: (comment: formattedComment) => boolean;
|
|
882
|
-
declare const parseCommandAndNicoScript: (comment: formattedComment) => formattedCommentWithFont;
|
|
883
|
-
declare const getStrokeColor: (comment: formattedCommentWithSize) => string;
|
|
884
|
-
declare const ArrayEqual: (a: unknown[], b: unknown[]) => boolean;
|
|
885
|
-
declare const getFlashFontIndex: (part: string) => commentContentIndex[];
|
|
886
|
-
declare const getFlashFontName: (font: string) => commentFlashFont;
|
|
887
|
-
declare const getValue: <T>(value: T | null | undefined, alternative: T) => T;
|
|
888
|
-
declare const nativeSort: <T>(getter: (input: T) => number) => (a: T, b: T) => 0 | 1 | -1;
|
|
889
|
-
|
|
890
1052
|
|
|
891
1053
|
export default NiconiComments;
|