ssovee-os-web-ui 0.1.34 → 0.1.35

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 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);
@@ -3239,34 +3240,28 @@ var useDeviceSupport = () => {
3239
3240
  }, []);
3240
3241
  return isSupported;
3241
3242
  };
3242
-
3243
- // src/assets/sounds/click-tone.wav
3244
- var click_tone_default = "./click-tone-GOELVSMY.wav";
3245
-
3246
- // src/assets/sounds/error-tone.wav
3247
- var error_tone_default = "./error-tone-YKNRLRXF.wav";
3248
-
3249
- // src/assets/sounds/notification-tone.wav
3250
- var notification_tone_default = "./notification-tone-7O3KFZG5.wav";
3251
-
3252
- // src/assets/sounds/success-tone.wav
3253
- var success_tone_default = "./success-tone-YKPPMCXK.wav";
3254
-
3255
- // src/assets/sounds/swipe-tone.wav
3256
- var swipe_tone_default = "./swipe-tone-UCF4T5MF.wav";
3257
-
3258
- // src/hooks/useSound.tsx
3259
3243
  var soundMap = {
3260
- click: click_tone_default,
3261
- alert: error_tone_default,
3262
- notification: notification_tone_default,
3263
- error: error_tone_default,
3264
- success: success_tone_default,
3265
- swipe: swipe_tone_default
3244
+ click: new URL("../assets/sounds/click-tone.wav", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).href,
3245
+ alert: new URL("../assets/sounds/error-tone.wav", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).href,
3246
+ notification: new URL("../assets/sounds/notification-tone.wav", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).href,
3247
+ error: new URL("../assets/sounds/error-tone.wav", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).href,
3248
+ success: new URL("../assets/sounds/success-tone.wav", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).href,
3249
+ swipe: new URL("../assets/sounds/swipe-tone.wav", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).href
3266
3250
  };
3267
3251
  var pendingPlaybackQueue = [];
3268
3252
  var interactionListenersBound = false;
3269
3253
  var clampVolume = (value) => Math.min(1, Math.max(0, value));
3254
+ var resolveSoundSrc = (soundSrc) => {
3255
+ if (!soundSrc) return soundSrc;
3256
+ if (soundSrc.startsWith("http://") || soundSrc.startsWith("https://") || soundSrc.startsWith("data:") || soundSrc.startsWith("blob:")) {
3257
+ return soundSrc;
3258
+ }
3259
+ try {
3260
+ 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;
3261
+ } catch {
3262
+ return soundSrc;
3263
+ }
3264
+ };
3270
3265
  var isAutoplayRestrictionError = (error) => {
3271
3266
  if (!error || typeof error !== "object") return false;
3272
3267
  const maybeError = error;
@@ -3278,7 +3273,7 @@ var playNativeAudio = async (type, options) => {
3278
3273
  return false;
3279
3274
  }
3280
3275
  const soundSrc = soundMap[type];
3281
- const audio = new window.Audio(soundSrc);
3276
+ const audio = new window.Audio(resolveSoundSrc(soundSrc));
3282
3277
  audio.preload = "auto";
3283
3278
  audio.volume = clampVolume(options?.volume ?? 1);
3284
3279
  if (options?.restart !== false) {
@@ -3312,12 +3307,13 @@ var bindInteractionListeners = () => {
3312
3307
  window.addEventListener("keydown", unlockAndFlush, { passive: true });
3313
3308
  };
3314
3309
  var useSound = () => {
3315
- const playSound = React22.useCallback(async (type, options) => {
3310
+ const playSound = React22.useCallback((type, options) => {
3316
3311
  bindInteractionListeners();
3317
- const played = await playNativeAudio(type, options);
3318
- if (played) return true;
3319
- pendingPlaybackQueue.push({ type, options });
3320
- return false;
3312
+ void playNativeAudio(type, options).then((played) => {
3313
+ if (!played) {
3314
+ pendingPlaybackQueue.push({ type, options });
3315
+ }
3316
+ });
3321
3317
  }, []);
3322
3318
  return { playSound };
3323
3319
  };