mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-11-19 01:10:44 -06:00
Run the shared app/ updaters and social posters from workers/updater: - Scheduler Durable Object lanes: "fast" keeps the Node cron cadence (quick at :00-:04, default at :05/:10/:15/:20/:30/:45) and posts to social after checking SITE_URL serves the new data; "slow" runs X-Rank, Splatfest rankings, and avatar updates hourly. Bounded retries, queued manual runs, pause, and persisted automatic-scheduling state. - RegionAuth Durable Object per region: the single owner of each Nintendo login, serving bullet tokens to both lanes and renewing them hourly at :35-:38. - A five-minute cron watchdog that only re-arms alarms, bearer-token control endpoints, and dev/production environments. DO migrations keep Scheduler at v1 to match the earlier dev deployment. - Per-run limits (RunLimits) and per-account NsoClient locks instead of module-level limiters, since Durable Objects sharing an isolate cannot share in-flight requests. Updaters without localization rules no longer rewrite locale files. - 20 workerd tests (npm run updater:test, included in npm test) with all network access blocked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
74 lines
1.7 KiB
JavaScript
74 lines
1.7 KiB
JavaScript
import createScreenshotDriver from './drivers/createScreenshotDriver.mjs';
|
|
import { defaultScreenshotViewport } from '../../src/common/screenshot.mjs';
|
|
|
|
let defaultDependencies = {};
|
|
|
|
/**
|
|
* Set driver options for every ScreenshotHelper created afterwards. The Worker uses this to
|
|
* select the Cloudflare driver and pass its BROWSER binding.
|
|
* @param {object} dependencies For example { provider: 'cloudflare', browser: env.BROWSER }
|
|
*/
|
|
export function configureScreenshots(dependencies) {
|
|
defaultDependencies = { ...dependencies };
|
|
}
|
|
|
|
export default class ScreenshotHelper
|
|
{
|
|
_driver = null;
|
|
_driverDependencies;
|
|
_isOpen = false;
|
|
|
|
defaultParams = null;
|
|
|
|
constructor(driverDependencies = {}) {
|
|
this._driverDependencies = { ...defaultDependencies, ...driverDependencies };
|
|
}
|
|
|
|
get isOpen() {
|
|
return this._isOpen;
|
|
}
|
|
|
|
async open() {
|
|
await this.close();
|
|
|
|
this._driver = createScreenshotDriver(
|
|
this._driverDependencies.provider ?? process.env.SCREENSHOT_PROVIDER,
|
|
this._driverDependencies,
|
|
);
|
|
await this._driver.open();
|
|
this._isOpen = true;
|
|
}
|
|
|
|
async capture(path, options = {}) {
|
|
if (!this.isOpen) {
|
|
await this.open();
|
|
}
|
|
|
|
let params = {
|
|
...this.defaultParams,
|
|
...options.params,
|
|
};
|
|
let route = path;
|
|
|
|
if (Object.keys(params).length) {
|
|
route += '?';
|
|
route += new URLSearchParams(params).toString();
|
|
}
|
|
|
|
let viewport = {
|
|
...defaultScreenshotViewport,
|
|
...options.viewport,
|
|
};
|
|
|
|
return await this._driver.capture(route, viewport);
|
|
}
|
|
|
|
async close() {
|
|
if (this._driver) {
|
|
await this._driver.close();
|
|
}
|
|
this._driver = null;
|
|
this._isOpen = false;
|
|
}
|
|
}
|