internal-ambient.d.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. declare var internalBinding: any;
  2. declare namespace NodeJS {
  3. interface FeaturesBinding {
  4. isDesktopCapturerEnabled(): boolean;
  5. isOffscreenRenderingEnabled(): boolean;
  6. isRemoteModuleEnabled(): boolean;
  7. isPDFViewerEnabled(): boolean;
  8. isRunAsNodeEnabled(): boolean;
  9. isFakeLocationProviderEnabled(): boolean;
  10. isViewApiEnabled(): boolean;
  11. isTtsEnabled(): boolean;
  12. isPrintingEnabled(): boolean;
  13. isPictureInPictureEnabled(): boolean;
  14. isExtensionsEnabled(): boolean;
  15. isComponentBuild(): boolean;
  16. }
  17. interface IpcBinding {
  18. send(internal: boolean, channel: string, args: any[]): void;
  19. sendSync(internal: boolean, channel: string, args: any[]): any;
  20. sendToHost(channel: string, args: any[]): void;
  21. sendTo(internal: boolean, sendToAll: boolean, webContentsId: number, channel: string, args: any[]): void;
  22. invoke<T>(internal: boolean, channel: string, args: any[]): Promise<{ error: string, result: T }>;
  23. }
  24. interface V8UtilBinding {
  25. getHiddenValue<T>(obj: any, key: string): T;
  26. setHiddenValue<T>(obj: any, key: string, value: T): void;
  27. deleteHiddenValue(obj: any, key: string): void;
  28. requestGarbageCollectionForTesting(): void;
  29. createDoubleIDWeakMap(): any;
  30. setRemoteCallbackFreer(fn: Function, frameId: number, contextId: String, id: number, sender: any): void
  31. weaklyTrackValue(value: any): void;
  32. clearWeaklyTrackedValues(): void;
  33. getWeaklyTrackedValues(): any[];
  34. }
  35. interface Process {
  36. /**
  37. * DO NOT USE DIRECTLY, USE process.electronBinding
  38. */
  39. _linkedBinding(name: string): any;
  40. electronBinding(name: string): any;
  41. electronBinding(name: 'features'): FeaturesBinding;
  42. electronBinding(name: 'ipc'): { ipc: IpcBinding };
  43. electronBinding(name: 'v8_util'): V8UtilBinding;
  44. electronBinding(name: 'app'): { app: Electron.App, App: Function };
  45. electronBinding(name: 'command_line'): Electron.CommandLine;
  46. electronBinding(name: 'desktop_capturer'): { createDesktopCapturer(): ElectronInternal.DesktopCapturer };
  47. log: NodeJS.WriteStream['write'];
  48. activateUvLoop(): void;
  49. // Additional events
  50. once(event: 'document-start', listener: () => any): this;
  51. once(event: 'document-end', listener: () => any): this;
  52. // Additional properties
  53. _firstFileName?: string;
  54. helperExecPath: string;
  55. isRemoteModuleEnabled: boolean;
  56. }
  57. }
  58. declare module NodeJS {
  59. interface Global {
  60. require: NodeRequire;
  61. module: NodeModule;
  62. __filename: string;
  63. __dirname: string;
  64. }
  65. }
  66. interface ContextMenuItem {
  67. id: number;
  68. label: string;
  69. type: 'normal' | 'separator' | 'subMenu' | 'checkbox';
  70. checked: boolean;
  71. enabled: boolean;
  72. subItems: ContextMenuItem[];
  73. }
  74. declare interface Window {
  75. ELECTRON_DISABLE_SECURITY_WARNINGS?: boolean;
  76. ELECTRON_ENABLE_SECURITY_WARNINGS?: boolean;
  77. InspectorFrontendHost?: {
  78. showContextMenuAtPoint: (x: number, y: number, items: ContextMenuItem[]) => void
  79. };
  80. DevToolsAPI?: {
  81. contextMenuItemSelected: (id: number) => void;
  82. contextMenuCleared: () => void
  83. };
  84. UI?: {
  85. createFileSelectorElement: (callback: () => void) => HTMLSpanElement
  86. };
  87. Persistence?: {
  88. FileSystemWorkspaceBinding: {
  89. completeURL: (project: string, path: string) => string;
  90. }
  91. };
  92. ResizeObserver: ResizeObserver;
  93. }
  94. /**
  95. * The ResizeObserver interface is used to observe changes to Element's content
  96. * rect.
  97. *
  98. * It is modeled after MutationObserver and IntersectionObserver.
  99. */
  100. declare class ResizeObserver {
  101. constructor (callback: ResizeObserverCallback);
  102. /**
  103. * Adds target to the list of observed elements.
  104. */
  105. observe: (target: Element) => void;
  106. /**
  107. * Removes target from the list of observed elements.
  108. */
  109. unobserve: (target: Element) => void;
  110. /**
  111. * Clears both the observationTargets and activeTargets lists.
  112. */
  113. disconnect: () => void;
  114. }
  115. /**
  116. * This callback delivers ResizeObserver's notifications. It is invoked by a
  117. * broadcast active observations algorithm.
  118. */
  119. interface ResizeObserverCallback {
  120. (entries: ResizeObserverEntry[], observer: ResizeObserver): void;
  121. }
  122. interface ResizeObserverEntry {
  123. /**
  124. * @param target The Element whose size has changed.
  125. */
  126. new (target: Element): ResizeObserverEntry;
  127. /**
  128. * The Element whose size has changed.
  129. */
  130. readonly target: Element;
  131. /**
  132. * Element's content rect when ResizeObserverCallback is invoked.
  133. */
  134. readonly contentRect: DOMRectReadOnly;
  135. }