search by uuid

This commit is contained in:
SheetJS 2023-07-05 04:24:21 -04:00
parent 990fa5880b
commit a087c06552

@ -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<string>("0");
@ -137,6 +168,8 @@ function App() {
const [loading, setLoading] = useState<boolean>(true);
/* search */
const [search, setSearch] = useState<string>("");
/* level */
const [level, setLevel] = useState<number>(1);
/* history stack */
const [stack, setStack] = useState<string[]>([]);
/* 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() {
<ObjectName name={name} />: <b>{frag} -&gt; <a onClick={() => {gotoRef(id)}}><b>{id}</b></a></b>
</span> );
}
if(data.PB_TYPE == ".TSP.UUID") {
let uuid = uuid2str(data.lower, data.upper);
return ( <span onContextMenu={(e) => {displayMenu(e, { type: data.PB_TYPE, id, data, field: data.PB_FIELD })}}>
<ObjectName name={name} />: <b>{frag} -&gt; {uuid}</b>
</span> );
}
return ( <span onContextMenu={(e) => {displayMenu(e, { type: data.PB_TYPE, id, data, field: data.PB_FIELD })}}>
<ObjectName name={name} />: {frag}
</span> );
@ -396,8 +435,12 @@ function App() {
<Panel><div className="overflow" style={{textAlign: "left", marginTop: "5px", paddingLeft: "5px"}}>
{/* inspector */}
<b>Message</b>
<ObjectInspector data={obj} expandLevel={1} nodeRenderer={nodeRenderer} />
<>
<b>Message</b> (showing {level} level{level > 1 ? "s" : ""})
{ level >= 5 ? void 0 : <span onClick={() => setLevel(level + 1)}> (+) </span> }
{ level <= 1 ? void 0 : <span onClick={() => setLevel(level - 1)}> (-) </span> }
</>
<ObjectInspector data={obj} expandLevel={level} nodeRenderer={nodeRenderer} key={level} />
<b>Meta</b>
<ObjectInspector data={meta} expandLevel={1} nodeRenderer={metaRenderer} />
{deps.length && <ObjectInspector data={deps} expandLevel={1} nodeRenderer={depsRenderer} /> || void 0}