@vertz/ui 0.2.23 → 0.2.24
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.
- package/dist/shared/{chunk-p3fz6qqp.js → chunk-18frwfc4.js} +1 -1
- package/dist/shared/chunk-2eh4p2n7.js +39 -0
- package/dist/shared/{chunk-016m1fq0.js → chunk-2wag9c7v.js} +116 -12
- package/dist/shared/{chunk-g6fb5yc2.js → chunk-4gen306a.js} +209 -152
- package/dist/shared/{chunk-2kyhn86t.js → chunk-ge2e6y2s.js} +4 -62
- package/dist/shared/{chunk-4xkw6h1s.js → chunk-h1fsr8kv.js} +67 -1
- package/dist/shared/{chunk-13tvh4wq.js → chunk-mbnda3pv.js} +60 -3
- package/dist/shared/{chunk-xhc7arn9.js → chunk-t3rnfxc0.js} +13 -11
- package/dist/src/auth/public.d.ts +35 -1
- package/dist/src/auth/public.js +69 -0
- package/dist/src/components/index.d.ts +2 -2
- package/dist/src/components/index.js +51 -46
- package/dist/src/css/public.d.ts +5 -1
- package/dist/src/css/public.js +3 -3
- package/dist/src/index.d.ts +139 -12
- package/dist/src/index.js +332 -126
- package/dist/src/internals.d.ts +35 -6
- package/dist/src/internals.js +106 -26
- package/dist/src/jsx-runtime/index.js +3 -5
- package/dist/src/query/public.d.ts +7 -3
- package/dist/src/query/public.js +2 -1
- package/dist/src/router/public.d.ts +27 -4
- package/dist/src/router/public.js +4 -5
- package/dist/src/test/index.d.ts +12 -3
- package/package.json +4 -3
- package/reactivity.json +1 -1
- package/dist/shared/chunk-prj7nm08.js +0 -67
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSSRContext
|
|
3
|
+
} from "./chunk-656n0x6y.js";
|
|
4
|
+
|
|
5
|
+
// src/query/invalidate.ts
|
|
6
|
+
var registry = new Set;
|
|
7
|
+
function registerActiveQuery(entityMeta, refetch, clearData) {
|
|
8
|
+
const registration = { entityMeta, refetch, clearData };
|
|
9
|
+
registry.add(registration);
|
|
10
|
+
return () => registry.delete(registration);
|
|
11
|
+
}
|
|
12
|
+
function invalidate(descriptor) {
|
|
13
|
+
const meta = descriptor._entity;
|
|
14
|
+
if (!meta)
|
|
15
|
+
return;
|
|
16
|
+
if (meta.kind === "get" && !meta.id)
|
|
17
|
+
return;
|
|
18
|
+
for (const reg of [...registry]) {
|
|
19
|
+
if (reg.entityMeta.entityType !== meta.entityType)
|
|
20
|
+
continue;
|
|
21
|
+
if (reg.entityMeta.kind !== meta.kind)
|
|
22
|
+
continue;
|
|
23
|
+
if (meta.kind === "get" && reg.entityMeta.id !== meta.id)
|
|
24
|
+
continue;
|
|
25
|
+
reg.refetch();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function invalidateTenantQueries() {
|
|
29
|
+
if (getSSRContext() !== undefined)
|
|
30
|
+
return;
|
|
31
|
+
for (const reg of [...registry]) {
|
|
32
|
+
if (reg.entityMeta.tenantScoped !== true)
|
|
33
|
+
continue;
|
|
34
|
+
reg.clearData?.();
|
|
35
|
+
reg.refetch();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { registerActiveQuery, invalidate, invalidateTenantQueries };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
-
__classList,
|
|
3
2
|
__on,
|
|
4
3
|
beginDeferringMounts,
|
|
5
4
|
discardDeferredMounts,
|
|
6
5
|
flushDeferredMounts
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ge2e6y2s.js";
|
|
8
7
|
import {
|
|
9
8
|
__append,
|
|
9
|
+
__classList,
|
|
10
10
|
__element,
|
|
11
11
|
__enterChildren,
|
|
12
12
|
__exitChildren,
|
|
13
13
|
__staticText
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-mbnda3pv.js";
|
|
15
15
|
import {
|
|
16
16
|
RouterContext
|
|
17
17
|
} from "./chunk-f4d5nphq.js";
|
|
@@ -34,6 +34,64 @@ import {
|
|
|
34
34
|
useContext
|
|
35
35
|
} from "./chunk-656n0x6y.js";
|
|
36
36
|
|
|
37
|
+
// src/component/error-boundary-context.ts
|
|
38
|
+
var handlerStack = [];
|
|
39
|
+
function pushErrorHandler(handler) {
|
|
40
|
+
handlerStack.push(handler);
|
|
41
|
+
}
|
|
42
|
+
function popErrorHandler() {
|
|
43
|
+
handlerStack.pop();
|
|
44
|
+
}
|
|
45
|
+
function getCurrentErrorHandler() {
|
|
46
|
+
if (handlerStack.length === 0) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
return handlerStack[handlerStack.length - 1];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/component/error-boundary.ts
|
|
53
|
+
function toError(value) {
|
|
54
|
+
if (value instanceof Error) {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
return new Error(String(value));
|
|
58
|
+
}
|
|
59
|
+
function ErrorBoundary(props) {
|
|
60
|
+
function handleAsyncError(error, placeholder) {
|
|
61
|
+
const fallbackNode = props.fallback(error, retry);
|
|
62
|
+
function retry() {
|
|
63
|
+
try {
|
|
64
|
+
const retryResult = props.children();
|
|
65
|
+
if (fallbackNode.parentNode) {
|
|
66
|
+
fallbackNode.parentNode.replaceChild(retryResult, fallbackNode);
|
|
67
|
+
}
|
|
68
|
+
} catch (_retryThrown) {}
|
|
69
|
+
}
|
|
70
|
+
if (placeholder.parentNode) {
|
|
71
|
+
placeholder.parentNode.replaceChild(fallbackNode, placeholder);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
pushErrorHandler(handleAsyncError);
|
|
76
|
+
const result = props.children();
|
|
77
|
+
popErrorHandler();
|
|
78
|
+
return result;
|
|
79
|
+
} catch (thrown) {
|
|
80
|
+
let retry = function() {
|
|
81
|
+
try {
|
|
82
|
+
const retryResult = props.children();
|
|
83
|
+
if (fallbackNode.parentNode) {
|
|
84
|
+
fallbackNode.parentNode.replaceChild(retryResult, fallbackNode);
|
|
85
|
+
}
|
|
86
|
+
} catch (_retryThrown) {}
|
|
87
|
+
};
|
|
88
|
+
popErrorHandler();
|
|
89
|
+
const error = toError(thrown);
|
|
90
|
+
const fallbackNode = props.fallback(error, retry);
|
|
91
|
+
return fallbackNode;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
37
95
|
// src/router/link.ts
|
|
38
96
|
var DANGEROUS_SCHEMES = ["javascript:", "data:", "vbscript:"];
|
|
39
97
|
function isSafeUrl(url) {
|
|
@@ -256,12 +314,13 @@ function Outlet() {
|
|
|
256
314
|
}
|
|
257
315
|
|
|
258
316
|
// src/router/router-view.ts
|
|
259
|
-
function RouterView({ router, fallback }) {
|
|
317
|
+
function RouterView({ router, fallback, errorFallback }) {
|
|
260
318
|
const container = __element("div");
|
|
261
319
|
let isFirstHydrationRender = getIsHydrating();
|
|
262
320
|
let renderGen = 0;
|
|
263
321
|
let pageCleanups = [];
|
|
264
322
|
let prevLevels = [];
|
|
323
|
+
let prevParamsKey;
|
|
265
324
|
__enterChildren(container);
|
|
266
325
|
const dispose = domEffect(() => {
|
|
267
326
|
const match = router.current.value;
|
|
@@ -274,17 +333,23 @@ function RouterView({ router, fallback }) {
|
|
|
274
333
|
if (prevLevels[divergeAt].route !== newMatched[divergeAt].route)
|
|
275
334
|
break;
|
|
276
335
|
}
|
|
277
|
-
|
|
336
|
+
const currentParamsKey = match ? JSON.stringify(match.params) : undefined;
|
|
337
|
+
const chainIdentical = prevLevels.length > 0 && divergeAt === prevLevels.length && divergeAt === newMatched.length;
|
|
338
|
+
if (chainIdentical && prevParamsKey === currentParamsKey) {
|
|
278
339
|
return;
|
|
279
340
|
}
|
|
341
|
+
if (chainIdentical) {
|
|
342
|
+
divergeAt = 0;
|
|
343
|
+
}
|
|
280
344
|
if (divergeAt > 0 && newMatched.length > 0) {
|
|
281
345
|
const newLevels = buildLevels(newMatched);
|
|
282
|
-
const newChildFactory = buildInsideOutFactory(newMatched, newLevels, divergeAt, router);
|
|
346
|
+
const newChildFactory = buildInsideOutFactory(newMatched, newLevels, divergeAt, router, errorFallback);
|
|
283
347
|
const parentLevel = prevLevels[divergeAt - 1];
|
|
284
348
|
if (parentLevel.childSignal) {
|
|
285
349
|
parentLevel.childSignal.value = newChildFactory;
|
|
286
350
|
}
|
|
287
351
|
prevLevels = [...prevLevels.slice(0, divergeAt), ...newLevels.slice(divergeAt)];
|
|
352
|
+
prevParamsKey = currentParamsKey;
|
|
288
353
|
return;
|
|
289
354
|
}
|
|
290
355
|
runCleanups(pageCleanups);
|
|
@@ -299,6 +364,7 @@ function RouterView({ router, fallback }) {
|
|
|
299
364
|
pageCleanups = pushScope();
|
|
300
365
|
if (!match) {
|
|
301
366
|
prevLevels = [];
|
|
367
|
+
prevParamsKey = undefined;
|
|
302
368
|
if (fallback) {
|
|
303
369
|
container.appendChild(fallback());
|
|
304
370
|
}
|
|
@@ -306,7 +372,8 @@ function RouterView({ router, fallback }) {
|
|
|
306
372
|
return;
|
|
307
373
|
}
|
|
308
374
|
const levels = buildLevels(newMatched);
|
|
309
|
-
const rootFactory = buildInsideOutFactory(newMatched, levels, 0, router);
|
|
375
|
+
const rootFactory = buildInsideOutFactory(newMatched, levels, 0, router, errorFallback);
|
|
376
|
+
const lazyFallback = match ? match.route.errorComponent ?? errorFallback : undefined;
|
|
310
377
|
let asyncRoute = false;
|
|
311
378
|
RouterContext.Provider(router, () => {
|
|
312
379
|
const result = rootFactory();
|
|
@@ -352,11 +419,35 @@ function RouterView({ router, fallback }) {
|
|
|
352
419
|
container.appendChild(node);
|
|
353
420
|
});
|
|
354
421
|
}
|
|
422
|
+
} catch (thrown) {
|
|
423
|
+
if (lazyFallback) {
|
|
424
|
+
const error = thrown instanceof Error ? thrown : new Error(String(thrown));
|
|
425
|
+
while (container.firstChild) {
|
|
426
|
+
container.removeChild(container.firstChild);
|
|
427
|
+
}
|
|
428
|
+
const fallbackNode = lazyFallback({
|
|
429
|
+
error,
|
|
430
|
+
retry: () => {
|
|
431
|
+
try {
|
|
432
|
+
const retryNode = mod.default();
|
|
433
|
+
if (fallbackNode.parentNode) {
|
|
434
|
+
fallbackNode.parentNode.replaceChild(retryNode, fallbackNode);
|
|
435
|
+
}
|
|
436
|
+
} catch {}
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
container.appendChild(fallbackNode);
|
|
440
|
+
} else {
|
|
441
|
+
throw thrown;
|
|
442
|
+
}
|
|
355
443
|
} finally {
|
|
356
444
|
popScope();
|
|
357
445
|
}
|
|
358
446
|
});
|
|
359
447
|
} else {
|
|
448
|
+
if (gen !== renderGen) {
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
360
451
|
__append(container, result);
|
|
361
452
|
if (getIsHydrating() && !container.contains(result)) {
|
|
362
453
|
while (container.firstChild) {
|
|
@@ -366,7 +457,10 @@ function RouterView({ router, fallback }) {
|
|
|
366
457
|
}
|
|
367
458
|
}
|
|
368
459
|
});
|
|
369
|
-
|
|
460
|
+
if (gen === renderGen) {
|
|
461
|
+
prevLevels = levels;
|
|
462
|
+
prevParamsKey = currentParamsKey;
|
|
463
|
+
}
|
|
370
464
|
if (!asyncRoute) {
|
|
371
465
|
popScope();
|
|
372
466
|
}
|
|
@@ -387,7 +481,7 @@ function buildLevels(matched) {
|
|
|
387
481
|
route: m.route
|
|
388
482
|
}));
|
|
389
483
|
}
|
|
390
|
-
function buildInsideOutFactory(matched, levels, startAt, router) {
|
|
484
|
+
function buildInsideOutFactory(matched, levels, startAt, router, errorFallback) {
|
|
391
485
|
const ssrCtx = getSSRContext();
|
|
392
486
|
const wrapForSSR = (route, routeIndex) => {
|
|
393
487
|
if (!ssrCtx)
|
|
@@ -415,12 +509,22 @@ function buildInsideOutFactory(matched, levels, startAt, router) {
|
|
|
415
509
|
return result;
|
|
416
510
|
};
|
|
417
511
|
};
|
|
418
|
-
|
|
512
|
+
const resolveFallback = (route) => route.errorComponent ?? errorFallback;
|
|
513
|
+
const maybeWrapInBoundary = (componentFn, fb) => {
|
|
514
|
+
if (!fb)
|
|
515
|
+
return componentFn;
|
|
516
|
+
return () => ErrorBoundary({
|
|
517
|
+
children: componentFn,
|
|
518
|
+
fallback: (error, retry) => fb({ error, retry })
|
|
519
|
+
});
|
|
520
|
+
};
|
|
521
|
+
const leafRoute = matched[matched.length - 1].route;
|
|
522
|
+
let factory = maybeWrapInBoundary(wrapForSSR(leafRoute, matched.length - 1), resolveFallback(leafRoute));
|
|
419
523
|
for (let i = matched.length - 2;i >= startAt; i--) {
|
|
420
524
|
const level = levels[i];
|
|
421
525
|
const childFactory = factory;
|
|
422
526
|
level.childSignal.value = childFactory;
|
|
423
|
-
const parentComponent = wrapForSSR(level.route, i);
|
|
527
|
+
const parentComponent = maybeWrapInBoundary(wrapForSSR(level.route, i), resolveFallback(level.route));
|
|
424
528
|
const cs = level.childSignal;
|
|
425
529
|
factory = () => {
|
|
426
530
|
let result;
|
|
@@ -451,4 +555,4 @@ function useSearchParams(searchSignal) {
|
|
|
451
555
|
return searchSignal.value;
|
|
452
556
|
}
|
|
453
557
|
|
|
454
|
-
export { createLink, Link, OutletContext, Outlet, RouterView, parseSearchParams, useSearchParams };
|
|
558
|
+
export { getCurrentErrorHandler, ErrorBoundary, createLink, Link, OutletContext, Outlet, RouterView, parseSearchParams, useSearchParams };
|