Skip to content

Commit

Permalink
Add closure-library externs for csp, and our own hack file for elemen…
Browse files Browse the repository at this point in the history
…tal2
  • Loading branch information
niloc132 committed Nov 4, 2023
1 parent 5875f53 commit 1d04521
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 0 deletions.
86 changes: 86 additions & 0 deletions externs/browser/cspviolationobserver_externs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Externs used by cspviolationobserver.js that are not available
* in the open-source Closure compiler release. This file should be deleted
* once w3c_reporting_observer.js is available in open-source externs.
*
* @externs
*/

// TODO(user): Remove this file once w3c_reporting_observer.js is
// available in the open-source Closure compiler.

/**
* https://w3c.github.io/reporting/#interface-reporting-observer
* @constructor
* @param {!ReportingObserverCallback} callback
* @param {!ReportingObserverOptions} opts
*/
function ReportingObserver2(callback, opts) {}
/** @return {void} */
ReportingObserver2.prototype.observe = function() {};
/** @return {void} */
ReportingObserver2.prototype.disconnect = function() {};
/** @return {!Array<!Report>} */
ReportingObserver2.prototype.takeRecords = function() {};

/**
* @typedef {ReportingObserver2|ReportingObserver}
* @suppress {duplicate}
*/
var ReportingObserver;


/**
* @typedef {!function(!Array<Report>, !ReportingObserver): void}
* @suppress {duplicate}
*/
var ReportingObserverCallback;


/**
* @constructor
*/
function ReportingObserverOptions2() {}
/** @type {undefined|!Array<string>} */
ReportingObserverOptions2.prototype.types;
/** @type {boolean} */
ReportingObserverOptions2.prototype.buffered;

/**
* @typedef {ReportingObserverOptions2|ReportingObserverOptions}
* @suppress {duplicate}
*/
var ReportingObserverOptions;


/**
* @constructor
* @suppress {duplicate}
*/
function Report2() {}
/** @type {string} */ Report2.prototype.type;
/** @type {string} */ Report2.prototype.url;
/** @type {?ReportBody} */ Report2.prototype.body;

/**
* @typedef {Report2|Report}
* @suppress {duplicate}
*/
var Report;


/**
* @constructor
*/
function ReportBody2() {}

/**
* @typedef {ReportBody2|ReportBody2}
* @suppress {duplicate}
*/
var ReportBody;
54 changes: 54 additions & 0 deletions externs/browser/elemental2-1.1.0-hack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* @fileoverview Describes types present in elemental2 1.1.0 that are not in closure-compiler, since they aren't
* real browser types. Presently this only contains the `WebWorker` type which never existed as a browser type,
* but showed up in closure-compiler as a typo or early draft or something. As long as elemental2 1.1.0 is
* supported, we must keep this file in our closure-compiler fork.
*
* TODO Remove this once elemental2 1.1.0 is considered to be unsupported by j2cl - this day may not come soon,
* if ever, as it is a "stable" release.
*
* @externs
*/

/**
* @see http://dev.w3.org/html5/workers/
* @constructor
* @implements {EventTarget}
*/
function WebWorker() {}

/** @override */
WebWorker.prototype.addEventListener = function(type, listener, opt_options) {};

/** @override */
WebWorker.prototype.removeEventListener = function(
type, listener, opt_options) {};

/** @override */
WebWorker.prototype.dispatchEvent = function(evt) {};

/**
* Stops the worker process
* @return {undefined}
*/
WebWorker.prototype.terminate = function() {};

/**
* Posts a message to the worker thread.
* @param {string} message
* @return {undefined}
*/
WebWorker.prototype.postMessage = function(message) {};

/**
* Sent when the worker thread posts a message to its creator.
* @type {?function(!MessageEvent<*>): void}
*/
WebWorker.prototype.onmessage;

/**
* Sent when the worker thread encounters an error.
* @type {?function(!ErrorEvent): void}
*/
WebWorker.prototype.onerror;

0 comments on commit 1d04521

Please sign in to comment.