@theia/core
Version:
Theia is a cloud & desktop IDE framework implemented in TypeScript.
58 lines • 3.48 kB
TypeScript
import { DisposableCollection } from '../common/disposable.js';
import { FrontendApplicationContribution } from './frontend-application-contribution.js';
import { SecondaryWindowService } from './window/secondary-window-service.js';
/**
* Mirrors runtime-added `<style>` and `<link>` elements from the main window's `<head>`
* into every secondary window, keeps CSSOM `insertRule`/`deleteRule` changes in sync,
* and propagates body class mutations.
*
* Elements that are already managed by dedicated services are excluded:
* - `monaco-colors` class stylesheets (managed by `MonacoFrontendApplicationContribution`)
* - `contributedColorTheme` ID stylesheets (managed by `StylingService`)
* - `theia-icon-theme` class stylesheets (managed by `PluginIconThemeService`)
*/
export declare class SecondaryWindowStyleMirror implements FrontendApplicationContribution {
protected readonly secondaryWindowService: SecondaryWindowService;
/** Maps a main-window element to its clones in each secondary window. */
protected readonly cloneMap: Map<HTMLLinkElement | HTMLStyleElement, Map<Window, HTMLLinkElement | HTMLStyleElement>>;
/** The set of currently tracked secondary windows. */
protected readonly trackedWindows: Set<Window>;
/** Records of CSSOM insertRule calls keyed by the main-window style element. */
protected readonly cssomRules: Map<HTMLStyleElement, {
rule: string;
index: number;
}[]>;
/** Original CSSStyleSheet methods, saved before monkey-patching. */
protected originalInsertRule: typeof CSSStyleSheet.prototype.insertRule | undefined;
protected originalDeleteRule: typeof CSSStyleSheet.prototype.deleteRule | undefined;
/** Body classes that represent per-window state and must not be mirrored. */
protected static readonly EXCLUDED_BODY_CLASSES: Set<string>;
/** Tracks which classes this mirror has added to each secondary window's body. */
protected readonly mainOriginatedClasses: Map<Window, Set<string>>;
/** Disposable collection for cleanup on stop. */
protected readonly toDispose: DisposableCollection;
/** Pending CSSOM rule re-syncs after insertRule (to capture rule.style mutations). */
protected readonly pendingRuleSyncs: Set<{
sheet: CSSStyleSheet;
index: number;
}>;
protected pendingRuleSyncScheduled: boolean;
onStart(): void;
onStop(): void;
protected shouldExclude(element: HTMLStyleElement | HTMLLinkElement): boolean;
protected isStyleOrLink(node: Node): node is HTMLStyleElement | HTMLLinkElement;
protected observeHeadMutations(): void;
protected observeBodyClassMutations(): void;
protected patchCSSOM(): void;
protected onInsertRule(sheet: CSSStyleSheet, rule: string, index: number): void;
protected scheduleRuleResync(sheet: CSSStyleSheet, index: number): void;
protected flushRuleResyncs(): void;
protected onDeleteRule(sheet: CSSStyleSheet, index: number): void;
protected snapshotExistingElements(win: Window): void;
protected trackAndCloneToAll(element: HTMLStyleElement | HTMLLinkElement): void;
protected cloneIntoWindow(element: HTMLStyleElement | HTMLLinkElement, win: Window): void;
protected hasMatchingLink(win: Window, href: string): boolean;
protected removeClones(element: HTMLStyleElement | HTMLLinkElement): void;
protected syncBodyClasses(win: Window): void;
}
//# sourceMappingURL=secondary-window-style-mirror.d.ts.map