@epoch32/visage 1.1.3 → 1.1.5

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 (52) hide show
  1. package/dist/api/index.js +55 -4085
  2. package/dist/charts/index.js +48 -2806
  3. package/dist/devtools/index.js +18 -4771
  4. package/dist/dom/index.js +32 -1639
  5. package/dist/form/index.js +13 -1498
  6. package/dist/index-061jf06a.js +848 -0
  7. package/dist/index-0madxn60.js +442 -0
  8. package/dist/index-1xtrtz1t.js +256 -0
  9. package/dist/index-2zz0g2n2.js +212 -0
  10. package/dist/index-5s255b3w.js +303 -0
  11. package/dist/index-6kfe1nr4.js +1179 -0
  12. package/dist/index-8czhpea8.js +338 -0
  13. package/dist/index-8x8xz80v.js +727 -0
  14. package/dist/index-921pn75b.js +0 -0
  15. package/dist/index-965ryh36.js +537 -0
  16. package/dist/index-9fvarkrx.js +98 -0
  17. package/dist/index-a4xns6cc.js +219 -0
  18. package/dist/index-b5wc752a.js +1696 -0
  19. package/dist/index-df5e614s.js +334 -0
  20. package/dist/index-dyvgtp43.js +1094 -0
  21. package/dist/index-grhdtcb5.js +234 -0
  22. package/dist/index-h6tjqk6e.js +158 -0
  23. package/dist/index-js199er4.js +101 -0
  24. package/dist/index-x2rs3vab.js +124 -0
  25. package/dist/index-y9bq7h9g.js +1162 -0
  26. package/dist/index-zr6cvset.js +2092 -0
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +458 -11920
  29. package/dist/jsx-runtime/index.js +13 -1719
  30. package/dist/query/index.js +47 -2505
  31. package/dist/router/index.js +25 -1945
  32. package/dist/rpc/index.js +39 -3567
  33. package/dist/server/index.js +11 -1256
  34. package/dist/signals/index.js +52 -1160
  35. package/dist/style/index.js +77 -2429
  36. package/dist/template/index.js +7 -1232
  37. package/dist/ui/index.d.ts +1 -1
  38. package/dist/ui/index.js +150 -4249
  39. package/dist/ui/tabs.d.ts +23 -1
  40. package/dist/virtual/index.js +12 -2044
  41. package/dist/vite/index.js +27 -746
  42. package/package.json +2 -2
  43. package/src/dom/render.ts +20 -7
  44. package/src/index.ts +2 -0
  45. package/src/signals/computed.ts +19 -12
  46. package/src/signals/effect.ts +7 -7
  47. package/src/signals/signal.ts +16 -12
  48. package/src/signals/system.ts +50 -21
  49. package/src/ui/index.ts +2 -0
  50. package/src/ui/tabs.tsx +211 -10
  51. package/src/ui/utils.ts +1 -3
  52. package/src/vite/lucide.ts +22 -2
@@ -0,0 +1,219 @@
1
+ import {
2
+ resolveValue2,
3
+ insertChild2,
4
+ Scope2,
5
+ onCleanup2,
6
+ runInScope2,
7
+ getActiveScope2,
8
+ createContext2,
9
+ useContext2,
10
+ effect2,
11
+ signal2
12
+ } from "./index-6kfe1nr4.js";
13
+
14
+ // src/dom/resource.ts
15
+ var SuspenseContext2 = createContext2(null);
16
+ function createResource2(sourceOrFetcher, maybeFetcher) {
17
+ const isDirect = typeof maybeFetcher !== "function";
18
+ const fetcher = isDirect ? sourceOrFetcher : maybeFetcher;
19
+ const source = isDirect ? null : sourceOrFetcher;
20
+ const data = signal2(undefined);
21
+ const loading = signal2(true);
22
+ const error = signal2(null);
23
+ let currentPromise = null;
24
+ let requestId = 0;
25
+ const load = async (arg) => {
26
+ const currentReq = ++requestId;
27
+ loading.set(true);
28
+ error.set(null);
29
+ const promise = isDirect ? fetcher() : fetcher(arg);
30
+ currentPromise = promise;
31
+ const suspense = useContext2(SuspenseContext2);
32
+ if (suspense) {
33
+ suspense.registerPromise(promise);
34
+ }
35
+ try {
36
+ const res = await promise;
37
+ if (currentReq === requestId) {
38
+ data.set(res);
39
+ loading.set(false);
40
+ currentPromise = null;
41
+ }
42
+ return res;
43
+ } catch (err) {
44
+ if (currentReq === requestId) {
45
+ error.set(err);
46
+ loading.set(false);
47
+ currentPromise = null;
48
+ }
49
+ throw err;
50
+ }
51
+ };
52
+ if (source) {
53
+ effect2(() => {
54
+ const sourceVal = resolveValue2(source);
55
+ if (sourceVal !== false && sourceVal !== null && sourceVal !== undefined) {
56
+ load(sourceVal).catch(() => {});
57
+ }
58
+ });
59
+ } else {
60
+ load().catch(() => {});
61
+ }
62
+ const accessor = () => {
63
+ if (loading() && currentPromise) {
64
+ const suspense = useContext2(SuspenseContext2);
65
+ if (suspense) {
66
+ suspense.registerPromise(currentPromise);
67
+ }
68
+ }
69
+ return data();
70
+ };
71
+ Object.defineProperties(accessor, {
72
+ loading: { get: () => loading },
73
+ error: { get: () => error },
74
+ mutate: { value: (val) => data.set(val) },
75
+ refetch: { value: () => source ? load(resolveValue2(source)) : load() }
76
+ });
77
+ return accessor;
78
+ }
79
+ // src/dom/async.ts
80
+ function Suspense2(props) {
81
+ if (typeof document === "undefined") {
82
+ return typeof props.children === "function" ? props.children() : props.children;
83
+ }
84
+ const marker = document.createTextNode("");
85
+ const initialFrag = document.createDocumentFragment();
86
+ const pendingCount = signal2(0);
87
+ let currentScope = null;
88
+ let currentNodes = [];
89
+ let isMounted = false;
90
+ const suspenseValue = {
91
+ registerPromise(p) {
92
+ pendingCount.update((c) => c + 1);
93
+ p.finally(() => {
94
+ pendingCount.update((c) => Math.max(0, c - 1));
95
+ });
96
+ }
97
+ };
98
+ const renderContent = (content) => {
99
+ const parent = marker.parentNode ?? (!isMounted ? initialFrag : null);
100
+ if (!parent)
101
+ return;
102
+ for (const n of currentNodes) {
103
+ if (n.parentNode)
104
+ n.parentNode.removeChild(n);
105
+ }
106
+ currentNodes = [];
107
+ const frag = document.createDocumentFragment();
108
+ insertChild2(frag, content);
109
+ currentNodes = Array.from(frag.childNodes);
110
+ if (marker.parentNode) {
111
+ marker.parentNode.insertBefore(frag, marker);
112
+ } else if (!isMounted) {
113
+ initialFrag.appendChild(frag);
114
+ }
115
+ };
116
+ effect2(() => {
117
+ if (currentScope) {
118
+ currentScope.dispose();
119
+ currentScope = null;
120
+ }
121
+ currentScope = new Scope2(getActiveScope2());
122
+ runInScope2(currentScope, () => {
123
+ let threwPromise = null;
124
+ let rendered = null;
125
+ try {
126
+ const SuspenseProvider = SuspenseContext2.Provider;
127
+ rendered = SuspenseProvider({
128
+ value: suspenseValue,
129
+ children: props.children
130
+ });
131
+ } catch (err) {
132
+ if (err && typeof err.then === "function") {
133
+ threwPromise = err;
134
+ suspenseValue.registerPromise(err);
135
+ } else {
136
+ throw err;
137
+ }
138
+ }
139
+ if (pendingCount() > 0 || threwPromise) {
140
+ renderContent(props.fallback);
141
+ } else {
142
+ renderContent(rendered);
143
+ }
144
+ });
145
+ });
146
+ isMounted = true;
147
+ initialFrag.appendChild(marker);
148
+ onCleanup2(() => {
149
+ if (currentScope)
150
+ currentScope.dispose();
151
+ });
152
+ return initialFrag;
153
+ }
154
+ function ErrorBoundary2(props) {
155
+ if (typeof document === "undefined") {
156
+ try {
157
+ return typeof props.children === "function" ? props.children() : props.children;
158
+ } catch (err) {
159
+ return typeof props.fallback === "function" ? props.fallback(err, () => {}) : props.fallback;
160
+ }
161
+ }
162
+ const marker = document.createTextNode("");
163
+ const initialFrag = document.createDocumentFragment();
164
+ const currentError = signal2(null);
165
+ let currentScope = null;
166
+ let currentNodes = [];
167
+ let isMounted = false;
168
+ const reset = () => {
169
+ currentError.set(null);
170
+ };
171
+ const renderNodes = (child) => {
172
+ const parent = marker.parentNode ?? (!isMounted ? initialFrag : null);
173
+ if (!parent)
174
+ return;
175
+ for (const n of currentNodes) {
176
+ if (n.parentNode)
177
+ n.parentNode.removeChild(n);
178
+ }
179
+ currentNodes = [];
180
+ const frag = document.createDocumentFragment();
181
+ insertChild2(frag, child);
182
+ currentNodes = Array.from(frag.childNodes);
183
+ if (marker.parentNode) {
184
+ marker.parentNode.insertBefore(frag, marker);
185
+ } else if (!isMounted) {
186
+ initialFrag.appendChild(frag);
187
+ }
188
+ };
189
+ effect2(() => {
190
+ const err = currentError();
191
+ if (currentScope) {
192
+ currentScope.dispose();
193
+ currentScope = null;
194
+ }
195
+ currentScope = new Scope2(getActiveScope2());
196
+ runInScope2(currentScope, () => {
197
+ if (err !== null) {
198
+ const fallbackNode = typeof props.fallback === "function" ? props.fallback(err, reset) : props.fallback;
199
+ renderNodes(fallbackNode);
200
+ } else {
201
+ try {
202
+ const content = typeof props.children === "function" ? props.children() : props.children;
203
+ renderNodes(content);
204
+ } catch (catchedErr) {
205
+ currentError.set(catchedErr);
206
+ }
207
+ }
208
+ });
209
+ });
210
+ isMounted = true;
211
+ initialFrag.appendChild(marker);
212
+ onCleanup2(() => {
213
+ if (currentScope)
214
+ currentScope.dispose();
215
+ });
216
+ return initialFrag;
217
+ }
218
+
219
+ export { SuspenseContext2, createResource2, Suspense2, ErrorBoundary2 };