-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from NillionNetwork/timhm/release-tweaks-and-f…
…ixes-0-2-0
- Loading branch information
Showing
31 changed files
with
642 additions
and
916 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"name": "@nillion/client-react-hooks", | ||
"license": "MIT", | ||
"author": "[email protected]", | ||
"version": "0.2.0-rc.3", | ||
"version": "0.2.0", | ||
"homepage": "https://nillion.pub/client-ts", | ||
"repository": { | ||
"type": "git", | ||
|
@@ -23,14 +23,14 @@ | |
"dependencies": { | ||
"@nillion/client-vms": "workspace:^", | ||
"@tanstack/react-query": "^5.59.20", | ||
"pino": "^9.5.0", | ||
"pino-pretty": "^13.0.0", | ||
"debug": "^4.3.7", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1", | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@tsconfig/vite-react": "^3.0.2", | ||
"@types/debug": "^4.1.12", | ||
"@types/react": "^18.3.12", | ||
"@types/react-dom": "^18.3.1", | ||
"browserslist": "^4.24.2", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { createLogger } from "@nillion/client-vms/logger"; | ||
import debug from "debug"; | ||
|
||
export const Log = createLogger("@nillion/client-react-hooks"); | ||
export const Log = debug("@nillion/client-react-hooks"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"name": "@nillion/client-vms", | ||
"license": "MIT", | ||
"author": "[email protected]", | ||
"version": "0.2.0-rc.3", | ||
"version": "0.2.0", | ||
"repository": "https://github.com/NillionNetwork/client-ts", | ||
"type": "module", | ||
"exports": { | ||
|
@@ -20,25 +20,25 @@ | |
}, | ||
"dependencies": { | ||
"@bufbuild/protobuf": "^2.2.2", | ||
"@connectrpc/connect": "2.0.0-rc.3", | ||
"@connectrpc/connect-web": "2.0.0-rc.3", | ||
"@connectrpc/connect": "^2.0.0", | ||
"@connectrpc/connect-web": "^2.0.0", | ||
"@cosmjs/proto-signing": "^0.32.4", | ||
"@cosmjs/stargate": "^0.32.4", | ||
"@nillion/client-wasm": "workspace:^", | ||
"@noble/curves": "^1.6.0", | ||
"@noble/hashes": "^1.5.0", | ||
"@noble/secp256k1": "^2.1.0", | ||
"bs58": "^6.0.0", | ||
"debug": "^4.3.7", | ||
"effect": "^3.10.14", | ||
"pino": "^9.5.0", | ||
"pino-pretty": "^13.0.0", | ||
"uuid": "^11.0.3", | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@bufbuild/buf": "^1.46.0", | ||
"@bufbuild/protoc-gen-es": "^2.2.2", | ||
"@keplr-wallet/types": "^0.12.154", | ||
"@types/debug": "^4.1.12", | ||
"@types/node": "^22.9.0", | ||
"@types/uuid": "^10.0.0", | ||
"@vitest/coverage-v8": "^2.1.4", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,3 @@ | ||
import pino, { type Logger } from "pino"; | ||
import debug from "debug"; | ||
|
||
export const Log = createLogger("@nillion/client-vm"); | ||
|
||
type PinoWriteFnArgs = { | ||
time: number; | ||
level: string; | ||
module: string; | ||
msg: string | object; | ||
[index: string]: unknown; | ||
}; | ||
|
||
const levelColors: Record<string, string> = { | ||
debug: "#808080", | ||
info: "#0099ff", | ||
warn: "#ffa500", | ||
error: "#ff0000", | ||
fatal: "#800000", | ||
trace: "#a0a0a0", | ||
}; | ||
|
||
export function createLogger(module: string): Logger<never, boolean> { | ||
const isBrowser = Boolean(globalThis.window); | ||
|
||
try { | ||
if (isBrowser) { | ||
return createBrowserLogger(module); | ||
} | ||
|
||
return pino({ | ||
level: "debug", | ||
transport: { | ||
target: "pino-pretty", | ||
}, | ||
}).child({ module }); | ||
} catch (_e) { | ||
return pino({ | ||
level: "debug", | ||
}).child({ module }); | ||
} | ||
} | ||
|
||
function createBrowserLogger(module: string): Logger<never, boolean> { | ||
return pino({ | ||
level: "debug", | ||
browser: { | ||
asObject: true, | ||
formatters: { | ||
level(label, _numerical) { | ||
return { level: label }; | ||
}, | ||
}, | ||
// @ts-expect-error args type is customised through `child` and `formatters` which pino doesn't recognize | ||
write: (args: PinoWriteFnArgs) => { | ||
if (!localStorage.debug?.includes("@nillion")) { | ||
return; | ||
} | ||
|
||
const time = new Date(args.time).toLocaleTimeString(); | ||
const { level, module, msg, time: _, ...rest } = args; | ||
const color = levelColors[level.toLowerCase()] || "#000000"; | ||
const style = `color: ${color}; font-weight: bold`; | ||
const baseMsg = `${time} %c${level.toUpperCase().padEnd(5)}%c ${module}:`; | ||
|
||
const logArgs: unknown[] = [baseMsg, style, ""]; | ||
|
||
if (typeof msg === "object") { | ||
logArgs[0] += " %O"; | ||
logArgs.push({ ...msg, ...rest }); | ||
} else { | ||
if (msg) { | ||
logArgs[0] += ` ${msg}`; | ||
} | ||
if (Object.keys(rest).length > 0) { | ||
logArgs[0] += " %O"; | ||
logArgs.push(rest); | ||
} | ||
} | ||
|
||
console.log(...logArgs); | ||
}, | ||
}, | ||
}).child({ module }); | ||
} | ||
export const Log = debug("@nillion/vms"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.