mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-11-18 16:58:18 -06:00
Replace the remaining Node-only dependencies so the updaters and social posters bundle and run in workerd, while the Node runner keeps working: - Replace nxapi with app/splatnet/coral.mjs (fetch + WebCrypto), aligned with nxapi 1.6.1-next.257: znca compatibility 3.5.0, the current client version, and the slimmer Login parameter. Use one znca-api client per Nintendo account, since its token binds to the first account it serves. Cache the remote config in private storage instead of restarting daily. Sessions cached by the nxapi package trigger a fresh login. - Convert images through #image-converter: sharp in Node, the Images binding in Workers. Read Bluesky aspect ratios from the PNG header. - Replace twitter-api-v2 with OAuth 1.0a signed fetch; TwitterClient now only updates the seasonal X profile (posts go through Buffer). - Load avatars through #avatars (bundled as Data modules in Workers) and keep the local Chrome driver out of Worker bundles via #local-screenshot-driver. - prefixedConsole forwards to the global console; shared code reports to Sentry through @sentry/core. Verified live: full credential refresh for all four regions in Node, and the complete Coral → bullet token → GraphQL chain for EU inside workerd. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 lines
883 B
JavaScript
25 lines
883 B
JavaScript
const methods = ['log', 'info', 'warn', 'error', 'debug'];
|
|
|
|
/**
|
|
* A console whose messages start with [prefix] labels. It forwards to the global console at
|
|
* call time, so the Node CLI's timestamps (console-stamp) and Workers logging both apply.
|
|
* @param {...string} prefixes
|
|
* @returns {Record<'log'|'info'|'warn'|'error'|'debug', (...args: unknown[]) => void>} The prefixed console
|
|
*/
|
|
export default function prefixedConsole(...prefixes) {
|
|
let prefix = prefixes.map(s => `[${s}]`).join(' ');
|
|
|
|
return Object.fromEntries(methods.map(method => [method, (...args) => {
|
|
if (!prefix) {
|
|
return console[method](...args);
|
|
}
|
|
|
|
// Keep printf-style placeholders in the first argument working.
|
|
if (typeof args[0] === 'string') {
|
|
return console[method](`${prefix} ${args[0]}`, ...args.slice(1));
|
|
}
|
|
|
|
return console[method](prefix, ...args);
|
|
}]));
|
|
}
|