wip:milestone 0 fixes
Some checks failed
CI/CD Pipeline / unit-tests (push) Failing after 1m16s
CI/CD Pipeline / integration-tests (push) Failing after 2m32s
CI/CD Pipeline / lint (push) Successful in 5m22s
CI/CD Pipeline / e2e-tests (push) Has been skipped
CI/CD Pipeline / build (push) Has been skipped

This commit is contained in:
2026-03-15 12:35:42 +02:00
parent 6708cf28a7
commit cffdf8af86
61266 changed files with 4511646 additions and 1938 deletions

View File

@@ -0,0 +1,9 @@
export type UnregisterToken = {
cleanupToken: number;
};
export type UnsubscribeFn = () => void;
export interface CleanupTracking {
register(object: any, unsubscribe: UnsubscribeFn, unregisterToken: UnregisterToken): void;
unregister(unregisterToken: UnregisterToken): void;
reset(): void;
}

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,7 @@
import { CleanupTracking, UnsubscribeFn, UnregisterToken } from './CleanupTracking';
export declare class FinalizationRegistryBasedCleanupTracking implements CleanupTracking {
registry: FinalizationRegistry<UnsubscribeFn>;
register(object: any, unsubscribe: UnsubscribeFn, unregisterToken: UnregisterToken): void;
unregister(unregisterToken: UnregisterToken): void;
reset(): void;
}

View File

@@ -0,0 +1,18 @@
export class FinalizationRegistryBasedCleanupTracking {
constructor() {
this.registry = new FinalizationRegistry(unsubscribe => {
if (typeof unsubscribe === 'function') {
unsubscribe();
}
});
}
register(object, unsubscribe, unregisterToken) {
this.registry.register(object, unsubscribe, unregisterToken);
}
unregister(unregisterToken) {
this.registry.unregister(unregisterToken);
}
// eslint-disable-next-line class-methods-use-this
reset() {}
}

View File

@@ -0,0 +1,10 @@
/// <reference types="node" />
import { CleanupTracking, UnregisterToken, UnsubscribeFn } from './CleanupTracking';
export declare class TimerBasedCleanupTracking implements CleanupTracking {
timeouts?: Map<number, NodeJS.Timeout> | undefined;
cleanupTimeout: number;
constructor(timeout?: number);
register(object: any, unsubscribe: UnsubscribeFn, unregisterToken: UnregisterToken): void;
unregister(unregisterToken: UnregisterToken): void;
reset(): void;
}

View File

@@ -0,0 +1,38 @@
// If no effect ran after this amount of time, we assume that the render was not committed by React
const CLEANUP_TIMER_LOOP_MILLIS = 1000;
export class TimerBasedCleanupTracking {
constructor(timeout = CLEANUP_TIMER_LOOP_MILLIS) {
this.timeouts = new Map();
this.cleanupTimeout = CLEANUP_TIMER_LOOP_MILLIS;
this.cleanupTimeout = timeout;
}
register(object, unsubscribe, unregisterToken) {
if (!this.timeouts) {
this.timeouts = new Map();
}
const timeout = setTimeout(() => {
if (typeof unsubscribe === 'function') {
unsubscribe();
}
this.timeouts.delete(unregisterToken.cleanupToken);
}, this.cleanupTimeout);
this.timeouts.set(unregisterToken.cleanupToken, timeout);
}
unregister(unregisterToken) {
const timeout = this.timeouts.get(unregisterToken.cleanupToken);
if (timeout) {
this.timeouts.delete(unregisterToken.cleanupToken);
clearTimeout(timeout);
}
}
reset() {
if (this.timeouts) {
this.timeouts.forEach((value, key) => {
this.unregister({
cleanupToken: key
});
});
this.timeouts = undefined;
}
}
}