@vertz/ui 0.2.21 → 0.2.23

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.
@@ -1,20 +1,23 @@
1
1
  import {
2
2
  __classList,
3
- __on
4
- } from "./chunk-kjwp5q5s.js";
3
+ __on,
4
+ beginDeferringMounts,
5
+ discardDeferredMounts,
6
+ flushDeferredMounts
7
+ } from "./chunk-2kyhn86t.js";
5
8
  import {
6
9
  __append,
7
10
  __element,
8
11
  __enterChildren,
9
12
  __exitChildren,
10
13
  __staticText
11
- } from "./chunk-vwz86vg9.js";
14
+ } from "./chunk-13tvh4wq.js";
12
15
  import {
13
16
  RouterContext
14
- } from "./chunk-4cmt1ve8.js";
17
+ } from "./chunk-f4d5nphq.js";
15
18
  import {
16
19
  isBrowser
17
- } from "./chunk-bybgyjye.js";
20
+ } from "./chunk-da2w7j7w.js";
18
21
  import {
19
22
  _tryOnCleanup,
20
23
  createContext,
@@ -29,7 +32,7 @@ import {
29
32
  startHydration,
30
33
  untrack,
31
34
  useContext
32
- } from "./chunk-2qe6aqhb.js";
35
+ } from "./chunk-656n0x6y.js";
33
36
 
34
37
  // src/router/link.ts
35
38
  var DANGEROUS_SCHEMES = ["javascript:", "data:", "vbscript:"];
@@ -191,32 +194,43 @@ function Outlet() {
191
194
  return;
192
195
  let node;
193
196
  childCleanups = pushScope();
194
- if (wasHydrating) {
195
- startHydration(container);
196
- try {
197
+ try {
198
+ if (wasHydrating) {
199
+ beginDeferringMounts();
200
+ startHydration(container);
201
+ let miniHydrationOk = false;
202
+ try {
203
+ RouterContext.Provider(router, () => {
204
+ node = mod.default();
205
+ __append(container, node);
206
+ });
207
+ miniHydrationOk = true;
208
+ } finally {
209
+ endHydration();
210
+ if (miniHydrationOk) {
211
+ flushDeferredMounts();
212
+ } else {
213
+ discardDeferredMounts();
214
+ }
215
+ }
216
+ if (!container.contains(node)) {
217
+ while (container.firstChild) {
218
+ container.removeChild(container.firstChild);
219
+ }
220
+ container.appendChild(node);
221
+ }
222
+ } else {
223
+ while (container.firstChild) {
224
+ container.removeChild(container.firstChild);
225
+ }
197
226
  RouterContext.Provider(router, () => {
198
227
  node = mod.default();
199
228
  __append(container, node);
200
229
  });
201
- } finally {
202
- endHydration();
203
- }
204
- if (!container.contains(node)) {
205
- while (container.firstChild) {
206
- container.removeChild(container.firstChild);
207
- }
208
- container.appendChild(node);
209
- }
210
- } else {
211
- while (container.firstChild) {
212
- container.removeChild(container.firstChild);
213
230
  }
214
- RouterContext.Provider(router, () => {
215
- node = mod.default();
216
- __append(container, node);
217
- });
231
+ } finally {
232
+ popScope();
218
233
  }
219
- popScope();
220
234
  });
221
235
  } else {
222
236
  __append(container, result);
@@ -304,32 +318,43 @@ function RouterView({ router, fallback }) {
304
318
  return;
305
319
  let node;
306
320
  pageCleanups = pushScope();
307
- if (wasHydrating) {
308
- startHydration(container);
309
- try {
310
- RouterContext.Provider(router, () => {
311
- node = mod.default();
312
- __append(container, node);
313
- });
314
- } finally {
315
- endHydration();
316
- }
317
- if (!container.contains(node)) {
321
+ try {
322
+ if (wasHydrating) {
323
+ beginDeferringMounts();
324
+ startHydration(container);
325
+ let miniHydrationOk = false;
326
+ try {
327
+ RouterContext.Provider(router, () => {
328
+ node = mod.default();
329
+ __append(container, node);
330
+ });
331
+ miniHydrationOk = true;
332
+ } finally {
333
+ endHydration();
334
+ if (miniHydrationOk) {
335
+ flushDeferredMounts();
336
+ } else {
337
+ discardDeferredMounts();
338
+ }
339
+ }
340
+ if (!container.contains(node)) {
341
+ while (container.firstChild) {
342
+ container.removeChild(container.firstChild);
343
+ }
344
+ container.appendChild(node);
345
+ }
346
+ } else {
318
347
  while (container.firstChild) {
319
348
  container.removeChild(container.firstChild);
320
349
  }
321
- container.appendChild(node);
322
- }
323
- } else {
324
- while (container.firstChild) {
325
- container.removeChild(container.firstChild);
350
+ RouterContext.Provider(router, () => {
351
+ node = mod.default();
352
+ container.appendChild(node);
353
+ });
326
354
  }
327
- RouterContext.Provider(router, () => {
328
- node = mod.default();
329
- container.appendChild(node);
330
- });
355
+ } finally {
356
+ popScope();
331
357
  }
332
- popScope();
333
358
  });
334
359
  } else {
335
360
  __append(container, result);
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  getAdapter,
8
8
  isRenderNode
9
- } from "./chunk-c61572xp.js";
9
+ } from "./chunk-2y9f9j62.js";
10
10
  import {
11
11
  claimElement,
12
12
  claimText,
@@ -16,8 +16,11 @@ import {
16
16
  exitChildren,
17
17
  getIsHydrating,
18
18
  pauseHydration,
19
- resumeHydration
20
- } from "./chunk-2qe6aqhb.js";
19
+ popScope,
20
+ pushScope,
21
+ resumeHydration,
22
+ runCleanups
23
+ } from "./chunk-656n0x6y.js";
21
24
 
22
25
  // src/dom/element.ts
23
26
  var MAX_THUNK_DEPTH = 100;
@@ -73,20 +76,33 @@ function __child(fn) {
73
76
  }
74
77
  pauseHydration();
75
78
  try {
79
+ let childCleanups2 = [];
76
80
  wrapper.dispose = domEffect(() => {
77
- const value = fn();
78
- if (isRenderNode(value) && wrapper.childNodes.length === 1 && wrapper.firstChild === value) {
79
- return;
80
- }
81
- if (!isRenderNode(value) && value != null && typeof value !== "boolean" && wrapper.childNodes.length === 1 && wrapper.firstChild.nodeType === 3) {
82
- const text = typeof value === "string" ? value : String(value);
83
- wrapper.firstChild.data = text;
84
- return;
85
- }
86
- while (wrapper.firstChild) {
87
- wrapper.removeChild(wrapper.firstChild);
81
+ runCleanups(childCleanups2);
82
+ const needsPause = getIsHydrating();
83
+ if (needsPause)
84
+ pauseHydration();
85
+ try {
86
+ const scope = pushScope();
87
+ const value = fn();
88
+ popScope();
89
+ childCleanups2 = scope;
90
+ if (isRenderNode(value) && wrapper.childNodes.length === 1 && wrapper.firstChild === value) {
91
+ return;
92
+ }
93
+ if (!isRenderNode(value) && value != null && typeof value !== "boolean" && wrapper.childNodes.length === 1 && wrapper.firstChild.nodeType === 3) {
94
+ const text = typeof value === "string" ? value : String(value);
95
+ wrapper.firstChild.data = text;
96
+ return;
97
+ }
98
+ while (wrapper.firstChild) {
99
+ wrapper.removeChild(wrapper.firstChild);
100
+ }
101
+ resolveAndAppend(wrapper, value);
102
+ } finally {
103
+ if (needsPause)
104
+ resumeHydration();
88
105
  }
89
- resolveAndAppend(wrapper, value);
90
106
  });
91
107
  } finally {
92
108
  resumeHydration();
@@ -96,8 +112,13 @@ function __child(fn) {
96
112
  }
97
113
  wrapper = getAdapter().createElement("span");
98
114
  wrapper.style.display = "contents";
115
+ let childCleanups = [];
99
116
  wrapper.dispose = domEffect(() => {
117
+ runCleanups(childCleanups);
118
+ const scope = pushScope();
100
119
  const value = fn();
120
+ popScope();
121
+ childCleanups = scope;
101
122
  if (isRenderNode(value) && wrapper.childNodes.length === 1 && wrapper.firstChild === value) {
102
123
  return;
103
124
  }
@@ -0,0 +1,160 @@
1
+ import {
2
+ styleObjectToString
3
+ } from "./chunk-4xkw6h1s.js";
4
+ import {
5
+ _tryOnCleanup,
6
+ deferredDomEffect,
7
+ getSSRContext,
8
+ popScope,
9
+ pushScope,
10
+ runCleanups,
11
+ untrack
12
+ } from "./chunk-656n0x6y.js";
13
+
14
+ // src/component/lifecycle.ts
15
+ var mountFrames = [];
16
+ var postHydrationQueue = null;
17
+ function __pushMountFrame() {
18
+ mountFrames.push([]);
19
+ return mountFrames.length;
20
+ }
21
+ function __flushMountFrame() {
22
+ const frame = mountFrames.pop();
23
+ if (!frame)
24
+ return;
25
+ if (postHydrationQueue) {
26
+ for (const cb of frame) {
27
+ postHydrationQueue.push(cb);
28
+ }
29
+ return;
30
+ }
31
+ let firstError;
32
+ for (const cb of frame) {
33
+ try {
34
+ cb();
35
+ } catch (e) {
36
+ if (firstError === undefined)
37
+ firstError = e;
38
+ }
39
+ }
40
+ if (firstError !== undefined)
41
+ throw firstError;
42
+ }
43
+ function __discardMountFrame(expectedDepth) {
44
+ if (mountFrames.length === expectedDepth) {
45
+ mountFrames.pop();
46
+ }
47
+ }
48
+ function beginDeferringMounts() {
49
+ if (!postHydrationQueue) {
50
+ postHydrationQueue = [];
51
+ }
52
+ }
53
+ function flushDeferredMounts() {
54
+ const queue = postHydrationQueue;
55
+ postHydrationQueue = null;
56
+ if (!queue)
57
+ return;
58
+ let firstError;
59
+ for (const cb of queue) {
60
+ try {
61
+ cb();
62
+ } catch (e) {
63
+ if (firstError === undefined)
64
+ firstError = e;
65
+ }
66
+ }
67
+ if (firstError !== undefined)
68
+ throw firstError;
69
+ }
70
+ function discardDeferredMounts() {
71
+ postHydrationQueue = null;
72
+ }
73
+ function onMount(callback) {
74
+ if (getSSRContext())
75
+ return;
76
+ const frame = mountFrames[mountFrames.length - 1];
77
+ if (frame) {
78
+ frame.push(() => executeOnMount(callback));
79
+ } else {
80
+ executeOnMount(callback);
81
+ }
82
+ }
83
+ function executeOnMount(callback) {
84
+ const scope = pushScope();
85
+ try {
86
+ const cleanup = untrack(callback);
87
+ if (typeof cleanup === "function") {
88
+ _tryOnCleanup(cleanup);
89
+ }
90
+ } finally {
91
+ popScope();
92
+ if (scope.length > 0) {
93
+ _tryOnCleanup(() => runCleanups(scope));
94
+ }
95
+ }
96
+ }
97
+
98
+ // src/dom/attributes.ts
99
+ function __attr(el, name, fn) {
100
+ return deferredDomEffect(() => {
101
+ const value = fn();
102
+ if (value == null || value === false) {
103
+ el.removeAttribute(name);
104
+ } else if (value === true) {
105
+ el.setAttribute(name, "");
106
+ } else if (name === "style" && typeof value === "object") {
107
+ el.setAttribute(name, styleObjectToString(value));
108
+ } else {
109
+ el.setAttribute(name, value);
110
+ }
111
+ });
112
+ }
113
+ function __prop(el, name, fn) {
114
+ return deferredDomEffect(() => {
115
+ const value = fn();
116
+ if (value == null) {
117
+ Reflect.set(el, name, typeof Reflect.get(el, name) === "boolean" ? false : "");
118
+ } else {
119
+ Reflect.set(el, name, value);
120
+ }
121
+ if (name === "selected") {
122
+ if (value) {
123
+ el.setAttribute(name, "");
124
+ } else {
125
+ el.removeAttribute(name);
126
+ }
127
+ }
128
+ });
129
+ }
130
+ function __show(el, fn) {
131
+ const originalDisplay = el.style.display;
132
+ return deferredDomEffect(() => {
133
+ el.style.display = fn() ? originalDisplay : "none";
134
+ });
135
+ }
136
+ function __classList(el, classMap) {
137
+ const disposers = [];
138
+ for (const [className, fn] of Object.entries(classMap)) {
139
+ disposers.push(deferredDomEffect(() => {
140
+ if (fn()) {
141
+ el.classList.add(className);
142
+ } else {
143
+ el.classList.remove(className);
144
+ }
145
+ }));
146
+ }
147
+ return () => {
148
+ for (const dispose of disposers) {
149
+ dispose();
150
+ }
151
+ };
152
+ }
153
+
154
+ // src/dom/events.ts
155
+ function __on(el, event, handler) {
156
+ el.addEventListener(event, handler);
157
+ return () => el.removeEventListener(event, handler);
158
+ }
159
+
160
+ export { __pushMountFrame, __flushMountFrame, __discardMountFrame, beginDeferringMounts, flushDeferredMounts, discardDeferredMounts, onMount, __attr, __prop, __show, __classList, __on };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getSSRContext
3
- } from "./chunk-2qe6aqhb.js";
3
+ } from "./chunk-656n0x6y.js";
4
4
 
5
5
  // src/dom/dom-adapter.ts
6
6
  function createDOMAdapter() {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  computed,
3
3
  signal
4
- } from "./chunk-2qe6aqhb.js";
4
+ } from "./chunk-656n0x6y.js";
5
5
 
6
6
  // src/form/field-state.ts
7
7
  function createFieldState(_name, initialValue) {
@@ -188,52 +188,6 @@ function runCleanups(cleanups) {
188
188
  cleanups.length = 0;
189
189
  }
190
190
 
191
- // src/runtime/tracking.ts
192
- var currentSubscriber = null;
193
- var readValueCallback = null;
194
- function getSubscriber() {
195
- const ctx = getSSRContext();
196
- if (ctx)
197
- return ctx.subscriber;
198
- return currentSubscriber;
199
- }
200
- function setSubscriber(sub) {
201
- const ctx = getSSRContext();
202
- if (ctx) {
203
- const prev2 = ctx.subscriber;
204
- ctx.subscriber = sub;
205
- return prev2;
206
- }
207
- const prev = currentSubscriber;
208
- currentSubscriber = sub;
209
- return prev;
210
- }
211
- function getReadValueCallback() {
212
- const ctx = getSSRContext();
213
- if (ctx)
214
- return ctx.readValueCb;
215
- return readValueCallback;
216
- }
217
- function setReadValueCallback(cb) {
218
- const ctx = getSSRContext();
219
- if (ctx) {
220
- const prev2 = ctx.readValueCb;
221
- ctx.readValueCb = cb;
222
- return prev2;
223
- }
224
- const prev = readValueCallback;
225
- readValueCallback = cb;
226
- return prev;
227
- }
228
- function untrack(fn) {
229
- const prev = setSubscriber(null);
230
- try {
231
- return fn();
232
- } finally {
233
- setSubscriber(prev);
234
- }
235
- }
236
-
237
191
  // src/runtime/scheduler.ts
238
192
  var batchDepth = 0;
239
193
  var pendingEffects = new Map;
@@ -285,6 +239,52 @@ function batch(fn) {
285
239
  }
286
240
  }
287
241
 
242
+ // src/runtime/tracking.ts
243
+ var currentSubscriber = null;
244
+ var readValueCallback = null;
245
+ function getSubscriber() {
246
+ const ctx = getSSRContext();
247
+ if (ctx)
248
+ return ctx.subscriber;
249
+ return currentSubscriber;
250
+ }
251
+ function setSubscriber(sub) {
252
+ const ctx = getSSRContext();
253
+ if (ctx) {
254
+ const prev2 = ctx.subscriber;
255
+ ctx.subscriber = sub;
256
+ return prev2;
257
+ }
258
+ const prev = currentSubscriber;
259
+ currentSubscriber = sub;
260
+ return prev;
261
+ }
262
+ function getReadValueCallback() {
263
+ const ctx = getSSRContext();
264
+ if (ctx)
265
+ return ctx.readValueCb;
266
+ return readValueCallback;
267
+ }
268
+ function setReadValueCallback(cb) {
269
+ const ctx = getSSRContext();
270
+ if (ctx) {
271
+ const prev2 = ctx.readValueCb;
272
+ ctx.readValueCb = cb;
273
+ return prev2;
274
+ }
275
+ const prev = readValueCallback;
276
+ readValueCallback = cb;
277
+ return prev;
278
+ }
279
+ function untrack(fn) {
280
+ const prev = setSubscriber(null);
281
+ try {
282
+ return fn();
283
+ } finally {
284
+ setSubscriber(prev);
285
+ }
286
+ }
287
+
288
288
  // src/hydrate/hydration-context.ts
289
289
  var isHydrating = false;
290
290
  var currentNode = null;
@@ -374,7 +374,7 @@ function claimElement(tag) {
374
374
  while (currentNode) {
375
375
  if (currentNode.nodeType === Node.ELEMENT_NODE) {
376
376
  const el = currentNode;
377
- if (el.tagName === upperTag) {
377
+ if (el.tagName.toUpperCase() === upperTag) {
378
378
  if (isDebug()) {
379
379
  const id = el.id ? `#${el.id}` : "";
380
380
  const cls = el.className ? `.${el.className.split(" ")[0]}` : "";
@@ -716,4 +716,4 @@ function lifecycleEffect(fn) {
716
716
  return dispose;
717
717
  }
718
718
 
719
- export { registerSSRResolver, getSSRContext, hasSSRResolver, createContext, useContext, getContextScope, setContextScope, DisposalScopeError, onCleanup, _tryOnCleanup, pushScope, popScope, runCleanups, setReadValueCallback, untrack, startHydration, endHydration, discardDeferredEffects, getIsHydrating, pauseHydration, resumeHydration, claimElement, claimText, claimComment, enterChildren, exitChildren, batch, startSignalCollection, stopSignalCollection, signal, computed, domEffect, deferredDomEffect, lifecycleEffect };
719
+ export { registerSSRResolver, getSSRContext, hasSSRResolver, createContext, useContext, getContextScope, setContextScope, startHydration, endHydration, discardDeferredEffects, getIsHydrating, pauseHydration, resumeHydration, claimElement, claimText, claimComment, enterChildren, exitChildren, DisposalScopeError, onCleanup, _tryOnCleanup, pushScope, popScope, runCleanups, batch, setReadValueCallback, untrack, startSignalCollection, stopSignalCollection, signal, computed, domEffect, deferredDomEffect, lifecycleEffect };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  hasSSRResolver
3
- } from "./chunk-2qe6aqhb.js";
3
+ } from "./chunk-656n0x6y.js";
4
4
 
5
5
  // src/env/is-browser.ts
6
6
  function isBrowser() {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createContext,
3
3
  useContext
4
- } from "./chunk-2qe6aqhb.js";
4
+ } from "./chunk-656n0x6y.js";
5
5
 
6
6
  // src/router/router-context.ts
7
7
  var RouterContext = createContext(undefined, "@vertz/ui::RouterContext");
@@ -4,10 +4,10 @@ import {
4
4
  import {
5
5
  getAdapter,
6
6
  isRenderNode
7
- } from "./chunk-c61572xp.js";
7
+ } from "./chunk-2y9f9j62.js";
8
8
  import {
9
9
  isBrowser
10
- } from "./chunk-bybgyjye.js";
10
+ } from "./chunk-da2w7j7w.js";
11
11
  import {
12
12
  _tryOnCleanup,
13
13
  batch,
@@ -21,7 +21,7 @@ import {
21
21
  setReadValueCallback,
22
22
  signal,
23
23
  untrack
24
- } from "./chunk-2qe6aqhb.js";
24
+ } from "./chunk-656n0x6y.js";
25
25
 
26
26
  // src/query/cache.ts
27
27
  class MemoryCache {
@@ -7,11 +7,11 @@ import {
7
7
  } from "./chunk-jrtrk5z4.js";
8
8
  import {
9
9
  isBrowser
10
- } from "./chunk-bybgyjye.js";
10
+ } from "./chunk-da2w7j7w.js";
11
11
  import {
12
12
  getSSRContext,
13
13
  signal
14
- } from "./chunk-2qe6aqhb.js";
14
+ } from "./chunk-656n0x6y.js";
15
15
 
16
16
  // src/router/view-transitions.ts
17
17
  var transitionGen = 0;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  injectCSS
3
- } from "./chunk-pq8khh47.js";
3
+ } from "./chunk-xhc7arn9.js";
4
4
 
5
5
  // src/dom/animation.ts
6
6
  function onAnimationsComplete(el, callback) {