mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 22:30:44 +00:00
Adds browser PWA manifest and service worker support for the Control UI, plus gateway RPC methods and persisted Web Push subscription handling.
Maintainer verification:
- OPENCLAW_VITEST_MAX_WORKERS=1 pnpm test src/infra/push-web.test.ts src/gateway/server-methods/push.test.ts src/gateway/control-ui.test.ts src/gateway/protocol/push.test.ts
- pnpm check:changed passed before final GitHub update-branch merge commit
- pnpm build
Source head: 0720024368
22 lines
579 B
TypeScript
22 lines
579 B
TypeScript
import "./styles.css";
|
|
import "./ui/app.ts";
|
|
|
|
type ViteImportMeta = ImportMeta & {
|
|
readonly env?: {
|
|
readonly PROD?: boolean;
|
|
};
|
|
};
|
|
|
|
const isProd = (import.meta as ViteImportMeta).env?.PROD === true;
|
|
|
|
if (isProd && "serviceWorker" in navigator) {
|
|
void navigator.serviceWorker.register("./sw.js");
|
|
} else if (!isProd && "serviceWorker" in navigator) {
|
|
// Unregister any leftover dev SW to avoid stale cache issues.
|
|
void navigator.serviceWorker.getRegistrations().then((registrations) => {
|
|
for (const r of registrations) {
|
|
void r.unregister();
|
|
}
|
|
});
|
|
}
|