UNPKG

google-closure-compiler-js

Version:

Check, compile, transpile, optimize and compress JavaScript with Closure Compiler in JS

1,918 lines (1,407 loc) • 262 kB
/* * Copyright 2009 The Closure Compiler Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @fileoverview Definitions for the Chromium extensions API. * * This is the externs file for the Chrome Extensions API. * See http://developer.chrome.com/extensions/ * * There are several problematic issues regarding Chrome extension APIs and * this externs files, including: * A. When to add packages to this file * B. Optional parameters * C. Pseudo-types * D. Events * E. Nullability * F. Private APIs * G. Enums * * The best practices for each are described in more detail below. It * should be noted that, due to historical reasons, and the evolutionary * nature of this file, much this file currently violates the best practices * described below. As changed are made, the changes should adhere to the * best practices. * * A. When to Add Packages to this File? * Packages in chrome.experimental.* should *not* be added to this file. The * experimental APIs change very quickly, so rather than add them here, make a * separate externs file for your project, then move the API here when it moves * out of experimental. * * Some non-experimental APIs are still evolving or are not full documented. It * is still advantageous to include these in this file as doing so avoids a * proliferation of project-private externs files containing duplicated info. In * these cases, use comments to describe the situation. * * B. Optional Parameters * The Chrome extension APIs make extensive use of optional parameters that * are not at the end of the parameter list, "interior optional parameters", * while the JS Compiler's type system requires optional parameters to be * at the end. This creates a bit of tension: * * 1. If a method has N required params, then the parameter declarations * should have N required params. * 2. If, due to interior optional params, a parameter can be of more than * one type, its at-param should: * a. be named to indicate both possibilities, eg, extensionIdOrRequest, * or getInfoOrCallback. * b. the type should include both types, in the same order as the parts * of the name, even when one type subsumes the other, eg, {string|*} * or {Object|function(string)}. * See chrome.runtime.sendMessage for a complex example as sendMessage * takes three params with the first and third being optional. * * C. Pseudo-types * The Chrome APIs define many types are that actually pseudo-types, that * is, they can't be instantiated by name. The extension APIs also pass * untyped objects (a bag of properties) to callbacks. * * The Chrome extension APIs include at least three different situations: * * 1. an object that must be created by an extension developer and passed * into a Chrome extension API and for which there is no constructor. * 2. an instance of a type that is created inside the extension libraries * and passed out to a callback/listener or returned by an extension API * (the constructor implicity lives within the library). * 3. like #2, but a bag-of-properties object that is passed out to a * callback/listener or returned by an extension API so there is no * defined type. * * For #1, use a typedef so object literals and objects created via goog.object * are acceptable, for example, the Permissions type defined at * http://developer.chrome.com/extensions/permissions.html#type-Permissions * should be: * * / ** * * at-typedef {?{ * * permissions: (!Array<string>|undefined), * * origins: (!Array<string>|undefined) * * }} * * / * chrome.permissions.Permissions; * * Using typedefs provides type-safety for the fields that are defined in * the object literal and also defined in the typedef. Note that typedefs define * a minimal interface and will not complain about extraneous (often * misspelled) fields. * * Also, typedefs of record types are non-nullable by default. The "{?{" * creates a nullable record-type typedef so ! has the same meaning in usages * as it does for real types. * * For #2, use a standard constructor, even though no constructor is provided * and extension writers will never instantiate an instance, as using a first * class type provides the strongest type checking. For example, see the Port * type defined at http://developer.chrome.com/apps/runtime.html#type-Port. * Always qualify the type name to reduce top-level pollution in this file: * * Do: * chrome.extension.Port = function() {} * Don't: * function Port() {} * * Note that, unfortunately, the actual Port class definition in this file * does not follow this recommendation. * * For #3, use {!Object}, that is, a bag of properites. This is a sad reality * given that the Chrome extensions do not document a real type. It is tempting * to define a real-type within this file and treat this situation as identical * to #2, but that means a new type is being defined in this file and developers * do not expect to find required new types in extension files. * * If a real type is declared here, then developers will need to incorporate * that type into the signature of their callback method and there will be * no indication from the docs that they need to do so. * * D. Events * Most packages define a set of events with the standard set of methods: * addListener, removeListener, hasListener and hasListeners. ChromeEvent * is the appropriate type when an event's listeners do not take any * parameters, however, many events take parameters specific to that event: * * 1. Create a pseudo-type for the event, for example, * chrome.runtime.PortEvent and define the four methods on it. * 2. Fully describe the listener/callback's signature, for example, * * * at-param {function(!chrome.runtime.Port): void} callback Callback. * chrome.runtime.PortEvent.prototype.addListener = * function(callback) {}; * or * * * at-param {function(*, !chrome.runtime.MessageSender, * * function(*): void): (boolean|undefined)} callback Callback. * chrome.runtime.MessageSenderEvent.prototype.addListener = * function(callback) {}; * * E. Nullability * We treat the Chrome Extension API pages as "the truth". Not-null types * should be used in the following situations: * * 1. Parameters and return values that are not explicitly declared to handle * null. * 2. Static event instances, for example, chrome.runtime.onConnect's type * should be: !chrome.runtime.PortEvent. * 3. Optional params as there is little value to passing null when the * parameter can be omitted, of course, if null is explicitly declared * to be meaningful, then a nullable type should be used. * * F. Private APIs * Private Chrome APIs (such as those that end in "Private") should go at the * bottom of this file. * * G. Enums * An enum's type name and the name of its members must be included in an * externs file, but the values of its members are ignored by the compiler. * To make it clear enums are not being *defined* in this file, we set * string enum values to the empty string (at this time, there are no * known enums of other types). * * As of Mar 2016, the chrome extension docs are incomplete wrt to enums * as they don't list the member names, only their string values. This means * extension authors will tend to use string literals. Therefore, whereever * an enum type should be used, we support either the enum or a string. Once * the docs are complete, new uses of enums will no longer need the "or string" * portion of the type. * * Finally, most places in this file where enums should be used are using only * string. This is historical and is no longer the recommended practice. * * See enum chrome.wallpaper.WallpaperLayout and chrome.wallpaper.setWallpaper's * param for examples. * * @externs * */ /* * Ensure projects don't execute this file. * The throw is to catch executions of this file, however, without the guard, * the compiler's flow analysis stops at the throw, even for an externs file. * Therefore, the Math.random() guard fools the compiler during externs * processing. */ if (Math.random() < 1) { // always true but the compiler doesn't know that throw 'Externs file "chrome_extensions.js" should not be executed'; } /** * @see https://developer.chrome.com/extensions/accessibilityFeatures * @const */ chrome.accessibilityFeatures = {}; /** @type {!ChromeSetting} */ chrome.accessibilityFeatures.spokenFeedback; /** @type {!ChromeSetting} */ chrome.accessibilityFeatures.largeCursor; /** @type {!ChromeSetting} */ chrome.accessibilityFeatures.stickyKeys; /** @type {!ChromeSetting} */ chrome.accessibilityFeatures.highContrast; /** @type {!ChromeSetting} */ chrome.accessibilityFeatures.screenMagnifier; /** @type {!ChromeSetting} */ chrome.accessibilityFeatures.autoclick; /** @type {!ChromeSetting} */ chrome.accessibilityFeatures.virtualKeyboard; /** @type {!ChromeSetting} */ chrome.accessibilityFeatures.animationPolicy; /** * @const * @see http://developer.chrome.com/apps/app.runtime.html */ chrome.app.runtime = {}; /** * @constructor * @see http://developer.chrome.com/apps/app_runtime.html */ chrome.app.runtime.LaunchItem = function() {}; /** @type {!FileEntry} */ chrome.app.runtime.LaunchItem.prototype.entry; /** @type {string} */ chrome.app.runtime.LaunchItem.prototype.type; /** @type {!ChromeObjectEvent} */ chrome.app.runtime.onLaunched; /** * @type {!ChromeEvent} * @see http://developer.chrome.com/apps/app.runtime.html#event-onRestarted */ chrome.app.runtime.onRestarted; /** * @const * @see http://developer.chrome.com/apps/app.window.html */ chrome.app.window = {}; /** * @see https://developer.chrome.com/apps/app_window#method-getAll * @return {!Array<!chrome.app.window.AppWindow>} */ chrome.app.window.getAll = function() {}; /** * @see https://developer.chrome.com/apps/app_window#method-get * @param {string} id * @return {chrome.app.window.AppWindow} */ chrome.app.window.get = function(id) {}; /** * @constructor * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow */ chrome.app.window.AppWindow = function() {}; /** * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow * @return {undefined} */ chrome.app.window.AppWindow.prototype.focus = function() {}; /** * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow * @return {undefined} */ chrome.app.window.AppWindow.prototype.fullscreen = function() {}; /** * @return {boolean} * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow */ chrome.app.window.AppWindow.prototype.isFullscreen = function() {}; /** * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow * @return {undefined} */ chrome.app.window.AppWindow.prototype.minimize = function() {}; /** * @return {boolean} * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow */ chrome.app.window.AppWindow.prototype.isMinimized = function() {}; /** * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow * @return {undefined} */ chrome.app.window.AppWindow.prototype.maximize = function() {}; /** * @return {boolean} * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow */ chrome.app.window.AppWindow.prototype.isMaximized = function() {}; /** * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow * @return {undefined} */ chrome.app.window.AppWindow.prototype.restore = function() {}; /** * @param {number} left The new left position, in pixels. * @param {number} top The new top position, in pixels. * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow * @return {undefined} */ chrome.app.window.AppWindow.prototype.moveTo = function(left, top) {}; /** * @param {number} width The new width, in pixels. * @param {number} height The new height, in pixels. * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow * @return {undefined} */ chrome.app.window.AppWindow.prototype.resizeTo = function(width, height) {}; /** * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow * @return {undefined} */ chrome.app.window.AppWindow.prototype.drawAttention = function() {}; /** * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow * @return {undefined} */ chrome.app.window.AppWindow.prototype.clearAttention = function() {}; /** * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow * @return {undefined} */ chrome.app.window.AppWindow.prototype.close = function() {}; /** * @param {boolean=} opt_focus Should the window be focused? Defaults to true. * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow * @return {undefined} */ chrome.app.window.AppWindow.prototype.show = function(opt_focus) {}; /** * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow * @return {undefined} */ chrome.app.window.AppWindow.prototype.hide = function() {}; /** * @return {!chrome.app.window.ContentBounds} The current window bounds. * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow */ chrome.app.window.AppWindow.prototype.getBounds = function() {}; /** * @param {!chrome.app.window.ContentBounds} bounds The new window bounds. * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow * @return {undefined} */ chrome.app.window.AppWindow.prototype.setBounds = function(bounds) {}; /** * @return {boolean} * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow */ chrome.app.window.AppWindow.prototype.isAlwaysOnTop = function() {}; /** * @param {boolean} alwaysOnTop Set whether the window should stay above most * other windows. * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow * @return {undefined} */ chrome.app.window.AppWindow.prototype.setAlwaysOnTop = function(alwaysOnTop) {}; /** * @param {boolean} alwaysVisible Set whether the window is visible on all * workspaces. * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow * @return {undefined} */ chrome.app.window.AppWindow.prototype.setVisibleOnAllWorkspaces = function(alwaysVisible) {}; /** * @param {boolean} wantAllKeys Set whether the window should get all keyboard * events including system keys that are usually not sent. * @see http://developer.chrome.com/apps/app.window.html#type-AppWindow * @return {undefined} */ chrome.app.window.AppWindow.prototype.setInterceptAllKeys = function(wantAllKeys) {}; /** @type {!ChromeEvent} */ chrome.app.window.AppWindow.prototype.onBoundsChanged; /** @type {!ChromeEvent} */ chrome.app.window.AppWindow.prototype.onClosed; /** @type {!ChromeEvent} */ chrome.app.window.AppWindow.prototype.onFullscreened; /** @type {!ChromeEvent} */ chrome.app.window.AppWindow.prototype.onMinimized; /** @type {!ChromeEvent} */ chrome.app.window.AppWindow.prototype.onMaximized; /** @type {!ChromeEvent} */ chrome.app.window.AppWindow.prototype.onRestored; /** @type {!Window} */ chrome.app.window.AppWindow.prototype.contentWindow; /** @type {string} */ chrome.app.window.AppWindow.prototype.id; /** @type {!chrome.app.window.Bounds} */ chrome.app.window.AppWindow.prototype.innerBounds; /** @type {!chrome.app.window.Bounds} */ chrome.app.window.AppWindow.prototype.outerBounds; /** * @typedef {?{ * left: number, * top: number, * width: number, * height: number, * minWidth: (number|undefined), * minHeight: (number|undefined), * maxWidth: (number|undefined), * maxHeight: (number|undefined), * setPosition: function(number, number), * setSize: function(number, number), * setMinimumSize: function(number, number), * setMaximumSize: function(number, number) * }} * @see http://developer.chrome.com/apps/app.window.html#type-Bounds */ chrome.app.window.Bounds; /** * @typedef {?{ * left: (number|undefined), * top: (number|undefined), * width: (number|undefined), * height: (number|undefined), * minWidth: (number|undefined), * minHeight: (number|undefined), * maxWidth: (number|undefined), * maxHeight: (number|undefined) * }} * @see http://developer.chrome.com/apps/app_window#type-BoundsSpecification */ chrome.app.window.BoundsSpecification; /** * @typedef {?{ * left: (number|undefined), * top: (number|undefined), * width: (number|undefined), * height: (number|undefined) * }} * @see http://developer.chrome.com/apps/app_window#type-ContentBounds */ chrome.app.window.ContentBounds; /** * @typedef {?{ * type: (string|undefined), * color: (string|undefined), * activeColor: (string|undefined), * inactiveColor: (string|undefined) * }} * @see http://developer.chrome.com/apps/app_window#type-FrameOptions */ chrome.app.window.FrameOptions; /** * @typedef {?{ * id: (string|undefined), * innerBounds: (!chrome.app.window.BoundsSpecification|undefined), * outerBounds: (!chrome.app.window.BoundsSpecification|undefined), * minWidth: (number|undefined), * minHeight: (number|undefined), * maxWidth: (number|undefined), * maxHeight: (number|undefined), * frame: (!chrome.app.window.FrameOptions|string|undefined), * bounds: (!chrome.app.window.ContentBounds|undefined), * state: (string|undefined), * hidden: (boolean|undefined), * resizable: (boolean|undefined), * singleton: (boolean|undefined), * alwaysOnTop: (boolean|undefined), * focused: (boolean|undefined), * visibleOnAllWorkspaces: (boolean|undefined) * }} * @see http://developer.chrome.com/apps/app.window.html#method-create */ chrome.app.window.CreateWindowOptions; /** * @param {string} url URL to create. * @param {!chrome.app.window.CreateWindowOptions=} opt_options The options for * the new window. * @param {function(!chrome.app.window.AppWindow)=} opt_createWindowCallback * Callback to be run. * @see http://developer.chrome.com/apps/app.window.html#method-create * @return {undefined} */ chrome.app.window.create = function( url, opt_options, opt_createWindowCallback) {}; /** * Returns an AppWindow object for the current script context (ie JavaScript * 'window' object). * @return {!chrome.app.window.AppWindow} * @see http://developer.chrome.com/apps/app.window.html#method-current */ chrome.app.window.current = function() {}; /** * @type {!ChromeEvent} * @see http://developer.chrome.com/apps/app.window.html#event-onBoundsChanged */ chrome.app.window.onBoundsChanged; /** * @type {!ChromeEvent} * @see http://developer.chrome.com/apps/app.window.html#event-onClosed */ chrome.app.window.onClosed; /** * @type {!ChromeEvent} * @see http://developer.chrome.com/apps/app.window.html#event-onFullscreened */ chrome.app.window.onFullscreened; /** * @type {!ChromeEvent} * @see http://developer.chrome.com/apps/app.window.html#event-onMaximized */ chrome.app.window.onMaximized; /** * @type {!ChromeEvent} * @see http://developer.chrome.com/apps/app.window.html#event-onMinimized */ chrome.app.window.onMinimized; /** * @type {!ChromeEvent} * @see http://developer.chrome.com/apps/app.window.html#event-onRestored */ chrome.app.window.onRestored; /** * Private API. * * @const * @see https://code.google.com/p/chromium/codesearch#chromium/src/chrome/common/extensions/api/audio_modem.idl * @see go/chrome-modem */ chrome.audioModem = {}; /** * @typedef {?{ * tokenLength: number, * crc: (boolean|undefined), * parity: (boolean|undefined) * }} */ chrome.audioModem.TokenEncoding; /** * @typedef {?{ * timeoutMillis: number, * band: string, * encoding: !chrome.audioModem.TokenEncoding * }} */ chrome.audioModem.RequestParams; /** @constructor */ chrome.audioModem.ReceivedToken = function() {}; /** @type {!ArrayBuffer} */ chrome.audioModem.ReceivedToken.prototype.token; /** @type {string} */ chrome.audioModem.ReceivedToken.prototype.band; /** * @param {!chrome.audioModem.RequestParams} params * @param {!ArrayBuffer} token * @param {function(string)} callback * @return {undefined} */ chrome.audioModem.transmit = function(params, token, callback) {}; /** * @param {string} band * @param {function(string)} callback * @return {undefined} */ chrome.audioModem.stopTransmit = function(band, callback) {}; /** * @param {!chrome.audioModem.RequestParams} params * @param {function(string)} callback * @return {undefined} */ chrome.audioModem.receive = function(params, callback) {}; /** * @param {string} band * @param {function(string)} callback * @return {undefined} */ chrome.audioModem.stopReceive = function(band, callback) {}; /** @constructor */ chrome.audioModem.ReceivedEvent = function() {}; /** * @param {function(!Array<!chrome.audioModem.ReceivedToken>)} callback * @return {undefined} */ chrome.audioModem.ReceivedEvent.prototype.addListener = function(callback) {}; /** * @param {function(!Array<!chrome.audioModem.ReceivedToken>)} callback * @return {undefined} */ chrome.audioModem.ReceivedEvent.prototype.removeListener = function(callback) {}; /** * @param {function(!Array<!chrome.audioModem.ReceivedToken>)} callback * @return {boolean} */ chrome.audioModem.ReceivedEvent.prototype.hasListener = function(callback) {}; /** * @return {boolean} */ chrome.audioModem.ReceivedEvent.prototype.hasListeners = function() {}; /** @type {!chrome.audioModem.ReceivedEvent} */ chrome.audioModem.onReceived; /** @type {!ChromeStringEvent} */ chrome.audioModem.onTransmitFail; /** * @see https://developer.chrome.com/apps/bluetooth */ chrome.bluetooth = {}; /** * @constructor * @see https://developer.chrome.com/apps/bluetooth#type-AdapterState */ chrome.bluetooth.AdapterState = function() {}; /** @type {string} */ chrome.bluetooth.AdapterState.prototype.address; /** @type {string} */ chrome.bluetooth.AdapterState.prototype.name; /** @type {boolean} */ chrome.bluetooth.AdapterState.prototype.powered; /** @type {boolean} */ chrome.bluetooth.AdapterState.prototype.available; /** @type {boolean} */ chrome.bluetooth.AdapterState.prototype.discovering; /** * @constructor * @see https://developer.chrome.com/apps/bluetooth#type-Device */ chrome.bluetooth.Device = function() {}; /** @type {string} */ chrome.bluetooth.Device.prototype.address; /** @type {string|undefined} */ chrome.bluetooth.Device.prototype.name; /** @type {number|undefined} */ chrome.bluetooth.Device.prototype.deviceClass; /** @type {string|undefined} */ chrome.bluetooth.Device.prototype.vendorIdSource; /** @type {string|undefined} */ chrome.bluetooth.Device.prototype.vendorId; /** @type {number|undefined} */ chrome.bluetooth.Device.prototype.productId; /** @type {number|undefined} */ chrome.bluetooth.Device.prototype.deviceId; /** @type {string|undefined} */ chrome.bluetooth.Device.prototype.type; /** @type {boolean|undefined} */ chrome.bluetooth.Device.prototype.paired; /** @type {boolean|undefined} */ chrome.bluetooth.Device.prototype.connected; /** @type {boolean|undefined} */ chrome.bluetooth.Device.prototype.connecting; /** @type {boolean|undefined} */ chrome.bluetooth.Device.prototype.connectable; /** @type {!Array<string>|undefined} */ chrome.bluetooth.Device.prototype.uuids; /** @type {number|undefined} */ chrome.bluetooth.Device.prototype.inquiryRssi; /** @type {number|undefined} */ chrome.bluetooth.Device.prototype.inquiryTxPower; /** * @param {function(!chrome.bluetooth.AdapterState)} callback * @see https://developer.chrome.com/apps/bluetooth#method-getAdapterState * @return {undefined} */ chrome.bluetooth.getAdapterState = function(callback) {}; /** * @param {string} deviceAddress * @param {function(!chrome.bluetooth.Device)} callback * @see https://developer.chrome.com/apps/bluetooth#method-getDevice * @return {undefined} */ chrome.bluetooth.getDevice = function(deviceAddress, callback) {}; /** * @param {function(!Array<!chrome.bluetooth.Device>)} callback * @see https://developer.chrome.com/apps/bluetooth#method-getDevices * @return {undefined} */ chrome.bluetooth.getDevices = function(callback) {}; /** * @param {function()=} opt_callback * @see https://developer.chrome.com/apps/bluetooth#method-startDiscovery * @return {undefined} */ chrome.bluetooth.startDiscovery = function(opt_callback) {}; /** * @param {function()=} opt_callback * @see https://developer.chrome.com/apps/bluetooth#method-stopDiscovery * @return {undefined} */ chrome.bluetooth.stopDiscovery = function(opt_callback) {}; /** * Event whose listeners take an AdapaterState parameter. * @constructor */ chrome.bluetooth.AdapterStateEvent = function() {}; /** * @param {function(!chrome.bluetooth.AdapterState): void} callback * @return {undefined} */ chrome.bluetooth.AdapterStateEvent.prototype.addListener = function(callback) {}; /** * @param {function(!chrome.bluetooth.AdapterState): void} callback * @return {undefined} */ chrome.bluetooth.AdapterStateEvent.prototype.removeListener = function(callback) {}; /** * @param {function(!chrome.bluetooth.AdapterState): void} callback * @return {boolean} */ chrome.bluetooth.AdapterStateEvent.prototype.hasListener = function(callback) {}; /** @return {boolean} */ chrome.bluetooth.AdapterStateEvent.prototype.hasListeners = function() {}; /** * @type {!chrome.bluetooth.AdapterStateEvent} * @see https://developer.chrome.com/apps/bluetooth#event-onAdapterStateChanged */ chrome.bluetooth.onAdapterStateChanged; /** * Event whose listeners take an Device parameter. * @constructor */ chrome.bluetooth.DeviceEvent = function() {}; /** * @param {function(!chrome.bluetooth.Device): void} callback * @return {undefined} */ chrome.bluetooth.DeviceEvent.prototype.addListener = function(callback) {}; /** * @param {function(!chrome.bluetooth.Device): void} callback * @return {undefined} */ chrome.bluetooth.DeviceEvent.prototype.removeListener = function(callback) {}; /** * @param {function(!chrome.bluetooth.Device): void} callback * @return {boolean} */ chrome.bluetooth.DeviceEvent.prototype.hasListener = function(callback) {}; /** @return {boolean} */ chrome.bluetooth.DeviceEvent.prototype.hasListeners = function() {}; /** * @type {!chrome.bluetooth.DeviceEvent} * @see https://developer.chrome.com/apps/bluetooth#event-onDeviceAdded */ chrome.bluetooth.onDeviceAdded; /** * @type {!chrome.bluetooth.DeviceEvent} * @see https://developer.chrome.com/apps/bluetooth#event-onDeviceChanged */ chrome.bluetooth.onDeviceChanged; /** * @type {!chrome.bluetooth.DeviceEvent} * @see https://developer.chrome.com/apps/bluetooth#event-onDeviceRemoved */ chrome.bluetooth.onDeviceRemoved; /** * @const * @see https://developer.chrome.com/apps/bluetoothSocket */ chrome.bluetoothSocket = {}; /** * @typedef {{ * persistent: (boolean|undefined), * name: (string|undefined), * bufferSize: (number|undefined) * }} * @see https://developer.chrome.com/apps/bluetoothSocket#type-SocketProperties */ chrome.bluetoothSocket.SocketProperties; /** * @typedef {{ * channel: (number|undefined), * psm: (number|undefined), * backlog: (number|undefined) * }} * @see https://developer.chrome.com/apps/bluetoothSocket#type-ListenOptions */ chrome.bluetoothSocket.ListenOptions; /** * @constructor * @see https://developer.chrome.com/apps/bluetoothSocket#type-SocketInfo */ chrome.bluetoothSocket.SocketInfo = function() {}; /** @type {number} */ chrome.bluetoothSocket.SocketInfo.prototype.socketId; /** @type {boolean} */ chrome.bluetoothSocket.SocketInfo.prototype.persistent; /** @type {string|undefined} */ chrome.bluetoothSocket.SocketInfo.prototype.name; /** @type {number|undefined} */ chrome.bluetoothSocket.SocketInfo.prototype.bufferSize; /** @type {boolean} */ chrome.bluetoothSocket.SocketInfo.prototype.paused; /** @type {boolean} */ chrome.bluetoothSocket.SocketInfo.prototype.connected; /** @type {string|undefined} */ chrome.bluetoothSocket.SocketInfo.prototype.address; /** @type {string|undefined} */ chrome.bluetoothSocket.SocketInfo.prototype.uuid; /** * @param {!chrome.bluetoothSocket.SocketProperties| * function(!{socketId: number})} propertiesOrCallback * @param {function(!{socketId: number})=} opt_callback * @see https://developer.chrome.com/apps/bluetoothSocket#method-create * @return {undefined} */ chrome.bluetoothSocket.create = function(propertiesOrCallback, opt_callback) {}; /** * @param {number} socketId * @param {!chrome.bluetoothSocket.SocketProperties} properties * @param {function()=} opt_callback * @see https://developer.chrome.com/apps/bluetoothSocket#method-update * @return {undefined} */ chrome.bluetoothSocket.update = function(socketId, properties, opt_callback) {}; /** * @param {number} socketId * @param {boolean} paused * @param {function()=} opt_callback * @see https://developer.chrome.com/apps/bluetoothSocket#method-setPaused * @return {undefined} */ chrome.bluetoothSocket.setPaused = function(socketId, paused, opt_callback) {}; /** * @param {number} socketId * @param {string} uuid * @param {!chrome.bluetoothSocket.ListenOptions|function()} optionsOrCallback * @param {function()=} opt_callback * @see https://developer.chrome.com/apps/bluetoothSocket#method-listenUsingRfcomm * @return {undefined} */ chrome.bluetoothSocket.listenUsingRfcomm = function(socketId, uuid, optionsOrCallback, opt_callback) {}; /** * @param {number} socketId * @param {string} uuid * @param {!chrome.bluetoothSocket.ListenOptions|function()} optionsOrCallback * @param {function()=} opt_callback * @see https://developer.chrome.com/apps/bluetoothSocket#method-listenUsingL2cap * @return {undefined} */ chrome.bluetoothSocket.listenUsingL2cap = function(socketId, uuid, optionsOrCallback, opt_callback) {}; /** * @param {number} socketId * @param {string} address * @param {string} uuid * @param {function()} callback * @see https://developer.chrome.com/apps/bluetoothSocket#method-connect * @return {undefined} */ chrome.bluetoothSocket.connect = function(socketId, address, uuid, callback) {}; /** * @param {number} socketId * @param {function()=} opt_callback * @see https://developer.chrome.com/apps/bluetoothSocket#method-disconnect * @return {undefined} */ chrome.bluetoothSocket.disconnect = function(socketId, opt_callback) {}; /** * @param {number} socketId * @param {function()=} opt_callback * @see https://developer.chrome.com/apps/bluetoothSocket#method-close * @return {undefined} */ chrome.bluetoothSocket.close = function(socketId, opt_callback) {}; /** * @param {number} socketId * @param {!ArrayBuffer} data * @param {function(number)=} opt_callback * @see https://developer.chrome.com/apps/bluetoothSocket#method-send * @return {undefined} */ chrome.bluetoothSocket.send = function(socketId, data, opt_callback) {}; /** * @param {number} socketId * @param {function(!chrome.bluetoothSocket.SocketInfo)} callback * @see https://developer.chrome.com/apps/bluetoothSocket#method-getInfo * @return {undefined} */ chrome.bluetoothSocket.getInfo = function(socketId, callback) {}; /** * @param {function(!Array<!chrome.bluetoothSocket.SocketInfo>)} callback * @see https://developer.chrome.com/apps/bluetoothSocket#method-getSockets * @return {undefined} */ chrome.bluetoothSocket.getSockets = function(callback) {}; /** * @constructor * @see https://developer.chrome.com/apps/bluetoothSocket#event-onAccept */ chrome.bluetoothSocket.AcceptEventData = function() {}; /** @type {number} */ chrome.bluetoothSocket.AcceptEventData.prototype.socketId; /** @type {number} */ chrome.bluetoothSocket.AcceptEventData.prototype.clientSocketId; /** * Event whose listeners take a AcceptEventData parameter. * @constructor */ chrome.bluetoothSocket.AcceptEvent = function() {}; /** * @param {function(!chrome.bluetoothSocket.AcceptEventData): void} callback * @return {undefined} */ chrome.bluetoothSocket.AcceptEvent.prototype.addListener = function(callback) {}; /** * @param {function(!chrome.bluetoothSocket.AcceptEventData): void} callback * @return {undefined} */ chrome.bluetoothSocket.AcceptEvent.prototype.removeListener = function(callback) {}; /** * @param {function(!chrome.bluetoothSocket.AcceptEventData): void} callback * @return {boolean} */ chrome.bluetoothSocket.AcceptEvent.prototype.hasListener = function(callback) {}; /** @return {boolean} */ chrome.bluetoothSocket.AcceptEvent.prototype.hasListeners = function() {}; /** @type {!chrome.bluetoothSocket.AcceptEvent} */ chrome.bluetoothSocket.onAccept; /** * @constructor * @see https://developer.chrome.com/apps/bluetoothSocket#event-onAcceptError */ chrome.bluetoothSocket.AcceptErrorEventData = function() {}; /** @type {number} */ chrome.bluetoothSocket.AcceptErrorEventData.prototype.socketId; /** @type {string} */ chrome.bluetoothSocket.AcceptErrorEventData.prototype.errorMessage; /** @type {string} */ chrome.bluetoothSocket.AcceptErrorEventData.prototype.error; /** * Event whose listeners take a AcceptErrorEventData parameter. * @constructor */ chrome.bluetoothSocket.AcceptErrorEvent = function() {}; /** * @param {function( * !chrome.bluetoothSocket.AcceptErrorEventData): void} callback * @return {undefined} */ chrome.bluetoothSocket.AcceptErrorEvent.prototype.addListener = function(callback) {}; /** * @param {function( * !chrome.bluetoothSocket.AcceptErrorEventData): void} callback * @return {undefined} */ chrome.bluetoothSocket.AcceptErrorEvent.prototype.removeListener = function(callback) {}; /** * @param {function( * !chrome.bluetoothSocket.AcceptErrorEventData): void} callback * @return {boolean} */ chrome.bluetoothSocket.AcceptErrorEvent.prototype.hasListener = function(callback) {}; /** @return {boolean} */ chrome.bluetoothSocket.AcceptErrorEvent.prototype.hasListeners = function() {}; /** @type {!chrome.bluetoothSocket.AcceptErrorEvent} */ chrome.bluetoothSocket.onAcceptError; /** * @constructor * @see https://developer.chrome.com/apps/bluetoothSocket#event-onReceive */ chrome.bluetoothSocket.ReceiveEventData = function() {}; /** @type {number} */ chrome.bluetoothSocket.ReceiveEventData.prototype.socketId; /** @type {!ArrayBuffer} */ chrome.bluetoothSocket.ReceiveEventData.prototype.data; /** * Event whose listeners take a ReceiveEventData parameter. * @constructor */ chrome.bluetoothSocket.ReceiveEvent = function() {}; /** * @param {function(!chrome.bluetoothSocket.ReceiveEventData): void} callback * @return {undefined} */ chrome.bluetoothSocket.ReceiveEvent.prototype.addListener = function(callback) {}; /** * @param {function(!chrome.bluetoothSocket.ReceiveEventData): void} callback * @return {undefined} */ chrome.bluetoothSocket.ReceiveEvent.prototype.removeListener = function(callback) {}; /** * @param {function(!chrome.bluetoothSocket.ReceiveEventData): void} callback * @return {boolean} */ chrome.bluetoothSocket.ReceiveEvent.prototype.hasListener = function(callback) {}; /** @return {boolean} */ chrome.bluetoothSocket.ReceiveEvent.prototype.hasListeners = function() {}; /** @type {!chrome.bluetoothSocket.ReceiveEvent} */ chrome.bluetoothSocket.onReceive; /** * @constructor * @see https://developer.chrome.com/apps/bluetoothSocket#event-onReceiveError */ chrome.bluetoothSocket.ReceiveErrorEventData = function() {}; /** @type {number} */ chrome.bluetoothSocket.ReceiveErrorEventData.prototype.socketId; /** @type {string} */ chrome.bluetoothSocket.ReceiveErrorEventData.prototype.errorMessage; /** @type {string} */ chrome.bluetoothSocket.ReceiveErrorEventData.prototype.error; /** * Event whose listeners take a ReceiveErrorEventData parameter. * @constructor */ chrome.bluetoothSocket.ReceiveErrorEvent = function() {}; /** * @param {function( * !chrome.bluetoothSocket.ReceiveErrorEventData): void} callback * @return {undefined} */ chrome.bluetoothSocket.ReceiveErrorEvent.prototype.addListener = function(callback) {}; /** * @param {function( * !chrome.bluetoothSocket.ReceiveErrorEventData): void} callback * @return {undefined} */ chrome.bluetoothSocket.ReceiveErrorEvent.prototype.removeListener = function(callback) {}; /** * @param {function( * !chrome.bluetoothSocket.ReceiveErrorEventData): void} callback * @return {boolean} */ chrome.bluetoothSocket.ReceiveErrorEvent.prototype.hasListener = function(callback) {}; /** @return {boolean} */ chrome.bluetoothSocket.ReceiveErrorEvent.prototype.hasListeners = function() {}; /** @type {!chrome.bluetoothSocket.ReceiveErrorEvent} */ chrome.bluetoothSocket.onReceiveError; /** * @see https://developer.chrome.com/apps/bluetoothLowEnergy * @const */ chrome.bluetoothLowEnergy = {}; /** * @constructor * @see https://developer.chrome.com/apps/bluetoothLowEnergy#type-Service */ chrome.bluetoothLowEnergy.Service = function() {}; /** @type {string} */ chrome.bluetoothLowEnergy.Service.prototype.uuid; /** @type {boolean} */ chrome.bluetoothLowEnergy.Service.prototype.isPrimary; /** @type {string|undefined} */ chrome.bluetoothLowEnergy.Service.prototype.instanceId; /** @type {string|undefined} */ chrome.bluetoothLowEnergy.Service.prototype.deviceAddress; /** * @constructor * @see https://developer.chrome.com/apps/bluetoothLowEnergy#type-Characteristic */ chrome.bluetoothLowEnergy.Characteristic = function() {}; /** @type {string} */ chrome.bluetoothLowEnergy.Characteristic.prototype.uuid; /** @type {!chrome.bluetoothLowEnergy.Service} */ chrome.bluetoothLowEnergy.Characteristic.prototype.service; /** @type {!Array<string>} */ chrome.bluetoothLowEnergy.Characteristic.prototype.properties; /** @type {string|undefined} */ chrome.bluetoothLowEnergy.Characteristic.prototype.instanceId; /** @type {!ArrayBuffer|undefined} */ chrome.bluetoothLowEnergy.Characteristic.prototype.value; /** * @constructor * @see https://developer.chrome.com/apps/bluetoothLowEnergy#type-Descriptor */ chrome.bluetoothLowEnergy.Descriptor = function() {}; /** @type {string} */ chrome.bluetoothLowEnergy.Descriptor.prototype.uuid; /** @type {!chrome.bluetoothLowEnergy.Characteristic} */ chrome.bluetoothLowEnergy.Descriptor.prototype.characteristic; /** @type {string|undefined} */ chrome.bluetoothLowEnergy.Descriptor.prototype.instanceId; /** @type {!ArrayBuffer|undefined} */ chrome.bluetoothLowEnergy.Descriptor.prototype.value; /** * @typedef {?{ * persistent: boolean * }} */ chrome.bluetoothLowEnergy.ConnectionProperties; /** * @param {string} deviceAddress * @param {!chrome.bluetoothLowEnergy.ConnectionProperties|function()} * propertiesOrCallback * @param {function()=} opt_callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-connect * @return {undefined} */ chrome.bluetoothLowEnergy.connect = function(deviceAddress, propertiesOrCallback, opt_callback) {}; /** * @param {string} deviceAddress * @param {function()=} opt_callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-disconnect * @return {undefined} */ chrome.bluetoothLowEnergy.disconnect = function(deviceAddress, opt_callback) {}; /** * @param {string} serviceId * @param {function(!chrome.bluetoothLowEnergy.Service)} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-getService * @return {undefined} */ chrome.bluetoothLowEnergy.getService = function(serviceId, callback) {}; /** * @param {string} deviceAddress * @param {function(!Array<!chrome.bluetoothLowEnergy.Service>)} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-getServices * @return {undefined} */ chrome.bluetoothLowEnergy.getServices = function(deviceAddress, callback) {}; /** * @param {string} characteristicId * @param {function(!chrome.bluetoothLowEnergy.Characteristic)} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-getCharacteristic * @return {undefined} */ chrome.bluetoothLowEnergy.getCharacteristic = function(characteristicId, callback) {}; /** * @param {string} serviceId * @param {function(!Array<!chrome.bluetoothLowEnergy.Characteristic>)} * callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-getCharacteristics * @return {undefined} */ chrome.bluetoothLowEnergy.getCharacteristics = function(serviceId, callback) {}; /** * @param {string} serviceId * @param {function(!Array<!chrome.bluetoothLowEnergy.Service>)} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-getIncludedServices * @return {undefined} */ chrome.bluetoothLowEnergy.getIncludedServices = function(serviceId, callback) {}; /** * @param {string} descriptorId * @param {function(!chrome.bluetoothLowEnergy.Descriptor)} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-getDescriptor * @return {undefined} */ chrome.bluetoothLowEnergy.getDescriptor = function(descriptorId, callback) {}; /** * @param {string} characteristicId * @param {function(!Array<!chrome.bluetoothLowEnergy.Descriptor>)} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-getDescriptors * @return {undefined} */ chrome.bluetoothLowEnergy.getDescriptors = function(characteristicId, callback) {}; /** * @param {string} characteristicId * @param {function(!chrome.bluetoothLowEnergy.Characteristic)} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-readCharacteristicValue * @return {undefined} */ chrome.bluetoothLowEnergy.readCharacteristicValue = function(characteristicId, callback) {}; /** * @param {string} characteristicId * @param {!ArrayBuffer} value * @param {function()} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-writeCharacteristicValue * @return {undefined} */ chrome.bluetoothLowEnergy.writeCharacteristicValue = function(characteristicId, value, callback) {}; /** * @typedef {?{ * persistent: boolean * }} */ chrome.bluetoothLowEnergy.NotificationSessionProperties; /** * @param {string} characteristicId * @param {!chrome.bluetoothLowEnergy.NotificationSessionProperties|function()} * propertiesOrCallback * @param {function()=} opt_callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-startCharacteristicNotifications * @return {undefined} */ chrome.bluetoothLowEnergy.startCharacteristicNotifications = function(characteristicId, propertiesOrCallback, opt_callback) {}; /** * @param {string} characteristicId * @param {function()=} opt_callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-stopCharacteristicNotifications * @return {undefined} */ chrome.bluetoothLowEnergy.stopCharacteristicNotifications = function(characteristicId, opt_callback) {}; /** * @param {string} descriptorId * @param {function(!chrome.bluetoothLowEnergy.Descriptor)} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-readDescriptorValue * @return {undefined} */ chrome.bluetoothLowEnergy.readDescriptorValue = function(descriptorId, callback) {}; /** * @param {string} descriptorId * @param {!ArrayBuffer} value * @param {function()} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-writeDescriptorValue * @return {undefined} */ chrome.bluetoothLowEnergy.writeDescriptorValue = function(descriptorId, value, callback) {}; /** * Event whose listeners take a Service parameter. * @constructor */ chrome.bluetoothLowEnergy.ServiceEvent = function() {}; /** * @param {function(!chrome.bluetoothLowEnergy.Service): void} callback * @return {undefined} */ chrome.bluetoothLowEnergy.ServiceEvent.prototype.addListener = function(callback) {}; /** * @param {function(!chrome.bluetoothLowEnergy.Service): void} callback * @return {undefined} */ chrome.bluetoothLowEnergy.ServiceEvent.prototype.removeListener = function(callback) {}; /** * @param {function(!chrome.bluetoothLowEnergy.Service): void} callback * @return {boolean} */ chrome.bluetoothLowEnergy.ServiceEvent.prototype.hasListener = function(callback) {}; /** @return {boolean} */ chrome.bluetoothLowEnergy.ServiceEvent.prototype.hasListeners = function() {}; /** * @type {!chrome.bluetoothLowEnergy.ServiceEvent} * @see https://developer.chrome.com/apps/bluetoothLowEnergy#event-onServiceAdded */ chrome.bluetoothLowEnergy.onServiceAdded; /** * @type {!chrome.bluetoothLowEnergy.ServiceEvent} * @see https://developer.chrome.com/apps/bluetoothLowEnergy#event-onServiceChanged */ chrome.bluetoothLowEnergy.onServiceChanged; /** * @type {!chrome.bluetoothLowEnergy.ServiceEvent} * @see https://developer.chrome.com/apps/bluetoothLowEnergy#event-onServiceRemoved */ chrome.bluetoothLowEnergy.onServiceRemoved; /** * Event whose listeners take a Characteristic parameter. * @constructor */ chrome.bluetoothLowEnergy.CharacteristicEvent = function() {}; /** * @param {function(!chrome.bluetoothLowEnergy.Characteristic): void} * callback * @return {undefined} */ chrome.bluetoothLowEnergy.CharacteristicEvent.prototype.addListener = function(callback) {}; /** * @param {function(!chrome.bluetoothLowEnergy.Characteristic): void} * callback * @return {undefined} */ chrome.bluetoothLowEnergy.CharacteristicEvent.prototype.removeListener = function(callback) {}; /** * @param {function(!chrome.bluetoothLowEnergy.Characteristic): void} * callback * @return {boolean} */ chrome.bluetoothLowEnergy.CharacteristicEvent.prototype.hasListener = function(callback) {}; /** @return {boolean} */ chrome.bluetoothLowEnergy.CharacteristicEvent.prototype.hasListeners = function() {}; /** * @type {!chrome.bluetoothLowEnergy.CharacteristicEvent} * @see https://developer.chrome.com/apps/bluetoothLowEnergy#event-onCharacteristicValueChanged */ chrome.bluetoothLowEnergy.onCharacteristicValueChanged; /** * Event whose listeners take a Characteristic parameter. * @constructor */ chrome.bluetoothLowEnergy.DescriptorEvent = function() {}; /** * @param {function(!chrome.bluetoothLowEnergy.Descriptor): void} * callback * @return {undefined} */ chrome.bluetoothLowEnergy.DescriptorEvent.prototype.addListener = function(callback) {}; /** * @param {function(!chrome.bluetoothLowEnergy.Descriptor): void} * callback * @return {undefined} */ chrome.bluetoothLowEnergy.DescriptorEvent.prototype.removeListener = function(callback) {}; /** * @param {function(!chrome.bluetoothLowEnergy.Descriptor): void} callback * @return {boolean} */ chrome.bluetoothLowEnergy.DescriptorEvent.prototype.hasListener = function(callback) {}; /** @return {boolean} */ chrome.bluetoothLowEnergy.DescriptorEvent.prototype.hasListeners = function() {}; /** * @type {!chrome.bluetoothLowEnergy.DescriptorEvent} * @see https://developer.chrome.com/apps/bluetoothLowEnergy#event-onDescriptorValueChanged */ chrome.bluetoothLowEnergy.onDescriptorValueChanged; /** * @see http://developer.chrome.com/extensions/commands.html * @const */ chrome.commands = {}; /** * @param {function(Array<string>): void} callback Callback function. * @return {undefined} */ chrome.commands.getAll = function(callback) {}; /** @type {!ChromeEvent} */ chrome.commands.onCommand; /** * @see https://developer.chrome.com/apps/copresence * @const */ chrome.copresence = {}; /** * @typedef {?{ * lowPower: (boolean|undefined), * onlyBroadcast: (boolean|undefined), * onlyScan: (boolean|undefined), * audible: (boolean|undefined) * }} * @see https://developer.chrome.com/apps/copresence#type-Strategy */ chrome.copresence.Strategy; /** * @typedef {?{ * type: string, * payload: ArrayBuffer * }} * @see https://developer.chrome.com/apps/copresence#type-Message */ chrome.copresence.Message; /** * @typedef {?{ * onlyEarshot: (boolean|undefined) * }} * https://developer.chrome.com/apps/copresence#type-AccessPolicy */ chrome.copresence.AccessPolicy; /** * @typedef {?{ * id: string, * message: !chrome.copresence.Message, * timeToLiveMillis: (number|undefined), * policy: (!chrome.copresence.AccessPolicy|undefined), * strategies: (!chrome.copresence.Strategy|undefined) * }} * @see https://developer.chrome.com/apps/copresence#type-PublishOperation */ chrome.copresence.PublishOperation; /** @typedef {?{type: string}} */ chrome.copresence.SubscriptionFilter; /** * @typedef {?{ * id: string, * filter: !chrome.copresence.SubscriptionFilter, * timeToLiveMillis: (number|undefined), * strategies: (!chrome.copresence.Strategy|undefined) * }} * @see https://developer.chrome.com/apps/copresence#type-SubscribeOperation */ chrome.copresence.SubscribeOperation; /** * @typedef {?{ * unpublishId: string * }} * @see https://developer.chrome.com/apps/copresence#type-UnpublishOperation */ chrome.copresence.UnpublishOperation; /** * @typedef {?{ * unsubscribeId: string *