@selvajs/ui 5.0.0 → 6.0.0-beta.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 (49) hide show
  1. package/dist/components/compute/ComputeApp.svelte +15 -7
  2. package/dist/components/compute/ComputeApp.svelte.d.ts +1 -1
  3. package/dist/components/primitives/alert/alert.svelte.d.ts +8 -8
  4. package/dist/components/primitives/badge/badge.svelte.d.ts +14 -14
  5. package/dist/components/primitives/button/button.svelte.d.ts +41 -41
  6. package/dist/components/primitives/button-group/button-group.svelte.d.ts +8 -8
  7. package/dist/components/primitives/field/field.svelte.d.ts +5 -5
  8. package/dist/components/primitives/textarea/textarea.svelte +1 -2
  9. package/dist/components/viewer/SceneManager.svelte +75 -160
  10. package/dist/components/viewer/SceneManager.svelte.d.ts +8 -3
  11. package/dist/components/viewer/Viewer.svelte +20 -3
  12. package/dist/compute/useSolveSession.svelte.d.ts +12 -0
  13. package/dist/compute/useSolveSession.svelte.js +76 -0
  14. package/dist/external/storage.d.ts +1 -15
  15. package/dist/external/storage.js +4 -54
  16. package/dist/index.d.ts +4 -3
  17. package/dist/index.js +7 -4
  18. package/dist/public.d.ts +4 -3
  19. package/dist/public.js +9 -5
  20. package/package.json +17 -15
  21. package/src/lib/components/compute/ComputeApp.svelte +15 -7
  22. package/src/lib/components/primitives/textarea/textarea.svelte +1 -2
  23. package/src/lib/components/viewer/SceneManager.svelte +75 -160
  24. package/src/lib/components/viewer/Viewer.svelte +20 -3
  25. package/src/lib/compute/mesh-policy-wiring.test.ts +72 -0
  26. package/src/lib/compute/useSolveSession.svelte.ts +83 -0
  27. package/src/lib/external/storage.ts +12 -64
  28. package/src/lib/index.ts +15 -5
  29. package/src/lib/public.ts +17 -6
  30. package/dist/compute/computeThrottle.svelte.d.ts +0 -24
  31. package/dist/compute/computeThrottle.svelte.js +0 -82
  32. package/dist/compute/createSolveSession.svelte.d.ts +0 -66
  33. package/dist/compute/createSolveSession.svelte.js +0 -159
  34. package/dist/compute/solve-session-core.d.ts +0 -54
  35. package/dist/compute/solve-session-core.js +0 -87
  36. package/dist/compute/solveMemo.d.ts +0 -22
  37. package/dist/compute/solveMemo.js +0 -124
  38. package/dist/types/solveFn.d.ts +0 -25
  39. package/dist/types/solveFn.js +0 -1
  40. package/src/lib/compute/computeThrottle.svelte.ts +0 -109
  41. package/src/lib/compute/computeThrottle.test.ts +0 -106
  42. package/src/lib/compute/createSolveSession.svelte.ts +0 -239
  43. package/src/lib/compute/createSolveSession.test.ts +0 -168
  44. package/src/lib/compute/solve-session-core.test.ts +0 -153
  45. package/src/lib/compute/solve-session-core.ts +0 -122
  46. package/src/lib/compute/solveMemo.test.ts +0 -220
  47. package/src/lib/compute/solveMemo.ts +0 -140
  48. package/src/lib/external/storage.test.ts +0 -99
  49. package/src/lib/types/solveFn.ts +0 -29
@@ -1,99 +0,0 @@
1
- import { afterEach, describe, expect, it, vi } from 'vitest';
2
- import {
3
- getExternalInputs,
4
- writeExternalValue,
5
- readExternalValue,
6
- clearExternalValue
7
- } from './storage';
8
- import type { UISchema } from '@selvajs/schemas';
9
-
10
- // getExternalInputs is the gate the whole client-input feature hangs on: it decides
11
- // which inputs a producer route must fill. These pin the source.kind === 'client'
12
- // filter and the displayName fallback. The read/write helpers are also covered with a
13
- // sessionStorage stub, including the no-storage guard (SSR / node).
14
-
15
- const input = (paramId: string, opts: { displayName?: string; source?: { kind: string } } = {}) =>
16
- ({ type: 'input', paramId, ...opts }) as never;
17
-
18
- function schema(items: unknown[]): UISchema {
19
- return {
20
- layout: { type: 'flat', groups: [{ id: 'g', label: 'g', items }] }
21
- } as unknown as UISchema;
22
- }
23
-
24
- describe('getExternalInputs', () => {
25
- it('keeps only inputs with source.kind === client', () => {
26
- const s = schema([
27
- input('a', { source: { kind: 'client' } }),
28
- input('b', { source: { kind: 'user' } }),
29
- input('c') // no source
30
- ]);
31
- expect(getExternalInputs(s).map((e) => e.paramId)).toEqual(['a']);
32
- });
33
-
34
- it('falls back to paramId when displayName is absent', () => {
35
- const s = schema([input('a', { source: { kind: 'client' } })]);
36
- expect(getExternalInputs(s)[0].displayName).toBe('a');
37
- });
38
-
39
- it('uses displayName when present', () => {
40
- const s = schema([input('a', { displayName: 'Width', source: { kind: 'client' } })]);
41
- expect(getExternalInputs(s)[0].displayName).toBe('Width');
42
- });
43
- });
44
-
45
- describe('read/write/clear with a sessionStorage stub', () => {
46
- afterEach(() => {
47
- vi.unstubAllGlobals();
48
- });
49
-
50
- function stubStorage() {
51
- const store = new Map<string, string>();
52
- vi.stubGlobal('sessionStorage', {
53
- getItem: (k: string) => store.get(k) ?? null,
54
- setItem: (k: string, v: string) => store.set(k, v),
55
- removeItem: (k: string) => store.delete(k)
56
- });
57
- return store;
58
- }
59
-
60
- it('round-trips a value scoped by (scopeKey, inputId)', () => {
61
- const store = stubStorage();
62
- writeExternalValue({ scopeKey: 's1', inputId: 'p1', value: { x: 1 } });
63
- expect(readExternalValue({ scopeKey: 's1', inputId: 'p1' })).toEqual({ x: 1 });
64
- expect(store.has('external:s1:p1')).toBe(true);
65
- });
66
-
67
- it('scopes values so they do not bleed across scopeKey', () => {
68
- stubStorage();
69
- writeExternalValue({ scopeKey: 's1', inputId: 'p1', value: 'a' });
70
- expect(readExternalValue({ scopeKey: 's2', inputId: 'p1' })).toBeUndefined();
71
- });
72
-
73
- it('clear removes the value', () => {
74
- stubStorage();
75
- writeExternalValue({ scopeKey: 's1', inputId: 'p1', value: 'a' });
76
- clearExternalValue({ scopeKey: 's1', inputId: 'p1' });
77
- expect(readExternalValue({ scopeKey: 's1', inputId: 'p1' })).toBeUndefined();
78
- });
79
-
80
- it('returns undefined for malformed JSON', () => {
81
- const store = stubStorage();
82
- store.set('external:s1:p1', '{not json');
83
- expect(readExternalValue({ scopeKey: 's1', inputId: 'p1' })).toBeUndefined();
84
- });
85
- });
86
-
87
- describe('no-storage guard (SSR / node)', () => {
88
- it('read returns undefined and write/clear no-op when sessionStorage is absent', () => {
89
- // node env: sessionStorage is undefined by default
90
- expect(readExternalValue({ scopeKey: 's1', inputId: 'p1' })).toBeUndefined();
91
- expect(() => writeExternalValue({ scopeKey: 's1', inputId: 'p1', value: 1 })).not.toThrow();
92
- expect(() => clearExternalValue({ scopeKey: 's1', inputId: 'p1' })).not.toThrow();
93
- });
94
-
95
- it('ignores empty scopeKey or inputId', () => {
96
- expect(readExternalValue({ scopeKey: '', inputId: 'p1' })).toBeUndefined();
97
- expect(readExternalValue({ scopeKey: 's1', inputId: '' })).toBeUndefined();
98
- });
99
- });
@@ -1,29 +0,0 @@
1
- /**
2
- * Result returned from a solve operation.
3
- *
4
- * @property outputs - Key-value pairs of computed results
5
- * @property meshes - Optional array of 3D mesh data generated during computation
6
- * @property errors - Optional array of error messages that occurred
7
- * @property warnings - Optional array of warning messages from the computation
8
- */
9
- export interface SolveResult {
10
- outputs: Record<string, unknown>;
11
- meshes?: any[];
12
- errors?: string[];
13
- warnings?: string[];
14
- }
15
-
16
- /**
17
- * Function type for running a computation with given input values.
18
- *
19
- * Implementations should listen to the abort signal and clean up resources
20
- * when the signal is triggered (e.g., when the user cancels the operation).
21
- *
22
- * @param values - Input parameters for the computation
23
- * @param signal - AbortSignal to cancel ongoing operations
24
- * @returns Promise resolving to the computation result
25
- */
26
- export type SolveFn = (
27
- values: Record<string, unknown>,
28
- signal: AbortSignal
29
- ) => Promise<SolveResult>;