mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
20 lines
533 B
TypeScript
20 lines
533 B
TypeScript
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
type FluxerDebugObject = NonNullable<Window['__FLUXER_DEBUG__']>;
|
|
|
|
export function getFluxerDebugObject(): FluxerDebugObject | null {
|
|
if (typeof window === 'undefined') {
|
|
return null;
|
|
}
|
|
const existing = window.__FLUXER_DEBUG__;
|
|
if (existing === undefined || existing === null) {
|
|
const created: FluxerDebugObject = {};
|
|
window.__FLUXER_DEBUG__ = created;
|
|
return created;
|
|
}
|
|
if (typeof existing !== 'object' || Array.isArray(existing)) {
|
|
return null;
|
|
}
|
|
return existing;
|
|
}
|