@selvajs/ui 6.0.0-beta.8 → 6.0.0

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.
Files changed (94) hide show
  1. package/README.md +5 -7
  2. package/dist/components/compute/AppLayout.svelte +2 -8
  3. package/dist/components/compute/AppLayout.svelte.d.ts +0 -2
  4. package/dist/components/compute/ComputeApp.svelte +25 -43
  5. package/dist/components/compute/ComputeApp.svelte.d.ts +8 -24
  6. package/dist/components/compute/ParameterPresetManager.svelte +4 -9
  7. package/dist/components/compute/ParameterPresetManager.svelte.d.ts +1 -1
  8. package/dist/components/layout/AppShell.svelte +5 -13
  9. package/dist/components/layout/AppShell.svelte.d.ts +1 -2
  10. package/dist/components/layout/EmptyState.svelte +2 -3
  11. package/dist/components/layout/PageFooter.svelte +0 -4
  12. package/dist/components/layout/index.js +0 -1
  13. package/dist/components/preview/Group.svelte +2 -5
  14. package/dist/components/preview/ImageOutput.svelte +5 -4
  15. package/dist/components/preview/InputControl.svelte +27 -28
  16. package/dist/components/preview/InputControl.svelte.d.ts +3 -3
  17. package/dist/components/preview/OutputDisplay.svelte +3 -6
  18. package/dist/components/preview/TabLayout.svelte +3 -3
  19. package/dist/components/preview/inputs/FileInput.svelte +9 -12
  20. package/dist/components/primitives/field/field-error.svelte +1 -3
  21. package/dist/components/primitives/index.js +0 -1
  22. package/dist/components/viewer/SceneManager.svelte +9 -20
  23. package/dist/components/viewer/SceneManager.svelte.d.ts +3 -3
  24. package/dist/components/viewer/Viewer.svelte +36 -61
  25. package/dist/components/viewer/Viewer.svelte.d.ts +6 -19
  26. package/dist/composables/useFooterItem.svelte.d.ts +3 -4
  27. package/dist/composables/useFooterItem.svelte.js +3 -3
  28. package/dist/compute/solving.svelte.d.ts +6 -6
  29. package/dist/compute/solving.svelte.js +6 -6
  30. package/dist/compute/useSolveSession.svelte.d.ts +5 -7
  31. package/dist/compute/useSolveSession.svelte.js +11 -24
  32. package/dist/constants.js +4 -4
  33. package/dist/contexts/clientSlotContext.svelte.d.ts +3 -5
  34. package/dist/contexts/footerContext.svelte.d.ts +6 -8
  35. package/dist/external/storage.js +2 -3
  36. package/dist/i18n/localeContext.svelte.d.ts +5 -7
  37. package/dist/i18n/localeContext.svelte.js +8 -15
  38. package/dist/i18n/messages.d.ts +0 -2
  39. package/dist/i18n/messages.js +3 -8
  40. package/dist/index.js +7 -13
  41. package/dist/public.js +14 -30
  42. package/dist/schema/defaults.js +2 -3
  43. package/dist/schema/dynamic-value-list.js +13 -15
  44. package/dist/schema/param-exporter.d.ts +7 -14
  45. package/dist/schema/param-exporter.js +6 -12
  46. package/dist/schema/traversal.js +3 -4
  47. package/dist/schema/visibility-rules.d.ts +4 -8
  48. package/dist/schema/visibility-rules.js +4 -8
  49. package/dist/types/actionButton.d.ts +1 -25
  50. package/dist/types/presetLabels.d.ts +2 -3
  51. package/dist/utils/color.js +6 -9
  52. package/dist/utils/debounce.d.ts +1 -11
  53. package/dist/utils/debounce.js +1 -11
  54. package/dist/utils/loadScript.d.ts +2 -7
  55. package/dist/utils/loadScript.js +2 -7
  56. package/package.json +16 -16
  57. package/src/lib/components/compute/AppLayout.svelte +2 -8
  58. package/src/lib/components/compute/ComputeApp.svelte +25 -43
  59. package/src/lib/components/compute/ParameterPresetManager.svelte +4 -9
  60. package/src/lib/components/layout/AppShell.svelte +5 -13
  61. package/src/lib/components/layout/EmptyState.svelte +2 -3
  62. package/src/lib/components/layout/PageFooter.svelte +0 -4
  63. package/src/lib/components/layout/index.ts +0 -1
  64. package/src/lib/components/preview/Group.svelte +2 -5
  65. package/src/lib/components/preview/ImageOutput.svelte +5 -4
  66. package/src/lib/components/preview/InputControl.svelte +27 -28
  67. package/src/lib/components/preview/OutputDisplay.svelte +3 -6
  68. package/src/lib/components/preview/TabLayout.svelte +3 -3
  69. package/src/lib/components/preview/inputs/FileInput.svelte +9 -12
  70. package/src/lib/components/primitives/field/field-error.svelte +1 -3
  71. package/src/lib/components/primitives/index.ts +0 -2
  72. package/src/lib/components/viewer/SceneManager.svelte +9 -20
  73. package/src/lib/components/viewer/Viewer.svelte +36 -61
  74. package/src/lib/composables/useFooterItem.svelte.ts +3 -4
  75. package/src/lib/compute/solving.svelte.ts +6 -6
  76. package/src/lib/compute/useSolveSession.svelte.ts +11 -24
  77. package/src/lib/constants.ts +4 -4
  78. package/src/lib/contexts/clientSlotContext.svelte.ts +7 -12
  79. package/src/lib/contexts/footerContext.svelte.ts +6 -8
  80. package/src/lib/external/storage.ts +2 -3
  81. package/src/lib/i18n/localeContext.svelte.ts +8 -17
  82. package/src/lib/i18n/messages.ts +3 -10
  83. package/src/lib/index.ts +8 -13
  84. package/src/lib/public.ts +22 -40
  85. package/src/lib/schema/defaults.ts +2 -3
  86. package/src/lib/schema/dynamic-value-list.ts +13 -15
  87. package/src/lib/schema/param-exporter.ts +9 -16
  88. package/src/lib/schema/traversal.ts +3 -4
  89. package/src/lib/schema/visibility-rules.ts +4 -8
  90. package/src/lib/types/actionButton.ts +1 -25
  91. package/src/lib/types/presetLabels.ts +2 -3
  92. package/src/lib/utils/color.ts +6 -9
  93. package/src/lib/utils/debounce.ts +1 -11
  94. package/src/lib/utils/loadScript.ts +2 -7
@@ -1,32 +1,30 @@
1
- // Helper to convert hex to OKLCH
1
+ // Hex OKLCH. A non-null input that isn't a 6-digit hex comes back unchanged, so
2
+ // callers can pass through CSS colors this function doesn't understand; null gives ''.
2
3
  export const hexToOklch = (hex: string | null): string => {
3
4
  if (!hex) return '';
4
5
 
5
- // Normalize hex (remove # if present)
6
6
  const normalized = hex.replace(/^#/, '');
7
7
 
8
- // If it's not a valid hex color, return as-is
9
8
  if (!/^[0-9A-Fa-f]{6}$/.test(normalized)) {
10
9
  return hex;
11
10
  }
12
11
 
13
- // Parse hex to RGB
14
12
  const r = parseInt(normalized.slice(0, 2), 16) / 255;
15
13
  const g = parseInt(normalized.slice(2, 4), 16) / 255;
16
14
  const b = parseInt(normalized.slice(4, 6), 16) / 255;
17
15
 
18
- // Convert RGB to linear RGB
16
+ // sRGB transfer function, inverted: gamma-encoded channel → linear light.
19
17
  const toLinear = (c: number) => (c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4));
20
18
  const lr = toLinear(r);
21
19
  const lg = toLinear(g);
22
20
  const lb = toLinear(b);
23
21
 
24
- // Convert linear RGB to XYZ
22
+ // Linear sRGB CIE XYZ (D65 white point).
25
23
  const x = lr * 0.4124564 + lg * 0.3575761 + lb * 0.1804375;
26
24
  const y = lr * 0.2126729 + lg * 0.7151522 + lb * 0.072175;
27
25
  const z = lr * 0.0193339 + lg * 0.119192 + lb * 0.9503041;
28
26
 
29
- // Convert XYZ to OKLab
27
+ // XYZ OKLab: the M1 cone-response matrix, cube root, then the M2 matrix.
30
28
  const l_ = Math.cbrt(0.8189330101 * x + 0.3618667424 * y - 0.1288597137 * z);
31
29
  const m_ = Math.cbrt(0.0329845436 * x + 0.9293118715 * y + 0.0361456387 * z);
32
30
  const s_ = Math.cbrt(0.0482003018 * x + 0.2643662691 * y + 0.633851707 * z);
@@ -35,11 +33,10 @@ export const hexToOklch = (hex: string | null): string => {
35
33
  const a = 1.9779984951 * l_ - 2.428592205 * m_ + 0.4505937099 * s_;
36
34
  const b_lab = 0.0259040371 * l_ + 0.7827717662 * m_ - 0.808675766 * s_;
37
35
 
38
- // Convert to LCH
36
+ // OKLab OKLCH: chroma and hue as polar coordinates of (a, b).
39
37
  const C = Math.sqrt(a * a + b_lab * b_lab);
40
38
  let H = (Math.atan2(b_lab, a) * 180) / Math.PI;
41
39
  if (H < 0) H += 360;
42
40
 
43
- // Format as OKLCH (round to reasonable precision)
44
41
  return `oklch(${L.toFixed(3)} ${C.toFixed(3)} ${H.toFixed(1)})`;
45
42
  };
@@ -1,14 +1,4 @@
1
- /**
2
- * Debounce utility - delays function execution until after a specified wait time
3
- * has elapsed since the last time it was invoked.
4
- *
5
- * Use for text inputs, search boxes, etc. where you want to wait for the user
6
- * to finish typing before executing.
7
- *
8
- * @param func The function to debounce
9
- * @param wait The delay in milliseconds
10
- * @returns A debounced version of the function with a cancel method
11
- */
1
+ /** Runs `func` once `wait` ms have passed with no further calls. `cancel()` drops a pending call. */
12
2
  export function debounce<T extends (...args: any[]) => any>(
13
3
  func: T,
14
4
  wait: number
@@ -1,13 +1,8 @@
1
1
  const scriptLoaders = new Map<string, Promise<void>>();
2
2
 
3
3
  /**
4
- * Load an external script from a CDN with automatic deduplication.
5
- * All calls to load the same script will share a single promise,
6
- * preventing duplicate script tags and race conditions.
7
- *
8
- * @param src The script URL
9
- * @param options Script attributes (crossOrigin, async, etc.)
10
- * @returns Promise that resolves when script is loaded
4
+ * Appends a `<script>` for `src` and resolves on load. Concurrent calls for the same URL share
5
+ * one promise, so a script never gets a second tag. A failed load is evicted so a retry can run.
11
6
  */
12
7
  export function loadScript(
13
8
  src: string,