ssovee-os-web-ui 0.1.39 → 0.1.40
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 +47 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +46 -5
- package/dist/index.js.map +1 -1
- package/dist/sdk.cjs +47 -5
- 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 +46 -5
- 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);
|
|
@@ -3264,16 +3265,57 @@ var soundMap = {
|
|
|
3264
3265
|
success: success_tone_default,
|
|
3265
3266
|
swipe: swipe_tone_default
|
|
3266
3267
|
};
|
|
3268
|
+
var DEFAULT_SOUND_TYPE = "click";
|
|
3269
|
+
var getAssetUrl = (asset) => {
|
|
3270
|
+
if (typeof asset === "string") return asset;
|
|
3271
|
+
if (asset && typeof asset === "object") {
|
|
3272
|
+
const record = asset;
|
|
3273
|
+
const candidate = record.default ?? record.src ?? record.url ?? record.href;
|
|
3274
|
+
if (typeof candidate === "string") return candidate;
|
|
3275
|
+
}
|
|
3276
|
+
return "";
|
|
3277
|
+
};
|
|
3278
|
+
var resolveSoundCandidates = (src) => {
|
|
3279
|
+
if (!src) return [];
|
|
3280
|
+
const candidates = [src];
|
|
3281
|
+
if (!/^https?:|^data:|^blob:/.test(src)) {
|
|
3282
|
+
try {
|
|
3283
|
+
candidates.push(new URL(src, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).href);
|
|
3284
|
+
} catch {
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
return [...new Set(candidates)];
|
|
3288
|
+
};
|
|
3289
|
+
var isSoundType = (type) => {
|
|
3290
|
+
return type in soundMap;
|
|
3291
|
+
};
|
|
3267
3292
|
var useSound = () => {
|
|
3268
3293
|
const playSound = React22.useCallback((type) => {
|
|
3269
3294
|
if (typeof window === "undefined" || typeof window.Audio === "undefined") {
|
|
3270
3295
|
return;
|
|
3271
3296
|
}
|
|
3272
|
-
const
|
|
3273
|
-
const
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3297
|
+
const requestedType = isSoundType(type) ? type : DEFAULT_SOUND_TYPE;
|
|
3298
|
+
const soundSrc = getAssetUrl(soundMap[requestedType]);
|
|
3299
|
+
const sourceCandidates = resolveSoundCandidates(soundSrc);
|
|
3300
|
+
if (sourceCandidates.length === 0) {
|
|
3301
|
+
console.error(`Sound playback failed: no source found for "${requestedType}"`);
|
|
3302
|
+
return;
|
|
3303
|
+
}
|
|
3304
|
+
void (async () => {
|
|
3305
|
+
let lastError;
|
|
3306
|
+
for (const source of sourceCandidates) {
|
|
3307
|
+
try {
|
|
3308
|
+
const audio = new window.Audio(source);
|
|
3309
|
+
audio.preload = "auto";
|
|
3310
|
+
audio.currentTime = 0;
|
|
3311
|
+
await audio.play();
|
|
3312
|
+
return;
|
|
3313
|
+
} catch (err) {
|
|
3314
|
+
lastError = err;
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
console.error("Sound playback failed:", lastError);
|
|
3318
|
+
})();
|
|
3277
3319
|
}, []);
|
|
3278
3320
|
return { playSound };
|
|
3279
3321
|
};
|