UNPKG

google-closure-compiler

Version:

Check, compile, optimize and compress Javascript with Closure-Compiler

1,830 lines (1,367 loc) • 331 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 changes 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 interior optional parameters * that are not at the end of the parameter list, 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 that are 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 record type so object literals and objects created via * goog.object are acceptable. (Note: a named record type may be declared using * the at-record syntax; an anonymous record type may be described using the * {foo: !Foo, ...} syntax. Anonymous record types may be named using an * at-typedef annotation. See * https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System * for more information.) For example, the Permissions type defined at * http://developer.chrome.com/extensions/permissions.html#type-Permissions * could be: * * / ** * * at-typedef {?{ * * permissions: (!Array<string>|undefined), * * origins: (!Array<string>|undefined), * * }} * * / * chrome.permissions.Permissions; * * Using record types provides type-safety for the fields that are defined in * the object literal and also defined in the record type. Note that record * types define a minimal interface and will not complain about extraneous * (often misspelled) fields. * * Also, 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.runtime.Port = function() {} * Don't: * function Port() {} * * Note that, unfortunately, the actual Port class definition in this file * does not follow this recommendation. * * For #3, the introduction of arrow functions that are frequently used for * callbacks has changed things. Prior to arrow functions, the Best Practices * recommended using !Object since that's what in the docs. It was tempting to * define a real type within this file and treat this situation as identical to * #2, but that meant a new type was being defined in this file and developers * did not expect to find required new types in extension files. * * Arrow functions change things. The common use of them does not include * specifying a type for the callback's param, so the compiler infers the type * from the externs file. This is good and happens automatically with no actions * required of the developer. Futhermore, since the param has a type, field * references can use dot access, obj.someField, vs bracket access, * obj['someField'] as required for !Object. * * So, for #3, the best practice is to define a record type for the parameter. * See chrome.proxy.settings.GetResponse for an example. As mentioned above in * the section for #1, there are three common ways to introduce a record type * and any of them are acceptable. Of course, if a type is going to be used more * than once, it should be named. * * While the externs file will define an undocumented record type for a * callback's param, using !Object as specified in the docs will continue to * work. This is crucial when a callback is a regular function, as opposed to an * arrow function (whose parameter's type can be inferred). * * D. Events * Most packages define a set of events with the standard set of methods: * addListener, removeListener, hasListener and hasListeners. ChromeVoidEvent * is the appropriate type when an event's listeners do not take any * parameters, however, many events take parameters specific to that event. * * For those cases, create a record type for the event that extends * ChromeBaseEvent with the correct listener function type filled in. * See any of the Event type definitions below that extend ChromeBaseEvent for * an example. * * In some cases the addListener method takes more than one argument, so * inheritance from ChromeBaseEvent will not work. In those cases extend * ChromeBaseEventNoListeners instead and add the listener interfaces * explicitly. See any of the Event type definitions below that extend * ChromeBaseEventNoListeners for an example. * * 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.caretHighlight; /** @type {!ChromeSetting} */ chrome.accessibilityFeatures.cursorHighlight; /** @type {!ChromeSetting} */ chrome.accessibilityFeatures.cursorColor; /** @type {!ChromeSetting} */ chrome.accessibilityFeatures.dockedMagnifier; /** @type {!ChromeSetting} */ chrome.accessibilityFeatures.focusHighlight; /** @type {!ChromeSetting} */ chrome.accessibilityFeatures.selectToSpeak; /** @type {!ChromeSetting} */ chrome.accessibilityFeatures.switchAccess; /** @type {!ChromeSetting} */ chrome.accessibilityFeatures.animationPolicy; /** * @const * @see https://developer.chrome.com/extensions/browserAction.html */ chrome.action = {}; /** * @typedef {{ * tabId: (number|undefined) * }} * @see https://developer.chrome.com/extensions/action#type-TabDetails */ chrome.action.TabDetails; /** * @typedef {{ * isOnToolbar: boolean * }} * @see https://developer.chrome.com/extensions/action#type-UserSettings */ chrome.action.UserSettings; /** * @typedef {{ * windowId: (number|undefined) * }} * @see https://developer.chrome.com/extensions/action#type-OpenPopupOptions */ chrome.action.OpenPopupOptions; /** * @param {{ * title: string, * tabId: (number|undefined) * }} details * @param {function(): void=} opt_callback * @return {undefined} * @see https://developer.chrome.com/extensions/action#method-setTitle */ chrome.action.setTitle = function(details, opt_callback) {}; /** * @param {!chrome.action.TabDetails} details * @param {function(string): void} callback * @return {undefined} * @see https://developer.chrome.com/extensions/action#method-getTitle */ chrome.action.getTitle = function(details, callback) {}; /** * @param {!chrome.browserAction.SetIconImageData} details * @param {function(): void=} opt_callback * @return {undefined} * @see https://developer.chrome.com/extensions/action#method-setIcon */ chrome.action.setIcon = function(details, opt_callback) {}; /** * @param {{ * tabId: (number|undefined), * popup: string * }} details * @param {function(): void=} opt_callback * @return {undefined} * @see https://developer.chrome.com/extensions/action#method-setPopup */ chrome.action.setPopup = function(details, opt_callback) {}; /** * @param {!chrome.action.TabDetails} details * @param {function(string): void} callback * @return {undefined} * @see https://developer.chrome.com/extensions/action#method-getPopup */ chrome.action.getPopup = function(details, callback) {}; /** * @param {{ * text: string, * tabId: (number|undefined) * }} details * @param {function(): void=} opt_callback * @return {undefined} * @see https://developer.chrome.com/extensions/action#method-setBadgeText */ chrome.action.setBadgeText = function(details, opt_callback) {}; /** * @param {!chrome.action.TabDetails} details * @param {function(string): void} callback * @return {undefined} * @see https://developer.chrome.com/extensions/action#method-getBadgeText */ chrome.action.getBadgeText = function(details, callback) {}; /** * @param {{ * color: (string|!chrome.browserAction.ColorArray), * tabId: (number|undefined) * }} details * @param {function(): void=} opt_callback * @return {undefined} * @see https://developer.chrome.com/extensions/action#method-setBadgeBackgroundColor */ chrome.action.setBadgeBackgroundColor = function(details, opt_callback) {}; /** * @param {!chrome.action.TabDetails} details * @param {function(!chrome.browserAction.ColorArray): void} callback * @return {undefined} * @see https://developer.chrome.com/extensions/action#method-getBadgeBackgroundColor */ chrome.action.getBadgeBackgroundColor = function(details, callback) {}; /** * @param {number=} opt_tabId * @param {function(): void=} opt_callback * @return {undefined} * @see https://developer.chrome.com/extensions/action#method-enable */ chrome.action.enable = function(opt_tabId, opt_callback) {}; /** * @param {number=} opt_tabId * @param {function(): void=} opt_callback * @return {undefined} * @see https://developer.chrome.com/extensions/action#method-disable */ chrome.action.disable = function(opt_tabId, opt_callback) {}; /** * @param {?number|undefined} tabId * @param {function(boolean): void} callback * @return {undefined} * @see https://developer.chrome.com/extensions/action#method-isEnabled */ chrome.action.isEnabled = function(tabId, callback) {}; /** * @param {function(!chrome.action.UserSettings): void} callback * @return {undefined} * @see https://developer.chrome.com/extensions/action#method-getUserSettings */ chrome.action.getUserSettings = function(callback) {}; /** * @param {?chrome.action.OpenPopupOptions|undefined} options * @param {function(): void} callback * @return {undefined} * @see https://developer.chrome.com/extensions/action#method-openPopup */ chrome.action.openPopup = function(options, callback) {}; /** * @interface * @extends {ChromeBaseEvent<function(!Tab)>} */ chrome.action.ActionTabEvent = function() {}; /** * @type {!chrome.action.ActionTabEvent} * @see https://developer.chrome.com/extensions/action#event-onClicked */ chrome.action.onClicked; /** * @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.onEmbedRequested; /** * @constructor * @see https://developer.chrome.com/apps/app_runtime#event-onLaunched */ chrome.app.runtime.LaunchData = function() {}; /** @type {!Array<{entry: !FileEntry, type: (string|undefined)}>|undefined} */ chrome.app.runtime.LaunchData.prototype.items; /** @type {boolean|undefined} */ chrome.app.runtime.LaunchData.prototype.isKioskSession; /** @type {string|undefined} */ chrome.app.runtime.LaunchData.prototype.source; /** @type {!ChromeBaseEvent<function(!chrome.app.runtime.LaunchData)>} */ 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) {}; /** * @interface * @extends {ChromeBaseEvent<function(!Array<!chrome.audioModem.ReceivedToken>)>} */ chrome.audioModem.ReceivedEvent = 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. * @interface * @extends {ChromeBaseEvent<function(!chrome.bluetooth.AdapterState)>} */ chrome.bluetooth.AdapterStateEvent = function() {}; /** * @type {!chrome.bluetooth.AdapterStateEvent} * @see https://developer.chrome.com/apps/bluetooth#event-onAdapterStateChanged */ chrome.bluetooth.onAdapterStateChanged; /** * Event whose listeners take an Device parameter. * @interface * @extends {ChromeBaseEvent<function(!chrome.bluetooth.Device)>} */ chrome.bluetooth.DeviceEvent = 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. * @interface * @extends {ChromeBaseEvent<function(!chrome.bluetoothSocket.AcceptEventData)>} */ chrome.bluetoothSocket.AcceptEvent = 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. * @interface * @extends {ChromeBaseEvent<function(!chrome.bluetoothSocket.AcceptErrorEventData)>} */ chrome.bluetoothSocket.AcceptErrorEvent = 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. * @interface * @extends * {ChromeBaseEvent<function(!chrome.bluetoothSocket.ReceiveEventData)>} */ chrome.bluetoothSocket.ReceiveEvent = 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. * @interface * @extends {ChromeBaseEvent< * function(!chrome.bluetoothSocket.ReceiveErrorEventData)>} */ chrome.bluetoothSocket.ReceiveErrorEvent = function() {}; /** @type {!chrome.bluetoothSocket.ReceiveErrorEvent} */ chrome.bluetoothSocket.onReceiveError; /** * @see https://developer.chrome.com/apps/bluetoothLowEnergy * @const */ chrome.bluetoothLowEnergy = {}; /** * @typedef {?{ * uuid: string, * isPrimary: boolean, * instanceId: (string|undefined), * deviceAddress: (string|undefined) * }} * @see https://developer.chrome.com/apps/bluetoothLowEnergy#type-Service */ chrome.bluetoothLowEnergy.Service; /** * @constructor * @see https://developer.chrome.com/apps/bluetoothLowEnergy#type-Request */ chrome.bluetoothLowEnergy.Request = function() {}; /** @type {number} */ chrome.bluetoothLowEnergy.Request.prototype.requestId; /** @type {!Object} */ chrome.bluetoothLowEnergy.Request.prototype.device; /** @type {!ArrayBuffer|undefined} */ chrome.bluetoothLowEnergy.Request.prototype.value; /** * @typedef {?{ * uuid: string, * service: (!chrome.bluetoothLowEnergy.Service|undefined), * properties: !Array<string>, * instanceId: (string|undefined), * value: (!ArrayBuffer|undefined) * }} * @see https://developer.chrome.com/apps/bluetoothLowEnergy#type-Characteristic */ chrome.bluetoothLowEnergy.Characteristic; /** * @typedef {?{ * uuid: string, * characteristic: (!chrome.bluetoothLowEnergy.Characteristic|undefined), * permissions: !Array<string>, * instanceId: (string|undefined), * value: (!ArrayBuffer|undefined) * }} * @see https://developer.chrome.com/apps/bluetoothLowEnergy#type-Descriptor */ chrome.bluetoothLowEnergy.Descriptor; /** * @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 {!chrome.bluetoothLowEnergy.Service} service * @param {function(string)} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-createService * @return {undefined} */ chrome.bluetoothLowEnergy.createService = function(service, 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 {!chrome.bluetoothLowEnergy.Characteristic} characteristic * @param {string} serviceId * @param {function(string)} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-createCharacteristic * @return {undefined} */ chrome.bluetoothLowEnergy.createCharacteristic = function( characteristic, serviceId, 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 {!chrome.bluetoothLowEnergy.Descriptor} descriptor * @param {string} characteristicId * @param {function(string)} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-createDescriptor * @return {undefined} */ chrome.bluetoothLowEnergy.createDescriptor = function( descriptor, characteristicId, 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) {}; /** * @typedef {?{ * value: !ArrayBuffer, * shouldIndicate: (boolean|undefined) * }} */ chrome.bluetoothLowEnergy.NotificationIndication; /** * @param {string} characteristicId * @param {!chrome.bluetoothLowEnergy.NotificationIndication} notification * @param {function()} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-notifyCharacteristicValueChanged * @return {undefined} */ chrome.bluetoothLowEnergy.notifyCharacteristicValueChanged = function( characteristicId, notification, 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) {}; /** * @param {string} serviceId * @param {function()} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-registerService * @return {undefined} */ chrome.bluetoothLowEnergy.registerService = function(serviceId, callback) {}; /** * @param {string} serviceId * @param {function()} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-unregisterService * @return {undefined} */ chrome.bluetoothLowEnergy.unregisterService = function(serviceId, callback) {}; /** * @param {string} serviceId * @param {function()=} opt_callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-removeService * @return {undefined} */ chrome.bluetoothLowEnergy.removeService = function(serviceId, opt_callback) {}; /** * @typedef {?{ * type: string, * serviceUuids: (!Array<string>|undefined), * manufacturerData: (!Array<{id: number, data: !Array<number>}>|undefined), * solicitUuids: (!Array<string>|undefined), * serviceData: (!Array<{uuid: string, data: !Array<number>}>|undefined) * }} */ chrome.bluetoothLowEnergy.Advertisement; /** * @param {!chrome.bluetoothLowEnergy.Advertisement} advertisement * @param {function(number)} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-registerAdvertisement */ chrome.bluetoothLowEnergy.registerAdvertisement = function( advertisement, callback) {}; /** * @param {number} advertisementId * @param {function()} callback * @see https://developer.chrome.com/apps/bluetoothLowEnergy#method-unregisterAdvertisement */ chrome.bluetoothLowEnergy.unregisterAdvertisement = function( advertisementId, callback) {}; /** * @param {function()} callback * @se