@svadmin/core 0.20.0 → 0.20.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svadmin/core",
3
- "version": "0.20.0",
3
+ "version": "0.20.2",
4
4
  "author": "zuohuadong",
5
5
  "repository": {
6
6
  "type": "git",
@@ -183,7 +183,9 @@ export function getAgentProvider(): AgentProvider | null {
183
183
 
184
184
  // ─── Tool Approval ─────────────────────────────────────────────
185
185
 
186
- type ApprovalCallback = (approved: boolean) => void;
186
+ interface ApprovalCallback {
187
+ (approved: boolean): void;
188
+ }
187
189
  const pendingApprovals = new Map<string, ApprovalCallback>();
188
190
 
189
191
  /**
@@ -1,8 +1,8 @@
1
1
  // Minimal i18n — simple key-value translation
2
2
 
3
- type Locale = Record<string, string>;
4
3
 
5
- const locales: Record<string, Locale> = {
4
+
5
+ const locales: Record<string, Record<string, string>> = {
6
6
  'zh-CN': {
7
7
  // Common
8
8
  'common.save': '保存',
@@ -341,7 +341,12 @@ applyTheme(getStoredTheme());
341
341
  // Listen for system preference changes
342
342
  if (typeof window !== 'undefined') {
343
343
  window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
344
- if (mode === 'system') applyTheme('system');
344
+ if (mode === 'system') {
345
+ applyTheme('system');
346
+ // Re-apply color preset for new resolved mode (light/dark values differ)
347
+ const preset = builtinPresets[colorTheme];
348
+ if (preset) applyColorPreset(preset);
349
+ }
345
350
  });
346
351
  }
347
352
 
@@ -355,6 +360,9 @@ export function setTheme(newMode: ThemeMode): void {
355
360
  localStorage.setItem(STORAGE_KEY, newMode);
356
361
  }
357
362
  applyTheme(newMode);
363
+ // Re-apply color preset — light/dark CSS variable overrides differ
364
+ const preset = builtinPresets[colorTheme];
365
+ if (preset) applyColorPreset(preset);
358
366
  }
359
367
 
360
368
  export function toggleTheme(): void {
@@ -384,6 +392,10 @@ function applyColorTheme(ct: ColorTheme): void {
384
392
 
385
393
  // Apply on init
386
394
  applyColorTheme(getStoredColorTheme());
395
+ {
396
+ const initPreset = builtinPresets[getStoredColorTheme()];
397
+ if (initPreset) applyColorPreset(initPreset);
398
+ }
387
399
 
388
400
  export function getColorTheme(): ColorTheme {
389
401
  return colorTheme;
@@ -395,4 +407,7 @@ export function setColorTheme(ct: ColorTheme): void {
395
407
  localStorage.setItem(COLOR_STORAGE_KEY, ct);
396
408
  }
397
409
  applyColorTheme(ct);
410
+ // Apply the preset's CSS variable overrides for the current resolved theme
411
+ const preset = builtinPresets[ct];
412
+ if (preset) applyColorPreset(preset);
398
413
  }
@@ -19,7 +19,9 @@ export function getUnsavedChanges(): boolean {
19
19
  * Frameworks like SvelteKit can register a cancel function here.
20
20
  * Return `true` to allow navigation, `false` to block it.
21
21
  */
22
- type NavigationGuard = (opts: { cancel: () => void }) => void;
22
+ interface NavigationGuard {
23
+ (opts: { cancel: () => void }): void;
24
+ }
23
25
 
24
26
  let _navigationGuard: NavigationGuard | null = null;
25
27