@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.mjs
CHANGED
|
@@ -2297,6 +2297,22 @@ function cn(...values) {
|
|
|
2297
2297
|
|
|
2298
2298
|
// src/audio/howl.ts
|
|
2299
2299
|
var import_howler = __toESM(require_howler());
|
|
2300
|
+
|
|
2301
|
+
// src/media-activation-event.ts
|
|
2302
|
+
function isMediaActivationEvent(event) {
|
|
2303
|
+
switch (event.type) {
|
|
2304
|
+
case "keydown":
|
|
2305
|
+
return event instanceof KeyboardEvent && event.key !== "Escape";
|
|
2306
|
+
case "pointerdown":
|
|
2307
|
+
return event instanceof PointerEvent && event.pointerType === "mouse";
|
|
2308
|
+
case "pointerup":
|
|
2309
|
+
return event instanceof PointerEvent && event.pointerType !== "mouse";
|
|
2310
|
+
default:
|
|
2311
|
+
return false;
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
// src/audio/howl.ts
|
|
2300
2316
|
import_howler.Howler.autoUnlock = true;
|
|
2301
2317
|
function resumePanoAudio() {
|
|
2302
2318
|
if (!import_howler.Howler.ctx || import_howler.Howler.ctx.state === "running") {
|
|
@@ -2304,6 +2320,9 @@ function resumePanoAudio() {
|
|
|
2304
2320
|
}
|
|
2305
2321
|
return import_howler.Howler.ctx.resume();
|
|
2306
2322
|
}
|
|
2323
|
+
function isPanoAudioUnlocked() {
|
|
2324
|
+
return !import_howler.Howler.ctx || import_howler.Howler.ctx.state === "running";
|
|
2325
|
+
}
|
|
2307
2326
|
function sourceList(src) {
|
|
2308
2327
|
if (src == null) {
|
|
2309
2328
|
return [];
|
|
@@ -2369,7 +2388,10 @@ function createUnlockingHowl({
|
|
|
2369
2388
|
blockedNotified = true;
|
|
2370
2389
|
onPlayError?.(error);
|
|
2371
2390
|
}
|
|
2372
|
-
const retry = () => {
|
|
2391
|
+
const retry = (event) => {
|
|
2392
|
+
if (!isMediaActivationEvent(event)) {
|
|
2393
|
+
return;
|
|
2394
|
+
}
|
|
2373
2395
|
removeUnlockListeners();
|
|
2374
2396
|
if (!disposed && isActive() && shouldRetryPlay()) {
|
|
2375
2397
|
void resumePanoAudio();
|
|
@@ -2378,8 +2400,10 @@ function createUnlockingHowl({
|
|
|
2378
2400
|
};
|
|
2379
2401
|
removeUnlockListeners();
|
|
2380
2402
|
unlockListeners.push({ type: "pointerdown", listener: retry });
|
|
2403
|
+
unlockListeners.push({ type: "pointerup", listener: retry });
|
|
2381
2404
|
unlockListeners.push({ type: "keydown", listener: retry });
|
|
2382
2405
|
window.addEventListener("pointerdown", retry, { capture: true });
|
|
2406
|
+
window.addEventListener("pointerup", retry, { capture: true });
|
|
2383
2407
|
window.addEventListener("keydown", retry, { capture: true });
|
|
2384
2408
|
}
|
|
2385
2409
|
});
|
|
@@ -7150,12 +7174,15 @@ var PanoViewer = forwardRef2(
|
|
|
7150
7174
|
}),
|
|
7151
7175
|
[bgmHost, videoHost]
|
|
7152
7176
|
);
|
|
7153
|
-
const
|
|
7154
|
-
setMediaActivated(true);
|
|
7177
|
+
const runMediaActivation = useCallback6(() => {
|
|
7155
7178
|
const resume = mediaActivationControls.resumeAudio();
|
|
7156
7179
|
mediaActivationOptions?.onActivate?.(mediaActivationControls);
|
|
7157
7180
|
return resume;
|
|
7158
7181
|
}, [mediaActivationControls, mediaActivationOptions]);
|
|
7182
|
+
const activateMedia = useCallback6(() => {
|
|
7183
|
+
setMediaActivated(true);
|
|
7184
|
+
return runMediaActivation();
|
|
7185
|
+
}, [runMediaActivation]);
|
|
7159
7186
|
const hasMediaActivationIntent = mediaActivationRevision >= 0 && hasPanoMediaActivationIntent(mediaActivationHost);
|
|
7160
7187
|
const shouldActivateMedia = mediaActivationOptions !== null && hasMediaActivationIntent && !mediaActivated;
|
|
7161
7188
|
useEffect13(() => {
|
|
@@ -7166,18 +7193,39 @@ var PanoViewer = forwardRef2(
|
|
|
7166
7193
|
void activateMedia();
|
|
7167
7194
|
return;
|
|
7168
7195
|
}
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
void activateMedia();
|
|
7172
|
-
};
|
|
7196
|
+
let cancelled = false;
|
|
7197
|
+
let activating = false;
|
|
7173
7198
|
const removeListeners = () => {
|
|
7174
7199
|
window.removeEventListener("pointerdown", handleGesture, true);
|
|
7200
|
+
window.removeEventListener("pointerup", handleGesture, true);
|
|
7175
7201
|
window.removeEventListener("keydown", handleGesture, true);
|
|
7176
7202
|
};
|
|
7203
|
+
const handleGesture = (event) => {
|
|
7204
|
+
if (!isMediaActivationEvent(event) || activating || cancelled) {
|
|
7205
|
+
return;
|
|
7206
|
+
}
|
|
7207
|
+
activating = true;
|
|
7208
|
+
try {
|
|
7209
|
+
const resume = runMediaActivation();
|
|
7210
|
+
void resume.then(() => {
|
|
7211
|
+
if (cancelled || !isPanoAudioUnlocked()) {
|
|
7212
|
+
return;
|
|
7213
|
+
}
|
|
7214
|
+
removeListeners();
|
|
7215
|
+
setMediaActivated(true);
|
|
7216
|
+
});
|
|
7217
|
+
} finally {
|
|
7218
|
+
activating = false;
|
|
7219
|
+
}
|
|
7220
|
+
};
|
|
7177
7221
|
window.addEventListener("pointerdown", handleGesture, { capture: true });
|
|
7222
|
+
window.addEventListener("pointerup", handleGesture, { capture: true });
|
|
7178
7223
|
window.addEventListener("keydown", handleGesture, { capture: true });
|
|
7179
|
-
return
|
|
7180
|
-
|
|
7224
|
+
return () => {
|
|
7225
|
+
cancelled = true;
|
|
7226
|
+
removeListeners();
|
|
7227
|
+
};
|
|
7228
|
+
}, [activateMedia, runMediaActivation, shouldActivateMedia]);
|
|
7181
7229
|
const fallbackViewRef = useRef13(DEFAULT_VIEW);
|
|
7182
7230
|
const normalizedMinFov = Math.max(1, Math.min(minFov, maxFov - 1));
|
|
7183
7231
|
const normalizedMaxFov = Math.min(
|