@xpadev-net/niconicomments 0.2.77 → 0.2.78

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
@@ -3280,7 +3280,8 @@ declare class CanvasRenderer implements IRenderer {
3280
3280
  private static readonly _MT_CACHE_MAX_SIZE;
3281
3281
  private static _mtCache;
3282
3282
  private readonly pooled;
3283
- constructor(canvas?: HTMLCanvasElement, video?: HTMLVideoElement, padding?: number);
3283
+ private readonly _onDestroy?;
3284
+ constructor(canvas?: HTMLCanvasElement, video?: HTMLVideoElement, padding?: number, onDestroy?: () => void);
3284
3285
  drawVideo(enableLegacyPip: boolean): void;
3285
3286
  getFont(): string;
3286
3287
  getFillStyle(): string | CanvasGradient | CanvasPattern;
package/dist/bundle.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- niconicomments.js v0.2.77
2
+ niconicomments.js v0.2.78
3
3
  (c) 2021 xpadev-net https://xpadev.net
4
4
  Released under the MIT License.
5
5
  */
@@ -148,7 +148,7 @@ Released under the MIT License.
148
148
  * @param video レンダリングするVideo(任意)
149
149
  */
150
150
  var CanvasRenderer = class CanvasRenderer {
151
- constructor(canvas, video, padding = 0) {
151
+ constructor(canvas, video, padding = 0, onDestroy) {
152
152
  _defineProperty(this, "rendererName", "CanvasRenderer");
153
153
  _defineProperty(this, "canvas", void 0);
154
154
  _defineProperty(this, "video", void 0);
@@ -157,7 +157,9 @@ Released under the MIT License.
157
157
  _defineProperty(this, "width", 0);
158
158
  _defineProperty(this, "height", 0);
159
159
  _defineProperty(this, "pooled", void 0);
160
+ _defineProperty(this, "_onDestroy", void 0);
160
161
  this.pooled = !canvas;
162
+ this._onDestroy = onDestroy;
161
163
  this.canvas = canvas !== null && canvas !== void 0 ? canvas : canvasPool.acquire();
162
164
  const context = this.canvas.getContext("2d");
163
165
  if (!context) throw new CanvasRenderingContext2DError();
@@ -283,6 +285,8 @@ Released under the MIT License.
283
285
  flush() {}
284
286
  invalidateImage(_image) {}
285
287
  destroy() {
288
+ var _this$_onDestroy;
289
+ (_this$_onDestroy = this._onDestroy) === null || _this$_onDestroy === void 0 || _this$_onDestroy.call(this);
286
290
  if (this.pooled) canvasPool.release(this.canvas);
287
291
  }
288
292
  };
@@ -5241,7 +5245,10 @@ void main() {
5241
5245
  };
5242
5246
  }
5243
5247
  getCanvas(padding = 0) {
5244
- return new CanvasRenderer(void 0, void 0, padding);
5248
+ const inner = new CanvasRenderer(void 0, void 0, padding, () => {
5249
+ this.invalidateImage(inner);
5250
+ });
5251
+ return inner;
5245
5252
  }
5246
5253
  clearRect(x, y, w, h) {
5247
5254
  this.gl.clearColor(0, 0, 0, 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpadev-net/niconicomments",
3
- "version": "0.2.77",
3
+ "version": "0.2.78",
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",