@vertz/ui 0.2.12 → 0.2.13

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 (35) hide show
  1. package/README.md +70 -6
  2. package/dist/shared/{chunk-bjcpcq5j.js → chunk-2sth83bd.js} +1 -1
  3. package/dist/shared/{chunk-9e92w0wt.js → chunk-83g4h38e.js} +13 -0
  4. package/dist/shared/{chunk-2rs8a26p.js → chunk-8hsz5y4a.js} +92 -33
  5. package/dist/shared/{chunk-55tgkc7s.js → chunk-c30eg6wn.js} +1 -1
  6. package/dist/shared/{chunk-kg898f92.js → chunk-c9xxsrat.js} +7 -2
  7. package/dist/shared/{chunk-wn4gv1qd.js → chunk-dksg08fq.js} +1 -1
  8. package/dist/shared/{chunk-g4rch80a.js → chunk-h89w580h.js} +7 -0
  9. package/dist/shared/chunk-hw67ckr3.js +1212 -0
  10. package/dist/shared/{chunk-662f9zrb.js → chunk-j6qyxfdc.js} +7 -7
  11. package/dist/shared/{chunk-g1gf16fz.js → chunk-mj7b4t40.js} +107 -41
  12. package/dist/shared/{chunk-18jzqefd.js → chunk-nn9v1zmk.js} +4 -4
  13. package/dist/src/auth/public.d.ts +303 -0
  14. package/dist/src/auth/public.js +773 -0
  15. package/dist/src/css/public.js +22 -0
  16. package/dist/{form → src/form}/public.js +2 -2
  17. package/dist/{index.d.ts → src/index.d.ts} +218 -14
  18. package/dist/{index.js → src/index.js} +79 -229
  19. package/dist/{internals.d.ts → src/internals.d.ts} +265 -3
  20. package/dist/{internals.js → src/internals.js} +18 -10
  21. package/dist/{jsx-runtime → src/jsx-runtime}/index.js +1 -1
  22. package/dist/{query → src/query}/public.d.ts +3 -1
  23. package/dist/src/query/public.js +15 -0
  24. package/dist/{router → src/router}/public.d.ts +25 -4
  25. package/dist/{router → src/router}/public.js +9 -9
  26. package/dist/{test → src/test}/index.d.ts +12 -2
  27. package/dist/{test → src/test}/index.js +4 -4
  28. package/package.json +31 -25
  29. package/reactivity.json +67 -0
  30. package/dist/css/public.js +0 -22
  31. package/dist/query/public.js +0 -15
  32. package/dist/shared/chunk-9k2z3jfx.js +0 -528
  33. /package/dist/{css → src/css}/public.d.ts +0 -0
  34. /package/dist/{form → src/form}/public.d.ts +0 -0
  35. /package/dist/{jsx-runtime → src/jsx-runtime}/index.d.ts +0 -0
@@ -20,7 +20,7 @@ import {
20
20
  slideOutToTop,
21
21
  zoomIn,
22
22
  zoomOut
23
- } from "./shared/chunk-bjcpcq5j.js";
23
+ } from "../shared/chunk-2sth83bd.js";
24
24
  import {
25
25
  Outlet,
26
26
  OutletContext,
@@ -31,25 +31,34 @@ import {
31
31
  useParams,
32
32
  useRouter,
33
33
  useSearchParams
34
- } from "./shared/chunk-18jzqefd.js";
35
- import"./shared/chunk-wn4gv1qd.js";
34
+ } from "../shared/chunk-nn9v1zmk.js";
35
+ import"../shared/chunk-dksg08fq.js";
36
36
  import {
37
37
  createRouter
38
- } from "./shared/chunk-g1gf16fz.js";
38
+ } from "../shared/chunk-mj7b4t40.js";
39
39
  import {
40
40
  defineRoutes
41
- } from "./shared/chunk-9e92w0wt.js";
41
+ } from "../shared/chunk-83g4h38e.js";
42
42
  import {
43
43
  createFieldState,
44
44
  form,
45
45
  formDataToObject,
46
46
  validate
47
- } from "./shared/chunk-55tgkc7s.js";
47
+ } from "../shared/chunk-c30eg6wn.js";
48
48
  import {
49
+ EntityStore,
50
+ QueryEnvelopeStore,
51
+ getEntityStore,
52
+ getMutationEventBus,
53
+ getQueryEnvelopeStore,
54
+ getRelationSchema,
55
+ invalidate,
49
56
  query,
50
- queryMatch
51
- } from "./shared/chunk-9k2z3jfx.js";
52
- import"./shared/chunk-jrtrk5z4.js";
57
+ queryMatch,
58
+ registerRelationSchema,
59
+ resetRelationSchemas_TEST_ONLY
60
+ } from "../shared/chunk-hw67ckr3.js";
61
+ import"../shared/chunk-jrtrk5z4.js";
53
62
  import {
54
63
  ThemeProvider,
55
64
  children,
@@ -63,7 +72,7 @@ import {
63
72
  resolveChildren,
64
73
  s,
65
74
  variants
66
- } from "./shared/chunk-kg898f92.js";
75
+ } from "../shared/chunk-c9xxsrat.js";
67
76
  import {
68
77
  __append,
69
78
  __element,
@@ -72,14 +81,15 @@ import {
72
81
  __staticText,
73
82
  endHydration,
74
83
  startHydration
75
- } from "./shared/chunk-662f9zrb.js";
84
+ } from "../shared/chunk-j6qyxfdc.js";
85
+ import"../shared/chunk-prj7nm08.js";
76
86
  import {
77
87
  RENDER_NODE_BRAND,
78
88
  createDOMAdapter,
79
89
  getAdapter,
80
90
  isRenderNode,
81
91
  setAdapter
82
- } from "./shared/chunk-g4rch80a.js";
92
+ } from "../shared/chunk-h89w580h.js";
83
93
  import {
84
94
  DisposalScopeError,
85
95
  _tryOnCleanup,
@@ -88,6 +98,7 @@ import {
88
98
  createContext,
89
99
  domEffect,
90
100
  getContextScope,
101
+ getSSRContext,
91
102
  popScope,
92
103
  pushScope,
93
104
  runCleanups,
@@ -95,8 +106,7 @@ import {
95
106
  signal,
96
107
  untrack,
97
108
  useContext
98
- } from "./shared/chunk-2rs8a26p.js";
99
- import"./shared/chunk-prj7nm08.js";
109
+ } from "../shared/chunk-8hsz5y4a.js";
100
110
  // src/component/error-boundary-context.ts
101
111
  var handlerStack = [];
102
112
  function pushErrorHandler(handler) {
@@ -156,11 +166,8 @@ function ErrorBoundary(props) {
156
166
  }
157
167
  // src/component/lifecycle.ts
158
168
  function onMount(callback) {
159
- if (typeof globalThis !== "undefined") {
160
- const check = globalThis.__VERTZ_IS_SSR__;
161
- if (typeof check === "function" && check())
162
- return;
163
- }
169
+ if (getSSRContext())
170
+ return;
164
171
  const scope = pushScope();
165
172
  try {
166
173
  const cleanup = untrack(callback);
@@ -253,14 +260,20 @@ function listTransition(startMarker, endMarker, items, keyFn, renderFn) {
253
260
  keyGeneration.set(key, gen);
254
261
  exitingNodes.add(node);
255
262
  exitingKeyMap.set(key, node);
256
- node.setAttribute("data-presence", "exit");
257
- onAnimationsComplete(node, () => {
258
- if (keyGeneration.get(key) === gen) {
259
- node.parentNode?.removeChild(node);
260
- exitingNodes.delete(node);
261
- exitingKeyMap.delete(key);
262
- }
263
- });
263
+ if (node instanceof Element) {
264
+ node.setAttribute("data-presence", "exit");
265
+ onAnimationsComplete(node, () => {
266
+ if (keyGeneration.get(key) === gen) {
267
+ node.parentNode?.removeChild(node);
268
+ exitingNodes.delete(node);
269
+ exitingKeyMap.delete(key);
270
+ }
271
+ });
272
+ } else {
273
+ node.parentNode?.removeChild(node);
274
+ exitingNodes.delete(node);
275
+ exitingKeyMap.delete(key);
276
+ }
264
277
  }
265
278
  }
266
279
  const desiredNodes = [];
@@ -285,7 +298,8 @@ function listTransition(startMarker, endMarker, items, keyFn, renderFn) {
285
298
  nodeMap.set(key, node);
286
299
  scopeMap.set(key, scope);
287
300
  itemSignalMap.set(key, itemSig);
288
- node.setAttribute("data-presence", "enter");
301
+ if (node instanceof Element)
302
+ node.setAttribute("data-presence", "enter");
289
303
  enterNodes.push({ node, key });
290
304
  } else {
291
305
  const itemSig = itemSignalMap.get(key);
@@ -310,6 +324,8 @@ function listTransition(startMarker, endMarker, items, keyFn, renderFn) {
310
324
  }
311
325
  }
312
326
  for (const { node: enterNode, key } of enterNodes) {
327
+ if (!(enterNode instanceof Element))
328
+ continue;
313
329
  onAnimationsComplete(enterNode, () => {
314
330
  if (nodeMap.get(key) === enterNode) {
315
331
  enterNode.removeAttribute("data-presence");
@@ -610,13 +626,10 @@ var _global = globalThis;
610
626
  if (!_global[MOUNTED_KEY])
611
627
  _global[MOUNTED_KEY] = new WeakMap;
612
628
  var mountedRoots = _global[MOUNTED_KEY];
613
- function mount(app, selector, options) {
614
- if (typeof selector !== "string" && !(selector instanceof HTMLElement)) {
615
- throw new Error(`mount(): selector must be a string or HTMLElement, got ${typeof selector}`);
616
- }
617
- const root = typeof selector === "string" ? document.querySelector(selector) : selector;
629
+ function mount(app, options) {
630
+ const root = document.getElementById("app");
618
631
  if (!root) {
619
- throw new Error(`mount(): root element "${selector}" not found`);
632
+ throw new Error('mount(): root element "#app" not found');
620
633
  }
621
634
  const existingHandle = mountedRoots.get(root);
622
635
  if (existingHandle)
@@ -674,208 +687,37 @@ function mount(app, selector, options) {
674
687
  mountedRoots.set(root, handle);
675
688
  return handle;
676
689
  }
677
- // src/store/merge.ts
678
- function shallowMerge(existing, incoming) {
679
- const result = { ...existing };
680
- for (const key of Object.keys(incoming)) {
681
- const value = incoming[key];
682
- if (value !== undefined) {
683
- result[key] = value;
684
- }
685
- }
686
- return result;
687
- }
688
- function shallowEqual(a, b) {
689
- const keysA = Object.keys(a);
690
- const keysB = Object.keys(b);
691
- if (keysA.length !== keysB.length) {
692
- return false;
693
- }
694
- for (const key of keysA) {
695
- if (a[key] !== b[key]) {
696
- return false;
697
- }
698
- }
699
- return true;
700
- }
701
-
702
- // src/store/query-result-index.ts
703
- class QueryResultIndex {
704
- _indices = new Map;
705
- set(queryKey, ids) {
706
- this._indices.set(queryKey, ids);
707
- }
708
- get(queryKey) {
709
- return this._indices.get(queryKey);
710
- }
711
- removeEntity(entityId) {
712
- for (const [queryKey, ids] of this._indices.entries()) {
713
- const filtered = ids.filter((id) => id !== entityId);
714
- if (filtered.length !== ids.length) {
715
- this._indices.set(queryKey, filtered);
690
+ // src/store/optimistic-handler.ts
691
+ function createOptimisticHandler(store, options) {
692
+ const bus = options?.mutationEventBus ?? getMutationEventBus();
693
+ return {
694
+ apply(meta, mutationId) {
695
+ const { entityType, kind, id, body } = meta;
696
+ if (kind === "update" && id && body) {
697
+ store.applyLayer(entityType, id, mutationId, body);
698
+ return () => store.rollbackLayer(entityType, id, mutationId);
716
699
  }
717
- }
718
- }
719
- clear(queryKey) {
720
- this._indices.delete(queryKey);
721
- }
722
- keys() {
723
- return Array.from(this._indices.keys());
724
- }
725
- }
726
-
727
- // src/store/entity-store.ts
728
- class EntityStore {
729
- _entities = new Map;
730
- _typeListeners = new Map;
731
- _queryIndices = new QueryResultIndex;
732
- constructor(options) {
733
- if (options?.initialData) {
734
- this.hydrate(options.initialData);
735
- }
736
- }
737
- get(type, id) {
738
- const typeMap = this._entities.get(type);
739
- if (typeMap?.has(id)) {
740
- return typeMap.get(id);
741
- }
742
- const sig = signal(undefined);
743
- this._getOrCreateTypeMap(type).set(id, sig);
744
- return sig;
745
- }
746
- getMany(type, ids) {
747
- return computed(() => ids.map((id) => this.get(type, id).value));
748
- }
749
- merge(type, data) {
750
- const items = Array.isArray(data) ? data : [data];
751
- if (items.length === 0) {
752
- return;
753
- }
754
- batch(() => {
755
- for (const item of items) {
756
- const typeMap = this._entities.get(type);
757
- const existing = typeMap?.get(item.id);
758
- if (existing) {
759
- const current = existing.peek();
760
- const merged = shallowMerge(current || {}, item);
761
- if (!shallowEqual(current || {}, merged)) {
762
- untrack(() => {
763
- existing.value = merged;
764
- });
765
- }
766
- } else {
767
- const newSignal = signal(item);
768
- this._getOrCreateTypeMap(type).set(item.id, newSignal);
769
- this._notifyTypeChange(type);
770
- }
700
+ if (kind === "delete" && id) {
701
+ const entitySnapshot = store.get(entityType, id).peek();
702
+ const indexSnapshot = store.queryIndices.snapshotEntity(id);
703
+ store.removeOptimistic(entityType, id, mutationId);
704
+ return () => store.restoreOptimistic(entityType, id, mutationId, entitySnapshot, indexSnapshot);
771
705
  }
772
- });
773
- }
774
- remove(type, id) {
775
- const typeMap = this._entities.get(type);
776
- if (!typeMap?.has(id)) {
777
706
  return;
778
- }
779
- const existing = typeMap.get(id);
780
- if (existing) {
781
- existing.value = undefined;
782
- }
783
- typeMap.delete(id);
784
- this._queryIndices.removeEntity(id);
785
- this._notifyTypeChange(type);
786
- }
787
- onTypeChange(type, callback) {
788
- const listeners = this._getOrCreateListeners(type);
789
- listeners.add(callback);
790
- return () => {
791
- listeners.delete(callback);
792
- };
793
- }
794
- has(type, id) {
795
- const typeMap = this._entities.get(type);
796
- if (!typeMap?.has(id)) {
797
- return false;
798
- }
799
- const signal2 = typeMap.get(id);
800
- return signal2?.peek() !== undefined;
801
- }
802
- size(type) {
803
- const typeMap = this._entities.get(type);
804
- if (!typeMap) {
805
- return 0;
806
- }
807
- let count = 0;
808
- for (const signal2 of typeMap.values()) {
809
- if (signal2.peek() !== undefined) {
810
- count++;
811
- }
812
- }
813
- return count;
814
- }
815
- dehydrate() {
816
- const entities = {};
817
- for (const [type, typeMap] of this._entities.entries()) {
818
- const typeEntities = {};
819
- for (const [id, signal2] of typeMap.entries()) {
820
- const value = signal2.peek();
821
- if (value !== undefined) {
822
- typeEntities[id] = value;
823
- }
707
+ },
708
+ commit(meta, mutationId, data) {
709
+ const { entityType, kind, id } = meta;
710
+ if (kind === "update" && id) {
711
+ store.commitLayer(entityType, id, mutationId, data);
824
712
  }
825
- if (Object.keys(typeEntities).length > 0) {
826
- entities[type] = typeEntities;
713
+ if (kind === "create" && data && typeof data === "object" && "id" in data) {
714
+ store.merge(entityType, data);
827
715
  }
828
- }
829
- const queries = {};
830
- for (const queryKey of this._queryIndices.keys()) {
831
- const ids = this._queryIndices.get(queryKey);
832
- if (ids) {
833
- queries[queryKey] = { ids };
716
+ if (!meta.skipInvalidation) {
717
+ bus.emit(entityType);
834
718
  }
835
719
  }
836
- return {
837
- entities,
838
- ...Object.keys(queries).length > 0 ? { queries } : {}
839
- };
840
- }
841
- hydrate(data) {
842
- for (const [type, typeEntities] of Object.entries(data.entities)) {
843
- const entities = Object.values(typeEntities).map((entity) => ({
844
- ...entity,
845
- id: entity.id
846
- }));
847
- this.merge(type, entities);
848
- }
849
- if (data.queries) {
850
- for (const [queryKey, queryData] of Object.entries(data.queries)) {
851
- this._queryIndices.set(queryKey, queryData.ids);
852
- }
853
- }
854
- }
855
- _getOrCreateTypeMap(type) {
856
- let typeMap = this._entities.get(type);
857
- if (!typeMap) {
858
- typeMap = new Map;
859
- this._entities.set(type, typeMap);
860
- }
861
- return typeMap;
862
- }
863
- _getOrCreateListeners(type) {
864
- let listeners = this._typeListeners.get(type);
865
- if (!listeners) {
866
- listeners = new Set;
867
- this._typeListeners.set(type, listeners);
868
- }
869
- return listeners;
870
- }
871
- _notifyTypeChange(type) {
872
- const listeners = this._typeListeners.get(type);
873
- if (listeners) {
874
- for (const callback of listeners) {
875
- callback();
876
- }
877
- }
878
- }
720
+ };
879
721
  }
880
722
  // src/store/test-utils.ts
881
723
  function createTestStore(data) {
@@ -911,7 +753,9 @@ export {
911
753
  setAdapter,
912
754
  s,
913
755
  resolveChildren,
756
+ resetRelationSchemas_TEST_ONLY,
914
757
  resetInjectedStyles,
758
+ registerRelationSchema,
915
759
  ref,
916
760
  queryMatch,
917
761
  query,
@@ -922,10 +766,14 @@ export {
922
766
  keyframes,
923
767
  isRenderNode,
924
768
  isQueryDescriptor,
769
+ invalidate,
925
770
  injectCSS,
926
771
  hydrate,
927
772
  globalCss,
773
+ getRelationSchema,
774
+ getQueryEnvelopeStore,
928
775
  getInjectedCSS,
776
+ getEntityStore,
929
777
  getAdapter,
930
778
  formDataToObject,
931
779
  form,
@@ -936,6 +784,7 @@ export {
936
784
  css,
937
785
  createTestStore,
938
786
  createRouter,
787
+ createOptimisticHandler,
939
788
  createLink,
940
789
  createFieldState,
941
790
  createDialogStack,
@@ -957,6 +806,7 @@ export {
957
806
  RouterView,
958
807
  RouterContext,
959
808
  RENDER_NODE_BRAND,
809
+ QueryEnvelopeStore,
960
810
  Presence,
961
811
  OutletContext,
962
812
  Outlet,