@kubohiroya/turbowarp-camera-source 0.23.0 → 0.23.2

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
@@ -40,13 +40,13 @@ TurboWarp Camera Sourceは、MediaDevicesのカメラストリームを名前付
40
40
  次のURLをunsandboxed custom extensionとして読み込みます。
41
41
 
42
42
  ```text
43
- https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-source@0.23.0/dist/camera-source.js
43
+ https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-source@0.23.2/dist/camera-source.js
44
44
  ```
45
45
 
46
46
  npm hostでは次を使います。
47
47
 
48
48
  ```bash
49
- pnpm add @kubohiroya/turbowarp-camera-source@0.23.0
49
+ pnpm add @kubohiroya/turbowarp-camera-source@0.23.2
50
50
  ```
51
51
 
52
52
  ## 最初の使い方
package/README.md CHANGED
@@ -44,13 +44,13 @@ the original description when no translation is available. Translation does not
44
44
  Load this URL as an unsandboxed custom extension:
45
45
 
46
46
  ```text
47
- https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-source@0.23.0/dist/camera-source.js
47
+ https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-source@0.23.2/dist/camera-source.js
48
48
  ```
49
49
 
50
50
  For npm hosts:
51
51
 
52
52
  ```bash
53
- pnpm add @kubohiroya/turbowarp-camera-source@0.23.0
53
+ pnpm add @kubohiroya/turbowarp-camera-source@0.23.2
54
54
  ```
55
55
 
56
56
  ## Quick start
@@ -64,29 +64,37 @@ function createRuntimeControlsDock(options) {
64
64
  const root = document.createElement("div");
65
65
  root.setAttribute("data-runtime-controls-dock", "true");
66
66
  const style = document.createElement("style");
67
- style.textContent = `[data-runtime-controls-dock] {position:fixed;z-index:2147483000;display:flex;align-items:center;gap:4px;font:14px/1.4 sans-serif;color:#25354a;max-width:100vw;max-height:100vh}
67
+ const tokens = (dark) => `color-scheme:var(--color-scheme,${dark ? "dark" : "light"});--rdock-bg:var(--ui-modal-background,var(--ui-primary,${dark ? "#1f2633" : "#fff"}));--rdock-fg:var(--ui-modal-foreground,var(--text-primary,${dark ? "#e6edf5" : "#25354a"}));--rdock-border:var(--ui-black-transparent,${dark ? "#5c6b7d" : "#9aa8b8"});--rdock-divider:var(--ui-black-transparent,${dark ? "#3a4656" : "#d8e0ea"});--rdock-surface:var(--ui-secondary,${dark ? "#2a3342" : "#f5f8fc"});--rdock-hover:var(--ui-tertiary,${dark ? "#34435a" : "#dae5f4"});--rdock-input:var(--input-background,${dark ? "#2a3342" : "#f5f8fc"});--rdock-bar:var(--popover-background,${dark ? "#1f2633ef" : "#f5f8fcef"});--rdock-accent:var(--looks-secondary,var(--link-color,${dark ? "#7aa7ea" : "#2864bd"}));--rdock-selected:color-mix(in srgb,var(--rdock-accent) 18%,var(--rdock-bg));--rdock-shadow:${dark ? "#0008" : "#0003"}`;
68
+ const themed = "[data-runtime-controls-dock], [data-runtime-dock-settings], [data-runtime-dock-panel]";
69
+ style.textContent = `${themed} {${tokens(false)}}
70
+ @media (prefers-color-scheme: dark) {${themed} {${tokens(true)}}}
71
+ [data-runtime-controls-dock] {position:fixed;z-index:2147483000;display:flex;align-items:center;gap:4px;font:14px/1.4 sans-serif;color:var(--rdock-fg);max-width:100vw;max-height:100vh}
68
72
  [data-runtime-controls-dock][hidden], [data-runtime-controls-dock] [hidden] {display:none!important}
69
73
  [data-runtime-controls-dock] button, [data-runtime-controls-dock] select {font:inherit;color:inherit;cursor:pointer}
70
- [data-runtime-controls-dock] button:focus-visible, [data-runtime-controls-dock] select:focus-visible {outline:3px solid #2864bd;outline-offset:2px}
71
- [data-runtime-dock-bar] {display:flex;gap:6px;padding:8px;border:1px solid #9aa8b8;border-radius:14px;background:#f5f8fceF;box-shadow:0 3px 16px #0003;backdrop-filter:blur(16px);overflow:auto;max-width:calc(100vw - 16px);max-height:calc(100vh - 48px)}
74
+ [data-runtime-controls-dock] button:focus-visible, [data-runtime-controls-dock] select:focus-visible {outline:3px solid var(--rdock-accent);outline-offset:2px}
75
+ [data-runtime-dock-bar] {display:flex;gap:6px;padding:8px;border:1px solid var(--rdock-border);border-radius:14px;background:var(--rdock-bar);box-shadow:0 3px 16px var(--rdock-shadow);backdrop-filter:blur(16px);overflow:auto;max-width:calc(100vw - 16px);max-height:calc(100vh - 48px)}
72
76
  [data-runtime-dock-bar] button {min-width:48px;min-height:48px;padding:0 4px;border:1px solid transparent;border-radius:8px;background:transparent;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;font-size:12px}
73
- [data-runtime-dock-bar] button:hover {background:#dae5f4}
74
- [data-runtime-dock-bar] button[aria-expanded=true] {border-color:#2864bd;background:#e8effb}
77
+ [data-runtime-dock-bar] button:hover {background:var(--rdock-hover)}
78
+ [data-runtime-dock-bar] button[aria-expanded=true] {border-color:var(--rdock-accent);background:var(--rdock-selected)}
75
79
  [data-runtime-dock-icon] {font-size:24px;line-height:1}
76
- [data-runtime-dock-handle] {min-width:48px;min-height:28px;border:1px solid #9aa8b8;border-radius:8px;background:#f5f8fc;color:#25354a}
77
- [data-runtime-dock-settings] {position:fixed;z-index:2147483001;box-sizing:border-box;width:280px;max-width:calc(100vw - 24px);padding:16px;border:1px solid #9aa8b8;border-radius:12px;background:#fff;box-shadow:0 4px 16px #0003;display:flex;flex-direction:column;gap:12px}
78
- [data-runtime-dock-panel] {box-sizing:border-box;display:flex;flex-direction:column;width:min(28rem,calc(100vw - 24px));background:#fff;color:#25354a;border:1px solid #9aa8b8;border-radius:12px;box-shadow:0 4px 16px #0003;z-index:2147483001!important;font:14px/1.5 sans-serif;overflow:hidden!important}
80
+ [data-runtime-dock-handle] {min-width:48px;min-height:28px;border:1px solid var(--rdock-border);border-radius:8px;background:var(--rdock-surface);color:var(--rdock-fg)}
81
+ [data-runtime-dock-settings] {position:fixed;z-index:2147483001;box-sizing:border-box;width:280px;max-width:calc(100vw - 24px);padding:16px;border:1px solid var(--rdock-border);border-radius:12px;background:var(--rdock-bg);color:var(--rdock-fg);box-shadow:0 4px 16px var(--rdock-shadow);display:flex;flex-direction:column;gap:12px}
82
+ [data-runtime-dock-settings-header] {display:flex;align-items:center;justify-content:space-between;gap:12px}
83
+ [data-runtime-dock-panel] {box-sizing:border-box;display:flex;flex-direction:column;width:min(28rem,calc(100vw - 24px));background:var(--rdock-bg);color:var(--rdock-fg);border:1px solid var(--rdock-border);border-radius:12px;box-shadow:0 4px 16px var(--rdock-shadow);z-index:2147483001!important;font:14px/1.5 sans-serif;overflow:hidden!important}
79
84
  [data-runtime-dock-panel][hidden] {display:none!important}
80
- [data-runtime-dock-panel] > :first-child {display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 16px;border-bottom:1px solid #d8e0ea}
85
+ [data-runtime-dock-panel] > :first-child {display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 16px;border-bottom:1px solid var(--rdock-divider)}
81
86
  [data-runtime-dock-panel] > :nth-child(2) {overflow:auto;min-height:0;padding:0 16px}
82
- [data-runtime-dock-panel] > :last-child {padding:12px 16px;border-top:1px solid #d8e0ea}
87
+ [data-runtime-dock-panel] > :last-child {padding:12px 16px;border-top:1px solid var(--rdock-divider)}
83
88
  [data-runtime-dock-panel] h2 {font-size:18px;margin:0}
84
89
  [data-runtime-dock-panel] h3 {font-size:15px}
85
- [data-runtime-dock-panel] button {font:inherit;min-height:36px;padding:6px 10px;margin:3px;border:1px solid #9aa8b8;border-radius:6px;background:#f5f8fc;color:#25354a;cursor:pointer}
86
- [data-runtime-dock-panel] button[aria-checked=true] {border-color:#2864bd;box-shadow:inset 0 0 0 1px #2864bd;background:#e8effb}
87
- [data-runtime-dock-panel] button:focus-visible {outline:3px solid #2864bd;outline-offset:1px}
90
+ [data-runtime-dock-panel] button {font:inherit;min-height:36px;padding:6px 10px;margin:3px;border:1px solid var(--rdock-border);border-radius:6px;background:var(--rdock-surface);color:var(--rdock-fg);cursor:pointer}
91
+ [data-runtime-dock-panel] button:hover {background:var(--rdock-hover)}
92
+ [data-runtime-dock-panel] button[aria-checked=true] {border-color:var(--rdock-accent);box-shadow:inset 0 0 0 1px var(--rdock-accent);background:var(--rdock-selected)}
93
+ [data-runtime-dock-panel] button:focus-visible {outline:3px solid var(--rdock-accent);outline-offset:1px}
88
94
  [data-runtime-dock-settings] label {display:flex;align-items:center;justify-content:space-between;gap:12px}
89
- [data-runtime-dock-settings] select, [data-runtime-dock-settings] button {min-height:36px;padding:6px 10px;border:1px solid #9aa8b8;border-radius:6px;background:#f5f8fc}
95
+ [data-runtime-dock-settings] select {min-height:36px;padding:6px 10px;border:1px solid var(--rdock-border);border-radius:6px;background:var(--rdock-input);color:var(--rdock-fg)}
96
+ [data-runtime-dock-settings] button[data-runtime-dock-settings-close] {display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;width:28px;height:28px;min-height:0;padding:0;border:0;border-radius:6px;background:transparent;color:inherit}
97
+ [data-runtime-dock-settings] button[data-runtime-dock-settings-close]:hover {background:var(--rdock-hover)}
90
98
  `;
91
99
  const handle = document.createElement("button");
92
100
  handle.type = "button";
@@ -121,8 +129,28 @@ function createRuntimeControlsDock(options) {
121
129
  autoLabel.append(autoCheck);
122
130
  const close = document.createElement("button");
123
131
  close.type = "button";
124
- close.textContent = labels.close;
125
- settings.append(heading, edgeLabel, autoLabel, close);
132
+ close.setAttribute("data-runtime-dock-settings-close", "true");
133
+ close.setAttribute("aria-label", labels.close);
134
+ close.title = labels.close;
135
+ const svgNs = "http://www.w3.org/2000/svg";
136
+ const closeIcon = document.createElementNS(svgNs, "svg");
137
+ closeIcon.setAttribute("viewBox", "0 0 16 16");
138
+ closeIcon.setAttribute("width", "16");
139
+ closeIcon.setAttribute("height", "16");
140
+ closeIcon.setAttribute("aria-hidden", "true");
141
+ closeIcon.setAttribute("focusable", "false");
142
+ const closePath = document.createElementNS(svgNs, "path");
143
+ closePath.setAttribute("d", "M4 4l8 8M12 4l-8 8");
144
+ closePath.setAttribute("fill", "none");
145
+ closePath.setAttribute("stroke", "currentColor");
146
+ closePath.setAttribute("stroke-width", "1.6");
147
+ closePath.setAttribute("stroke-linecap", "round");
148
+ closeIcon.append(closePath);
149
+ close.append(closeIcon);
150
+ const settingsHeader = document.createElement("div");
151
+ settingsHeader.setAttribute("data-runtime-dock-settings-header", "true");
152
+ settingsHeader.append(heading, close);
153
+ settings.append(settingsHeader, edgeLabel, autoLabel);
126
154
  const gear = document.createElement("button");
127
155
  gear.type = "button";
128
156
  const gearIcon = document.createElement("span");
@@ -396,6 +424,47 @@ function getRuntimeControlsDock(options) {
396
424
  return dock;
397
425
  }
398
426
  /** A host adapter for packaged HTML, independent of the player's optional control bar. */
427
+ var host = "[data-camera-source-entry-host]";
428
+ /**
429
+ * Panel colors follow the host theme: TurboWarp publishes its resolved light/dark/auto palette as CSS
430
+ * custom properties on the root element; other hosts fall back to prefers-color-scheme defaults.
431
+ */
432
+ var cameraPanelStyle = `${host} {
433
+ --camera-panel-fallback-bg:#fff;--camera-panel-fallback-fg:#25354a;--camera-panel-fallback-border:#617184;
434
+ --camera-panel-fallback-input:#fff;--camera-panel-fallback-muted:#575e75;--camera-panel-fallback-accent:#4c97ff;
435
+ --camera-panel-fallback-shadow:#0004;--camera-panel-fallback-scheme:light;
436
+ --camera-panel-bg:var(--ui-modal-background, var(--ui-primary, var(--camera-panel-fallback-bg)));
437
+ --camera-panel-fg:var(--ui-modal-foreground, var(--text-primary, var(--camera-panel-fallback-fg)));
438
+ --camera-panel-border:var(--ui-black-transparent, var(--camera-panel-fallback-border));
439
+ --camera-panel-input:var(--input-background, var(--ui-secondary, var(--camera-panel-fallback-input)));
440
+ --camera-panel-button:var(--ui-tertiary, var(--camera-panel-input));
441
+ --camera-panel-muted:var(--text-primary, var(--camera-panel-fallback-muted));
442
+ --camera-panel-accent:var(--looks-secondary, var(--link-color, var(--camera-panel-fallback-accent)));
443
+ color-scheme:var(--color-scheme, var(--camera-panel-fallback-scheme));
444
+ color:var(--camera-panel-fg)}
445
+ @media (prefers-color-scheme: dark) {${host} {
446
+ --camera-panel-fallback-bg:#1e1e1e;--camera-panel-fallback-fg:#e6e6e6;--camera-panel-fallback-border:#5a5f6b;
447
+ --camera-panel-fallback-input:#2a2a2a;--camera-panel-fallback-muted:#b8bcc6;--camera-panel-fallback-accent:#7aa9ff;
448
+ --camera-panel-fallback-shadow:#000a;--camera-panel-fallback-scheme:dark}}
449
+ ${host} [data-camera-source-panel] {background:var(--camera-panel-bg);color:var(--camera-panel-fg);border:1px solid var(--camera-panel-border);box-shadow:0 4px 16px var(--camera-panel-fallback-shadow);color-scheme:inherit}
450
+ ${host} [data-camera-source-panel] > div:first-child {color:var(--camera-panel-fg)}
451
+ ${host} [data-camera-source-panel] > select {border:1px solid var(--camera-panel-border);background:var(--camera-panel-input);color:var(--camera-panel-fg)}
452
+ ${host} option {background:var(--camera-panel-input);color:var(--camera-panel-fg)}
453
+ ${host} [data-camera-source-settings] {display:flex;flex-direction:column;gap:12px}
454
+ ${host} [data-camera-source-settings] p {margin:0;color:var(--camera-panel-muted)}
455
+ ${host} [data-camera-source-settings] label {display:flex;flex-direction:column;gap:4px}
456
+ ${host} [data-camera-source-settings] select,
457
+ ${host} [data-camera-source-settings] input,
458
+ ${host} [data-camera-source-settings] button {min-height:36px;padding:6px 12px;border:1px solid var(--camera-panel-border);border-radius:6px;background:var(--camera-panel-input);color:var(--camera-panel-fg);font:inherit}
459
+ ${host} [data-camera-source-settings] button {background:var(--camera-panel-button);cursor:pointer}
460
+ ${host} [data-camera-source-settings] button[aria-pressed="true"] {border-color:var(--camera-panel-accent);box-shadow:inset 0 0 0 1px var(--camera-panel-accent)}
461
+ ${host} [data-camera-source-settings] button:hover:not(:disabled) {border-color:var(--camera-panel-accent)}
462
+ ${host} [data-camera-source-settings] [hidden] {display:none}
463
+ ${host} [data-camera-source-panel-close] {background:transparent;color:inherit}
464
+ ${host} [data-camera-source-panel-close]:hover {background:color-mix(in srgb, currentColor 12%, transparent)}
465
+ ${host} button:focus-visible,
466
+ ${host} select:focus-visible,
467
+ ${host} input:focus-visible {outline:2px solid var(--camera-panel-accent);outline-offset:1px}`;
399
468
  function createStandaloneCameraControlsHost(document, locale) {
400
469
  const ja = /^ja(?:-|$)/iu.test(locale);
401
470
  const label = ja ? "カメラ" : "Camera";
@@ -461,10 +530,7 @@ function createStandaloneCameraControlsHost(document, locale) {
461
530
  const buttonStyle = {
462
531
  minHeight: "36px",
463
532
  padding: "6px 12px",
464
- border: "1px solid #617184",
465
533
  borderRadius: "6px",
466
- background: "#fff",
467
- color: "#25354a",
468
534
  font: "inherit",
469
535
  cursor: "pointer"
470
536
  };
@@ -481,7 +547,6 @@ function createStandaloneCameraControlsHost(document, locale) {
481
547
  flexDirection: "column",
482
548
  alignItems: "flex-end",
483
549
  gap: "8px",
484
- color: "#25354a",
485
550
  font: "14px/1.5 sans-serif",
486
551
  maxWidth: "calc(100vw - 32px)"
487
552
  });
@@ -496,10 +561,7 @@ function createStandaloneCameraControlsHost(document, locale) {
496
561
  maxHeight: "calc(100vh - 96px)",
497
562
  overflowY: "auto",
498
563
  padding: "16px",
499
- border: "1px solid #617184",
500
- borderRadius: "8px",
501
- background: "#fff",
502
- boxShadow: "0 4px 16px #0004"
564
+ borderRadius: "8px"
503
565
  });
504
566
  const header = document.createElement("div");
505
567
  Object.assign(header.style, {
@@ -510,11 +572,39 @@ function createStandaloneCameraControlsHost(document, locale) {
510
572
  });
511
573
  const title = document.createElement("strong");
512
574
  title.textContent = label;
575
+ const dismissLabel = ja ? "閉じる" : "Close";
513
576
  const dismiss = document.createElement("button");
514
577
  dismiss.type = "button";
515
- dismiss.textContent = "×";
516
- dismiss.setAttribute("aria-label", ja ? "閉じる" : "Close");
517
- Object.assign(dismiss.style, buttonStyle);
578
+ dismiss.setAttribute("data-camera-source-panel-close", "");
579
+ dismiss.setAttribute("aria-label", dismissLabel);
580
+ dismiss.setAttribute("title", dismissLabel);
581
+ Object.assign(dismiss.style, {
582
+ display: "inline-flex",
583
+ alignItems: "center",
584
+ justifyContent: "center",
585
+ flex: "none",
586
+ width: "28px",
587
+ height: "28px",
588
+ padding: "0",
589
+ border: "none",
590
+ borderRadius: "4px",
591
+ cursor: "pointer"
592
+ });
593
+ const svgNs = "http://www.w3.org/2000/svg";
594
+ const icon = document.createElementNS(svgNs, "svg");
595
+ icon.setAttribute("viewBox", "0 0 16 16");
596
+ icon.setAttribute("width", "18");
597
+ icon.setAttribute("height", "18");
598
+ icon.setAttribute("aria-hidden", "true");
599
+ icon.setAttribute("focusable", "false");
600
+ const cross = document.createElementNS(svgNs, "path");
601
+ cross.setAttribute("d", "M4 4l8 8M12 4l-8 8");
602
+ cross.setAttribute("stroke", "currentColor");
603
+ cross.setAttribute("stroke-width", "1.6");
604
+ cross.setAttribute("stroke-linecap", "round");
605
+ cross.setAttribute("fill", "none");
606
+ icon.appendChild(cross);
607
+ dismiss.appendChild(icon);
518
608
  dismiss.addEventListener("click", () => close(true));
519
609
  header.append(title, dismiss);
520
610
  chooser = document.createElement("select");
@@ -547,12 +637,7 @@ function createStandaloneCameraControlsHost(document, locale) {
547
637
  if (open && root) dock.placePanel(root);
548
638
  });
549
639
  const style = document.createElement("style");
550
- style.textContent = `[data-camera-source-entry-host] [data-camera-source-settings] {display:flex;flex-direction:column;gap:12px}
551
- [data-camera-source-entry-host] [data-camera-source-settings] p {margin:0}
552
- [data-camera-source-entry-host] [data-camera-source-settings] label {display:flex;flex-direction:column;gap:4px}
553
- [data-camera-source-entry-host] [data-camera-source-settings] select,
554
- [data-camera-source-entry-host] [data-camera-source-settings] button {min-height:36px;padding:6px 12px;border:1px solid #617184;border-radius:6px;background:#fff;color:#25354a;font:inherit}
555
- [data-camera-source-entry-host] [data-camera-source-settings] [hidden] {display:none}`;
640
+ style.textContent = cameraPanelStyle;
556
641
  root.append(style, panel);
557
642
  (document.fullscreenElement || document.body).appendChild(root);
558
643
  document.addEventListener("keydown", onKey, true);
@@ -4264,18 +4349,32 @@ var CameraSourceExtension = class {
4264
4349
  this.storedProfileOutcomes = /* @__PURE__ */ new Map();
4265
4350
  this.storedProfilesGeneration = 0;
4266
4351
  this.removeFixedEditors = () => {};
4352
+ this.editorsReleased = false;
4267
4353
  this.dispose = () => {
4268
- this.removeFixedEditors();
4269
- this.removeSourceEditors();
4270
- this.stopAllCameras();
4354
+ Scratch.vm.runtime.off?.("RUNTIME_DISPOSED", this.handleRuntimeDisposed);
4355
+ Scratch.vm.runtime.off?.("PROJECT_LOADED", this.restoreEditors);
4356
+ this.editorsReleased = false;
4357
+ this.removeEditors();
4358
+ this.tearDown();
4359
+ };
4360
+ this.handleRuntimeDisposed = () => {
4361
+ this.removeEditors();
4362
+ this.editorsReleased = true;
4363
+ this.handleProjectBoundary();
4271
4364
  this.standaloneControls?.dispose();
4272
4365
  this.standaloneControls = null;
4273
- const runtime = Scratch.vm.runtime;
4274
- if (runtime["kubohiroyaCameraSourceCapability"] === this.capability) delete runtime[cameraSourceCapabilityKey];
4275
- this.profileChannel?.close();
4276
- Scratch.vm.runtime.off?.("PROJECT_STOP_ALL", this.handleProjectBoundary);
4277
- Scratch.vm.runtime.off?.("PROJECT_LOADED", this.handleProjectBoundary);
4278
- Scratch.vm.runtime.off?.("RUNTIME_DISPOSED", this.dispose);
4366
+ };
4367
+ this.restoreEditors = () => {
4368
+ if (!this.editorsReleased) return;
4369
+ this.editorsReleased = false;
4370
+ this.removeSourceEditors = registerSourceEditors(Scratch);
4371
+ try {
4372
+ this.removeFixedEditors = registerFixedInputEditors(Scratch, fixedInputEditors);
4373
+ } catch (error) {
4374
+ this.removeEditors();
4375
+ this.editorsReleased = true;
4376
+ throw error;
4377
+ }
4279
4378
  };
4280
4379
  this.handleProjectBoundary = () => {
4281
4380
  this.stopAllCameras();
@@ -4303,7 +4402,8 @@ var CameraSourceExtension = class {
4303
4402
  Scratch.vm.runtime[cameraSourceCapabilityKey] = this.capability;
4304
4403
  Scratch.vm.runtime.on?.("PROJECT_STOP_ALL", this.handleProjectBoundary);
4305
4404
  Scratch.vm.runtime.on?.("PROJECT_LOADED", this.handleProjectBoundary);
4306
- Scratch.vm.runtime.on?.("RUNTIME_DISPOSED", this.dispose);
4405
+ Scratch.vm.runtime.on?.("RUNTIME_DISPOSED", this.handleRuntimeDisposed);
4406
+ Scratch.vm.runtime.on?.("PROJECT_LOADED", this.restoreEditors);
4307
4407
  } catch (error) {
4308
4408
  this.dispose();
4309
4409
  throw error;
@@ -4479,6 +4579,20 @@ var CameraSourceExtension = class {
4479
4579
  this.blockLeases.clear();
4480
4580
  this.blockPreviewLeases.clear();
4481
4581
  }
4582
+ removeEditors() {
4583
+ this.removeFixedEditors();
4584
+ this.removeSourceEditors();
4585
+ }
4586
+ tearDown() {
4587
+ this.stopAllCameras();
4588
+ this.standaloneControls?.dispose();
4589
+ this.standaloneControls = null;
4590
+ const runtime = Scratch.vm.runtime;
4591
+ if (runtime["kubohiroyaCameraSourceCapability"] === this.capability) delete runtime[cameraSourceCapabilityKey];
4592
+ this.profileChannel?.close();
4593
+ Scratch.vm.runtime.off?.("PROJECT_STOP_ALL", this.handleProjectBoundary);
4594
+ Scratch.vm.runtime.off?.("PROJECT_LOADED", this.handleProjectBoundary);
4595
+ }
4482
4596
  registerCameraProfile(args = {}) {
4483
4597
  this.registerProfileText(args.PROFILE_JSON, (document) => document);
4484
4598
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-camera-source",
3
- "version": "0.23.0",
3
+ "version": "0.23.2",
4
4
  "author": {
5
5
  "name": "Hiroya Kubo",
6
6
  "email": "hiroya@cuc.ac.jp",
@@ -79,7 +79,7 @@
79
79
  "pages:build": "node scripts/prepare-pages.mjs"
80
80
  },
81
81
  "devDependencies": {
82
- "@kubohiroya/turbowarp-app-shell": "^0.6.0",
82
+ "@kubohiroya/turbowarp-app-shell": "^0.6.1",
83
83
  "@eslint/js": "^9.39.5",
84
84
  "@kubohiroya/turbowarp-extension-manifest": "^0.5.0",
85
85
  "@kubohiroya/vite-plugin-turbowarp-extension": "^0.11.0",