@camera.ui/browser 0.0.181 → 0.0.182

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.
Files changed (2) hide show
  1. package/dist/index.js +26 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4134,6 +4134,8 @@ function isElementVisible(el) {
4134
4134
  }
4135
4135
  function useCameraStream(options) {
4136
4136
  const { activityConfig, autoStart: autoStartOption = true, isolated = false } = options;
4137
+ let effectiveIsolated = isolated;
4138
+ let conflictTimer;
4137
4139
  const shouldAutoStart = () => toValue(autoStartOption);
4138
4140
  const startDelay = options.startDelay ?? acquireAutoStaggerDelay();
4139
4141
  const cleanupFns = [];
@@ -4239,7 +4241,7 @@ function useCameraStream(options) {
4239
4241
  if (video.parentElement !== container) container.appendChild(video);
4240
4242
  }
4241
4243
  function reclaimSharedVideo() {
4242
- if (isolated) return;
4244
+ if (effectiveIsolated) return;
4243
4245
  const container = containerElement.value;
4244
4246
  const video = videoElement.value;
4245
4247
  if (!container || !video || video.parentElement === container) return;
@@ -4271,7 +4273,7 @@ function useCameraStream(options) {
4271
4273
  }
4272
4274
  function initialize() {
4273
4275
  if (initialized.value) return;
4274
- if (isolated) {
4276
+ if (effectiveIsolated) {
4275
4277
  initializeIsolated();
4276
4278
  return;
4277
4279
  }
@@ -4279,6 +4281,27 @@ function useCameraStream(options) {
4279
4281
  const camName = cameraName.value;
4280
4282
  const camDevice = resolvedCameraDevice.value;
4281
4283
  if (!container || !camName || !isConnected.value) return;
4284
+ const existing = streamManager.get(camName);
4285
+ if (existing && existing.refCount > 0) {
4286
+ const activeHost = existing.containerElementRef.value;
4287
+ if (activeHost && activeHost !== container && isElementVisible(activeHost)) {
4288
+ if (!conflictTimer) {
4289
+ conflictTimer = setTimeout(() => {
4290
+ conflictTimer = void 0;
4291
+ if (cleanedUp.value || initialized.value) return;
4292
+ const entry = streamManager.get(camName);
4293
+ const host = entry?.containerElementRef.value;
4294
+ if (entry && entry.refCount > 0 && host && host !== containerElement.value && isElementVisible(host)) effectiveIsolated = true;
4295
+ initialize();
4296
+ }, 200);
4297
+ cleanupFns.push(() => {
4298
+ if (conflictTimer) clearTimeout(conflictTimer);
4299
+ conflictTimer = void 0;
4300
+ });
4301
+ }
4302
+ return;
4303
+ }
4304
+ }
4282
4305
  const cached = streamManager.acquire(camName, containerElement);
4283
4306
  if (cached) {
4284
4307
  initialized.value = true;
@@ -4453,7 +4476,7 @@ function useCameraStream(options) {
4453
4476
  if (video) video.muted = true;
4454
4477
  for (const stopFn of cleanupFns) stopFn();
4455
4478
  cleanupFns.length = 0;
4456
- if (isolated) ownedConnection?.destroy();
4479
+ if (effectiveIsolated) ownedConnection?.destroy();
4457
4480
  else {
4458
4481
  const camName = registeredCamName;
4459
4482
  const video = videoElement.value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camera.ui/browser",
3
- "version": "0.0.181",
3
+ "version": "0.0.182",
4
4
  "description": "camera.ui browser client",
5
5
  "author": "seydx (https://github.com/cameraui/clients)",
6
6
  "type": "module",