ssovee-os-web-ui 0.1.34 → 0.1.36
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 +29 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -7
- package/dist/index.js.map +1 -1
- package/dist/sdk.cjs +29 -7
- package/dist/sdk.cjs.map +1 -1
- package/dist/sdk.d.cts +1 -1
- package/dist/sdk.d.ts +1 -1
- package/dist/sdk.js +28 -7
- package/dist/sdk.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
5
5
|
var react = require('@phosphor-icons/react');
|
|
6
6
|
var uaParserJs = require('ua-parser-js');
|
|
7
7
|
|
|
8
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
8
9
|
function _interopNamespace(e) {
|
|
9
10
|
if (e && e.__esModule) return e;
|
|
10
11
|
var n = Object.create(null);
|
|
@@ -3267,6 +3268,26 @@ var soundMap = {
|
|
|
3267
3268
|
var pendingPlaybackQueue = [];
|
|
3268
3269
|
var interactionListenersBound = false;
|
|
3269
3270
|
var clampVolume = (value) => Math.min(1, Math.max(0, value));
|
|
3271
|
+
var getAssetUrl = (asset) => {
|
|
3272
|
+
if (typeof asset === "string") return asset;
|
|
3273
|
+
if (asset && typeof asset === "object") {
|
|
3274
|
+
const record = asset;
|
|
3275
|
+
const candidate = record.default ?? record.src ?? record.url ?? record.href;
|
|
3276
|
+
if (typeof candidate === "string") return candidate;
|
|
3277
|
+
}
|
|
3278
|
+
return "";
|
|
3279
|
+
};
|
|
3280
|
+
var resolveSoundSrc = (soundSrc) => {
|
|
3281
|
+
if (!soundSrc) return soundSrc;
|
|
3282
|
+
if (soundSrc.startsWith("http://") || soundSrc.startsWith("https://") || soundSrc.startsWith("data:") || soundSrc.startsWith("blob:")) {
|
|
3283
|
+
return soundSrc;
|
|
3284
|
+
}
|
|
3285
|
+
try {
|
|
3286
|
+
return new URL(soundSrc, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).href;
|
|
3287
|
+
} catch {
|
|
3288
|
+
return soundSrc;
|
|
3289
|
+
}
|
|
3290
|
+
};
|
|
3270
3291
|
var isAutoplayRestrictionError = (error) => {
|
|
3271
3292
|
if (!error || typeof error !== "object") return false;
|
|
3272
3293
|
const maybeError = error;
|
|
@@ -3277,8 +3298,8 @@ var playNativeAudio = async (type, options) => {
|
|
|
3277
3298
|
if (typeof window === "undefined" || typeof window.Audio === "undefined") {
|
|
3278
3299
|
return false;
|
|
3279
3300
|
}
|
|
3280
|
-
const soundSrc = soundMap[type];
|
|
3281
|
-
const audio = new window.Audio(soundSrc);
|
|
3301
|
+
const soundSrc = getAssetUrl(soundMap[type]);
|
|
3302
|
+
const audio = new window.Audio(resolveSoundSrc(soundSrc));
|
|
3282
3303
|
audio.preload = "auto";
|
|
3283
3304
|
audio.volume = clampVolume(options?.volume ?? 1);
|
|
3284
3305
|
if (options?.restart !== false) {
|
|
@@ -3312,12 +3333,13 @@ var bindInteractionListeners = () => {
|
|
|
3312
3333
|
window.addEventListener("keydown", unlockAndFlush, { passive: true });
|
|
3313
3334
|
};
|
|
3314
3335
|
var useSound = () => {
|
|
3315
|
-
const playSound = React22.useCallback(
|
|
3336
|
+
const playSound = React22.useCallback((type, options) => {
|
|
3316
3337
|
bindInteractionListeners();
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3338
|
+
void playNativeAudio(type, options).then((played) => {
|
|
3339
|
+
if (!played) {
|
|
3340
|
+
pendingPlaybackQueue.push({ type, options });
|
|
3341
|
+
}
|
|
3342
|
+
});
|
|
3321
3343
|
}, []);
|
|
3322
3344
|
return { playSound };
|
|
3323
3345
|
};
|