@epoch32/visage 0.0.0-stage → 0.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 (138) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +110 -2
  3. package/dist/bundle.dev.js +4875 -0
  4. package/dist/index.js +9633 -0
  5. package/dist/src/api/index.js +4002 -0
  6. package/dist/src/charts/index.js +2717 -0
  7. package/dist/src/devtools/index.js +4677 -0
  8. package/dist/src/dom/index.js +1550 -0
  9. package/dist/src/form/index.js +1415 -0
  10. package/dist/src/index.js +11826 -0
  11. package/dist/src/jsx-runtime/index.js +1630 -0
  12. package/dist/src/query/index.js +2422 -0
  13. package/dist/src/router/index.js +1856 -0
  14. package/dist/src/rpc/index.js +3484 -0
  15. package/dist/src/server/index.js +1173 -0
  16. package/dist/src/signals/index.js +1077 -0
  17. package/dist/src/style/index.js +2340 -0
  18. package/dist/src/template/index.js +1149 -0
  19. package/dist/src/ui/index.js +4155 -0
  20. package/dist/src/virtual/index.js +1955 -0
  21. package/dist/src/vite/index.js +984 -0
  22. package/dist/vite/index.js +707 -0
  23. package/package.json +140 -4
  24. package/src/api/client.ts +371 -0
  25. package/src/api/file-router.ts +183 -0
  26. package/src/api/handler.ts +326 -0
  27. package/src/api/index.ts +71 -0
  28. package/src/api/middleware.ts +54 -0
  29. package/src/api/pragma.ts +155 -0
  30. package/src/api/procedure.ts +172 -0
  31. package/src/api/types.ts +249 -0
  32. package/src/charts/Area.tsx +111 -0
  33. package/src/charts/Axis.tsx +126 -0
  34. package/src/charts/Bar.tsx +86 -0
  35. package/src/charts/CartesianGrid.tsx +72 -0
  36. package/src/charts/Chart.tsx +269 -0
  37. package/src/charts/Cursor.tsx +42 -0
  38. package/src/charts/Legend.tsx +56 -0
  39. package/src/charts/Line.tsx +106 -0
  40. package/src/charts/Pie.tsx +88 -0
  41. package/src/charts/Tooltip.tsx +127 -0
  42. package/src/charts/context.ts +30 -0
  43. package/src/charts/index.ts +14 -0
  44. package/src/charts/path.ts +155 -0
  45. package/src/charts/scale.ts +133 -0
  46. package/src/charts/types.ts +50 -0
  47. package/src/devtools/DomTab.tsx +134 -0
  48. package/src/devtools/GraphInspector.tsx +196 -0
  49. package/src/devtools/GraphTab.tsx +315 -0
  50. package/src/devtools/QueryTab.tsx +200 -0
  51. package/src/devtools/RpcTab.tsx +190 -0
  52. package/src/devtools/SignalsTab.tsx +129 -0
  53. package/src/devtools/component.tsx +243 -0
  54. package/src/devtools/highlighter.ts +134 -0
  55. package/src/devtools/hub.ts +175 -0
  56. package/src/devtools/index.ts +20 -0
  57. package/src/devtools/styles.ts +313 -0
  58. package/src/devtools/types.ts +45 -0
  59. package/src/dom/async.ts +232 -0
  60. package/src/dom/control-flow.ts +353 -0
  61. package/src/dom/index.ts +32 -0
  62. package/src/dom/lazy.ts +82 -0
  63. package/src/dom/render.ts +286 -0
  64. package/src/dom/resource.ts +120 -0
  65. package/src/form/form.ts +218 -0
  66. package/src/form/index.ts +17 -0
  67. package/src/form/schema.ts +299 -0
  68. package/src/index.ts +413 -0
  69. package/src/jsx-dev-runtime/index.ts +1 -0
  70. package/src/jsx-runtime/index.ts +112 -0
  71. package/src/jsx-runtime/jsx.d.ts +278 -0
  72. package/src/query/create-mutation.ts +64 -0
  73. package/src/query/create-query.ts +426 -0
  74. package/src/query/focus-manager.ts +68 -0
  75. package/src/query/index.ts +63 -0
  76. package/src/query/mutation-cache.ts +138 -0
  77. package/src/query/online-manager.ts +67 -0
  78. package/src/query/query-cache.ts +369 -0
  79. package/src/query/query-client.ts +248 -0
  80. package/src/query/types.ts +221 -0
  81. package/src/query/utils.ts +132 -0
  82. package/src/router/index.ts +19 -0
  83. package/src/router/router.tsx +352 -0
  84. package/src/rpc/client.ts +317 -0
  85. package/src/rpc/error.ts +70 -0
  86. package/src/rpc/index.ts +52 -0
  87. package/src/rpc/procedure.ts +88 -0
  88. package/src/rpc/router.ts +105 -0
  89. package/src/rpc/server.ts +511 -0
  90. package/src/rpc/types.ts +328 -0
  91. package/src/server/hydrate.ts +21 -0
  92. package/src/server/index.ts +10 -0
  93. package/src/server/render-to-stream.ts +31 -0
  94. package/src/server/render-to-string.ts +125 -0
  95. package/src/signals/computed.ts +217 -0
  96. package/src/signals/context.ts +89 -0
  97. package/src/signals/effect.ts +161 -0
  98. package/src/signals/index.ts +57 -0
  99. package/src/signals/scope.ts +132 -0
  100. package/src/signals/signal.ts +203 -0
  101. package/src/signals/store.ts +163 -0
  102. package/src/signals/system.ts +124 -0
  103. package/src/signals/types.ts +64 -0
  104. package/src/style/component.tsx +122 -0
  105. package/src/style/create-style.ts +229 -0
  106. package/src/style/cx.ts +75 -0
  107. package/src/style/hash.ts +19 -0
  108. package/src/style/index.ts +8 -0
  109. package/src/style/layout.tsx +406 -0
  110. package/src/style/manager.ts +87 -0
  111. package/src/style/parser.ts +257 -0
  112. package/src/style/scale.ts +237 -0
  113. package/src/template/index.ts +4 -0
  114. package/src/template/template.ts +126 -0
  115. package/src/ui/accordion.tsx +286 -0
  116. package/src/ui/command-dialog.tsx +49 -0
  117. package/src/ui/command.tsx +400 -0
  118. package/src/ui/data-table.tsx +322 -0
  119. package/src/ui/dialog.tsx +362 -0
  120. package/src/ui/dropdown-menu.tsx +381 -0
  121. package/src/ui/icon.tsx +69 -0
  122. package/src/ui/index.ts +138 -0
  123. package/src/ui/layout.tsx +13 -0
  124. package/src/ui/popover.tsx +249 -0
  125. package/src/ui/switch.tsx +114 -0
  126. package/src/ui/tabs.tsx +297 -0
  127. package/src/ui/toast.tsx +280 -0
  128. package/src/ui/tooltip.tsx +262 -0
  129. package/src/ui/utils.ts +110 -0
  130. package/src/virtual/index.ts +12 -0
  131. package/src/virtual/virtual-list.tsx +185 -0
  132. package/src/virtual/virtualizer.ts +274 -0
  133. package/src/vite/hmr.ts +38 -0
  134. package/src/vite/index.ts +3 -0
  135. package/src/vite/lucide.ts +124 -0
  136. package/src/vite/plugin.ts +102 -0
  137. package/src/vite/rpc-middleware.ts +82 -0
  138. package/src/vite/types.ts +65 -0
@@ -0,0 +1,1856 @@
1
+ // src/signals/types.ts
2
+ var SubscriberState;
3
+ ((SubscriberState) => {
4
+ SubscriberState[SubscriberState["CLEAN"] = 0] = "CLEAN";
5
+ SubscriberState[SubscriberState["CHECK_DIRTY"] = 1] = "CHECK_DIRTY";
6
+ SubscriberState[SubscriberState["DIRTY"] = 2] = "DIRTY";
7
+ SubscriberState[SubscriberState["DISPOSED"] = 3] = "DISPOSED";
8
+ })(SubscriberState ||= {});
9
+ var SIGNAL_BRAND = Symbol("visage.signal");
10
+ var COMPUTED_BRAND = Symbol("visage.computed");
11
+ function isSignal(value) {
12
+ return typeof value === "function" && ((SIGNAL_BRAND in value) || (COMPUTED_BRAND in value));
13
+ }
14
+
15
+ // src/signals/system.ts
16
+ var currentSubscriber = null;
17
+ var currentScope = null;
18
+ var batchDepth = 0;
19
+ var pendingEffects = new Set;
20
+ var warnedCyclicSubscribers = new WeakSet;
21
+ var isFlushing = false;
22
+ function setCurrentSubscriber(sub) {
23
+ currentSubscriber = sub;
24
+ }
25
+ function setCurrentScope(scope) {
26
+ currentScope = scope;
27
+ }
28
+ function getCurrentScope() {
29
+ return currentScope;
30
+ }
31
+ function addPendingEffect(eff) {
32
+ pendingEffects.add(eff);
33
+ }
34
+ function removePendingEffect(eff) {
35
+ pendingEffects.delete(eff);
36
+ }
37
+ var MAX_FLUSH_COUNT = 100;
38
+ function flushEffects() {
39
+ if (isFlushing || batchDepth > 0)
40
+ return;
41
+ isFlushing = true;
42
+ let iterations = 0;
43
+ try {
44
+ while (pendingEffects.size > 0) {
45
+ if (++iterations > MAX_FLUSH_COUNT) {
46
+ pendingEffects.clear();
47
+ throw new Error(`[Visage Reactivity] Maximum update depth exceeded (${MAX_FLUSH_COUNT} cycles). ` + `An effect continuously triggered state mutations (infinite loop detected). ` + `Ensure effects that modify signals do not unconditionally depend on them, or use untrack() to read state.`);
48
+ }
49
+ const effectsToRun = Array.from(pendingEffects);
50
+ pendingEffects.clear();
51
+ for (const eff of effectsToRun) {
52
+ if (eff.state === 2 /* DIRTY */ || eff.state === 1 /* CHECK_DIRTY */) {
53
+ eff.run();
54
+ }
55
+ }
56
+ }
57
+ } finally {
58
+ isFlushing = false;
59
+ }
60
+ }
61
+ function batch(fn) {
62
+ batchDepth++;
63
+ try {
64
+ return fn();
65
+ } finally {
66
+ batchDepth--;
67
+ if (batchDepth === 0) {
68
+ flushEffects();
69
+ }
70
+ }
71
+ }
72
+ function untrack(fn) {
73
+ const prev = currentSubscriber;
74
+ currentSubscriber = null;
75
+ try {
76
+ return fn();
77
+ } finally {
78
+ currentSubscriber = prev;
79
+ }
80
+ }
81
+
82
+ // src/signals/computed.ts
83
+ class Computed {
84
+ [COMPUTED_BRAND] = true;
85
+ _fn;
86
+ _value;
87
+ _subscribers = new Set;
88
+ sources = new Set;
89
+ sourceVersions = new Map;
90
+ state = 2 /* DIRTY */;
91
+ scope;
92
+ version = 0;
93
+ constructor(fn) {
94
+ this._fn = fn;
95
+ this.scope = currentScope;
96
+ if (currentScope) {
97
+ currentScope.addSubscriber(this);
98
+ }
99
+ }
100
+ get() {
101
+ if (this.state === 3 /* DISPOSED */) {
102
+ return this._fn();
103
+ }
104
+ if (currentSubscriber !== null && currentSubscriber.state !== 3 /* DISPOSED */) {
105
+ this._subscribers.add(currentSubscriber);
106
+ currentSubscriber.sources.add(this);
107
+ currentSubscriber.sourceVersions.set(this, this.version);
108
+ }
109
+ if (this.state === 2 /* DIRTY */ || this.state === 1 /* CHECK_DIRTY */) {
110
+ this.updateIfNecessary();
111
+ }
112
+ return this._value;
113
+ }
114
+ get value() {
115
+ return this.get();
116
+ }
117
+ removeSubscriber(sub) {
118
+ this._subscribers.delete(sub);
119
+ }
120
+ markDirty(targetState = 1 /* CHECK_DIRTY */) {
121
+ if (this.state >= targetState || this.state === 3 /* DISPOSED */) {
122
+ return;
123
+ }
124
+ this.state = targetState;
125
+ for (const sub of this._subscribers) {
126
+ sub.markDirty(1 /* CHECK_DIRTY */);
127
+ }
128
+ }
129
+ updateIfNecessary() {
130
+ if (this.state === 2 /* DIRTY */) {
131
+ const prev = this._value;
132
+ this.recompute();
133
+ return !Object.is(prev, this._value);
134
+ }
135
+ if (this.state === 1 /* CHECK_DIRTY */) {
136
+ let anyChanged = false;
137
+ for (const source of this.sources) {
138
+ if (source instanceof Computed) {
139
+ source.updateIfNecessary();
140
+ }
141
+ const lastVersion = this.sourceVersions.get(source);
142
+ if (lastVersion !== undefined && lastVersion !== source.version) {
143
+ anyChanged = true;
144
+ }
145
+ }
146
+ if (anyChanged) {
147
+ const prev = this._value;
148
+ this.recompute();
149
+ return !Object.is(prev, this._value);
150
+ }
151
+ this.state = 0 /* CLEAN */;
152
+ return false;
153
+ }
154
+ return false;
155
+ }
156
+ recompute() {
157
+ this.cleanupSources();
158
+ const prevSubscriber = currentSubscriber;
159
+ setCurrentSubscriber(this);
160
+ const prevScope = currentScope;
161
+ setCurrentScope(this.scope);
162
+ try {
163
+ const next = this._fn();
164
+ if (!Object.is(this._value, next)) {
165
+ this._value = next;
166
+ this.version++;
167
+ }
168
+ this.state = 0 /* CLEAN */;
169
+ } finally {
170
+ setCurrentSubscriber(prevSubscriber);
171
+ setCurrentScope(prevScope);
172
+ }
173
+ }
174
+ cleanupSources() {
175
+ for (const source of this.sources) {
176
+ source.removeSubscriber(this);
177
+ }
178
+ this.sources.clear();
179
+ this.sourceVersions.clear();
180
+ }
181
+ dispose() {
182
+ if (this.state === 3 /* DISPOSED */)
183
+ return;
184
+ this.state = 3 /* DISPOSED */;
185
+ this.cleanupSources();
186
+ this._subscribers.clear();
187
+ }
188
+ }
189
+ function computed(fn, options) {
190
+ const isInternal = options?.internal ?? false;
191
+ const customName = options?.name;
192
+ const c = new Computed(fn);
193
+ const accessor = () => c.get();
194
+ Object.defineProperties(accessor, {
195
+ [COMPUTED_BRAND]: { value: true },
196
+ get: { value: () => c.get() },
197
+ value: { get: () => c.get() }
198
+ });
199
+ if (!isInternal && typeof window !== "undefined" && window.__VISAGE_DEVTOOLS__) {
200
+ const devtools = window.__VISAGE_DEVTOOLS__;
201
+ const sigId = devtools.registerSignal({
202
+ name: customName,
203
+ type: "computed",
204
+ getValue: () => c.get(),
205
+ version: () => c.version,
206
+ subscribersCount: () => c._subscribers?.size ?? 0,
207
+ dependencies: () => Array.from(c.sources ?? []).map((src) => src._devId).filter(Boolean),
208
+ dependents: () => Array.from(c._subscribers ?? []).map((sub) => sub._devId).filter(Boolean)
209
+ });
210
+ c._devId = sigId;
211
+ if (currentScope) {
212
+ currentScope.addCleanup(() => {
213
+ devtools.unregisterSignal(sigId);
214
+ });
215
+ }
216
+ }
217
+ return accessor;
218
+ }
219
+ var createMemo = computed;
220
+ // src/style/cx.ts
221
+ function hasReactiveClass(val) {
222
+ if (typeof val === "function")
223
+ return true;
224
+ if (Array.isArray(val)) {
225
+ for (let i = 0;i < val.length; i++) {
226
+ if (hasReactiveClass(val[i]))
227
+ return true;
228
+ }
229
+ return false;
230
+ }
231
+ if (typeof val === "object" && val !== null) {
232
+ for (const k in val) {
233
+ if (typeof val[k] === "function")
234
+ return true;
235
+ }
236
+ }
237
+ return false;
238
+ }
239
+ function normalizeClass(val) {
240
+ if (!val)
241
+ return "";
242
+ if (typeof val === "function")
243
+ return normalizeClass(val());
244
+ if (typeof val === "string")
245
+ return val.trim();
246
+ if (typeof val === "number")
247
+ return String(val);
248
+ if (Array.isArray(val)) {
249
+ let res = "";
250
+ for (let i = 0;i < val.length; i++) {
251
+ const item = typeof val[i] === "function" ? val[i]() : val[i];
252
+ const itemStr = normalizeClass(item);
253
+ if (itemStr) {
254
+ res = res ? `${res} ${itemStr}` : itemStr;
255
+ }
256
+ }
257
+ return res;
258
+ }
259
+ if (typeof val === "object") {
260
+ let res = "";
261
+ for (const key in val) {
262
+ const condition = typeof val[key] === "function" ? val[key]() : val[key];
263
+ if (condition) {
264
+ res = res ? `${res} ${key}` : key;
265
+ }
266
+ }
267
+ return res;
268
+ }
269
+ return "";
270
+ }
271
+ function cx(...args) {
272
+ return normalizeClass(args);
273
+ }
274
+
275
+ // src/style/scale.ts
276
+ var UNITLESS_PROPERTIES = new Set([
277
+ "animationIterationCount",
278
+ "aspectRatio",
279
+ "borderImageSlice",
280
+ "columnCount",
281
+ "columns",
282
+ "flex",
283
+ "flexGrow",
284
+ "flexShrink",
285
+ "flexOrder",
286
+ "fontWeight",
287
+ "lineHeight",
288
+ "opacity",
289
+ "order",
290
+ "orphans",
291
+ "scale",
292
+ "tabSize",
293
+ "widows",
294
+ "zIndex",
295
+ "zoom",
296
+ "fillOpacity",
297
+ "strokeOpacity"
298
+ ]);
299
+ var DIMENSION_KEYWORDS = {
300
+ screen: "100dvh",
301
+ "screen-h": "100dvh",
302
+ "screen-w": "100dvw",
303
+ full: "100%",
304
+ half: "50%",
305
+ third: "33.333333%",
306
+ "two-thirds": "66.666667%",
307
+ quarter: "25%",
308
+ "three-quarters": "75%",
309
+ auto: "auto",
310
+ min: "min-content",
311
+ max: "max-content",
312
+ fit: "fit-content"
313
+ };
314
+ function space(val) {
315
+ if (val === undefined || val === null || val === "")
316
+ return "";
317
+ if (typeof val === "number") {
318
+ if (val === 0)
319
+ return "0px";
320
+ return `${val * 4}px`;
321
+ }
322
+ const str = String(val).trim();
323
+ if (str in DIMENSION_KEYWORDS) {
324
+ return DIMENSION_KEYWORDS[str];
325
+ }
326
+ return str;
327
+ }
328
+ function resolveDimension(val) {
329
+ if (val === undefined || val === null || val === "")
330
+ return "";
331
+ if (typeof val === "number") {
332
+ if (val === 0)
333
+ return "0px";
334
+ if (val > 48)
335
+ return `${val}px`;
336
+ return `${val * 4}px`;
337
+ }
338
+ const str = String(val).trim();
339
+ if (str in DIMENSION_KEYWORDS) {
340
+ return DIMENSION_KEYWORDS[str];
341
+ }
342
+ return str;
343
+ }
344
+ function px(val) {
345
+ return `${val}px`;
346
+ }
347
+ function rem(val) {
348
+ return `${val}rem`;
349
+ }
350
+ function em(val) {
351
+ return `${val}em`;
352
+ }
353
+ function fluid(minPx, maxPx, options) {
354
+ const minVw = options?.minVw ?? 375;
355
+ const maxVw = options?.maxVw ?? 1280;
356
+ const slope = (maxPx - minPx) / (maxVw - minVw);
357
+ const yIntercept = -minVw * slope + minPx;
358
+ const slopeVw = slope * 100;
359
+ const preferred = `${yIntercept.toFixed(2)}px + ${slopeVw.toFixed(2)}vw`;
360
+ const min = Math.min(minPx, maxPx);
361
+ const max = Math.max(minPx, maxPx);
362
+ return `clamp(${min}px, ${preferred}, ${max}px)`;
363
+ }
364
+ var SHADOW_PRESETS = {
365
+ none: "none",
366
+ sm: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
367
+ md: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",
368
+ lg: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",
369
+ xl: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",
370
+ soft: "0 8px 30px rgba(0, 0, 0, 0.06)",
371
+ glow: "0 0 24px rgba(168, 85, 247, 0.35)",
372
+ inner: "inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)"
373
+ };
374
+ function shadow(variant) {
375
+ if (variant in SHADOW_PRESETS) {
376
+ return SHADOW_PRESETS[variant];
377
+ }
378
+ return variant;
379
+ }
380
+ var RADIUS_PRESETS = {
381
+ none: "0px",
382
+ sm: "4px",
383
+ md: "8px",
384
+ lg: "12px",
385
+ xl: "16px",
386
+ "2xl": "20px",
387
+ "3xl": "24px",
388
+ full: "9999px"
389
+ };
390
+ function radius(variant) {
391
+ if (typeof variant === "number") {
392
+ return `${variant}px`;
393
+ }
394
+ if (variant in RADIUS_PRESETS) {
395
+ return RADIUS_PRESETS[variant];
396
+ }
397
+ return String(variant);
398
+ }
399
+ function glass(options = {}) {
400
+ const blurVal = typeof options.blur === "number" ? `${options.blur}px` : options.blur ?? "20px";
401
+ const tintVal = options.tint ?? "rgba(255, 255, 255, 0.65)";
402
+ const borderVal = options.border ?? "1px solid rgba(255, 255, 255, 0.75)";
403
+ return {
404
+ backdropFilter: `blur(${blurVal})`,
405
+ WebkitBackdropFilter: `blur(${blurVal})`,
406
+ backgroundColor: tintVal,
407
+ border: borderVal
408
+ };
409
+ }
410
+ function formatStyleProp(prop, val) {
411
+ if (val === null || val === undefined || val === "")
412
+ return "";
413
+ if (typeof val === "number") {
414
+ if (val === 0 || UNITLESS_PROPERTIES.has(prop)) {
415
+ return String(val);
416
+ }
417
+ return `${val}px`;
418
+ }
419
+ const str = String(val).trim();
420
+ if (str in DIMENSION_KEYWORDS) {
421
+ const lowerProp = prop.toLowerCase();
422
+ if (str === "screen") {
423
+ if (lowerProp.includes("width"))
424
+ return "100dvw";
425
+ return "100dvh";
426
+ }
427
+ return DIMENSION_KEYWORDS[str];
428
+ }
429
+ return str;
430
+ }
431
+
432
+ // src/dom/render.ts
433
+ function isReactive(value) {
434
+ return isSignal(value) || typeof value === "function";
435
+ }
436
+ function resolveValue(val) {
437
+ if (typeof val === "function") {
438
+ return val();
439
+ }
440
+ return val;
441
+ }
442
+ function render(fn, container) {
443
+ return createRoot((dispose) => {
444
+ container.textContent = "";
445
+ const node = insertChild(container, fn());
446
+ onCleanup(() => {
447
+ if (node && node instanceof Node && node.parentNode === container) {
448
+ container.removeChild(node);
449
+ }
450
+ });
451
+ return dispose;
452
+ });
453
+ }
454
+ function setAttribute(el, key, value) {
455
+ if (key.startsWith("on") && typeof value === "function") {
456
+ const eventName = key.startsWith("onCapture") ? key.slice(9).toLowerCase() : key.slice(2).toLowerCase();
457
+ const useCapture = key.startsWith("onCapture");
458
+ el.addEventListener(eventName, value, useCapture);
459
+ onCleanup(() => {
460
+ el.removeEventListener(eventName, value, useCapture);
461
+ });
462
+ return;
463
+ }
464
+ if (key === "ref" && typeof value === "function") {
465
+ value(el);
466
+ return;
467
+ }
468
+ if (key === "class" || key === "className") {
469
+ if (hasReactiveClass(value)) {
470
+ effect(() => {
471
+ const cls = normalizeClass(value);
472
+ if (cls)
473
+ el.setAttribute("class", cls);
474
+ else
475
+ el.removeAttribute("class");
476
+ });
477
+ } else {
478
+ const cls = normalizeClass(value);
479
+ if (cls)
480
+ el.setAttribute("class", cls);
481
+ else
482
+ el.removeAttribute("class");
483
+ }
484
+ return;
485
+ }
486
+ if (isReactive(value)) {
487
+ effect(() => {
488
+ const resolved = resolveValue(value);
489
+ applyProp(el, key, resolved);
490
+ });
491
+ } else {
492
+ applyProp(el, key, value);
493
+ }
494
+ }
495
+ function setStyleProperty(el, prop, val) {
496
+ const formatted = formatStyleProp(prop, val);
497
+ if (prop.startsWith("--") || prop.includes("-")) {
498
+ if (formatted === "") {
499
+ el.style.removeProperty(prop);
500
+ } else {
501
+ el.style.setProperty(prop, formatted);
502
+ }
503
+ } else {
504
+ el.style[prop] = formatted;
505
+ }
506
+ }
507
+ function applyProp(el, key, value) {
508
+ if (value === null || value === undefined || value === false && !key.startsWith("aria-") && !key.startsWith("data-")) {
509
+ if (key === "className" || key === "class") {
510
+ el.removeAttribute("class");
511
+ } else if (key === "style" && typeof value === "string") {
512
+ el.removeAttribute("style");
513
+ } else if (key in el && !(el instanceof SVGElement)) {
514
+ try {
515
+ el[key] = typeof el[key] === "boolean" ? false : "";
516
+ } catch {
517
+ el.removeAttribute(key);
518
+ }
519
+ } else {
520
+ el.removeAttribute(key);
521
+ }
522
+ return;
523
+ }
524
+ if (key === "className" || key === "class") {
525
+ const cls = normalizeClass(value);
526
+ if (cls) {
527
+ el.setAttribute("class", cls);
528
+ } else {
529
+ el.removeAttribute("class");
530
+ }
531
+ } else if (key === "style") {
532
+ if (typeof value === "string") {
533
+ el.setAttribute("style", value);
534
+ } else if (typeof value === "object" && value !== null) {
535
+ for (const styleKey in value) {
536
+ const styleVal = value[styleKey];
537
+ if (isReactive(styleVal)) {
538
+ effect(() => {
539
+ setStyleProperty(el, styleKey, resolveValue(styleVal));
540
+ });
541
+ } else {
542
+ setStyleProperty(el, styleKey, styleVal);
543
+ }
544
+ }
545
+ }
546
+ } else if (key === "dangerouslySetInnerHTML" && value && typeof value.__html === "string") {
547
+ el.innerHTML = value.__html;
548
+ } else if (key in el && !(el instanceof SVGElement) && key !== "list" && key !== "form") {
549
+ try {
550
+ el[key] = value;
551
+ } catch {
552
+ el.setAttribute(key, String(value));
553
+ }
554
+ } else {
555
+ if (key.startsWith("aria-") || key.startsWith("data-")) {
556
+ el.setAttribute(key, String(value));
557
+ } else if (value === true) {
558
+ el.setAttribute(key, "");
559
+ } else {
560
+ el.setAttribute(key, String(value));
561
+ }
562
+ }
563
+ }
564
+ function insertChild(parent, child, before = null) {
565
+ if (child === null || child === undefined || child === false || child === true) {
566
+ return null;
567
+ }
568
+ if (child instanceof Node) {
569
+ parent.insertBefore(child, before);
570
+ return child;
571
+ }
572
+ if (Array.isArray(child)) {
573
+ const fragment = document.createDocumentFragment();
574
+ for (const item of child) {
575
+ insertChild(fragment, item);
576
+ }
577
+ parent.insertBefore(fragment, before);
578
+ return fragment;
579
+ }
580
+ if (isReactive(child)) {
581
+ const marker = document.createTextNode("");
582
+ parent.insertBefore(marker, before);
583
+ let childScope = null;
584
+ let currentNodes = [];
585
+ effect(() => {
586
+ const resolved = resolveValue(child);
587
+ if ((typeof resolved === "string" || typeof resolved === "number") && currentNodes.length === 1 && currentNodes[0].nodeType === Node.TEXT_NODE) {
588
+ currentNodes[0].data = String(resolved);
589
+ return;
590
+ }
591
+ if (childScope) {
592
+ childScope.dispose();
593
+ }
594
+ childScope = new Scope(getActiveScope());
595
+ runInScope(childScope, () => {
596
+ for (const node of currentNodes) {
597
+ if (node.parentNode) {
598
+ node.parentNode.removeChild(node);
599
+ }
600
+ }
601
+ currentNodes = [];
602
+ if (resolved === null || resolved === undefined || resolved === false) {
603
+ return;
604
+ }
605
+ const frag = document.createDocumentFragment();
606
+ if (typeof resolved === "string" || typeof resolved === "number" || typeof resolved === "boolean") {
607
+ frag.appendChild(document.createTextNode(String(resolved)));
608
+ } else {
609
+ insertChild(frag, resolved);
610
+ }
611
+ currentNodes = Array.from(frag.childNodes);
612
+ if (marker.parentNode) {
613
+ marker.parentNode.insertBefore(frag, marker);
614
+ }
615
+ });
616
+ });
617
+ onCleanup(() => {
618
+ if (childScope) {
619
+ childScope.dispose();
620
+ }
621
+ for (const node of currentNodes) {
622
+ if (node.parentNode) {
623
+ node.parentNode.removeChild(node);
624
+ }
625
+ }
626
+ if (marker.parentNode) {
627
+ marker.parentNode.removeChild(marker);
628
+ }
629
+ });
630
+ return marker;
631
+ }
632
+ const textNode = document.createTextNode(String(child));
633
+ parent.insertBefore(textNode, before);
634
+ return textNode;
635
+ }
636
+
637
+ // src/signals/scope.ts
638
+ class Scope {
639
+ subscribers = new Set;
640
+ cleanups = [];
641
+ parent = null;
642
+ isDisposed = false;
643
+ context;
644
+ constructor(parent = currentScope) {
645
+ this.parent = parent;
646
+ if (parent && !parent.isDisposed) {
647
+ parent.cleanups.push(() => this.dispose());
648
+ if (parent.context) {
649
+ this.context = new Map(parent.context);
650
+ }
651
+ }
652
+ }
653
+ addSubscriber(sub) {
654
+ if (this.isDisposed)
655
+ return;
656
+ this.subscribers.add(sub);
657
+ }
658
+ addCleanup(fn) {
659
+ if (this.isDisposed) {
660
+ fn();
661
+ return;
662
+ }
663
+ this.cleanups.push(fn);
664
+ }
665
+ dispose() {
666
+ if (this.isDisposed)
667
+ return;
668
+ this.isDisposed = true;
669
+ for (const sub of this.subscribers) {
670
+ sub.dispose();
671
+ }
672
+ this.subscribers.clear();
673
+ for (let i = this.cleanups.length - 1;i >= 0; i--) {
674
+ try {
675
+ this.cleanups[i]();
676
+ } catch (err) {
677
+ console.error("Error during cleanup:", err);
678
+ }
679
+ }
680
+ this.cleanups = [];
681
+ }
682
+ }
683
+ function onCleanup(fn) {
684
+ if (currentSubscriber && "addCleanup" in currentSubscriber) {
685
+ currentSubscriber.addCleanup(fn);
686
+ } else if (currentScope) {
687
+ currentScope.addCleanup(fn);
688
+ }
689
+ }
690
+ function createRoot(fn) {
691
+ const prevScope = currentScope;
692
+ const scope = new Scope(null);
693
+ setCurrentScope(scope);
694
+ try {
695
+ return fn(() => scope.dispose());
696
+ } finally {
697
+ setCurrentScope(prevScope);
698
+ }
699
+ }
700
+ function runInScope(scope, fn) {
701
+ const prevScope = currentScope;
702
+ setCurrentScope(scope);
703
+ try {
704
+ return fn();
705
+ } finally {
706
+ setCurrentScope(prevScope);
707
+ }
708
+ }
709
+ function getActiveScope() {
710
+ return getCurrentScope();
711
+ }
712
+
713
+ // src/signals/context.ts
714
+ function createContext(defaultValue) {
715
+ const id = Symbol("visage.context");
716
+ const context = {
717
+ id,
718
+ defaultValue,
719
+ Provider: (props) => {
720
+ const parentScope = getActiveScope();
721
+ const scope = new Scope(parentScope);
722
+ if (!scope.context) {
723
+ scope.context = new Map(parentScope?.context);
724
+ }
725
+ scope.context.set(id, props.value);
726
+ return runInScope(scope, () => {
727
+ const content = typeof props.children === "function" ? untrack(() => props.children()) : props.children;
728
+ if (typeof document !== "undefined") {
729
+ const frag = document.createDocumentFragment();
730
+ insertChild(frag, content);
731
+ return frag;
732
+ }
733
+ return content;
734
+ });
735
+ }
736
+ };
737
+ return context;
738
+ }
739
+ function useContext(context) {
740
+ let scope = getActiveScope();
741
+ while (scope) {
742
+ if (scope.context?.has(context.id)) {
743
+ return scope.context.get(context.id);
744
+ }
745
+ scope = scope.parent;
746
+ }
747
+ return context.defaultValue;
748
+ }
749
+ // src/signals/effect.ts
750
+ class Effect {
751
+ _fn;
752
+ sources = new Set;
753
+ sourceVersions = new Map;
754
+ cleanups = [];
755
+ state = 2 /* DIRTY */;
756
+ scope;
757
+ constructor(fn) {
758
+ this._fn = fn;
759
+ this.scope = currentScope;
760
+ if (currentScope) {
761
+ currentScope.addSubscriber(this);
762
+ }
763
+ this.run();
764
+ }
765
+ addCleanup(fn) {
766
+ this.cleanups.push(fn);
767
+ }
768
+ runCleanups() {
769
+ for (let i = this.cleanups.length - 1;i >= 0; i--) {
770
+ try {
771
+ this.cleanups[i]();
772
+ } catch (e) {
773
+ console.error("Error in effect cleanup:", e);
774
+ }
775
+ }
776
+ this.cleanups = [];
777
+ }
778
+ markDirty(targetState = 2 /* DIRTY */) {
779
+ if (this.state >= targetState || this.state === 3 /* DISPOSED */) {
780
+ return;
781
+ }
782
+ this.state = targetState;
783
+ addPendingEffect(this);
784
+ if (batchDepth === 0) {
785
+ flushEffects();
786
+ }
787
+ }
788
+ run() {
789
+ if (this.state === 3 /* DISPOSED */)
790
+ return;
791
+ if (this.state === 1 /* CHECK_DIRTY */) {
792
+ let isDirty = false;
793
+ for (const source of this.sources) {
794
+ if (source instanceof Computed) {
795
+ source.updateIfNecessary();
796
+ }
797
+ const lastVersion = this.sourceVersions.get(source);
798
+ if (lastVersion !== undefined && lastVersion !== source.version) {
799
+ isDirty = true;
800
+ }
801
+ }
802
+ if (!isDirty) {
803
+ this.state = 0 /* CLEAN */;
804
+ return;
805
+ }
806
+ }
807
+ this.runCleanups();
808
+ this.cleanupSources();
809
+ const prevSubscriber = currentSubscriber;
810
+ setCurrentSubscriber(this);
811
+ const prevScope = currentScope;
812
+ setCurrentScope(this.scope);
813
+ try {
814
+ this.state = 0 /* CLEAN */;
815
+ const res = this._fn();
816
+ if (typeof res === "function") {
817
+ this.cleanups.push(res);
818
+ }
819
+ } finally {
820
+ setCurrentSubscriber(prevSubscriber);
821
+ setCurrentScope(prevScope);
822
+ }
823
+ }
824
+ cleanupSources() {
825
+ for (const source of this.sources) {
826
+ source.removeSubscriber(this);
827
+ }
828
+ this.sources.clear();
829
+ this.sourceVersions.clear();
830
+ }
831
+ dispose() {
832
+ if (this.state === 3 /* DISPOSED */)
833
+ return;
834
+ this.state = 3 /* DISPOSED */;
835
+ this.runCleanups();
836
+ this.cleanupSources();
837
+ removePendingEffect(this);
838
+ }
839
+ }
840
+ function effect(fn) {
841
+ const eff = new Effect(fn);
842
+ return () => eff.dispose();
843
+ }
844
+ var createEffect = effect;
845
+ // src/signals/signal.ts
846
+ class Signal {
847
+ [SIGNAL_BRAND] = true;
848
+ _value;
849
+ _subscribers = new Set;
850
+ _equals;
851
+ version = 0;
852
+ constructor(initialValue, equals) {
853
+ this._value = initialValue;
854
+ this._equals = equals ?? Object.is;
855
+ }
856
+ get() {
857
+ if (currentSubscriber !== null && currentSubscriber.state !== 3 /* DISPOSED */) {
858
+ this._subscribers.add(currentSubscriber);
859
+ currentSubscriber.sources.add(this);
860
+ currentSubscriber.sourceVersions.set(this, this.version);
861
+ }
862
+ return this._value;
863
+ }
864
+ set(newValue) {
865
+ if (this._equals(this._value, newValue)) {
866
+ return;
867
+ }
868
+ if (currentSubscriber !== null && this._subscribers.has(currentSubscriber)) {
869
+ if (!warnedCyclicSubscribers.has(currentSubscriber)) {
870
+ warnedCyclicSubscribers.add(currentSubscriber);
871
+ if (typeof console !== "undefined" && typeof console.warn === "function") {
872
+ console.warn(`[Visage Reactivity] Cyclic update detected: An active subscriber modified a signal that it depends on. ` + `To read a signal inside an effect/computed without creating a circular dependency, wrap the read in untrack():
873
+ ` + ` untrack(() => signal())`);
874
+ }
875
+ }
876
+ }
877
+ this._value = newValue;
878
+ this.version++;
879
+ batch(() => {
880
+ this.notify();
881
+ });
882
+ }
883
+ update(fn) {
884
+ this.set(fn(this._value));
885
+ }
886
+ get value() {
887
+ return this.get();
888
+ }
889
+ set value(val) {
890
+ this.set(val);
891
+ }
892
+ removeSubscriber(sub) {
893
+ this._subscribers.delete(sub);
894
+ }
895
+ notify() {
896
+ if (this._subscribers.size === 0)
897
+ return;
898
+ const subs = Array.from(this._subscribers);
899
+ for (const sub of subs) {
900
+ sub.markDirty(2 /* DIRTY */);
901
+ }
902
+ }
903
+ }
904
+ function signal(initialValue, optionsOrEquals) {
905
+ const equals = typeof optionsOrEquals === "function" ? optionsOrEquals : optionsOrEquals?.equals;
906
+ const isInternal = typeof optionsOrEquals === "object" ? optionsOrEquals?.internal : false;
907
+ const customName = typeof optionsOrEquals === "object" ? optionsOrEquals?.name : undefined;
908
+ const s = new Signal(initialValue, equals);
909
+ const accessor = (...args) => {
910
+ if (args.length === 0) {
911
+ return s.get();
912
+ }
913
+ s.set(args[0]);
914
+ return args[0];
915
+ };
916
+ Object.defineProperties(accessor, {
917
+ [SIGNAL_BRAND]: { value: true },
918
+ get: { value: () => s.get() },
919
+ set: { value: (v) => s.set(v) },
920
+ update: { value: (fn) => s.update(fn) },
921
+ value: {
922
+ get: () => s.get(),
923
+ set: (v) => s.set(v)
924
+ }
925
+ });
926
+ if (!isInternal && typeof window !== "undefined" && window.__VISAGE_DEVTOOLS__) {
927
+ const devtools = window.__VISAGE_DEVTOOLS__;
928
+ const sigId = devtools.registerSignal({
929
+ name: customName,
930
+ type: "signal",
931
+ getValue: () => s.get(),
932
+ version: () => s.version,
933
+ subscribersCount: () => s._subscribers?.size ?? 0,
934
+ dependents: () => Array.from(s._subscribers ?? []).map((sub) => sub._devId).filter(Boolean)
935
+ });
936
+ s._devId = sigId;
937
+ if (currentScope) {
938
+ currentScope.addCleanup(() => {
939
+ devtools.unregisterSignal(sigId);
940
+ });
941
+ }
942
+ }
943
+ return accessor;
944
+ }
945
+ function createSignal(initialValue, optionsOrEquals) {
946
+ const s = signal(initialValue, optionsOrEquals);
947
+ const setter = (value) => {
948
+ if (typeof value === "function") {
949
+ s.update(value);
950
+ } else {
951
+ s.set(value);
952
+ }
953
+ };
954
+ return [s, setter];
955
+ }
956
+ // src/signals/store.ts
957
+ var STORE_RAW = Symbol("visage.store.raw");
958
+ var STORE_SIGNALS = Symbol("visage.store.signals");
959
+ var STORE_PROXY = Symbol("visage.store.proxy");
960
+ function isObject(val) {
961
+ return typeof val === "object" && val !== null && (typeof Node === "undefined" || !(val instanceof Node)) && !isSignal(val);
962
+ }
963
+ function getOrCreatePropertySignal(target, prop) {
964
+ let signalsMap = target[STORE_SIGNALS];
965
+ if (!signalsMap) {
966
+ signalsMap = new Map;
967
+ Object.defineProperty(target, STORE_SIGNALS, {
968
+ value: signalsMap,
969
+ enumerable: false,
970
+ writable: true
971
+ });
972
+ }
973
+ let sig = signalsMap.get(prop);
974
+ if (!sig) {
975
+ sig = new Signal(target[prop]);
976
+ signalsMap.set(prop, sig);
977
+ }
978
+ return sig;
979
+ }
980
+ function createStoreProxy(target) {
981
+ if (!isObject(target))
982
+ return target;
983
+ if (target[STORE_PROXY])
984
+ return target[STORE_PROXY];
985
+ const proxy = new Proxy(target, {
986
+ get(target, prop, receiver) {
987
+ if (prop === STORE_RAW)
988
+ return target;
989
+ if (prop === STORE_PROXY)
990
+ return proxy;
991
+ if (typeof prop === "string" || typeof prop === "symbol") {
992
+ const sig = getOrCreatePropertySignal(target, prop);
993
+ sig.get();
994
+ }
995
+ const value = Reflect.get(target, prop, receiver);
996
+ if (isObject(value)) {
997
+ return createStoreProxy(value);
998
+ }
999
+ return value;
1000
+ },
1001
+ set(target, prop, value, receiver) {
1002
+ const prevValue = Reflect.get(target, prop, receiver);
1003
+ if (Object.is(prevValue, value)) {
1004
+ return true;
1005
+ }
1006
+ const success = Reflect.set(target, prop, value, receiver);
1007
+ if (success) {
1008
+ const sig = getOrCreatePropertySignal(target, prop);
1009
+ sig.set(value);
1010
+ if (Array.isArray(target) && prop !== "length") {
1011
+ const lenSig = getOrCreatePropertySignal(target, "length");
1012
+ lenSig.set(target.length);
1013
+ }
1014
+ }
1015
+ return success;
1016
+ },
1017
+ deleteProperty(target, prop) {
1018
+ const hadProp = Reflect.has(target, prop);
1019
+ const success = Reflect.deleteProperty(target, prop);
1020
+ if (hadProp && success) {
1021
+ const sig = getOrCreatePropertySignal(target, prop);
1022
+ sig.set(undefined);
1023
+ }
1024
+ return success;
1025
+ }
1026
+ });
1027
+ Object.defineProperty(target, STORE_PROXY, {
1028
+ value: proxy,
1029
+ enumerable: false,
1030
+ writable: true
1031
+ });
1032
+ return proxy;
1033
+ }
1034
+ function createStore(initialState) {
1035
+ if (!isObject(initialState)) {
1036
+ throw new Error("createStore requires an object or array as initial state");
1037
+ }
1038
+ return createStoreProxy(initialState);
1039
+ }
1040
+ function mutateStore(store, mutator) {
1041
+ batch(() => {
1042
+ mutator(store);
1043
+ });
1044
+ }
1045
+ function unwrapStore(store) {
1046
+ if (isObject(store) && store[STORE_RAW]) {
1047
+ return store[STORE_RAW];
1048
+ }
1049
+ return store;
1050
+ }
1051
+ // src/dom/resource.ts
1052
+ var SuspenseContext = createContext(null);
1053
+ function createResource(sourceOrFetcher, maybeFetcher) {
1054
+ const isDirect = typeof maybeFetcher !== "function";
1055
+ const fetcher = isDirect ? sourceOrFetcher : maybeFetcher;
1056
+ const source = isDirect ? null : sourceOrFetcher;
1057
+ const data = signal(undefined);
1058
+ const loading = signal(true);
1059
+ const error = signal(null);
1060
+ let currentPromise = null;
1061
+ let requestId = 0;
1062
+ const load = async (arg) => {
1063
+ const currentReq = ++requestId;
1064
+ loading.set(true);
1065
+ error.set(null);
1066
+ const promise = isDirect ? fetcher() : fetcher(arg);
1067
+ currentPromise = promise;
1068
+ const suspense = useContext(SuspenseContext);
1069
+ if (suspense) {
1070
+ suspense.registerPromise(promise);
1071
+ }
1072
+ try {
1073
+ const res = await promise;
1074
+ if (currentReq === requestId) {
1075
+ data.set(res);
1076
+ loading.set(false);
1077
+ currentPromise = null;
1078
+ }
1079
+ return res;
1080
+ } catch (err) {
1081
+ if (currentReq === requestId) {
1082
+ error.set(err);
1083
+ loading.set(false);
1084
+ currentPromise = null;
1085
+ }
1086
+ throw err;
1087
+ }
1088
+ };
1089
+ if (source) {
1090
+ effect(() => {
1091
+ const sourceVal = resolveValue(source);
1092
+ if (sourceVal !== false && sourceVal !== null && sourceVal !== undefined) {
1093
+ load(sourceVal).catch(() => {});
1094
+ }
1095
+ });
1096
+ } else {
1097
+ load().catch(() => {});
1098
+ }
1099
+ const accessor = () => {
1100
+ if (loading() && currentPromise) {
1101
+ const suspense = useContext(SuspenseContext);
1102
+ if (suspense) {
1103
+ suspense.registerPromise(currentPromise);
1104
+ }
1105
+ }
1106
+ return data();
1107
+ };
1108
+ Object.defineProperties(accessor, {
1109
+ loading: { get: () => loading },
1110
+ error: { get: () => error },
1111
+ mutate: { value: (val) => data.set(val) },
1112
+ refetch: { value: () => source ? load(resolveValue(source)) : load() }
1113
+ });
1114
+ return accessor;
1115
+ }
1116
+
1117
+ // src/dom/lazy.ts
1118
+ function lazy(importer) {
1119
+ let loadedComponent = null;
1120
+ let loadingPromise = null;
1121
+ const preload = () => {
1122
+ if (loadedComponent) {
1123
+ return Promise.resolve(loadedComponent);
1124
+ }
1125
+ if (!loadingPromise) {
1126
+ loadingPromise = importer().then((mod) => {
1127
+ const comp = mod && typeof mod === "object" && "default" in mod ? mod.default : mod;
1128
+ loadedComponent = comp;
1129
+ return comp;
1130
+ }).catch((err) => {
1131
+ loadingPromise = null;
1132
+ throw err;
1133
+ });
1134
+ }
1135
+ return loadingPromise;
1136
+ };
1137
+ const LazyWrapper = (props) => {
1138
+ if (loadedComponent) {
1139
+ return loadedComponent(props);
1140
+ }
1141
+ const promise = preload();
1142
+ const suspense = useContext(SuspenseContext);
1143
+ if (suspense) {
1144
+ suspense.registerPromise(promise);
1145
+ }
1146
+ const res = createResource(() => promise);
1147
+ return () => {
1148
+ const Comp = res();
1149
+ return Comp ? Comp(props) : null;
1150
+ };
1151
+ };
1152
+ LazyWrapper.preload = preload;
1153
+ return LazyWrapper;
1154
+ }
1155
+ // src/dom/async.ts
1156
+ function Suspense(props) {
1157
+ if (typeof document === "undefined") {
1158
+ return typeof props.children === "function" ? props.children() : props.children;
1159
+ }
1160
+ const marker = document.createTextNode("");
1161
+ const initialFrag = document.createDocumentFragment();
1162
+ const pendingCount = signal(0);
1163
+ let currentScope = null;
1164
+ let currentNodes = [];
1165
+ let isMounted = false;
1166
+ const suspenseValue = {
1167
+ registerPromise(p) {
1168
+ pendingCount.update((c) => c + 1);
1169
+ p.finally(() => {
1170
+ pendingCount.update((c) => Math.max(0, c - 1));
1171
+ });
1172
+ }
1173
+ };
1174
+ const renderContent = (content) => {
1175
+ const parent = marker.parentNode ?? (!isMounted ? initialFrag : null);
1176
+ if (!parent)
1177
+ return;
1178
+ for (const n of currentNodes) {
1179
+ if (n.parentNode)
1180
+ n.parentNode.removeChild(n);
1181
+ }
1182
+ currentNodes = [];
1183
+ const frag = document.createDocumentFragment();
1184
+ insertChild(frag, content);
1185
+ currentNodes = Array.from(frag.childNodes);
1186
+ if (marker.parentNode) {
1187
+ marker.parentNode.insertBefore(frag, marker);
1188
+ } else if (!isMounted) {
1189
+ initialFrag.appendChild(frag);
1190
+ }
1191
+ };
1192
+ effect(() => {
1193
+ if (currentScope) {
1194
+ currentScope.dispose();
1195
+ currentScope = null;
1196
+ }
1197
+ currentScope = new Scope(getActiveScope());
1198
+ runInScope(currentScope, () => {
1199
+ let threwPromise = null;
1200
+ let rendered = null;
1201
+ try {
1202
+ const SuspenseProvider = SuspenseContext.Provider;
1203
+ rendered = SuspenseProvider({
1204
+ value: suspenseValue,
1205
+ children: props.children
1206
+ });
1207
+ } catch (err) {
1208
+ if (err && typeof err.then === "function") {
1209
+ threwPromise = err;
1210
+ suspenseValue.registerPromise(err);
1211
+ } else {
1212
+ throw err;
1213
+ }
1214
+ }
1215
+ if (pendingCount() > 0 || threwPromise) {
1216
+ renderContent(props.fallback);
1217
+ } else {
1218
+ renderContent(rendered);
1219
+ }
1220
+ });
1221
+ });
1222
+ isMounted = true;
1223
+ initialFrag.appendChild(marker);
1224
+ onCleanup(() => {
1225
+ if (currentScope)
1226
+ currentScope.dispose();
1227
+ });
1228
+ return initialFrag;
1229
+ }
1230
+ function ErrorBoundary(props) {
1231
+ if (typeof document === "undefined") {
1232
+ try {
1233
+ return typeof props.children === "function" ? props.children() : props.children;
1234
+ } catch (err) {
1235
+ return typeof props.fallback === "function" ? props.fallback(err, () => {}) : props.fallback;
1236
+ }
1237
+ }
1238
+ const marker = document.createTextNode("");
1239
+ const initialFrag = document.createDocumentFragment();
1240
+ const currentError = signal(null);
1241
+ let currentScope = null;
1242
+ let currentNodes = [];
1243
+ let isMounted = false;
1244
+ const reset = () => {
1245
+ currentError.set(null);
1246
+ };
1247
+ const renderNodes = (child) => {
1248
+ const parent = marker.parentNode ?? (!isMounted ? initialFrag : null);
1249
+ if (!parent)
1250
+ return;
1251
+ for (const n of currentNodes) {
1252
+ if (n.parentNode)
1253
+ n.parentNode.removeChild(n);
1254
+ }
1255
+ currentNodes = [];
1256
+ const frag = document.createDocumentFragment();
1257
+ insertChild(frag, child);
1258
+ currentNodes = Array.from(frag.childNodes);
1259
+ if (marker.parentNode) {
1260
+ marker.parentNode.insertBefore(frag, marker);
1261
+ } else if (!isMounted) {
1262
+ initialFrag.appendChild(frag);
1263
+ }
1264
+ };
1265
+ effect(() => {
1266
+ const err = currentError();
1267
+ if (currentScope) {
1268
+ currentScope.dispose();
1269
+ currentScope = null;
1270
+ }
1271
+ currentScope = new Scope(getActiveScope());
1272
+ runInScope(currentScope, () => {
1273
+ if (err !== null) {
1274
+ const fallbackNode = typeof props.fallback === "function" ? props.fallback(err, reset) : props.fallback;
1275
+ renderNodes(fallbackNode);
1276
+ } else {
1277
+ try {
1278
+ const content = typeof props.children === "function" ? props.children() : props.children;
1279
+ renderNodes(content);
1280
+ } catch (catchedErr) {
1281
+ currentError.set(catchedErr);
1282
+ }
1283
+ }
1284
+ });
1285
+ });
1286
+ isMounted = true;
1287
+ initialFrag.appendChild(marker);
1288
+ onCleanup(() => {
1289
+ if (currentScope)
1290
+ currentScope.dispose();
1291
+ });
1292
+ return initialFrag;
1293
+ }
1294
+ // src/dom/control-flow.ts
1295
+ function Show(props) {
1296
+ if (typeof document === "undefined") {
1297
+ const condition = resolveValue(props.when);
1298
+ if (condition) {
1299
+ return typeof props.children === "function" && props.children.length > 0 ? props.children(() => resolveValue(props.when)) : typeof props.children === "function" ? props.children() : props.children;
1300
+ }
1301
+ return props.fallback ?? null;
1302
+ }
1303
+ const marker = document.createTextNode("");
1304
+ const initialFrag = document.createDocumentFragment();
1305
+ let currentScope = null;
1306
+ let currentContent = [];
1307
+ let isMounted = false;
1308
+ effect(() => {
1309
+ const condition = resolveValue(props.when);
1310
+ if (currentScope) {
1311
+ currentScope.dispose();
1312
+ currentScope = null;
1313
+ }
1314
+ for (const node of currentContent) {
1315
+ if (node.parentNode) {
1316
+ node.parentNode.removeChild(node);
1317
+ }
1318
+ }
1319
+ currentContent = [];
1320
+ const frag = document.createDocumentFragment();
1321
+ if (condition) {
1322
+ currentScope = new Scope(getActiveScope());
1323
+ untrack(() => {
1324
+ runInScope(currentScope, () => {
1325
+ const childRes = typeof props.children === "function" && props.children.length > 0 ? props.children(() => resolveValue(props.when)) : typeof props.children === "function" ? props.children() : props.children;
1326
+ insertChild(frag, childRes);
1327
+ });
1328
+ });
1329
+ } else if (props.fallback !== undefined) {
1330
+ currentScope = new Scope(getActiveScope());
1331
+ untrack(() => {
1332
+ runInScope(currentScope, () => {
1333
+ insertChild(frag, props.fallback);
1334
+ });
1335
+ });
1336
+ }
1337
+ currentContent = Array.from(frag.childNodes);
1338
+ if (marker.parentNode) {
1339
+ marker.parentNode.insertBefore(frag, marker);
1340
+ } else if (!isMounted) {
1341
+ initialFrag.appendChild(frag);
1342
+ }
1343
+ });
1344
+ isMounted = true;
1345
+ initialFrag.appendChild(marker);
1346
+ onCleanup(() => {
1347
+ if (currentScope) {
1348
+ currentScope.dispose();
1349
+ }
1350
+ });
1351
+ return initialFrag;
1352
+ }
1353
+ function For(props) {
1354
+ if (typeof document === "undefined") {
1355
+ const list = resolveValue(props.each) ?? [];
1356
+ if (list.length === 0) {
1357
+ return props.fallback ?? null;
1358
+ }
1359
+ return list.map((item, idx) => props.children(item, () => idx));
1360
+ }
1361
+ const marker = document.createTextNode("");
1362
+ const initialFrag = document.createDocumentFragment();
1363
+ let items = [];
1364
+ let fallbackScope = null;
1365
+ let fallbackNodes = [];
1366
+ let isMounted = false;
1367
+ effect(() => {
1368
+ const list = resolveValue(props.each) ?? [];
1369
+ const parent = marker.parentNode ?? (!isMounted ? initialFrag : null);
1370
+ if (list.length === 0) {
1371
+ for (const rec of items) {
1372
+ rec.scope.dispose();
1373
+ for (const node of rec.nodes) {
1374
+ if (node.parentNode)
1375
+ node.parentNode.removeChild(node);
1376
+ }
1377
+ }
1378
+ items = [];
1379
+ if (props.fallback !== undefined && fallbackNodes.length === 0 && parent) {
1380
+ fallbackScope = new Scope(getActiveScope());
1381
+ untrack(() => {
1382
+ runInScope(fallbackScope, () => {
1383
+ const frag = document.createDocumentFragment();
1384
+ insertChild(frag, props.fallback);
1385
+ fallbackNodes = Array.from(frag.childNodes);
1386
+ if (marker.parentNode) {
1387
+ marker.parentNode.insertBefore(frag, marker);
1388
+ } else if (!isMounted) {
1389
+ initialFrag.appendChild(frag);
1390
+ }
1391
+ });
1392
+ });
1393
+ }
1394
+ return;
1395
+ }
1396
+ if (fallbackNodes.length > 0) {
1397
+ if (fallbackScope) {
1398
+ fallbackScope.dispose();
1399
+ fallbackScope = null;
1400
+ }
1401
+ for (const node of fallbackNodes) {
1402
+ if (node.parentNode)
1403
+ node.parentNode.removeChild(node);
1404
+ }
1405
+ fallbackNodes = [];
1406
+ }
1407
+ if (!parent)
1408
+ return;
1409
+ const newItems = [];
1410
+ const prevMap = new Map;
1411
+ for (const rec of items) {
1412
+ prevMap.set(rec.item, rec);
1413
+ }
1414
+ for (let i = 0;i < list.length; i++) {
1415
+ const item = list[i];
1416
+ const existing = prevMap.get(item);
1417
+ if (existing) {
1418
+ existing.indexSignal(i);
1419
+ newItems.push(existing);
1420
+ prevMap.delete(item);
1421
+ } else {
1422
+ let indexVal = i;
1423
+ const indexSubscribers = new Set;
1424
+ const indexSignal = (...args) => {
1425
+ if (args.length > 0 && args[0] !== undefined && args[0] !== indexVal) {
1426
+ indexVal = args[0];
1427
+ for (const sub of Array.from(indexSubscribers))
1428
+ sub();
1429
+ }
1430
+ return indexVal;
1431
+ };
1432
+ const itemScope = new Scope(getActiveScope());
1433
+ let itemNodes = [];
1434
+ untrack(() => {
1435
+ runInScope(itemScope, () => {
1436
+ const frag = document.createDocumentFragment();
1437
+ const child = props.children(item, indexSignal);
1438
+ insertChild(frag, child);
1439
+ itemNodes = Array.from(frag.childNodes);
1440
+ });
1441
+ });
1442
+ newItems.push({
1443
+ item,
1444
+ scope: itemScope,
1445
+ nodes: itemNodes,
1446
+ indexSignal
1447
+ });
1448
+ }
1449
+ }
1450
+ for (const [, removed] of prevMap) {
1451
+ removed.scope.dispose();
1452
+ for (const node of removed.nodes) {
1453
+ if (node.parentNode)
1454
+ node.parentNode.removeChild(node);
1455
+ }
1456
+ }
1457
+ if (marker.parentNode) {
1458
+ let currentMarker = marker;
1459
+ for (let i = newItems.length - 1;i >= 0; i--) {
1460
+ const rec = newItems[i];
1461
+ for (let j = rec.nodes.length - 1;j >= 0; j--) {
1462
+ const node = rec.nodes[j];
1463
+ if (node.nextSibling !== currentMarker) {
1464
+ marker.parentNode.insertBefore(node, currentMarker);
1465
+ }
1466
+ currentMarker = node;
1467
+ }
1468
+ }
1469
+ } else if (!isMounted) {
1470
+ for (const rec of newItems) {
1471
+ for (const node of rec.nodes) {
1472
+ initialFrag.appendChild(node);
1473
+ }
1474
+ }
1475
+ }
1476
+ items = newItems;
1477
+ });
1478
+ isMounted = true;
1479
+ initialFrag.appendChild(marker);
1480
+ onCleanup(() => {
1481
+ for (const rec of items) {
1482
+ rec.scope.dispose();
1483
+ }
1484
+ if (fallbackScope) {
1485
+ fallbackScope.dispose();
1486
+ }
1487
+ });
1488
+ return initialFrag;
1489
+ }
1490
+ function Portal(props) {
1491
+ if (typeof document === "undefined") {
1492
+ return null;
1493
+ }
1494
+ const marker = document.createTextNode("");
1495
+ let currentScope = null;
1496
+ let nodes = [];
1497
+ effect(() => {
1498
+ const target = props.mount ?? (typeof document !== "undefined" ? document.body : null);
1499
+ if (!target)
1500
+ return;
1501
+ if (currentScope) {
1502
+ currentScope.dispose();
1503
+ currentScope = null;
1504
+ }
1505
+ for (const node of nodes) {
1506
+ if (node.parentNode) {
1507
+ node.parentNode.removeChild(node);
1508
+ }
1509
+ }
1510
+ nodes = [];
1511
+ currentScope = new Scope(getActiveScope());
1512
+ untrack(() => {
1513
+ runInScope(currentScope, () => {
1514
+ const childRes = typeof props.children === "function" ? props.children() : props.children;
1515
+ const frag = document.createDocumentFragment();
1516
+ insertChild(frag, childRes);
1517
+ nodes = Array.from(frag.childNodes);
1518
+ target.appendChild(frag);
1519
+ });
1520
+ });
1521
+ });
1522
+ onCleanup(() => {
1523
+ if (currentScope) {
1524
+ currentScope.dispose();
1525
+ currentScope = null;
1526
+ }
1527
+ for (const node of nodes) {
1528
+ if (node.parentNode) {
1529
+ node.parentNode.removeChild(node);
1530
+ }
1531
+ }
1532
+ nodes = [];
1533
+ });
1534
+ return marker;
1535
+ }
1536
+ // src/jsx-runtime/index.ts
1537
+ var SVG_NS = "http://www.w3.org/2000/svg";
1538
+ var SVG_TAGS = new Set([
1539
+ "svg",
1540
+ "path",
1541
+ "circle",
1542
+ "rect",
1543
+ "g",
1544
+ "line",
1545
+ "polyline",
1546
+ "polygon",
1547
+ "text",
1548
+ "defs",
1549
+ "clipPath",
1550
+ "linearGradient",
1551
+ "radialGradient",
1552
+ "stop"
1553
+ ]);
1554
+ function Fragment(props) {
1555
+ if (typeof document === "undefined") {
1556
+ return props.children !== undefined ? props.children : [];
1557
+ }
1558
+ const fragment = document.createDocumentFragment();
1559
+ if (props.children !== undefined) {
1560
+ insertChild(fragment, props.children);
1561
+ }
1562
+ return fragment;
1563
+ }
1564
+ function jsx(type, props = {}, key) {
1565
+ if (typeof type === "function") {
1566
+ return type(props, key);
1567
+ }
1568
+ if (typeof type === "string") {
1569
+ const { children, ...restProps } = props;
1570
+ if (typeof document === "undefined") {
1571
+ const attributes = new Map;
1572
+ for (const propName in restProps) {
1573
+ const val = restProps[propName];
1574
+ if (propName === "className" || propName === "class") {
1575
+ const resolved = typeof val === "function" ? val() : val;
1576
+ if (resolved)
1577
+ attributes.set("class", resolved);
1578
+ } else if (propName === "style") {
1579
+ const val = restProps[propName];
1580
+ const resolved = resolveValue(val);
1581
+ if (typeof resolved === "string") {
1582
+ attributes.set("style", resolved);
1583
+ } else if (typeof resolved === "object" && resolved !== null) {
1584
+ const styleStr = Object.entries(resolved).map(([k, v]) => {
1585
+ const finalVal = resolveValue(v);
1586
+ const formatted = formatStyleProp(k, finalVal);
1587
+ if (!formatted)
1588
+ return "";
1589
+ const kebab = k.startsWith("--") ? k : k.replace(/([A-Z])/g, "-$1").toLowerCase();
1590
+ return `${kebab}: ${formatted}`;
1591
+ }).filter(Boolean).join("; ");
1592
+ if (styleStr)
1593
+ attributes.set("style", styleStr);
1594
+ }
1595
+ } else if (!propName.startsWith("on")) {
1596
+ const resolved = typeof val === "function" ? val() : val;
1597
+ if (resolved === true) {
1598
+ attributes.set(propName, propName);
1599
+ } else if (resolved !== false && resolved !== null && resolved !== undefined) {
1600
+ attributes.set(propName, resolved);
1601
+ }
1602
+ }
1603
+ }
1604
+ const childNodes = children !== undefined ? Array.isArray(children) ? children : [children] : [];
1605
+ return {
1606
+ tagName: type,
1607
+ attributes,
1608
+ childNodes
1609
+ };
1610
+ }
1611
+ const isSvg = SVG_TAGS.has(type);
1612
+ const element = isSvg ? document.createElementNS(SVG_NS, type) : document.createElement(type);
1613
+ for (const propName in restProps) {
1614
+ setAttribute(element, propName, restProps[propName]);
1615
+ }
1616
+ if (children !== undefined) {
1617
+ insertChild(element, children);
1618
+ }
1619
+ return element;
1620
+ }
1621
+ return type;
1622
+ }
1623
+ var jsxs = jsx;
1624
+ var jsxDEV = jsx;
1625
+
1626
+ // src/router/router.tsx
1627
+ var RouterContext = createContext(null);
1628
+ function compilePath(path) {
1629
+ const paramNames = [];
1630
+ const normalized = path.replace(/\/+$/, "") || "/";
1631
+ const regexStr = normalized.replace(/:([a-zA-Z0-9_]+)/g, (_, name) => {
1632
+ paramNames.push(name);
1633
+ return "([^/]+)";
1634
+ }).replace(/\*/g, "(.*)");
1635
+ const matcher = new RegExp(`^${regexStr}(?:/)?$`);
1636
+ return { matcher, paramNames };
1637
+ }
1638
+ function matchRoute(routes, pathname, base = "") {
1639
+ const cleanPath = base && pathname.startsWith(base) ? pathname.slice(base.length) || "/" : pathname;
1640
+ for (const route of routes) {
1641
+ const match = cleanPath.match(route.matcher);
1642
+ if (match) {
1643
+ const params = {};
1644
+ const captures = match.slice(1);
1645
+ route.paramNames.forEach((name, i) => {
1646
+ params[name] = decodeURIComponent(captures[i] ?? "");
1647
+ });
1648
+ return {
1649
+ path: route.path,
1650
+ params,
1651
+ component: route.component,
1652
+ children: route.children
1653
+ };
1654
+ }
1655
+ }
1656
+ return null;
1657
+ }
1658
+ function Router(props) {
1659
+ const base = props.base ?? "";
1660
+ const mode = props.mode ?? "history";
1661
+ const getPathname = () => {
1662
+ if (typeof window === "undefined" || !window.location)
1663
+ return "/";
1664
+ if (mode === "hash") {
1665
+ const hash = window.location.hash.slice(1) || "/";
1666
+ return hash.split("?")[0] || "/";
1667
+ }
1668
+ return window.location.pathname || "/";
1669
+ };
1670
+ const getSearch = () => {
1671
+ if (typeof window === "undefined" || !window.location)
1672
+ return "";
1673
+ if (mode === "hash") {
1674
+ const hash = window.location.hash.slice(1);
1675
+ const queryIdx = hash.indexOf("?");
1676
+ return queryIdx !== -1 ? hash.slice(queryIdx) : "";
1677
+ }
1678
+ return window.location.search || "";
1679
+ };
1680
+ const getHash = () => {
1681
+ if (typeof window === "undefined" || !window.location)
1682
+ return "";
1683
+ return window.location.hash || "";
1684
+ };
1685
+ const pathname = signal(getPathname());
1686
+ const search = signal(getSearch());
1687
+ const hash = signal(getHash());
1688
+ const routes = [];
1689
+ const registeredRoutes = signal([]);
1690
+ const registerRoute = (route) => {
1691
+ routes.push(route);
1692
+ registeredRoutes.set([...routes]);
1693
+ };
1694
+ const syncLocation = () => {
1695
+ pathname.set(getPathname());
1696
+ search.set(getSearch());
1697
+ hash.set(getHash());
1698
+ };
1699
+ if (typeof window !== "undefined") {
1700
+ const eventName = mode === "hash" ? "hashchange" : "popstate";
1701
+ window.addEventListener(eventName, syncLocation);
1702
+ onCleanup(() => window.removeEventListener(eventName, syncLocation));
1703
+ }
1704
+ const navigate = (to, options) => {
1705
+ if (typeof window === "undefined" || !window.history) {
1706
+ pathname.set(to);
1707
+ return;
1708
+ }
1709
+ const target = base ? `${base.replace(/\/$/, "")}/${to.replace(/^\//, "")}` : to;
1710
+ if (mode === "hash") {
1711
+ if (options?.replace) {
1712
+ window.location.replace(`#${to}`);
1713
+ } else {
1714
+ window.location.hash = `#${to}`;
1715
+ }
1716
+ } else {
1717
+ if (options?.replace) {
1718
+ window.history.replaceState(null, "", target);
1719
+ } else {
1720
+ window.history.pushState(null, "", target);
1721
+ }
1722
+ }
1723
+ syncLocation();
1724
+ };
1725
+ const matchedRoute = computed(() => {
1726
+ const currentPath = pathname();
1727
+ const routeList = registeredRoutes();
1728
+ return matchRoute(routeList, currentPath, base);
1729
+ });
1730
+ const params = computed(() => matchedRoute()?.params ?? {});
1731
+ const routerValue = {
1732
+ location: { pathname, search, hash },
1733
+ navigate,
1734
+ params,
1735
+ base,
1736
+ matchedRoute,
1737
+ routes,
1738
+ registerRoute
1739
+ };
1740
+ return RouterContext.Provider({
1741
+ value: routerValue,
1742
+ children: props.children
1743
+ });
1744
+ }
1745
+ function Route(props) {
1746
+ const router = useContext(RouterContext);
1747
+ if (!router) {
1748
+ throw new Error("<Route> must be rendered inside a <Router>");
1749
+ }
1750
+ const { matcher, paramNames } = compilePath(props.path);
1751
+ router.registerRoute({
1752
+ path: props.path,
1753
+ component: props.component,
1754
+ children: props.children,
1755
+ matcher,
1756
+ paramNames
1757
+ });
1758
+ return null;
1759
+ }
1760
+ function Routes(props) {
1761
+ const router = useContext(RouterContext);
1762
+ if (!router) {
1763
+ throw new Error("<Routes> must be rendered inside a <Router>");
1764
+ }
1765
+ const _ = typeof props.children === "function" ? props.children() : props.children;
1766
+ return Show({
1767
+ when: () => router.matchedRoute() !== null,
1768
+ fallback: props.fallback ?? (() => document.createTextNode("404 Not Found")),
1769
+ children: () => {
1770
+ const match = router.matchedRoute();
1771
+ if (!match)
1772
+ return null;
1773
+ if (match.component) {
1774
+ return match.component({ params: match.params });
1775
+ }
1776
+ return match.children ?? null;
1777
+ }
1778
+ });
1779
+ }
1780
+ function Link(props) {
1781
+ const router = useContext(RouterContext);
1782
+ const { href, class: className, activeClass = "active", replace, children, ...rest } = props;
1783
+ const handleClick = (e) => {
1784
+ if (e.ctrlKey || e.metaKey || e.altKey || e.shiftKey || e.button !== 0) {
1785
+ return;
1786
+ }
1787
+ e.preventDefault();
1788
+ if (router) {
1789
+ router.navigate(href, { replace });
1790
+ } else if (typeof window !== "undefined") {
1791
+ window.location.href = href;
1792
+ }
1793
+ };
1794
+ const isActive = computed(() => {
1795
+ if (!router)
1796
+ return false;
1797
+ const current = router.location.pathname();
1798
+ return current === href || href !== "/" && current.startsWith(href);
1799
+ });
1800
+ const computedClass = computed(() => {
1801
+ const baseCls = typeof className === "function" ? className() : className ?? "";
1802
+ if (activeClass && isActive()) {
1803
+ return baseCls ? `${baseCls} ${activeClass}` : activeClass;
1804
+ }
1805
+ return baseCls;
1806
+ });
1807
+ return /* @__PURE__ */ jsx("a", {
1808
+ href,
1809
+ class: computedClass,
1810
+ onClick: handleClick,
1811
+ ...rest,
1812
+ children
1813
+ });
1814
+ }
1815
+ function useLocation() {
1816
+ const router = useContext(RouterContext);
1817
+ if (!router)
1818
+ throw new Error("useLocation must be used within a <Router>");
1819
+ return router.location;
1820
+ }
1821
+ function useNavigate() {
1822
+ const router = useContext(RouterContext);
1823
+ if (!router)
1824
+ throw new Error("useNavigate must be used within a <Router>");
1825
+ return router.navigate;
1826
+ }
1827
+ function useParams() {
1828
+ const router = useContext(RouterContext);
1829
+ if (!router)
1830
+ throw new Error("useParams must be used within a <Router>");
1831
+ return () => router.params();
1832
+ }
1833
+ function useSearchParams() {
1834
+ const router = useContext(RouterContext);
1835
+ if (!router)
1836
+ throw new Error("useSearchParams must be used within a <Router>");
1837
+ const params = computed(() => new URLSearchParams(router.location.search()));
1838
+ const setSearchParams = (next) => {
1839
+ const sp = next instanceof URLSearchParams ? next : new URLSearchParams(next);
1840
+ const queryString = sp.toString();
1841
+ const newUrl = `${router.location.pathname()}${queryString ? `?${queryString}` : ""}${router.location.hash()}`;
1842
+ router.navigate(newUrl);
1843
+ };
1844
+ return [params, setSearchParams];
1845
+ }
1846
+ export {
1847
+ Link,
1848
+ Route,
1849
+ Router,
1850
+ Routes,
1851
+ lazy,
1852
+ useLocation,
1853
+ useNavigate,
1854
+ useParams,
1855
+ useSearchParams
1856
+ };