@kubohiroya/turbowarp-camera-source 0.9.0 → 0.9.1

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/README.ja.md CHANGED
@@ -26,13 +26,13 @@ TurboWarp-Camera-Sourceは、MediaDevicesのカメラストリームを名前付
26
26
  次のURLをunsandboxed custom extensionとして読み込みます。
27
27
 
28
28
  ```text
29
- https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-source@0.9.0/dist/camera-source.js
29
+ https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-source@0.9.1/dist/camera-source.js
30
30
  ```
31
31
 
32
32
  npm hostでは次を使います。
33
33
 
34
34
  ```bash
35
- pnpm add @kubohiroya/turbowarp-camera-source@0.9.0
35
+ pnpm add @kubohiroya/turbowarp-camera-source@0.9.1
36
36
  ```
37
37
 
38
38
  ## Quick start
package/README.md CHANGED
@@ -30,13 +30,13 @@ or select separate cameras for separate roles.
30
30
  Load this URL as an unsandboxed custom extension:
31
31
 
32
32
  ```text
33
- https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-source@0.9.0/dist/camera-source.js
33
+ https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-source@0.9.1/dist/camera-source.js
34
34
  ```
35
35
 
36
36
  For npm hosts:
37
37
 
38
38
  ```bash
39
- pnpm add @kubohiroya/turbowarp-camera-source@0.9.0
39
+ pnpm add @kubohiroya/turbowarp-camera-source@0.9.1
40
40
  ```
41
41
 
42
42
  ## Quick Start
@@ -1103,16 +1103,12 @@
1103
1103
  this.lastCurrentTime = NaN;
1104
1104
  this.handleVideoFrame = () => {
1105
1105
  if (this.disposed) return;
1106
- this.dirty = true;
1107
- this.onFrame(this.syncMetrics());
1106
+ this.markChanged();
1108
1107
  this.scheduleFrame();
1109
1108
  };
1110
1109
  this.handleAnimationFrame = () => {
1111
1110
  if (this.disposed) return;
1112
- if (this.video.currentTime !== this.lastCurrentTime) {
1113
- this.dirty = true;
1114
- this.onFrame(this.syncMetrics());
1115
- }
1111
+ if (this.video.currentTime !== this.lastCurrentTime) this.markChanged();
1116
1112
  this.scheduleFrame();
1117
1113
  };
1118
1114
  this.video = video;
@@ -1169,6 +1165,31 @@
1169
1165
  this.rotationCenter[1] = height / 2;
1170
1166
  return true;
1171
1167
  }
1168
+ /**
1169
+ * Says a new frame arrived, to everything that has to hear it.
1170
+ *
1171
+ * Three separate listeners, and missing any one of them stops the picture
1172
+ * without stopping anything else:
1173
+ *
1174
+ * `dirty` is this skin's own note that the texture it holds is behind the
1175
+ * video. `getTexture` reads it.
1176
+ *
1177
+ * `emitWasAltered` is the renderer's. A renderer that redrew every frame
1178
+ * regardless would not need it, but this one skips the work when nothing
1179
+ * says it changed -- and a video is the one skin whose content changes
1180
+ * without anybody touching a drawable. Without this the preview updated
1181
+ * only when something else forced a redraw, so resizing the stage showed
1182
+ * the current frame and then it froze again. `draw` was still being called
1183
+ * thirty times a second; it was returning immediately every time.
1184
+ *
1185
+ * `onFrame` is the extension's, which asks the VM for a redraw and keeps
1186
+ * the drawable's size in step with the video's.
1187
+ */
1188
+ markChanged() {
1189
+ this.dirty = true;
1190
+ this.emitWasAltered();
1191
+ this.onFrame(this.syncMetrics());
1192
+ }
1172
1193
  scheduleFrame() {
1173
1194
  if (typeof this.video.requestVideoFrameCallback === "function") this.videoFrameCallbackId = this.video.requestVideoFrameCallback(this.handleVideoFrame);
1174
1195
  else if (typeof globalThis.requestAnimationFrame === "function") this.animationFrameId = globalThis.requestAnimationFrame(this.handleAnimationFrame);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-camera-source",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "author": "Hiroya Kubo <hiroya@cuc.ac.jp>",
5
5
  "description": "A TurboWarp capability extension for sharing one MediaDevices camera stream across extensions.",
6
6
  "type": "module",