ssovee-os-web-ui 0.1.35 → 0.1.37

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/README.md CHANGED
@@ -75,7 +75,7 @@ const app = {
75
75
 
76
76
  export function NotesWindow() {
77
77
  return (
78
- <WindowWithoutSideMenu app={app} defaultSize={{ width: 420, height: 320 }}>
78
+ <WindowWithoutSideMenu app={app} defaultSize={ { width: 420, height: 320 } }>
79
79
  <Typography variant="h6">Notes</Typography>
80
80
  </WindowWithoutSideMenu>
81
81
  );
@@ -102,15 +102,15 @@ export function SettingsWindow() {
102
102
  return (
103
103
  <WindowWithSideMenu
104
104
  app={app}
105
- defaultSize={{ width: 720, height: 500 }}
106
- actionButtons={{ title: "Save", onClick: () => console.log("Saved") }}
107
- menu={{
105
+ defaultSize={ { width: 720, height: 500 } }
106
+ actionButtons={ { title: "Save", onClick: () => console.log("Saved") } }
107
+ menu={ {
108
108
  title: "Navigation",
109
109
  items: [
110
110
  { title: "Profile", icon: "👤", onClick: () => console.log("Profile"), isActive: true },
111
111
  { title: "Security", icon: "🔒", onClick: () => console.log("Security") },
112
112
  ],
113
- }}
113
+ } }
114
114
  >
115
115
  <Typography variant="h6">Settings</Typography>
116
116
  <Button variant="primary">Update</Button>
@@ -126,7 +126,7 @@ import { Skeleton } from "ssovee-os-web-ui";
126
126
 
127
127
  export function LoadingState() {
128
128
  return (
129
- <div style={{ display: "grid", gap: 12 }}>
129
+ <div style={ { display: "grid", gap: 12 } }>
130
130
  <Skeleton variant="text" lines={3} />
131
131
  <Skeleton variant="avatar" className="h-12 w-12" />
132
132
  <Skeleton variant="image" className="h-40" />
Binary file
Binary file
package/dist/index.cjs CHANGED
@@ -3240,17 +3240,51 @@ var useDeviceSupport = () => {
3240
3240
  }, []);
3241
3241
  return isSupported;
3242
3242
  };
3243
+
3244
+ // src/assets/sounds/click-tone.wav
3245
+ var click_tone_default = "./click-tone-GOELVSMY.wav";
3246
+
3247
+ // src/assets/sounds/error-tone.wav
3248
+ var error_tone_default = "./error-tone-YKNRLRXF.wav";
3249
+
3250
+ // src/assets/sounds/notification-tone.wav
3251
+ var notification_tone_default = "./notification-tone-7O3KFZG5.wav";
3252
+
3253
+ // src/assets/sounds/success-tone.wav
3254
+ var success_tone_default = "./success-tone-YKPPMCXK.wav";
3255
+
3256
+ // src/assets/sounds/swipe-tone.wav
3257
+ var swipe_tone_default = "./swipe-tone-UCF4T5MF.wav";
3258
+
3259
+ // src/hooks/useSound.tsx
3243
3260
  var soundMap = {
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
3261
+ click: click_tone_default,
3262
+ alert: error_tone_default,
3263
+ notification: notification_tone_default,
3264
+ error: error_tone_default,
3265
+ success: success_tone_default,
3266
+ swipe: swipe_tone_default
3267
+ };
3268
+ var fallbackToneMap = {
3269
+ click: { frequency: 900, durationMs: 70 },
3270
+ swipe: { frequency: 740, durationMs: 90 },
3271
+ success: { frequency: 660, durationMs: 140 },
3272
+ notification: { frequency: 580, durationMs: 130 },
3273
+ error: { frequency: 260, durationMs: 180 },
3274
+ alert: { frequency: 300, durationMs: 170 }
3250
3275
  };
3251
3276
  var pendingPlaybackQueue = [];
3252
3277
  var interactionListenersBound = false;
3253
3278
  var clampVolume = (value) => Math.min(1, Math.max(0, value));
3279
+ var getAssetUrl = (asset) => {
3280
+ if (typeof asset === "string") return asset;
3281
+ if (asset && typeof asset === "object") {
3282
+ const record = asset;
3283
+ const candidate = record.default ?? record.src ?? record.url ?? record.href;
3284
+ if (typeof candidate === "string") return candidate;
3285
+ }
3286
+ return "";
3287
+ };
3254
3288
  var resolveSoundSrc = (soundSrc) => {
3255
3289
  if (!soundSrc) return soundSrc;
3256
3290
  if (soundSrc.startsWith("http://") || soundSrc.startsWith("https://") || soundSrc.startsWith("data:") || soundSrc.startsWith("blob:")) {
@@ -3268,11 +3302,40 @@ var isAutoplayRestrictionError = (error) => {
3268
3302
  const message = maybeError.message?.toLowerCase() ?? "";
3269
3303
  return maybeError.name === "NotAllowedError" || message.includes("gesture") || message.includes("user");
3270
3304
  };
3305
+ var playFallbackTone = (type, volume) => {
3306
+ if (typeof window === "undefined") return false;
3307
+ const Ctx = window.AudioContext || window.webkitAudioContext;
3308
+ if (!Ctx) return false;
3309
+ try {
3310
+ const context = new Ctx();
3311
+ const oscillator = context.createOscillator();
3312
+ const gain = context.createGain();
3313
+ const { frequency, durationMs } = fallbackToneMap[type];
3314
+ oscillator.type = type === "error" || type === "alert" ? "square" : "sine";
3315
+ oscillator.frequency.value = frequency;
3316
+ const now = context.currentTime;
3317
+ const end = now + durationMs / 1e3;
3318
+ const safeVolume = Math.min(0.12, Math.max(0.01, volume * 0.08));
3319
+ gain.gain.setValueAtTime(1e-4, now);
3320
+ gain.gain.exponentialRampToValueAtTime(safeVolume, now + 0.01);
3321
+ gain.gain.exponentialRampToValueAtTime(1e-4, end);
3322
+ oscillator.connect(gain);
3323
+ gain.connect(context.destination);
3324
+ oscillator.start(now);
3325
+ oscillator.stop(end);
3326
+ oscillator.onended = () => {
3327
+ void context.close();
3328
+ };
3329
+ return true;
3330
+ } catch {
3331
+ return false;
3332
+ }
3333
+ };
3271
3334
  var playNativeAudio = async (type, options) => {
3272
3335
  if (typeof window === "undefined" || typeof window.Audio === "undefined") {
3273
3336
  return false;
3274
3337
  }
3275
- const soundSrc = soundMap[type];
3338
+ const soundSrc = getAssetUrl(soundMap[type]);
3276
3339
  const audio = new window.Audio(resolveSoundSrc(soundSrc));
3277
3340
  audio.preload = "auto";
3278
3341
  audio.volume = clampVolume(options?.volume ?? 1);
@@ -3283,10 +3346,14 @@ var playNativeAudio = async (type, options) => {
3283
3346
  await audio.play();
3284
3347
  return true;
3285
3348
  } catch (err) {
3286
- if (!isAutoplayRestrictionError(err)) {
3349
+ if (isAutoplayRestrictionError(err)) {
3350
+ return false;
3351
+ }
3352
+ const fallbackPlayed = playFallbackTone(type, clampVolume(options?.volume ?? 1));
3353
+ if (!fallbackPlayed) {
3287
3354
  console.error("Sound playback failed:", err);
3288
3355
  }
3289
- return false;
3356
+ return fallbackPlayed;
3290
3357
  }
3291
3358
  };
3292
3359
  var flushPendingQueue = () => {