tokensafe-ui 0.1.12 → 0.1.15
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/{chunk-H3UPVNVN.js → chunk-6SK6WA5M.js} +1 -1
- package/dist/{chunk-IV6VZQHA.js → chunk-PKUTL3A5.js} +2 -2
- package/dist/{chunk-QVRCZPAK.js → chunk-ST2BXX65.js} +1 -1
- package/dist/{chunk-N5DE4X4Z.js → chunk-T43DXEMD.js} +387 -13
- package/dist/{chunk-NZZXPY5Y.js → chunk-Y7AA2FFP.js} +3 -3
- package/dist/cli.cjs +185 -6
- package/dist/cli.js +4 -4
- package/dist/index.cjs +406 -13
- package/dist/index.d.cts +77 -1
- package/dist/index.d.ts +77 -1
- package/dist/index.js +39 -1
- package/dist/mcp.cjs +182 -3
- package/dist/mcp.js +4 -4
- package/dist/observer.cjs +179 -0
- package/dist/observer.js +2 -2
- package/dist/oumv.cjs +182 -3
- package/dist/oumv.js +4 -4
- package/dist/react.cjs +188 -6
- package/dist/react.js +4 -4
- package/dist/testing.cjs +179 -0
- package/dist/testing.js +1 -1
- package/dist/vite.cjs +74 -13
- package/dist/vite.js +60 -14
- package/dist/vue.cjs +182 -3
- package/dist/vue.js +4 -4
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildDependencyGraph,
|
|
3
3
|
observeDiff
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6SK6WA5M.js";
|
|
5
5
|
import {
|
|
6
6
|
applyPatch
|
|
7
7
|
} from "./chunk-N7XIVYCL.js";
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
activeInstances,
|
|
10
10
|
testAction,
|
|
11
11
|
testEffect
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-T43DXEMD.js";
|
|
13
13
|
|
|
14
14
|
// ../mcp/dist/index.js
|
|
15
15
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
@@ -811,6 +811,143 @@ function For(props) {
|
|
|
811
811
|
function ErrorBoundary(props) {
|
|
812
812
|
return props;
|
|
813
813
|
}
|
|
814
|
+
var currentHookContext = null;
|
|
815
|
+
function setCurrentHookContext(ctx) {
|
|
816
|
+
currentHookContext = ctx;
|
|
817
|
+
}
|
|
818
|
+
function getCurrentHookContext() {
|
|
819
|
+
return currentHookContext;
|
|
820
|
+
}
|
|
821
|
+
function createHookContext() {
|
|
822
|
+
return {
|
|
823
|
+
slots: [],
|
|
824
|
+
effects: [],
|
|
825
|
+
hookIndex: 0,
|
|
826
|
+
effectIndex: 0
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
function flushComponentEffects(ctx) {
|
|
830
|
+
for (const eff of ctx.effects) {
|
|
831
|
+
if (eff.cleanup) {
|
|
832
|
+
try {
|
|
833
|
+
eff.cleanup();
|
|
834
|
+
} catch (err) {
|
|
835
|
+
console.error("[TokenSafe UI Hook Error] Error in effect cleanup:", err);
|
|
836
|
+
}
|
|
837
|
+
eff.cleanup = void 0;
|
|
838
|
+
}
|
|
839
|
+
try {
|
|
840
|
+
const cleanup = eff.fn();
|
|
841
|
+
if (typeof cleanup === "function") {
|
|
842
|
+
eff.cleanup = cleanup;
|
|
843
|
+
}
|
|
844
|
+
} catch (err) {
|
|
845
|
+
console.error("[TokenSafe UI Hook Error] Error in effect execution:", err);
|
|
846
|
+
}
|
|
847
|
+
eff.isMounted = true;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
function disposeComponentEffects(ctx) {
|
|
851
|
+
for (const eff of ctx.effects) {
|
|
852
|
+
if (eff.cleanup) {
|
|
853
|
+
try {
|
|
854
|
+
eff.cleanup();
|
|
855
|
+
} catch (err) {
|
|
856
|
+
}
|
|
857
|
+
eff.cleanup = void 0;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
function depsChanged(prev, next) {
|
|
862
|
+
if (!prev || !next) return true;
|
|
863
|
+
if (prev.length !== next.length) return true;
|
|
864
|
+
for (let i = 0; i < prev.length; i++) {
|
|
865
|
+
if (!Object.is(prev[i], next[i])) return true;
|
|
866
|
+
}
|
|
867
|
+
return false;
|
|
868
|
+
}
|
|
869
|
+
function useState(initialState) {
|
|
870
|
+
const ctx = currentHookContext;
|
|
871
|
+
if (!ctx) {
|
|
872
|
+
const sig2 = signal(
|
|
873
|
+
typeof initialState === "function" ? initialState() : initialState
|
|
874
|
+
);
|
|
875
|
+
const set2 = (next) => {
|
|
876
|
+
sig2.value = typeof next === "function" ? next(sig2.value) : next;
|
|
877
|
+
};
|
|
878
|
+
return [sig2.value, set2];
|
|
879
|
+
}
|
|
880
|
+
const idx = ctx.hookIndex++;
|
|
881
|
+
if (idx >= ctx.slots.length) {
|
|
882
|
+
const val = typeof initialState === "function" ? initialState() : initialState;
|
|
883
|
+
ctx.slots.push({
|
|
884
|
+
type: "state",
|
|
885
|
+
data: signal(val, { name: `hook:state:${idx}` })
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
const sig = ctx.slots[idx].data;
|
|
889
|
+
const set = (next) => {
|
|
890
|
+
const nextVal = typeof next === "function" ? next(sig.peek()) : next;
|
|
891
|
+
sig.value = nextVal;
|
|
892
|
+
};
|
|
893
|
+
return [sig.value, set];
|
|
894
|
+
}
|
|
895
|
+
function useRef(initialValue) {
|
|
896
|
+
const ctx = currentHookContext;
|
|
897
|
+
if (!ctx) return { current: initialValue };
|
|
898
|
+
const idx = ctx.hookIndex++;
|
|
899
|
+
if (idx >= ctx.slots.length) {
|
|
900
|
+
ctx.slots.push({
|
|
901
|
+
type: "ref",
|
|
902
|
+
data: { current: initialValue }
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
return ctx.slots[idx].data;
|
|
906
|
+
}
|
|
907
|
+
function useMemo(factory, deps) {
|
|
908
|
+
const ctx = currentHookContext;
|
|
909
|
+
if (!ctx) return factory();
|
|
910
|
+
const idx = ctx.hookIndex++;
|
|
911
|
+
if (idx >= ctx.slots.length) {
|
|
912
|
+
const val = factory();
|
|
913
|
+
ctx.slots.push({
|
|
914
|
+
type: "memo",
|
|
915
|
+
data: { value: val, deps }
|
|
916
|
+
});
|
|
917
|
+
return val;
|
|
918
|
+
}
|
|
919
|
+
const entry = ctx.slots[idx].data;
|
|
920
|
+
if (depsChanged(entry.deps, deps)) {
|
|
921
|
+
entry.value = factory();
|
|
922
|
+
entry.deps = deps;
|
|
923
|
+
}
|
|
924
|
+
return entry.value;
|
|
925
|
+
}
|
|
926
|
+
function useCallback(callback, deps) {
|
|
927
|
+
return useMemo(() => callback, deps);
|
|
928
|
+
}
|
|
929
|
+
function useEffect(effectFn, deps) {
|
|
930
|
+
const ctx = currentHookContext;
|
|
931
|
+
if (!ctx) {
|
|
932
|
+
setTimeout(effectFn, 0);
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
const idx = ctx.effectIndex++;
|
|
936
|
+
if (idx >= ctx.effects.length) {
|
|
937
|
+
ctx.effects.push({
|
|
938
|
+
fn: effectFn,
|
|
939
|
+
deps,
|
|
940
|
+
isMounted: false
|
|
941
|
+
});
|
|
942
|
+
} else {
|
|
943
|
+
const existing = ctx.effects[idx];
|
|
944
|
+
if (depsChanged(existing.deps, deps)) {
|
|
945
|
+
existing.fn = effectFn;
|
|
946
|
+
existing.deps = deps;
|
|
947
|
+
existing.isMounted = false;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
814
951
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
815
952
|
var SVG_TAGS = /* @__PURE__ */ new Set([
|
|
816
953
|
"svg",
|
|
@@ -835,14 +972,17 @@ var SVG_TAGS = /* @__PURE__ */ new Set([
|
|
|
835
972
|
"radialGradient",
|
|
836
973
|
"stop"
|
|
837
974
|
]);
|
|
975
|
+
var isValidChild = (c) => c !== null && c !== void 0 && c !== false && c !== true;
|
|
838
976
|
function h(type, props, ...children) {
|
|
839
977
|
const normalizedProps = props || {};
|
|
840
|
-
let flatChildren = children.flat().filter(
|
|
978
|
+
let flatChildren = children.flat().filter(isValidChild);
|
|
841
979
|
if (flatChildren.length === 0 && normalizedProps.children) {
|
|
842
980
|
if (Array.isArray(normalizedProps.children)) {
|
|
843
|
-
flatChildren = normalizedProps.children.flat().filter(
|
|
844
|
-
} else {
|
|
981
|
+
flatChildren = normalizedProps.children.flat().filter(isValidChild);
|
|
982
|
+
} else if (isValidChild(normalizedProps.children)) {
|
|
845
983
|
flatChildren = [normalizedProps.children];
|
|
984
|
+
} else {
|
|
985
|
+
flatChildren = [];
|
|
846
986
|
}
|
|
847
987
|
} else if (flatChildren.length > 0 && !normalizedProps.children) {
|
|
848
988
|
normalizedProps.children = flatChildren.length === 1 ? flatChildren[0] : flatChildren;
|
|
@@ -1115,13 +1255,18 @@ function renderVNode(node, instance) {
|
|
|
1115
1255
|
if (typeof node === "function") {
|
|
1116
1256
|
return renderVNode(node(), instance);
|
|
1117
1257
|
}
|
|
1118
|
-
if (typeof node === "
|
|
1258
|
+
if (typeof node === "boolean" || node === null || node === void 0) {
|
|
1259
|
+
return document.createTextNode("");
|
|
1260
|
+
}
|
|
1261
|
+
if (typeof node === "string" || typeof node === "number") {
|
|
1119
1262
|
return document.createTextNode(String(node));
|
|
1120
1263
|
}
|
|
1121
1264
|
if (Array.isArray(node)) {
|
|
1122
1265
|
const fragment = document.createDocumentFragment();
|
|
1123
1266
|
for (const child of node) {
|
|
1124
|
-
|
|
1267
|
+
if (child !== null && child !== void 0 && child !== false && child !== true) {
|
|
1268
|
+
fragment.appendChild(renderVNode(child, instance));
|
|
1269
|
+
}
|
|
1125
1270
|
}
|
|
1126
1271
|
return fragment;
|
|
1127
1272
|
}
|
|
@@ -1300,17 +1445,25 @@ function renderVNode(node, instance) {
|
|
|
1300
1445
|
let currentNodes = [];
|
|
1301
1446
|
let currentScope = null;
|
|
1302
1447
|
let isInitial = true;
|
|
1448
|
+
const hookCtx = createHookContext();
|
|
1303
1449
|
const stop = effect(() => {
|
|
1304
1450
|
if (currentScope) {
|
|
1305
1451
|
currentScope.dispose();
|
|
1306
1452
|
currentScope = null;
|
|
1307
1453
|
}
|
|
1454
|
+
hookCtx.hookIndex = 0;
|
|
1455
|
+
hookCtx.effectIndex = 0;
|
|
1456
|
+
setCurrentHookContext(hookCtx);
|
|
1308
1457
|
const { result: rawChild, scope: compScope } = createScope(() => {
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
res
|
|
1458
|
+
try {
|
|
1459
|
+
let res = targetType(vnode.props);
|
|
1460
|
+
if (typeof res === "function") {
|
|
1461
|
+
res = res();
|
|
1462
|
+
}
|
|
1463
|
+
return res;
|
|
1464
|
+
} finally {
|
|
1465
|
+
setCurrentHookContext(null);
|
|
1312
1466
|
}
|
|
1313
|
-
return res;
|
|
1314
1467
|
});
|
|
1315
1468
|
currentScope = compScope;
|
|
1316
1469
|
let rendered = null;
|
|
@@ -1319,7 +1472,7 @@ function renderVNode(node, instance) {
|
|
|
1319
1472
|
}
|
|
1320
1473
|
if (isInitial) {
|
|
1321
1474
|
if (rendered) {
|
|
1322
|
-
if (rendered
|
|
1475
|
+
if (rendered.nodeType === 11) {
|
|
1323
1476
|
currentNodes = Array.from(rendered.childNodes);
|
|
1324
1477
|
} else {
|
|
1325
1478
|
currentNodes = [rendered];
|
|
@@ -1339,7 +1492,7 @@ function renderVNode(node, instance) {
|
|
|
1339
1492
|
}
|
|
1340
1493
|
currentNodes = [];
|
|
1341
1494
|
if (rendered) {
|
|
1342
|
-
if (rendered
|
|
1495
|
+
if (rendered.nodeType === 11) {
|
|
1343
1496
|
currentNodes = Array.from(rendered.childNodes);
|
|
1344
1497
|
} else {
|
|
1345
1498
|
currentNodes = [rendered];
|
|
@@ -1347,10 +1500,17 @@ function renderVNode(node, instance) {
|
|
|
1347
1500
|
parent.insertBefore(rendered, endAnchor);
|
|
1348
1501
|
}
|
|
1349
1502
|
}
|
|
1503
|
+
flushComponentEffects(hookCtx);
|
|
1350
1504
|
}, {
|
|
1351
1505
|
name: `component:${compName}`,
|
|
1352
1506
|
kind: "dom_binding"
|
|
1353
1507
|
});
|
|
1508
|
+
if (instance && instance._cleanups) {
|
|
1509
|
+
instance._cleanups.add(() => {
|
|
1510
|
+
stop();
|
|
1511
|
+
disposeComponentEffects(hookCtx);
|
|
1512
|
+
});
|
|
1513
|
+
}
|
|
1354
1514
|
if (instance && instance._cleanups) {
|
|
1355
1515
|
instance._cleanups.add(stop);
|
|
1356
1516
|
}
|
|
@@ -1501,7 +1661,9 @@ function renderVNode(node, instance) {
|
|
|
1501
1661
|
});
|
|
1502
1662
|
if (cleanups) cleanups.add(stop);
|
|
1503
1663
|
} else {
|
|
1504
|
-
|
|
1664
|
+
if (child !== null && child !== void 0 && child !== false && child !== true) {
|
|
1665
|
+
el.appendChild(renderVNode(child, instance));
|
|
1666
|
+
}
|
|
1505
1667
|
}
|
|
1506
1668
|
}
|
|
1507
1669
|
return el;
|
|
@@ -1523,7 +1685,10 @@ ${stateScript}`;
|
|
|
1523
1685
|
return vnodeToString(instanceOrVNode);
|
|
1524
1686
|
}
|
|
1525
1687
|
function vnodeToString(node) {
|
|
1526
|
-
if (typeof node === "
|
|
1688
|
+
if (typeof node === "boolean" || node === null || node === void 0) {
|
|
1689
|
+
return "";
|
|
1690
|
+
}
|
|
1691
|
+
if (typeof node === "string" || typeof node === "number") {
|
|
1527
1692
|
return escapeHtml(String(node));
|
|
1528
1693
|
}
|
|
1529
1694
|
if (typeof node === "function") {
|
|
@@ -2178,6 +2343,196 @@ function createUseSignal(useSyncExternalStore) {
|
|
|
2178
2343
|
);
|
|
2179
2344
|
};
|
|
2180
2345
|
}
|
|
2346
|
+
var queryCache = /* @__PURE__ */ new Map();
|
|
2347
|
+
function normalizeKey(key) {
|
|
2348
|
+
if (typeof key === "string") return key;
|
|
2349
|
+
return JSON.stringify(key);
|
|
2350
|
+
}
|
|
2351
|
+
function createQuery(options) {
|
|
2352
|
+
const normKey = normalizeKey(options.queryKey);
|
|
2353
|
+
let entry = queryCache.get(normKey);
|
|
2354
|
+
if (!entry) {
|
|
2355
|
+
entry = {
|
|
2356
|
+
key: normKey,
|
|
2357
|
+
data: signal(options.initialData ?? null, { name: `query:${normKey}.data` }),
|
|
2358
|
+
isLoading: signal(options.initialData === void 0, { name: `query:${normKey}.isLoading` }),
|
|
2359
|
+
isFetching: signal(false, { name: `query:${normKey}.isFetching` }),
|
|
2360
|
+
error: signal(null, { name: `query:${normKey}.error` }),
|
|
2361
|
+
lastFetched: 0,
|
|
2362
|
+
options,
|
|
2363
|
+
subscribers: 0
|
|
2364
|
+
};
|
|
2365
|
+
queryCache.set(normKey, entry);
|
|
2366
|
+
} else {
|
|
2367
|
+
entry.options = options;
|
|
2368
|
+
}
|
|
2369
|
+
entry.subscribers++;
|
|
2370
|
+
const executeFetch = async () => {
|
|
2371
|
+
if (!entry) return null;
|
|
2372
|
+
const isEnabled = typeof options.enabled === "function" ? options.enabled() : options.enabled !== false;
|
|
2373
|
+
if (!isEnabled) {
|
|
2374
|
+
entry.isLoading.value = false;
|
|
2375
|
+
return null;
|
|
2376
|
+
}
|
|
2377
|
+
entry.isFetching.value = true;
|
|
2378
|
+
try {
|
|
2379
|
+
const result = await options.queryFn();
|
|
2380
|
+
entry.data.value = result;
|
|
2381
|
+
entry.error.value = null;
|
|
2382
|
+
entry.lastFetched = Date.now();
|
|
2383
|
+
return result;
|
|
2384
|
+
} catch (err) {
|
|
2385
|
+
entry.error.value = err instanceof Error ? err : new Error(String(err));
|
|
2386
|
+
return null;
|
|
2387
|
+
} finally {
|
|
2388
|
+
entry.isLoading.value = false;
|
|
2389
|
+
entry.isFetching.value = false;
|
|
2390
|
+
}
|
|
2391
|
+
};
|
|
2392
|
+
const staleLimit = options.staleTime ?? 0;
|
|
2393
|
+
const isStale = Date.now() - entry.lastFetched >= staleLimit;
|
|
2394
|
+
if (isStale || entry.data.value === null) {
|
|
2395
|
+
executeFetch();
|
|
2396
|
+
}
|
|
2397
|
+
let intervalTimer = null;
|
|
2398
|
+
const setupInterval = () => {
|
|
2399
|
+
if (intervalTimer) clearInterval(intervalTimer);
|
|
2400
|
+
const intervalMs = typeof options.refetchInterval === "function" ? options.refetchInterval(entry.data.value) : options.refetchInterval;
|
|
2401
|
+
if (typeof intervalMs === "number" && intervalMs > 0 && typeof window !== "undefined") {
|
|
2402
|
+
intervalTimer = setInterval(() => {
|
|
2403
|
+
if (typeof document !== "undefined" && document.hidden) return;
|
|
2404
|
+
executeFetch();
|
|
2405
|
+
}, intervalMs);
|
|
2406
|
+
}
|
|
2407
|
+
};
|
|
2408
|
+
setupInterval();
|
|
2409
|
+
return {
|
|
2410
|
+
data: entry.data,
|
|
2411
|
+
isLoading: entry.isLoading,
|
|
2412
|
+
isFetching: entry.isFetching,
|
|
2413
|
+
error: entry.error,
|
|
2414
|
+
refetch: executeFetch
|
|
2415
|
+
};
|
|
2416
|
+
}
|
|
2417
|
+
function invalidateQueries(keyPrefix) {
|
|
2418
|
+
const prefix = normalizeKey(keyPrefix);
|
|
2419
|
+
for (const [key, entry] of queryCache.entries()) {
|
|
2420
|
+
if (key === prefix || key.startsWith(prefix) || key.includes(prefix)) {
|
|
2421
|
+
entry.lastFetched = 0;
|
|
2422
|
+
const isEnabled = typeof entry.options.enabled === "function" ? entry.options.enabled() : entry.options.enabled !== false;
|
|
2423
|
+
if (isEnabled) {
|
|
2424
|
+
entry.isFetching.value = true;
|
|
2425
|
+
entry.options.queryFn().then((res) => {
|
|
2426
|
+
entry.data.value = res;
|
|
2427
|
+
entry.error.value = null;
|
|
2428
|
+
}).catch((err) => {
|
|
2429
|
+
entry.error.value = err instanceof Error ? err : new Error(String(err));
|
|
2430
|
+
}).finally(() => {
|
|
2431
|
+
entry.isFetching.value = false;
|
|
2432
|
+
entry.isLoading.value = false;
|
|
2433
|
+
});
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
var initialPath = typeof window !== "undefined" ? window.location.pathname : "/";
|
|
2439
|
+
var initialSearch = typeof window !== "undefined" ? window.location.search : "";
|
|
2440
|
+
var initialHash = typeof window !== "undefined" ? window.location.hash : "";
|
|
2441
|
+
var currentPath = signal(initialPath, { name: "router.path" });
|
|
2442
|
+
var currentSearch = signal(initialSearch, { name: "router.search" });
|
|
2443
|
+
var currentHash = signal(initialHash, { name: "router.hash" });
|
|
2444
|
+
var popstateRegistered = false;
|
|
2445
|
+
if (typeof window !== "undefined" && !popstateRegistered) {
|
|
2446
|
+
popstateRegistered = true;
|
|
2447
|
+
window.addEventListener("popstate", () => {
|
|
2448
|
+
currentPath.value = window.location.pathname;
|
|
2449
|
+
currentSearch.value = window.location.search;
|
|
2450
|
+
currentHash.value = window.location.hash;
|
|
2451
|
+
});
|
|
2452
|
+
}
|
|
2453
|
+
function navigate(to, options = {}) {
|
|
2454
|
+
if (typeof window === "undefined") return;
|
|
2455
|
+
const url = new URL(to, window.location.origin);
|
|
2456
|
+
const newPath = url.pathname;
|
|
2457
|
+
const newSearch = url.search;
|
|
2458
|
+
const newHash = url.hash;
|
|
2459
|
+
if (options.replace) {
|
|
2460
|
+
window.history.replaceState({}, "", to);
|
|
2461
|
+
} else {
|
|
2462
|
+
window.history.pushState({}, "", to);
|
|
2463
|
+
}
|
|
2464
|
+
currentPath.value = newPath;
|
|
2465
|
+
currentSearch.value = newSearch;
|
|
2466
|
+
currentHash.value = newHash;
|
|
2467
|
+
if (options.scroll !== false) {
|
|
2468
|
+
window.scrollTo({ top: 0, behavior: "instant" });
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
function matchPath(pattern, pathname) {
|
|
2472
|
+
if (pattern === "*" || pattern === "/*") return {};
|
|
2473
|
+
if (pattern === pathname) return {};
|
|
2474
|
+
const patternParts = pattern.split("/").filter(Boolean);
|
|
2475
|
+
const pathParts = pathname.split("/").filter(Boolean);
|
|
2476
|
+
if (patternParts.length !== pathParts.length && !pattern.endsWith("/*")) {
|
|
2477
|
+
return null;
|
|
2478
|
+
}
|
|
2479
|
+
const params = {};
|
|
2480
|
+
for (let i = 0; i < patternParts.length; i++) {
|
|
2481
|
+
const p = patternParts[i];
|
|
2482
|
+
const val = pathParts[i];
|
|
2483
|
+
if (p.startsWith(":")) {
|
|
2484
|
+
const paramName = p.slice(1);
|
|
2485
|
+
params[paramName] = decodeURIComponent(val || "");
|
|
2486
|
+
} else if (p === "*") {
|
|
2487
|
+
return params;
|
|
2488
|
+
} else if (p !== val) {
|
|
2489
|
+
return null;
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
return params;
|
|
2493
|
+
}
|
|
2494
|
+
function Link(props) {
|
|
2495
|
+
const { href, class: cls, className, children, replace, scroll, onClick, ...rest } = props;
|
|
2496
|
+
const classVal = cls || className || "";
|
|
2497
|
+
const handleClick = (e) => {
|
|
2498
|
+
if (onClick) onClick(e);
|
|
2499
|
+
if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) {
|
|
2500
|
+
return;
|
|
2501
|
+
}
|
|
2502
|
+
if (href.startsWith("/") || href.startsWith("#")) {
|
|
2503
|
+
e.preventDefault();
|
|
2504
|
+
navigate(href, { replace, scroll });
|
|
2505
|
+
}
|
|
2506
|
+
};
|
|
2507
|
+
return h(
|
|
2508
|
+
"a",
|
|
2509
|
+
{
|
|
2510
|
+
href,
|
|
2511
|
+
class: classVal,
|
|
2512
|
+
onClick: handleClick,
|
|
2513
|
+
...rest
|
|
2514
|
+
},
|
|
2515
|
+
children
|
|
2516
|
+
);
|
|
2517
|
+
}
|
|
2518
|
+
function Router(props) {
|
|
2519
|
+
const path = currentPath.value;
|
|
2520
|
+
const search = currentSearch.value;
|
|
2521
|
+
const searchParams = new URLSearchParams(search);
|
|
2522
|
+
if (props.routes[path]) {
|
|
2523
|
+
return props.routes[path]({ path, params: {}, searchParams });
|
|
2524
|
+
}
|
|
2525
|
+
for (const [pattern, handler] of Object.entries(props.routes)) {
|
|
2526
|
+
const params = matchPath(pattern, path);
|
|
2527
|
+
if (params) {
|
|
2528
|
+
return handler({ path, params, searchParams });
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
if (props.fallback) {
|
|
2532
|
+
return props.fallback({ path, params: {}, searchParams });
|
|
2533
|
+
}
|
|
2534
|
+
return null;
|
|
2535
|
+
}
|
|
2181
2536
|
var VERSION = "0.2.0";
|
|
2182
2537
|
|
|
2183
2538
|
export {
|
|
@@ -2204,6 +2559,16 @@ export {
|
|
|
2204
2559
|
Show,
|
|
2205
2560
|
For,
|
|
2206
2561
|
ErrorBoundary,
|
|
2562
|
+
setCurrentHookContext,
|
|
2563
|
+
getCurrentHookContext,
|
|
2564
|
+
createHookContext,
|
|
2565
|
+
flushComponentEffects,
|
|
2566
|
+
disposeComponentEffects,
|
|
2567
|
+
useState,
|
|
2568
|
+
useRef,
|
|
2569
|
+
useMemo,
|
|
2570
|
+
useCallback,
|
|
2571
|
+
useEffect,
|
|
2207
2572
|
h,
|
|
2208
2573
|
Fragment,
|
|
2209
2574
|
mount,
|
|
@@ -2217,5 +2582,14 @@ export {
|
|
|
2217
2582
|
defineAsyncCrudComponent,
|
|
2218
2583
|
ReactBridge,
|
|
2219
2584
|
createUseSignal,
|
|
2585
|
+
createQuery,
|
|
2586
|
+
invalidateQueries,
|
|
2587
|
+
currentPath,
|
|
2588
|
+
currentSearch,
|
|
2589
|
+
currentHash,
|
|
2590
|
+
navigate,
|
|
2591
|
+
matchPath,
|
|
2592
|
+
Link,
|
|
2593
|
+
Router,
|
|
2220
2594
|
VERSION
|
|
2221
2595
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
atomicApplySourceEdit,
|
|
3
3
|
validateWorkspacePath
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PKUTL3A5.js";
|
|
5
5
|
import {
|
|
6
6
|
buildDependencyGraph,
|
|
7
7
|
observe
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-6SK6WA5M.js";
|
|
9
9
|
import {
|
|
10
10
|
testAction
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-T43DXEMD.js";
|
|
12
12
|
|
|
13
13
|
// ../oumv/dist/chunk-ONAJHNWR.js
|
|
14
14
|
import fs from "fs";
|