@xpadev-net/niconicomments 0.2.47 → 0.2.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.d.ts CHANGED
@@ -290,6 +290,63 @@ type BaseConfig = {
290
290
 
291
291
  export type Config = Partial<BaseConfig>;
292
292
 
293
+ export interface CommentEventBase {
294
+ type: CommentEventName;
295
+ timeStamp: number;
296
+ vpos: number;
297
+ }
298
+
299
+ export interface SeekDisableEvent extends CommentEventBase {
300
+ type: "seekDisable";
301
+ }
302
+
303
+ export type SeekDisableEventHandler = (event: SeekDisableEvent) => unknown;
304
+
305
+ export interface SeekEnableEvent extends CommentEventBase {
306
+ type: "seekEnable";
307
+ }
308
+ export type SeekEnableEventHandler = (event: SeekEnableEvent) => unknown;
309
+
310
+ export interface CommentDisableEvent extends CommentEventBase {
311
+ type: "commentDisable";
312
+ }
313
+ export type CommentDisableEventHandler = (
314
+ event: CommentDisableEvent
315
+ ) => unknown;
316
+
317
+ export interface CommentEnableEvent extends CommentEventBase {
318
+ type: "commentEnable";
319
+ }
320
+ export type CommentEnableEventHandler = (event: CommentEnableEvent) => unknown;
321
+
322
+ export interface JumpEvent extends CommentEventBase {
323
+ type: "jump";
324
+ to: string;
325
+ message?: string;
326
+ }
327
+ export type JumpEventHandler = (event: JumpEvent) => unknown;
328
+
329
+ export type CommentEventName =
330
+ | "seekDisable"
331
+ | "seekEnable"
332
+ | "commentDisable"
333
+ | "commentEnable"
334
+ | "jump";
335
+ export interface CommentEventHandlerMap {
336
+ seekDisable: SeekDisableEventHandler;
337
+ seekEnable: SeekEnableEventHandler;
338
+ commentDisable: CommentDisableEventHandler;
339
+ commentEnable: CommentEnableEventHandler;
340
+ jump: JumpEventHandler;
341
+ }
342
+ export interface CommentEventMap {
343
+ seekDisable: SeekDisableEvent;
344
+ seekEnable: SeekEnableEvent;
345
+ commentDisable: CommentDisableEvent;
346
+ commentEnable: CommentEnableEvent;
347
+ jump: JumpEvent;
348
+ }
349
+
293
350
  type platform =
294
351
  | "win7"
295
352
  | "win8_1"
@@ -373,27 +430,27 @@ export type ownerComment = {
373
430
  comment: string;
374
431
  };
375
432
 
376
- export type v1Thread = {
377
- id: string;
378
- fork: string;
379
- commentCount: number;
380
- comments: v1Comment[];
381
- };
382
- type v1Comment = {
383
- id: string;
384
- no: number;
385
- vposMs: number;
386
- body: string;
387
- commands: string[];
388
- userId: string;
389
- isPremium: boolean;
390
- score: number;
391
- postedAt: string;
392
- nicoruCount: number;
393
- nicoruId: undefined;
394
- source: string;
395
- isMyPost: boolean;
396
- };
433
+ export type v1Thread = {
434
+ id: string;
435
+ fork: string;
436
+ commentCount: number;
437
+ comments: v1Comment[];
438
+ };
439
+ type v1Comment = {
440
+ id: string;
441
+ no: number;
442
+ vposMs: number;
443
+ body: string;
444
+ commands: string[];
445
+ userId: string;
446
+ isPremium: boolean;
447
+ score: number;
448
+ postedAt: string;
449
+ nicoruCount: number;
450
+ nicoruId: undefined;
451
+ source: string;
452
+ isMyPost: boolean;
453
+ };
397
454
 
398
455
 
399
456
 
@@ -537,6 +594,18 @@ type nicoScript = {
537
594
  ban: nicoScriptBan[];
538
595
  default: nicoScriptDefault[];
539
596
  replace: nicoScriptReplace[];
597
+ seekDisable: nicoScriptSeekDisable[];
598
+ jump: nicoScriptJump[];
599
+ };
600
+ type nicoScriptSeekDisable = {
601
+ start: number;
602
+ end: number;
603
+ };
604
+ type nicoScriptJump = {
605
+ start: number;
606
+ end?: number;
607
+ to: string;
608
+ message?: string;
540
609
  };
541
610
  type nicoScriptReverse = {
542
611
  target: nicoScriptReverseTarget;
@@ -623,6 +692,14 @@ type measureInput = {
623
692
  charSize: number;
624
693
  lineCount: number;
625
694
  };
695
+
696
+ type valueOf<T> = T[keyof T];
697
+
698
+
699
+ declare const registerHandler: <K extends keyof CommentEventHandlerMap>(eventName: K, handler: CommentEventHandlerMap[K]) => void;
700
+ declare const removeHandler: <K extends keyof CommentEventHandlerMap>(eventName: K, handler: CommentEventHandlerMap[K]) => void;
701
+ declare const triggerHandler: (vpos: number, lastVpos: number) => void;
702
+
626
703
 
627
704
 
628
705
 
@@ -631,6 +708,7 @@ declare const convert2formattedComment: (data: unknown, type: inputFormatType) =
631
708
 
632
709
 
633
710
 
711
+
634
712
  declare class NiconiComments {
635
713
  enableLegacyPiP: boolean;
636
714
  showCollision: boolean;
@@ -701,6 +779,8 @@ declare class NiconiComments {
701
779
  private sortComment;
702
780
  addComments(...rawComments: formattedComment[]): void;
703
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;
704
784
  clear(): void;
705
785
  }
706
786
 
package/dist/bundle.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- niconicomments.js v0.2.47
2
+ niconicomments.js v0.2.48
3
3
  (c) 2021 xpadev-net https://xpadev.net
4
4
  Released under the MIT License.
5
5
  */
@@ -918,6 +918,8 @@
918
918
  default: [],
919
919
  replace: [],
920
920
  ban: [],
921
+ seekDisable: [],
922
+ jump: [],
921
923
  };
922
924
  var resetNicoScripts = function () {
923
925
  nicoScripts = {
@@ -925,6 +927,8 @@
925
927
  default: [],
926
928
  replace: [],
927
929
  ban: [],
930
+ seekDisable: [],
931
+ jump: [],
928
932
  };
929
933
  };
930
934
 
@@ -1088,107 +1092,8 @@
1088
1092
  };
1089
1093
  var parseCommandAndNicoScript = function (comment) {
1090
1094
  var isFlash = isFlashComment(comment);
1091
- var data = parseCommand(comment), string = comment.content, nicoscript = string.match(/^(?:@|\uff20)(\u30c7\u30d5\u30a9\u30eb\u30c8|\u7f6e\u63db|\u9006|\u30b3\u30e1\u30f3\u30c8\u7981\u6b62|\u30b7\u30fc\u30af\u7981\u6b62|\u30b8\u30e3\u30f3\u30d7)/);
1092
- if (nicoscript && comment.owner) {
1093
- var reverse = comment.content.match(/^(?:@|\uff20)\u9006(?:\s+)?(\u5168|\u30b3\u30e1|\u6295\u30b3\u30e1)?/);
1094
- var content = comment.content.split(""), result = [];
1095
- var quote = "", last_i = "", string_1 = "";
1096
- if (nicoscript[1] === "\u30c7\u30d5\u30a9\u30eb\u30c8") {
1097
- nicoScripts.default.unshift({
1098
- start: comment.vpos,
1099
- long: data.long === undefined ? undefined : Math.floor(data.long * 100),
1100
- color: data.color,
1101
- size: data.size,
1102
- font: data.font,
1103
- loc: data.loc,
1104
- });
1105
- }
1106
- else if (nicoscript[1] === "\u9006" &&
1107
- reverse &&
1108
- reverse[1] &&
1109
- typeGuard.nicoScript.range.target(reverse[1])) {
1110
- if (data.long === undefined) {
1111
- data.long = 30;
1112
- }
1113
- nicoScripts.reverse.unshift({
1114
- start: comment.vpos,
1115
- end: comment.vpos + data.long * 100,
1116
- target: reverse[1],
1117
- });
1118
- }
1119
- else if (nicoscript[1] === "\u30b3\u30e1\u30f3\u30c8\u7981\u6b62") {
1120
- if (data.long === undefined) {
1121
- data.long = 30;
1122
- }
1123
- nicoScripts.ban.unshift({
1124
- start: comment.vpos,
1125
- end: comment.vpos + data.long * 100,
1126
- });
1127
- }
1128
- else if (nicoscript[1] === "\u7f6e\u63db") {
1129
- for (var _i = 0, _a = content.slice(4); _i < _a.length; _i++) {
1130
- var i = _a[_i];
1131
- if (i.match(/["'\u300c]/) && quote === "") {
1132
- quote = i;
1133
- }
1134
- else if (i.match(/["']/) && quote === i && last_i !== "\\") {
1135
- result.push(string_1.replaceAll("\\n", "\n"));
1136
- quote = "";
1137
- string_1 = "";
1138
- }
1139
- else if (i.match(/\u300d/) && quote === "\u300c") {
1140
- result.push(string_1);
1141
- quote = "";
1142
- string_1 = "";
1143
- }
1144
- else if (quote === "" && i.match(/\s+/)) {
1145
- if (string_1) {
1146
- result.push(string_1);
1147
- string_1 = "";
1148
- }
1149
- }
1150
- else {
1151
- string_1 += i;
1152
- }
1153
- last_i = i;
1154
- }
1155
- result.push(string_1);
1156
- if (!(result[0] === undefined ||
1157
- (result[2] !== undefined &&
1158
- !typeGuard.nicoScript.replace.range(result[2])) ||
1159
- (result[3] !== undefined &&
1160
- !typeGuard.nicoScript.replace.target(result[3])) ||
1161
- (result[4] !== undefined &&
1162
- !typeGuard.nicoScript.replace.condition(result[4])))) {
1163
- nicoScripts.replace.unshift({
1164
- start: comment.vpos,
1165
- long: data.long === undefined ? undefined : Math.floor(data.long * 100),
1166
- keyword: result[0],
1167
- replace: result[1] || "",
1168
- range: result[2] || "\u5358",
1169
- target: result[3] || "\u30b3\u30e1",
1170
- condition: result[4] || "\u90e8\u5206\u4e00\u81f4",
1171
- color: data.color,
1172
- size: data.size,
1173
- font: data.font,
1174
- loc: data.loc,
1175
- no: comment.id,
1176
- });
1177
- nicoScripts.replace.sort(function (a, b) {
1178
- if (a.start < b.start)
1179
- return -1;
1180
- if (a.start > b.start)
1181
- return 1;
1182
- if (a.no < b.no)
1183
- return -1;
1184
- if (a.no > b.no)
1185
- return 1;
1186
- return 0;
1187
- });
1188
- }
1189
- }
1190
- data.invisible = true;
1191
- }
1095
+ var commands = parseCommand(comment);
1096
+ processNicoscript(comment, commands);
1192
1097
  var color = undefined, size = undefined, font = undefined, loc = undefined;
1193
1098
  for (var i = 0; i < nicoScripts.default.length; i++) {
1194
1099
  var item = nicoScripts.default[i];
@@ -1236,40 +1141,173 @@
1236
1141
  comment.content = item.replace;
1237
1142
  }
1238
1143
  if (item.loc) {
1239
- data.loc = item.loc;
1144
+ commands.loc = item.loc;
1240
1145
  }
1241
1146
  if (item.color) {
1242
- data.color = item.color;
1147
+ commands.color = item.color;
1243
1148
  }
1244
1149
  if (item.size) {
1245
- data.size = item.size;
1246
- data.fontSize = getConfig(config.fontSize, isFlash)[data.size].default;
1150
+ commands.size = item.size;
1151
+ commands.fontSize = getConfig(config.fontSize, isFlash)[commands.size].default;
1247
1152
  }
1248
1153
  if (item.font) {
1249
- data.font = item.font;
1154
+ commands.font = item.font;
1250
1155
  }
1251
1156
  }
1252
1157
  }
1253
- if (!data.loc) {
1254
- data.loc = loc || "naka";
1158
+ if (!commands.loc) {
1159
+ commands.loc = loc || "naka";
1255
1160
  }
1256
- if (!data.color) {
1257
- data.color = color || "#FFFFFF";
1161
+ if (!commands.color) {
1162
+ commands.color = color || "#FFFFFF";
1258
1163
  }
1259
- if (!data.size) {
1260
- data.size = size || "medium";
1261
- data.fontSize = getConfig(config.fontSize, isFlash)[data.size].default;
1164
+ if (!commands.size) {
1165
+ commands.size = size || "medium";
1166
+ commands.fontSize = getConfig(config.fontSize, isFlash)[commands.size].default;
1262
1167
  }
1263
- if (!data.font) {
1264
- data.font = font || "defont";
1168
+ if (!commands.font) {
1169
+ commands.font = font || "defont";
1265
1170
  }
1266
- if (!data.long) {
1267
- data.long = 300;
1171
+ if (!commands.long) {
1172
+ commands.long = 300;
1268
1173
  }
1269
1174
  else {
1270
- data.long = Math.floor(Number(data.long) * 100);
1175
+ commands.long = Math.floor(Number(commands.long) * 100);
1176
+ }
1177
+ return _assign(_assign(_assign(_assign({}, comment), { content: [], lineCount: 0, lineOffset: 0 }), commands), { flash: isFlash });
1178
+ };
1179
+ var processNicoscript = function (comment, commands) {
1180
+ var nicoscript = comment.content.match(/^(?:@|\uff20)(\u30c7\u30d5\u30a9\u30eb\u30c8|\u7f6e\u63db|\u9006|\u30b3\u30e1\u30f3\u30c8\u7981\u6b62|\u30b7\u30fc\u30af\u7981\u6b62|\u30b8\u30e3\u30f3\u30d7)(.*)/);
1181
+ if (!nicoscript || !comment.owner)
1182
+ return;
1183
+ commands.invisible = true;
1184
+ if (nicoscript[1] === "\u30c7\u30d5\u30a9\u30eb\u30c8") {
1185
+ nicoScripts.default.unshift({
1186
+ start: comment.vpos,
1187
+ long: commands.long === undefined
1188
+ ? undefined
1189
+ : Math.floor(commands.long * 100),
1190
+ color: commands.color,
1191
+ size: commands.size,
1192
+ font: commands.font,
1193
+ loc: commands.loc,
1194
+ });
1195
+ return;
1196
+ }
1197
+ if (nicoscript[1] === "\u9006") {
1198
+ var reverse = comment.content.match(/^(?:@|\uff20)\u9006(?:\s+)?(\u5168|\u30b3\u30e1|\u6295\u30b3\u30e1)?/);
1199
+ if (!reverse ||
1200
+ !reverse[1] ||
1201
+ !typeGuard.nicoScript.range.target(reverse[1]))
1202
+ return;
1203
+ if (commands.long === undefined) {
1204
+ commands.long = 30;
1205
+ }
1206
+ nicoScripts.reverse.unshift({
1207
+ start: comment.vpos,
1208
+ end: comment.vpos + commands.long * 100,
1209
+ target: reverse[1],
1210
+ });
1211
+ return;
1212
+ }
1213
+ if (nicoscript[1] === "\u30b3\u30e1\u30f3\u30c8\u7981\u6b62") {
1214
+ if (commands.long === undefined) {
1215
+ commands.long = 30;
1216
+ }
1217
+ nicoScripts.ban.unshift({
1218
+ start: comment.vpos,
1219
+ end: comment.vpos + commands.long * 100,
1220
+ });
1221
+ return;
1222
+ }
1223
+ if (nicoscript[1] === "\u30b7\u30fc\u30af\u7981\u6b62") {
1224
+ if (commands.long === undefined) {
1225
+ commands.long = 30;
1226
+ }
1227
+ nicoScripts.seekDisable.unshift({
1228
+ start: comment.vpos,
1229
+ end: comment.vpos + commands.long * 100,
1230
+ });
1231
+ return;
1232
+ }
1233
+ if (nicoscript[1] === "\u30b8\u30e3\u30f3\u30d7" && nicoscript[2]) {
1234
+ var to = nicoscript[2].match(/\s*((?:sm|so|nm|\uff53\uff4d|\uff53\uff4f|\uff4e\uff4d)?[1-9\uff11-\uff19][0-9\uff11-\uff19]*|#[0-9]+:[0-9]+(?:\.[0-9]+)?)\s+(.*)/);
1235
+ if (!to || !to[1])
1236
+ return;
1237
+ nicoScripts.jump.unshift({
1238
+ start: comment.vpos,
1239
+ end: commands.long === undefined ? undefined : commands.long * 100,
1240
+ to: to[1],
1241
+ message: to[2],
1242
+ });
1243
+ return;
1244
+ }
1245
+ if (nicoscript[1] === "\u7f6e\u63db") {
1246
+ var content = comment.content.split(""), result = [];
1247
+ var quote = "", last_i = "", string = "";
1248
+ for (var _i = 0, _a = content.slice(4); _i < _a.length; _i++) {
1249
+ var i = _a[_i];
1250
+ if (i.match(/["'\u300c]/) && quote === "") {
1251
+ quote = i;
1252
+ }
1253
+ else if (i.match(/["']/) && quote === i && last_i !== "\\") {
1254
+ result.push(string.replaceAll("\\n", "\n"));
1255
+ quote = "";
1256
+ string = "";
1257
+ }
1258
+ else if (i.match(/\u300d/) && quote === "\u300c") {
1259
+ result.push(string);
1260
+ quote = "";
1261
+ string = "";
1262
+ }
1263
+ else if (quote === "" && i.match(/\s+/)) {
1264
+ if (string) {
1265
+ result.push(string);
1266
+ string = "";
1267
+ }
1268
+ }
1269
+ else {
1270
+ string += i;
1271
+ }
1272
+ last_i = i;
1273
+ }
1274
+ result.push(string);
1275
+ if (result[0] === undefined ||
1276
+ (result[2] !== undefined &&
1277
+ !typeGuard.nicoScript.replace.range(result[2])) ||
1278
+ (result[3] !== undefined &&
1279
+ !typeGuard.nicoScript.replace.target(result[3])) ||
1280
+ (result[4] !== undefined &&
1281
+ !typeGuard.nicoScript.replace.condition(result[4])))
1282
+ return;
1283
+ nicoScripts.replace.unshift({
1284
+ start: comment.vpos,
1285
+ long: commands.long === undefined
1286
+ ? undefined
1287
+ : Math.floor(commands.long * 100),
1288
+ keyword: result[0],
1289
+ replace: result[1] || "",
1290
+ range: result[2] || "\u5358",
1291
+ target: result[3] || "\u30b3\u30e1",
1292
+ condition: result[4] || "\u90e8\u5206\u4e00\u81f4",
1293
+ color: commands.color,
1294
+ size: commands.size,
1295
+ font: commands.font,
1296
+ loc: commands.loc,
1297
+ no: comment.id,
1298
+ });
1299
+ nicoScripts.replace.sort(function (a, b) {
1300
+ if (a.start < b.start)
1301
+ return -1;
1302
+ if (a.start > b.start)
1303
+ return 1;
1304
+ if (a.no < b.no)
1305
+ return -1;
1306
+ if (a.no > b.no)
1307
+ return 1;
1308
+ return 0;
1309
+ });
1271
1310
  }
1272
- return _assign(_assign(_assign(_assign({}, comment), { content: [], lineCount: 0, lineOffset: 0 }), data), { flash: isFlash });
1273
1311
  };
1274
1312
  var parseCommand = function (comment) {
1275
1313
  var metadata = comment.mail, isFlash = isFlashComment(comment);
@@ -2336,6 +2374,106 @@
2336
2374
  plugins = input;
2337
2375
  };
2338
2376
 
2377
+ var handlerList = [];
2378
+ var handlerCounts = {
2379
+ seekDisable: 0,
2380
+ seekEnable: 0,
2381
+ commentDisable: 0,
2382
+ commentEnable: 0,
2383
+ jump: 0,
2384
+ };
2385
+ var registerHandler = function (eventName, handler) {
2386
+ handlerList.push({ eventName: eventName, handler: handler });
2387
+ updateEventHandlerCounts();
2388
+ };
2389
+ var removeHandler = function (eventName, handler) {
2390
+ handlerList = handlerList.filter(function (item) { return item.eventName !== eventName || item.handler !== handler; });
2391
+ updateEventHandlerCounts();
2392
+ };
2393
+ var updateEventHandlerCounts = function () {
2394
+ var _loop_1 = function (key_) {
2395
+ var key = key_;
2396
+ handlerCounts[key] = handlerList.filter(function (item) { return item.eventName === key; }).length;
2397
+ };
2398
+ for (var key_ in handlerCounts) {
2399
+ _loop_1(key_);
2400
+ }
2401
+ };
2402
+ var triggerHandler = function (vpos, lastVpos) {
2403
+ processCommentDisableScript(vpos, lastVpos);
2404
+ processSeekDisableScript(vpos, lastVpos);
2405
+ processJumpScript(vpos, lastVpos);
2406
+ };
2407
+ var processCommentDisableScript = function (vpos, lastVpos) {
2408
+ if (handlerCounts.commentDisable < 1 && handlerCounts.commentEnable < 1)
2409
+ return;
2410
+ for (var _i = 0, _a = nicoScripts.ban; _i < _a.length; _i++) {
2411
+ var range = _a[_i];
2412
+ var vposInRange = range.start < vpos && vpos < range.end, lastVposInRange = range.start < lastVpos && lastVpos < range.end;
2413
+ if (vposInRange && !lastVposInRange) {
2414
+ executeEvents("commentDisable", {
2415
+ type: "commentDisable",
2416
+ timeStamp: new Date().getTime(),
2417
+ vpos: vpos,
2418
+ });
2419
+ }
2420
+ else if (!vposInRange && lastVposInRange) {
2421
+ executeEvents("commentEnable", {
2422
+ type: "commentEnable",
2423
+ timeStamp: new Date().getTime(),
2424
+ vpos: vpos,
2425
+ });
2426
+ }
2427
+ }
2428
+ };
2429
+ var processSeekDisableScript = function (vpos, lastVpos) {
2430
+ if (handlerCounts.seekDisable < 1 && handlerCounts.seekEnable < 1)
2431
+ return;
2432
+ for (var _i = 0, _a = nicoScripts.seekDisable; _i < _a.length; _i++) {
2433
+ var range = _a[_i];
2434
+ var vposInRange = range.start < vpos && vpos < range.end, lastVposInRange = range.start < lastVpos && lastVpos < range.end;
2435
+ if (vposInRange && !lastVposInRange) {
2436
+ executeEvents("seekDisable", {
2437
+ type: "seekDisable",
2438
+ timeStamp: new Date().getTime(),
2439
+ vpos: vpos,
2440
+ });
2441
+ }
2442
+ else if (!vposInRange && lastVposInRange) {
2443
+ executeEvents("seekEnable", {
2444
+ type: "seekEnable",
2445
+ timeStamp: new Date().getTime(),
2446
+ vpos: vpos,
2447
+ });
2448
+ }
2449
+ }
2450
+ };
2451
+ var processJumpScript = function (vpos, lastVpos) {
2452
+ if (handlerCounts.jump < 1)
2453
+ return;
2454
+ for (var _i = 0, _a = nicoScripts.jump; _i < _a.length; _i++) {
2455
+ var range = _a[_i];
2456
+ var vposInRange = range.start < vpos && (!range.end || vpos < range.end), lastVposInRange = range.start < lastVpos && (!range.end || lastVpos < range.end);
2457
+ if (vposInRange && !lastVposInRange) {
2458
+ executeEvents("jump", {
2459
+ type: "jump",
2460
+ timeStamp: new Date().getTime(),
2461
+ vpos: vpos,
2462
+ to: range.to,
2463
+ message: range.message,
2464
+ });
2465
+ }
2466
+ }
2467
+ };
2468
+ var executeEvents = function (eventName, event) {
2469
+ for (var _i = 0, handlerList_1 = handlerList; _i < handlerList_1.length; _i++) {
2470
+ var item = handlerList_1[_i];
2471
+ if (eventName !== item.eventName)
2472
+ continue;
2473
+ item.handler(event);
2474
+ }
2475
+ };
2476
+
2339
2477
  var isDebug = false;
2340
2478
  var NiconiComments = (function () {
2341
2479
  function NiconiComments(canvas, data, initOptions) {
@@ -2645,6 +2783,7 @@
2645
2783
  var drawCanvasStart = performance.now();
2646
2784
  if (this.lastVpos === vpos && !forceRendering)
2647
2785
  return false;
2786
+ triggerHandler(vpos, this.lastVpos);
2648
2787
  var timelineRange = this.timeline[vpos];
2649
2788
  if (!forceRendering &&
2650
2789
  (timelineRange === null || timelineRange === void 0 ? void 0 : timelineRange.filter(function (item) { return item.loc === "naka"; }).length) === 0 &&
@@ -2719,6 +2858,12 @@
2719
2858
  logger("drawCanvas complete: ".concat(performance.now() - drawCanvasStart, "ms"));
2720
2859
  return true;
2721
2860
  };
2861
+ NiconiComments.prototype.addEventListener = function (eventName, handler) {
2862
+ registerHandler(eventName, handler);
2863
+ };
2864
+ NiconiComments.prototype.removeEventListener = function (eventName, handler) {
2865
+ removeHandler(eventName, handler);
2866
+ };
2722
2867
  NiconiComments.prototype.clear = function () {
2723
2868
  this.context.clearRect(0, 0, config.canvasWidth, config.canvasHeight);
2724
2869
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpadev-net/niconicomments",
3
- "version": "0.2.47",
3
+ "version": "0.2.48",
4
4
  "description": "NiconiComments is a comment drawing library that is somewhat compatible with the official Nico Nico Douga player.",
5
5
  "main": "dist/bundle.js",
6
6
  "types": "dist/bundle.d.ts",