@epoch32/visage 1.3.0 → 1.3.1

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 (44) hide show
  1. package/dist/api/index.js +4 -4
  2. package/dist/charts/index.js +5 -5
  3. package/dist/devtools/index.js +7 -7
  4. package/dist/dom/index.js +3 -3
  5. package/dist/form/index.js +2 -2
  6. package/dist/{index-grhdtcb5.js → index-0qat98zs.js} +3 -3
  7. package/dist/{index-h6tjqk6e.js → index-1jcd8gjf.js} +28 -17
  8. package/dist/{index-6kfe1nr4.js → index-1yhbg34h.js} +41 -9
  9. package/dist/{index-9fvarkrx.js → index-3y73zgbk.js} +1 -1
  10. package/dist/{index-y9bq7h9g.js → index-5jhzwtdz.js} +2 -2
  11. package/dist/{index-a4xns6cc.js → index-65j7a9et.js} +1 -1
  12. package/dist/{index-dyvgtp43.js → index-9bez1tmf.js} +2 -2
  13. package/dist/{index-dvq5f3s8.js → index-aagpn02x.js} +4 -4
  14. package/dist/{index-df5e614s.js → index-awcrz19g.js} +1 -1
  15. package/dist/{index-8x8xz80v.js → index-b7emqmej.js} +3 -3
  16. package/dist/{index-061jf06a.js → index-cgepvvd4.js} +1 -1
  17. package/dist/{index-1xtrtz1t.js → index-dmhmde2z.js} +2 -2
  18. package/dist/{index-0madxn60.js → index-enc8cmea.js} +1 -1
  19. package/dist/{index-js199er4.js → index-g1drdx7k.js} +12 -1
  20. package/dist/{index-zr6cvset.js → index-ptj8rt6b.js} +5 -5
  21. package/dist/{index-8czhpea8.js → index-x6whpv54.js} +30 -19
  22. package/dist/{index-5s255b3w.js → index-xby428n5.js} +23 -22
  23. package/dist/{index-x2rs3vab.js → index-y3nprgn7.js} +1 -1
  24. package/dist/index.js +18 -18
  25. package/dist/jsx-runtime/index.js +4 -4
  26. package/dist/query/index.js +3 -3
  27. package/dist/router/index.js +5 -5
  28. package/dist/rpc/index.js +4 -4
  29. package/dist/server/index.js +2 -2
  30. package/dist/signals/index.js +1 -1
  31. package/dist/signals/system.d.ts +2 -0
  32. package/dist/style/index.js +6 -6
  33. package/dist/template/index.js +2 -2
  34. package/dist/ui/index.js +7 -7
  35. package/dist/virtual/index.js +5 -5
  36. package/package.json +1 -1
  37. package/src/dom/control-flow.ts +31 -21
  38. package/src/form/form.ts +29 -17
  39. package/src/signals/effect.ts +2 -2
  40. package/src/signals/scope.ts +10 -8
  41. package/src/signals/store.ts +32 -1
  42. package/src/signals/system.ts +8 -0
  43. package/src/template/template.ts +12 -1
  44. package/src/virtual/virtualizer.ts +31 -18
@@ -7,12 +7,13 @@ import {
7
7
  runInScope2,
8
8
  getActiveScope2,
9
9
  useContext2,
10
- effect2
11
- } from "./index-6kfe1nr4.js";
10
+ effect2,
11
+ signal2
12
+ } from "./index-1yhbg34h.js";
12
13
  import {
13
14
  SuspenseContext2,
14
15
  createResource2
15
- } from "./index-a4xns6cc.js";
16
+ } from "./index-65j7a9et.js";
16
17
 
17
18
  // src/dom/lazy.ts
18
19
  function lazy2(importer) {
@@ -176,26 +177,24 @@ function For2(props) {
176
177
  const newItems = [];
177
178
  const prevMap = new Map;
178
179
  for (const rec of items) {
179
- prevMap.set(rec.item, rec);
180
+ const group = prevMap.get(rec.item);
181
+ if (group) {
182
+ group.push(rec);
183
+ } else {
184
+ prevMap.set(rec.item, [rec]);
185
+ }
180
186
  }
181
187
  for (let i = 0;i < list.length; i++) {
182
188
  const item = list[i];
183
- const existing = prevMap.get(item);
189
+ const existingGroup = prevMap.get(item);
190
+ const existing = existingGroup && existingGroup.length > 0 ? existingGroup.shift() : undefined;
184
191
  if (existing) {
185
- existing.indexSignal(i);
192
+ untrack2(() => {
193
+ existing.indexSignal.set(i);
194
+ });
186
195
  newItems.push(existing);
187
- prevMap.delete(item);
188
196
  } else {
189
- let indexVal = i;
190
- const indexSubscribers = new Set;
191
- const indexSignal = (...args) => {
192
- if (args.length > 0 && args[0] !== undefined && args[0] !== indexVal) {
193
- indexVal = args[0];
194
- for (const sub of Array.from(indexSubscribers))
195
- sub();
196
- }
197
- return indexVal;
198
- };
197
+ const indexSignal = signal2(i, { internal: true });
199
198
  const itemScope = new Scope2(getActiveScope2());
200
199
  let itemNodes = [];
201
200
  untrack2(() => {
@@ -214,11 +213,13 @@ function For2(props) {
214
213
  });
215
214
  }
216
215
  }
217
- for (const [, removed] of prevMap) {
218
- removed.scope.dispose();
219
- for (const node of removed.nodes) {
220
- if (node.parentNode)
221
- node.parentNode.removeChild(node);
216
+ for (const [, remainingGroup] of prevMap) {
217
+ for (const removed of remainingGroup) {
218
+ removed.scope.dispose();
219
+ for (const node of removed.nodes) {
220
+ if (node.parentNode)
221
+ node.parentNode.removeChild(node);
222
+ }
222
223
  }
223
224
  }
224
225
  if (marker.parentNode) {
@@ -2,7 +2,7 @@ import {
2
2
  insertChild2,
3
3
  onCleanup2,
4
4
  createRoot2
5
- } from "./index-6kfe1nr4.js";
5
+ } from "./index-1yhbg34h.js";
6
6
 
7
7
  // src/server/hydrate.ts
8
8
  function hydrate2(fn, container) {
package/dist/index.js CHANGED
@@ -40,7 +40,7 @@ import {
40
40
  createStore2,
41
41
  mutateStore2,
42
42
  unwrapStore2
43
- } from "./index-6kfe1nr4.js";
43
+ } from "./index-1yhbg34h.js";
44
44
  import {
45
45
  createApiClient2,
46
46
  buildFileRouter2,
@@ -49,24 +49,24 @@ import {
49
49
  defineMiddleware2,
50
50
  ProcedureBuilder2,
51
51
  procedure2
52
- } from "./index-061jf06a.js";
52
+ } from "./index-cgepvvd4.js";
53
53
  import {
54
54
  lazy2,
55
55
  Show2,
56
56
  For2,
57
57
  Portal2
58
- } from "./index-5s255b3w.js";
59
- import"./index-9fvarkrx.js";
58
+ } from "./index-xby428n5.js";
59
+ import"./index-3y73zgbk.js";
60
60
  import {
61
61
  DevToolsHub2,
62
62
  devtoolsHub2,
63
63
  highlightElement2,
64
64
  VisageDevTools2,
65
65
  connectDevTools2
66
- } from "./index-zr6cvset.js";
66
+ } from "./index-ptj8rt6b.js";
67
67
  import {
68
68
  createForm2
69
- } from "./index-h6tjqk6e.js";
69
+ } from "./index-1jcd8gjf.js";
70
70
  import"./index-921pn75b.js";
71
71
  import {
72
72
  Router2,
@@ -77,7 +77,7 @@ import {
77
77
  useNavigate2,
78
78
  useParams2,
79
79
  useSearchParams2
80
- } from "./index-grhdtcb5.js";
80
+ } from "./index-0qat98zs.js";
81
81
  import {
82
82
  createClient2,
83
83
  RouterImpl2,
@@ -85,17 +85,17 @@ import {
85
85
  query3,
86
86
  mutation3,
87
87
  subscription3
88
- } from "./index-df5e614s.js";
88
+ } from "./index-awcrz19g.js";
89
89
  import {
90
90
  hydrate2,
91
91
  renderChildToString2,
92
92
  renderToString2,
93
93
  renderToStream2
94
- } from "./index-x2rs3vab.js";
94
+ } from "./index-y3nprgn7.js";
95
95
  import {
96
96
  template2,
97
97
  html2
98
- } from "./index-js199er4.js";
98
+ } from "./index-g1drdx7k.js";
99
99
  import {
100
100
  useAccordionContext2,
101
101
  useAccordionItemContext2,
@@ -152,12 +152,12 @@ import {
152
152
  ToastDescription2,
153
153
  ToastClose2,
154
154
  Toast2
155
- } from "./index-dvq5f3s8.js";
155
+ } from "./index-aagpn02x.js";
156
156
  import {
157
157
  createVirtualizer2,
158
158
  VirtualList2,
159
159
  VirtualGrid2
160
- } from "./index-8czhpea8.js";
160
+ } from "./index-x6whpv54.js";
161
161
  import {
162
162
  ChartContext2,
163
163
  useChartContext2,
@@ -179,7 +179,7 @@ import {
179
179
  Line2,
180
180
  Pie2,
181
181
  ChartTooltip2
182
- } from "./index-dyvgtp43.js";
182
+ } from "./index-9bez1tmf.js";
183
183
  import {
184
184
  createId2,
185
185
  createControllableSignal2,
@@ -198,7 +198,7 @@ import {
198
198
  Tooltip3,
199
199
  SwitchThumb2,
200
200
  Switch2
201
- } from "./index-8x8xz80v.js";
201
+ } from "./index-b7emqmej.js";
202
202
  import {
203
203
  ERROR_CODE_TO_STATUS2,
204
204
  STATUS_TO_ERROR_CODE2,
@@ -228,7 +228,7 @@ import {
228
228
  createMutation2,
229
229
  createQuery2,
230
230
  createInfiniteQuery2
231
- } from "./index-y9bq7h9g.js";
231
+ } from "./index-5jhzwtdz.js";
232
232
  import {
233
233
  hashString2,
234
234
  getScopeId2,
@@ -241,19 +241,19 @@ import {
241
241
  css2,
242
242
  useStyle2,
243
243
  Style2
244
- } from "./index-0madxn60.js";
244
+ } from "./index-enc8cmea.js";
245
245
  import {
246
246
  Stack2,
247
247
  Row2,
248
248
  Center2,
249
249
  Grid2,
250
250
  Spacer2
251
- } from "./index-1xtrtz1t.js";
251
+ } from "./index-dmhmde2z.js";
252
252
  import {
253
253
  createResource2,
254
254
  Suspense2,
255
255
  ErrorBoundary2
256
- } from "./index-a4xns6cc.js";
256
+ } from "./index-65j7a9et.js";
257
257
  export {
258
258
  Accordion2 as Accordion,
259
259
  AccordionContent2 as AccordionContent,
@@ -3,10 +3,10 @@ import {
3
3
  jsx2,
4
4
  jsxs2,
5
5
  jsxDEV2
6
- } from "../index-9fvarkrx.js";
7
- import"../index-5s255b3w.js";
8
- import"../index-a4xns6cc.js";
9
- import"../index-6kfe1nr4.js";
6
+ } from "../index-3y73zgbk.js";
7
+ import"../index-xby428n5.js";
8
+ import"../index-65j7a9et.js";
9
+ import"../index-1yhbg34h.js";
10
10
  export {
11
11
  Fragment2 as Fragment,
12
12
  jsx2 as jsx,
@@ -21,9 +21,9 @@ import {
21
21
  createMutation2,
22
22
  createQuery2,
23
23
  createInfiniteQuery2
24
- } from "../index-y9bq7h9g.js";
25
- import"../index-a4xns6cc.js";
26
- import"../index-6kfe1nr4.js";
24
+ } from "../index-5jhzwtdz.js";
25
+ import"../index-65j7a9et.js";
26
+ import"../index-1yhbg34h.js";
27
27
  export {
28
28
  FocusManager2 as FocusManager,
29
29
  Mutation2 as Mutation,
@@ -7,13 +7,13 @@ import {
7
7
  useNavigate2,
8
8
  useParams2,
9
9
  useSearchParams2
10
- } from "../index-grhdtcb5.js";
11
- import"../index-9fvarkrx.js";
10
+ } from "../index-0qat98zs.js";
11
+ import"../index-3y73zgbk.js";
12
12
  import {
13
13
  lazy2
14
- } from "../index-5s255b3w.js";
15
- import"../index-a4xns6cc.js";
16
- import"../index-6kfe1nr4.js";
14
+ } from "../index-xby428n5.js";
15
+ import"../index-65j7a9et.js";
16
+ import"../index-1yhbg34h.js";
17
17
  export {
18
18
  Link2 as Link,
19
19
  Route2 as Route,
package/dist/rpc/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  query3,
6
6
  mutation3,
7
7
  subscription3
8
- } from "../index-df5e614s.js";
8
+ } from "../index-awcrz19g.js";
9
9
  import {
10
10
  ERROR_CODE_TO_STATUS2,
11
11
  STATUS_TO_ERROR_CODE2,
@@ -19,9 +19,9 @@ import {
19
19
  validateWithSchema2,
20
20
  v2
21
21
  } from "../index-2zz0g2n2.js";
22
- import"../index-y9bq7h9g.js";
23
- import"../index-a4xns6cc.js";
24
- import"../index-6kfe1nr4.js";
22
+ import"../index-5jhzwtdz.js";
23
+ import"../index-65j7a9et.js";
24
+ import"../index-1yhbg34h.js";
25
25
  export {
26
26
  ERROR_CODE_TO_STATUS2 as ERROR_CODE_TO_STATUS,
27
27
  RPCError2 as RPCError,
@@ -3,8 +3,8 @@ import {
3
3
  renderChildToString2,
4
4
  renderToString2,
5
5
  renderToStream2
6
- } from "../index-x2rs3vab.js";
7
- import"../index-6kfe1nr4.js";
6
+ } from "../index-y3nprgn7.js";
7
+ import"../index-1yhbg34h.js";
8
8
  export {
9
9
  hydrate2 as hydrate,
10
10
  renderChildToString2 as renderChildToString,
@@ -24,7 +24,7 @@ import {
24
24
  createStore2,
25
25
  mutateStore2,
26
26
  unwrapStore2
27
- } from "../index-6kfe1nr4.js";
27
+ } from "../index-1yhbg34h.js";
28
28
  export {
29
29
  COMPUTED_BRAND2 as COMPUTED_BRAND,
30
30
  Computed2 as Computed,
@@ -14,6 +14,8 @@ export declare function setCurrentScope(scope: any): void;
14
14
  export declare function getCurrentScope(): any;
15
15
  export declare function addPendingEffect(eff: any): void;
16
16
  export declare function removePendingEffect(eff: any): void;
17
+ export declare function getBatchDepth(): number;
18
+ export declare function getIsFlushing(): boolean;
17
19
  export declare function flushEffects(): void;
18
20
  /**
19
21
  * Batch multiple signal mutations so downstreams and effects update synchronously once at completion.
@@ -16,9 +16,9 @@ import {
16
16
  radius2,
17
17
  glass2,
18
18
  formatStyleProp2
19
- } from "../index-6kfe1nr4.js";
20
- import"../index-5s255b3w.js";
21
- import"../index-9fvarkrx.js";
19
+ } from "../index-1yhbg34h.js";
20
+ import"../index-xby428n5.js";
21
+ import"../index-3y73zgbk.js";
22
22
  import {
23
23
  hashString2,
24
24
  getScopeId2,
@@ -32,15 +32,15 @@ import {
32
32
  css2,
33
33
  useStyle2,
34
34
  Style2
35
- } from "../index-0madxn60.js";
35
+ } from "../index-enc8cmea.js";
36
36
  import {
37
37
  Stack2,
38
38
  Row2,
39
39
  Center2,
40
40
  Grid2,
41
41
  Spacer2
42
- } from "../index-1xtrtz1t.js";
43
- import"../index-a4xns6cc.js";
42
+ } from "../index-dmhmde2z.js";
43
+ import"../index-65j7a9et.js";
44
44
  export {
45
45
  Center2 as Center,
46
46
  DIMENSION_KEYWORDS2 as DIMENSION_KEYWORDS,
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  template2,
3
3
  html2
4
- } from "../index-js199er4.js";
5
- import"../index-6kfe1nr4.js";
4
+ } from "../index-g1drdx7k.js";
5
+ import"../index-1yhbg34h.js";
6
6
  export {
7
7
  html2 as html,
8
8
  template2 as template
package/dist/ui/index.js CHANGED
@@ -54,7 +54,7 @@ import {
54
54
  ToastDescription2,
55
55
  ToastClose2,
56
56
  Toast2
57
- } from "../index-dvq5f3s8.js";
57
+ } from "../index-aagpn02x.js";
58
58
  import {
59
59
  createId2,
60
60
  createControllableSignal2,
@@ -73,18 +73,18 @@ import {
73
73
  Tooltip3,
74
74
  SwitchThumb2,
75
75
  Switch2
76
- } from "../index-8x8xz80v.js";
76
+ } from "../index-b7emqmej.js";
77
77
  import {
78
78
  Stack2,
79
79
  Row2,
80
80
  Center2,
81
81
  Grid2,
82
82
  Spacer2
83
- } from "../index-1xtrtz1t.js";
84
- import"../index-9fvarkrx.js";
85
- import"../index-5s255b3w.js";
86
- import"../index-a4xns6cc.js";
87
- import"../index-6kfe1nr4.js";
83
+ } from "../index-dmhmde2z.js";
84
+ import"../index-3y73zgbk.js";
85
+ import"../index-xby428n5.js";
86
+ import"../index-65j7a9et.js";
87
+ import"../index-1yhbg34h.js";
88
88
  export {
89
89
  Accordion2 as Accordion,
90
90
  AccordionContent2 as AccordionContent,
@@ -2,11 +2,11 @@ import {
2
2
  createVirtualizer2,
3
3
  VirtualList2,
4
4
  VirtualGrid2
5
- } from "../index-8czhpea8.js";
6
- import"../index-9fvarkrx.js";
7
- import"../index-5s255b3w.js";
8
- import"../index-a4xns6cc.js";
9
- import"../index-6kfe1nr4.js";
5
+ } from "../index-x6whpv54.js";
6
+ import"../index-3y73zgbk.js";
7
+ import"../index-xby428n5.js";
8
+ import"../index-65j7a9et.js";
9
+ import"../index-1yhbg34h.js";
10
10
  export {
11
11
  VirtualGrid2 as VirtualGrid,
12
12
  VirtualList2 as VirtualList,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epoch32/visage",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Lightning-fast, zero-VDOM, fine-grained reactive UI library with full TypeScript support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,4 +1,13 @@
1
- import { effect, getActiveScope, onCleanup, runInScope, Scope, untrack } from "../signals";
1
+ import {
2
+ effect,
3
+ getActiveScope,
4
+ onCleanup,
5
+ runInScope,
6
+ Scope,
7
+ signal,
8
+ untrack,
9
+ type WritableSignal
10
+ } from "../signals";
2
11
  import { type Child, insertChild, type ReactiveValue, resolveValue } from "./render";
3
12
 
4
13
  export interface ShowProps<T> {
@@ -120,7 +129,7 @@ interface ItemRecord<T> {
120
129
  item: T;
121
130
  scope: Scope;
122
131
  nodes: Node[];
123
- indexSignal: (val?: number) => number;
132
+ indexSignal: WritableSignal<number>;
124
133
  }
125
134
 
126
135
  /**
@@ -206,32 +215,31 @@ export function For<T>(props: ForProps<T>): any {
206
215
  if (!parent) return;
207
216
 
208
217
  const newItems: ItemRecord<T>[] = [];
209
- const prevMap = new Map<T, ItemRecord<T>>();
218
+ const prevMap = new Map<T, ItemRecord<T>[]>();
210
219
 
211
220
  for (const rec of items) {
212
- prevMap.set(rec.item, rec);
221
+ const group = prevMap.get(rec.item);
222
+ if (group) {
223
+ group.push(rec);
224
+ } else {
225
+ prevMap.set(rec.item, [rec]);
226
+ }
213
227
  }
214
228
 
215
229
  // Fast-path: map existing or create new item scopes
216
230
  for (let i = 0; i < list.length; i++) {
217
231
  const item = list[i]!;
218
- const existing = prevMap.get(item);
232
+ const existingGroup = prevMap.get(item);
233
+ const existing =
234
+ existingGroup && existingGroup.length > 0 ? existingGroup.shift() : undefined;
219
235
 
220
236
  if (existing) {
221
- existing.indexSignal(i);
237
+ untrack(() => {
238
+ existing.indexSignal.set(i);
239
+ });
222
240
  newItems.push(existing);
223
- prevMap.delete(item);
224
241
  } else {
225
- let indexVal = i;
226
- const indexSubscribers = new Set<() => void>();
227
- const indexSignal = (...args: [number?]): number => {
228
- if (args.length > 0 && args[0] !== undefined && args[0] !== indexVal) {
229
- indexVal = args[0];
230
- for (const sub of Array.from(indexSubscribers)) sub();
231
- }
232
- return indexVal;
233
- };
234
-
242
+ const indexSignal = signal(i, { internal: true });
235
243
  const itemScope = new Scope(getActiveScope());
236
244
  let itemNodes: Node[] = [];
237
245
 
@@ -254,10 +262,12 @@ export function For<T>(props: ForProps<T>): any {
254
262
  }
255
263
 
256
264
  // Clean up removed items
257
- for (const [, removed] of prevMap) {
258
- removed.scope.dispose();
259
- for (const node of removed.nodes) {
260
- if (node.parentNode) node.parentNode.removeChild(node);
265
+ for (const [, remainingGroup] of prevMap) {
266
+ for (const removed of remainingGroup) {
267
+ removed.scope.dispose();
268
+ for (const node of removed.nodes) {
269
+ if (node.parentNode) node.parentNode.removeChild(node);
270
+ }
261
271
  }
262
272
  }
263
273
 
package/src/form/form.ts CHANGED
@@ -54,6 +54,32 @@ export function createForm<T extends Record<string, any> = Record<string, any>>(
54
54
  const submitCount = signal(0);
55
55
  const customErrors = signal<Partial<Record<keyof T, string>>>({});
56
56
 
57
+ const getValues = (): T => {
58
+ const res: Record<string, any> = {};
59
+ for (const key in fields) {
60
+ res[key] = (fields as any)[key].value();
61
+ }
62
+ return res as T;
63
+ };
64
+
65
+ const schemaValidation = computed(() => {
66
+ if (!options.schema) {
67
+ return { success: true, issuesMap: new Map<string, string>() };
68
+ }
69
+ const currentValues = getValues();
70
+ const res = validateWithSchema(options.schema, currentValues);
71
+ const issuesMap = new Map<string, string>();
72
+ if (!res.success && res.issues) {
73
+ for (const issue of res.issues) {
74
+ const pathKey = String(issue.path);
75
+ if (!issuesMap.has(pathKey)) {
76
+ issuesMap.set(pathKey, issue.message);
77
+ }
78
+ }
79
+ }
80
+ return { success: res.success, issuesMap };
81
+ });
82
+
57
83
  for (const key in initialValues) {
58
84
  const initVal = initialValues[key];
59
85
  const valSignal = signal(initVal);
@@ -74,25 +100,12 @@ export function createForm<T extends Record<string, any> = Record<string, any>>(
74
100
 
75
101
  if (!options.schema) return null;
76
102
 
77
- const currentValues = getValues();
78
- const res = validateWithSchema(options.schema, currentValues);
79
- if (!res.success && res.issues) {
80
- const match = res.issues.find((i) => i.path === key || i.path === `${key}`);
81
- return match ? match.message : null;
82
- }
83
- return null;
103
+ const validation = schemaValidation();
104
+ return validation.issuesMap.get(key) ?? validation.issuesMap.get(String(key)) ?? null;
84
105
  })
85
106
  };
86
107
  }
87
108
 
88
- const getValues = (): T => {
89
- const res: Record<string, any> = {};
90
- for (const key in fields) {
91
- res[key] = (fields as any)[key].value();
92
- }
93
- return res as T;
94
- };
95
-
96
109
  const errors = computed<Partial<Record<keyof T, string>>>(() => {
97
110
  const errMap: Partial<Record<keyof T, string>> = {};
98
111
  for (const key in fields) {
@@ -118,8 +131,7 @@ export function createForm<T extends Record<string, any> = Record<string, any>>(
118
131
 
119
132
  const validate = (): boolean => {
120
133
  if (!options.schema) return true;
121
- const res = validateWithSchema(options.schema, getValues());
122
- return res.success;
134
+ return schemaValidation().success;
123
135
  };
124
136
 
125
137
  const handleSubmit = async (e?: Event): Promise<boolean> => {
@@ -5,8 +5,8 @@ import { Computed } from "./computed";
5
5
  import type { Scope } from "./scope";
6
6
  import {
7
7
  addPendingEffect,
8
- batchDepth,
9
8
  flushEffects,
9
+ getBatchDepth,
10
10
  getCurrentScope,
11
11
  getCurrentSubscriber,
12
12
  removePendingEffect,
@@ -57,7 +57,7 @@ export class Effect implements ISubscriber {
57
57
  this.state = targetState;
58
58
  addPendingEffect(this);
59
59
 
60
- if (batchDepth === 0) {
60
+ if (getBatchDepth() === 0) {
61
61
  flushEffects();
62
62
  }
63
63
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Visage Reactive Scope & Lifecycle Management
3
3
  */
4
- import { currentScope, currentSubscriber, getCurrentScope, setCurrentScope } from "./system";
4
+ import { getCurrentScope, getCurrentSubscriber, setCurrentScope } from "./system";
5
5
  import type { CleanupFn, ISubscriber } from "./types";
6
6
 
7
7
  /**
@@ -14,7 +14,7 @@ export class Scope {
14
14
  isDisposed = false;
15
15
  context?: Map<symbol, any>;
16
16
 
17
- constructor(parent: Scope | null = currentScope) {
17
+ constructor(parent: Scope | null = getCurrentScope()) {
18
18
  this.parent = parent;
19
19
  if (parent && !parent.isDisposed) {
20
20
  parent.cleanups.push(() => this.dispose());
@@ -72,10 +72,12 @@ export class Scope {
72
72
  * ```
73
73
  */
74
74
  export function onCleanup(fn: CleanupFn): void {
75
- if (currentSubscriber && "addCleanup" in currentSubscriber) {
76
- (currentSubscriber as any).addCleanup(fn);
77
- } else if (currentScope) {
78
- currentScope.addCleanup(fn);
75
+ const curSub = getCurrentSubscriber();
76
+ const curScope = getCurrentScope();
77
+ if (curSub && "addCleanup" in curSub) {
78
+ (curSub as any).addCleanup(fn);
79
+ } else if (curScope) {
80
+ curScope.addCleanup(fn);
79
81
  }
80
82
  }
81
83
 
@@ -101,7 +103,7 @@ export function onCleanup(fn: CleanupFn): void {
101
103
  * @returns The return value of `fn`
102
104
  */
103
105
  export function createRoot<T>(fn: (dispose: () => void) => T): T {
104
- const prevScope = currentScope;
106
+ const prevScope = getCurrentScope();
105
107
  const scope = new Scope(null);
106
108
  setCurrentScope(scope);
107
109
  try {
@@ -115,7 +117,7 @@ export function createRoot<T>(fn: (dispose: () => void) => T): T {
115
117
  * Run a function with a specified reactive scope active.
116
118
  */
117
119
  export function runInScope<T>(scope: Scope | null, fn: () => T): T {
118
- const prevScope = currentScope;
120
+ const prevScope = getCurrentScope();
119
121
  setCurrentScope(scope);
120
122
  try {
121
123
  return fn();