export interface ScriptLike { getAttribute(name: string): string | null; } export interface AttachOptions { /** 明示名(data-global より優先)。テストや ESM から呼ぶとき用。 */ name?: string | null; /** window 相当。テストで差し替えられるようにしている。 */ scope?: Record | null; /** document.currentScript 相当。 */ script?: ScriptLike | null; /** 警告の出口(テストで差し替え可)。 */ warn?: (message: string) => void; } export interface GlobalExtras { /** 実際に公開された名前(公開できなかった場合は空)。 */ globalNames: string[]; /** 上書きしたグローバルを元に戻す。 */ noConflict(all?: boolean): unknown; /** 別名を追加する(既に使われている名前は奪わない)。 */ as(name: string): boolean; } /** * api を適切なグローバル名で公開する。 * 戻り値は api 自身(noConflict / as / globalNames が生えた状態)。 */ export declare function attachGlobal(api: T, options?: AttachOptions): T & GlobalExtras;