From a087c06552077662c7d22d5db3d6348a63b2dd12 Mon Sep 17 00:00:00 2001 From: SheetJS Date: Wed, 5 Jul 2023 04:24:21 -0400 Subject: [PATCH] search by uuid --- src/App.tsx | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index a97eb3c..1eee678 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -26,6 +26,28 @@ import 'react-toastify/dist/ReactToastify.css'; //#region Xxd +const uuid2str = (l: bigint, u: bigint): string => [ + ((l >> 0n) & 0xFFn).toString(16).padStart(2, "0"), + ((l >> 8n) & 0xFFn).toString(16).padStart(2, "0"), + ((l >> 16n) & 0xFFn).toString(16).padStart(2, "0"), + ((l >> 24n) & 0xFFn).toString(16).padStart(2, "0"), + "-", + ((l >> 32n) & 0xFFn).toString(16).padStart(2, "0"), + ((l >> 40n) & 0xFFn).toString(16).padStart(2, "0"), + "-", + ((l >> 48n) & 0xFFn).toString(16).padStart(2, "0"), + ((l >> 56n) & 0xFFn).toString(16).padStart(2, "0"), + "-", + ((u >> 0n) & 0xFFn).toString(16).padStart(2, "0"), + ((u >> 8n) & 0xFFn).toString(16).padStart(2, "0"), + "-", + ((u >> 16n) & 0xFFn).toString(16).padStart(2, "0"), + ((u >> 24n) & 0xFFn).toString(16).padStart(2, "0"), + ((u >> 32n) & 0xFFn).toString(16).padStart(2, "0"), + ((u >> 40n) & 0xFFn).toString(16).padStart(2, "0"), + ((u >> 48n) & 0xFFn).toString(16).padStart(2, "0"), + ((u >> 56n) & 0xFFn).toString(16).padStart(2, "0"), +].join("").toUpperCase(); //import { vsprintf } from 'printj'; /*const X = "%02hhx", Y = X + X + " "; const FMT = [...Array.from({length:16}).map((_,i) => @@ -114,6 +136,15 @@ const ContextMenu = ({ID, menuType, menuField, menuId, onClickId, onClickCopyByt //#endregion +const replacer = (_: string, v: any): any => { + switch(true) { + case (typeof v == "bigint"): return v.toString(); + case (v instanceof Uint8Array): return [...v]; + case (v != null && typeof v.lower == "bigint" && typeof v.upper == "bigint"): return uuid2str(v.lower, v.upper); + } + return v; +}; + function App() { /* selected message ID */ const [id, setId] = useState("0"); @@ -137,6 +168,8 @@ function App() { const [loading, setLoading] = useState(true); /* search */ const [search, setSearch] = useState(""); + /* level */ + const [level, setLevel] = useState(1); /* history stack */ const [stack, setStack] = useState([]); /* react-contexify */ @@ -152,7 +185,7 @@ function App() { const item = f.space[+id][0]; if(!item.parsed) { item.parsed = process(item.data, message, p); - item.pre = JSON.stringify(item.parsed, (_,v) => typeof v == "bigint" ? v.toString() : v instanceof Uint8Array ? [...v]: v); + item.pre = JSON.stringify(item.parsed, replacer); } if(!item.parsedmeta) { const m: $_TSP_MessageInfo = item.parsedmeta = process(item.rawmeta, ".TSP.MessageInfo", p); @@ -322,6 +355,12 @@ function App() { : {frag} -> {gotoRef(id)}}>{id} ); } + if(data.PB_TYPE == ".TSP.UUID") { + let uuid = uuid2str(data.lower, data.upper); + return ( {displayMenu(e, { type: data.PB_TYPE, id, data, field: data.PB_FIELD })}}> + : {frag} -> {uuid} + ); + } return ( {displayMenu(e, { type: data.PB_TYPE, id, data, field: data.PB_FIELD })}}> : {frag} ); @@ -396,8 +435,12 @@ function App() {
{/* inspector */} - Message - + <> + Message (showing {level} level{level > 1 ? "s" : ""}) + { level >= 5 ? void 0 : setLevel(level + 1)}> (+) } + { level <= 1 ? void 0 : setLevel(level - 1)}> (-) } + + Meta {deps.length && || void 0}