@ericchen1990/pano-view 3.1.1 → 3.1.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/dist/index.cjs +57 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +57 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2352,6 +2352,22 @@ function cn(...values) {
|
|
|
2352
2352
|
|
|
2353
2353
|
// src/audio/howl.ts
|
|
2354
2354
|
var import_howler = __toESM(require_howler());
|
|
2355
|
+
|
|
2356
|
+
// src/media-activation-event.ts
|
|
2357
|
+
function isMediaActivationEvent(event) {
|
|
2358
|
+
switch (event.type) {
|
|
2359
|
+
case "keydown":
|
|
2360
|
+
return event instanceof KeyboardEvent && event.key !== "Escape";
|
|
2361
|
+
case "pointerdown":
|
|
2362
|
+
return event instanceof PointerEvent && event.pointerType === "mouse";
|
|
2363
|
+
case "pointerup":
|
|
2364
|
+
return event instanceof PointerEvent && event.pointerType !== "mouse";
|
|
2365
|
+
default:
|
|
2366
|
+
return false;
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2370
|
+
// src/audio/howl.ts
|
|
2355
2371
|
import_howler.Howler.autoUnlock = true;
|
|
2356
2372
|
function resumePanoAudio() {
|
|
2357
2373
|
if (!import_howler.Howler.ctx || import_howler.Howler.ctx.state === "running") {
|
|
@@ -2359,6 +2375,9 @@ function resumePanoAudio() {
|
|
|
2359
2375
|
}
|
|
2360
2376
|
return import_howler.Howler.ctx.resume();
|
|
2361
2377
|
}
|
|
2378
|
+
function isPanoAudioUnlocked() {
|
|
2379
|
+
return !import_howler.Howler.ctx || import_howler.Howler.ctx.state === "running";
|
|
2380
|
+
}
|
|
2362
2381
|
function sourceList(src) {
|
|
2363
2382
|
if (src == null) {
|
|
2364
2383
|
return [];
|
|
@@ -2424,7 +2443,10 @@ function createUnlockingHowl({
|
|
|
2424
2443
|
blockedNotified = true;
|
|
2425
2444
|
onPlayError?.(error);
|
|
2426
2445
|
}
|
|
2427
|
-
const retry = () => {
|
|
2446
|
+
const retry = (event) => {
|
|
2447
|
+
if (!isMediaActivationEvent(event)) {
|
|
2448
|
+
return;
|
|
2449
|
+
}
|
|
2428
2450
|
removeUnlockListeners();
|
|
2429
2451
|
if (!disposed && isActive() && shouldRetryPlay()) {
|
|
2430
2452
|
void resumePanoAudio();
|
|
@@ -2433,8 +2455,10 @@ function createUnlockingHowl({
|
|
|
2433
2455
|
};
|
|
2434
2456
|
removeUnlockListeners();
|
|
2435
2457
|
unlockListeners.push({ type: "pointerdown", listener: retry });
|
|
2458
|
+
unlockListeners.push({ type: "pointerup", listener: retry });
|
|
2436
2459
|
unlockListeners.push({ type: "keydown", listener: retry });
|
|
2437
2460
|
window.addEventListener("pointerdown", retry, { capture: true });
|
|
2461
|
+
window.addEventListener("pointerup", retry, { capture: true });
|
|
2438
2462
|
window.addEventListener("keydown", retry, { capture: true });
|
|
2439
2463
|
}
|
|
2440
2464
|
});
|
|
@@ -7165,12 +7189,15 @@ var PanoViewer = (0, import_react26.forwardRef)(
|
|
|
7165
7189
|
}),
|
|
7166
7190
|
[bgmHost, videoHost]
|
|
7167
7191
|
);
|
|
7168
|
-
const
|
|
7169
|
-
setMediaActivated(true);
|
|
7192
|
+
const runMediaActivation = (0, import_react26.useCallback)(() => {
|
|
7170
7193
|
const resume = mediaActivationControls.resumeAudio();
|
|
7171
7194
|
mediaActivationOptions?.onActivate?.(mediaActivationControls);
|
|
7172
7195
|
return resume;
|
|
7173
7196
|
}, [mediaActivationControls, mediaActivationOptions]);
|
|
7197
|
+
const activateMedia = (0, import_react26.useCallback)(() => {
|
|
7198
|
+
setMediaActivated(true);
|
|
7199
|
+
return runMediaActivation();
|
|
7200
|
+
}, [runMediaActivation]);
|
|
7174
7201
|
const hasMediaActivationIntent = mediaActivationRevision >= 0 && hasPanoMediaActivationIntent(mediaActivationHost);
|
|
7175
7202
|
const shouldActivateMedia = mediaActivationOptions !== null && hasMediaActivationIntent && !mediaActivated;
|
|
7176
7203
|
(0, import_react26.useEffect)(() => {
|
|
@@ -7181,18 +7208,39 @@ var PanoViewer = (0, import_react26.forwardRef)(
|
|
|
7181
7208
|
void activateMedia();
|
|
7182
7209
|
return;
|
|
7183
7210
|
}
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
void activateMedia();
|
|
7187
|
-
};
|
|
7211
|
+
let cancelled = false;
|
|
7212
|
+
let activating = false;
|
|
7188
7213
|
const removeListeners = () => {
|
|
7189
7214
|
window.removeEventListener("pointerdown", handleGesture, true);
|
|
7215
|
+
window.removeEventListener("pointerup", handleGesture, true);
|
|
7190
7216
|
window.removeEventListener("keydown", handleGesture, true);
|
|
7191
7217
|
};
|
|
7218
|
+
const handleGesture = (event) => {
|
|
7219
|
+
if (!isMediaActivationEvent(event) || activating || cancelled) {
|
|
7220
|
+
return;
|
|
7221
|
+
}
|
|
7222
|
+
activating = true;
|
|
7223
|
+
try {
|
|
7224
|
+
const resume = runMediaActivation();
|
|
7225
|
+
void resume.then(() => {
|
|
7226
|
+
if (cancelled || !isPanoAudioUnlocked()) {
|
|
7227
|
+
return;
|
|
7228
|
+
}
|
|
7229
|
+
removeListeners();
|
|
7230
|
+
setMediaActivated(true);
|
|
7231
|
+
});
|
|
7232
|
+
} finally {
|
|
7233
|
+
activating = false;
|
|
7234
|
+
}
|
|
7235
|
+
};
|
|
7192
7236
|
window.addEventListener("pointerdown", handleGesture, { capture: true });
|
|
7237
|
+
window.addEventListener("pointerup", handleGesture, { capture: true });
|
|
7193
7238
|
window.addEventListener("keydown", handleGesture, { capture: true });
|
|
7194
|
-
return
|
|
7195
|
-
|
|
7239
|
+
return () => {
|
|
7240
|
+
cancelled = true;
|
|
7241
|
+
removeListeners();
|
|
7242
|
+
};
|
|
7243
|
+
}, [activateMedia, runMediaActivation, shouldActivateMedia]);
|
|
7196
7244
|
const fallbackViewRef = (0, import_react26.useRef)(DEFAULT_VIEW);
|
|
7197
7245
|
const normalizedMinFov = Math.max(1, Math.min(minFov, maxFov - 1));
|
|
7198
7246
|
const normalizedMaxFov = Math.min(
|