generated from uwu/neptune-template
-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib - trace.native, discordRPC.native
- Loading branch information
Showing
14 changed files
with
189 additions
and
141 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,9 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"@inrixia/lib": "../_lib", | ||
"discord-rpc": "^4.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/discord-rpc": "^4.0.8" | ||
"@inrixia/lib": "../_lib" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// @ts-nocheck | ||
export const broadcast = (channel: string, ...args: any[]) => { | ||
for (const window of electron.BrowserWindow.getAllWindows()) { | ||
window.webContents.send(channel, ...args); | ||
} | ||
}; |
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./updateRPC.native"; |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { broadcast } from "./broadcast.native"; | ||
|
||
type LoggerFunc = (...data: any[]) => void; | ||
|
||
type Logger<T extends LoggerFunc = LoggerFunc> = { | ||
(...data: Parameters<T>): undefined; | ||
withContext(context: string): (...data: Parameters<T>) => undefined; | ||
}; | ||
|
||
export const Tracer = (source: string) => { | ||
const createLogger = <T extends LoggerFunc>(logger: T): Logger<T> => { | ||
const _logger = (...data: Parameters<T>) => { | ||
logger("native", source, ...data); | ||
return undefined; | ||
}; | ||
_logger.withContext = | ||
(context: string) => | ||
(...data: Parameters<T>) => { | ||
logger("native", source, context, ...data); | ||
return undefined; | ||
}; | ||
return _logger; | ||
}; | ||
|
||
const log = createLogger((...args) => broadcast("NEPTUNE_RENDERER_LOG", "log", ...args)); | ||
const warn = createLogger((...args) => broadcast("NEPTUNE_RENDERER_LOG", "warn", ...args)); | ||
const err = createLogger((...args) => broadcast("NEPTUNE_RENDERER_LOG", "error", ...args)); | ||
|
||
return { | ||
log, | ||
warn, | ||
err, | ||
}; | ||
}; | ||
export const libTrace = Tracer("[lib]"); |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const inRenderer = globalThis?.process === undefined; | ||
export const inNative = !inRenderer; |
Oops, something went wrong.