Skip to content

Instantly share code, notes, and snippets.

@orian
Created November 2, 2017 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save orian/0bed94b92f571bf65522e440532e94d9 to your computer and use it in GitHub Desktop.
Save orian/0bed94b92f571bf65522e440532e94d9 to your computer and use it in GitHub Desktop.
A Google Closure Library DefinitelyTyped typings
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_eventsource.js
//!! Processing provides [goog.labs.userAgent.engine] from input closure-library/closure/goog/labs/useragent/engine.js
//!! Processing provides [goog.html.TrustedResourceUrl] from input closure-library/closure/goog/html/trustedresourceurl.js
//!! Processing provides [goog.events.EventId] from input closure-library/closure/goog/events/eventid.js
//!! Processing provides [goog.html.SafeUrl] from input closure-library/closure/goog/html/safeurl.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/intl.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_pointerlock.js
//!! Processing provides [goog.dom.vendor] from input closure-library/closure/goog/dom/vendor.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_vibration.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/webkit_notifications.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_geolocation.js
//!! Processing provides [goog.asserts, goog.asserts.AssertionError] from input closure-library/closure/goog/asserts/asserts.js
//!! Processing provides [goog.debug.errorcontext] from input closure-library/closure/goog/debug/errorcontext.js
//!! Processing provides [goog.dom.asserts] from input closure-library/closure/goog/dom/asserts.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_gamepad.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/deprecated.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_requestidlecallback.js
//!! Processing provides [goog.Disposable, goog.dispose, goog.disposeAll] from input closure-library/closure/goog/disposable/disposable.js
//!! Processing provides [goog.net.EventType] from input closure-library/closure/goog/net/eventtype.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_rtc.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/gecko_event.js
//!! Processing provides [goog.dom.BrowserFeature] from input closure-library/closure/goog/dom/browserfeature.js
//!! Processing provides [goog.debug.LogManager, goog.debug.Loggable, goog.debug.Logger, goog.debug.Logger.Level] from input closure-library/closure/goog/debug/logger.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_selectors.js
//!! Processing provides [goog.structs.Map] from input closure-library/closure/goog/structs/map.js
//!! Processing provides [] from input tools/closure-compiler/externs/es3.js
//!! Processing provides [goog.labs.userAgent.browser] from input closure-library/closure/goog/labs/useragent/browser.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/iphone.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_elementtraversal.js
//!! Processing provides [goog.events.Listenable, goog.events.ListenableKey] from input closure-library/closure/goog/events/listenable.js
//!! Processing provides [goog.html.SafeScript] from input closure-library/closure/goog/html/safescript.js
//!! Processing provides [goog.debug.LogRecord] from input closure-library/closure/goog/debug/logrecord.js
//!! Processing provides [goog.net.DefaultXmlHttpFactory, goog.net.XmlHttp, goog.net.XmlHttp.OptionType, goog.net.XmlHttp.ReadyState, goog.net.XmlHttpDefines] from input closure-library/closure/goog/net/xmlhttp.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/gecko_dom.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_dom3.js
//!! Processing provides [goog.events.EventTarget] from input closure-library/closure/goog/events/eventtarget.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/flash.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/google.js
//!! Processing provides [goog.dom.HtmlElement] from input closure-library/closure/goog/dom/htmlelement.js
//!! Processing provides [goog.async.run] from input closure-library/closure/goog/async/run.js
//!! Processing provides [goog.dom.TagName] from input closure-library/closure/goog/dom/tagname.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/webkit_event.js
//!! Processing provides [goog.dom.NodeType] from input closure-library/closure/goog/dom/nodetype.js
//!! Processing provides [goog.dom, goog.dom.Appendable, goog.dom.DomHelper] from input closure-library/closure/goog/dom/dom.js
//!! Processing provides [goog.uri.utils, goog.uri.utils.ComponentIndex, goog.uri.utils.QueryArray, goog.uri.utils.QueryValue, goog.uri.utils.StandardQueryParam] from input closure-library/closure/goog/uri/utils.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/v8.js
//!! Processing provides [goog.events.BrowserEvent, goog.events.BrowserEvent.MouseButton, goog.events.BrowserEvent.PointerType] from input closure-library/closure/goog/events/browserevent.js
//!! Processing provides [goog.object] from input closure-library/closure/goog/object/object.js
//!! Processing provides [goog.reflect] from input closure-library/closure/goog/reflect/reflect.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_serviceworker.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_css3d.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/streamsapi.js
//!! Processing provides [goog.events.ListenerMap] from input closure-library/closure/goog/events/listenermap.js
//!! Processing provides [goog.labs.userAgent.util] from input closure-library/closure/goog/labs/useragent/util.js
//!! Processing provides [] from input [synthetic:base]
//!! Processing provides [goog.debug] from input closure-library/closure/goog/debug/debug.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_midi.js
//!! Processing provides [goog.labs.dom.PageVisibilityEvent, goog.labs.dom.PageVisibilityMonitor, goog.labs.dom.PageVisibilityState] from input closure-library/closure/goog/labs/dom/pagevisibilitymonitor.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/intersection_observer.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_css.js
//!! Processing provides [goog.iter, goog.iter.Iterable, goog.iter.Iterator, goog.iter.StopIteration] from input closure-library/closure/goog/iter/iter.js
//!! Processing provides [goog.net.CorsXmlHttpFactory, goog.net.IeCorsXhrAdapter] from input closure-library/closure/goog/net/corsxmlhttpfactory.js
//!! Processing provides [] from input tools/closure-compiler/externs/es5.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_indexeddb.js
//!! Processing provides [goog.Promise] from input closure-library/closure/goog/promise/promise.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_range.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_dom1.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/url.js
//!! Processing provides [goog.debug.Error] from input closure-library/closure/goog/debug/error.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_pointer_events.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/mediakeys.js
//!! Processing provides [goog.userAgent] from input closure-library/closure/goog/useragent/useragent.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_navigation_timing.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_webcrypto.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/page_visibility.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_audio.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/html5.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_touch_event.js
//!! Processing provides [goog.debug.EntryPointMonitor, goog.debug.entryPointRegistry] from input closure-library/closure/goog/debug/entrypointregistry.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_xml.js
//!! Processing provides [goog.json.hybrid] from input closure-library/closure/goog/json/hybrid.js
//!! Processing provides [goog.promise.Resolver] from input closure-library/closure/goog/promise/resolver.js
//!! Processing provides [goog.disposable.IDisposable] from input closure-library/closure/goog/disposable/idisposable.js
//!! Processing provides [goog.html.SafeStyleSheet] from input closure-library/closure/goog/html/safestylesheet.js
//!! Processing provides [goog.json, goog.json.Replacer, goog.json.Reviver, goog.json.Serializer] from input closure-library/closure/goog/json/json.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_dom4.js
//!! Processing provides [goog.math.Size] from input closure-library/closure/goog/math/size.js
//!! Processing provides [goog.math.Coordinate] from input closure-library/closure/goog/math/coordinate.js
//!! Processing provides [goog.array] from input closure-library/closure/goog/array/array.js
//!! Processing provides [goog.net.XhrLike] from input closure-library/closure/goog/net/xhrlike.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/ie_css.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_event.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/webgl.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/mediasource.js
//!! Processing provides [goog.events.Listener] from input closure-library/closure/goog/events/listener.js
//!! Processing provides [goog.html.SafeHtml] from input closure-library/closure/goog/html/safehtml.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/ie_vml.js
//!! Processing provides [goog.net.WrapperXmlHttpFactory] from input closure-library/closure/goog/net/wrapperxmlhttpfactory.js
//!! Processing provides [goog.Thenable] from input closure-library/closure/goog/promise/thenable.js
//!! Processing provides [goog.Timer] from input closure-library/closure/goog/timer/timer.js
//!! Processing provides [goog.events, goog.events.CaptureSimulationMode, goog.events.Key, goog.events.ListenableType] from input closure-library/closure/goog/events/events.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/window.js
//!! Processing provides [goog.html.uncheckedconversions] from input closure-library/closure/goog/html/uncheckedconversions.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/ie_event.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_netinfo.js
//!! Processing provides [goog.math] from input closure-library/closure/goog/math/math.js
//!! Processing provides [goog.async.WorkItem, goog.async.WorkQueue] from input closure-library/closure/goog/async/workqueue.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/webstorage.js
//!! Processing provides [goog.net.HttpStatus] from input closure-library/closure/goog/net/httpstatus.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_screen_orientation.js
//!! Processing provides [goog] from input closure-library/closure/goog/base.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/whatwg_encoding.js
//!! Processing provides [goog.labs.userAgent.platform] from input closure-library/closure/goog/labs/useragent/platform.js
//!! Processing provides [goog.html.SafeStyle] from input closure-library/closure/goog/html/safestyle.js
//!! Processing provides [goog.events.EventType, goog.events.PointerFallbackEventType] from input closure-library/closure/goog/events/eventtype.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_batterystatus.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/webkit_dom.js
//!! Processing provides [goog.log, goog.log.Level, goog.log.LogRecord, goog.log.Logger] from input closure-library/closure/goog/log/log.js
//!! Processing provides [goog.async.nextTick, goog.async.throwException] from input closure-library/closure/goog/async/nexttick.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_device_sensor_event.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_permissions.js
//!! Processing provides [goog.memoize] from input closure-library/closure/goog/memoize/memoize.js
//!! Processing provides [goog.string, goog.string.Unicode] from input closure-library/closure/goog/string/string.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_dom2.js
//!! Processing provides [goog.functions] from input closure-library/closure/goog/functions/functions.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/gecko_css.js
//!! Processing provides [goog.string.TypedString] from input closure-library/closure/goog/string/typedstring.js
//!! Processing provides [goog.dom.safe, goog.dom.safe.InsertAdjacentHtmlPosition] from input closure-library/closure/goog/dom/safe.js
//!! Processing provides [goog.math.ExponentialBackoff] from input closure-library/closure/goog/math/exponentialbackoff.js
//!! Processing provides [goog.net.Cookies, goog.net.cookies] from input closure-library/closure/goog/net/cookies.js
//!! Processing provides [goog.events.Event, goog.events.EventLike] from input closure-library/closure/goog/events/event.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/gecko_xml.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/webkit_usercontent.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/fileapi.js
//!! Processing provides [goog.net.XhrIo, goog.net.XhrIo.ResponseType] from input closure-library/closure/goog/net/xhrio.js
//!! Processing provides [goog.i18n.bidi, goog.i18n.bidi.Dir, goog.i18n.bidi.DirectionalString, goog.i18n.bidi.Format] from input closure-library/closure/goog/i18n/bidi.js
//!! Processing provides [] from input tools/closure-compiler/externs/es6_collections.js
//!! Processing provides [goog.events.BrowserFeature] from input closure-library/closure/goog/events/browserfeature.js
//!! Processing provides [goog.dom.tags] from input closure-library/closure/goog/dom/tags.js
//!! Processing provides [goog.structs] from input closure-library/closure/goog/structs/structs.js
//!! Processing provides [goog.debug.LogBuffer] from input closure-library/closure/goog/debug/logbuffer.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/ie_dom.js
//!! Processing provides [goog.fs.url] from input closure-library/closure/goog/fs/url.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_event3.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/webkit_css.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/fetchapi.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_anim_timing.js
//!! Processing provides [] from input tools/closure-compiler/externs/es6.js
//!! Processing provides [goog.net.XmlHttpFactory] from input closure-library/closure/goog/net/xmlhttpfactory.js
//!! Processing provides [goog.string.Const] from input closure-library/closure/goog/string/const.js
//!! Processing provides [goog.async.FreeList] from input closure-library/closure/goog/async/freelist.js
//!! Processing provides [goog.net.ErrorCode] from input closure-library/closure/goog/net/errorcode.js
declare namespace goog {
var DEBUG : boolean ;
var DEBUG_LOADER : string ;
/**
* True if goog.dependencies_ is available.
*/
var DEPENDENCIES_ENABLED : boolean ;
var DISALLOW_TEST_ONLY_CODE : boolean ;
/**
* A debug loader is responsible for downloading and executing javascript
* files in an unbundled, uncompiled environment.
*/
class DebugLoader extends DebugLoader_Instance {
}
class DebugLoader_Instance {
private noStructuralTyping_: any;
addDependency (relPath : string , provides : string [] , requires : string [] , opt_loadFlags ? : boolean | { [ /* warning: coerced from ? */ key: string ]: string } ) : void ;
/**
* Performs any needed preprocessing of a goog.require call.
*/
earlyProcessLoad (name : string ) : void ;
getTranspiler ( ) : ಠ_ಠ.clutz.goog.Transpiler ;
inHtmlDocument ( ) : boolean ;
isProvided (namespaceOrPath : string ) : boolean ;
/**
* Loads the given symbol along with any dependencies.
*/
load (name : string ) : void ;
loadFileSync (srcUrl : string ) : string | null ;
logToConsole (message : string ) : void ;
normalizePath (path : string ) : string ;
}
var ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING : boolean ;
var ENABLE_DEBUG_LOADER : boolean ;
var LOAD_MODULE_USING_EVAL : boolean ;
var LOCALE : string ;
var NATIVE_ARRAY_PROTOTYPES : boolean ;
var SEAL_MODULE_EXPORTS : boolean ;
var STRICT_MODE_COMPATIBLE : boolean ;
var TRANSPILE : string ;
var TRANSPILER : string ;
var TRUSTED_SITE : boolean ;
class Transpiler extends Transpiler_Instance {
}
class Transpiler_Instance {
private noStructuralTyping_: any;
/**
* Determines whether the given language needs to be transpiled.
*/
needsTranspile (lang : string ) : boolean ;
/**
* Lazily retrieves the transpiler and applies it to the source.
* @param code JS code.
* @param path Path to the code.
*/
transpile (code : string , path : string ) : string ;
}
/**
* When defining a class Foo with an abstract method bar(), you can do:
* Foo.prototype.bar = goog.abstractMethod
*
* Now if a subclass of Foo fails to override bar(), an error will be thrown
* when bar() is invoked.
*/
function abstractMethod ( ...a : any [] ) : any ;
/**
* Adds a dependency from a file to the files it requires.
* @param relPath The path to the js file.
* @param provides An array of strings with the names of the objects this file provides.
* @param requires An array of strings with the names of the objects this file requires.
* @param opt_loadFlags Parameters indicating how the file must be loaded. The boolean 'true' is equivalent to {'module': 'goog'} for backwards-compatibility. Valid properties and values include {'module': 'goog'} and {'lang': 'es6'}.
*/
function addDependency (relPath : string , provides : string [] , requires : string [] , opt_loadFlags ? : boolean | { [ /* warning: coerced from ? */ key: string ]: string } ) : void ;
/**
* Adds a {@code getInstance} static method that always returns the same
* instance object.
* @param ctor The constructor for the class to add the static method to.
*/
function addSingletonGetter (ctor : Function ) : void ;
/**
* Call up to the superclass.
*
* If this is called from a constructor, then this calls the superclass
* constructor with arguments 1-N.
*
* If this is called from a prototype method, then you must pass the name of the
* method as the second argument to this function. If you do not, you will get a
* runtime error. This calls the superclass' method with arguments 2-N.
*
* This function only works if you use goog.inherits to express inheritance
* relationships between your classes.
*
* This function is a compiler primitive. At compile-time, the compiler will do
* macro expansion to remove a lot of the extra overhead that this function
* introduces. The compiler will also enforce a lot of the assumptions that this
* function makes, and treat it as a compiler error if you break them.
* @param me Should always be "this".
* @param opt_methodName The method name if calling a super method.
* @param var_args The rest of the arguments.
*/
function base (me : GlobalObject , opt_methodName ? : any , ...var_args : any [] ) : any ;
/**
* Path for included scripts.
*/
var basePath : string ;
/**
* Partially applies this function to a particular 'this object' and zero or
* more arguments. The result is a new function with some arguments of the first
* function pre-filled and the value of this 'pre-specified'.
*
* Remaining arguments specified at call-time are appended to the pre-specified
* ones.
*
* Also see: {@link #partial}.
*
* Usage:
* <pre>var barMethBound = goog.bind(myFunction, myObj, 'arg1', 'arg2');
* barMethBound('arg3', 'arg4');</pre>
* @param fn A function to partially apply.
* @param selfObj Specifies the object which this should point to when the function is run.
* @param var_args Additional arguments that are partially applied to the function.
*/
function bind < T > (fn : ( ( ...a : any [] ) => any ) | null , selfObj : T , ...var_args : any [] ) : Function ;
/**
* Clones a value. The input may be an Object, Array, or basic type. Objects and
* arrays will be cloned recursively.
*
* WARNINGS:
* <code>goog.cloneObject</code> does not detect reference loops. Objects that
* refer to themselves will cause infinite recursion.
*
* <code>goog.cloneObject</code> is unaware of unique identifiers, and copies
* UIDs created by <code>getUid</code> into cloned results.
* @param obj The value to clone.
*/
function cloneObject (obj : any ) : any ;
/**
* Defines a named value. In uncompiled mode, the value is retrieved from
* CLOSURE_DEFINES or CLOSURE_UNCOMPILED_DEFINES if the object is defined and
* has the property specified, and otherwise used the defined defaultValue.
* When compiled the default can be overridden using the compiler
* options or the value set in the CLOSURE_DEFINES object.
* @param name The distinguished name to provide.
*/
function define (name : string , defaultValue : string | number | boolean ) : void ;
/**
* Creates a restricted form of a Closure "class":
* - from the compiler's perspective, the instance returned from the
* constructor is sealed (no new properties may be added). This enables
* better checks.
* - the compiler will rewrite this definition to a form that is optimal
* for type checking and optimization (initially this will be a more
* traditional form).
* @param superClass The superclass, Object or null.
* @param def An object literal describing the class. It may have the following properties: "constructor": the constructor function "statics": an object literal containing methods to add to the constructor as "static" methods or a function that will receive the constructor function as its only parameter to which static properties can be added. all other properties are added to the prototype.
*/
function defineClass (superClass : Function | null , def : ಠ_ಠ.clutz.goog.defineClass.ClassDescriptor ) : Function ;
/**
* Exports a property unobfuscated into the object's namespace.
* ex. goog.exportProperty(Foo, 'staticFunction', Foo.staticFunction);
* ex. goog.exportProperty(Foo.prototype, 'myMethod', Foo.prototype.myMethod);
* @param object Object whose static property is being exported.
* @param publicName Unobfuscated name to export.
* @param symbol Object the name should point to.
*/
function exportProperty (object : GlobalObject | null , publicName : string , symbol : any ) : void ;
/**
* Exposes an unobfuscated global namespace path for the given object.
* Note that fields of the exported object *will* be obfuscated, unless they are
* exported in turn via this function or goog.exportProperty.
*
* Also handy for making public items that are defined in anonymous closures.
*
* ex. goog.exportSymbol('public.path.Foo', Foo);
*
* ex. goog.exportSymbol('public.path.Foo.staticFunction', Foo.staticFunction);
* public.path.Foo.staticFunction();
*
* ex. goog.exportSymbol('public.path.Foo.prototype.myMethod',
* Foo.prototype.myMethod);
* new public.path.Foo().myMethod();
* @param publicPath Unobfuscated name to export.
* @param object Object the name should point to.
* @param opt_objectToExportTo The object to add the path to; default is goog.global.
*/
function exportSymbol (publicPath : string , object : any , opt_objectToExportTo ? : GlobalObject | null ) : void ;
/**
* Forward declares a symbol. This is an indication to the compiler that the
* symbol may be used in the source yet is not required and may not be provided
* in compilation.
*
* The most common usage of forward declaration is code that takes a type as a
* function parameter but does not need to require it. By forward declaring
* instead of requiring, no hard dependency is made, and (if not required
* elsewhere) the namespace may never be required and thus, not be pulled
* into the JavaScript binary. If it is required elsewhere, it will be type
* checked as normal.
*
* Before using goog.forwardDeclare, please read the documentation at
* https://github.com/google/closure-compiler/wiki/Bad-Type-Annotation to
* understand the options and tradeoffs when working with forward declarations.
* @param name The namespace to forward declare in the form of "goog.package.part".
*/
function forwardDeclare (name : string ) : void ;
/**
* Handles strings that are intended to be used as CSS class names.
*
* This function works in tandem with @see goog.setCssNameMapping.
*
* Without any mapping set, the arguments are simple joined with a hyphen and
* passed through unaltered.
*
* When there is a mapping, there are two possible styles in which these
* mappings are used. In the BY_PART style, each part (i.e. in between hyphens)
* of the passed in css name is rewritten according to the map. In the BY_WHOLE
* style, the full css name is looked up in the map directly. If a rewrite is
* not specified by the map, the compiler will output a warning.
*
* When the mapping is passed to the compiler, it will replace calls to
* goog.getCssName with the strings from the mapping, e.g.
* var x = goog.getCssName('foo');
* var y = goog.getCssName(this.baseClass, 'active');
* becomes:
* var x = 'foo';
* var y = this.baseClass + '-active';
*
* If one argument is passed it will be processed, if two are passed only the
* modifier will be processed, as it is assumed the first argument was generated
* as a result of calling goog.getCssName.
* @param className The class name.
* @param opt_modifier A modifier to be appended to the class name.
*/
function getCssName (className : string , opt_modifier ? : string ) : string ;
/**
* Adds a hash code field to an object. The hash code is unique for the
* given object.
* @param obj The object to get the hash code for.
*/
function getHashCode (a : GlobalObject | null ) : number ;
/**
* Gets a localized message.
*
* This function is a compiler primitive. If you give the compiler a localized
* message bundle, it will replace the string at compile-time with a localized
* version, and expand goog.getMsg call to a concatenated string.
*
* Messages must be initialized in the form:
* <code>
* var MSG_NAME = goog.getMsg('Hello {$placeholder}', {'placeholder': 'world'});
* </code>
*
* This function produces a string which should be treated as plain text. Use
* {@link goog.html.SafeHtmlFormatter} in conjunction with goog.getMsg to
* produce SafeHtml.
* @param str Translatable string, places holders in the form {$foo}.
* @param opt_values Maps place holder name to value.
*/
function getMsg (str : string , opt_values ? : { [ key: string ]: string } | null ) : string ;
/**
* Gets a localized message. If the message does not have a translation, gives a
* fallback message.
*
* This is useful when introducing a new message that has not yet been
* translated into all languages.
*
* This function is a compiler primitive. Must be used in the form:
* <code>var x = goog.getMsgWithFallback(MSG_A, MSG_B);</code>
* where MSG_A and MSG_B were initialized with goog.getMsg.
* @param a The preferred message.
* @param b The fallback message.
*/
function getMsgWithFallback (a : string , b : string ) : string ;
/**
* Returns an object based on its fully qualified external name. The object
* is not found if null or undefined. If you are using a compilation pass that
* renames property names beware that using this function will not find renamed
* properties.
* @param name The fully qualified name.
* @param opt_obj The object within which to look; default is |goog.global|.
*/
function getObjectByName (name : string , opt_obj ? : GlobalObject | null ) : any ;
/**
* Gets a unique ID for an object. This mutates the object so that further calls
* with the same object as a parameter returns the same value. The unique ID is
* guaranteed to be unique across the current session amongst objects that are
* passed into {@code getUid}. There is no guarantee that the ID is unique or
* consistent across sessions. It is unsafe to generate unique ID for function
* prototypes.
* @param obj The object to get the unique ID for.
*/
function getUid (obj : GlobalObject | null ) : number ;
/**
* Evals JavaScript in the global scope. In IE this uses execScript, other
* browsers use goog.global.eval. If goog.global.eval does not evaluate in the
* global scope (for example, in Safari), appends a script tag instead.
* Throws an exception if neither execScript or eval is defined.
* @param script JavaScript string.
*/
function globalEval (script : string ) : void ;
/**
* Globalizes a whole namespace, such as goog or goog.lang.
* @param obj The namespace to globalize.
* @param opt_global The object to add the properties to.
*/
function globalize (obj : GlobalObject , opt_global ? : GlobalObject | null ) : void ;
var hasBadLetScoping : boolean | null ;
/**
* Whether the given object is already assigned a unique ID.
*
* This does not modify the object.
* @param obj The object to check.
*/
function hasUid (obj : GlobalObject ) : boolean ;
/**
* Inherit the prototype methods from one constructor into another.
*
* Usage:
* <pre>
* function ParentClass(a, b) { }
* ParentClass.prototype.foo = function(a) { };
*
* function ChildClass(a, b, c) {
* ChildClass.base(this, 'constructor', a, b);
* }
* goog.inherits(ChildClass, ParentClass);
*
* var child = new ChildClass('a', 'b', 'see');
* child.foo(); // This works.
* </pre>
* @param childCtor Child class.
* @param parentCtor Parent class.
*/
function inherits (childCtor : Function , parentCtor : Function ) : void ;
/**
* Returns true if the specified value is an array.
* @param val Variable to test.
*/
function isArray (val : any ) : boolean ;
/**
* Returns true if the object looks like an array. To qualify as array like
* the value needs to be either a NodeList or an object with a Number length
* property. As a special case, a function value is not array like, because its
* length property is fixed to correspond to the number of expected arguments.
* @param val Variable to test.
*/
function isArrayLike (val : any ) : boolean ;
/**
* Returns true if the specified value is a boolean.
* @param val Variable to test.
*/
function isBoolean (val : any ) : boolean ;
/**
* Returns true if the object looks like a Date. To qualify as Date-like the
* value needs to be an object and have a getFullYear() function.
* @param val Variable to test.
*/
function isDateLike (val : any ) : boolean ;
/**
* Returns true if the specified value is not undefined.
* @param val Variable to test.
*/
function isDef (val : any ) : boolean ;
/**
* Returns true if the specified value is defined and not null.
* @param val Variable to test.
*/
function isDefAndNotNull (val : any ) : boolean ;
/**
* Returns true if the specified value is a function.
* @param val Variable to test.
*/
function isFunction (val : any ) : boolean ;
/**
* Returns true if the specified value is null.
* @param val Variable to test.
*/
function isNull (val : any ) : boolean ;
/**
* Returns true if the specified value is a number.
* @param val Variable to test.
*/
function isNumber (val : any ) : boolean ;
/**
* Returns true if the specified value is an object. This includes arrays and
* functions.
* @param val Variable to test.
*/
function isObject (val : any ) : boolean ;
/**
* Returns true if the specified value is a string.
* @param val Variable to test.
*/
function isString (val : any ) : boolean ;
function loadModule (moduleDef : ( (a : any ) => any ) | string ) : void ;
/**
* Copies all the members of a source object to a target object. This method
* does not work on all browsers for all objects that contain keys such as
* toString or hasOwnProperty. Use goog.object.extend for this purpose.
* @param target Target.
* @param source Source.
*/
function mixin (target : GlobalObject | null , source : GlobalObject | null ) : void ;
/**
* Defines a module in Closure.
*
* Marks that this file must be loaded as a module and claims the namespace.
*
* A namespace may only be defined once in a codebase. It may be defined using
* goog.provide() or goog.module().
*
* goog.module() has three requirements:
* - goog.module may not be used in the same file as goog.provide.
* - goog.module must be the first statement in the file.
* - only one goog.module is allowed per file.
*
* When a goog.module annotated file is loaded, it is enclosed in
* a strict function closure. This means that:
* - any variables declared in a goog.module file are private to the file
* (not global), though the compiler is expected to inline the module.
* - The code must obey all the rules of "strict" JavaScript.
* - the file will be marked as "use strict"
*
* NOTE: unlike goog.provide, goog.module does not declare any symbols by
* itself. If declared symbols are desired, use
* goog.module.declareLegacyNamespace().
*
*
* See the public goog.module proposal: http://goo.gl/Va1hin
* @param name Namespace provided by this file in the form "goog.package.part", is expected but not required.
*/
function module (name : string ) : void ;
function now ( ) : number ;
/**
* Null function used for default values of callbacks, etc.
*/
function nullFunction ( ) : void ;
/**
* Like goog.bind(), except that a 'this object' is not required. Useful when
* the target function is already bound.
*
* Usage:
* var g = goog.partial(f, arg1, arg2);
* g(arg3, arg4);
* @param fn A function to partially apply.
* @param var_args Additional arguments that are partially applied to fn.
*/
function partial (fn : Function | null , ...var_args : any [] ) : Function ;
/**
* Defines a namespace in Closure.
*
* A namespace may only be defined once in a codebase. It may be defined using
* goog.provide() or goog.module().
*
* The presence of one or more goog.provide() calls in a file indicates
* that the file defines the given objects/namespaces.
* Provided symbols must not be null or undefined.
*
* In addition, goog.provide() creates the object stubs for a namespace
* (for example, goog.provide("goog.foo.bar") will create the object
* goog.foo.bar if it does not already exist).
*
* Build tools also scan for provide/require/module statements
* to discern dependencies, build dependency files (see deps.js), etc.
* @param name Namespace provided by this file in the form "goog.package.part".
*/
function provide (name : string ) : void ;
function registerDebugLoader (loader : ಠ_ಠ.clutz.goog.DebugLoader ) : void ;
/**
* Removes the hash code field from an object.
* @param obj The object to remove the field from.
*/
function removeHashCode (a : GlobalObject | null ) : any ;
/**
* Removes the unique ID from an object. This is useful if the object was
* previously mutated using {@code goog.getUid} in which case the mutation is
* undone.
* @param obj The object to remove the unique ID field from.
*/
function removeUid (obj : GlobalObject | null ) : void ;
function require (name : string ) : ಠ_ಠ.clutz.ClosureSymbolNotGoogProvided;
/**
* Allow for aliasing within scope functions. This function exists for
* uncompiled code - in compiled code the calls will be inlined and the aliases
* applied. In uncompiled code the function is simply run since the aliases as
* written are valid JavaScript.
* @param fn Function to call. This function can contain aliases to namespaces (e.g. "var dom = goog.dom") or classes (e.g. "var Timer = goog.Timer").
*/
function scope (fn : ( ) => any ) : void ;
/**
* Sets the map to check when returning a value from goog.getCssName(). Example:
* <pre>
* goog.setCssNameMapping({
* "goog": "a",
* "disabled": "b",
* });
*
* var x = goog.getCssName('goog');
* // The following evaluates to: "a a-b".
* goog.getCssName('goog') + ' ' + goog.getCssName(x, 'disabled')
* </pre>
* When declared as a map of string literals to string literals, the JSCompiler
* will replace all calls to goog.getCssName() using the supplied map if the
* --process_closure_primitives flag is set.
* @param mapping A map of strings to strings where keys are possible arguments to goog.getCssName() and values are the corresponding values that should be returned.
* @param opt_style The style of css name mapping. There are two valid options: 'BY_PART', and 'BY_WHOLE'.
*/
function setCssNameMapping (mapping : GlobalObject , opt_style ? : string ) : void ;
/**
* Marks that the current file should only be used for testing, and never for
* live code in production.
*
* In the case of unit tests, the message may optionally be an exact namespace
* for the test (e.g. 'goog.stringTest'). The linter will then ignore the extra
* provide (if not explicitly defined in the code).
* @param opt_message Optional message to add to the error that's raised when used in production code.
*/
function setTestOnly (opt_message ? : string ) : void ;
/**
* Sealing classes breaks the older idiom of assigning properties on the
* prototype rather than in the constructor. As such, goog.defineClass
* must not seal subclasses of these old-style classes until they are fixed.
* Until then, this marks a class as "broken", instructing defineClass
* not to seal subclasses.
* @param ctr The legacy constructor to tag as unsealable.
*/
function tagUnsealableClass (ctr : Function ) : void ;
/**
* This is a "fixed" version of the typeof operator. It differs from the typeof
* operator in such a way that null returns 'null' and arrays return 'array'.
* @param value The value to get the type of.
*/
function typeOf (value : any ) : string ;
function useSafari10Workaround ( ) : boolean ;
function workaroundSafari10EvalBug (moduleDef : string ) : string ;
}
declare namespace ಠ_ಠ.clutz.goog {
/**
* Class that provides the basic implementation for disposable objects. If your
* class holds one or more references to COM objects, DOM nodes, or other
* disposable objects, it should extend this class or implement the disposable
* interface (defined in goog.disposable.IDisposable).
*/
class Disposable extends Disposable_Instance {
static INCLUDE_STACK_ON_CREATION : boolean ;
static MONITORING_MODE : number ;
/**
* Clears the registry of undisposed objects but doesn't dispose of them.
*/
static clearUndisposedObjects ( ) : void ;
static getUndisposedObjects ( ) : ಠ_ಠ.clutz.goog.Disposable [] ;
/**
* Returns True if we can verify the object is disposed.
* Calls {@code isDisposed} on the argument if it supports it. If obj
* is not an object with an isDisposed() method, return false.
* @param obj The object to investigate.
*/
static isDisposed (obj : any ) : boolean ;
}
class Disposable_Instance implements ಠ_ಠ.clutz.goog.disposable.IDisposable {
private noStructuralTyping_: any;
/**
* If monitoring the goog.Disposable instances is enabled, stores the creation
* stack trace of the Disposable instance.
*/
creationStack ? : string ;
/**
* Invokes a callback function when this object is disposed. Callbacks are
* invoked in the order in which they were added. If a callback is added to
* an already disposed Disposable, it will be called immediately.
* @param callback The callback function.
* @param opt_scope An optional scope to call the callback in.
*/
addOnDisposeCallback < T > (callback : ( ) => any , opt_scope ? : T ) : void ;
/**
* Disposes of the object. If the object hasn't already been disposed of, calls
* {@link #disposeInternal}. Classes that extend {@code goog.Disposable} should
* override {@link #disposeInternal} in order to delete references to COM
* objects, DOM nodes, and other disposable objects. Reentrant.
*/
dispose ( ) : void ;
/**
* Deletes or nulls out any references to COM objects, DOM nodes, or other
* disposable objects. Classes that extend {@code goog.Disposable} should
* override this method.
* Not reentrant. To avoid calling it twice, it must only be called from the
* subclass' {@code disposeInternal} method. Everywhere else the public
* {@code dispose} method must be used.
* For example:
* <pre>
* mypackage.MyClass = function() {
* mypackage.MyClass.base(this, 'constructor');
* // Constructor logic specific to MyClass.
* ...
* };
* goog.inherits(mypackage.MyClass, goog.Disposable);
*
* mypackage.MyClass.prototype.disposeInternal = function() {
* // Dispose logic specific to MyClass.
* ...
* // Call superclass's disposeInternal at the end of the subclass's, like
* // in C++, to avoid hard-to-catch issues.
* mypackage.MyClass.base(this, 'disposeInternal');
* };
* </pre>
*/
disposeInternal ( ) : void ;
getDisposed ( ) : boolean ;
isDisposed ( ) : boolean ;
/**
* Associates a disposable object with this object so that they will be disposed
* together.
* @param disposable that will be disposed when this object is disposed.
*/
registerDisposable (disposable : ಠ_ಠ.clutz.goog.disposable.IDisposable | null ) : void ;
}
}
declare namespace ಠ_ಠ.clutz.goog.Disposable {
enum MonitoringMode {
INTERACTIVE ,
OFF ,
PERMANENT ,
}
}
declare module 'goog:goog.Disposable' {
import alias = ಠ_ಠ.clutz.goog.Disposable;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog {
/**
* NOTE: This class was created in anticipation of the built-in Promise type
* being standardized and implemented across browsers. Now that Promise is
* available in modern browsers, and is automatically polyfilled by the Closure
* Compiler, by default, most new code should use native {@code Promise}
* instead of {@code goog.Promise}. However, {@code goog.Promise} has the
* concept of cancellation which native Promises do not yet have. So code
* needing cancellation may still want to use {@code goog.Promise}.
*
* Promises provide a result that may be resolved asynchronously. A Promise may
* be resolved by being fulfilled with a fulfillment value, rejected with a
* rejection reason, or blocked by another Promise. A Promise is said to be
* settled if it is either fulfilled or rejected. Once settled, the Promise
* result is immutable.
*
* Promises may represent results of any type, including undefined. Rejection
* reasons are typically Errors, but may also be of any type. Closure Promises
* allow for optional type annotations that enforce that fulfillment values are
* of the appropriate types at compile time.
*
* The result of a Promise is accessible by calling {@code then} and registering
* {@code onFulfilled} and {@code onRejected} callbacks. Once the Promise
* is settled, the relevant callbacks are invoked with the fulfillment value or
* rejection reason as argument. Callbacks are always invoked in the order they
* were registered, even when additional {@code then} calls are made from inside
* another callback. A callback is always run asynchronously sometime after the
* scope containing the registering {@code then} invocation has returned.
*
* If a Promise is resolved with another Promise, the first Promise will block
* until the second is settled, and then assumes the same result as the second
* Promise. This allows Promises to depend on the results of other Promises,
* linking together multiple asynchronous operations.
*
* This implementation is compatible with the Promises/A+ specification and
* passes that specification's conformance test suite. A Closure Promise may be
* resolved with a Promise instance (or sufficiently compatible Promise-like
* object) created by other Promise implementations. From the specification,
* Promise-like objects are known as "Thenables".
*/
class Promise < TYPE , RESOLVER_CONTEXT > extends Promise_Instance < TYPE , RESOLVER_CONTEXT > {
static DEFAULT_MAX_UNUSED : number ;
static LONG_STACK_TRACES : boolean ;
static UNHANDLED_REJECTION_DELAY : number ;
static all < TYPE > (promises : ಠ_ಠ.clutz.goog.uri.utils.QueryArray ) : ಠ_ಠ.clutz.goog.Promise < TYPE [] , any > ;
static allSettled < TYPE > (promises : ಠ_ಠ.clutz.goog.uri.utils.QueryArray ) : ಠ_ಠ.clutz.goog.Promise < { fulfilled : boolean , reason ? : any , value ? : TYPE } [] , any > ;
static firstFulfilled < TYPE > (promises : ಠ_ಠ.clutz.goog.uri.utils.QueryArray ) : ಠ_ಠ.clutz.goog.Promise < TYPE , any > ;
static race < TYPE > (promises : ಠ_ಠ.clutz.goog.uri.utils.QueryArray ) : ಠ_ಠ.clutz.goog.Promise < TYPE , any > ;
static reject (opt_reason ? : any ) : ಠ_ಠ.clutz.goog.Promise < any , any > ;
static resolve < T >(value: Promise < T > | T): Promise < T >;
/**
* Sets a handler that will be called with reasons from unhandled rejected
* Promises. If the rejected Promise (or one of its descendants) has an
* {@code onRejected} callback registered, the rejection will be considered
* handled, and the rejection handler will not be called.
*
* By default, unhandled rejections are rethrown so that the error may be
* captured by the developer console or a {@code window.onerror} handler.
* @param handler A function that will be called with reasons from rejected Promises. Defaults to {@code goog.async.throwException}.
*/
static setUnhandledRejectionHandler (handler : (a : any ) => any ) : void ;
static withResolver < TYPE > ( ) : ಠ_ಠ.clutz.goog.promise.Resolver < TYPE > ;
}
class Promise_Instance < TYPE , RESOLVER_CONTEXT > implements ಠ_ಠ.clutz.goog.Thenable < TYPE > {
private noStructuralTyping_: any;
/**
* NOTE: This class was created in anticipation of the built-in Promise type
* being standardized and implemented across browsers. Now that Promise is
* available in modern browsers, and is automatically polyfilled by the Closure
* Compiler, by default, most new code should use native {@code Promise}
* instead of {@code goog.Promise}. However, {@code goog.Promise} has the
* concept of cancellation which native Promises do not yet have. So code
* needing cancellation may still want to use {@code goog.Promise}.
*
* Promises provide a result that may be resolved asynchronously. A Promise may
* be resolved by being fulfilled with a fulfillment value, rejected with a
* rejection reason, or blocked by another Promise. A Promise is said to be
* settled if it is either fulfilled or rejected. Once settled, the Promise
* result is immutable.
*
* Promises may represent results of any type, including undefined. Rejection
* reasons are typically Errors, but may also be of any type. Closure Promises
* allow for optional type annotations that enforce that fulfillment values are
* of the appropriate types at compile time.
*
* The result of a Promise is accessible by calling {@code then} and registering
* {@code onFulfilled} and {@code onRejected} callbacks. Once the Promise
* is settled, the relevant callbacks are invoked with the fulfillment value or
* rejection reason as argument. Callbacks are always invoked in the order they
* were registered, even when additional {@code then} calls are made from inside
* another callback. A callback is always run asynchronously sometime after the
* scope containing the registering {@code then} invocation has returned.
*
* If a Promise is resolved with another Promise, the first Promise will block
* until the second is settled, and then assumes the same result as the second
* Promise. This allows Promises to depend on the results of other Promises,
* linking together multiple asynchronous operations.
*
* This implementation is compatible with the Promises/A+ specification and
* passes that specification's conformance test suite. A Closure Promise may be
* resolved with a Promise instance (or sufficiently compatible Promise-like
* object) created by other Promise implementations. From the specification,
* Promise-like objects are known as "Thenables".
* @param resolver Initialization function that is invoked immediately with {@code resolve} and {@code reject} functions as arguments. The Promise is resolved or rejected with the first argument passed to either function.
* @param opt_context An optional context for executing the resolver function. If unspecified, the resolver function will be executed in the default scope.
*/
constructor (resolver : (a : (a ? : TYPE | PromiseLike < TYPE > | null | { then : any } ) => any , b : (a ? : any ) => any ) => void , opt_context ? : RESOLVER_CONTEXT ) ;
/**
* Cancels the Promise if it is still pending by rejecting it with a cancel
* Error. No action is performed if the Promise is already resolved.
*
* All child Promises of the canceled Promise will be rejected with the same
* cancel error, as with normal Promise rejection. If the Promise to be canceled
* is the only child of a pending Promise, the parent Promise will also be
* canceled. Cancellation may propagate upward through multiple generations.
* @param opt_message An optional debugging message for describing the cancellation reason.
*/
cancel (opt_message ? : string ) : void ;
/**
* Adds callbacks that will operate on the result of the Promise, returning a
* new child Promise.
*
* If the Promise is fulfilled, the {@code onFulfilled} callback will be invoked
* with the fulfillment value as argument, and the child Promise will be
* fulfilled with the return value of the callback. If the callback throws an
* exception, the child Promise will be rejected with the thrown value instead.
*
* If the Promise is rejected, the {@code onRejected} callback will be invoked
* with the rejection reason as argument, and the child Promise will be resolved
* with the return value or rejected with the thrown value of the callback.
*/
then < RESULT > (opt_onFulfilled ? : ( (a : RESOLVER_CONTEXT ) => Promise < RESULT > | RESULT ) | null , opt_onRejected ? : ( (a : any ) => any ) | null) : Promise < RESULT > ;
/**
* Adds a callback that will be invoked when the Promise is settled (fulfilled
* or rejected). The callback receives no argument, and no new child Promise is
* created. This is useful for ensuring that cleanup takes place after certain
* asynchronous operations. Callbacks added with {@code thenAlways} will be
* executed in the same order with other calls to {@code then},
* {@code thenAlways}, or {@code thenCatch}.
*
* Since it does not produce a new child Promise, cancellation propagation is
* not prevented by adding callbacks with {@code thenAlways}. A Promise that has
* a cleanup handler added with {@code thenAlways} will be canceled if all of
* its children created by {@code then} (or {@code thenCatch}) are canceled.
* Additionally, since any rejections are not passed to the callback, it does
* not stop the unhandled rejection handler from running.
* @param onSettled A function that will be invoked when the Promise is settled (fulfilled or rejected).
* @param opt_context An optional context object that will be the execution context for the callbacks. By default, functions are executed in the global scope.
*/
thenAlways < THIS > (onSettled : ( ) => void , opt_context ? : THIS ) : ಠ_ಠ.clutz.goog.Promise < TYPE , any > ;
/**
* Adds a callback that will be invoked only if the Promise is rejected. This
* is equivalent to {@code then(null, onRejected)}.
* @param onRejected A function that will be invoked with the rejection reason if the Promise is rejected.
* @param opt_context An optional context object that will be the execution context for the callbacks. By default, functions are executed in the global scope.
*/
thenCatch < THIS > (onRejected : (a : any ) => any , opt_context ? : THIS ) : ಠ_ಠ.clutz.goog.Promise < any , any > ;
/**
* Adds callbacks that will operate on the result of the Promise without
* returning a child Promise (unlike "then").
*
* If the Promise is fulfilled, the {@code onFulfilled} callback will be invoked
* with the fulfillment value as argument.
*
* If the Promise is rejected, the {@code onRejected} callback will be invoked
* with the rejection reason as argument.
* @param opt_onFulfilled A function that will be invoked with the fulfillment value if the Promise is fulfilled.
* @param opt_onRejected A function that will be invoked with the rejection reason if the Promise is rejected.
* @param opt_context An optional context object that will be the execution context for the callbacks. By default, functions are executed with the default this.
*/
thenVoid < THIS > (opt_onFulfilled ? : ( (a : TYPE ) => any ) | null , opt_onRejected ? : ( (a : any ) => any ) | null , opt_context ? : THIS ) : void ;
}
}
declare namespace ಠ_ಠ.clutz.goog.Promise {
class CallbackEntry_ extends CallbackEntry__Instance {
}
class CallbackEntry__Instance {
private noStructuralTyping_: any;
/**
* A boolean value to indicate this is a "thenAlways" callback entry.
* Unlike a normal "then/thenVoid" a "thenAlways doesn't participate
* in "cancel" considerations but is simply an observer and requires
* special handling.
*/
always : boolean ;
child : ಠ_ಠ.clutz.goog.Promise < any , any > | null ;
context : any ;
next : ಠ_ಠ.clutz.goog.Promise.CallbackEntry_ | null ;
onFulfilled : Function | null ;
onRejected : Function | null ;
/**
* clear the object prior to reuse
*/
reset ( ) : void ;
}
class CancellationError extends CancellationError_Instance {
}
class CancellationError_Instance extends ಠ_ಠ.clutz.goog.debug.Error_Instance {
/**
* Error used as a rejection reason for canceled Promises.
*/
constructor (opt_message ? : string ) ;
}
class Resolver_ < TYPE > extends Resolver__Instance < TYPE > {
}
class Resolver__Instance < TYPE > implements ಠ_ಠ.clutz.goog.promise.Resolver < TYPE > {
private noStructuralTyping_: any;
promise : ಠ_ಠ.clutz.goog.Promise < TYPE , any > ;
reject (a ? : any ) : void ;
resolve (a ? : TYPE | ಠ_ಠ.clutz.goog.Promise < TYPE , any > | null | { then : any } ) : any ;
}
}
declare module 'goog:goog.Promise' {
import alias = ಠ_ಠ.clutz.goog.Promise;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog {
/**
* Provides a more strict interface for Thenables in terms of
* http://promisesaplus.com for interop with {@see goog.Promise}.
*/
interface Thenable < TYPE > extends PromiseLike < TYPE > {
/**
* Adds callbacks that will operate on the result of the Thenable, returning a
* new child Promise.
*
* If the Thenable is fulfilled, the {@code onFulfilled} callback will be
* invoked with the fulfillment value as argument, and the child Promise will
* be fulfilled with the return value of the callback. If the callback throws
* an exception, the child Promise will be rejected with the thrown value
* instead.
*
* If the Thenable is rejected, the {@code onRejected} callback will be invoked
* with the rejection reason as argument, and the child Promise will be rejected
* with the return value of the callback or thrown value.
* @param opt_onFulfilled A function that will be invoked with the fulfillment value if the Promise is fulfilled.
* @param opt_onRejected A function that will be invoked with the rejection reason if the Promise is rejected.
* @param opt_context An optional context object that will be the execution context for the callbacks. By default, functions are executed with the default this.
*/
then < RESULT > (opt_onFulfilled ? : ( (a : TYPE ) => Thenable < RESULT > | RESULT ) | null , opt_onRejected ? : ( (a : any ) => any ) | null) : Thenable < RESULT > ;
}
}
declare namespace ಠ_ಠ.clutz.goog.Thenable {
var IMPLEMENTED_BY_PROP : string ;
function addImplementation (ctor : { new ( ...a : any [] ) : ಠ_ಠ.clutz.goog.Thenable < any > } ) : void ;
function isImplementedBy (object : any ) : boolean ;
}
declare module 'goog:goog.Thenable' {
import alias = ಠ_ಠ.clutz.goog.Thenable;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog {
/**
* Class for handling timing events.
*/
class Timer extends Timer_Instance {
/**
* Constant for the timer's event type.
*/
static TICK : string ;
/**
* Calls the given function once, after the optional pause.
* <p>
* The function is always called asynchronously, even if the delay is 0. This
* is a common trick to schedule a function to run after a batch of browser
* event processing.
* @param listener Function or object that has a handleEvent method.
* @param opt_delay Milliseconds to wait; default is 0.
* @param opt_handler Object in whose scope to call the listener.
*/
static callOnce < SCOPE > (listener : ( ( ) => any ) | { handleEvent : ( ) => any } | null , opt_delay ? : number , opt_handler ? : SCOPE ) : number ;
/**
* Clears a timeout initiated by {@link #callOnce}.
* @param timerId A timer ID.
*/
static clear (timerId : number | null ) : void ;
/**
* An object that implements {@code setTimeout}, {@code setInterval},
* {@code clearTimeout} and {@code clearInterval}. We default to the global
* object. Changing {@code goog.Timer.defaultTimerObject} changes the object for
* all timer instances which can be useful if your environment has some other
* implementation of timers you'd like to use.
*/
static defaultTimerObject : { clearTimeout : any , setTimeout : any } ;
/**
* Variable that controls the timer error correction. If the timer is called
* before the requested interval times {@code intervalScale}, which often
* happens on Mozilla, the timer is rescheduled.
*/
static intervalScale : number ;
static promise < RESULT > (delay : number , opt_result ? : RESULT | ಠ_ಠ.clutz.goog.Thenable < RESULT > | null | { then : any } ) : ಠ_ಠ.clutz.goog.Promise < RESULT , any > ;
}
class Timer_Instance extends ಠ_ಠ.clutz.goog.events.EventTarget_Instance {
/**
* Class for handling timing events.
* @param opt_interval Number of ms between ticks (default: 1ms).
* @param opt_timerObject An object that has {@code setTimeout}, {@code setInterval}, {@code clearTimeout} and {@code clearInterval} (e.g., {@code window}).
*/
constructor (opt_interval ? : number , opt_timerObject ? : GlobalObject | null ) ;
/**
* Dispatches the TICK event. This is its own method so subclasses can override.
*/
dispatchTick ( ) : void ;
disposeInternal ( ) : void ;
/**
* Whether this timer is enabled
*/
enabled : boolean ;
/**
* Gets the interval of the timer.
*/
getInterval ( ) : number ;
/**
* Sets the interval of the timer.
* @param interval Number of ms between ticks.
*/
setInterval (interval : number ) : void ;
/**
* Starts the timer.
*/
start ( ) : void ;
/**
* Stops the timer.
*/
stop ( ) : void ;
}
}
declare module 'goog:goog.Timer' {
import alias = ಠ_ಠ.clutz.goog.Timer;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.array {
var ASSUME_NATIVE_FUNCTIONS : boolean ;
/**
* Inserts a value into a sorted array. The array is not modified if the
* value is already present.
* @param array The array to modify.
* @param value The object to insert.
* @param opt_compareFn Optional comparison function by which the array is ordered. Should take 2 arguments to compare, and return a negative number, zero, or a positive number depending on whether the first argument is less than, equal to, or greater than the second.
*/
function binaryInsert < VALUE > (array : ArrayLike < VALUE > | null , value : VALUE , opt_compareFn ? : (a : VALUE , b : VALUE ) => number ) : boolean ;
/**
* Removes a value from a sorted array.
* @param array The array to modify.
* @param value The object to remove.
* @param opt_compareFn Optional comparison function by which the array is ordered. Should take 2 arguments to compare, and return a negative number, zero, or a positive number depending on whether the first argument is less than, equal to, or greater than the second.
*/
function binaryRemove < VALUE > (array : ArrayLike < VALUE > , value : VALUE , opt_compareFn ? : (a : VALUE , b : VALUE ) => number ) : boolean ;
/**
* Searches the specified array for the specified target using the binary
* search algorithm. If no opt_compareFn is specified, elements are compared
* using <code>goog.array.defaultCompare</code>, which compares the elements
* using the built in < and > operators. This will produce the expected
* behavior for homogeneous arrays of String(s) and Number(s). The array
* specified <b>must</b> be sorted in ascending order (as defined by the
* comparison function). If the array is not sorted, results are undefined.
* If the array contains multiple instances of the specified target value, any
* of these instances may be found.
*
* Runtime: O(log n)
* @param arr The array to be searched.
* @param target The sought value.
* @param opt_compareFn Optional comparison function by which the array is ordered. Should take 2 arguments to compare, and return a negative number, zero, or a positive number depending on whether the first argument is less than, equal to, or greater than the second.
*/
function binarySearch < TARGET , VALUE > (arr : ArrayLike < VALUE > | null , target : TARGET , opt_compareFn ? : (a : TARGET , b : VALUE ) => number ) : number ;
/**
* Selects an index in the specified array using the binary search algorithm.
* The evaluator receives an element and determines whether the desired index
* is before, at, or after it. The evaluator must be consistent (formally,
* goog.array.map(goog.array.map(arr, evaluator, opt_obj), goog.math.sign)
* must be monotonically non-increasing).
*
* Runtime: O(log n)
* @param arr The array to be searched.
* @param evaluator Evaluator function that receives 3 arguments (the element, the index and the array). Should return a negative number, zero, or a positive number depending on whether the desired index is before, at, or after the element passed to it.
* @param opt_obj The object to be used as the value of 'this' within evaluator.
*/
function binarySelect < THIS , VALUE > (arr : ArrayLike < VALUE > | null , evaluator : (a : VALUE , b : number , c : any ) => number , opt_obj ? : THIS ) : number ;
/**
* Splits an array into disjoint buckets according to a splitting function.
* @param array The array.
* @param sorter Function to call for every element. This takes 3 arguments (the element, the index and the array) and must return a valid object key (a string, number, etc), or undefined, if that object should not be placed in a bucket.
* @param opt_obj The object to be used as the value of 'this' within sorter.
*/
function bucket < T , S > (array : T [] | null , sorter : (a : T , b : number , c : T [] ) => any , opt_obj ? : S ) : { [ /* warning: coerced from ? */ key: string ]: T [] } ;
/**
* Clears the array.
* @param arr Array or array like object to clear.
*/
function clear (arr : ArrayLike < any > | null ) : void ;
/**
* Does a shallow copy of an array.
* @param arr Array or array-like object to clone.
*/
function clone < T > (a : ArrayLike < T > | null | string ) : T [] ;
/**
* 3-way array compare function.
* @param arr1 The first array to compare.
* @param arr2 The second array to compare.
* @param opt_compareFn Optional comparison function by which the array is to be ordered. Should take 2 arguments to compare, and return a negative number, zero, or a positive number depending on whether the first argument is less than, equal to, or greater than the second.
*/
function compare3 < VALUE > (arr1 : ArrayLike < VALUE > , arr2 : ArrayLike < VALUE > , opt_compareFn ? : (a : VALUE , b : VALUE ) => number ) : number ;
/**
* Returns a new array that is the result of joining the arguments. If arrays
* are passed then their items are added, however, if non-arrays are passed they
* will be added to the return array as is.
*
* Note that ArrayLike objects will be added as is, rather than having their
* items added.
*
* goog.array.concat([1, 2], [3, 4]) -> [1, 2, 3, 4]
* goog.array.concat(0, [1, 2]) -> [0, 1, 2]
* goog.array.concat([1, 2], null) -> [1, 2, null]
*
* There is bug in all current versions of IE (6, 7 and 8) where arrays created
* in an iframe become corrupted soon (not immediately) after the iframe is
* destroyed. This is common if loading data via goog.net.IframeIo, for example.
* This corruption only affects the concat method which will start throwing
* Catastrophic Errors (#-2147418113).
*
* See http://endoflow.com/scratch/corrupted-arrays.html for a test case.
*
* Internally goog.array should use this, so that all methods will continue to
* work on these broken array objects.
* @param var_args Items to concatenate. Arrays will have each item added, while primitives and objects will be added as is.
*/
function concat ( ...var_args : any [] ) : any [] ;
/**
* Maps each element of the input array into zero or more elements of the output
* array.
* @param arr Array or array like object over which to iterate.
* @param f The function to call for every element. This function takes 3 arguments (the element, the index and the array) and should return an array. The result will be used to extend a new array.
* @param opt_obj The object to be used as the value of 'this' within f.
*/
function concatMap < THIS , VALUE , RESULT > (arr : ArrayLike < VALUE > | string , f : (a : VALUE , b : number , c : any ) => RESULT [] , opt_obj ? : THIS ) : RESULT [] ;
/**
* Whether the array contains the given object.
* @param arr The array to test for the presence of the element.
* @param obj The object for which to test.
*/
function contains (arr : ArrayLike < any > | null | string , obj : any ) : boolean ;
/**
* Returns a new array of elements from arr, based on the indexes of elements
* provided by index_arr. For example, the result of index copying
* ['a', 'b', 'c'] with index_arr [1,0,0,2] is ['b', 'a', 'a', 'c'].
* @param arr The array to get a indexed copy from.
* @param index_arr An array of indexes to get from arr.
*/
function copyByIndex < T > (arr : T [] , index_arr : number [] ) : T [] ;
/**
* Counts the array elements that fulfill the predicate, i.e. for which the
* callback function returns true. Skips holes in the array.
* @param arr Array or array like object over which to iterate.
* @param f The function to call for every element. Takes 3 arguments (the element, the index and the array).
* @param opt_obj The object to be used as the value of 'this' within f.
*/
function count < T , S > (arr : ArrayLike < T > | string , f : (a : T , b : number , c : any ) => boolean , opt_obj ? : S ) : number ;
/**
* Compares its two arguments for order, using the built in < and >
* operators.
* @param a The first object to be compared.
* @param b The second object to be compared.
*/
function defaultCompare < VALUE > (a : VALUE , b : VALUE ) : number ;
/**
* Compares its two arguments for equality, using the built in === operator.
* @param a The first object to compare.
* @param b The second object to compare.
*/
function defaultCompareEquality (a : any , b : any ) : boolean ;
/**
* Compares two arrays for equality. Two arrays are considered equal if they
* have the same length and their corresponding elements are equal according to
* the comparison function.
* @param arr1 The first array to compare.
* @param arr2 The second array to compare.
* @param opt_equalsFn Optional comparison function. Should take 2 arguments to compare, and return true if the arguments are equal. Defaults to {@link goog.array.defaultCompareEquality} which compares the elements using the built-in '===' operator.
*/
function equals (arr1 : ArrayLike < any > | null , arr2 : ArrayLike < any > | null , opt_equalsFn ? : Function | null ) : boolean ;
/**
* Call f for each element of an array. If all calls return true, every()
* returns true. If any call returns false, every() returns false and
* does not continue to check the remaining elements.
*
* See {@link http://tinyurl.com/developer-mozilla-org-array-every}
* @param arr Array or array like object over which to iterate.
* @param f The function to call for for every element. This function takes 3 arguments (the element, the index and the array) and should return a boolean.
* @param opt_obj The object to be used as the value of 'this' within f.
*/
function every < T , S > (a : ArrayLike < T > | null | string , b : ( (a : T , b : number , c : any ) => boolean ) | null , c ? : S ) : boolean ;
/**
* Extends an array with another array, element, or "array like" object.
* This function operates 'in-place', it does not create a new Array.
*
* Example:
* var a = [];
* goog.array.extend(a, [0, 1]);
* a; // [0, 1]
* goog.array.extend(a, 2);
* a; // [0, 1, 2]
* @param arr1 The array to modify.
* @param var_args The elements or arrays of elements to add to arr1.
*/
function extend < VALUE > (arr1 : VALUE [] | null , ...var_args : ( VALUE [] | null | VALUE | undefined ) [] ) : void ;
/**
* Calls a function for each element in an array, and if the function returns
* true adds the element to a new array.
*
* See {@link http://tinyurl.com/developer-mozilla-org-array-filter}
* @param arr Array or array like object over which to iterate.
* @param f The function to call for every element. This function takes 3 arguments (the element, the index and the array) and must return a Boolean. If the return value is true the element is added to the result array. If it is false the element is not included.
* @param opt_obj The object to be used as the value of 'this' within f.
*/
function filter < T , S > (a : ArrayLike < T > | null | string , b : ( (a : T , b : number , c : any ) => boolean ) | null , c ? : S ) : T [] ;
/**
* Search an array for the first element that satisfies a given condition and
* return that element.
* @param arr Array or array like object over which to iterate.
* @param f The function to call for every element. This function takes 3 arguments (the element, the index and the array) and should return a boolean.
* @param opt_obj An optional "this" context for the function.
*/
function find < T , S > (arr : ArrayLike < T > | null | string , f : ( (a : T , b : number , c : any ) => boolean ) | null , opt_obj ? : S ) : T | null ;
/**
* Search an array for the first element that satisfies a given condition and
* return its index.
* @param arr Array or array like object over which to iterate.
* @param f The function to call for every element. This function takes 3 arguments (the element, the index and the array) and should return a boolean.
* @param opt_obj An optional "this" context for the function.
*/
function findIndex < T , S > (arr : ArrayLike < T > | null | string , f : ( (a : T , b : number , c : any ) => boolean ) | null , opt_obj ? : S ) : number ;
/**
* Search an array (in reverse order) for the last element that satisfies a
* given condition and return its index.
* @param arr Array or array like object over which to iterate.
* @param f The function to call for every element. This function takes 3 arguments (the element, the index and the array) and should return a boolean.
* @param opt_obj An optional "this" context for the function.
*/
function findIndexRight < T , S > (arr : ArrayLike < T > | null | string , f : ( (a : T , b : number , c : any ) => boolean ) | null , opt_obj ? : S ) : number ;
/**
* Search an array (in reverse order) for the last element that satisfies a
* given condition and return that element.
* @param arr Array or array like object over which to iterate.
* @param f The function to call for every element. This function takes 3 arguments (the element, the index and the array) and should return a boolean.
* @param opt_obj An optional "this" context for the function.
*/
function findRight < T , S > (arr : ArrayLike < T > | null | string , f : ( (a : T , b : number , c : any ) => boolean ) | null , opt_obj ? : S ) : T | null ;
/**
* Returns an array consisting of every argument with all arrays
* expanded in-place recursively.
* @param var_args The values to flatten.
*/
function flatten ( ...var_args : any [] ) : any [] ;
/**
* Calls a function for each element in an array. Skips holes in the array.
* See {@link http://tinyurl.com/developer-mozilla-org-array-foreach}
* @param arr Array or array like object over which to iterate.
* @param f The function to call for every element. This function takes 3 arguments (the element, the index and the array). The return value is ignored.
* @param opt_obj The object to be used as the value of 'this' within f.
*/
function forEach < T , S > (a : ArrayLike < T > | null | string , b : ( (a : T , b : number , c : any ) => any ) | null , c ? : S ) : any ;
/**
* Calls a function for each element in an array, starting from the last
* element rather than the first.
* @param arr Array or array like object over which to iterate.
* @param f The function to call for every element. This function takes 3 arguments (the element, the index and the array). The return value is ignored.
* @param opt_obj The object to be used as the value of 'this' within f.
*/
function forEachRight < T , S > (arr : ArrayLike < T > | null | string , f : ( (a : T , b : number , c : any ) => any ) | null , opt_obj ? : S ) : void ;
/**
* Returns the index of the first element of an array with a specified value, or
* -1 if the element is not present in the array.
*
* See {@link http://tinyurl.com/developer-mozilla-org-array-indexof}
* @param arr The array to be searched.
* @param obj The object for which we are searching.
* @param opt_fromIndex The index at which to start the search. If omitted the search starts at index 0.
*/
function indexOf < T > (a : ArrayLike < T > | null | string , b : T , c ? : number ) : number ;
/**
* Pushes an item into an array, if it's not already in the array.
* @param arr Array into which to insert the item.
* @param obj Value to add.
*/
function insert < T > (arr : T [] | null , obj : T ) : void ;
/**
* Inserts at the given index of the array, all elements of another array.
* @param arr The array to modify.
* @param elementsToAdd The array of elements to add.
* @param opt_i The index at which to insert the object. If omitted, treated as 0. A negative index is counted from the end of the array.
*/
function insertArrayAt (arr : ArrayLike < any > | null , elementsToAdd : ArrayLike < any > | null , opt_i ? : number ) : void ;
/**
* Inserts an object at the given index of the array.
* @param arr The array to modify.
* @param obj The object to insert.
* @param opt_i The index at which to insert the object. If omitted, treated as 0. A negative index is counted from the end of the array.
*/
function insertAt (arr : ArrayLike < any > | null , obj : any , opt_i ? : number ) : void ;
/**
* Inserts an object into an array before a specified object.
* @param arr The array to modify.
* @param obj The object to insert.
* @param opt_obj2 The object before which obj should be inserted. If obj2 is omitted or not found, obj is inserted at the end of the array.
*/
function insertBefore < T > (arr : T [] | null , obj : T , opt_obj2 ? : T ) : void ;
/**
* Compares its two arguments for inverse order, using the built in < and >
* operators.
* @param a The first object to be compared.
* @param b The second object to be compared.
*/
function inverseDefaultCompare < VALUE > (a : VALUE , b : VALUE ) : number ;
/**
* Whether the array is empty.
* @param arr The array to test.
*/
function isEmpty (arr : ArrayLike < any > | null | string ) : boolean ;
/**
* Tells if the array is sorted.
* @param arr The array.
* @param opt_compareFn Function to compare the array elements. Should take 2 arguments to compare, and return a negative number, zero, or a positive number depending on whether the first argument is less than, equal to, or greater than the second.
* @param opt_strict If true no equal elements are allowed.
*/
function isSorted < T > (arr : T [] , opt_compareFn ? : ( (a : T , b : T ) => number ) | null , opt_strict ? : boolean ) : boolean ;
/**
* Returns a new array that contains the contents of all the arrays passed.
*/
function join < T > ( ...var_args : ( T [] | undefined ) [] ) : T [] ;
/**
* Returns the last element in an array without removing it.
* Same as goog.array.peek.
* @param array The array.
*/
function last < T > (a : ArrayLike < T > | null | string ) : T ;
/**
* Returns the index of the last element of an array with a specified value, or
* -1 if the element is not present in the array.
*
* See {@link http://tinyurl.com/developer-mozilla-org-array-lastindexof}
* @param arr The array to be searched.
* @param obj The object for which we are searching.
* @param opt_fromIndex The index at which to start the search. If omitted the search starts at the end of the array.
*/
function lastIndexOf < T > (a : ArrayLike < T > | string , b : T , c ? : number | null ) : number ;
/**
* Calls a function for each element in an array and inserts the result into a
* new array.
*
* See {@link http://tinyurl.com/developer-mozilla-org-array-map}
* @param arr Array or array like object over which to iterate.
* @param f The function to call for every element. This function takes 3 arguments (the element, the index and the array) and should return something. The result will be inserted into a new array.
* @param opt_obj The object to be used as the value of 'this' within f.
*/
function map < THIS , VALUE , RESULT > (a : ArrayLike < VALUE > | null | string , b : (a : VALUE , b : number , c : any ) => RESULT , c ? : THIS ) : RESULT [] ;
/**
* Moves one item of an array to a new position keeping the order of the rest
* of the items. Example use case: keeping a list of JavaScript objects
* synchronized with the corresponding list of DOM elements after one of the
* elements has been dragged to a new position.
* @param arr The array to modify.
* @param fromIndex Index of the item to move between 0 and {@code arr.length - 1}.
* @param toIndex Target index between 0 and {@code arr.length - 1}.
*/
function moveItem (arr : ArrayLike < any > , fromIndex : number , toIndex : number ) : void ;
/**
* Returns the last element in an array without removing it.
* Same as goog.array.last.
* @param array The array.
*/
function peek < T > (array : ArrayLike < T > | null | string ) : T ;
/**
* Creates a range of numbers in an arithmetic progression.
*
* Range takes 1, 2, or 3 arguments:
* <pre>
* range(5) is the same as range(0, 5, 1) and produces [0, 1, 2, 3, 4]
* range(2, 5) is the same as range(2, 5, 1) and produces [2, 3, 4]
* range(-2, -5, -1) produces [-2, -3, -4]
* range(-2, -5, 1) produces [], since stepping by 1 wouldn't ever reach -5.
* </pre>
* @param startOrEnd The starting value of the range if an end argument is provided. Otherwise, the start value is 0, and this is the end value.
* @param opt_end The optional end value of the range.
* @param opt_step The step size between range values. Defaults to 1 if opt_step is undefined or 0.
*/
function range (startOrEnd : number , opt_end ? : number , opt_step ? : number ) : number [] ;
/**
* Passes every element of an array into a function and accumulates the result.
*
* See {@link http://tinyurl.com/developer-mozilla-org-array-reduce}
*
* For example:
* var a = [1, 2, 3, 4];
* goog.array.reduce(a, function(r, v, i, arr) {return r + v;}, 0);
* returns 10
* @param arr Array or array like object over which to iterate.
* @param f The function to call for every element. This function takes 4 arguments (the function's previous result or the initial value, the value of the current array element, the current array index, and the array itself) function(previousValue, currentValue, index, array).
* @param val The initial value to pass into the function on the first call.
* @param opt_obj The object to be used as the value of 'this' within f.
*/
function reduce < T , S , R > (a : ArrayLike < T > | null | string , b : (a : R , b : T , c : number , d : any ) => R , c : any , d ? : S ) : R ;
/**
* Passes every element of an array into a function and accumulates the result,
* starting from the last element and working towards the first.
*
* See {@link http://tinyurl.com/developer-mozilla-org-array-reduceright}
*
* For example:
* var a = ['a', 'b', 'c'];
* goog.array.reduceRight(a, function(r, v, i, arr) {return r + v;}, '');
* returns 'cba'
* @param arr Array or array like object over which to iterate.
* @param f The function to call for every element. This function takes 4 arguments (the function's previous result or the initial value, the value of the current array element, the current array index, and the array itself) function(previousValue, currentValue, index, array).
* @param val The initial value to pass into the function on the first call.
* @param opt_obj The object to be used as the value of 'this' within f.
*/
function reduceRight < T , S , R > (a : ArrayLike < T > | null | string , b : ( (a : R , b : T , c : number , d : any ) => R ) | null , c : any , d ? : S ) : R ;
/**
* Removes the first occurrence of a particular value from an array.
* @param arr Array from which to remove value.
* @param obj Object to remove.
*/
function remove < T > (arr : ArrayLike < T > | null , obj : T ) : boolean ;
/**
* Removes all values that satisfy the given condition.
* @param arr Array or array like object over which to iterate.
* @param f The function to call for every element. This function takes 3 arguments (the element, the index and the array) and should return a boolean.
* @param opt_obj An optional "this" context for the function.
*/
function removeAllIf < T , S > (arr : ArrayLike < T > | null , f : ( (a : T , b : number , c : any ) => boolean ) | null , opt_obj ? : S ) : number ;
/**
* Removes from an array the element at index i
* @param arr Array or array like object from which to remove value.
* @param i The index to remove.
*/
function removeAt (arr : ArrayLike < any > | null , i : number ) : boolean ;
/**
* Removes all duplicates from an array (retaining only the first
* occurrence of each array element). This function modifies the
* array in place and doesn't change the order of the non-duplicate items.
*
* For objects, duplicates are identified as having the same unique ID as
* defined by {@link goog.getUid}.
*
* Alternatively you can specify a custom hash function that returns a unique
* value for each item in the array it should consider unique.
*
* Runtime: N,
* Worstcase space: 2N (no dupes)
* @param arr The array from which to remove duplicates.
* @param opt_rv An optional array in which to return the results, instead of performing the removal inplace. If specified, the original array will remain unchanged.
* @param opt_hashFn An optional function to use to apply to every item in the array. This function should return a unique value for each item in the array it should consider unique.
*/
function removeDuplicates < T > (arr : ArrayLike < T > | null , opt_rv ? : any [] | null , opt_hashFn ? : (a : T ) => string ) : void ;
/**
* Removes the first value that satisfies the given condition.
* @param arr Array or array like object over which to iterate.
* @param f The function to call for every element. This function takes 3 arguments (the element, the index and the array) and should return a boolean.
* @param opt_obj An optional "this" context for the function.
*/
function removeIf < T , S > (arr : ArrayLike < T > | null , f : ( (a : T , b : number , c : any ) => boolean ) | null , opt_obj ? : S ) : boolean ;
/**
* Removes the last occurrence of a particular value from an array.
* @param arr Array from which to remove value.
* @param obj Object to remove.
*/
function removeLast < T > (arr : ArrayLike < T > , obj : T ) : boolean ;
/**
* Returns an array consisting of the given value repeated N times.
* @param value The value to repeat.
* @param n The repeat count.
*/
function repeat < VALUE > (value : VALUE , n : number ) : VALUE [] ;
/**
* Rotates an array in-place. After calling this method, the element at
* index i will be the element previously at index (i - n) %
* array.length, for all values of i between 0 and array.length - 1,
* inclusive.
*
* For example, suppose list comprises [t, a, n, k, s]. After invoking
* rotate(array, 1) (or rotate(array, -4)), array will comprise [s, t, a, n, k].
* @param array The array to rotate.
* @param n The amount to rotate.
*/
function rotate < T > (array : T [] , n : number ) : T [] ;
/**
* Shuffles the values in the specified array using the Fisher-Yates in-place
* shuffle (also known as the Knuth Shuffle). By default, calls Math.random()
* and so resets the state of that random number generator. Similarly, may reset
* the state of the any other specified random number generator.
*
* Runtime: O(n)
* @param arr The array to be shuffled.
* @param opt_randFn Optional random function to use for shuffling. Takes no arguments, and returns a random number on the interval [0, 1). Defaults to Math.random() using JavaScript's built-in Math library.
*/
function shuffle (arr : any [] , opt_randFn ? : ( ) => number ) : void ;
/**
* Returns a new array from a segment of an array. This is a generic version of
* Array slice. This means that it might work on other objects similar to
* arrays, such as the arguments object.
* @param arr The array from which to copy a segment.
* @param start The index of the first element to copy.
* @param opt_end The index after the last element to copy.
*/
function slice < T > (arr : ArrayLike < T > | null | string , start : number , opt_end ? : number ) : T [] ;
/**
* Calls f for each element of an array. If any call returns true, some()
* returns true (without checking the remaining elements). If all calls
* return false, some() returns false.
*
* See {@link http://tinyurl.com/developer-mozilla-org-array-some}
* @param arr Array or array like object over which to iterate.
* @param f The function to call for for every element. This function takes 3 arguments (the element, the index and the array) and should return a boolean.
* @param opt_obj The object to be used as the value of 'this' within f.
*/
function some < T , S > (a : ArrayLike < T > | null | string , b : ( (a : T , b : number , c : any ) => boolean ) | null , c ? : S ) : boolean ;
/**
* Sorts the specified array into ascending order. If no opt_compareFn is
* specified, elements are compared using
* <code>goog.array.defaultCompare</code>, which compares the elements using
* the built in < and > operators. This will produce the expected behavior
* for homogeneous arrays of String(s) and Number(s), unlike the native sort,
* but will give unpredictable results for heterogeneous lists of strings and
* numbers with different numbers of digits.
*
* This sort is not guaranteed to be stable.
*
* Runtime: Same as <code>Array.prototype.sort</code>
* @param arr The array to be sorted.
* @param opt_compareFn Optional comparison function by which the array is to be ordered. Should take 2 arguments to compare, and return a negative number, zero, or a positive number depending on whether the first argument is less than, equal to, or greater than the second.
*/
function sort < T > (arr : T [] | null , opt_compareFn ? : ( (a : T , b : T ) => number ) | null ) : void ;
/**
* Sort the specified array into ascending order based on item keys
* returned by the specified key function.
* If no opt_compareFn is specified, the keys are compared in ascending order
* using <code>goog.array.defaultCompare</code>.
*
* Runtime: O(S(f(n)), where S is runtime of <code>goog.array.sort</code>
* and f(n) is runtime of the key function.
* @param arr The array to be sorted.
* @param keyFn Function taking array element and returning a key used for sorting this element.
* @param opt_compareFn Optional comparison function by which the keys are to be ordered. Should take 2 arguments to compare, and return a negative number, zero, or a positive number depending on whether the first argument is less than, equal to, or greater than the second.
*/
function sortByKey < T , K > (arr : T [] | null , keyFn : (a : T ) => K , opt_compareFn ? : ( (a : K , b : K ) => number ) | null ) : void ;
/**
* Sorts an array of objects by the specified object key and compare
* function. If no compare function is provided, the key values are
* compared in ascending order using <code>goog.array.defaultCompare</code>.
* This won't work for keys that get renamed by the compiler. So use
* {'foo': 1, 'bar': 2} rather than {foo: 1, bar: 2}.
* @param arr An array of objects to sort.
* @param key The object key to sort by.
* @param opt_compareFn The function to use to compare key values.
*/
function sortObjectsByKey (arr : ( GlobalObject | null ) [] | null , key : string , opt_compareFn ? : Function | null ) : void ;
/**
* Adds or removes elements from an array. This is a generic version of Array
* splice. This means that it might work on other objects similar to arrays,
* such as the arguments object.
* @param arr The array to modify.
* @param index The index at which to start changing the array. If not defined, treated as 0.
* @param howMany How many elements to remove (0 means no removal. A value below 0 is treated as zero and so is any other non number. Numbers are floored).
* @param var_args Optional, additional elements to insert into the array.
*/
function splice < T > (arr : ArrayLike < T > | null , index : number | undefined , howMany : number , ...var_args : ( T | undefined ) [] ) : T [] ;
/**
* Sorts the specified array into ascending order in a stable way. If no
* opt_compareFn is specified, elements are compared using
* <code>goog.array.defaultCompare</code>, which compares the elements using
* the built in < and > operators. This will produce the expected behavior
* for homogeneous arrays of String(s) and Number(s).
*
* Runtime: Same as <code>Array.prototype.sort</code>, plus an additional
* O(n) overhead of copying the array twice.
* @param arr The array to be sorted.
* @param opt_compareFn Optional comparison function by which the array is to be ordered. Should take 2 arguments to compare, and return a negative number, zero, or a positive number depending on whether the first argument is less than, equal to, or greater than the second.
*/
function stableSort < T > (arr : T [] | null , opt_compareFn ? : ( (a : T , b : T ) => number ) | null ) : void ;
/**
* Converts an object to an array.
* @param object The object to convert to an array.
*/
function toArray < T > (object : ArrayLike < T > | null | string ) : T [] ;
/**
* Creates a new object built from the provided array and the key-generation
* function.
* @param arr Array or array like object over which to iterate whose elements will be the values in the new object.
* @param keyFunc The function to call for every element. This function takes 3 arguments (the element, the index and the array) and should return a string that will be used as the key for the element in the new object. If the function returns the same key for more than one element, the value for that key is implementation-defined.
* @param opt_obj The object to be used as the value of 'this' within keyFunc.
*/
function toObject < T , S > (arr : ArrayLike < T > | null , keyFunc : ( (a : T , b : number , c : any ) => string ) | null , opt_obj ? : S ) : { [ /* warning: coerced from ? */ key: string ]: T } ;
/**
* Creates a new array for which the element at position i is an array of the
* ith element of the provided arrays. The returned array will only be as long
* as the shortest array provided; additional values are ignored. For example,
* the result of zipping [1, 2] and [3, 4, 5] is [[1,3], [2, 4]].
*
* This is similar to the zip() function in Python. See {@link
* http://docs.python.org/library/functions.html#zip}
* @param var_args Arrays to be combined.
*/
function zip ( ...var_args : ( ArrayLike < any > | undefined ) [] ) : any [] [] ;
}
declare module 'goog:goog.array' {
import alias = ಠ_ಠ.clutz.goog.array;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.asserts {
/**
* The default error handler.
* @param e The exception to be handled.
*/
function DEFAULT_ERROR_HANDLER (e : ಠ_ಠ.clutz.goog.asserts.AssertionError ) : any ;
var ENABLE_ASSERTS : boolean ;
/**
* Checks if the condition evaluates to true if goog.asserts.ENABLE_ASSERTS is
* true.
* @param condition The condition to check.
* @param opt_message Error message in case of failure.
* @param var_args The items to substitute into the failure message.
*/
function assert < T > (condition : T , opt_message ? : string , ...var_args : any [] ) : T ;
/**
* Checks if the value is an Array if goog.asserts.ENABLE_ASSERTS is true.
* @param value The value to check.
* @param opt_message Error message in case of failure.
* @param var_args The items to substitute into the failure message.
*/
function assertArray (value : any , opt_message ? : string , ...var_args : any [] ) : any [] ;
/**
* Checks if the value is a boolean if goog.asserts.ENABLE_ASSERTS is true.
* @param value The value to check.
* @param opt_message Error message in case of failure.
* @param var_args The items to substitute into the failure message.
*/
function assertBoolean (value : any , opt_message ? : string , ...var_args : any [] ) : boolean ;
/**
* Checks if the value is a DOM Element if goog.asserts.ENABLE_ASSERTS is true.
* @param value The value to check.
* @param opt_message Error message in case of failure.
* @param var_args The items to substitute into the failure message.
*/
function assertElement (value : any , opt_message ? : string , ...var_args : any [] ) : Element ;
/**
* Checks whether the value is a finite number, if goog.asserts.ENABLE_ASSERTS
* is true.
* @param value The value to check.
* @param opt_message Error message in case of failure.
* @param var_args The items to substitute into the failure message.
*/
function assertFinite (value : any , opt_message ? : string , ...var_args : any [] ) : number ;
/**
* Checks if the value is a function if goog.asserts.ENABLE_ASSERTS is true.
* @param value The value to check.
* @param opt_message Error message in case of failure.
* @param var_args The items to substitute into the failure message.
*/
function assertFunction (value : any , opt_message ? : string , ...var_args : any [] ) : Function ;
/**
* Checks if the value is an instance of the user-defined type if
* goog.asserts.ENABLE_ASSERTS is true.
*
* The compiler may tighten the type returned by this function.
* @param value The value to check.
* @param type A user-defined constructor.
* @param opt_message Error message in case of failure.
* @param var_args The items to substitute into the failure message.
*/
function assertInstanceof < T > (value : any , type : { new ( ...a : any [] ) : T } , opt_message ? : string , ...var_args : any [] ) : T ;
/**
* Checks if the value is a number if goog.asserts.ENABLE_ASSERTS is true.
* @param value The value to check.
* @param opt_message Error message in case of failure.
* @param var_args The items to substitute into the failure message.
*/
function assertNumber (value : any , opt_message ? : string , ...var_args : any [] ) : number ;
/**
* Checks if the value is an Object if goog.asserts.ENABLE_ASSERTS is true.
* @param value The value to check.
* @param opt_message Error message in case of failure.
* @param var_args The items to substitute into the failure message.
*/
function assertObject (value : any , opt_message ? : string , ...var_args : any [] ) : GlobalObject ;
/**
* Checks that no enumerable keys are present in Object.prototype. Such keys
* would break most code that use {@code for (var ... in ...)} loops.
*/
function assertObjectPrototypeIsIntact ( ) : void ;
/**
* Checks if the value is a string if goog.asserts.ENABLE_ASSERTS is true.
* @param value The value to check.
* @param opt_message Error message in case of failure.
* @param var_args The items to substitute into the failure message.
*/
function assertString (value : any , opt_message ? : string , ...var_args : any [] ) : string ;
/**
* Fails if goog.asserts.ENABLE_ASSERTS is true. This function is useful in case
* when we want to add a check in the unreachable area like switch-case
* statement:
*
* <pre>
* switch(type) {
* case FOO: doSomething(); break;
* case BAR: doSomethingElse(); break;
* default: goog.asserts.fail('Unrecognized type: ' + type);
* // We have only 2 types - "default:" section is unreachable code.
* }
* </pre>
* @param opt_message Error message in case of failure.
* @param var_args The items to substitute into the failure message.
*/
function fail (opt_message ? : string , ...var_args : any [] ) : void ;
/**
* Sets a custom error handler that can be used to customize the behavior of
* assertion failures, for example by turning all assertion failures into log
* messages.
*/
function setErrorHandler (errorHandler : (a : ಠ_ಠ.clutz.goog.asserts.AssertionError ) => any ) : void ;
}
declare module 'goog:goog.asserts' {
import alias = ಠ_ಠ.clutz.goog.asserts;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.asserts {
/**
* Error object for failed assertions.
*/
class AssertionError extends AssertionError_Instance {
}
class AssertionError_Instance extends ಠ_ಠ.clutz.goog.debug.Error_Instance {
/**
* Error object for failed assertions.
* @param messagePattern The pattern that was used to form message.
* @param messageArgs The items to substitute into the pattern.
*/
constructor (messagePattern : string , messageArgs : ಠ_ಠ.clutz.goog.uri.utils.QueryArray ) ;
/**
* The message pattern used to format the error message. Error handlers can
* use this to uniquely identify the assertion.
*/
messagePattern : string ;
}
}
declare module 'goog:goog.asserts.AssertionError' {
import alias = ಠ_ಠ.clutz.goog.asserts.AssertionError;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.async {
class FreeList < ITEM > extends FreeList_Instance < ITEM > {
}
class FreeList_Instance < ITEM > {
private noStructuralTyping_: any;
constructor (create : ( ) => ITEM , reset : (a : ITEM ) => void , limit : number ) ;
get ( ) : ITEM ;
/**
* Visible for testing.
*/
occupants ( ) : number ;
put (item : ITEM ) : void ;
}
}
declare module 'goog:goog.async.FreeList' {
import alias = ಠ_ಠ.clutz.goog.async.FreeList;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.async {
class WorkItem extends WorkItem_Instance {
}
class WorkItem_Instance {
private noStructuralTyping_: any;
fn : ( ( ) => any ) | null ;
next : ಠ_ಠ.clutz.goog.async.WorkItem | null ;
scope ? : GlobalObject | null ;
/**
* Reset the work item so they don't prevent GC before reuse
*/
reset ( ) : void ;
set (fn : ( ) => any , scope : GlobalObject | null | undefined ) : void ;
}
}
declare module 'goog:goog.async.WorkItem' {
import alias = ಠ_ಠ.clutz.goog.async.WorkItem;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.async {
/**
* A low GC workqueue. The key elements of this design:
* - avoids the need for goog.bind or equivalent by carrying scope
* - avoids the need for array reallocation by using a linked list
* - minimizes work entry objects allocation by recycling objects
*/
class WorkQueue extends WorkQueue_Instance {
static DEFAULT_MAX_UNUSED : number ;
}
class WorkQueue_Instance {
private noStructuralTyping_: any;
workHead_ : null | ಠ_ಠ.clutz.goog.async.WorkItem ;
workTail_ : null | ಠ_ಠ.clutz.goog.async.WorkItem ;
add (fn : ( ) => any , scope : GlobalObject | null | undefined ) : void ;
remove ( ) : ಠ_ಠ.clutz.goog.async.WorkItem | null ;
returnUnused (item : ಠ_ಠ.clutz.goog.async.WorkItem | null ) : void ;
}
}
declare module 'goog:goog.async.WorkQueue' {
import alias = ಠ_ಠ.clutz.goog.async.WorkQueue;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.async {
/**
* Fires the provided callbacks as soon as possible after the current JS
* execution context. setTimeout(…, 0) takes at least 4ms when called from
* within another setTimeout(…, 0) for legacy reasons.
*
* This will not schedule the callback as a microtask (i.e. a task that can
* preempt user input or networking callbacks). It is meant to emulate what
* setTimeout(_, 0) would do if it were not throttled. If you desire microtask
* behavior, use {@see goog.Promise} instead.
* @param callback Callback function to fire as soon as possible.
* @param opt_context Object in whose scope to call the listener.
* @param opt_useSetImmediate Avoid the IE workaround that ensures correctness at the cost of speed. See comments for details.
*/
function nextTick < SCOPE > (callback : ( ) => any , opt_context ? : SCOPE , opt_useSetImmediate ? : boolean ) : void ;
}
declare module 'goog:goog.async.nextTick' {
import alias = ಠ_ಠ.clutz.goog.async.nextTick;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.async {
/**
* Fires the provided callback just before the current callstack unwinds, or as
* soon as possible after the current JS execution context.
* @param opt_context Object to use as the "this value" when calling the provided function.
*/
function run < THIS > (callback : ( ) => any , opt_context ? : THIS ) : void ;
}
declare module 'goog:goog.async.run' {
import alias = ಠ_ಠ.clutz.goog.async.run;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.async {
/**
* Throw an item without interrupting the current execution context. For
* example, if processing a group of items in a loop, sometimes it is useful
* to report an error while still allowing the rest of the batch to be
* processed.
*/
function throwException (exception : any ) : void ;
}
declare module 'goog:goog.async.throwException' {
import alias = ಠ_ಠ.clutz.goog.async.throwException;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.debug {
var FORCE_SLOPPY_STACKS : boolean ;
var LOGGING_ENABLED : boolean ;
/**
* Max length of stack to try and output
*/
var MAX_STACK_DEPTH : number ;
/**
* Catches onerror events fired by windows and similar objects.
* @param logFunc The function to call with the error information.
* @param opt_cancel Whether to stop the error from reaching the browser.
* @param opt_target Object that fires onerror events.
*/
function catchErrors (logFunc : (a : GlobalObject | null ) => any , opt_cancel ? : boolean , opt_target ? : GlobalObject | null ) : void ;
/**
* Creates a string representing a given primitive or object, and for an
* object, all its properties and nested objects. NOTE: The output will include
* Uids on all objects that were exposed. Any added Uids will be removed before
* returning.
* @param obj Object to expose.
* @param opt_showFn Also show properties that are functions (by default, functions are omitted).
*/
function deepExpose (obj : any , opt_showFn ? : boolean ) : string ;
/**
* Converts an object to an Error using the object's toString if it's not
* already an Error, adds a stacktrace if there isn't one, and optionally adds
* an extra message.
* @param err The original thrown error, object, or string.
* @param opt_message optional additional message to add to the error.
*/
function enhanceError (err : any , opt_message ? : string ) : GlobalError ;
/**
* Converts an object to an Error using the object's toString if it's not
* already an Error, adds a stacktrace if there isn't one, and optionally adds
* context to the Error, which is reported by the closure error reporter.
* @param err The original thrown error, object, or string.
* @param opt_context Key-value context to add to the Error.
*/
function enhanceErrorWithContext (err : any , opt_context ? : { [ key: string ]: string } ) : GlobalError ;
/**
* Creates a string representing an object and all its properties.
* @param obj Object to expose.
* @param opt_showFn Show the functions as well as the properties, default is false.
*/
function expose (obj : GlobalObject | null | undefined , opt_showFn ? : boolean ) : string ;
/**
* Recursively outputs a nested array as a string.
* @param arr The array.
*/
function exposeArray (arr : any [] | null ) : string ;
/**
* Freezes the given object, but only in debug mode (and in browsers that
* support it). Note that this is a shallow freeze, so for deeply nested
* objects it must be called at every level to ensure deep immutability.
*/
function freeze < T > (arg : T ) : T ;
/**
* Gets a function name
* @param fn Function to get name of.
*/
function getFunctionName (fn : Function | null ) : string ;
/**
* Gets the current stack trace, either starting from the caller or starting
* from a specified function that's currently on the call stack.
* @param fn If provided, when collecting the stack trace all frames above the topmost call to this function, including that call, will be left out of the stack trace.
*/
function getStacktrace (fn ? : Function | null ) : string ;
/**
* Gets the current stack trace. Simple and iterative - doesn't worry about
* catching circular references or getting the args.
* @param opt_depth Optional maximum depth to trace back to.
*/
function getStacktraceSimple (opt_depth ? : number ) : string ;
/**
* Makes whitespace visible by replacing it with printable characters.
* This is useful in finding diffrences between the expected and the actual
* output strings of a testcase.
* @param string whose whitespace needs to be made visible.
*/
function makeWhitespaceVisible (string : string ) : string ;
/**
* Normalizes the error/exception object between browsers.
* @param err Raw error object.
*/
function normalizeErrorObject (err : any ) : { fileName ? : any , lineNumber ? : any , message ? : any , name ? : any , stack ? : any } ;
/**
* Returns the type of a value. If a constructor is passed, and a suitable
* string cannot be found, 'unknown type name' will be returned.
*
* <p>Forked rather than moved from {@link goog.asserts.getType_}
* to avoid adding a dependency to goog.asserts.
* @param value A constructor, object, or primitive.
*/
function runtimeType (value : any ) : string ;
/**
* Set a custom function name resolver.
* @param resolver Resolves functions to their names.
*/
function setFunctionResolver (resolver : (a : Function | null ) => string ) : void ;
}
declare module 'goog:goog.debug' {
import alias = ಠ_ಠ.clutz.goog.debug;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.debug {
interface EntryPointMonitor {
/**
* Try to remove an instrumentation wrapper created by this monitor.
* If the function passed to unwrap is not a wrapper created by this
* monitor, then we will do nothing.
*
* Notice that some wrappers may not be unwrappable. For example, if other
* monitors have applied their own wrappers, then it will be impossible to
* unwrap them because their wrappers will have captured our wrapper.
*
* So it is important that entry points are unwrapped in the reverse
* order that they were wrapped.
* @param fn A function to unwrap.
*/
unwrap (a : Function ) : Function ;
/**
* Instruments a function.
* @param fn A function to instrument.
*/
wrap (a : Function ) : Function ;
}
}
declare module 'goog:goog.debug.EntryPointMonitor' {
import alias = ಠ_ಠ.clutz.goog.debug.EntryPointMonitor;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.debug {
/**
* Base class for custom error objects.
*/
class Error extends Error_Instance {
}
class Error_Instance extends GlobalError {
/**
* Base class for custom error objects.
* @param opt_msg The message associated with the error.
*/
constructor (opt_msg ? : any ) ;
message : string ;
/**
* Whether to report this error to the server. Setting this to false will
* cause the error reporter to not report the error back to the server,
* which can be useful if the client knows that the error has already been
* logged on the server.
*/
reportErrorToServer : boolean ;
stack : string ;
}
}
declare module 'goog:goog.debug.Error' {
import alias = ಠ_ಠ.clutz.goog.debug.Error;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.debug {
/**
* Creates the log buffer.
*/
class LogBuffer extends LogBuffer_Instance {
static CAPACITY : number ;
/**
* A static method that always returns the same instance of LogBuffer.
*/
static getInstance ( ) : ಠ_ಠ.clutz.goog.debug.LogBuffer ;
static instance_ : ಠ_ಠ.clutz.goog.debug.LogBuffer ;
static isBufferingEnabled ( ) : boolean ;
}
class LogBuffer_Instance {
private noStructuralTyping_: any;
/**
* Adds a log record to the buffer, possibly overwriting the oldest record.
* @param level One of the level identifiers.
* @param msg The string message.
* @param loggerName The name of the source logger.
*/
addRecord (level : ಠ_ಠ.clutz.goog.debug.Logger.Level | null , msg : string , loggerName : string ) : ಠ_ಠ.clutz.goog.debug.LogRecord ;
/**
* Removes all buffered log records.
*/
clear ( ) : void ;
/**
* Calls the given function for each buffered log record, starting with the
* oldest one.
* @param func The function to call.
*/
forEachRecord (func : (a : ಠ_ಠ.clutz.goog.debug.LogRecord ) => any ) : void ;
}
}
declare module 'goog:goog.debug.LogBuffer' {
import alias = ಠ_ಠ.clutz.goog.debug.LogBuffer;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.debug.LogManager {
/**
* Creates a function that can be passed to goog.debug.catchErrors. The function
* will log all reported errors using the given logger.
* @param opt_logger The logger to log the errors to. Defaults to the root logger.
*/
function createFunctionForCatchErrors (opt_logger ? : ಠ_ಠ.clutz.goog.debug.Logger | null ) : (a : GlobalObject | null ) => any ;
/**
* Finds a named logger.
* @param name A name for the logger. This should be a dot-separated name and should normally be based on the package name or class name of the subsystem, such as goog.net.BrowserChannel.
*/
function getLogger (name : string ) : ಠ_ಠ.clutz.goog.debug.Logger ;
/**
* Returns all the loggers.
*/
function getLoggers ( ) : { [ key: string ]: ಠ_ಠ.clutz.goog.debug.Logger } ;
/**
* Returns the root of the logger tree namespace, the logger with the empty
* string as its name.
*/
function getRoot ( ) : ಠ_ಠ.clutz.goog.debug.Logger ;
/**
* Initializes the LogManager if not already initialized.
*/
function initialize ( ) : void ;
}
declare module 'goog:goog.debug.LogManager' {
import alias = ಠ_ಠ.clutz.goog.debug.LogManager;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.debug {
/**
* LogRecord objects are used to pass logging requests between
* the logging framework and individual log Handlers.
*/
class LogRecord extends LogRecord_Instance {
static ENABLE_SEQUENCE_NUMBERS : boolean ;
}
class LogRecord_Instance {
private noStructuralTyping_: any;
/**
* LogRecord objects are used to pass logging requests between
* the logging framework and individual log Handlers.
* @param level One of the level identifiers.
* @param msg The string message.
* @param loggerName The name of the source logger.
* @param opt_time Time this log record was created if other than now. If 0, we use #goog.now.
* @param opt_sequenceNumber Sequence number of this log record. This should only be passed in when restoring a log record from persistence.
*/
constructor (level : ಠ_ಠ.clutz.goog.debug.Logger.Level | null , msg : string , loggerName : string , opt_time ? : number , opt_sequenceNumber ? : number ) ;
/**
* Get the exception that is part of the log record.
*/
getException ( ) : GlobalObject | null ;
/**
* Get the logging message level, for example Level.SEVERE.
*/
getLevel ( ) : ಠ_ಠ.clutz.goog.debug.Logger.Level | null ;
/**
* Get the source Logger's name.
*/
getLoggerName ( ) : string ;
/**
* Get the "raw" log message, before localization or formatting.
*/
getMessage ( ) : string ;
/**
* Get event time in milliseconds since 1970.
*/
getMillis ( ) : number ;
/**
* Get the sequence number.
* <p>
* Sequence numbers are normally assigned in the LogRecord
* constructor, which assigns unique sequence numbers to
* each new LogRecord in increasing order.
*/
getSequenceNumber ( ) : number ;
/**
* Sets all fields of the log record.
* @param level One of the level identifiers.
* @param msg The string message.
* @param loggerName The name of the source logger.
* @param opt_time Time this log record was created if other than now. If 0, we use #goog.now.
* @param opt_sequenceNumber Sequence number of this log record. This should only be passed in when restoring a log record from persistence.
*/
reset (level : ಠ_ಠ.clutz.goog.debug.Logger.Level | null , msg : string , loggerName : string , opt_time ? : number , opt_sequenceNumber ? : number ) : void ;
/**
* Set the exception that is part of the log record.
* @param exception the exception.
*/
setException (exception : GlobalObject | null ) : void ;
/**
* Set the logging message level, for example Level.SEVERE.
* @param level the logging message level.
*/
setLevel (level : ಠ_ಠ.clutz.goog.debug.Logger.Level | null ) : void ;
/**
* Get the source Logger's name.
* @param loggerName source logger name (may be null).
*/
setLoggerName (loggerName : string ) : void ;
/**
* Set the "raw" log message, before localization or formatting.
* @param msg the raw message string.
*/
setMessage (msg : string ) : void ;
/**
* Set event time in milliseconds since 1970.
* @param time event time in millis since 1970.
*/
setMillis (time : number ) : void ;
}
}
declare module 'goog:goog.debug.LogRecord' {
import alias = ಠ_ಠ.clutz.goog.debug.LogRecord;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.debug {
/**
* A message value that can be handled by a Logger.
*
* Functions are treated like callbacks, but are only called when the event's
* log level is enabled. This is useful for logging messages that are expensive
* to construct.
*/
type Loggable = string | ( ( ) => string ) ;
}
declare module 'goog:goog.debug.Loggable' {
import alias = ಠ_ಠ.clutz.goog.debug.Loggable;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.debug {
/**
* The Logger is an object used for logging debug messages. Loggers are
* normally named, using a hierarchical dot-separated namespace. Logger names
* can be arbitrary strings, but they should normally be based on the package
* name or class name of the logged component, such as goog.net.BrowserChannel.
*
* The Logger object is loosely based on the java class
* java.util.logging.Logger. It supports different levels of filtering for
* different loggers.
*
* The logger object should never be instantiated by application code. It
* should always use the goog.debug.Logger.getLogger function.
*/
class Logger extends Logger_Instance {
static ENABLE_HIERARCHY : boolean ;
static ENABLE_PROFILER_LOGGING : boolean ;
static ROOT_LOGGER_NAME : string ;
/**
* Finds or creates a logger for a named subsystem. If a logger has already been
* created with the given name it is returned. Otherwise a new logger is
* created. If a new logger is created its log level will be configured based
* on the LogManager configuration and it will configured to also send logging
* output to its parent's handlers. It will be registered in the LogManager
* global namespace.
* @param name A name for the logger. This should be a dot-separated name and should normally be based on the package name or class name of the subsystem, such as goog.net.BrowserChannel.
*/
static getLogger (name : string ) : ಠ_ಠ.clutz.goog.debug.Logger ;
/**
* Logs a message to profiling tools, if available.
* {@see https://developers.google.com/web-toolkit/speedtracer/logging-api}
* {@see http://msdn.microsoft.com/en-us/library/dd433074(VS.85).aspx}
* @param msg The message to log.
*/
static logToProfilers (msg : string ) : void ;
}
class Logger_Instance {
private noStructuralTyping_: any;
/**
* The Logger is an object used for logging debug messages. Loggers are
* normally named, using a hierarchical dot-separated namespace. Logger names
* can be arbitrary strings, but they should normally be based on the package
* name or class name of the logged component, such as goog.net.BrowserChannel.
*
* The Logger object is loosely based on the java class
* java.util.logging.Logger. It supports different levels of filtering for
* different loggers.
*
* The logger object should never be instantiated by application code. It
* should always use the goog.debug.Logger.getLogger function.
* @param name The name of the Logger.
*/
constructor (name : string ) ;
/**
* Adds a handler to the logger. This doesn't use the event system because
* we want to be able to add logging to the event system.
* @param handler Handler function to add.
*/
addHandler (handler : Function | null ) : void ;
/**
* Logs a message at the Logger.Level.CONFIG level.
* If the logger is currently enabled for the given message level then the
* given message is forwarded to all the registered output Handler objects.
* @param msg The message to log.
* @param opt_exception An exception associated with the message.
*/
config (msg : string | ( ( ) => string ) , opt_exception ? : GlobalError | null ) : void ;
/**
* Logs a message at the Logger.Level.FINE level.
* If the logger is currently enabled for the given message level then the
* given message is forwarded to all the registered output Handler objects.
* @param msg The message to log.
* @param opt_exception An exception associated with the message.
*/
fine (msg : string | ( ( ) => string ) , opt_exception ? : GlobalError | null ) : void ;
/**
* Logs a message at the Logger.Level.FINER level.
* If the logger is currently enabled for the given message level then the
* given message is forwarded to all the registered output Handler objects.
* @param msg The message to log.
* @param opt_exception An exception associated with the message.
*/
finer (msg : string | ( ( ) => string ) , opt_exception ? : GlobalError | null ) : void ;
/**
* Logs a message at the Logger.Level.FINEST level.
* If the logger is currently enabled for the given message level then the
* given message is forwarded to all the registered output Handler objects.
* @param msg The message to log.
* @param opt_exception An exception associated with the message.
*/
finest (msg : string | ( ( ) => string ) , opt_exception ? : GlobalError | null ) : void ;
/**
* Returns the children of this logger as a map of the child name to the logger.
*/
getChildren ( ) : GlobalObject ;
/**
* Returns the effective level of the logger based on its ancestors' levels.
*/
getEffectiveLevel ( ) : ಠ_ಠ.clutz.goog.debug.Logger.Level | null ;
/**
* Gets the log level specifying which message levels will be logged by this
* logger. Message levels lower than this value will be discarded.
* The level value Level.OFF can be used to turn off logging. If the level
* is null, it means that this node should inherit its level from its nearest
* ancestor with a specific (non-null) level value.
*/
getLevel ( ) : ಠ_ಠ.clutz.goog.debug.Logger.Level | null ;
/**
* Creates a new log record and adds the exception (if present) to it.
* @param level One of the level identifiers.
* @param msg The string message.
* @param opt_exception An exception associated with the message.
*/
getLogRecord (level : ಠ_ಠ.clutz.goog.debug.Logger.Level | null , msg : string , opt_exception ? : null | GlobalObject ) : ಠ_ಠ.clutz.goog.debug.LogRecord ;
/**
* Gets the name of this logger.
*/
getName ( ) : string ;
/**
* Returns the parent of this logger.
*/
getParent ( ) : ಠ_ಠ.clutz.goog.debug.Logger | null ;
/**
* Logs a message at the Logger.Level.INFO level.
* If the logger is currently enabled for the given message level then the
* given message is forwarded to all the registered output Handler objects.
* @param msg The message to log.
* @param opt_exception An exception associated with the message.
*/
info (msg : string | ( ( ) => string ) , opt_exception ? : GlobalError | null ) : void ;
/**
* Checks if a message of the given level would actually be logged by this
* logger. This check is based on the Loggers effective level, which may be
* inherited from its parent.
* @param level The level to check.
*/
isLoggable (level : ಠ_ಠ.clutz.goog.debug.Logger.Level | null ) : boolean ;
/**
* Logs a message. If the logger is currently enabled for the
* given message level then the given message is forwarded to all the
* registered output Handler objects.
* @param level One of the level identifiers.
* @param msg The message to log.
* @param opt_exception An exception associated with the message.
*/
log (level : ಠ_ಠ.clutz.goog.debug.Logger.Level | null , msg : string | ( ( ) => string ) , opt_exception ? : null | GlobalObject ) : void ;
/**
* Logs a LogRecord. If the logger is currently enabled for the
* given message level then the given message is forwarded to all the
* registered output Handler objects.
* @param logRecord A log record to log.
*/
logRecord (logRecord : ಠ_ಠ.clutz.goog.debug.LogRecord | null ) : void ;
/**
* Removes a handler from the logger. This doesn't use the event system because
* we want to be able to add logging to the event system.
* @param handler Handler function to remove.
*/
removeHandler (handler : Function | null ) : boolean ;
/**
* Set the log level specifying which message levels will be logged by this
* logger. Message levels lower than this value will be discarded.
* The level value Level.OFF can be used to turn off logging. If the new level
* is null, it means that this node should inherit its level from its nearest
* ancestor with a specific (non-null) level value.
* @param level The new level.
*/
setLevel (level : ಠ_ಠ.clutz.goog.debug.Logger.Level | null ) : void ;
/**
* Logs a message at the Logger.Level.SEVERE level.
* If the logger is currently enabled for the given message level then the
* given message is forwarded to all the registered output Handler objects.
* @param msg The message to log.
* @param opt_exception An exception associated with the message.
*/
severe (msg : string | ( ( ) => string ) , opt_exception ? : GlobalError | null ) : void ;
/**
* Logs a message at the Logger.Level.SHOUT level.
* If the logger is currently enabled for the given message level then the
* given message is forwarded to all the registered output Handler objects.
* @param msg The message to log.
* @param opt_exception An exception associated with the message.
*/
shout (msg : string | ( ( ) => string ) , opt_exception ? : GlobalError | null ) : void ;
/**
* Logs a message at the Logger.Level.WARNING level.
* If the logger is currently enabled for the given message level then the
* given message is forwarded to all the registered output Handler objects.
* @param msg The message to log.
* @param opt_exception An exception associated with the message.
*/
warning (msg : string | ( ( ) => string ) , opt_exception ? : GlobalError | null ) : void ;
}
}
declare module 'goog:goog.debug.Logger' {
import alias = ಠ_ಠ.clutz.goog.debug.Logger;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.debug.Logger {
/**
* The Level class defines a set of standard logging levels that
* can be used to control logging output. The logging Level objects
* are ordered and are specified by ordered integers. Enabling logging
* at a given level also enables logging at all higher levels.
* <p>
* Clients should normally use the predefined Level constants such
* as Level.SEVERE.
* <p>
* The levels in descending order are:
* <ul>
* <li>SEVERE (highest value)
* <li>WARNING
* <li>INFO
* <li>CONFIG
* <li>FINE
* <li>FINER
* <li>FINEST (lowest value)
* </ul>
* In addition there is a level OFF that can be used to turn
* off logging, and a level ALL that can be used to enable
* logging of all messages.
*/
class Level extends Level_Instance {
/**
* ALL indicates that all messages should be logged.
* This level is initialized to <CODE>0</CODE>.
*/
static ALL : ಠ_ಠ.clutz.goog.debug.Logger.Level ;
/**
* CONFIG is a message level for static configuration messages.
* This level is initialized to <CODE>700</CODE>.
*/
static CONFIG : ಠ_ಠ.clutz.goog.debug.Logger.Level ;
/**
* FINE is a message level providing tracing information.
* This level is initialized to <CODE>500</CODE>.
*/
static FINE : ಠ_ಠ.clutz.goog.debug.Logger.Level ;
/**
* FINER indicates a fairly detailed tracing message.
* This level is initialized to <CODE>400</CODE>.
*/
static FINER : ಠ_ಠ.clutz.goog.debug.Logger.Level ;
/**
* FINEST indicates a highly detailed tracing message.
* This level is initialized to <CODE>300</CODE>.
*/
static FINEST : ಠ_ಠ.clutz.goog.debug.Logger.Level ;
/**
* INFO is a message level for informational messages.
* This level is initialized to <CODE>800</CODE>.
*/
static INFO : ಠ_ಠ.clutz.goog.debug.Logger.Level ;
/**
* OFF is a special level that can be used to turn off logging.
* This level is initialized to <CODE>Infinity</CODE>.
*/
static OFF : ಠ_ಠ.clutz.goog.debug.Logger.Level ;
/**
* The predefined levels.
*/
static PREDEFINED_LEVELS : ಠ_ಠ.clutz.goog.debug.Logger.Level [] ;
/**
* SEVERE is a message level indicating a serious failure.
* This level is initialized to <CODE>1000</CODE>.
*/
static SEVERE : ಠ_ಠ.clutz.goog.debug.Logger.Level ;
/**
* SHOUT is a message level for extra debugging loudness.
* This level is initialized to <CODE>1200</CODE>.
*/
static SHOUT : ಠ_ಠ.clutz.goog.debug.Logger.Level ;
/**
* WARNING is a message level indicating a potential problem.
* This level is initialized to <CODE>900</CODE>.
*/
static WARNING : ಠ_ಠ.clutz.goog.debug.Logger.Level ;
/**
* Gets the predefined level with the given name.
* @param name The name of the level.
*/
static getPredefinedLevel (name : string ) : ಠ_ಠ.clutz.goog.debug.Logger.Level | null ;
/**
* Gets the highest predefined level <= #value.
* @param value Level value.
*/
static getPredefinedLevelByValue (value : number ) : ಠ_ಠ.clutz.goog.debug.Logger.Level | null ;
}
class Level_Instance {
private noStructuralTyping_: any;
/**
* The Level class defines a set of standard logging levels that
* can be used to control logging output. The logging Level objects
* are ordered and are specified by ordered integers. Enabling logging
* at a given level also enables logging at all higher levels.
* <p>
* Clients should normally use the predefined Level constants such
* as Level.SEVERE.
* <p>
* The levels in descending order are:
* <ul>
* <li>SEVERE (highest value)
* <li>WARNING
* <li>INFO
* <li>CONFIG
* <li>FINE
* <li>FINER
* <li>FINEST (lowest value)
* </ul>
* In addition there is a level OFF that can be used to turn
* off logging, and a level ALL that can be used to enable
* logging of all messages.
* @param name The name of the level.
* @param value The numeric value of the level.
*/
constructor (name : string , value : number ) ;
/**
* The name of the level
*/
name : string ;
/**
* The numeric value of the level
*/
value : number ;
toString ( ) : string ;
}
}
declare module 'goog:goog.debug.Logger.Level' {
import alias = ಠ_ಠ.clutz.goog.debug.Logger.Level;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.debug.entryPointRegistry {
/**
* Configures a monitor to wrap all entry points.
*
* Entry points that have already been registered are immediately wrapped by
* the monitor. When an entry point is registered in the future, it will also
* be wrapped by the monitor when it is registered.
* @param monitor An entry point monitor.
*/
function monitorAll (monitor : ಠ_ಠ.clutz.goog.debug.EntryPointMonitor ) : void ;
/**
* Register an entry point with this module.
*
* The entry point will be instrumented when a monitor is passed to
* goog.debug.entryPointRegistry.monitorAll. If this has already occurred, the
* entry point is instrumented immediately.
* @param callback A callback function which is called with a transforming function to instrument the entry point. The callback is responsible for wrapping the relevant entry point with the transforming function.
*/
function register (callback : (a : Function ) => any ) : void ;
/**
* Try to unmonitor all the entry points that have already been registered. If
* an entry point is registered in the future, it will not be wrapped by the
* monitor when it is registered. Note that this may fail if the entry points
* have additional wrapping.
* @param monitor The last monitor to wrap the entry points.
*/
function unmonitorAllIfPossible (monitor : ಠ_ಠ.clutz.goog.debug.EntryPointMonitor ) : void ;
}
declare module 'goog:goog.debug.entryPointRegistry' {
import alias = ಠ_ಠ.clutz.goog.debug.entryPointRegistry;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.debug.errorcontext {
/**
* Adds key-value context to the error.
* @param err The error to add context to.
* @param contextKey Key for the context to be added.
* @param contextValue Value for the context to be added.
*/
function addErrorContext (err : GlobalError , contextKey : string , contextValue : string ) : void ;
function getErrorContext (err : GlobalError ) : { [ key: string ]: string } ;
}
declare module 'goog:goog.debug.errorcontext' {
import alias = ಠ_ಠ.clutz.goog.debug.errorcontext;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.disposable {
/**
* Interface for a disposable object. If a instance requires cleanup
* (references COM objects, DOM nodes, or other disposable objects), it should
* implement this interface (it may subclass goog.Disposable).
*/
interface IDisposable {
/**
* Disposes of the object and its resources.
*/
dispose ( ) : void ;
isDisposed ( ) : boolean ;
}
}
declare module 'goog:goog.disposable.IDisposable' {
import alias = ಠ_ಠ.clutz.goog.disposable.IDisposable;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog {
/**
* Calls {@code dispose} on the argument if it supports it. If obj is not an
* object with a dispose() method, this is a no-op.
* @param obj The object to dispose of.
*/
function dispose (obj : any ) : void ;
}
declare module 'goog:goog.dispose' {
import alias = ಠ_ಠ.clutz.goog.dispose;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog {
/**
* Calls {@code dispose} on each member of the list that supports it. (If the
* member is an ArrayLike, then {@code goog.disposeAll()} will be called
* recursively on each of its members.) If the member is not an object with a
* {@code dispose()} method, then it is ignored.
* @param var_args The list.
*/
function disposeAll ( ...var_args : any [] ) : void ;
}
declare module 'goog:goog.disposeAll' {
import alias = ಠ_ಠ.clutz.goog.disposeAll;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.dom {
/**
* Alias for getElement.
* @param element Element ID or a DOM node.
*/
function $ (a : string | Element | null ) : Element | null ;
/**
* Alias for {@code getElementsByTagNameAndClass}.
* @param opt_tag Element tag name.
* @param opt_class Optional class name.
* @param opt_el Optional element to look in.
*/
function $$ < T , R > (a ? : string | ಠ_ಠ.clutz.goog.dom.TagName < T > | null , b ? : string | null , c ? : Element | null ) : ArrayLike < R > ;
/**
* Alias for {@code createDom}.
* @param tagName Tag to create.
* @param opt_attributes If object, then a map of name-value pairs for attributes. If a string, then this is the className of the new element. If an array, the elements will be joined together as the className of the new element.
* @param var_args Further DOM nodes or strings for text nodes. If one of the var_args is an array, its children will be added as childNodes instead.
*/
function $dom < T , R > (a : string | ಠ_ಠ.clutz.goog.dom.TagName < T > , b ? : GlobalObject | null | string , ...c : ( GlobalObject | null | string | undefined ) [] ) : R ;
var ASSUME_QUIRKS_MODE : boolean ;
var ASSUME_STANDARDS_MODE : boolean ;
/**
* Appends a node with text or other nodes.
* @param parent The node to append nodes to.
* @param var_args The things to append to the node. If this is a Node it is appended as is. If this is a string then a text node is appended. If this is an array like object then fields 0 to length - 1 are appended.
*/
function append (parent : Node , ...var_args : ( GlobalObject | null | string | undefined ) [] ) : void ;
/**
* Appends a child to a node.
* @param parent Parent.
* @param child Child.
*/
function appendChild (parent : Node | null , child : Node | null ) : void ;
/**
* Determines if the given node can contain children, intended to be used for
* HTML generation.
*
* IE natively supports node.canHaveChildren but has inconsistent behavior.
* Prior to IE8 the base tag allows children and in IE9 all nodes return true
* for canHaveChildren.
*
* In practice all non-IE browsers allow you to add children to any node, but
* the behavior is inconsistent:
*
* <pre>
* var a = goog.dom.createElement(goog.dom.TagName.BR);
* a.appendChild(document.createTextNode('foo'));
* a.appendChild(document.createTextNode('bar'));
* console.log(a.childNodes.length); // 2
* console.log(a.innerHTML); // Chrome: "", IE9: "foobar", FF3.5: "foobar"
* </pre>
*
* For more information, see:
* http://dev.w3.org/html5/markup/syntax.html#syntax-elements
*
* TODO(user): Rename shouldAllowChildren() ?
* @param node The node to check.
*/
function canHaveChildren (node : Node | null ) : boolean ;
/**
* Compares the document order of two nodes, returning 0 if they are the same
* node, a negative number if node1 is before node2, and a positive number if
* node2 is before node1. Note that we compare the order the tags appear in the
* document so in the tree <b><i>text</i></b> the B node is considered to be
* before the I node.
* @param node1 The first node to compare.
* @param node2 The second node to compare.
*/
function compareNodeOrder (node1 : Node | null , node2 : Node | null ) : number ;
/**
* Creates a new Node from constant strings of HTML markup.
* @param var_args The HTML strings to concatenate then convert into a node.
*/
function constHtmlToNode ( ...var_args : ( ಠ_ಠ.clutz.goog.string.Const | undefined ) [] ) : Node ;
/**
* Whether a node contains another node.
* @param parent The node that should contain the other node.
* @param descendant The node to test presence of.
*/
function contains (parent : Node | null | undefined , descendant : Node | null | undefined ) : boolean ;
/**
* Returns a dom node with a set of attributes. This function accepts varargs
* for subsequent nodes to be added. Subsequent nodes will be added to the
* first node as childNodes.
*
* So:
* <code>createDom(goog.dom.TagName.DIV, null, createDom(goog.dom.TagName.P),
* createDom(goog.dom.TagName.P));</code> would return a div with two child
* paragraphs
*
* For passing properties, please see {@link goog.dom.setProperties} for more
* information.
* @param tagName Tag to create.
* @param opt_attributes If object, then a map of name-value pairs for attributes. If a string, then this is the className of the new element. If an array, the elements will be joined together as the className of the new element.
* @param var_args Further DOM nodes or strings for text nodes. If one of the var_args is an array or NodeList, its elements will be added as childNodes instead.
*/
function createDom < T , R > (tagName : string | ಠ_ಠ.clutz.goog.dom.TagName < T > , opt_attributes ? : GlobalObject | null | string , ...var_args : ( GlobalObject | null | string | undefined ) [] ) : R ;
/**
* Creates a new element.
* @param name Tag to create.
*/
function createElement < T , R > (name : string | ಠ_ಠ.clutz.goog.dom.TagName < T > ) : R ;
/**
* Create a table.
* @param rows The number of rows in the table. Must be >= 1.
* @param columns The number of columns in the table. Must be >= 1.
* @param opt_fillWithNbsp If true, fills table entries with {@code goog.string.Unicode.NBSP} characters.
*/
function createTable (rows : number , columns : number , opt_fillWithNbsp ? : boolean ) : Element ;
/**
* Creates a new text node.
* @param content Content.
*/
function createTextNode (content : number | string ) : Text ;
/**
* Find the deepest common ancestor of the given nodes.
* @param var_args The nodes to find a common ancestor of.
*/
function findCommonAncestor ( ...var_args : ( Node | null | undefined ) [] ) : Node | null ;
/**
* Finds the first descendant node that matches the filter function, using
* a depth first search. This function offers the most general purpose way
* of finding a matching element. You may also wish to consider
* {@code goog.dom.query} which can express many matching criteria using
* CSS selector expressions. These expressions often result in a more
* compact representation of the desired result.
* @param root The root of the tree to search.
* @param p The filter function.
*/
function findNode (root : Node | null , p : (a : Node | null ) => boolean ) : Node | null | undefined ;
/**
* Finds all the descendant nodes that match the filter function, using a
* a depth first search. This function offers the most general-purpose way
* of finding a set of matching elements. You may also wish to consider
* {@code goog.dom.query} which can express many matching criteria using
* CSS selector expressions. These expressions often result in a more
* compact representation of the desired result.
* @param root The root of the tree to search.
* @param p The filter function.
*/
function findNodes (root : Node | null , p : (a : Node | null ) => boolean ) : Node [] ;
/**
* Flattens an element. That is, removes it and replace it with its children.
* Does nothing if the element is not in the document.
* @param element The element to flatten.
*/
function flattenElement (element : Element | null ) : Element | null | undefined ;
/**
* Determines the active element in the given document.
* @param doc The document to look in.
*/
function getActiveElement (doc : Document | null ) : Element | null ;
/**
* Walks up the DOM hierarchy returning the first ancestor that passes the
* matcher function.
* @param element The DOM node to start with.
* @param matcher A function that returns true if the passed node matches the desired criteria.
* @param opt_includeNode If true, the node itself is included in the search (the first call to the matcher will pass startElement as the node to test).
* @param opt_maxSearchSteps Maximum number of levels to search up the dom.
*/
function getAncestor (element : Node | null , matcher : (a : Node | null ) => boolean , opt_includeNode ? : boolean , opt_maxSearchSteps ? : number ) : Node | null ;
/**
* Walks up the DOM hierarchy returning the first ancestor that has the passed
* class name. If the passed element matches the specified criteria, the
* element itself is returned.
* @param element The DOM node to start with.
* @param className The class name to match.
* @param opt_maxSearchSteps Maximum number of levels to search up the dom.
*/
function getAncestorByClass (element : Node | null , className : string , opt_maxSearchSteps ? : number ) : Element | null ;
/**
* Walks up the DOM hierarchy returning the first ancestor that has the passed
* tag name and/or class name. If the passed element matches the specified
* criteria, the element itself is returned.
* @param element The DOM node to start with.
* @param opt_tag The tag name to match (or null/undefined to match only based on class name).
* @param opt_class The class name to match (or null/undefined to match only based on tag name).
* @param opt_maxSearchSteps Maximum number of levels to search up the dom.
*/
function getAncestorByTagNameAndClass < T , R > (element : Node | null , opt_tag ? : ಠ_ಠ.clutz.goog.dom.TagName < T > | null | string , opt_class ? : string | null , opt_maxSearchSteps ? : number ) : R | null ;
/**
* Gets '2d' context of a canvas. Shortcut for canvas.getContext('2d') with a
* type information.
*/
function getCanvasContext2D (canvas : HTMLCanvasElement ) : CanvasRenderingContext2D ;
/**
* Returns an array containing just the element children of the given element.
* @param element The element whose element children we want.
*/
function getChildren (element : Element | null ) : Element [] | NodeList ;
/**
* Gets the document object being used by the dom library.
*/
function getDocument ( ) : Document ;
/**
* Calculates the height of the document.
*/
function getDocumentHeight ( ) : number ;
/**
* Calculates the height of the document of the given window.
* @param win The window whose document height to retrieve.
*/
function getDocumentHeightForWindow (win : Window ) : number ;
/**
* Gets the document scroll distance as a coordinate object.
*/
function getDocumentScroll ( ) : ಠ_ಠ.clutz.goog.math.Coordinate ;
/**
* Gets the document scroll element.
*/
function getDocumentScrollElement ( ) : Element ;
/**
* Gets the DomHelper object for the document where the element resides.
* @param opt_element If present, gets the DomHelper for this element.
*/
function getDomHelper (opt_element ? : Node | null | Window ) : ಠ_ಠ.clutz.goog.dom.DomHelper ;
/**
* Gets an element from the current document by element id.
*
* If an Element is passed in, it is returned.
* @param element Element ID or a DOM node.
*/
function getElement (element : string | Element | null ) : Element | null ;
/**
* Returns the first element with the provided className.
* @param className the name of the class to look for.
* @param opt_el Optional element to look in.
*/
function getElementByClass (className : string , opt_el ? : Element | null | Document ) : Element | null ;
/**
* Gets the first element matching the tag and the class.
* @param opt_tag Element tag name.
* @param opt_class Optional class name.
* @param opt_el Optional element to look in.
*/
function getElementByTagNameAndClass < T , R > (opt_tag ? : string | ಠ_ಠ.clutz.goog.dom.TagName < T > | null , opt_class ? : string | null , opt_el ? : Document | null | Element ) : R | null ;
/**
* Returns a static, array-like list of the elements with the provided
* className.
* @param className the name of the class to look for.
* @param opt_el Optional element to look in.
*/
function getElementsByClass (className : string , opt_el ? : Document | null | Element ) : ArrayLike < Element > ;
/**
* Gets elements by tag name.
* @param opt_parent Parent element or document where to look for elements. Defaults to document.
*/
function getElementsByTagName < T , R > (tagName : ಠ_ಠ.clutz.goog.dom.TagName < T > , opt_parent ? : Document | Element ) : NodeList ;
/**
* Looks up elements by both tag and class name, using browser native functions
* ({@code querySelectorAll}, {@code getElementsByTagName} or
* {@code getElementsByClassName}) where possible. This function
* is a useful, if limited, way of collecting a list of DOM elements
* with certain characteristics. {@code goog.dom.query} offers a
* more powerful and general solution which allows matching on CSS3
* selector expressions, but at increased cost in code size. If all you
* need is particular tags belonging to a single class, this function
* is fast and sleek.
*
* Note that tag names are case sensitive in the SVG namespace, and this
* function converts opt_tag to uppercase for comparisons. For queries in the
* SVG namespace you should use querySelector or querySelectorAll instead.
* https://bugzilla.mozilla.org/show_bug.cgi?id=963870
* https://bugs.webkit.org/show_bug.cgi?id=83438
* @param opt_tag Element tag name.
* @param opt_class Optional class name.
* @param opt_el Optional element to look in.
*/
function getElementsByTagNameAndClass < T , R > (opt_tag ? : string | ಠ_ಠ.clutz.goog.dom.TagName < T > | null , opt_class ? : string | null , opt_el ? : Document | null | Element ) : ArrayLike < R > ;
/**
* Returns the first child node that is an element.
* @param node The node to get the first child element of.
*/
function getFirstElementChild (node : Node | null ) : Element | null ;
/**
* Cross-browser function for getting the document element of a frame or iframe.
* @param frame Frame element.
*/
function getFrameContentDocument (frame : Element | null ) : Document ;
/**
* Cross-browser function for getting the window of a frame or iframe.
* @param frame Frame element.
*/
function getFrameContentWindow (frame : Element | null ) : Window | null ;
/**
* Returns the last child node that is an element.
* @param node The node to get the last child element of.
*/
function getLastElementChild (node : Node | null ) : Element | null ;
/**
* Returns the first next sibling that is an element.
* @param node The node to get the next sibling element of.
*/
function getNextElementSibling (node : Node | null ) : Element | null ;
/**
* Returns the next node in source order from the given node.
* @param node The node.
*/
function getNextNode (node : Node | null ) : Node | null ;
/**
* Returns the node at a given offset in a parent node. If an object is
* provided for the optional third parameter, the node and the remainder of the
* offset will stored as properties of this object.
* @param parent The parent node.
* @param offset The offset into the parent node.
* @param opt_result Object to be used to store the return value. The return value will be stored in the form {node: Node, remainder: number} if this object is provided.
*/
function getNodeAtOffset (parent : Node | null , offset : number , opt_result ? : GlobalObject | null ) : Node | null ;
/**
* Returns the text length of the text contained in a node, without markup. This
* is equivalent to the selection length if the node was selected, or the number
* of cursor movements to traverse the node. Images & BRs take one space. New
* lines are ignored.
* @param node The node whose text content length is being calculated.
*/
function getNodeTextLength (node : Node | null ) : number ;
/**
* Returns the text offset of a node relative to one of its ancestors. The text
* length is the same as the length calculated by goog.dom.getNodeTextLength.
* @param node The node whose offset is being calculated.
* @param opt_offsetParent The node relative to which the offset will be calculated. Defaults to the node's owner document's body.
*/
function getNodeTextOffset (node : Node | null , opt_offsetParent ? : Node | null ) : number ;
/**
* Gets the outerHTML of a node, which islike innerHTML, except that it
* actually contains the HTML of the node itself.
* @param element The element to get the HTML of.
*/
function getOuterHtml (element : Element | null ) : string ;
/**
* Returns the owner document for a node.
* @param node The node to get the document for.
*/
function getOwnerDocument (node : Node | null | Window ) : Document ;
/**
* Gets the page scroll distance as a coordinate object.
* @param opt_window Optional window element to test.
*/
function getPageScroll (opt_window ? : Window | null ) : ಠ_ಠ.clutz.goog.math.Coordinate ;
/**
* Returns an element's parent, if it's an Element.
* @param element The DOM element.
*/
function getParentElement (element : Element | null ) : Element | null ;
/**
* Gives the current devicePixelRatio.
*
* By default, this is the value of window.devicePixelRatio (which should be
* preferred if present).
*
* If window.devicePixelRatio is not present, the ratio is calculated with
* window.matchMedia, if present. Otherwise, gives 1.0.
*
* Some browsers (including Chrome) consider the browser zoom level in the pixel
* ratio, so the value may change across multiple calls.
*/
function getPixelRatio ( ) : number ;
/**
* Returns the first previous sibling that is an element.
* @param node The node to get the previous sibling element of.
*/
function getPreviousElementSibling (node : Node | null ) : Element | null ;
/**
* Returns the previous node in source order from the given node.
* @param node The node.
*/
function getPreviousNode (node : Node | null ) : Node | null ;
/**
* Returns the text content of the current node, without markup.
*
* Unlike {@code getTextContent} this method does not collapse whitespaces
* or normalize lines breaks.
* @param node The node from which we are getting content.
*/
function getRawTextContent (node : Node | null ) : string ;
/**
* Gets an element by id, asserting that the element is found.
*
* This is used when an element is expected to exist, and should fail with
* an assertion error if it does not (if assertions are enabled).
* @param id Element ID.
*/
function getRequiredElement (id : string ) : Element ;
/**
* Ensures an element with the given className exists, and then returns the
* first element with the provided className.
* @param className the name of the class to look for.
* @param opt_root Optional element or document to look in.
*/
function getRequiredElementByClass (className : string , opt_root ? : Element | Document ) : Element ;
/**
* Returns the text content of the current node, without markup and invisible
* symbols. New lines are stripped and whitespace is collapsed,
* such that each character would be visible.
*
* In browsers that support it, innerText is used. Other browsers attempt to
* simulate it via node traversal. Line breaks are canonicalized in IE.
* @param node The node from which we are getting content.
*/
function getTextContent (node : Node | null ) : string ;
/**
* Gets the dimensions of the viewport.
*
* Gecko Standards mode:
* docEl.clientWidth Width of viewport excluding scrollbar.
* win.innerWidth Width of viewport including scrollbar.
* body.clientWidth Width of body element.
*
* docEl.clientHeight Height of viewport excluding scrollbar.
* win.innerHeight Height of viewport including scrollbar.
* body.clientHeight Height of document.
*
* Gecko Backwards compatible mode:
* docEl.clientWidth Width of viewport excluding scrollbar.
* win.innerWidth Width of viewport including scrollbar.
* body.clientWidth Width of viewport excluding scrollbar.
*
* docEl.clientHeight Height of document.
* win.innerHeight Height of viewport including scrollbar.
* body.clientHeight Height of viewport excluding scrollbar.
*
* IE6/7 Standards mode:
* docEl.clientWidth Width of viewport excluding scrollbar.
* win.innerWidth Undefined.
* body.clientWidth Width of body element.
*
* docEl.clientHeight Height of viewport excluding scrollbar.
* win.innerHeight Undefined.
* body.clientHeight Height of document element.
*
* IE5 + IE6/7 Backwards compatible mode:
* docEl.clientWidth 0.
* win.innerWidth Undefined.
* body.clientWidth Width of viewport excluding scrollbar.
*
* docEl.clientHeight 0.
* win.innerHeight Undefined.
* body.clientHeight Height of viewport excluding scrollbar.
*
* Opera 9 Standards and backwards compatible mode:
* docEl.clientWidth Width of viewport excluding scrollbar.
* win.innerWidth Width of viewport including scrollbar.
* body.clientWidth Width of viewport excluding scrollbar.
*
* docEl.clientHeight Height of document.
* win.innerHeight Height of viewport including scrollbar.
* body.clientHeight Height of viewport excluding scrollbar.
*
* WebKit:
* Safari 2
* docEl.clientHeight Same as scrollHeight.
* docEl.clientWidth Same as innerWidth.
* win.innerWidth Width of viewport excluding scrollbar.
* win.innerHeight Height of the viewport including scrollbar.
* frame.innerHeight Height of the viewport exluding scrollbar.
*
* Safari 3 (tested in 522)
*
* docEl.clientWidth Width of viewport excluding scrollbar.
* docEl.clientHeight Height of viewport excluding scrollbar in strict mode.
* body.clientHeight Height of viewport excluding scrollbar in quirks mode.
* @param opt_window Optional window element to test.
*/
function getViewportSize (opt_window ? : Window | null ) : ಠ_ಠ.clutz.goog.math.Size ;
/**
* Gets the window object associated with the given document.
* @param opt_doc Document object to get window for.
*/
function getWindow (opt_doc ? : Document | null ) : Window ;
/**
* Insert a child at a given index. If index is larger than the number of child
* nodes that the parent currently has, the node is inserted as the last child
* node.
* @param parent The element into which to insert the child.
* @param child The element to insert.
* @param index The index at which to insert the new child node. Must not be negative.
*/
function insertChildAt (parent : Element | null , child : Node | null , index : number ) : void ;
/**
* Inserts a new node after an existing reference node (i.e. as the next
* sibling). If the reference node has no parent, then does nothing.
* @param newNode Node to insert.
* @param refNode Reference node to insert after.
*/
function insertSiblingAfter (newNode : Node | null , refNode : Node | null ) : void ;
/**
* Inserts a new node before an existing reference node (i.e. as the previous
* sibling). If the reference node has no parent, then does nothing.
* @param newNode Node to insert.
* @param refNode Reference node to insert before.
*/
function insertSiblingBefore (newNode : Node | null , refNode : Node | null ) : void ;
/**
* Returns true if the browser is in "CSS1-compatible" (standards-compliant)
* mode, false otherwise.
*/
function isCss1CompatMode ( ) : boolean ;
/**
* Whether the object looks like an Element.
* @param obj The object being tested for Element likeness.
*/
function isElement (obj : any ) : boolean ;
/**
* Returns true if the element can be focused, i.e. it has a tab index that
* allows it to receive keyboard focus (tabIndex >= 0), or it is an element
* that natively supports keyboard focus.
* @param element Element to check.
*/
function isFocusable (element : Element ) : boolean ;
/**
* Returns true if the element has a tab index that allows it to receive
* keyboard focus (tabIndex >= 0), false otherwise. Note that some elements
* natively support keyboard focus, even if they have no tab index.
* @param element Element to check.
*/
function isFocusableTabIndex (element : Element ) : boolean ;
/**
* Whether the object looks like a DOM node.
* @param obj The object being tested for node likeness.
*/
function isNodeLike (obj : any ) : boolean ;
/**
* Returns true if the object is a {@code NodeList}. To qualify as a NodeList,
* the object must have a numeric length property and an item function (which
* has type 'string' on IE for some reason).
* @param val Object to test.
*/
function isNodeList (val : GlobalObject | null ) : boolean ;
/**
* Returns true if the specified value is a Window object. This includes the
* global window for HTML pages, and iframe windows.
* @param obj Variable to test.
*/
function isWindow (obj : any ) : boolean ;
/**
* Removes all the child nodes on a DOM node.
* @param node Node to remove children from.
*/
function removeChildren (node : Node | null ) : void ;
/**
* Removes a node from its parent.
* @param node The node to remove.
*/
function removeNode (node : Node | null ) : Node | null ;
/**
* Replaces a node in the DOM tree. Will do nothing if {@code oldNode} has no
* parent.
* @param newNode Node to insert.
* @param oldNode Node to replace.
*/
function replaceNode (newNode : Node | null , oldNode : Node | null ) : void ;
/**
* Converts HTML markup into a node. This is a safe version of
* {@code goog.dom.htmlToDocumentFragment} which is now deleted.
* @param html The HTML markup to convert.
*/
function safeHtmlToNode (html : ಠ_ಠ.clutz.goog.html.SafeHtml ) : Node ;
/**
* Enables or disables keyboard focus support on the element via its tab index.
* Only elements for which {@link goog.dom.isFocusableTabIndex} returns true
* (or elements that natively support keyboard focus, like form elements) can
* receive keyboard focus. See http://go/tabindex for more info.
* @param element Element whose tab index is to be changed.
* @param enable Whether to set or remove a tab index on the element that supports keyboard focus.
*/
function setFocusableTabIndex (element : Element | null , enable : boolean ) : void ;
/**
* Sets multiple properties, and sometimes attributes, on an element. Note that
* properties are simply object properties on the element instance, while
* attributes are visible in the DOM. Many properties map to attributes with the
* same names, some with different names, and there are also unmappable cases.
*
* This method sets properties by default (which means that custom attributes
* are not supported). These are the exeptions (some of which is legacy):
* - "style": Even though this is an attribute name, it is translated to a
* property, "style.cssText". Note that this property sanitizes and formats
* its value, unlike the attribute.
* - "class": This is an attribute name, it is translated to the "className"
* property.
* - "for": This is an attribute name, it is translated to the "htmlFor"
* property.
* - Entries in {@see goog.dom.DIRECT_ATTRIBUTE_MAP_} are set as attributes,
* this is probably due to browser quirks.
* - "aria-*", "data-*": Always set as attributes, they have no property
* counterparts.
* @param element DOM node to set properties on.
* @param properties Hash of property:value pairs. Property values can be strings or goog.string.TypedString values (such as goog.html.SafeUrl).
*/
function setProperties (element : Element | null , properties : GlobalObject | null ) : void ;
/**
* Sets the text content of a node, with cross-browser support.
* @param node The node to change the text content of.
* @param text The value that should replace the node's content.
*/
function setTextContent (node : Node | null , text : string | number ) : void ;
}
declare module 'goog:goog.dom' {
import alias = ಠ_ಠ.clutz.goog.dom;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.dom {
/**
* Typedef for use with goog.dom.createDom and goog.dom.append.
*/
type Appendable = GlobalObject | null | string ;
}
declare module 'goog:goog.dom.Appendable' {
import alias = ಠ_ಠ.clutz.goog.dom.Appendable;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.dom {
/**
* Enum of browser capabilities.
*/
type BrowserFeature = boolean &{clutzEnumBrand: never} ;
var BrowserFeature : {
CAN_ADD_NAME_OR_TYPE_ATTRIBUTES : BrowserFeature ,
CAN_USE_CHILDREN_ATTRIBUTE : BrowserFeature ,
CAN_USE_INNER_TEXT : BrowserFeature ,
CAN_USE_PARENT_ELEMENT_PROPERTY : BrowserFeature ,
INNER_HTML_NEEDS_SCOPED_ELEMENT : BrowserFeature ,
LEGACY_IE_RANGES : BrowserFeature ,
};
}
declare module 'goog:goog.dom.BrowserFeature' {
import alias = ಠ_ಠ.clutz.goog.dom.BrowserFeature;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.dom {
/**
* Create an instance of a DOM helper with a new document object.
*/
class DomHelper extends DomHelper_Instance {
}
class DomHelper_Instance {
private noStructuralTyping_: any;
/**
* Create an instance of a DOM helper with a new document object.
* @param opt_document Document object to associate with this DOM helper.
*/
constructor (opt_document ? : Document | null ) ;
/**
* Alias for {@code getElement}.
* @param element Element ID or a DOM node.
*/
$ (a : string | Element | null ) : Element | null ;
/**
* Alias for {@code getElementsByTagNameAndClass}.
* @param opt_tag Element tag name.
* @param opt_class Optional class name.
* @param opt_el Optional element to look in.
*/
/* function had TTE, but not a known translation. Emitted type is likely wrong. */
$$ < T , R > (a ? : string | ಠ_ಠ.clutz.goog.dom.TagName < T > | null , b ? : string | null , c ? : Element | null ) : ArrayLike < R > ;
/**
* Alias for {@code createDom}.
* @param tagName Tag to create.
* @param opt_attributes If object, then a map of name-value pairs for attributes. If a string, then this is the className of the new element. If an array, the elements will be joined together as the className of the new element.
* @param var_args Further DOM nodes or strings for text nodes. If one of the var_args is an array, its children will be added as childNodes instead.
*/
/* function had TTE, but not a known translation. Emitted type is likely wrong. */
$dom < T , R > (a : string | ಠ_ಠ.clutz.goog.dom.TagName < T > , b ? : GlobalObject | null | string , ...c : ( GlobalObject | null | string | undefined ) [] ) : R ;
/**
* Appends a node with text or other nodes.
* @param parent The node to append nodes to.
* @param var_args The things to append to the node. If this is a Node it is appended as is. If this is a string then a text node is appended. If this is an array like object then fields 0 to length - 1 are appended.
*/
append (a : Node , ...b : ( GlobalObject | null | string | undefined ) [] ) : any ;
/**
* Appends a child to a node.
* @param parent Parent.
* @param child Child.
*/
appendChild (a : Node | null , b : Node | null ) : any ;
/**
* Determines if the given node can contain children, intended to be used for
* HTML generation.
* @param node The node to check.
*/
canHaveChildren (a : Node | null ) : boolean ;
/**
* Compares the document order of two nodes, returning 0 if they are the same
* node, a negative number if node1 is before node2, and a positive number if
* node2 is before node1. Note that we compare the order the tags appear in the
* document so in the tree <b><i>text</i></b> the B node is considered to be
* before the I node.
* @param node1 The first node to compare.
* @param node2 The second node to compare.
*/
compareNodeOrder (a : Node | null , b : Node | null ) : number ;
/**
* Whether a node contains another node.
* @param parent The node that should contain the other node.
* @param descendant The node to test presence of.
*/
contains (a : Node | null , b : Node | null ) : boolean ;
/**
* Returns a dom node with a set of attributes. This function accepts varargs
* for subsequent nodes to be added. Subsequent nodes will be added to the
* first node as childNodes.
*
* So:
* <code>createDom(goog.dom.TagName.DIV, null, createDom(goog.dom.TagName.P),
* createDom(goog.dom.TagName.P));</code> would return a div with two child
* paragraphs
*
* An easy way to move all child nodes of an existing element to a new parent
* element is:
* <code>createDom(goog.dom.TagName.DIV, null, oldElement.childNodes);</code>
* which will remove all child nodes from the old element and add them as
* child nodes of the new DIV.
* @param tagName Tag to create.
* @param opt_attributes If object, then a map of name-value pairs for attributes. If a string, then this is the className of the new element. If an array, the elements will be joined together as the className of the new element.
* @param var_args Further DOM nodes or strings for text nodes. If one of the var_args is an array or NodeList, its elements will be added as childNodes instead.
*/
/* function had TTE, but not a known translation. Emitted type is likely wrong. */
createDom < T , R > (tagName : string | ಠ_ಠ.clutz.goog.dom.TagName < T > , opt_attributes ? : GlobalObject | null | string , ...var_args : ( GlobalObject | null | string | undefined ) [] ) : R ;
/**
* Creates a new element.
* @param name Tag to create.
*/
/* function had TTE, but not a known translation. Emitted type is likely wrong. */
createElement < T , R > (name : string | ಠ_ಠ.clutz.goog.dom.TagName < T > ) : R ;
/**
* Create a table.
* @param rows The number of rows in the table. Must be >= 1.
* @param columns The number of columns in the table. Must be >= 1.
* @param opt_fillWithNbsp If true, fills table entries with {@code goog.string.Unicode.NBSP} characters.
*/
createTable (rows : number , columns : number , opt_fillWithNbsp ? : boolean ) : HTMLElement ;
/**
* Creates a new text node.
* @param content Content.
*/
createTextNode (content : number | string ) : Text ;
/**
* Find the deepest common ancestor of the given nodes.
* @param var_args The nodes to find a common ancestor of.
*/
findCommonAncestor ( ...a : ( Node | null | undefined ) [] ) : Node | null ;
/**
* Finds the first descendant node that matches the filter function. This does
* a depth first search.
* @param root The root of the tree to search.
* @param p The filter function.
*/
findNode (a : Node | null , b : (a : Node | null ) => boolean ) : Node | null | undefined ;
/**
* Finds all the descendant nodes that matches the filter function. This does a
* depth first search.
* @param root The root of the tree to search.
* @param p The filter function.
*/
findNodes (a : Node | null , b : (a : Node | null ) => boolean ) : ( Node | null ) [] | null ;
/**
* Flattens an element. That is, removes it and replace it with its children.
* @param element The element to flatten.
*/
flattenElement (a : Element | null ) : Element | null | undefined ;
/**
* Determines the active element in the given document.
* @param opt_doc The document to look in.
*/
getActiveElement (opt_doc ? : Document | null ) : Element | null ;
/**
* Walks up the DOM hierarchy returning the first ancestor that passes the
* matcher function.
* @param element The DOM node to start with.
* @param matcher A function that returns true if the passed node matches the desired criteria.
* @param opt_includeNode If true, the node itself is included in the search (the first call to the matcher will pass startElement as the node to test).
* @param opt_maxSearchSteps Maximum number of levels to search up the dom.
*/
getAncestor (a : Node | null , b : (a : Node | null ) => boolean , c ? : boolean , d ? : number ) : Node | null ;
/**
* Walks up the DOM hierarchy returning the first ancestor that has the passed
* class name. If the passed element matches the specified criteria, the
* element itself is returned.
* @param element The DOM node to start with.
* @param class The class name to match.
* @param opt_maxSearchSteps Maximum number of levels to search up the dom.
*/
getAncestorByClass (a : Node | null , b : string , c ? : number ) : Element | null ;
/**
* Walks up the DOM hierarchy returning the first ancestor that has the passed
* tag name and/or class name. If the passed element matches the specified
* criteria, the element itself is returned.
* @param element The DOM node to start with.
* @param opt_tag The tag name to match (or null/undefined to match only based on class name).
* @param opt_class The class name to match (or null/undefined to match only based on tag name).
* @param opt_maxSearchSteps Maximum number of levels to search up the dom.
*/
/* function had TTE, but not a known translation. Emitted type is likely wrong. */
getAncestorByTagNameAndClass < T , R > (a : Node | null , b ? : ಠ_ಠ.clutz.goog.dom.TagName < T > | null | string , c ? : string | null , d ? : number ) : R | null ;
/**
* Gets '2d' context of a canvas. Shortcut for canvas.getContext('2d') with a
* type information.
*/
getCanvasContext2D (a : HTMLCanvasElement ) : CanvasRenderingContext2D ;
/**
* Returns an array containing just the element children of the given element.
* @param element The element whose element children we want.
*/
getChildren (a : Element | null ) : Element [] | NodeList ;
/**
* Gets the document object being used by the dom library.
*/
getDocument ( ) : Document ;
/**
* Calculates the height of the document.
*/
getDocumentHeight ( ) : number ;
/**
* Gets the document scroll distance as a coordinate object.
*/
getDocumentScroll ( ) : ಠ_ಠ.clutz.goog.math.Coordinate ;
/**
* Gets the document scroll element.
*/
getDocumentScrollElement ( ) : Element ;
/**
* Gets the dom helper object for the document where the element resides.
* @param opt_node If present, gets the DomHelper for this node.
*/
getDomHelper (a ? : Node | null ) : ಠ_ಠ.clutz.goog.dom.DomHelper ;
/**
* Alias for {@code getElementById}. If a DOM node is passed in then we just
* return that.
* @param element Element ID or a DOM node.
*/
getElement (element : string | Element | null ) : Element | null ;
/**
* Returns the first element we find matching the provided class name.
* @param className the name of the class to look for.
* @param opt_el Optional element to look in.
*/
getElementByClass (className : string , opt_el ? : Element | null | Document ) : Element | null ;
/**
* Gets the first element matching the tag and the class.
* @param opt_tag Element tag name.
* @param opt_class Optional class name.
* @param opt_el Optional element to look in.
*/
/* function had TTE, but not a known translation. Emitted type is likely wrong. */
getElementByTagNameAndClass < T , R > (opt_tag ? : string | ಠ_ಠ.clutz.goog.dom.TagName < T > | null , opt_class ? : string | null , opt_el ? : Document | null | Element ) : R | null ;
/**
* Returns an array of all the elements with the provided className.
* @param className the name of the class to look for.
* @param opt_el Optional element to look in.
*/
getElementsByClass (className : string , opt_el ? : Element | null | Document ) : ArrayLike < Element > ;
/**
* Gets elements by tag name.
* @param opt_parent Parent element or document where to look for elements. Defaults to document of this DomHelper.
*/
/* function had TTE, but not a known translation. Emitted type is likely wrong. */
getElementsByTagName < T , R > (tagName : ಠ_ಠ.clutz.goog.dom.TagName < T > , opt_parent ? : Document | Element ) : NodeList ;
/**
* Looks up elements by both tag and class name, using browser native functions
* ({@code querySelectorAll}, {@code getElementsByTagName} or
* {@code getElementsByClassName}) where possible. The returned array is a live
* NodeList or a static list depending on the code path taken.
* @param opt_tag Element tag name or * for all tags.
* @param opt_class Optional class name.
* @param opt_el Optional element to look in.
*/
/* function had TTE, but not a known translation. Emitted type is likely wrong. */
getElementsByTagNameAndClass < T , R > (opt_tag ? : string | ಠ_ಠ.clutz.goog.dom.TagName < T > | null , opt_class ? : string | null , opt_el ? : Document | null | Element ) : ArrayLike < R > ;
/**
* Returns the first child node that is an element.
* @param node The node to get the first child element of.
*/
getFirstElementChild (a : Node | null ) : Element | null ;
/**
* Cross browser function for getting the document element of an iframe.
* @param iframe Iframe element.
*/
getFrameContentDocument (a : Element | null ) : Document ;
/**
* Cross browser function for getting the window of a frame or iframe.
* @param frame Frame element.
*/
getFrameContentWindow (a : Element | null ) : Window | null ;
/**
* Returns the last child node that is an element.
* @param node The node to get the last child element of.
*/
getLastElementChild (a : Node | null ) : Element | null ;
/**
* Returns the first next sibling that is an element.
* @param node The node to get the next sibling element of.
*/
getNextElementSibling (a : Node | null ) : Element | null ;
/**
* Returns the next node in source order from the given node.
* @param node The node.
*/
getNextNode (a : Node | null ) : Node | null ;
/**
* Returns the node at a given offset in a parent node. If an object is
* provided for the optional third parameter, the node and the remainder of the
* offset will stored as properties of this object.
* @param parent The parent node.
* @param offset The offset into the parent node.
* @param opt_result Object to be used to store the return value. The return value will be stored in the form {node: Node, remainder: number} if this object is provided.
*/
getNodeAtOffset (a : Node | null , b : number , c ? : GlobalObject | null ) : Node | null ;
/**
* Returns the text length of the text contained in a node, without markup. This
* is equivalent to the selection length if the node was selected, or the number
* of cursor movements to traverse the node. Images & BRs take one space. New
* lines are ignored.
* @param node The node whose text content length is being calculated.
*/
getNodeTextLength (a : Node | null ) : number ;
/**
* Returns the text offset of a node relative to one of its ancestors. The text
* length is the same as the length calculated by
* {@code goog.dom.getNodeTextLength}.
* @param node The node whose offset is being calculated.
* @param opt_offsetParent Defaults to the node's owner document's body.
*/
getNodeTextOffset (a : Node | null , b ? : Node | null ) : number ;
/**
* Gets the outerHTML of a node, which islike innerHTML, except that it
* actually contains the HTML of the node itself.
* @param element The element to get the HTML of.
*/
getOuterHtml (a : Element | null ) : string ;
/**
* Returns the owner document for a node.
* @param node The node to get the document for.
*/
getOwnerDocument (a : Node | null ) : Document ;
/**
* Returns an element's parent, if it's an Element.
* @param element The DOM element.
*/
getParentElement (a : Element | null ) : Element | null ;
/**
* Returns the first previous sibling that is an element.
* @param node The node to get the previous sibling element of.
*/
getPreviousElementSibling (a : Node | null ) : Element | null ;
/**
* Returns the previous node in source order from the given node.
* @param node The node.
*/
getPreviousNode (a : Node | null ) : Node | null ;
/**
* Gets an element by id, asserting that the element is found.
*
* This is used when an element is expected to exist, and should fail with
* an assertion error if it does not (if assertions are enabled).
* @param id Element ID.
*/
getRequiredElement (id : string ) : Element ;
/**
* Ensures an element with the given className exists, and then returns the
* first element with the provided className.
* @param className the name of the class to look for.
* @param opt_root Optional element or document to look in.
*/
getRequiredElementByClass (className : string , opt_root ? : Element | Document ) : Element ;
/**
* Returns the text contents of the current node, without markup. New lines are
* stripped and whitespace is collapsed, such that each character would be
* visible.
*
* In browsers that support it, innerText is used. Other browsers attempt to
* simulate it via node traversal. Line breaks are canonicalized in IE.
* @param node The node from which we are getting content.
*/
getTextContent (a : Node | null ) : string ;
/**
* Gets the dimensions of the viewport.
* @param opt_window Optional window element to test. Defaults to the window of the Dom Helper.
*/
getViewportSize (opt_window ? : Window | null ) : ಠ_ಠ.clutz.goog.math.Size ;
/**
* Gets the window object associated with the document.
*/
getWindow ( ) : Window ;
/**
* Insert a child at a given index. If index is larger than the number of child
* nodes that the parent currently has, the node is inserted as the last child
* node.
* @param parent The element into which to insert the child.
* @param child The element to insert.
* @param index The index at which to insert the new child node. Must not be negative.
*/
insertChildAt (a : Element | null , b : Node | null , c : number ) : any ;
/**
* Inserts a new node after an existing reference node (i.e., as the next
* sibling). If the reference node has no parent, then does nothing.
* @param newNode Node to insert.
* @param refNode Reference node to insert after.
*/
insertSiblingAfter (a : Node | null , b : Node | null ) : any ;
/**
* Inserts a new node before an existing reference node (i.e., as the previous
* sibling). If the reference node has no parent, then does nothing.
* @param newNode Node to insert.
* @param refNode Reference node to insert before.
*/
insertSiblingBefore (a : Node | null , b : Node | null ) : any ;
/**
* Returns true if the browser is in "CSS1-compatible" (standards-compliant)
* mode, false otherwise.
*/
isCss1CompatMode ( ) : boolean ;
/**
* Whether the object looks like an Element.
* @param obj The object being tested for Element likeness.
*/
isElement (a : any ) : boolean ;
/**
* Returns true if the element can be focused, i.e. it has a tab index that
* allows it to receive keyboard focus (tabIndex >= 0), or it is an element
* that natively supports keyboard focus.
* @param element Element to check.
*/
isFocusable (a : Element ) : boolean ;
/**
* Returns true if the element has a tab index that allows it to receive
* keyboard focus (tabIndex >= 0), false otherwise. Note that some elements
* natively support keyboard focus, even if they have no tab index.
* @param element Element to check.
*/
isFocusableTabIndex (a : Element ) : boolean ;
/**
* Whether the object looks like a DOM node.
* @param obj The object being tested for node likeness.
*/
isNodeLike (a : any ) : boolean ;
/**
* Returns true if the object is a {@code NodeList}. To qualify as a NodeList,
* the object must have a numeric length property and an item function (which
* has type 'string' on IE for some reason).
* @param val Object to test.
*/
isNodeList (a : GlobalObject | null ) : boolean ;
/**
* Returns true if the specified value is a Window object. This includes the
* global window for HTML pages, and iframe windows.
* @param obj Variable to test.
*/
isWindow (a : any ) : boolean ;
/**
* Removes all the child nodes on a DOM node.
* @param node Node to remove children from.
*/
removeChildren (a : Node | null ) : any ;
/**
* Removes a node from its parent.
* @param node The node to remove.
*/
removeNode (a : Node | null ) : Node | null ;
/**
* Replaces a node in the DOM tree. Will do nothing if {@code oldNode} has no
* parent.
* @param newNode Node to insert.
* @param oldNode Node to replace.
*/
replaceNode (a : Node | null , b : Node | null ) : any ;
/**
* Converts an HTML into a node or a document fragment. A single Node is used if
* {@code html} only generates a single node. If {@code html} generates multiple
* nodes then these are put inside a {@code DocumentFragment}. This is a safe
* version of {@code goog.dom.DomHelper#htmlToDocumentFragment} which is now
* deleted.
* @param html The HTML markup to convert.
*/
safeHtmlToNode (html : ಠ_ಠ.clutz.goog.html.SafeHtml ) : Node ;
/**
* Sets the document object.
* @param document Document object.
*/
setDocument (document : Document ) : void ;
/**
* Enables or disables keyboard focus support on the element via its tab index.
* Only elements for which {@link goog.dom.isFocusableTabIndex} returns true
* (or elements that natively support keyboard focus, like form elements) can
* receive keyboard focus. See http://go/tabindex for more info.
* @param element Element whose tab index is to be changed.
* @param enable Whether to set or remove a tab index on the element that supports keyboard focus.
*/
setFocusableTabIndex (a : Element | null , b : boolean ) : any ;
/**
* Sets a number of properties on a node.
* @param element DOM node to set properties on.
* @param properties Hash of property:value pairs.
*/
setProperties (a : Element | null , b : GlobalObject | null ) : any ;
/**
* Sets the text content of a node, with cross-browser support.
* @param node The node to change the text content of.
* @param text The value that should replace the node's content.
*/
setTextContent (a : Node | null , b : string | number ) : any ;
}
}
declare module 'goog:goog.dom.DomHelper' {
import alias = ಠ_ಠ.clutz.goog.dom.DomHelper;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.dom {
/**
* This subclass of HTMLElement is used when only a HTMLElement is possible and
* not any of its subclasses. Normally, a type can refer to an instance of
* itself or an instance of any subtype. More concretely, if HTMLElement is used
* then the compiler must assume that it might still be e.g. HTMLScriptElement.
* With this, the type check knows that it couldn't be any special element.
*/
class HtmlElement extends HtmlElement_Instance {
}
class HtmlElement_Instance extends HTMLElement {
}
}
declare module 'goog:goog.dom.HtmlElement' {
import alias = ಠ_ಠ.clutz.goog.dom.HtmlElement;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.dom {
/**
* Constants for the nodeType attribute in the Node interface.
*
* These constants match those specified in the Node interface. These are
* usually present on the Node object in recent browsers, but not in older
* browsers (specifically, early IEs) and thus are given here.
*
* In some browsers (early IEs), these are not defined on the Node object,
* so they are provided here.
*
* See http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247
*/
enum NodeType {
ATTRIBUTE ,
CDATA_SECTION ,
COMMENT ,
DOCUMENT ,
DOCUMENT_FRAGMENT ,
DOCUMENT_TYPE ,
ELEMENT ,
ENTITY ,
ENTITY_REFERENCE ,
NOTATION ,
PROCESSING_INSTRUCTION ,
TEXT ,
}
}
declare module 'goog:goog.dom.NodeType' {
import alias = ಠ_ಠ.clutz.goog.dom.NodeType;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.dom {
/**
* A tag name with the type of the element stored in the generic.
*/
class TagName < T > extends TagName_Instance < T > {
static A : ಠ_ಠ.clutz.goog.dom.TagName < HTMLAnchorElement > ;
static ABBR : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static ACRONYM : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static ADDRESS : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static APPLET : ಠ_ಠ.clutz.goog.dom.TagName < HTMLAppletElement > ;
static AREA : ಠ_ಠ.clutz.goog.dom.TagName < HTMLAreaElement > ;
static ARTICLE : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static ASIDE : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static AUDIO : ಠ_ಠ.clutz.goog.dom.TagName < HTMLAudioElement > ;
static B : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static BASE : ಠ_ಠ.clutz.goog.dom.TagName < HTMLBaseElement > ;
static BASEFONT : ಠ_ಠ.clutz.goog.dom.TagName < HTMLBaseFontElement > ;
static BDI : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static BDO : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static BIG : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static BLOCKQUOTE : ಠ_ಠ.clutz.goog.dom.TagName < HTMLQuoteElement > ;
static BODY : ಠ_ಠ.clutz.goog.dom.TagName < HTMLBodyElement > ;
static BR : ಠ_ಠ.clutz.goog.dom.TagName < HTMLBRElement > ;
static BUTTON : ಠ_ಠ.clutz.goog.dom.TagName < HTMLButtonElement > ;
static CANVAS : ಠ_ಠ.clutz.goog.dom.TagName < HTMLCanvasElement > ;
static CAPTION : ಠ_ಠ.clutz.goog.dom.TagName < HTMLTableCaptionElement > ;
static CENTER : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static CITE : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static CODE : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static COL : ಠ_ಠ.clutz.goog.dom.TagName < HTMLTableColElement > ;
static COLGROUP : ಠ_ಠ.clutz.goog.dom.TagName < HTMLTableColElement > ;
static COMMAND : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static DATA : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static DATALIST : ಠ_ಠ.clutz.goog.dom.TagName < HTMLDataListElement > ;
static DD : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static DEL : ಠ_ಠ.clutz.goog.dom.TagName < HTMLModElement > ;
static DETAILS : ಠ_ಠ.clutz.goog.dom.TagName < HTMLDetailsElement > ;
static DFN : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static DIALOG : ಠ_ಠ.clutz.goog.dom.TagName < HTMLDialogElement > ;
static DIR : ಠ_ಠ.clutz.goog.dom.TagName < HTMLDirectoryElement > ;
static DIV : ಠ_ಠ.clutz.goog.dom.TagName < HTMLDivElement > ;
static DL : ಠ_ಠ.clutz.goog.dom.TagName < HTMLDListElement > ;
static DT : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static EM : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static EMBED : ಠ_ಠ.clutz.goog.dom.TagName < HTMLEmbedElement > ;
static FIELDSET : ಠ_ಠ.clutz.goog.dom.TagName < HTMLFieldSetElement > ;
static FIGCAPTION : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static FIGURE : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static FONT : ಠ_ಠ.clutz.goog.dom.TagName < HTMLFontElement > ;
static FOOTER : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static FORM : ಠ_ಠ.clutz.goog.dom.TagName < HTMLFormElement > ;
static FRAME : ಠ_ಠ.clutz.goog.dom.TagName < HTMLFrameElement > ;
static FRAMESET : ಠ_ಠ.clutz.goog.dom.TagName < HTMLFrameSetElement > ;
static H1 : ಠ_ಠ.clutz.goog.dom.TagName < HTMLHeadingElement > ;
static H2 : ಠ_ಠ.clutz.goog.dom.TagName < HTMLHeadingElement > ;
static H3 : ಠ_ಠ.clutz.goog.dom.TagName < HTMLHeadingElement > ;
static H4 : ಠ_ಠ.clutz.goog.dom.TagName < HTMLHeadingElement > ;
static H5 : ಠ_ಠ.clutz.goog.dom.TagName < HTMLHeadingElement > ;
static H6 : ಠ_ಠ.clutz.goog.dom.TagName < HTMLHeadingElement > ;
static HEAD : ಠ_ಠ.clutz.goog.dom.TagName < HTMLHeadElement > ;
static HEADER : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static HGROUP : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static HR : ಠ_ಠ.clutz.goog.dom.TagName < HTMLHRElement > ;
static HTML : ಠ_ಠ.clutz.goog.dom.TagName < HTMLHtmlElement > ;
static I : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static IFRAME : ಠ_ಠ.clutz.goog.dom.TagName < HTMLIFrameElement > ;
static IMG : ಠ_ಠ.clutz.goog.dom.TagName < HTMLImageElement > ;
static INPUT : ಠ_ಠ.clutz.goog.dom.TagName < HTMLInputElement > ;
static INS : ಠ_ಠ.clutz.goog.dom.TagName < HTMLModElement > ;
static ISINDEX : ಠ_ಠ.clutz.goog.dom.TagName < HTMLIsIndexElement > ;
static KBD : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static KEYGEN : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static LABEL : ಠ_ಠ.clutz.goog.dom.TagName < HTMLLabelElement > ;
static LEGEND : ಠ_ಠ.clutz.goog.dom.TagName < HTMLLegendElement > ;
static LI : ಠ_ಠ.clutz.goog.dom.TagName < HTMLLIElement > ;
static LINK : ಠ_ಠ.clutz.goog.dom.TagName < HTMLLinkElement > ;
static MAP : ಠ_ಠ.clutz.goog.dom.TagName < HTMLMapElement > ;
static MARK : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static MATH : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static MENU : ಠ_ಠ.clutz.goog.dom.TagName < HTMLMenuElement > ;
static META : ಠ_ಠ.clutz.goog.dom.TagName < HTMLMetaElement > ;
static METER : ಠ_ಠ.clutz.goog.dom.TagName < HTMLMeterElement > ;
static NAV : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static NOFRAMES : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static NOSCRIPT : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static OBJECT : ಠ_ಠ.clutz.goog.dom.TagName < HTMLObjectElement > ;
static OL : ಠ_ಠ.clutz.goog.dom.TagName < HTMLOListElement > ;
static OPTGROUP : ಠ_ಠ.clutz.goog.dom.TagName < HTMLOptGroupElement > ;
static OPTION : ಠ_ಠ.clutz.goog.dom.TagName < HTMLOptionElement > ;
static OUTPUT : ಠ_ಠ.clutz.goog.dom.TagName < HTMLOutputElement > ;
static P : ಠ_ಠ.clutz.goog.dom.TagName < HTMLParagraphElement > ;
static PARAM : ಠ_ಠ.clutz.goog.dom.TagName < HTMLParamElement > ;
static PRE : ಠ_ಠ.clutz.goog.dom.TagName < HTMLPreElement > ;
static PROGRESS : ಠ_ಠ.clutz.goog.dom.TagName < HTMLProgressElement > ;
static Q : ಠ_ಠ.clutz.goog.dom.TagName < HTMLQuoteElement > ;
static RP : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static RT : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static RUBY : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static S : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static SAMP : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static SCRIPT : ಠ_ಠ.clutz.goog.dom.TagName < HTMLScriptElement > ;
static SECTION : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static SELECT : ಠ_ಠ.clutz.goog.dom.TagName < HTMLSelectElement > ;
static SMALL : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static SOURCE : ಠ_ಠ.clutz.goog.dom.TagName < HTMLSourceElement > ;
static SPAN : ಠ_ಠ.clutz.goog.dom.TagName < HTMLSpanElement > ;
static STRIKE : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static STRONG : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static STYLE : ಠ_ಠ.clutz.goog.dom.TagName < HTMLStyleElement > ;
static SUB : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static SUMMARY : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static SUP : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static SVG : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static TABLE : ಠ_ಠ.clutz.goog.dom.TagName < HTMLTableElement > ;
static TBODY : ಠ_ಠ.clutz.goog.dom.TagName < HTMLTableSectionElement > ;
static TD : ಠ_ಠ.clutz.goog.dom.TagName < HTMLTableCellElement > ;
static TEMPLATE : ಠ_ಠ.clutz.goog.dom.TagName < HTMLTemplateElement > ;
static TEXTAREA : ಠ_ಠ.clutz.goog.dom.TagName < HTMLTextAreaElement > ;
static TFOOT : ಠ_ಠ.clutz.goog.dom.TagName < HTMLTableSectionElement > ;
static TH : ಠ_ಠ.clutz.goog.dom.TagName < HTMLTableCellElement > ;
static THEAD : ಠ_ಠ.clutz.goog.dom.TagName < HTMLTableSectionElement > ;
static TIME : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static TITLE : ಠ_ಠ.clutz.goog.dom.TagName < HTMLTitleElement > ;
static TR : ಠ_ಠ.clutz.goog.dom.TagName < HTMLTableRowElement > ;
static TRACK : ಠ_ಠ.clutz.goog.dom.TagName < HTMLTrackElement > ;
static TT : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static U : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static UL : ಠ_ಠ.clutz.goog.dom.TagName < HTMLUListElement > ;
static VAR : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
static VIDEO : ಠ_ಠ.clutz.goog.dom.TagName < HTMLVideoElement > ;
static WBR : ಠ_ಠ.clutz.goog.dom.TagName < ಠ_ಠ.clutz.goog.dom.HtmlElement > ;
}
class TagName_Instance < T > {
private noStructuralTyping_: any;
/**
* A tag name with the type of the element stored in the generic.
*/
constructor (tagName : string ) ;
/**
* Returns the tag name.
*/
toString ( ) : string ;
}
}
declare module 'goog:goog.dom.TagName' {
import alias = ಠ_ಠ.clutz.goog.dom.TagName;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.dom.asserts {
/**
* Asserts that a given object is a HTMLAnchorElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not of type Location nor a subtype
* of Element.
* @param o The object whose type to assert.
*/
function assertIsHTMLAnchorElement (o : GlobalObject | null ) : HTMLAnchorElement ;
/**
* Asserts that a given object is a HTMLButtonElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
* @param o The object whose type to assert.
*/
function assertIsHTMLButtonElement (o : GlobalObject | null ) : HTMLButtonElement ;
/**
* Asserts that a given object is a HTMLEmbedElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
* @param o The object whose type to assert.
*/
function assertIsHTMLEmbedElement (o : GlobalObject | null ) : HTMLEmbedElement ;
/**
* Asserts that a given object is a HTMLFormElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
* @param o The object whose type to assert.
*/
function assertIsHTMLFormElement (o : GlobalObject | null ) : HTMLFormElement ;
/**
* Asserts that a given object is a HTMLFrameElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
* @param o The object whose type to assert.
*/
function assertIsHTMLFrameElement (o : GlobalObject | null ) : HTMLFrameElement ;
/**
* Asserts that a given object is a HTMLIFrameElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
* @param o The object whose type to assert.
*/
function assertIsHTMLIFrameElement (o : GlobalObject | null ) : HTMLIFrameElement ;
/**
* Asserts that a given object is a HTMLImageElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
* @param o The object whose type to assert.
*/
function assertIsHTMLImageElement (o : GlobalObject | null ) : HTMLImageElement ;
/**
* Asserts that a given object is a HTMLInputElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
* @param o The object whose type to assert.
*/
function assertIsHTMLInputElement (o : GlobalObject | null ) : HTMLInputElement ;
/**
* Asserts that a given object is a HTMLLinkElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
* @param o The object whose type to assert.
*/
function assertIsHTMLLinkElement (o : GlobalObject | null ) : HTMLLinkElement ;
/**
* Asserts that a given object is a HTMLObjectElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
* @param o The object whose type to assert.
*/
function assertIsHTMLObjectElement (o : GlobalObject | null ) : HTMLObjectElement ;
/**
* Asserts that a given object is a HTMLScriptElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
* @param o The object whose type to assert.
*/
function assertIsHTMLScriptElement (o : GlobalObject | null ) : HTMLScriptElement ;
/**
* Asserts that a given object is a Location.
*
* To permit this assertion to pass in the context of tests where DOM APIs might
* be mocked, also accepts any other type except for subtypes of {!Element}.
* This is to ensure that, for instance, HTMLLinkElement is not being used in
* place of a Location, since this could result in security bugs due to stronger
* contracts required for assignments to the href property of the latter.
* @param o The object whose type to assert.
*/
function assertIsLocation (o : GlobalObject | null ) : Location ;
}
declare module 'goog:goog.dom.asserts' {
import alias = ಠ_ಠ.clutz.goog.dom.asserts;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.dom.safe {
/**
* Writes known-safe HTML to a document.
* @param doc The document to be written to.
* @param html The known-safe HTML to assign.
*/
function documentWrite (doc : Document , html : ಠ_ಠ.clutz.goog.html.SafeHtml ) : void ;
/**
* Inserts known-safe HTML into a Node, at the specified position.
* @param node The node on which to call insertAdjacentHTML.
* @param position Position where to insert the HTML.
* @param html The known-safe HTML to insert.
*/
function insertAdjacentHtml (node : Node , position : ಠ_ಠ.clutz.goog.dom.safe.InsertAdjacentHtmlPosition , html : ಠ_ಠ.clutz.goog.html.SafeHtml ) : void ;
/**
* Safely opens a URL in a new window (via window.open).
*
* If url is of type goog.html.SafeUrl, its value is unwrapped and passed in to
* window.open. If url is of type string however, it is first sanitized
* using goog.html.SafeUrl.sanitize.
*
* Note that this function does not prevent leakages via the referer that is
* sent by window.open. It is advised to only use this to open 1st party URLs.
*
* Example usage:
* goog.dom.safe.openInWindow(url);
* which is a safe alternative to
* window.open(url);
* The latter can result in XSS vulnerabilities if redirectUrl is a
* user-/attacker-controlled value.
* @param url The URL to open.
* @param opt_openerWin Window of which to call the .open() method. Defaults to the global window.
* @param opt_name Name of the window to open in. Can be _top, etc as allowed by window.open().
* @param opt_specs Comma-separated list of specifications, same as in window.open().
* @param opt_replace Whether to replace the current entry in browser history, same as in window.open().
*/
function openInWindow (url : string | ಠ_ಠ.clutz.goog.html.SafeUrl , opt_openerWin ? : Window | null , opt_name ? : ಠ_ಠ.clutz.goog.string.Const , opt_specs ? : string , opt_replace ? : boolean ) : Window | null ;
/**
* Safely replaces the URL of a Location object.
*
* If url is of type goog.html.SafeUrl, its value is unwrapped and
* passed to Location#replace. If url is of type string however, it is
* first sanitized using goog.html.SafeUrl.sanitize.
*
* Example usage:
* goog.dom.safe.replaceHref(document.location, newUrl);
* which is a safe alternative to
* document.location.replace(newUrl);
* The latter can result in XSS vulnerabilities if newUrl is a
* user-/attacker-controlled value.
* @param loc The Location object which is to be replaced.
* @param url The URL to assign.
*/
function replaceLocation (loc : Location , url : string | ಠ_ಠ.clutz.goog.html.SafeUrl ) : void ;
/**
* Safely assigns a URL to an anchor element's href property.
*
* If url is of type goog.html.SafeUrl, its value is unwrapped and assigned to
* anchor's href property. If url is of type string however, it is first
* sanitized using goog.html.SafeUrl.sanitize.
*
* Example usage:
* goog.dom.safe.setAnchorHref(anchorEl, url);
* which is a safe alternative to
* anchorEl.href = url;
* The latter can result in XSS vulnerabilities if url is a
* user-/attacker-controlled value.
* @param anchor The anchor element whose href property is to be assigned to.
* @param url The URL to assign.
*/
function setAnchorHref (anchor : HTMLAnchorElement , url : string | ಠ_ಠ.clutz.goog.html.SafeUrl ) : void ;
/**
* Safely assigns a URL to a button element's formaction property.
*
* If url is of type goog.html.SafeUrl, its value is unwrapped and assigned to
* anchor's href property. If url is of type string however, it is first
* sanitized using goog.html.SafeUrl.sanitize.
*
* Example usage:
* goog.dom.safe.setButtonFormAction(buttonEl, url);
* which is a safe alternative to
* buttonEl.action = url;
* The latter can result in XSS vulnerabilities if url is a
* user-/attacker-controlled value.
* @param button The button element whose action property is to be assigned to.
* @param url The URL to assign.
*/
function setButtonFormAction (button : Element , url : string | ಠ_ಠ.clutz.goog.html.SafeUrl ) : void ;
/**
* Safely assigns a URL to an embed element's src property.
*
* Example usage:
* goog.dom.safe.setEmbedSrc(embedEl, url);
* which is a safe alternative to
* embedEl.src = url;
* The latter can result in loading untrusted code unless it is ensured that
* the URL refers to a trustworthy resource.
* @param embed The embed element whose src property is to be assigned to.
* @param url The URL to assign.
*/
function setEmbedSrc (embed : HTMLEmbedElement , url : ಠ_ಠ.clutz.goog.html.TrustedResourceUrl ) : void ;
/**
* Safely assigns a URL a form element's action property.
*
* If url is of type goog.html.SafeUrl, its value is unwrapped and assigned to
* anchor's href property. If url is of type string however, it is first
* sanitized using goog.html.SafeUrl.sanitize.
*
* Example usage:
* goog.dom.safe.setFormElementAction(formEl, url);
* which is a safe alternative to
* formEl.action = url;
* The latter can result in XSS vulnerabilities if url is a
* user-/attacker-controlled value.
* @param form The form element whose action property is to be assigned to.
* @param url The URL to assign.
*/
function setFormElementAction (form : Element , url : string | ಠ_ಠ.clutz.goog.html.SafeUrl ) : void ;
/**
* Safely assigns a URL to a frame element's src property.
*
* Example usage:
* goog.dom.safe.setFrameSrc(frameEl, url);
* which is a safe alternative to
* frameEl.src = url;
* The latter can result in loading untrusted code unless it is ensured that
* the URL refers to a trustworthy resource.
* @param frame The frame element whose src property is to be assigned to.
* @param url The URL to assign.
*/
function setFrameSrc (frame : HTMLFrameElement , url : ಠ_ಠ.clutz.goog.html.TrustedResourceUrl ) : void ;
/**
* Safely assigns a URL to an iframe element's src property.
*
* Example usage:
* goog.dom.safe.setIframeSrc(iframeEl, url);
* which is a safe alternative to
* iframeEl.src = url;
* The latter can result in loading untrusted code unless it is ensured that
* the URL refers to a trustworthy resource.
* @param iframe The iframe element whose src property is to be assigned to.
* @param url The URL to assign.
*/
function setIframeSrc (iframe : HTMLIFrameElement , url : ಠ_ಠ.clutz.goog.html.TrustedResourceUrl ) : void ;
/**
* Safely assigns HTML to an iframe element's srcdoc property.
*
* Example usage:
* goog.dom.safe.setIframeSrcdoc(iframeEl, safeHtml);
* which is a safe alternative to
* iframeEl.srcdoc = html;
* The latter can result in loading untrusted code.
* @param iframe The iframe element whose srcdoc property is to be assigned to.
* @param html The HTML to assign.
*/
function setIframeSrcdoc (iframe : HTMLIFrameElement , html : ಠ_ಠ.clutz.goog.html.SafeHtml ) : void ;
/**
* Safely assigns a URL to an image element's src property.
*
* If url is of type goog.html.SafeUrl, its value is unwrapped and assigned to
* image's src property. If url is of type string however, it is first
* sanitized using goog.html.SafeUrl.sanitize.
* @param imageElement The image element whose src property is to be assigned to.
* @param url The URL to assign.
*/
function setImageSrc (imageElement : HTMLImageElement , url : string | ಠ_ಠ.clutz.goog.html.SafeUrl ) : void ;
/**
* Assigns known-safe HTML to an element's innerHTML property.
* @param elem The element whose innerHTML is to be assigned to.
* @param html The known-safe HTML to assign.
*/
function setInnerHtml (elem : Element , html : ಠ_ಠ.clutz.goog.html.SafeHtml ) : void ;
/**
* Safely assigns a URL to an input element's formaction property.
*
* If url is of type goog.html.SafeUrl, its value is unwrapped and assigned to
* anchor's href property. If url is of type string however, it is first
* sanitized using goog.html.SafeUrl.sanitize.
*
* Example usage:
* goog.dom.safe.setInputFormAction(inputEl, url);
* which is a safe alternative to
* inputEl.action = url;
* The latter can result in XSS vulnerabilities if url is a
* user-/attacker-controlled value.
* @param input The input element whose action property is to be assigned to.
* @param url The URL to assign.
*/
function setInputFormAction (input : Element , url : string | ಠ_ಠ.clutz.goog.html.SafeUrl ) : void ;
/**
* Safely sets a link element's href and rel properties. Whether or not
* the URL assigned to href has to be a goog.html.TrustedResourceUrl
* depends on the value of the rel property. If rel contains "stylesheet"
* then a TrustedResourceUrl is required.
*
* Example usage:
* goog.dom.safe.setLinkHrefAndRel(linkEl, url, 'stylesheet');
* which is a safe alternative to
* linkEl.rel = 'stylesheet';
* linkEl.href = url;
* The latter can result in loading untrusted code unless it is ensured that
* the URL refers to a trustworthy resource.
* @param link The link element whose href property is to be assigned to.
* @param url The URL to assign to the href property. Must be a TrustedResourceUrl if the value assigned to rel contains "stylesheet". A string value is sanitized with goog.html.SafeUrl.sanitize.
* @param rel The value to assign to the rel property.
*/
function setLinkHrefAndRel (link : HTMLLinkElement , url : string | ಠ_ಠ.clutz.goog.html.SafeUrl | ಠ_ಠ.clutz.goog.html.TrustedResourceUrl , rel : string ) : void ;
/**
* Safely assigns a URL to a Location object's href property.
*
* If url is of type goog.html.SafeUrl, its value is unwrapped and assigned to
* loc's href property. If url is of type string however, it is first sanitized
* using goog.html.SafeUrl.sanitize.
*
* Example usage:
* goog.dom.safe.setLocationHref(document.location, redirectUrl);
* which is a safe alternative to
* document.location.href = redirectUrl;
* The latter can result in XSS vulnerabilities if redirectUrl is a
* user-/attacker-controlled value.
* @param loc The Location object whose href property is to be assigned to.
* @param url The URL to assign.
*/
function setLocationHref (loc : Location , url : string | ಠ_ಠ.clutz.goog.html.SafeUrl ) : void ;
/**
* Safely assigns a URL to an object element's data property.
*
* Example usage:
* goog.dom.safe.setObjectData(objectEl, url);
* which is a safe alternative to
* objectEl.data = url;
* The latter can result in loading untrusted code unless setit is ensured that
* the URL refers to a trustworthy resource.
* @param object The object element whose data property is to be assigned to.
* @param url The URL to assign.
*/
function setObjectData (object : HTMLObjectElement , url : ಠ_ಠ.clutz.goog.html.TrustedResourceUrl ) : void ;
/**
* Assigns known-safe HTML to an element's outerHTML property.
* @param elem The element whose outerHTML is to be assigned to.
* @param html The known-safe HTML to assign.
*/
function setOuterHtml (elem : Element , html : ಠ_ಠ.clutz.goog.html.SafeHtml ) : void ;
/**
* Safely assigns a value to a script element's content.
*
* Example usage:
* goog.dom.safe.setScriptContent(scriptEl, content);
* which is a safe alternative to
* scriptEl.text = content;
* The latter can result in executing untrusted code unless it is ensured that
* the code is loaded from a trustworthy resource.
* @param script The script element whose content is being set.
* @param content The content to assign.
*/
function setScriptContent (script : HTMLScriptElement , content : ಠ_ಠ.clutz.goog.html.SafeScript ) : void ;
/**
* Safely assigns a URL to a script element's src property.
*
* Example usage:
* goog.dom.safe.setScriptSrc(scriptEl, url);
* which is a safe alternative to
* scriptEl.src = url;
* The latter can result in loading untrusted code unless it is ensured that
* the URL refers to a trustworthy resource.
* @param script The script element whose src property is to be assigned to.
* @param url The URL to assign.
*/
function setScriptSrc (script : HTMLScriptElement , url : ಠ_ಠ.clutz.goog.html.TrustedResourceUrl ) : void ;
/**
* Sets the given element's style property to the contents of the provided
* SafeStyle object.
*/
function setStyle (elem : Element , style : ಠ_ಠ.clutz.goog.html.SafeStyle ) : void ;
}
declare module 'goog:goog.dom.safe' {
import alias = ಠ_ಠ.clutz.goog.dom.safe;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.dom.safe {
type InsertAdjacentHtmlPosition = string &{clutzEnumBrand: never} ;
var InsertAdjacentHtmlPosition : {
AFTERBEGIN : InsertAdjacentHtmlPosition ,
AFTEREND : InsertAdjacentHtmlPosition ,
BEFOREBEGIN : InsertAdjacentHtmlPosition ,
BEFOREEND : InsertAdjacentHtmlPosition ,
};
}
declare module 'goog:goog.dom.safe.InsertAdjacentHtmlPosition' {
import alias = ಠ_ಠ.clutz.goog.dom.safe.InsertAdjacentHtmlPosition;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.dom.tags {
/**
* Checks whether the tag is void (with no contents allowed and no legal end
* tag), for example 'br'.
* @param tagName The tag name in lower case.
*/
function isVoidTag (tagName : string ) : boolean ;
}
declare module 'goog:goog.dom.tags' {
import alias = ಠ_ಠ.clutz.goog.dom.tags;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.dom.vendor {
function getPrefixedEventType (eventType : string ) : string ;
function getPrefixedPropertyName (propertyName : string , opt_object ? : GlobalObject ) : string | null ;
/**
* Returns the JS vendor prefix used in CSS properties. Different vendors
* use different methods of changing the case of the property names.
*/
function getVendorJsPrefix ( ) : string | null ;
/**
* Returns the vendor prefix used in CSS properties.
*/
function getVendorPrefix ( ) : string | null ;
}
declare module 'goog:goog.dom.vendor' {
import alias = ಠ_ಠ.clutz.goog.dom.vendor;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.events {
var CAPTURE_SIMULATION_MODE : number ;
/**
* Dispatches an event (or event like object) and calls all listeners
* listening for events of this type. The type of the event is decided by the
* type property on the event object.
*
* If any of the listeners returns false OR calls preventDefault then this
* function will return false. If one of the capture listeners calls
* stopPropagation, then the bubble listeners won't fire.
* @param src The event target.
* @param e Event object.
*/
function dispatchEvent (src : ಠ_ಠ.clutz.goog.events.Listenable | null , e : string | GlobalObject | null ) : boolean ;
/**
* Provides a nice string showing the normalized event objects public members
* @param e Event Object.
*/
function expose (e : GlobalObject | null ) : string ;
/**
* Fires a listener with a set of arguments
* @param listener The listener object to call.
* @param eventObject The event object to pass to the listener.
*/
function fireListener (listener : ಠ_ಠ.clutz.goog.events.Listener | null , eventObject : GlobalObject | null ) : any ;
/**
* Fires an object's listeners of a particular type and phase
* @param obj Object whose listeners to call.
* @param type Event type.
* @param capture Which event phase.
* @param eventObject Event object to be passed to listener.
*/
function fireListeners (obj : GlobalObject | null , type : string | ಠ_ಠ.clutz.goog.events.EventId < any > , capture : boolean , eventObject : GlobalObject | null ) : boolean ;
/**
* Gets the goog.events.Listener for the event or null if no such listener is
* in use.
* @param src The target from which to get listeners.
* @param type The type of the event.
* @param listener The listener function to get.
* @param opt_capt In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
* @param opt_handler Element in whose scope to call the listener.
*/
function getListener < EVENTOBJ > (src : GlobalEventTarget | null | ಠ_ಠ.clutz.goog.events.Listenable , type : string | null | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > , listener : ( (a : EVENTOBJ ) => any ) | { handleEvent : (a : any ) => any } | null , opt_capt ? : boolean , opt_handler ? : GlobalObject | null ) : ಠ_ಠ.clutz.goog.events.ListenableKey | null ;
/**
* Gets the listeners for a given object, type and capture phase.
* @param obj Object to get listeners for.
* @param type Event type.
* @param capture Capture phase?.
*/
function getListeners (obj : GlobalObject | null , type : string | ಠ_ಠ.clutz.goog.events.EventId < any > , capture : boolean ) : ಠ_ಠ.clutz.goog.events.Listener [] | null ;
/**
* Helper function for returning a proxy function.
*/
function getProxy ( ) : Function ;
/**
* Gets the total number of listeners currently in the system.
*/
function getTotalListenerCount ( ) : number ;
/**
* Creates a unique event id.
* @param identifier The identifier.
*/
function getUniqueId (identifier : string ) : string ;
/**
* Returns whether an event target has any active listeners matching the
* specified signature. If either the type or capture parameters are
* unspecified, the function will match on the remaining criteria.
* @param obj Target to get listeners for.
* @param opt_type Event type.
* @param opt_capture Whether to check for capture or bubble-phase listeners.
*/
function hasListener (obj : GlobalEventTarget | null | ಠ_ಠ.clutz.goog.events.Listenable , opt_type ? : string | ಠ_ಠ.clutz.goog.events.EventId < any > , opt_capture ? : boolean ) : boolean ;
/**
* Adds an event listener for a specific event on a native event
* target (such as a DOM element) or an object that has implemented
* {@link goog.events.Listenable}. A listener can only be added once
* to an object and if it is added again the key for the listener is
* returned. Note that if the existing listener is a one-off listener
* (registered via listenOnce), it will no longer be a one-off
* listener after a call to listen().
* @param src The node to listen to events on.
* @param type Event type or array of event types.
* @param listener Callback method, or an object with a handleEvent function. WARNING: passing an Object is now softly deprecated.
* @param opt_handler Element in whose scope to call the listener.
*/
function listen < T , EVENTOBJ > (src : GlobalEventTarget | null | ಠ_ಠ.clutz.goog.events.Listenable , type : string | string [] | null | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > [] , listener : ( (a : EVENTOBJ ) => any ) | { handleEvent : (a : any ) => any } | null , opt_options ? : boolean | AddEventListenerOptions , opt_handler ? : T ) : number | ಠ_ಠ.clutz.goog.events.ListenableKey | null ;
/**
* Adds an event listener for a specific event on a native event
* target (such as a DOM element) or an object that has implemented
* {@link goog.events.Listenable}. After the event has fired the event
* listener is removed from the target.
*
* If an existing listener already exists, listenOnce will do
* nothing. In particular, if the listener was previously registered
* via listen(), listenOnce() will not turn the listener into a
* one-off listener. Similarly, if there is already an existing
* one-off listener, listenOnce does not modify the listeners (it is
* still a once listener).
* @param src The node to listen to events on.
* @param type Event type or array of event types.
* @param listener Callback method.
* @param opt_handler Element in whose scope to call the listener.
*/
function listenOnce < T , EVENTOBJ > (src : GlobalEventTarget | null | ಠ_ಠ.clutz.goog.events.Listenable , type : string | string [] | null | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > [] , listener : ( (a : EVENTOBJ ) => any ) | { handleEvent : (a : any ) => any } | null , opt_options ? : boolean | AddEventListenerOptions , opt_handler ? : T ) : number | ಠ_ಠ.clutz.goog.events.ListenableKey | null ;
/**
* Adds an event listener with a specific event wrapper on a DOM Node or an
* object that has implemented {@link goog.events.Listenable}. A listener can
* only be added once to an object.
* @param src The target to listen to events on.
* @param wrapper Event wrapper to use.
* @param listener Callback method, or an object with a handleEvent function.
* @param opt_capt Whether to fire in capture phase (defaults to false).
* @param opt_handler Element in whose scope to call the listener.
*/
function listenWithWrapper < T > (src : GlobalEventTarget | null | ಠ_ಠ.clutz.goog.events.Listenable , wrapper : any | null , listener : ( (a : any ) => any ) | { handleEvent : (a : any ) => any } | null , opt_capt ? : boolean , opt_handler ? : T ) : void ;
/**
* Installs exception protection for the browser event entry point using the
* given error handler.
* @param errorHandler Error handler with which to protect the entry point.
*/
function protectBrowserEventEntryPoint (errorHandler : any | null ) : void ;
/**
* Removes all listeners from an object. You can also optionally
* remove listeners of a particular type.
* @param obj Object to remove listeners from. Must be an EventTarget or a goog.events.Listenable.
* @param opt_type Type of event to remove. Default is all types.
*/
function removeAll (obj : GlobalObject | null | undefined , opt_type ? : string | ಠ_ಠ.clutz.goog.events.EventId < any > ) : number ;
/**
* Removes an event listener which was added with listen().
* @param src The target to stop listening to events on.
* @param type Event type or array of event types to unlisten to.
* @param listener The listener function to remove.
* @param opt_options whether the listener is fired during the capture or bubble phase of the event.
* @param opt_handler Element in whose scope to call the listener.
*/
function unlisten < EVENTOBJ > (src : GlobalEventTarget | null | ಠ_ಠ.clutz.goog.events.Listenable , type : string | string [] | null | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > [] , listener : ( (a : any ) => any ) | { handleEvent : (a : any ) => any } | null , opt_options ? : boolean | EventListenerOptions , opt_handler ? : GlobalObject | null ) : boolean | null ;
/**
* Removes an event listener which was added with listen() by the key
* returned by listen().
* @param key The key returned by listen() for this event listener.
*/
function unlistenByKey (key : number | ಠ_ಠ.clutz.goog.events.ListenableKey | null ) : boolean ;
/**
* Removes an event listener which was added with listenWithWrapper().
* @param src The target to stop listening to events on.
* @param wrapper Event wrapper to use.
* @param listener The listener function to remove.
* @param opt_capt In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
* @param opt_handler Element in whose scope to call the listener.
*/
function unlistenWithWrapper (src : GlobalEventTarget | null | ಠ_ಠ.clutz.goog.events.Listenable , wrapper : any | null , listener : ( (a : any ) => any ) | { handleEvent : (a : any ) => any } | null , opt_capt ? : boolean , opt_handler ? : GlobalObject | null ) : void ;
function wrapListener (listener : GlobalObject | null ) : Function ;
}
declare module 'goog:goog.events' {
import alias = ಠ_ಠ.clutz.goog.events;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.events {
/**
* Accepts a browser event object and creates a patched, cross browser event
* object.
* The content of this object will not be initialized if no event object is
* provided. If this is the case, init() needs to be invoked separately.
*/
class BrowserEvent extends BrowserEvent_Instance {
/**
* Static data for mapping mouse buttons.
*/
static IEButtonMap : number [] ;
/**
* Static data for mapping mouse buttons.
*/
static IE_BUTTON_MAP : number [] ;
/**
* Static data for mapping MSPointerEvent types to PointerEvent types.
*/
static IE_POINTER_TYPE_MAP : { [ key: number ]: ಠ_ಠ.clutz.goog.events.BrowserEvent.PointerType } ;
}
class BrowserEvent_Instance extends ಠ_ಠ.clutz.goog.events.Event_Instance {
/**
* Accepts a browser event object and creates a patched, cross browser event
* object.
* The content of this object will not be initialized if no event object is
* provided. If this is the case, init() needs to be invoked separately.
* @param opt_e Browser event object.
* @param opt_currentTarget Current target for event.
*/
constructor (opt_e ? : GlobalEvent | null , opt_currentTarget ? : GlobalEventTarget | null ) ;
/**
* Whether alt was pressed at time of event.
*/
altKey : boolean ;
/**
* Which mouse button was pressed.
*/
button : number ;
/**
* Keycode of key press.
*/
charCode : number ;
/**
* X-coordinate relative to the window.
*/
clientX : number ;
/**
* Y-coordinate relative to the window.
*/
clientY : number ;
/**
* Whether control was pressed at time of event.
*/
ctrlKey : boolean ;
/**
* Node that had the listener attached.
*/
currentTarget ? : Node | null ;
/**
* Key of key press.
*/
key : string ;
/**
* Keycode of key press.
*/
keyCode : number ;
/**
* Whether the meta key was pressed at time of event.
*/
metaKey : boolean ;
/**
* X-coordinate relative to target.
*/
offsetX : number ;
/**
* Y-coordinate relative to target.
*/
offsetY : number ;
/**
* Whether the default platform modifier key was pressed at time of event.
* (This is control for all platforms except Mac, where it's Meta.)
*/
platformModifierKey : boolean ;
pointerId : number ;
pointerType : string ;
/**
* For mouseover and mouseout events, the related object for the event.
*/
relatedTarget : Node | null ;
/**
* X-coordinate relative to the monitor.
*/
screenX : number ;
/**
* Y-coordinate relative to the monitor.
*/
screenY : number ;
/**
* Whether shift was pressed at time of event.
*/
shiftKey : boolean ;
/**
* History state object, only set for PopState events where it's a copy of the
* state object provided to pushState or replaceState.
*/
state : GlobalObject | null ;
/**
* Target that fired the event.
*/
target : Node | null ;
type : string ;
getBrowserEvent ( ) : GlobalEvent | null ;
/**
* Accepts a browser event object and creates a patched, cross browser event
* object.
* @param e Browser event object.
* @param opt_currentTarget Current target for event.
*/
init (e : GlobalEvent | null , opt_currentTarget ? : GlobalEventTarget | null ) : void ;
/**
* Tests to see which button was pressed during the event. This is really only
* useful in IE and Gecko browsers. And in IE, it's only useful for
* mousedown/mouseup events, because click only fires for the left mouse button.
*
* Safari 2 only reports the left button being clicked, and uses the value '1'
* instead of 0. Opera only reports a mousedown event for the middle button, and
* no mouse events for the right button. Opera has default behavior for left and
* middle click that can only be overridden via a configuration setting.
*
* There's a nice table of this mess at http://www.unixpapa.com/js/mouse.html.
* @param button The button to test for.
*/
isButton (button : ಠ_ಠ.clutz.goog.events.BrowserEvent.MouseButton ) : boolean ;
/**
* Whether this has an "action"-producing mouse button.
*
* By definition, this includes left-click on windows/linux, and left-click
* without the ctrl key on Macs.
*/
isMouseActionButton ( ) : boolean ;
preventDefault ( ) : void ;
stopPropagation ( ) : void ;
}
}
declare module 'goog:goog.events.BrowserEvent' {
import alias = ಠ_ಠ.clutz.goog.events.BrowserEvent;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.events.BrowserEvent {
/**
* Normalized button constants for the mouse.
*/
enum MouseButton {
LEFT ,
MIDDLE ,
RIGHT ,
}
}
declare module 'goog:goog.events.BrowserEvent.MouseButton' {
import alias = ಠ_ಠ.clutz.goog.events.BrowserEvent.MouseButton;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.events.BrowserEvent {
/**
* Normalized pointer type constants for pointer events.
*/
type PointerType = string &{clutzEnumBrand: never} ;
var PointerType : {
MOUSE : PointerType ,
PEN : PointerType ,
TOUCH : PointerType ,
};
}
declare module 'goog:goog.events.BrowserEvent.PointerType' {
import alias = ಠ_ಠ.clutz.goog.events.BrowserEvent.PointerType;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.events {
/**
* Enum of browser capabilities.
*/
type BrowserFeature = boolean &{clutzEnumBrand: never} ;
var BrowserFeature : {
HAS_HTML5_NETWORK_EVENT_SUPPORT : BrowserFeature ,
HAS_NAVIGATOR_ONLINE_PROPERTY : BrowserFeature ,
HAS_W3C_BUTTON : BrowserFeature ,
HAS_W3C_EVENT_SUPPORT : BrowserFeature ,
HTML5_NETWORK_EVENTS_FIRE_ON_BODY : BrowserFeature ,
MSPOINTER_EVENTS : BrowserFeature ,
PASSIVE_EVENTS : BrowserFeature ,
POINTER_EVENTS : BrowserFeature ,
SET_KEY_CODE_TO_PREVENT_DEFAULT : BrowserFeature ,
TOUCH_ENABLED : BrowserFeature ,
};
}
declare module 'goog:goog.events.BrowserFeature' {
import alias = ಠ_ಠ.clutz.goog.events.BrowserFeature;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.events {
enum CaptureSimulationMode {
OFF_AND_FAIL ,
OFF_AND_SILENT ,
ON ,
}
}
declare module 'goog:goog.events.CaptureSimulationMode' {
import alias = ಠ_ಠ.clutz.goog.events.CaptureSimulationMode;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.events {
/**
* A base class for event objects, so that they can support preventDefault and
* stopPropagation.
*/
class Event extends Event_Instance {
/**
* Prevents the default action. It is equivalent to
* {@code e.preventDefault()}, but can be used as the callback argument of
* {@link goog.events.listen} without declaring another function.
* @param e An event.
*/
static preventDefault (e : ಠ_ಠ.clutz.goog.events.Event ) : void ;
/**
* Stops the propagation of the event. It is equivalent to
* {@code e.stopPropagation()}, but can be used as the callback argument of
* {@link goog.events.listen} without declaring another function.
* @param e An event.
*/
static stopPropagation (e : ಠ_ಠ.clutz.goog.events.Event ) : void ;
}
class Event_Instance {
private noStructuralTyping_: any;
/**
* A base class for event objects, so that they can support preventDefault and
* stopPropagation.
* @param type Event Type.
* @param opt_target Reference to the object that is the target of this event. It has to implement the {@code EventTarget} interface declared at {@link http://developer.mozilla.org/en/DOM/EventTarget}.
*/
constructor (type : string | ಠ_ಠ.clutz.goog.events.EventId < any > , opt_target ? : GlobalObject | null ) ;
/**
* Object that had the listener attached.
*/
currentTarget ? : GlobalObject | null ;
/**
* Whether the default action has been prevented.
* This is a property to match the W3C specification at
* {@link http://www.w3.org/TR/DOM-Level-3-Events/
* #events-event-type-defaultPrevented}.
* Must be treated as read-only outside the class.
*/
defaultPrevented : boolean ;
/**
* Whether to cancel the event in internal capture/bubble processing for IE.
*/
propagationStopped_ : boolean ;
/**
* Return value for in internal capture/bubble processing for IE.
*/
returnValue_ : boolean ;
/**
* TODO(tbreisacher): The type should probably be
* EventTarget|goog.events.EventTarget.
*
* Target of the event.
*/
target ? : GlobalObject | null ;
/**
* Event type.
*/
type : string ;
/**
* Prevents the default action, for example a link redirecting to a url.
*/
preventDefault ( ) : void ;
/**
* Stops event propagation.
*/
stopPropagation ( ) : void ;
}
}
declare module 'goog:goog.events.Event' {
import alias = ಠ_ಠ.clutz.goog.events.Event;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.events {
/**
* A templated class that is used when registering for events. Typical usage:
*
* /** @type {goog.events.EventId<MyEventObj>} *\
* var myEventId = new goog.events.EventId(
* goog.events.getUniqueId(('someEvent'));
*
* // No need to cast or declare here since the compiler knows the
* // correct type of 'evt' (MyEventObj).
* something.listen(myEventId, function(evt) {});
*/
class EventId < T > extends EventId_Instance < T > {
}
class EventId_Instance < T > {
private noStructuralTyping_: any;
/**
* A templated class that is used when registering for events. Typical usage:
*
* /** @type {goog.events.EventId<MyEventObj>} *\
* var myEventId = new goog.events.EventId(
* goog.events.getUniqueId(('someEvent'));
*
* // No need to cast or declare here since the compiler knows the
* // correct type of 'evt' (MyEventObj).
* something.listen(myEventId, function(evt) {});
*/
constructor (eventId : string ) ;
id : string ;
toString ( ) : string ;
}
}
declare module 'goog:goog.events.EventId' {
import alias = ಠ_ಠ.clutz.goog.events.EventId;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.events {
/**
* A typedef for event like objects that are dispatchable via the
* goog.events.dispatchEvent function. strings are treated as the type for a
* goog.events.Event. Objects are treated as an extension of a new
* goog.events.Event with the type property of the object being used as the type
* of the Event.
*/
type EventLike = string | GlobalObject | null ;
}
declare module 'goog:goog.events.EventLike' {
import alias = ಠ_ಠ.clutz.goog.events.EventLike;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.events {
/**
* An implementation of {@code goog.events.Listenable} with full W3C
* EventTarget-like support (capture/bubble mechanism, stopping event
* propagation, preventing default actions).
*
* You may subclass this class to turn your class into a Listenable.
*
* Unless propagation is stopped, an event dispatched by an
* EventTarget will bubble to the parent returned by
* {@code getParentEventTarget}. To set the parent, call
* {@code setParentEventTarget}. Subclasses that don't support
* changing the parent can override the setter to throw an error.
*
* Example usage:
* <pre>
* var source = new goog.events.EventTarget();
* function handleEvent(e) {
* alert('Type: ' + e.type + '; Target: ' + e.target);
* }
* source.listen('foo', handleEvent);
* // Or: goog.events.listen(source, 'foo', handleEvent);
* ...
* source.dispatchEvent('foo'); // will call handleEvent
* ...
* source.unlisten('foo', handleEvent);
* // Or: goog.events.unlisten(source, 'foo', handleEvent);
* </pre>
*/
class EventTarget extends EventTarget_Instance {
}
class EventTarget_Instance extends ಠ_ಠ.clutz.goog.Disposable_Instance implements ಠ_ಠ.clutz.goog.events.Listenable {
/**
* Adds an event listener to the event target. The same handler can only be
* added once per the type. Even if you add the same handler multiple times
* using the same type then it will only be called once when the event is
* dispatched.
* @param type The type of the event to listen for
* @param handler The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
* @param opt_capture In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
* @param opt_handlerScope Object in whose scope to call the listener.
*/
addEventListener (type : string | ಠ_ಠ.clutz.goog.events.EventId < any > , handler : ( (a : any ) => any ) | { handleEvent : (a : any ) => any } | null , opt_capture ? : boolean , opt_handlerScope ? : GlobalObject | null ) : void ;
dispatchEvent (e : string | GlobalObject | null ) : boolean ;
/**
* Removes listeners from this object. Classes that extend EventTarget may
* need to override this method in order to remove references to DOM Elements
* and additional listeners.
*/
disposeInternal ( ) : void ;
fireListeners < EVENTOBJ > (type : string | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > , capture : boolean , eventObject : EVENTOBJ ) : boolean ;
getListener < SCOPE , EVENTOBJ > (type : string | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > , listener : (a : EVENTOBJ ) => boolean | undefined , capture : boolean , opt_listenerScope ? : SCOPE ) : ಠ_ಠ.clutz.goog.events.ListenableKey | null ;
getListeners < EVENTOBJ > (type : string | ಠ_ಠ.clutz.goog.events.EventId < any > , capture : boolean ) : ಠ_ಠ.clutz.goog.events.ListenableKey [] ;
/**
* Returns the parent of this event target to use for bubbling.
*/
getParentEventTarget ( ) : ಠ_ಠ.clutz.goog.events.EventTarget | null ;
hasListener < EVENTOBJ > (opt_type ? : string | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > , opt_capture ? : boolean ) : boolean ;
listen < SCOPE , EVENTOBJ > (type : string | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > , listener : (a : EVENTOBJ ) => boolean | undefined , opt_useCapture ? : boolean , opt_listenerScope ? : SCOPE ) : ಠ_ಠ.clutz.goog.events.ListenableKey ;
listenOnce < SCOPE , EVENTOBJ > (type : string | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > , listener : (a : EVENTOBJ ) => boolean | undefined , opt_useCapture ? : boolean , opt_listenerScope ? : SCOPE ) : ಠ_ಠ.clutz.goog.events.ListenableKey ;
removeAllListeners (opt_type ? : string ) : number ;
/**
* Removes an event listener from the event target. The handler must be the
* same object as the one added. If the handler has not been added then
* nothing is done.
* @param type The type of the event to listen for.
* @param handler The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
* @param opt_capture In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
* @param opt_handlerScope Object in whose scope to call the listener.
*/
removeEventListener (type : string , handler : ( (a : any ) => any ) | { handleEvent : (a : any ) => any } | null , opt_capture ? : boolean , opt_handlerScope ? : GlobalObject | null ) : void ;
/**
* Sets the parent of this event target to use for capture/bubble
* mechanism.
* @param parent Parent listenable (null if none).
*/
setParentEventTarget (parent : ಠ_ಠ.clutz.goog.events.EventTarget | null ) : void ;
/**
* Sets the target to be used for {@code event.target} when firing
* event. Mainly used for testing. For example, see
* {@code goog.testing.events.mixinListenable}.
* @param target The target.
*/
setTargetForTesting (target : GlobalObject ) : void ;
unlisten < SCOPE , EVENTOBJ > (type : string | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > , listener : (a : EVENTOBJ ) => boolean | undefined , opt_useCapture ? : boolean , opt_listenerScope ? : SCOPE ) : boolean ;
unlistenByKey (key : ಠ_ಠ.clutz.goog.events.ListenableKey ) : boolean ;
}
}
declare module 'goog:goog.events.EventTarget' {
import alias = ಠ_ಠ.clutz.goog.events.EventTarget;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.events {
/**
* Constants for event names.
*/
type EventType = string &{clutzEnumBrand: never} ;
var EventType : {
ABORT : EventType ,
ACTIVATE : EventType ,
AFTERPRINT : EventType ,
ANIMATIONEND : EventType ,
ANIMATIONITERATION : EventType ,
ANIMATIONSTART : EventType ,
BEFORECOPY : EventType ,
BEFORECUT : EventType ,
BEFOREINPUT : EventType ,
BEFOREPASTE : EventType ,
BEFOREPRINT : EventType ,
BEFOREUNLOAD : EventType ,
BLUR : EventType ,
CANPLAY : EventType ,
CANPLAYTHROUGH : EventType ,
CHANGE : EventType ,
CLICK : EventType ,
COMPOSITIONEND : EventType ,
COMPOSITIONSTART : EventType ,
COMPOSITIONUPDATE : EventType ,
CONNECT : EventType ,
CONSOLEMESSAGE : EventType ,
CONTEXTMENU : EventType ,
CONTROLLERCHANGE : EventType ,
COPY : EventType ,
CUT : EventType ,
DBLCLICK : EventType ,
DEACTIVATE : EventType ,
DEVICEMOTION : EventType ,
DEVICEORIENTATION : EventType ,
DOMATTRMODIFIED : EventType ,
DOMCHARACTERDATAMODIFIED : EventType ,
DOMCONTENTLOADED : EventType ,
DOMNODEINSERTED : EventType ,
DOMNODEINSERTEDINTODOCUMENT : EventType ,
DOMNODEREMOVED : EventType ,
DOMNODEREMOVEDFROMDOCUMENT : EventType ,
DOMSUBTREEMODIFIED : EventType ,
DRAG : EventType ,
DRAGEND : EventType ,
DRAGENTER : EventType ,
DRAGLEAVE : EventType ,
DRAGOVER : EventType ,
DRAGSTART : EventType ,
DROP : EventType ,
DURATIONCHANGE : EventType ,
EMPTIED : EventType ,
ENDED : EventType ,
ERROR : EventType ,
EXIT : EventType ,
FETCH : EventType ,
FOCUS : EventType ,
FOCUSIN : EventType ,
FOCUSOUT : EventType ,
FOREIGNFETCH : EventType ,
GOTPOINTERCAPTURE : EventType ,
HASHCHANGE : EventType ,
HELP : EventType ,
INPUT : EventType ,
INSTALL : EventType ,
KEYDOWN : EventType ,
KEYPRESS : EventType ,
KEYUP : EventType ,
LOAD : EventType ,
LOADABORT : EventType ,
LOADCOMMIT : EventType ,
LOADEDDATA : EventType ,
LOADEDMETADATA : EventType ,
LOADREDIRECT : EventType ,
LOADSTART : EventType ,
LOADSTOP : EventType ,
LOSECAPTURE : EventType ,
LOSTPOINTERCAPTURE : EventType ,
MESSAGE : EventType ,
MESSAGEERROR : EventType ,
MOUSEDOWN : EventType ,
MOUSEENTER : EventType ,
MOUSELEAVE : EventType ,
MOUSEMOVE : EventType ,
MOUSEOUT : EventType ,
MOUSEOVER : EventType ,
MOUSEUP : EventType ,
MSGESTURECHANGE : EventType ,
MSGESTUREEND : EventType ,
MSGESTUREHOLD : EventType ,
MSGESTURESTART : EventType ,
MSGESTURETAP : EventType ,
MSGOTPOINTERCAPTURE : EventType ,
MSINERTIASTART : EventType ,
MSLOSTPOINTERCAPTURE : EventType ,
MSPOINTERCANCEL : EventType ,
MSPOINTERDOWN : EventType ,
MSPOINTERENTER : EventType ,
MSPOINTERHOVER : EventType ,
MSPOINTERLEAVE : EventType ,
MSPOINTERMOVE : EventType ,
MSPOINTEROUT : EventType ,
MSPOINTEROVER : EventType ,
MSPOINTERUP : EventType ,
OFFLINE : EventType ,
ONLINE : EventType ,
ORIENTATIONCHANGE : EventType ,
PAGEHIDE : EventType ,
PAGESHOW : EventType ,
PASTE : EventType ,
PAUSE : EventType ,
PLAY : EventType ,
PLAYING : EventType ,
POINTERCANCEL : EventType ,
POINTERDOWN : EventType ,
POINTERENTER : EventType ,
POINTERLEAVE : EventType ,
POINTERMOVE : EventType ,
POINTEROUT : EventType ,
POINTEROVER : EventType ,
POINTERUP : EventType ,
POPSTATE : EventType ,
PROPERTYCHANGE : EventType ,
RATECHANGE : EventType ,
READYSTATECHANGE : EventType ,
RESET : EventType ,
RESIZE : EventType ,
RESPONSIVE : EventType ,
RIGHTCLICK : EventType ,
SCROLL : EventType ,
SEEKED : EventType ,
SEEKING : EventType ,
SELECT : EventType ,
SELECTIONCHANGE : EventType ,
SELECTSTART : EventType ,
SIZECHANGED : EventType ,
SOURCECLOSED : EventType ,
SOURCEENDED : EventType ,
SOURCEOPEN : EventType ,
STALLED : EventType ,
STATECHANGE : EventType ,
STORAGE : EventType ,
SUBMIT : EventType ,
SUSPEND : EventType ,
TEXT : EventType ,
TEXTINPUT : EventType ,
TIMEUPDATE : EventType ,
TOUCHCANCEL : EventType ,
TOUCHEND : EventType ,
TOUCHMOVE : EventType ,
TOUCHSTART : EventType ,
TRANSITIONEND : EventType ,
UNLOAD : EventType ,
UNRESPONSIVE : EventType ,
UPDATE : EventType ,
UPDATEEND : EventType ,
UPDATEFOUND : EventType ,
UPDATESTART : EventType ,
VISIBILITYCHANGE : EventType ,
VOLUMECHANGE : EventType ,
WAITING : EventType ,
WHEEL : EventType ,
};
}
declare module 'goog:goog.events.EventType' {
import alias = ಠ_ಠ.clutz.goog.events.EventType;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.events {
type Key = number | ಠ_ಠ.clutz.goog.events.ListenableKey | null ;
}
declare module 'goog:goog.events.Key' {
import alias = ಠ_ಠ.clutz.goog.events.Key;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.events {
/**
* A listenable interface. A listenable is an object with the ability
* to dispatch/broadcast events to "event listeners" registered via
* listen/listenOnce.
*
* The interface allows for an event propagation mechanism similar
* to one offered by native browser event targets, such as
* capture/bubble mechanism, stopping propagation, and preventing
* default actions. Capture/bubble mechanism depends on the ancestor
* tree constructed via {@code #getParentEventTarget}; this tree
* must be directed acyclic graph. The meaning of default action(s)
* in preventDefault is specific to a particular use case.
*
* Implementations that do not support capture/bubble or can not have
* a parent listenable can simply not implement any ability to set the
* parent listenable (and have {@code #getParentEventTarget} return
* null).
*
* Implementation of this class can be used with or independently from
* goog.events.
*
* Implementation must call {@code #addImplementation(implClass)}.
*/
interface Listenable {
/**
* Dispatches an event (or event like object) and calls all listeners
* listening for events of this type. The type of the event is decided by the
* type property on the event object.
*
* If any of the listeners returns false OR calls preventDefault then this
* function will return false. If one of the capture listeners calls
* stopPropagation, then the bubble listeners won't fire.
* @param e Event object.
*/
dispatchEvent (a : string | GlobalObject | null ) : boolean ;
/**
* Fires all registered listeners in this listenable for the given
* type and capture mode, passing them the given eventObject. This
* does not perform actual capture/bubble. Only implementors of the
* interface should be using this.
* @param type The type of the listeners to fire.
* @param capture The capture mode of the listeners to fire.
* @param eventObject The event object to fire.
*/
fireListeners < EVENTOBJ > (a : string | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > , b : boolean , c : EVENTOBJ ) : boolean ;
/**
* Gets the goog.events.ListenableKey for the event or null if no such
* listener is in use.
* @param type The name of the event without the 'on' prefix.
* @param listener The listener function to get.
* @param capture Whether the listener is a capturing listener.
* @param opt_listenerScope Object in whose scope to call the listener.
*/
getListener < SCOPE , EVENTOBJ > (a : string | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > , b : (a : EVENTOBJ ) => boolean | undefined , c : boolean , d ? : SCOPE ) : ಠ_ಠ.clutz.goog.events.ListenableKey | null ;
/**
* Gets all listeners in this listenable for the given type and
* capture mode.
* @param type The type of the listeners to fire.
* @param capture The capture mode of the listeners to fire.
*/
getListeners < EVENTOBJ > (a : string | ಠ_ಠ.clutz.goog.events.EventId < any > , b : boolean ) : ಠ_ಠ.clutz.goog.events.ListenableKey [] ;
/**
* Returns the parent of this event target to use for capture/bubble
* mechanism.
*
* NOTE(chrishenry): The name reflects the original implementation of
* custom event target ({@code goog.events.EventTarget}). We decided
* that changing the name is not worth it.
*/
getParentEventTarget ( ) : ಠ_ಠ.clutz.goog.events.Listenable | null ;
/**
* Whether there is any active listeners matching the specified
* signature. If either the type or capture parameters are
* unspecified, the function will match on the remaining criteria.
* @param opt_type Event type.
* @param opt_capture Whether to check for capture or bubble listeners.
*/
hasListener < EVENTOBJ > (a ? : string | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > , b ? : boolean ) : boolean ;
/**
* Adds an event listener. A listener can only be added once to an
* object and if it is added again the key for the listener is
* returned. Note that if the existing listener is a one-off listener
* (registered via listenOnce), it will no longer be a one-off
* listener after a call to listen().
* @param type The event type id.
* @param listener Callback method.
* @param opt_useCapture Whether to fire in capture phase (defaults to false).
* @param opt_listenerScope Object in whose scope to call the listener.
*/
listen < SCOPE , EVENTOBJ > (a : string | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > , b : (a : EVENTOBJ ) => boolean | undefined , c ? : boolean , d ? : SCOPE ) : ಠ_ಠ.clutz.goog.events.ListenableKey ;
/**
* Adds an event listener that is removed automatically after the
* listener fired once.
*
* If an existing listener already exists, listenOnce will do
* nothing. In particular, if the listener was previously registered
* via listen(), listenOnce() will not turn the listener into a
* one-off listener. Similarly, if there is already an existing
* one-off listener, listenOnce does not modify the listeners (it is
* still a once listener).
* @param type The event type id.
* @param listener Callback method.
* @param opt_useCapture Whether to fire in capture phase (defaults to false).
* @param opt_listenerScope Object in whose scope to call the listener.
*/
listenOnce < SCOPE , EVENTOBJ > (a : string | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > , b : (a : EVENTOBJ ) => boolean | undefined , c ? : boolean , d ? : SCOPE ) : ಠ_ಠ.clutz.goog.events.ListenableKey ;
/**
* Removes all listeners from this listenable. If type is specified,
* it will only remove listeners of the particular type. otherwise all
* registered listeners will be removed.
* @param opt_type Type of event to remove, default is to remove all types.
*/
removeAllListeners (a ? : string ) : number ;
/**
* Removes an event listener which was added with listen() or listenOnce().
* @param type The event type id.
* @param listener Callback method.
* @param opt_useCapture Whether to fire in capture phase (defaults to false).
* @param opt_listenerScope Object in whose scope to call the listener.
*/
unlisten < SCOPE , EVENTOBJ > (a : string | ಠ_ಠ.clutz.goog.events.EventId < EVENTOBJ > , b : (a : EVENTOBJ ) => boolean | undefined , c ? : boolean , d ? : SCOPE ) : boolean ;
/**
* Removes an event listener which was added with listen() by the key
* returned by listen().
* @param key The key returned by listen() or listenOnce().
*/
unlistenByKey (a : ಠ_ಠ.clutz.goog.events.ListenableKey ) : boolean ;
}
}
declare namespace ಠ_ಠ.clutz.goog.events.Listenable {
var IMPLEMENTED_BY_PROP : string ;
function addImplementation (cls : { new ( ...a : any [] ) : ಠ_ಠ.clutz.goog.events.Listenable } ) : void ;
function isImplementedBy (obj : GlobalObject | null ) : boolean ;
}
declare module 'goog:goog.events.Listenable' {
import alias = ಠ_ಠ.clutz.goog.events.Listenable;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.events {
/**
* An interface that describes a single registered listener.
*/
interface ListenableKey {
/**
* Whether the listener works on capture phase.
*/
capture : boolean ;
/**
* The 'this' object for the listener function's scope.
*/
handler ? : GlobalObject | null ;
/**
* A globally unique number to identify the key.
*/
key : number ;
/**
* The listener function.
*/
listener : ( (a : any ) => any ) | { handleEvent : (a : any ) => any } | null ;
/**
* The source event target.
*/
src : GlobalObject | null ;
/**
* The event type the listener is listening to.
*/
type : string ;
}
}
declare namespace ಠ_ಠ.clutz.goog.events.ListenableKey {
function reserveKey ( ) : number ;
}
declare module 'goog:goog.events.ListenableKey' {
import alias = ಠ_ಠ.clutz.goog.events.ListenableKey;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.events {
type ListenableType = GlobalEventTarget | null | ಠ_ಠ.clutz.goog.events.Listenable ;
}
declare module 'goog:goog.events.ListenableType' {
import alias = ಠ_ಠ.clutz.goog.events.ListenableType;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.events {
/**
* Simple class that stores information about a listener
*/
class Listener extends Listener_Instance {
static ENABLE_MONITORING : boolean ;
}
class Listener_Instance implements ಠ_ಠ.clutz.goog.events.ListenableKey {
private noStructuralTyping_: any;
/**
* Simple class that stores information about a listener
* @param listener Callback function.
* @param proxy Wrapper for the listener that patches the event.
* @param src Source object for the event.
* @param type Event type.
* @param capture Whether in capture or bubble phase.
* @param opt_handler Object in whose context to execute the callback.
*/
constructor (listener : (a : any ) => any , proxy : Function | null , src : GlobalEventTarget | null | ಠ_ಠ.clutz.goog.events.Listenable , type : string , capture : boolean , opt_handler ? : GlobalObject | null ) ;
/**
* Whether to remove the listener after it has been called.
*/
callOnce : boolean ;
/**
* Whether the listener is being called in the capture or bubble phase
*/
capture : boolean ;
/**
* Optional object whose context to execute the listener in
*/
handler ? : GlobalObject | null ;
/**
* The key of the listener.
*/
key : number ;
listener : ( (a : any ) => any ) | null ;
/**
* A wrapper over the original listener. This is used solely to
* handle native browser events (it is used to simulate the capture
* phase and to patch the event object).
*/
proxy : Function | null ;
/**
* Whether the listener has been removed.
*/
removed : boolean ;
/**
* Object or node that callback is listening to
*/
src : GlobalEventTarget | null | ಠ_ಠ.clutz.goog.events.Listenable ;
/**
* The event type.
*/
type : string ;
/**
* If monitoring the goog.events.Listener instances is enabled, stores the
* creation stack trace of the Disposable instance.
*/
creationStack : string ;
/**
* Marks this listener as removed. This also remove references held by
* this listener object (such as listener and event source).
*/
markAsRemoved ( ) : void ;
}
}
declare module 'goog:goog.events.Listener' {
import alias = ಠ_ಠ.clutz.goog.events.Listener;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.events {
/**
* Creates a new listener map.
*/
class ListenerMap extends ListenerMap_Instance {
}
class ListenerMap_Instance {
private noStructuralTyping_: any;
/**
* Creates a new listener map.
* @param src The src object.
*/
constructor (src : GlobalEventTarget | null | ಠ_ಠ.clutz.goog.events.Listenable ) ;
/**
* Maps of event type to an array of listeners.
*/
listeners : { [ key: string ]: ಠ_ಠ.clutz.goog.events.Listener [] } ;
src : GlobalEventTarget | null | ಠ_ಠ.clutz.goog.events.Listenable ;
/**
* Adds an event listener. A listener can only be added once to an
* object and if it is added again the key for the listener is
* returned.
*
* Note that a one-off listener will not change an existing listener,
* if any. On the other hand a normal listener will change existing
* one-off listener to become a normal listener.
* @param type The listener event type.
* @param listener This listener callback method.
* @param callOnce Whether the listener is a one-off listener.
* @param opt_useCapture The capture mode of the listener.
* @param opt_listenerScope Object in whose scope to call the listener.
*/
add (type : string | ಠ_ಠ.clutz.goog.events.EventId < any > , listener : Function , callOnce : boolean , opt_useCapture ? : boolean , opt_listenerScope ? : GlobalObject | null ) : ಠ_ಠ.clutz.goog.events.ListenableKey ;
/**
* Gets the goog.events.ListenableKey for the event or null if no such
* listener is in use.
* @param type The type of the listener to retrieve.
* @param listener The listener function to get.
* @param capture Whether the listener is a capturing listener.
* @param opt_listenerScope Object in whose scope to call the listener.
*/
getListener (type : string | ಠ_ಠ.clutz.goog.events.EventId < any > , listener : Function , capture : boolean , opt_listenerScope ? : GlobalObject | null ) : ಠ_ಠ.clutz.goog.events.ListenableKey | null ;
getListenerCount ( ) : number ;
/**
* Gets all listeners that match the given type and capture mode. The
* returned array is a copy (but the listener objects are not).
* @param type The type of the listeners to retrieve.
* @param capture The capture mode of the listeners to retrieve.
*/
getListeners (type : string | ಠ_ಠ.clutz.goog.events.EventId < any > , capture : boolean ) : ಠ_ಠ.clutz.goog.events.ListenableKey [] ;
getTypeCount ( ) : number ;
/**
* Whether there is a matching listener. If either the type or capture
* parameters are unspecified, the function will match on the
* remaining criteria.
* @param opt_type The type of the listener.
* @param opt_capture The capture mode of the listener.
*/
hasListener (opt_type ? : string | ಠ_ಠ.clutz.goog.events.EventId < any > , opt_capture ? : boolean ) : boolean ;
/**
* Removes a matching listener.
* @param type The listener event type.
* @param listener This listener callback method.
* @param opt_useCapture The capture mode of the listener.
* @param opt_listenerScope Object in whose scope to call the listener.
*/
remove (type : string | ಠ_ಠ.clutz.goog.events.EventId < any > , listener : Function , opt_useCapture ? : boolean , opt_listenerScope ? : GlobalObject | null ) : boolean ;
/**
* Removes all listeners from this map. If opt_type is provided, only
* listeners that match the given type are removed.
* @param opt_type Type of event to remove.
*/
removeAll (opt_type ? : string | ಠ_ಠ.clutz.goog.events.EventId < any > ) : number ;
/**
* Removes the given listener object.
* @param listener The listener to remove.
*/
removeByKey (listener : ಠ_ಠ.clutz.goog.events.ListenableKey ) : boolean ;
}
}
declare module 'goog:goog.events.ListenerMap' {
import alias = ಠ_ಠ.clutz.goog.events.ListenerMap;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.events {
/**
* Constants for pointer event names that fall back to corresponding mouse event
* names on unsupported platforms. These are intended to be drop-in replacements
* for corresponding values in {@code goog.events.EventType}.
*/
type PointerFallbackEventType = string &{clutzEnumBrand: never} ;
var PointerFallbackEventType : {
POINTERCANCEL : PointerFallbackEventType ,
POINTERDOWN : PointerFallbackEventType ,
POINTERENTER : PointerFallbackEventType ,
POINTERLEAVE : PointerFallbackEventType ,
POINTERMOVE : PointerFallbackEventType ,
POINTEROUT : PointerFallbackEventType ,
POINTEROVER : PointerFallbackEventType ,
POINTERUP : PointerFallbackEventType ,
};
}
declare module 'goog:goog.events.PointerFallbackEventType' {
import alias = ಠ_ಠ.clutz.goog.events.PointerFallbackEventType;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.fs.url {
type UrlObject_ = { createObjectURL : (a : Blob ) => string , revokeObjectURL : (a : string ) => void } ;
/**
* Checks whether this browser supports Object Urls. If not, calls to
* createObjectUrl and revokeObjectUrl will result in an error.
*/
function browserSupportsObjectUrls ( ) : boolean ;
/**
* Creates a blob URL for a blob object.
* Throws an error if the browser does not support Object Urls.
* @param blob The object for which to create the URL.
*/
function createObjectUrl (blob : Blob ) : string ;
/**
* Revokes a URL created by {@link goog.fs.url.createObjectUrl}.
* Throws an error if the browser does not support Object Urls.
* @param url The URL to revoke.
*/
function revokeObjectUrl (url : string ) : void ;
}
declare module 'goog:goog.fs.url' {
import alias = ಠ_ಠ.clutz.goog.fs.url;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.functions {
var CACHE_RETURN_VALUE : boolean ;
/**
* Always returns false.
*/
function FALSE ( ...a : any [] ) : boolean ;
/**
* Always returns NULL.
*/
function NULL ( ...a : any [] ) : null ;
/**
* Always returns true.
*/
function TRUE ( ...a : any [] ) : boolean ;
/**
* Creates a function that returns true if each of its components evaluates
* to true. The components are evaluated in order, and the evaluation will be
* short-circuited as soon as a function returns false.
* For example, (goog.functions.and(f, g))(x) is equivalent to f(x) && g(x).
* @param var_args A list of functions.
*/
function and ( ...var_args : ( Function | null | undefined ) [] ) : ( ...a : any [] ) => boolean ;
/**
* Gives a wrapper function that caches the return value of a parameterless
* function when first called.
*
* When called for the first time, the given function is called and its
* return value is cached (thus this is only appropriate for idempotent
* functions). Subsequent calls will return the cached return value. This
* allows the evaluation of expensive functions to be delayed until first used.
*
* To cache the return values of functions with parameters, see goog.memoize.
* @param fn A function to lazily evaluate.
*/
function cacheReturnValue < T > (fn : ( ) => T ) : ( ) => T ;
/**
* Creates the composition of the functions passed in.
* For example, (goog.functions.compose(f, g))(a) is equivalent to f(g(a)).
* @param fn The final function.
* @param var_args A list of functions.
*/
function compose < T > (fn : ( ...a : any [] ) => T , ...var_args : ( Function | null | undefined ) [] ) : ( ...a : any [] ) => T ;
/**
* Creates a function that always returns the same value.
* @param retValue The value to return.
*/
function constant < T > (retValue : T ) : ( ) => T ;
/**
* Generic factory function to construct an object given the constructor
* and the arguments. Intended to be bound to create object factories.
*
* Example:
*
* var factory = goog.partial(goog.functions.create, Class);
* @param constructor The constructor for the Object.
* @param var_args The arguments to be passed to the constructor.
*/
function create < T > (constructor : { new ( ...a : any [] ) : T } , ...var_args : any [] ) : T ;
/**
* Wraps a function to allow it to be called, at most, once per interval
* (specified in milliseconds). If the wrapper function is called N times within
* that interval, only the Nth call will go through.
*
* This is particularly useful for batching up repeated actions where the
* last action should win. This can be used, for example, for refreshing an
* autocomplete pop-up every so often rather than updating with every keystroke,
* since the final text typed by the user is the one that should produce the
* final autocomplete results. For more stateful debouncing with support for
* pausing, resuming, and canceling debounced actions, use {@code
* goog.async.Debouncer}.
* @param f Function to call.
* @param interval Interval over which to debounce. The function will only be called after the full interval has elapsed since the last call.
* @param opt_scope Object in whose scope to call the function.
*/
function debounce < SCOPE > (f : ( ...a : any [] ) => any , interval : number , opt_scope ? : SCOPE ) : ( ...a : any [] ) => void ;
/**
* Creates a function that returns whether its argument equals the given value.
*
* Example:
* var key = goog.object.findKey(obj, goog.functions.equalTo('needle'));
* @param value The value to compare to.
* @param opt_useLooseComparison Whether to use a loose (==) comparison rather than a strict (===) one. Defaults to false.
*/
function equalTo (value : any , opt_useLooseComparison ? : boolean ) : (a : any ) => boolean ;
/**
* Creates a function that always throws an error with the given message.
* @param message The error message.
*/
function error (message : string ) : Function ;
/**
* Creates a function that throws the given object.
* @param err An object to be thrown.
*/
function fail (err : any ) : Function ;
/**
* A simple function that returns the first argument of whatever is passed
* into it.
* @param opt_returnValue The single value that will be returned.
* @param var_args Optional trailing arguments. These are ignored.
*/
function identity < T > (opt_returnValue ? : T , ...var_args : any [] ) : T ;
/**
* Given a function, create a function that keeps opt_numArgs arguments and
* silently discards all additional arguments.
* @param f The original function.
* @param opt_numArgs The number of arguments to keep. Defaults to 0.
*/
function lock (f : Function | null , opt_numArgs ? : number ) : Function ;
/**
* Creates a function that returns the Boolean opposite of a provided function.
* For example, (goog.functions.not(f))(x) is equivalent to !f(x).
* @param f The original function.
*/
function not (f : Function ) : ( ...a : any [] ) => boolean ;
/**
* Creates a function that returns its nth argument.
* @param n The position of the return argument.
*/
function nth (n : number ) : Function ;
/**
* Wraps a function to allow it to be called, at most, once. All
* additional calls are no-ops.
*
* This is particularly useful for initialization functions
* that should be called, at most, once.
* @param f Function to call.
*/
function once (f : ( ) => any ) : ( ) => void ;
/**
* Creates a function that returns true if any of its components evaluates
* to true. The components are evaluated in order, and the evaluation will be
* short-circuited as soon as a function returns true.
* For example, (goog.functions.or(f, g))(x) is equivalent to f(x) || g(x).
* @param var_args A list of functions.
*/
function or ( ...var_args : ( Function | null | undefined ) [] ) : ( ...a : any [] ) => boolean ;
/**
* Like goog.partial(), except that arguments are added after arguments to the
* returned function.
*
* Usage:
* function f(arg1, arg2, arg3, arg4) { ... }
* var g = goog.functions.partialRight(f, arg3, arg4);
* g(arg1, arg2);
* @param fn A function to partially apply.
* @param var_args Additional arguments that are partially applied to fn at the end.
*/
function partialRight (fn : Function , ...var_args : any [] ) : Function ;
/**
* Wraps a function to allow it to be called, at most, once per interval
* (specified in milliseconds). If the wrapper function is called N times within
* that interval, only the 1st call will go through.
*
* This is particularly useful for limiting repeated user requests where the
* first request is guaranteed to have all the data required to perform the
* final action, so there's no need to wait until the end of the interval before
* sending the request out.
* @param f Function to call.
* @param interval Interval over which to rate-limit. The function will only be called once per interval, and ignored for the remainer of the interval.
* @param opt_scope Object in whose scope to call the function.
*/
function rateLimit < SCOPE > (f : ( ...a : any [] ) => any , interval : number , opt_scope ? : SCOPE ) : ( ...a : any [] ) => void ;
/**
* Creates a function that calls the functions passed in in sequence, and
* returns the value of the last function. For example,
* (goog.functions.sequence(f, g))(x) is equivalent to f(x),g(x).
* @param var_args A list of functions.
*/
function sequence ( ...var_args : ( Function | null | undefined ) [] ) : Function ;
/**
* Wraps a function to allow it to be called, at most, once per interval
* (specified in milliseconds). If the wrapper function is called N times in
* that interval, both the 1st and the Nth calls will go through.
*
* This is particularly useful for limiting repeated user requests where the
* the last action should win, but you also don't want to wait until the end of
* the interval before sending a request out, as it leads to a perception of
* slowness for the user.
* @param f Function to call.
* @param interval Interval over which to throttle. The function can only be called once per interval.
* @param opt_scope Object in whose scope to call the function.
*/
function throttle < SCOPE > (f : ( ...a : any [] ) => any , interval : number , opt_scope ? : SCOPE ) : ( ...a : any [] ) => void ;
/**
* Given a function, create a new function that swallows its return value
* and replaces it with a new one.
* @param f A function.
* @param retValue A new return value.
*/
function withReturnValue < T > (f : Function | null , retValue : T ) : ( ...a : any [] ) => T ;
}
declare module 'goog:goog.functions' {
import alias = ಠ_ಠ.clutz.goog.functions;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.html {
/**
* A string that is safe to use in HTML context in DOM APIs and HTML documents.
*
* A SafeHtml is a string-like object that carries the security type contract
* that its value as a string will not cause untrusted script execution when
* evaluated as HTML in a browser.
*
* Values of this type are guaranteed to be safe to use in HTML contexts,
* such as, assignment to the innerHTML DOM property, or interpolation into
* a HTML template in HTML PC_DATA context, in the sense that the use will not
* result in a Cross-Site-Scripting vulnerability.
*
* Instances of this type must be created via the factory methods
* ({@code goog.html.SafeHtml.create}, {@code goog.html.SafeHtml.htmlEscape}),
* etc and not by invoking its constructor. The constructor intentionally
* takes no parameters and the type is immutable; hence only a default instance
* corresponding to the empty string can be obtained via constructor invocation.
*/
class SafeHtml extends SafeHtml_Instance {
/**
* A SafeHtml instance corresponding to the <br> tag.
*/
static BR : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* A SafeHtml instance corresponding to the HTML doctype: "<!DOCTYPE html>".
*/
static DOCTYPE_HTML : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* A SafeHtml instance corresponding to the empty string.
*/
static EMPTY : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Checks if the user agent supports sandboxed iframes.
*/
static canUseSandboxIframe ( ) : boolean ;
static combineAttributes (fixedAttributes : { [ key: string ]: string | number | ಠ_ಠ.clutz.goog.string.TypedString | null | ಠ_ಠ.clutz.goog.html.SafeStyle.PropertyMap | undefined } , defaultAttributes : { [ key: string ]: string } , opt_attributes ? : { [ key: string ]: string | number | ಠ_ಠ.clutz.goog.string.TypedString | null | ಠ_ಠ.clutz.goog.html.SafeStyle.PropertyMap | undefined } | null ) : { [ key: string ]: string | number | ಠ_ಠ.clutz.goog.string.TypedString | null | ಠ_ಠ.clutz.goog.html.SafeStyle.PropertyMap | undefined } ;
/**
* Creates a new SafeHtml object by concatenating values.
* @param var_args Values to concatenate.
*/
static concat ( ...var_args : ( string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString | ( string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString ) [] | undefined ) [] ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Creates a new SafeHtml object with known directionality by concatenating the
* values.
* @param dir Directionality.
* @param var_args Elements of array arguments would be processed recursively.
*/
static concatWithDir (dir : ಠ_ಠ.clutz.goog.i18n.bidi.Dir , ...var_args : ( string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString | ( string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString ) [] | undefined ) [] ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Creates a SafeHtml content consisting of a tag with optional attributes and
* optional content.
*
* For convenience tag names and attribute names are accepted as regular
* strings, instead of goog.string.Const. Nevertheless, you should not pass
* user-controlled values to these parameters. Note that these parameters are
* syntactically validated at runtime, and invalid values will result in
* an exception.
*
* Example usage:
*
* goog.html.SafeHtml.create('br');
* goog.html.SafeHtml.create('div', {'class': 'a'});
* goog.html.SafeHtml.create('p', {}, 'a');
* goog.html.SafeHtml.create('p', {}, goog.html.SafeHtml.create('br'));
*
* goog.html.SafeHtml.create('span', {
* 'style': {'margin': '0'}
* });
*
* To guarantee SafeHtml's type contract is upheld there are restrictions on
* attribute values and tag names.
*
* - For attributes which contain script code (on*), a goog.string.Const is
* required.
* - For attributes which contain style (style), a goog.html.SafeStyle or a
* goog.html.SafeStyle.PropertyMap is required.
* - For attributes which are interpreted as URLs (e.g. src, href) a
* goog.html.SafeUrl, goog.string.Const or string is required. If a string
* is passed, it will be sanitized with SafeUrl.sanitize().
* - For tags which can load code or set security relevant page metadata,
* more specific goog.html.SafeHtml.create*() functions must be used. Tags
* which are not supported by this function are applet, base, embed, iframe,
* link, math, object, script, style, svg, and template.
* @param tagName The name of the tag. Only tag names consisting of [a-zA-Z0-9-] are allowed. Tag names documented above are disallowed.
* @param opt_attributes Mapping from attribute names to their values. Only attribute names consisting of [a-zA-Z0-9-] are allowed. Value of null or undefined causes the attribute to be omitted.
* @param opt_content Content to HTML-escape and put inside the tag. This must be empty for void tags like <br>. Array elements are concatenated.
*/
static create (tagName : ಠ_ಠ.clutz.goog.dom.TagName < any > | string , opt_attributes ? : { [ key: string ]: string | number | ಠ_ಠ.clutz.goog.string.TypedString | null | ಠ_ಠ.clutz.goog.html.SafeStyle.PropertyMap | undefined } | null , opt_content ? : string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString | ( string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString ) [] ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Creates a SafeHtml representing an iframe tag.
*
* This by default restricts the iframe as much as possible by setting the
* sandbox attribute to the empty string. If the iframe requires less
* restrictions, set the sandbox attribute as tight as possible, but do not rely
* on the sandbox as a security feature because it is not supported by older
* browsers. If a sandbox is essential to security (e.g. for third-party
* frames), use createSandboxIframe which checks for browser support.
* @param opt_src The value of the src attribute. If null or undefined src will not be set.
* @param opt_srcdoc The value of the srcdoc attribute. If null or undefined srcdoc will not be set.
* @param opt_attributes Mapping from attribute names to their values. Only attribute names consisting of [a-zA-Z0-9-] are allowed. Value of null or undefined causes the attribute to be omitted.
* @param opt_content Content to HTML-escape and put inside the tag. Array elements are concatenated.
*/
static createIframe (opt_src ? : ಠ_ಠ.clutz.goog.html.TrustedResourceUrl | null , opt_srcdoc ? : ಠ_ಠ.clutz.goog.html.SafeHtml | null , opt_attributes ? : { [ key: string ]: string | number | ಠ_ಠ.clutz.goog.string.TypedString | null | ಠ_ಠ.clutz.goog.html.SafeStyle.PropertyMap | undefined } | null , opt_content ? : string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString | ( string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString ) [] ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Creates a SafeHtml representing a meta refresh tag.
* @param url Where to redirect. If a string is passed, it will be sanitized with SafeUrl.sanitize().
* @param opt_secs Number of seconds until the page should be reloaded. Will be set to 0 if unspecified.
*/
static createMetaRefresh (url : ಠ_ಠ.clutz.goog.html.SafeUrl | string , opt_secs ? : number ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Package-internal utility method to create SafeHtml instances.
* @param html The string to initialize the SafeHtml object with.
* @param dir The directionality of the SafeHtml to be constructed, or null if unknown.
*/
static createSafeHtmlSecurityPrivateDoNotAccessOrElse (html : string , dir : ಠ_ಠ.clutz.goog.i18n.bidi.Dir | null ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Like create() but does not restrict which tags can be constructed.
* @param tagName Tag name. Set or validated by caller.
*/
static createSafeHtmlTagSecurityPrivateDoNotAccessOrElse (tagName : string , opt_attributes ? : { [ key: string ]: string | number | ಠ_ಠ.clutz.goog.string.TypedString | null | ಠ_ಠ.clutz.goog.html.SafeStyle.PropertyMap | undefined } | null , opt_content ? : string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString | ( string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString ) [] ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Creates a SafeHtml representing a sandboxed iframe tag.
*
* The sandbox attribute is enforced in its most restrictive mode, an empty
* string. Consequently, the security requirements for the src and srcdoc
* attributes are relaxed compared to SafeHtml.createIframe. This function
* will throw on browsers that do not support the sandbox attribute, as
* determined by SafeHtml.canUseSandboxIframe.
*
* The SafeHtml returned by this function can trigger downloads with no
* user interaction on Chrome (though only a few, further attempts are blocked).
* Firefox and IE will block all downloads from the sandbox.
* @param opt_src The value of the src attribute. If null or undefined src will not be set.
* @param opt_srcdoc The value of the srcdoc attribute. If null or undefined srcdoc will not be set. Will not be sanitized.
* @param opt_attributes Mapping from attribute names to their values. Only attribute names consisting of [a-zA-Z0-9-] are allowed. Value of null or undefined causes the attribute to be omitted.
* @param opt_content Content to HTML-escape and put inside the tag. Array elements are concatenated.
*/
static createSandboxIframe (opt_src ? : string | ಠ_ಠ.clutz.goog.html.SafeUrl , opt_srcdoc ? : string , opt_attributes ? : { [ key: string ]: string | number | ಠ_ಠ.clutz.goog.string.TypedString | null | ಠ_ಠ.clutz.goog.html.SafeStyle.PropertyMap | undefined } , opt_content ? : string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString | ( string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString ) [] ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Creates a SafeHtml representing a script tag. Does not allow the language,
* src, text or type attributes to be set.
* @param script Content to put inside the tag. Array elements are concatenated.
* @param opt_attributes Mapping from attribute names to their values. Only attribute names consisting of [a-zA-Z0-9-] are allowed. Value of null or undefined causes the attribute to be omitted.
*/
static createScript (script : ಠ_ಠ.clutz.goog.html.SafeScript | ಠ_ಠ.clutz.goog.html.SafeScript [] , opt_attributes ? : { [ key: string ]: string | number | ಠ_ಠ.clutz.goog.string.TypedString | null | ಠ_ಠ.clutz.goog.html.SafeStyle.PropertyMap | undefined } | null ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Creates a SafeHtml representing a script tag with the src attribute.
* @param src The value of the src attribute.
* @param opt_attributes Mapping from attribute names to their values. Only attribute names consisting of [a-zA-Z0-9-] are allowed. Value of null or undefined causes the attribute to be omitted.
*/
static createScriptSrc (src : ಠ_ಠ.clutz.goog.html.TrustedResourceUrl , opt_attributes ? : { [ key: string ]: string | number | ಠ_ಠ.clutz.goog.string.TypedString | null | ಠ_ಠ.clutz.goog.html.SafeStyle.PropertyMap | undefined } | null ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Creates a SafeHtml representing a style tag. The type attribute is set
* to "text/css".
* @param styleSheet Content to put inside the tag. Array elements are concatenated.
* @param opt_attributes Mapping from attribute names to their values. Only attribute names consisting of [a-zA-Z0-9-] are allowed. Value of null or undefined causes the attribute to be omitted.
*/
static createStyle (styleSheet : ಠ_ಠ.clutz.goog.html.SafeStyleSheet | ಠ_ಠ.clutz.goog.html.SafeStyleSheet [] , opt_attributes ? : { [ key: string ]: string | number | ಠ_ಠ.clutz.goog.string.TypedString | null | ಠ_ಠ.clutz.goog.html.SafeStyle.PropertyMap | undefined } | null ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Creates a SafeHtml content with known directionality consisting of a tag with
* optional attributes and optional content.
* @param dir Directionality.
*/
static createWithDir (dir : ಠ_ಠ.clutz.goog.i18n.bidi.Dir , tagName : string , opt_attributes ? : { [ key: string ]: string | number | ಠ_ಠ.clutz.goog.string.TypedString | null | ಠ_ಠ.clutz.goog.html.SafeStyle.PropertyMap | undefined } | null , opt_content ? : string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString | ( string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString ) [] ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Coerces an arbitrary object into a SafeHtml object.
*
* If {@code textOrHtml} is already of type {@code goog.html.SafeHtml}, the same
* object is returned. Otherwise, {@code textOrHtml} is coerced to string, and
* HTML-escaped. If {@code textOrHtml} is of a type that implements
* {@code goog.i18n.bidi.DirectionalString}, its directionality, if known, is
* preserved.
* @param textOrHtml The text or SafeHtml to coerce.
*/
static from (a : string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Returns HTML-escaped text as a SafeHtml object.
*
* If text is of a type that implements
* {@code goog.i18n.bidi.DirectionalString}, the directionality of the new
* {@code SafeHtml} object is set to {@code text}'s directionality, if known.
* Otherwise, the directionality of the resulting SafeHtml is unknown (i.e.,
* {@code null}).
* @param textOrHtml The text to escape. If the parameter is of type SafeHtml it is returned directly (no escaping is done).
*/
static htmlEscape (textOrHtml : string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Returns HTML-escaped text as a SafeHtml object, with newlines changed to
* &lt;br&gt;.
* @param textOrHtml The text to escape. If the parameter is of type SafeHtml it is returned directly (no escaping is done).
*/
static htmlEscapePreservingNewlines (textOrHtml : string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Returns HTML-escaped text as a SafeHtml object, with newlines changed to
* &lt;br&gt; and escaping whitespace to preserve spatial formatting. Character
* entity #160 is used to make it safer for XML.
* @param textOrHtml The text to escape. If the parameter is of type SafeHtml it is returned directly (no escaping is done).
*/
static htmlEscapePreservingNewlinesAndSpaces (textOrHtml : string | number | boolean | ಠ_ಠ.clutz.goog.string.TypedString | ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Creates a string with attributes to insert after tagName.
*/
static stringifyAttributes (tagName : string , opt_attributes ? : { [ key: string ]: string | number | ಠ_ಠ.clutz.goog.string.TypedString | null | ಠ_ಠ.clutz.goog.html.SafeStyle.PropertyMap | undefined } | null ) : string ;
/**
* Performs a runtime check that the provided object is indeed a SafeHtml
* object, and returns its value.
* @param safeHtml The object to extract from.
*/
static unwrap (safeHtml : ಠ_ಠ.clutz.goog.html.SafeHtml ) : string ;
/**
* Verifies if the tag name is valid and if it doesn't change the context.
* E.g. STRONG is fine but SCRIPT throws because it changes context. See
* goog.html.SafeHtml.create for an explanation of allowed tags.
*/
static verifyTagName (tagName : string ) : void ;
}
class SafeHtml_Instance implements ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString , ಠ_ಠ.clutz.goog.string.TypedString {
private noStructuralTyping_: any;
getDirection ( ) : ಠ_ಠ.clutz.goog.i18n.bidi.Dir | null ;
/**
* Returns this SafeHtml's value as string.
*
* IMPORTANT: In code where it is security relevant that an object's type is
* indeed {@code SafeHtml}, use {@code goog.html.SafeHtml.unwrap} instead of
* this method. If in doubt, assume that it's security relevant. In particular,
* note that goog.html functions which return a goog.html type do not guarantee
* that the returned instance is of the right type. For example:
*
* <pre>
* var fakeSafeHtml = new String('fake');
* fakeSafeHtml.__proto__ = goog.html.SafeHtml.prototype;
* var newSafeHtml = goog.html.SafeHtml.htmlEscape(fakeSafeHtml);
* // newSafeHtml is just an alias for fakeSafeHtml, it's passed through by
* // goog.html.SafeHtml.htmlEscape() as fakeSafeHtml
* // instanceof goog.html.SafeHtml.
* </pre>
*/
getTypedStringValue ( ) : string ;
implementsGoogI18nBidiDirectionalString : boolean ;
implementsGoogStringTypedString : boolean ;
/**
* Returns a debug string-representation of this value.
*
* To obtain the actual string value wrapped in a SafeHtml, use
* {@code goog.html.SafeHtml.unwrap}.
*/
toString ( ) : string ;
}
}
declare namespace ಠ_ಠ.clutz.goog.html.SafeHtml {
type AttributeValue = string | number | ಠ_ಠ.clutz.goog.string.TypedString | null | ಠ_ಠ.clutz.goog.html.SafeStyle.PropertyMap | undefined ;
}
declare module 'goog:goog.html.SafeHtml' {
import alias = ಠ_ಠ.clutz.goog.html.SafeHtml;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.html {
/**
* A string-like object which represents JavaScript code and that carries the
* security type contract that its value, as a string, will not cause execution
* of unconstrained attacker controlled code (XSS) when evaluated as JavaScript
* in a browser.
*
* Instances of this type must be created via the factory method
* {@code goog.html.SafeScript.fromConstant} and not by invoking its
* constructor. The constructor intentionally takes no parameters and the type
* is immutable; hence only a default instance corresponding to the empty string
* can be obtained via constructor invocation.
*
* A SafeScript's string representation can safely be interpolated as the
* content of a script element within HTML. The SafeScript string should not be
* escaped before interpolation.
*
* Note that the SafeScript might contain text that is attacker-controlled but
* that text should have been interpolated with appropriate escaping,
* sanitization and/or validation into the right location in the script, such
* that it is highly constrained in its effect (for example, it had to match a
* set of whitelisted words).
*
* A SafeScript can be constructed via security-reviewed unchecked
* conversions. In this case producers of SafeScript must ensure themselves that
* the SafeScript does not contain unsafe script. Note in particular that
* {@code &lt;} is dangerous, even when inside JavaScript strings, and so should
* always be forbidden or JavaScript escaped in user controlled input. For
* example, if {@code &lt;/script&gt;&lt;script&gt;evil&lt;/script&gt;"} were
* interpolated inside a JavaScript string, it would break out of the context
* of the original script element and {@code evil} would execute. Also note
* that within an HTML script (raw text) element, HTML character references,
* such as "&lt;" are not allowed. See
* http://www.w3.org/TR/html5/scripting-1.html#restrictions-for-contents-of-script-elements.
*/
class SafeScript extends SafeScript_Instance {
/**
* A SafeScript instance corresponding to the empty string.
*/
static EMPTY : ಠ_ಠ.clutz.goog.html.SafeScript ;
/**
* Package-internal utility method to create SafeScript instances.
* @param script The string to initialize the SafeScript object with.
*/
static createSafeScriptSecurityPrivateDoNotAccessOrElse (script : string ) : ಠ_ಠ.clutz.goog.html.SafeScript ;
/**
* Creates a SafeScript object from a compile-time constant string.
* @param script A compile-time-constant string from which to create a SafeScript.
*/
static fromConstant (script : ಠ_ಠ.clutz.goog.string.Const ) : ಠ_ಠ.clutz.goog.html.SafeScript ;
/**
* Performs a runtime check that the provided object is indeed a
* SafeScript object, and returns its value.
* @param safeScript The object to extract from.
*/
static unwrap (safeScript : ಠ_ಠ.clutz.goog.html.SafeScript ) : string ;
}
class SafeScript_Instance implements ಠ_ಠ.clutz.goog.string.TypedString {
private noStructuralTyping_: any;
/**
* Returns this SafeScript's value as a string.
*
* IMPORTANT: In code where it is security relevant that an object's type is
* indeed {@code SafeScript}, use {@code goog.html.SafeScript.unwrap} instead of
* this method. If in doubt, assume that it's security relevant. In particular,
* note that goog.html functions which return a goog.html type do not guarantee
* the returned instance is of the right type. For example:
*
* <pre>
* var fakeSafeHtml = new String('fake');
* fakeSafeHtml.__proto__ = goog.html.SafeHtml.prototype;
* var newSafeHtml = goog.html.SafeHtml.htmlEscape(fakeSafeHtml);
* // newSafeHtml is just an alias for fakeSafeHtml, it's passed through by
* // goog.html.SafeHtml.htmlEscape() as fakeSafeHtml
* // instanceof goog.html.SafeHtml.
* </pre>
*/
getTypedStringValue ( ) : string ;
implementsGoogStringTypedString : boolean ;
/**
* Returns a debug string-representation of this value.
*
* To obtain the actual string value wrapped in a SafeScript, use
* {@code goog.html.SafeScript.unwrap}.
*/
toString ( ) : string ;
}
}
declare module 'goog:goog.html.SafeScript' {
import alias = ಠ_ಠ.clutz.goog.html.SafeScript;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.html {
/**
* A string-like object which represents a sequence of CSS declarations
* ({@code propertyName1: propertyvalue1; propertyName2: propertyValue2; ...})
* and that carries the security type contract that its value, as a string,
* will not cause untrusted script execution (XSS) when evaluated as CSS in a
* browser.
*
* Instances of this type must be created via the factory methods
* ({@code goog.html.SafeStyle.create} or
* {@code goog.html.SafeStyle.fromConstant}) and not by invoking its
* constructor. The constructor intentionally takes no parameters and the type
* is immutable; hence only a default instance corresponding to the empty string
* can be obtained via constructor invocation.
*
* SafeStyle's string representation can safely be:
* <ul>
* <li>Interpolated as the content of a *quoted* HTML style attribute.
* However, the SafeStyle string *must be HTML-attribute-escaped* before
* interpolation.
* <li>Interpolated as the content of a {}-wrapped block within a stylesheet.
* '<' characters in the SafeStyle string *must be CSS-escaped* before
* interpolation. The SafeStyle string is also guaranteed not to be able
* to introduce new properties or elide existing ones.
* <li>Interpolated as the content of a {}-wrapped block within an HTML
* <style> element. '<' characters in the SafeStyle string
* * must be CSS-escaped* before interpolation.
* <li>Assigned to the style property of a DOM node. The SafeStyle string
* should not be escaped before being assigned to the property.
* </ul>
*
* A SafeStyle may never contain literal angle brackets. Otherwise, it could
* be unsafe to place a SafeStyle into a &lt;style&gt; tag (where it can't
* be HTML escaped). For example, if the SafeStyle containing
* "{@code font: 'foo &lt;style/&gt;&lt;script&gt;evil&lt;/script&gt;'}" were
* interpolated within a &lt;style&gt; tag, this would then break out of the
* style context into HTML.
*
* A SafeStyle may contain literal single or double quotes, and as such the
* entire style string must be escaped when used in a style attribute (if
* this were not the case, the string could contain a matching quote that
* would escape from the style attribute).
*
* Values of this type must be composable, i.e. for any two values
* {@code style1} and {@code style2} of this type,
* {@code goog.html.SafeStyle.unwrap(style1) +
* goog.html.SafeStyle.unwrap(style2)} must itself be a value that satisfies
* the SafeStyle type constraint. This requirement implies that for any value
* {@code style} of this type, {@code goog.html.SafeStyle.unwrap(style)} must
* not end in a "property value" or "property name" context. For example,
* a value of {@code background:url("} or {@code font-} would not satisfy the
* SafeStyle contract. This is because concatenating such strings with a
* second value that itself does not contain unsafe CSS can result in an
* overall string that does. For example, if {@code javascript:evil())"} is
* appended to {@code background:url("}, the resulting string may result in
* the execution of a malicious script.
*
* TODO(mlourenco): Consider whether we should implement UTF-8 interchange
* validity checks and blacklisting of newlines (including Unicode ones) and
* other whitespace characters (\t, \f). Document here if so and also update
* SafeStyle.fromConstant().
*
* The following example values comply with this type's contract:
* <ul>
* <li><pre>width: 1em;</pre>
* <li><pre>height:1em;</pre>
* <li><pre>width: 1em;height: 1em;</pre>
* <li><pre>background:url('http://url');</pre>
* </ul>
* In addition, the empty string is safe for use in a CSS attribute.
*
* The following example values do NOT comply with this type's contract:
* <ul>
* <li><pre>background: red</pre> (missing a trailing semi-colon)
* <li><pre>background:</pre> (missing a value and a trailing semi-colon)
* <li><pre>1em</pre> (missing an attribute name, which provides context for
* the value)
* </ul>
*/
class SafeStyle extends SafeStyle_Instance {
/**
* A SafeStyle instance corresponding to the empty string.
*/
static EMPTY : ಠ_ಠ.clutz.goog.html.SafeStyle ;
/**
* The innocuous string generated by goog.html.SafeStyle.create when passed
* an unsafe value.
*/
static INNOCUOUS_STRING : string ;
/**
* Creates a new SafeStyle object by concatenating the values.
* @param var_args SafeStyles to concatenate.
*/
static concat ( ...var_args : ( ಠ_ಠ.clutz.goog.html.SafeStyle | ಠ_ಠ.clutz.goog.html.SafeStyle [] | undefined ) [] ) : ಠ_ಠ.clutz.goog.html.SafeStyle ;
/**
* Creates a new SafeStyle object from the properties specified in the map.
* @param map Mapping of property names to their values, for example {'margin': '1px'}. Names must consist of [-_a-zA-Z0-9]. Values might be strings consisting of [-,.'"%_!# a-zA-Z0-9], where " and ' must be properly balanced. We also allow simple functions like rgb() and url() which sanitizes its contents. Other values must be wrapped in goog.string.Const. URLs might be passed as goog.html.SafeUrl which will be wrapped into url(""). We also support array whose elements are joined with ' '. Null value causes skipping the property.
*/
static create (map : ಠ_ಠ.clutz.goog.html.SafeStyle.PropertyMap ) : ಠ_ಠ.clutz.goog.html.SafeStyle ;
/**
* Package-internal utility method to create SafeStyle instances.
* @param style The string to initialize the SafeStyle object with.
*/
static createSafeStyleSecurityPrivateDoNotAccessOrElse (style : string ) : ಠ_ಠ.clutz.goog.html.SafeStyle ;
/**
* Creates a SafeStyle object from a compile-time constant string.
*
* {@code style} should be in the format
* {@code name: value; [name: value; ...]} and must not have any < or >
* characters in it. This is so that SafeStyle's contract is preserved,
* allowing the SafeStyle to correctly be interpreted as a sequence of CSS
* declarations and without affecting the syntactic structure of any
* surrounding CSS and HTML.
*
* This method performs basic sanity checks on the format of {@code style}
* but does not constrain the format of {@code name} and {@code value}, except
* for disallowing tag characters.
* @param style A compile-time-constant string from which to create a SafeStyle.
*/
static fromConstant (style : ಠ_ಠ.clutz.goog.string.Const ) : ಠ_ಠ.clutz.goog.html.SafeStyle ;
/**
* Performs a runtime check that the provided object is indeed a
* SafeStyle object, and returns its value.
* @param safeStyle The object to extract from.
*/
static unwrap (safeStyle : ಠ_ಠ.clutz.goog.html.SafeStyle ) : string ;
}
class SafeStyle_Instance implements ಠ_ಠ.clutz.goog.string.TypedString {
private noStructuralTyping_: any;
/**
* Returns this SafeStyle's value as a string.
*
* IMPORTANT: In code where it is security relevant that an object's type is
* indeed {@code SafeStyle}, use {@code goog.html.SafeStyle.unwrap} instead of
* this method. If in doubt, assume that it's security relevant. In particular,
* note that goog.html functions which return a goog.html type do not guarantee
* the returned instance is of the right type. For example:
*
* <pre>
* var fakeSafeHtml = new String('fake');
* fakeSafeHtml.__proto__ = goog.html.SafeHtml.prototype;
* var newSafeHtml = goog.html.SafeHtml.htmlEscape(fakeSafeHtml);
* // newSafeHtml is just an alias for fakeSafeHtml, it's passed through by
* // goog.html.SafeHtml.htmlEscape() as fakeSafeHtml
* // instanceof goog.html.SafeHtml.
* </pre>
*/
getTypedStringValue ( ) : string ;
implementsGoogStringTypedString : boolean ;
/**
* Returns a debug string-representation of this value.
*
* To obtain the actual string value wrapped in a SafeStyle, use
* {@code goog.html.SafeStyle.unwrap}.
*/
toString ( ) : string ;
}
}
declare namespace ಠ_ಠ.clutz.goog.html.SafeStyle {
type PropertyMap = { [ key: string ]: string | ಠ_ಠ.clutz.goog.string.Const | ಠ_ಠ.clutz.goog.html.SafeUrl | null | ( string | ಠ_ಠ.clutz.goog.string.Const | ಠ_ಠ.clutz.goog.html.SafeUrl ) [] } ;
type PropertyValue = string | ಠ_ಠ.clutz.goog.string.Const | ಠ_ಠ.clutz.goog.html.SafeUrl ;
}
declare module 'goog:goog.html.SafeStyle' {
import alias = ಠ_ಠ.clutz.goog.html.SafeStyle;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.html {
/**
* A string-like object which represents a CSS style sheet and that carries the
* security type contract that its value, as a string, will not cause untrusted
* script execution (XSS) when evaluated as CSS in a browser.
*
* Instances of this type must be created via the factory method
* {@code goog.html.SafeStyleSheet.fromConstant} and not by invoking its
* constructor. The constructor intentionally takes no parameters and the type
* is immutable; hence only a default instance corresponding to the empty string
* can be obtained via constructor invocation.
*
* A SafeStyleSheet's string representation can safely be interpolated as the
* content of a style element within HTML. The SafeStyleSheet string should
* not be escaped before interpolation.
*
* Values of this type must be composable, i.e. for any two values
* {@code styleSheet1} and {@code styleSheet2} of this type,
* {@code goog.html.SafeStyleSheet.unwrap(styleSheet1) +
* goog.html.SafeStyleSheet.unwrap(styleSheet2)} must itself be a value that
* satisfies the SafeStyleSheet type constraint. This requirement implies that
* for any value {@code styleSheet} of this type,
* {@code goog.html.SafeStyleSheet.unwrap(styleSheet1)} must end in
* "beginning of rule" context.
*
* A SafeStyleSheet can be constructed via security-reviewed unchecked
* conversions. In this case producers of SafeStyleSheet must ensure themselves
* that the SafeStyleSheet does not contain unsafe script. Note in particular
* that {@code &lt;} is dangerous, even when inside CSS strings, and so should
* always be forbidden or CSS-escaped in user controlled input. For example, if
* {@code &lt;/style&gt;&lt;script&gt;evil&lt;/script&gt;"} were interpolated
* inside a CSS string, it would break out of the context of the original
* style element and {@code evil} would execute. Also note that within an HTML
* style (raw text) element, HTML character references, such as
* {@code &amp;lt;}, are not allowed. See
*
* http://www.w3.org/TR/html5/scripting-1.html#restrictions-for-contents-of-script-elements
* (similar considerations apply to the style element).
*/
class SafeStyleSheet extends SafeStyleSheet_Instance {
/**
* A SafeStyleSheet instance corresponding to the empty string.
*/
static EMPTY : ಠ_ಠ.clutz.goog.html.SafeStyleSheet ;
/**
* Creates a new SafeStyleSheet object by concatenating values.
* @param var_args Values to concatenate.
*/
static concat ( ...var_args : ( ಠ_ಠ.clutz.goog.html.SafeStyleSheet | ಠ_ಠ.clutz.goog.html.SafeStyleSheet [] | undefined ) [] ) : ಠ_ಠ.clutz.goog.html.SafeStyleSheet ;
/**
* Creates a style sheet consisting of one selector and one style definition.
* Use {@link goog.html.SafeStyleSheet.concat} to create longer style sheets.
* This function doesn't support @import, @media and similar constructs.
* @param selector CSS selector, e.g. '#id' or 'tag .class, #id'. We support CSS3 selectors: https://w3.org/TR/css3-selectors/#selectors.
* @param style Style definition associated with the selector.
*/
static createRule (selector : string , style : ಠ_ಠ.clutz.goog.html.SafeStyle.PropertyMap | ಠ_ಠ.clutz.goog.html.SafeStyle ) : ಠ_ಠ.clutz.goog.html.SafeStyleSheet ;
/**
* Package-internal utility method to create SafeStyleSheet instances.
* @param styleSheet The string to initialize the SafeStyleSheet object with.
*/
static createSafeStyleSheetSecurityPrivateDoNotAccessOrElse (styleSheet : string ) : ಠ_ಠ.clutz.goog.html.SafeStyleSheet ;
/**
* Creates a SafeStyleSheet object from a compile-time constant string.
*
* {@code styleSheet} must not have any &lt; characters in it, so that
* the syntactic structure of the surrounding HTML is not affected.
* @param styleSheet A compile-time-constant string from which to create a SafeStyleSheet.
*/
static fromConstant (styleSheet : ಠ_ಠ.clutz.goog.string.Const ) : ಠ_ಠ.clutz.goog.html.SafeStyleSheet ;
/**
* Performs a runtime check that the provided object is indeed a
* SafeStyleSheet object, and returns its value.
* @param safeStyleSheet The object to extract from.
*/
static unwrap (safeStyleSheet : ಠ_ಠ.clutz.goog.html.SafeStyleSheet ) : string ;
}
class SafeStyleSheet_Instance implements ಠ_ಠ.clutz.goog.string.TypedString {
private noStructuralTyping_: any;
/**
* Returns this SafeStyleSheet's value as a string.
*
* IMPORTANT: In code where it is security relevant that an object's type is
* indeed {@code SafeStyleSheet}, use {@code goog.html.SafeStyleSheet.unwrap}
* instead of this method. If in doubt, assume that it's security relevant. In
* particular, note that goog.html functions which return a goog.html type do
* not guarantee the returned instance is of the right type. For example:
*
* <pre>
* var fakeSafeHtml = new String('fake');
* fakeSafeHtml.__proto__ = goog.html.SafeHtml.prototype;
* var newSafeHtml = goog.html.SafeHtml.htmlEscape(fakeSafeHtml);
* // newSafeHtml is just an alias for fakeSafeHtml, it's passed through by
* // goog.html.SafeHtml.htmlEscape() as fakeSafeHtml
* // instanceof goog.html.SafeHtml.
* </pre>
*/
getTypedStringValue ( ) : string ;
implementsGoogStringTypedString : boolean ;
/**
* Returns a debug string-representation of this value.
*
* To obtain the actual string value wrapped in a SafeStyleSheet, use
* {@code goog.html.SafeStyleSheet.unwrap}.
*/
toString ( ) : string ;
}
}
declare module 'goog:goog.html.SafeStyleSheet' {
import alias = ಠ_ಠ.clutz.goog.html.SafeStyleSheet;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.html {
/**
* A string that is safe to use in URL context in DOM APIs and HTML documents.
*
* A SafeUrl is a string-like object that carries the security type contract
* that its value as a string will not cause untrusted script execution
* when evaluated as a hyperlink URL in a browser.
*
* Values of this type are guaranteed to be safe to use in URL/hyperlink
* contexts, such as assignment to URL-valued DOM properties, in the sense that
* the use will not result in a Cross-Site-Scripting vulnerability. Similarly,
* SafeUrls can be interpolated into the URL context of an HTML template (e.g.,
* inside a href attribute). However, appropriate HTML-escaping must still be
* applied.
*
* Note that, as documented in {@code goog.html.SafeUrl.unwrap}, this type's
* contract does not guarantee that instances are safe to interpolate into HTML
* without appropriate escaping.
*
* Note also that this type's contract does not imply any guarantees regarding
* the resource the URL refers to. In particular, SafeUrls are <b>not</b>
* safe to use in a context where the referred-to resource is interpreted as
* trusted code, e.g., as the src of a script tag.
*
* Instances of this type must be created via the factory methods
* ({@code goog.html.SafeUrl.fromConstant}, {@code goog.html.SafeUrl.sanitize}),
* etc and not by invoking its constructor. The constructor intentionally
* takes no parameters and the type is immutable; hence only a default instance
* corresponding to the empty string can be obtained via constructor invocation.
*/
class SafeUrl extends SafeUrl_Instance {
/**
* A SafeUrl corresponding to the special about:blank url.
*/
static ABOUT_BLANK : ಠ_ಠ.clutz.goog.html.SafeUrl ;
/**
* The innocuous string generated by goog.html.SafeUrl.sanitize when passed
* an unsafe URL.
*
* about:invalid is registered in
* http://www.w3.org/TR/css3-values/#about-invalid.
* http://tools.ietf.org/html/rfc6694#section-2.2.1 permits about URLs to
* contain a fragment, which is not to be considered when determining if an
* about URL is well-known.
*
* Using about:invalid seems preferable to using a fixed data URL, since
* browsers might choose to not report CSP violations on it, as legitimate
* CSS function calls to attr() can result in this URL being produced. It is
* also a standard URL which matches exactly the semantics we need:
* "The about:invalid URI references a non-existent document with a generic
* error condition. It can be used when a URI is necessary, but the default
* value shouldn't be resolveable as any type of document".
*/
static INNOCUOUS_STRING : string ;
/**
* Package-internal utility method to create SafeUrl instances.
* @param url The string to initialize the SafeUrl object with.
*/
static createSafeUrlSecurityPrivateDoNotAccessOrElse (url : string ) : ಠ_ಠ.clutz.goog.html.SafeUrl ;
/**
* Creates a SafeUrl wrapping a blob URL for the given {@code blob}.
*
* The blob URL is created with {@code URL.createObjectURL}. If the MIME type
* for {@code blob} is not of a known safe audio, image or video MIME type,
* then the SafeUrl will wrap {@link #INNOCUOUS_STRING}.
*/
static fromBlob (blob : Blob ) : ಠ_ಠ.clutz.goog.html.SafeUrl ;
/**
* Creates a SafeUrl object from a compile-time constant string.
*
* Compile-time constant strings are inherently program-controlled and hence
* trusted.
* @param url A compile-time-constant string from which to create a SafeUrl.
*/
static fromConstant (url : ಠ_ಠ.clutz.goog.string.Const ) : ಠ_ಠ.clutz.goog.html.SafeUrl ;
/**
* Creates a SafeUrl wrapping a data: URL, after validating it matches a
* known-safe audio, image or video MIME type.
* @param dataUrl A valid base64 data URL with one of the whitelisted audio, image or video MIME types.
*/
static fromDataUrl (dataUrl : string ) : ಠ_ಠ.clutz.goog.html.SafeUrl ;
/**
* Creates a SafeUrl wrapping a tel: URL.
* @param telUrl A tel URL.
*/
static fromTelUrl (telUrl : string ) : ಠ_ಠ.clutz.goog.html.SafeUrl ;
/**
* Creates a SafeUrl from TrustedResourceUrl. This is safe because
* TrustedResourceUrl is more tightly restricted than SafeUrl.
*/
static fromTrustedResourceUrl (trustedResourceUrl : ಠ_ಠ.clutz.goog.html.TrustedResourceUrl ) : ಠ_ಠ.clutz.goog.html.SafeUrl ;
/**
* Creates a SafeUrl object from {@code url}. If {@code url} is a
* goog.html.SafeUrl then it is simply returned. Otherwise the input string is
* validated to match a pattern of commonly used safe URLs.
*
* {@code url} may be a URL with the http, https, mailto or ftp scheme,
* or a relative URL (i.e., a URL without a scheme; specifically, a
* scheme-relative, absolute-path-relative, or path-relative URL).
* @param url The URL to validate.
*/
static sanitize (url : string | ಠ_ಠ.clutz.goog.string.TypedString ) : ಠ_ಠ.clutz.goog.html.SafeUrl ;
/**
* Creates a SafeUrl object from {@code url}. If {@code url} is a
* goog.html.SafeUrl then it is simply returned. Otherwise the input string is
* validated to match a pattern of commonly used safe URLs.
*
* {@code url} may be a URL with the http, https, mailto or ftp scheme,
* or a relative URL (i.e., a URL without a scheme; specifically, a
* scheme-relative, absolute-path-relative, or path-relative URL).
*
* This function asserts (using goog.asserts) that the URL matches this pattern.
* If it does not, in addition to failing the assert, an innocous URL will be
* returned.
* @param url The URL to validate.
*/
static sanitizeAssertUnchanged (url : string | ಠ_ಠ.clutz.goog.string.TypedString ) : ಠ_ಠ.clutz.goog.html.SafeUrl ;
/**
* Performs a runtime check that the provided object is indeed a SafeUrl
* object, and returns its value.
*
* IMPORTANT: The guarantees of the SafeUrl type contract only extend to the
* behavior of browsers when interpreting URLs. Values of SafeUrl objects MUST
* be appropriately escaped before embedding in a HTML document. Note that the
* required escaping is context-sensitive (e.g. a different escaping is
* required for embedding a URL in a style property within a style
* attribute, as opposed to embedding in a href attribute).
* @param safeUrl The object to extract from.
*/
static unwrap (safeUrl : ಠ_ಠ.clutz.goog.html.SafeUrl ) : string ;
}
class SafeUrl_Instance implements ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString , ಠ_ಠ.clutz.goog.string.TypedString {
private noStructuralTyping_: any;
/**
* Returns this URLs directionality, which is always {@code LTR}.
*/
getDirection ( ) : ಠ_ಠ.clutz.goog.i18n.bidi.Dir | null ;
/**
* Returns this SafeUrl's value a string.
*
* IMPORTANT: In code where it is security relevant that an object's type is
* indeed {@code SafeUrl}, use {@code goog.html.SafeUrl.unwrap} instead of this
* method. If in doubt, assume that it's security relevant. In particular, note
* that goog.html functions which return a goog.html type do not guarantee that
* the returned instance is of the right type. For example:
*
* <pre>
* var fakeSafeHtml = new String('fake');
* fakeSafeHtml.__proto__ = goog.html.SafeHtml.prototype;
* var newSafeHtml = goog.html.SafeHtml.htmlEscape(fakeSafeHtml);
* // newSafeHtml is just an alias for fakeSafeHtml, it's passed through by
* // goog.html.SafeHtml.htmlEscape() as fakeSafeHtml instanceof
* // goog.html.SafeHtml.
* </pre>
*
* IMPORTANT: The guarantees of the SafeUrl type contract only extend to the
* behavior of browsers when interpreting URLs. Values of SafeUrl objects MUST
* be appropriately escaped before embedding in a HTML document. Note that the
* required escaping is context-sensitive (e.g. a different escaping is
* required for embedding a URL in a style property within a style
* attribute, as opposed to embedding in a href attribute).
*/
getTypedStringValue ( ) : string ;
implementsGoogI18nBidiDirectionalString : boolean ;
implementsGoogStringTypedString : boolean ;
/**
* Returns a debug string-representation of this value.
*
* To obtain the actual string value wrapped in a SafeUrl, use
* {@code goog.html.SafeUrl.unwrap}.
*/
toString ( ) : string ;
}
}
declare module 'goog:goog.html.SafeUrl' {
import alias = ಠ_ಠ.clutz.goog.html.SafeUrl;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.html {
/**
* A URL which is under application control and from which script, CSS, and
* other resources that represent executable code, can be fetched.
*
* Given that the URL can only be constructed from strings under application
* control and is used to load resources, bugs resulting in a malformed URL
* should not have a security impact and are likely to be easily detectable
* during testing. Given the wide number of non-RFC compliant URLs in use,
* stricter validation could prevent some applications from being able to use
* this type.
*
* Instances of this type must be created via the factory method,
* ({@code fromConstant}, {@code fromConstants}, {@code format} or {@code
* formatWithParams}), and not by invoking its constructor. The constructor
* intentionally takes no parameters and the type is immutable; hence only a
* default instance corresponding to the empty string can be obtained via
* constructor invocation.
*/
class TrustedResourceUrl extends TrustedResourceUrl_Instance {
/**
* Package-internal utility method to create TrustedResourceUrl instances.
* @param url The string to initialize the TrustedResourceUrl object with.
*/
static createTrustedResourceUrlSecurityPrivateDoNotAccessOrElse (url : string ) : ಠ_ಠ.clutz.goog.html.TrustedResourceUrl ;
/**
* Creates a TrustedResourceUrl from a format string and arguments.
*
* The arguments for interpolation into the format string map labels to values.
* Values of type `goog.string.Const` are interpolated without modifcation.
* Values of other types are cast to string and encoded with
* encodeURIComponent.
*
* `%{<label>}` markers are used in the format string to indicate locations
* to be interpolated with the valued mapped to the given label. `<label>`
* must contain only alphanumeric and `_` characters.
*
* The format string must start with one of the following:
* - `https://<origin>/`
* - `//<origin>/`
* - `/<pathStart>`
* - `about:blank`
*
* `<origin>` must contain only alphanumeric or any of the following: `-.:[]`.
* `<pathStart>` is any character except `/` and `\`.
*
* Example usage:
*
* var url = goog.html.TrustedResourceUrl.format(goog.string.Const.from(
* 'https://www.google.com/search?q=%{query}'), {'query': searchTerm});
*
* var url = goog.html.TrustedResourceUrl.format(goog.string.Const.from(
* '//www.youtube.com/v/%{videoId}?hl=en&fs=1%{autoplay}'), {
* 'videoId': videoId,
* 'autoplay': opt_autoplay ?
* goog.string.Const.from('&autoplay=1') : goog.string.Const.EMPTY
* });
*
* While this function can be used to create a TrustedResourceUrl from only
* constants, fromConstant() and fromConstants() are generally preferable for
* that purpose.
* @param format The format string.
* @param args Mapping of labels to values to be interpolated into the format string. goog.string.Const values are interpolated without encoding.
*/
static format (format : ಠ_ಠ.clutz.goog.string.Const , args : { [ key: string ]: string | number | ಠ_ಠ.clutz.goog.string.Const } ) : ಠ_ಠ.clutz.goog.html.TrustedResourceUrl ;
/**
* Formats the URL same as TrustedResourceUrl.format and then adds extra URL
* parameters.
*
* Example usage:
*
* // Creates '//www.youtube.com/v/abc?autoplay=1' for videoId='abc' and
* // opt_autoplay=1. Creates '//www.youtube.com/v/abc' for videoId='abc'
* // and opt_autoplay=undefined.
* var url = goog.html.TrustedResourceUrl.formatWithParams(
* goog.string.Const.from('//www.youtube.com/v/%{videoId}'),
* {'videoId': videoId},
* {'autoplay': opt_autoplay});
* @param format The format string.
* @param args Mapping of labels to values to be interpolated into the format string. goog.string.Const values are interpolated without encoding.
* @param params Parameters to add to URL. Parameters with value {@code null} or {@code undefined} are skipped. Both keys and values are encoded. If the value is an array then the same parameter is added for every element in the array. Note that JavaScript doesn't guarantee the order of values in an object which might result in non-deterministic order of the parameters. However, browsers currently preserve the order.
*/
static formatWithParams (format : ಠ_ಠ.clutz.goog.string.Const , args : { [ key: string ]: string | number | ಠ_ಠ.clutz.goog.string.Const } , params : { [ key: string ]: any } ) : ಠ_ಠ.clutz.goog.html.TrustedResourceUrl ;
/**
* Creates a TrustedResourceUrl object from a compile-time constant string.
*
* Compile-time constant strings are inherently program-controlled and hence
* trusted.
* @param url A compile-time-constant string from which to create a TrustedResourceUrl.
*/
static fromConstant (url : ಠ_ಠ.clutz.goog.string.Const ) : ಠ_ಠ.clutz.goog.html.TrustedResourceUrl ;
/**
* Creates a TrustedResourceUrl object from a compile-time constant strings.
*
* Compile-time constant strings are inherently program-controlled and hence
* trusted.
* @param parts Compile-time-constant strings from which to create a TrustedResourceUrl.
*/
static fromConstants (parts : ಠ_ಠ.clutz.goog.string.Const [] ) : ಠ_ಠ.clutz.goog.html.TrustedResourceUrl ;
/**
* Performs a runtime check that the provided object is indeed a
* TrustedResourceUrl object, and returns its value.
* @param trustedResourceUrl The object to extract from.
*/
static unwrap (trustedResourceUrl : ಠ_ಠ.clutz.goog.html.TrustedResourceUrl ) : string ;
}
class TrustedResourceUrl_Instance implements ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString , ಠ_ಠ.clutz.goog.string.TypedString {
private noStructuralTyping_: any;
/**
* Creates a new TrustedResourceUrl with params added to URL.
* @param params Parameters to add to URL. Parameters with value {@code null} or {@code undefined} are skipped. Both keys and values are encoded. If the value is an array then the same parameter is added for every element in the array. Note that JavaScript doesn't guarantee the order of values in an object which might result in non-deterministic order of the parameters. However, browsers currently preserve the order.
*/
cloneWithParams (params : { [ key: string ]: any } ) : ಠ_ಠ.clutz.goog.html.TrustedResourceUrl ;
/**
* Returns this URLs directionality, which is always {@code LTR}.
*/
getDirection ( ) : ಠ_ಠ.clutz.goog.i18n.bidi.Dir | null ;
/**
* Returns this TrustedResourceUrl's value as a string.
*
* IMPORTANT: In code where it is security relevant that an object's type is
* indeed {@code TrustedResourceUrl}, use
* {@code goog.html.TrustedResourceUrl.unwrap} instead of this method. If in
* doubt, assume that it's security relevant. In particular, note that
* goog.html functions which return a goog.html type do not guarantee that
* the returned instance is of the right type. For example:
*
* <pre>
* var fakeSafeHtml = new String('fake');
* fakeSafeHtml.__proto__ = goog.html.SafeHtml.prototype;
* var newSafeHtml = goog.html.SafeHtml.htmlEscape(fakeSafeHtml);
* // newSafeHtml is just an alias for fakeSafeHtml, it's passed through by
* // goog.html.SafeHtml.htmlEscape() as fakeSafeHtml instanceof
* // goog.html.SafeHtml.
* </pre>
*/
getTypedStringValue ( ) : string ;
implementsGoogI18nBidiDirectionalString : boolean ;
implementsGoogStringTypedString : boolean ;
/**
* Returns a debug string-representation of this value.
*
* To obtain the actual string value wrapped in a TrustedResourceUrl, use
* {@code goog.html.TrustedResourceUrl.unwrap}.
*/
toString ( ) : string ;
}
}
declare module 'goog:goog.html.TrustedResourceUrl' {
import alias = ಠ_ಠ.clutz.goog.html.TrustedResourceUrl;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.html.uncheckedconversions {
/**
* Performs an "unchecked conversion" to SafeHtml from a plain string that is
* known to satisfy the SafeHtml type contract.
*
* IMPORTANT: Uses of this method must be carefully security-reviewed to ensure
* that the value of {@code html} satisfies the SafeHtml type contract in all
* possible program states.
* @param justification A constant string explaining why this use of this method is safe. May include a security review ticket number.
* @param html A string that is claimed to adhere to the SafeHtml contract.
* @param opt_dir The optional directionality of the SafeHtml to be constructed. A null or undefined value signifies an unknown directionality.
*/
function safeHtmlFromStringKnownToSatisfyTypeContract (justification : ಠ_ಠ.clutz.goog.string.Const , html : string , opt_dir ? : ಠ_ಠ.clutz.goog.i18n.bidi.Dir | null ) : ಠ_ಠ.clutz.goog.html.SafeHtml ;
/**
* Performs an "unchecked conversion" to SafeScript from a plain string that is
* known to satisfy the SafeScript type contract.
*
* IMPORTANT: Uses of this method must be carefully security-reviewed to ensure
* that the value of {@code script} satisfies the SafeScript type contract in
* all possible program states.
* @param justification A constant string explaining why this use of this method is safe. May include a security review ticket number.
* @param script The string to wrap as a SafeScript.
*/
function safeScriptFromStringKnownToSatisfyTypeContract (justification : ಠ_ಠ.clutz.goog.string.Const , script : string ) : ಠ_ಠ.clutz.goog.html.SafeScript ;
/**
* Performs an "unchecked conversion" to SafeStyle from a plain string that is
* known to satisfy the SafeStyle type contract.
*
* IMPORTANT: Uses of this method must be carefully security-reviewed to ensure
* that the value of {@code style} satisfies the SafeStyle type contract in all
* possible program states.
* @param justification A constant string explaining why this use of this method is safe. May include a security review ticket number.
* @param style The string to wrap as a SafeStyle.
*/
function safeStyleFromStringKnownToSatisfyTypeContract (justification : ಠ_ಠ.clutz.goog.string.Const , style : string ) : ಠ_ಠ.clutz.goog.html.SafeStyle ;
/**
* Performs an "unchecked conversion" to SafeStyleSheet from a plain string
* that is known to satisfy the SafeStyleSheet type contract.
*
* IMPORTANT: Uses of this method must be carefully security-reviewed to ensure
* that the value of {@code styleSheet} satisfies the SafeStyleSheet type
* contract in all possible program states.
* @param justification A constant string explaining why this use of this method is safe. May include a security review ticket number.
* @param styleSheet The string to wrap as a SafeStyleSheet.
*/
function safeStyleSheetFromStringKnownToSatisfyTypeContract (justification : ಠ_ಠ.clutz.goog.string.Const , styleSheet : string ) : ಠ_ಠ.clutz.goog.html.SafeStyleSheet ;
/**
* Performs an "unchecked conversion" to SafeUrl from a plain string that is
* known to satisfy the SafeUrl type contract.
*
* IMPORTANT: Uses of this method must be carefully security-reviewed to ensure
* that the value of {@code url} satisfies the SafeUrl type contract in all
* possible program states.
* @param justification A constant string explaining why this use of this method is safe. May include a security review ticket number.
* @param url The string to wrap as a SafeUrl.
*/
function safeUrlFromStringKnownToSatisfyTypeContract (justification : ಠ_ಠ.clutz.goog.string.Const , url : string ) : ಠ_ಠ.clutz.goog.html.SafeUrl ;
/**
* Performs an "unchecked conversion" to TrustedResourceUrl from a plain string
* that is known to satisfy the TrustedResourceUrl type contract.
*
* IMPORTANT: Uses of this method must be carefully security-reviewed to ensure
* that the value of {@code url} satisfies the TrustedResourceUrl type contract
* in all possible program states.
* @param justification A constant string explaining why this use of this method is safe. May include a security review ticket number.
* @param url The string to wrap as a TrustedResourceUrl.
*/
function trustedResourceUrlFromStringKnownToSatisfyTypeContract (justification : ಠ_ಠ.clutz.goog.string.Const , url : string ) : ಠ_ಠ.clutz.goog.html.TrustedResourceUrl ;
}
declare module 'goog:goog.html.uncheckedconversions' {
import alias = ಠ_ಠ.clutz.goog.html.uncheckedconversions;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.i18n.bidi {
var FORCE_RTL : boolean ;
/**
* 'right' if locale is RTL, 'left' if not.
*/
var I18N_LEFT : string ;
/**
* 'left' if locale is RTL, 'right' if not.
*/
var I18N_RIGHT : string ;
/**
* Constant that defines whether or not the current locale is a RTL locale.
* If {@link goog.i18n.bidi.FORCE_RTL} is not true, this constant will default
* to check that {@link goog.LOCALE} is one of a few major RTL locales.
*
* <p>This is designed to be a maximally efficient compile-time constant. For
* example, for the default goog.LOCALE, compiling
* "if (goog.i18n.bidi.IS_RTL) alert('rtl') else {}" should produce no code. It
* is this design consideration that limits the implementation to only
* supporting a few major RTL locales, as opposed to the broader repertoire of
* something like goog.i18n.bidi.isRtlLanguage.
*
* <p>Since this constant refers to the directionality of the locale, it is up
* to the caller to determine if this constant should also be used for the
* direction of the UI.
*
* {@see goog.LOCALE}
*/
var IS_RTL : boolean ;
/**
* 'left' string constant.
*/
var LEFT : string ;
/**
* 'right' string constant.
*/
var RIGHT : string ;
/**
* Check the directionality of a piece of text, return true if the piece of
* text should be laid out in RTL direction.
* @param str The piece of text that need to be detected.
* @param opt_isHtml Whether str is HTML / HTML-escaped. Default: false.
*/
function detectRtlDirectionality (str : string , opt_isHtml ? : boolean ) : boolean ;
/**
* Check if the exit directionality a piece of text is LTR, i.e. if the last
* strongly-directional character in the string is LTR.
* @param str String being checked.
* @param opt_isHtml Whether str is HTML / HTML-escaped. Default: false.
*/
function endsWithLtr (str : string , opt_isHtml ? : boolean ) : boolean ;
/**
* Check if the exit directionality a piece of text is RTL, i.e. if the last
* strongly-directional character in the string is RTL.
* @param str String being checked.
* @param opt_isHtml Whether str is HTML / HTML-escaped. Default: false.
*/
function endsWithRtl (str : string , opt_isHtml ? : boolean ) : boolean ;
/**
* Enforce the html snippet in RTL directionality regardless overall context.
* If the html piece was enclosed by tag, dir will be applied to existing
* tag, otherwise a span tag will be added as wrapper. For this reason, if
* html snippet start with with tag, this tag must enclose the whole piece. If
* the tag already has a dir specified, this new one will override existing
* one in behavior (tested on FF and IE).
* @param html The string that need to be processed.
*/
function enforceLtrInHtml (html : string ) : string ;
/**
* Enforce LTR on both end of the given text piece using unicode BiDi formatting
* characters LRE and PDF.
* @param text The piece of text that need to be wrapped.
*/
function enforceLtrInText (text : string ) : string ;
/**
* Enforce the html snippet in RTL directionality regardless overall context.
* If the html piece was enclosed by tag, dir will be applied to existing
* tag, otherwise a span tag will be added as wrapper. For this reason, if
* html snippet start with with tag, this tag must enclose the whole piece. If
* the tag already has a dir specified, this new one will override existing
* one in behavior (tested on FF and IE).
* @param html The string that need to be processed.
*/
function enforceRtlInHtml (html : string ) : string ;
/**
* Enforce RTL on both end of the given text piece using unicode BiDi formatting
* characters RLE and PDF.
* @param text The piece of text that need to be wrapped.
*/
function enforceRtlInText (text : string ) : string ;
/**
* Estimates the directionality of a string based on relative word counts.
* If the number of RTL words is above a certain percentage of the total number
* of strongly directional words, returns RTL.
* Otherwise, if any words are strongly or weakly LTR, returns LTR.
* Otherwise, returns UNKNOWN, which is used to mean "neutral".
* Numbers are counted as weakly LTR.
* @param str The string to be checked.
* @param opt_isHtml Whether str is HTML / HTML-escaped. Default: false.
*/
function estimateDirection (str : string , opt_isHtml ? : boolean ) : ಠ_ಠ.clutz.goog.i18n.bidi.Dir ;
/**
* Apply bracket guard using LRM and RLM. This is to address the problem of
* messy bracket display frequently happens in RTL layout.
* This function works for plain text, not for HTML. In HTML, the opening
* bracket might be in a different context than the closing bracket (such as
* an attribute value).
* @param s The string that need to be processed.
* @param opt_isRtlContext specifies default direction (usually direction of the UI).
*/
function guardBracketInText (s : string , opt_isRtlContext ? : boolean ) : string ;
/**
* Test whether the given string has any LTR characters in it.
* @param str The given string that need to be tested.
* @param opt_isHtml Whether str is HTML / HTML-escaped. Default: false.
*/
function hasAnyLtr (str : string , opt_isHtml ? : boolean ) : boolean ;
/**
* Test whether the given string has any RTL characters in it.
* @param str The given string that need to be tested.
* @param opt_isHtml Whether str is HTML / HTML-escaped. Default: false.
*/
function hasAnyRtl (str : string , opt_isHtml ? : boolean ) : boolean ;
/**
* Test whether the given string has any RTL characters in it.
* @param str The given string that need to be tested.
*/
function hasRtlChar (a : string ) : boolean ;
/**
* Check if the first character in the string is LTR or not.
* @param str The given string that need to be tested.
*/
function isLtrChar (str : string ) : boolean ;
/**
* Check if the exit directionality a piece of text is LTR, i.e. if the last
* strongly-directional character in the string is LTR.
* @param str String being checked.
* @param opt_isHtml Whether str is HTML / HTML-escaped. Default: false.
*/
function isLtrExitText (a : string , b ? : boolean ) : boolean ;
/**
* Check whether the first strongly directional character (if any) is LTR.
* @param str String being checked.
* @param opt_isHtml Whether str is HTML / HTML-escaped. Default: false.
*/
function isLtrText (a : string , b ? : boolean ) : boolean ;
/**
* Check if the first character in the string is neutral or not.
* @param str The given string that need to be tested.
*/
function isNeutralChar (str : string ) : boolean ;
/**
* Check whether the input string either contains no strongly directional
* characters or looks like a url.
* @param str String being checked.
* @param opt_isHtml Whether str is HTML / HTML-escaped. Default: false.
*/
function isNeutralText (str : string , opt_isHtml ? : boolean ) : boolean ;
/**
* Check if the first character in the string is RTL or not.
* @param str The given string that need to be tested.
*/
function isRtlChar (str : string ) : boolean ;
/**
* Check if the exit directionality a piece of text is RTL, i.e. if the last
* strongly-directional character in the string is RTL.
* @param str String being checked.
* @param opt_isHtml Whether str is HTML / HTML-escaped. Default: false.
*/
function isRtlExitText (a : string , b ? : boolean ) : boolean ;
/**
* Check if a BCP 47 / III language code indicates an RTL language, i.e. either:
* - a language code explicitly specifying one of the right-to-left scripts,
* e.g. "az-Arab", or<p>
* - a language code specifying one of the languages normally written in a
* right-to-left script, e.g. "fa" (Farsi), except ones explicitly specifying
* Latin or Cyrillic script (which are the usual LTR alternatives).<p>
* The list of right-to-left scripts appears in the 100-199 range in
* http://www.unicode.org/iso15924/iso15924-num.html, of which Arabic and
* Hebrew are by far the most widely used. We also recognize Thaana, N'Ko, and
* Tifinagh, which also have significant modern usage. The rest (Syriac,
* Samaritan, Mandaic, etc.) seem to have extremely limited or no modern usage
* and are not recognized to save on code size.
* The languages usually written in a right-to-left script are taken as those
* with Suppress-Script: Hebr|Arab|Thaa|Nkoo|Tfng in
* http://www.iana.org/assignments/language-subtag-registry,
* as well as Central (or Sorani) Kurdish (ckb), Sindhi (sd) and Uyghur (ug).
* Other subtags of the language code, e.g. regions like EG (Egypt), are
* ignored.
* @param lang BCP 47 (a.k.a III) language code.
*/
function isRtlLanguage (lang : string ) : boolean ;
/**
* Check whether the first strongly directional character (if any) is RTL.
* @param str String being checked.
* @param opt_isHtml Whether str is HTML / HTML-escaped. Default: false.
*/
function isRtlText (a : string , b ? : boolean ) : boolean ;
/**
* Swap location parameters and 'left'/'right' in CSS specification. The
* processed string will be suited for RTL layout. Though this function can
* cover most cases, there are always exceptions. It is suggested to put
* those exceptions in separate group of CSS string.
* @param cssStr CSS spefication string.
*/
function mirrorCSS (cssStr : string ) : string ;
/**
* Replace the double and single quote directly after a Hebrew character with
* GERESH and GERSHAYIM. In such case, most likely that's user intention.
* @param str String that need to be processed.
*/
function normalizeHebrewQuote (str : string ) : string ;
/**
* Sets text input element's directionality and text alignment based on a
* given directionality. Does nothing if the given directionality is unknown or
* neutral.
* @param element Input field element to set directionality to.
* @param dir Desired directionality, given in one of the following formats: 1. A goog.i18n.bidi.Dir constant. 2. A number (positive = LRT, negative = RTL, 0 = neutral). 3. A boolean (true = RTL, false = LTR). 4. A null for unknown directionality.
*/
function setElementDirAndAlign (element : Element | null , dir : number | boolean | null ) : void ;
/**
* Sets element dir based on estimated directionality of the given text.
*/
function setElementDirByTextDirectionality (element : Element , text : string ) : void ;
/**
* Check whether the first strongly directional character (if any) is LTR.
* @param str String being checked.
* @param opt_isHtml Whether str is HTML / HTML-escaped. Default: false.
*/
function startsWithLtr (str : string , opt_isHtml ? : boolean ) : boolean ;
/**
* Check whether the first strongly directional character (if any) is RTL.
* @param str String being checked.
* @param opt_isHtml Whether str is HTML / HTML-escaped. Default: false.
*/
function startsWithRtl (str : string , opt_isHtml ? : boolean ) : boolean ;
/**
* Convert a directionality given in various formats to a goog.i18n.bidi.Dir
* constant. Useful for interaction with different standards of directionality
* representation.
* @param givenDir Directionality given in one of the following formats: 1. A goog.i18n.bidi.Dir constant. 2. A number (positive = LTR, negative = RTL, 0 = neutral). 3. A boolean (true = RTL, false = LTR). 4. A null for unknown directionality.
* @param opt_noNeutral Whether a givenDir of zero or goog.i18n.bidi.Dir.NEUTRAL should be treated as null, i.e. unknown, in order to preserve legacy behavior.
*/
function toDir (givenDir : number | boolean | null , opt_noNeutral ? : boolean ) : ಠ_ಠ.clutz.goog.i18n.bidi.Dir | null ;
}
declare module 'goog:goog.i18n.bidi' {
import alias = ಠ_ಠ.clutz.goog.i18n.bidi;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.i18n.bidi {
/**
* Directionality enum.
*/
enum Dir {
LTR ,
NEUTRAL ,
RTL ,
}
}
declare module 'goog:goog.i18n.bidi.Dir' {
import alias = ಠ_ಠ.clutz.goog.i18n.bidi.Dir;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.i18n.bidi {
/**
* Strings that have an (optional) known direction.
*
* Implementations of this interface are string-like objects that carry an
* attached direction, if known.
*/
interface DirectionalString {
/**
* Retrieves this object's known direction (if any).
*/
getDirection ( ) : ಠ_ಠ.clutz.goog.i18n.bidi.Dir | null ;
/**
* Interface marker of the DirectionalString interface.
*
* This property can be used to determine at runtime whether or not an object
* implements this interface. All implementations of this interface set this
* property to {@code true}.
*/
implementsGoogI18nBidiDirectionalString : boolean ;
}
}
declare module 'goog:goog.i18n.bidi.DirectionalString' {
import alias = ಠ_ಠ.clutz.goog.i18n.bidi.DirectionalString;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.i18n.bidi {
/**
* Unicode formatting characters and directionality string constants.
*/
type Format = string &{clutzEnumBrand: never} ;
var Format : {
LRE : Format ,
LRM : Format ,
PDF : Format ,
RLE : Format ,
RLM : Format ,
};
}
declare module 'goog:goog.i18n.bidi.Format' {
import alias = ಠ_ಠ.clutz.goog.i18n.bidi.Format;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.iter {
/**
* Implements the {@code goog.iter.groupBy} iterator.
*/
class GroupByIterator_ < KEY , VALUE > extends GroupByIterator__Instance < KEY , VALUE > {
}
class GroupByIterator__Instance < KEY , VALUE > extends ಠ_ಠ.clutz.goog.iter.Iterator_Instance < any [] > {
/**
* The current key visited during iteration.
*/
currentKey : KEY ;
/**
* The current value being added to the group.
*/
currentValue : VALUE ;
/**
* The iterable to group, coerced to an iterator.
*/
iterator : ಠ_ಠ.clutz.goog.iter.Iterator < any > ;
/**
* A function for determining the key value for each element in the iterable.
* If no function is provided, the identity function is used and returns the
* element unchanged.
*/
keyFunc (a : VALUE ) : KEY ;
/**
* The target key for determining the start of a group.
*/
targetKey : KEY ;
next ( ) : any [] ;
}
/**
* Creates an iterator that returns running totals from the numbers in
* {@code iterable}. For example, the array {@code [1, 2, 3, 4, 5]} yields
* {@code 1 -> 3 -> 6 -> 10 -> 15}.
* @param iterable The iterable of numbers to accumulate.
*/
function accumulate (iterable : { length : number } | { __iterator__ : any } ) : ಠ_ಠ.clutz.goog.iter.Iterator < number > ;
/**
* Takes zero or more iterables and returns one iterator that will iterate over
* them in the order chained.
* @param var_args Any number of iterable objects.
*/
function chain < VALUE > ( ...var_args : ( ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } | undefined ) [] ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ;
/**
* Takes a single iterable containing zero or more iterables and returns one
* iterator that will iterate over each one in the order given.
* @param iterable The iterable of iterables to chain.
*/
function chainFromIterable < VALUE > (iterable : null | { length : number } | { __iterator__ : any } ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ;
/**
* Creates an iterator that returns combinations of elements from
* {@code iterable}.
*
* Combinations are obtained by taking the {@see goog.iter#permutations} of
* {@code iterable} and filtering those whose elements appear in the order they
* are encountered in {@code iterable}. For example, the 3-length combinations
* of {@code [0,1,2,3]} are {@code [[0,1,2], [0,1,3], [0,2,3], [1,2,3]]}.
* @param iterable The iterable from which to generate combinations.
* @param length The length of each combination.
*/
function combinations < VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } , length : number ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE [] > ;
/**
* Creates an iterator that returns combinations of elements from
* {@code iterable}, with repeated elements possible.
*
* Combinations are obtained by taking the Cartesian product of {@code length}
* iterables and filtering those whose elements appear in the order they are
* encountered in {@code iterable}. For example, the 2-length combinations of
* {@code [1,2,3]} are {@code [[1,1], [1,2], [1,3], [2,2], [2,3], [3,3]]}.
* @param iterable The iterable to combine.
* @param length The length of each combination.
*/
function combinationsWithReplacement < VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } , length : number ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE [] > ;
/**
* Creates an iterator that filters {@code iterable} based on a series of
* {@code selectors}. On each call to {@code next()}, one item is taken from
* both the {@code iterable} and {@code selectors} iterators. If the item from
* {@code selectors} evaluates to true, the item from {@code iterable} is given.
* Otherwise, it is skipped. Once either {@code iterable} or {@code selectors}
* is exhausted, subsequent calls to {@code next()} will throw
* {@code goog.iter.StopIteration}.
* @param iterable The iterable to filter.
* @param selectors An iterable of items to be evaluated in a boolean context to determine if the corresponding element in {@code iterable} should be included in the result.
*/
function compress < VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } , selectors : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ;
/**
* Creates an iterator that is advanced {@code count} steps ahead. Consumed
* values are silently discarded. If {@code count} is greater than the number
* of elements in {@code iterable}, an empty iterator is returned. Subsequent
* calls to {@code next()} will throw {@code goog.iter.StopIteration}.
* @param iterable The iterable to consume.
* @param count The number of elements to consume from the iterator.
*/
function consume < VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } , count : number ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ;
/**
* Creates an iterator that counts indefinitely from a starting value.
* @param opt_start The starting value. Default is 0.
* @param opt_step The number to increment with between each call to next. Negative and floating point numbers are allowed. Default is 1.
*/
function count (opt_start ? : number , opt_step ? : number ) : ಠ_ಠ.clutz.goog.iter.Iterator < number > ;
/**
* Create an iterator to cycle over the iterable's elements indefinitely.
* For example, ([1, 2, 3]) would return : 1, 2, 3, 1, 2, 3, ...
* @param iterable The iterable object.
*/
function cycle < VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ;
/**
* Builds a new iterator that iterates over the original, but skips elements as
* long as a supplied function returns true.
* @param iterable The iterator object.
* @param f The function to call for every value. This function takes 3 arguments (the value, undefined, and the iterator) and should return a boolean.
* @param opt_obj The object to be used as the value of 'this' within {@code f}.
*/
function dropWhile < THIS , VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | null | { length : number } | { __iterator__ : any } , f : (a : VALUE , b : undefined , c : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ) => boolean , opt_obj ? : THIS ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ;
/**
* Creates an iterator that returns arrays containing a count and an element
* obtained from the given {@code iterable}.
* @param iterable The iterable to enumerate.
* @param opt_start Optional starting value. Default is 0.
*/
function enumerate < VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } , opt_start ? : number ) : ಠ_ಠ.clutz.goog.iter.Iterator < any [] > ;
/**
* Iterates over two iterables and returns true if they contain the same
* sequence of elements and have the same length.
* @param iterable1 The first iterable object.
* @param iterable2 The second iterable object.
* @param opt_equalsFn Optional comparison function. Should take two arguments to compare, and return true if the arguments are equal. Defaults to {@link goog.array.defaultCompareEquality} which compares the elements using the built-in '===' operator.
*/
function equals < VALUE > (iterable1 : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } , iterable2 : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } , opt_equalsFn ? : (a : VALUE , b : VALUE ) => boolean ) : boolean ;
/**
* Goes through the values in the iterator. Calls f for each of these and if any
* of them returns false this returns false (without checking the rest). If all
* return true this will return true.
* @param iterable The iterator object.
* @param f The function to call for every value. This function takes 3 arguments (the value, undefined, and the iterator) and should return a boolean.
* @param opt_obj The object to be used as the value of 'this' within {@code f}.
*/
function every < THIS , VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | null | { length : number } | { __iterator__ : any } , f : (a : VALUE , b : undefined , c : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ) => boolean , opt_obj ? : THIS ) : boolean ;
/**
* Calls a function for every element in the iterator, and if the function
* returns true adds the element to a new iterator.
* @param iterable The iterator to iterate over.
* @param f The function to call for every element. This function takes 3 arguments (the element, undefined, and the iterator) and should return a boolean. If the return value is true the element will be included in the returned iterator. If it is false the element is not included.
* @param opt_obj The object to be used as the value of 'this' within {@code f}.
*/
function filter < THIS , VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | null | { length : number } | { __iterator__ : any } , f : (a : VALUE , b : undefined , c : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ) => boolean , opt_obj ? : THIS ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ;
/**
* Calls a function for every element in the iterator, and if the function
* returns false adds the element to a new iterator.
* @param iterable The iterator to iterate over.
* @param f The function to call for every element. This function takes 3 arguments (the element, undefined, and the iterator) and should return a boolean. If the return value is false the element will be included in the returned iterator. If it is true the element is not included.
* @param opt_obj The object to be used as the value of 'this' within {@code f}.
*/
function filterFalse < THIS , VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | null | { length : number } | { __iterator__ : any } , f : (a : VALUE , b : undefined , c : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ) => boolean , opt_obj ? : THIS ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ;
/**
* Calls a function for each element in the iterator with the element of the
* iterator passed as argument.
* @param iterable The iterator to iterate over. If the iterable is an object {@code toIterator} will be called on it.
* @param f The function to call for every element. This function takes 3 arguments (the element, undefined, and the iterator) and the return value is irrelevant. The reason for passing undefined as the second argument is so that the same function can be used in {@see goog.array#forEach} as well as others. The third parameter is of type "number" for arraylike objects, undefined, otherwise.
* @param opt_obj The object to be used as the value of 'this' within {@code f}.
*/
function forEach < THIS , VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | null | { length : number } | { __iterator__ : any } , f : (a : VALUE , b : any , c : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ) => any , opt_obj ? : THIS ) : void ;
/**
* Creates an iterator that returns arrays containing elements from the
* {@code iterable} grouped by a key value. For iterables with repeated
* elements (i.e. sorted according to a particular key function), this function
* has a {@code uniq}-like effect. For example, grouping the array:
* {@code [A, B, B, C, C, A]} produces
* {@code [A, [A]], [B, [B, B]], [C, [C, C]], [A, [A]]}.
* @param iterable The iterable to group.
* @param opt_keyFunc Optional function for determining the key value for each group in the {@code iterable}. Default is the identity function.
*/
function groupBy < KEY , VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } , opt_keyFunc ? : (a : VALUE ) => KEY ) : ಠ_ಠ.clutz.goog.iter.Iterator < any [] > ;
/**
* Joins the values in a iterator with a delimiter.
* @param iterable The iterator to get the values from.
* @param deliminator The text to put between the values.
*/
function join < VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | null | { length : number } | { __iterator__ : any } , deliminator : string ) : string ;
/**
* Creates an iterator that returns the first {@code limitSize} elements from an
* iterable. If this number is greater than the number of elements in the
* iterable, all the elements are returned.
* @param iterable The iterable to limit.
* @param limitSize The maximum number of elements to return.
*/
function limit < VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } , limitSize : number ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ;
/**
* For every element in the iterator call a function and return a new iterator
* with that value.
* @param iterable The iterator to iterate over.
* @param f The function to call for every element. This function takes 3 arguments (the element, undefined, and the iterator) and should return a new value.
* @param opt_obj The object to be used as the value of 'this' within {@code f}.
*/
function map < THIS , VALUE , RESULT > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } , f : (a : VALUE , b : undefined , c : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ) => RESULT , opt_obj ? : THIS ) : ಠ_ಠ.clutz.goog.iter.Iterator < RESULT > ;
/**
* Advances the iterator to the next position, returning the given default value
* instead of throwing an exception if the iterator has no more entries.
* @param iterable The iterable object.
* @param defaultValue The value to return if the iterator is empty.
*/
function nextOrValue < VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | null | { length : number } | { __iterator__ : any } , defaultValue : VALUE ) : VALUE ;
/**
* Creates an iterator that returns permutations of elements in
* {@code iterable}.
*
* Permutations are obtained by taking the Cartesian product of
* {@code opt_length} iterables and filtering out those with repeated
* elements. For example, the permutations of {@code [1,2,3]} are
* {@code [[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]}.
* @param iterable The iterable from which to generate permutations.
* @param opt_length Length of each permutation. If omitted, defaults to the length of {@code iterable}.
*/
function permutations < VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } , opt_length ? : number ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE [] > ;
/**
* Cartesian product of zero or more sets. Gives an iterator that gives every
* combination of one element chosen from each set. For example,
* ([1, 2], [3, 4]) gives ([1, 3], [1, 4], [2, 3], [2, 4]).
* @param var_args Zero or more sets, as arrays.
*/
function product < VALUE > ( ...var_args : ( ArrayLike < VALUE > | undefined ) [] ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE [] > ;
/**
* Creates a new iterator that returns the values in a range. This function
* can take 1, 2 or 3 arguments:
* <pre>
* range(5) same as range(0, 5, 1)
* range(2, 5) same as range(2, 5, 1)
* </pre>
* @param startOrStop The stop value if only one argument is provided. The start value if 2 or more arguments are provided. If only one argument is used the start value is 0.
* @param opt_stop The stop value. If left out then the first argument is used as the stop value.
* @param opt_step The number to increment with between each call to next. This can be negative.
*/
function range (startOrStop : number , opt_stop ? : number , opt_step ? : number ) : ಠ_ಠ.clutz.goog.iter.Iterator < number > ;
/**
* Passes every element of an iterator into a function and accumulates the
* result.
* @param iterable The iterator to iterate over.
* @param f The function to call for every element. This function takes 2 arguments (the function's previous result or the initial value, and the value of the current element). function(previousValue, currentElement) : newValue.
* @param val The initial value to pass into the function on the first call.
* @param opt_obj The object to be used as the value of 'this' within f.
*/
function reduce < THIS , VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | null | { length : number } | { __iterator__ : any } , f : (a : VALUE , b : VALUE ) => VALUE , val : VALUE , opt_obj ? : THIS ) : VALUE ;
/**
* Creates an iterator that returns the same object or value repeatedly.
* @param value Any object or value to repeat.
*/
function repeat < VALUE > (value : VALUE ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ;
/**
* Creates an iterator that returns a range of elements from an iterable.
* Similar to {@see goog.array#slice} but does not support negative indexes.
* @param iterable The iterable to slice.
* @param start The index of the first element to return.
* @param opt_end The index after the last element to return. If defined, must be greater than or equal to {@code start}.
*/
function slice < VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } , start : number , opt_end ? : number ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ;
/**
* Goes through the values in the iterator. Calls f for each of these, and if
* any of them returns true, this returns true (without checking the rest). If
* all return false this will return false.
* @param iterable The iterator object.
* @param f The function to call for every value. This function takes 3 arguments (the value, undefined, and the iterator) and should return a boolean.
* @param opt_obj The object to be used as the value of 'this' within {@code f}.
*/
function some < THIS , VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | null | { length : number } | { __iterator__ : any } , f : (a : VALUE , b : undefined , c : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ) => boolean , opt_obj ? : THIS ) : boolean ;
/**
* Gives an iterator that gives the result of calling the given function
* <code>f</code> with the arguments taken from the next element from
* <code>iterable</code> (the elements are expected to also be iterables).
*
* Similar to {@see goog.iter#map} but allows the function to accept multiple
* arguments from the iterable.
* @param iterable The iterable of iterables to iterate over.
* @param f The function to call for every element. This function takes N+2 arguments, where N represents the number of items from the next element of the iterable. The two additional arguments passed to the function are undefined and the iterator itself. The function should return a new value.
* @param opt_obj The object to be used as the value of 'this' within {@code f}.
*/
function starMap < THIS , RESULT > (iterable : { length : number } | { __iterator__ : any } , f : ( ...a : any [] ) => RESULT , opt_obj ? : THIS ) : ಠ_ಠ.clutz.goog.iter.Iterator < RESULT > ;
/**
* Builds a new iterator that iterates over the original, but only as long as a
* supplied function returns true.
* @param iterable The iterator object.
* @param f The function to call for every value. This function takes 3 arguments (the value, undefined, and the iterator) and should return a boolean.
* @param opt_obj This is used as the 'this' object in f when called.
*/
function takeWhile < THIS , VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | null | { length : number } | { __iterator__ : any } , f : (a : VALUE , b : undefined , c : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ) => boolean , opt_obj ? : THIS ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ;
/**
* Returns an array of iterators each of which can iterate over the values in
* {@code iterable} without advancing the others.
* @param iterable The iterable to tee.
* @param opt_num The number of iterators to create. Default is 2.
*/
function tee < VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } , opt_num ? : number ) : ( ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | null ) [] ;
/**
* Converts the iterator to an array
* @param iterable The iterator to convert to an array.
*/
function toArray < VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | null | { length : number } | { __iterator__ : any } ) : VALUE [] ;
/**
* Returns an iterator that knows how to iterate over the values in the object.
* @param iterable If the object is an iterator it will be returned as is. If the object has an {@code __iterator__} method that will be called to get the value iterator. If the object is an array-like object we create an iterator for that.
*/
function toIterator < VALUE > (iterable : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | null | { length : number } | { __iterator__ : any } ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ;
/**
* Creates an iterator that returns arrays containing the ith elements from the
* provided iterables. The returned arrays will be the same size as the number
* of iterables given in {@code var_args}. Once the shortest iterable is
* exhausted, subsequent calls to {@code next()} will throw
* {@code goog.iter.StopIteration}.
* @param var_args Any number of iterable objects.
*/
function zip < VALUE > ( ...var_args : ( ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } | undefined ) [] ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE [] > ;
/**
* Creates an iterator that returns arrays containing the ith elements from the
* provided iterables. The returned arrays will be the same size as the number
* of iterables given in {@code var_args}. Shorter iterables will be extended
* with {@code fillValue}. Once the longest iterable is exhausted, subsequent
* calls to {@code next()} will throw {@code goog.iter.StopIteration}.
* @param fillValue The object or value used to fill shorter iterables.
* @param var_args Any number of iterable objects.
*/
function zipLongest < VALUE > (fillValue : VALUE , ...var_args : ( ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > | { length : number } | { __iterator__ : any } | undefined ) [] ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE [] > ;
}
declare module 'goog:goog.iter' {
import alias = ಠ_ಠ.clutz.goog.iter;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.iter {
type Iterable = null | { length : number } | { __iterator__ : any } ;
}
declare module 'goog:goog.iter.Iterable' {
import alias = ಠ_ಠ.clutz.goog.iter.Iterable;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.iter {
/**
* Class/interface for iterators. An iterator needs to implement a {@code next}
* method and it needs to throw a {@code goog.iter.StopIteration} when the
* iteration passes beyond the end. Iterators have no {@code hasNext} method.
* It is recommended to always use the helper functions to iterate over the
* iterator or in case you are only targeting JavaScript 1.7 for in loops.
*/
class Iterator < VALUE > extends Iterator_Instance < VALUE > {
}
class Iterator_Instance < VALUE > {
private noStructuralTyping_: any;
/**
* Returns the {@code Iterator} object itself. This is used to implement
* the iterator protocol in JavaScript 1.7
* @param opt_keys Whether to return the keys or values. Default is to only return the values. This is being used by the for-in loop (true) and the for-each-in loop (false). Even though the param gives a hint about what the iterator will return there is no guarantee that it will return the keys when true is passed.
*/
__iterator__ (opt_keys ? : boolean ) : ಠ_ಠ.clutz.goog.iter.Iterator < VALUE > ;
/**
* Returns the next value of the iteration. This will throw the object
* {@see goog.iter#StopIteration} when the iteration passes the end.
*/
next ( ) : VALUE ;
}
}
declare module 'goog:goog.iter.Iterator' {
import alias = ಠ_ಠ.clutz.goog.iter.Iterator;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.iter {
/**
* Singleton Error object that is used to terminate iterations.
*/
var StopIteration : GlobalError ;
}
declare module 'goog:goog.iter.StopIteration' {
import alias = ಠ_ಠ.clutz.goog.iter.StopIteration;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.json {
var TRY_NATIVE_JSON : boolean ;
var USE_NATIVE_JSON : boolean ;
/**
* Tests if a string is an invalid JSON string. This only ensures that we are
* not using any invalid characters
* @param s The string to test.
*/
function isValid (s : string ) : boolean ;
/**
* Parses a JSON string and returns the result. This throws an exception if
* the string is an invalid JSON string.
*
* Note that this is very slow on large strings. Use JSON.parse if possible.
* @param s The JSON string to parse.
*/
function parse (a : any ) : GlobalObject | null ;
/**
* Serializes an object or a value to a JSON string.
* @param object The object to serialize.
* @param opt_replacer A replacer function called for each (key, value) pair that determines how the value should be serialized. By defult, this just returns the value and allows default serialization to kick in.
*/
function serialize (a : any , b ? : ( ಠ_ಠ.clutz.goog.json.Reviver ) | null ) : string ;
/**
* Sets an error logger to use if there's a recoverable parsing error and {@code
* goog.json.TRY_NATIVE_JSON} is enabled.
* @param errorLogger The first parameter is the error message, the second is the exception thrown by {@code JSON.parse}.
*/
function setErrorLogger (errorLogger : (a : string , b : GlobalError ) => any ) : void ;
}
declare module 'goog:goog.json' {
import alias = ಠ_ಠ.clutz.goog.json;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.json {
/**
* JSON replacer, as defined in Section 15.12.3 of the ES5 spec.
*/
type Replacer = (a : string , b : any ) => any ;
}
declare module 'goog:goog.json.Replacer' {
import alias = ಠ_ಠ.clutz.goog.json.Replacer;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.json {
/**
* JSON reviver, as defined in Section 15.12.2 of the ES5 spec.
*/
type Reviver = (a : string , b : any ) => any ;
}
declare module 'goog:goog.json.Reviver' {
import alias = ಠ_ಠ.clutz.goog.json.Reviver;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.json {
/**
* Class that is used to serialize JSON objects to a string.
*/
class Serializer extends Serializer_Instance {
}
class Serializer_Instance {
private noStructuralTyping_: any;
/**
* Class that is used to serialize JSON objects to a string.
* @param opt_replacer Replacer.
*/
constructor (opt_replacer ? : ( ಠ_ಠ.clutz.goog.json.Reviver ) | null ) ;
/**
* Serializes an object or a value to a JSON string.
* @param object The object to serialize.
*/
serialize (object : any ) : string ;
/**
* Serializes an array to a JSON string
* @param arr The array to serialize.
* @param sb Array used as a string builder.
*/
serializeArray (arr : string [] | null , sb : string [] | null ) : void ;
/**
* Serializes a generic value to a JSON string
* @param object The object to serialize.
* @param sb Array used as a string builder.
*/
serializeInternal (object : any , sb : string [] | null ) : void ;
}
}
declare module 'goog:goog.json.Serializer' {
import alias = ಠ_ಠ.clutz.goog.json.Serializer;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.json.hybrid {
/**
* Attempts to parse the JSON string natively, falling back to
* {@code goog.json.parse} if unsuccessful.
* @param jsonString JSON string to parse.
*/
function parse (a : string ) : GlobalObject | null ;
/**
* Attempts to serialize the JSON string natively, falling back to
* {@code goog.json.serialize} if unsuccessful.
* @param obj JavaScript object to serialize to JSON.
*/
function stringify (a : GlobalObject ) : string ;
}
declare module 'goog:goog.json.hybrid' {
import alias = ಠ_ಠ.clutz.goog.json.hybrid;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.labs.dom {
/**
* A page visibility change event.
*/
class PageVisibilityEvent extends PageVisibilityEvent_Instance {
}
class PageVisibilityEvent_Instance extends ಠ_ಠ.clutz.goog.events.Event_Instance {
/**
* A page visibility change event.
* @param hidden Whether the page is hidden.
* @param visibilityState A more detailed visibility state.
*/
constructor (hidden : boolean , visibilityState : ಠ_ಠ.clutz.goog.labs.dom.PageVisibilityState ) ;
/**
* Whether the page is hidden.
*/
hidden : boolean ;
/**
* A more detailed visibility state.
*/
visibilityState : ಠ_ಠ.clutz.goog.labs.dom.PageVisibilityState ;
}
}
declare module 'goog:goog.labs.dom.PageVisibilityEvent' {
import alias = ಠ_ಠ.clutz.goog.labs.dom.PageVisibilityEvent;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.labs.dom {
/**
* This event handler allows you to catch page visibility change events.
*/
class PageVisibilityMonitor extends PageVisibilityMonitor_Instance {
}
class PageVisibilityMonitor_Instance extends ಠ_ಠ.clutz.goog.events.EventTarget_Instance {
/**
* This event handler allows you to catch page visibility change events.
*/
constructor (opt_domHelper ? : ಠ_ಠ.clutz.goog.dom.DomHelper ) ;
disposeInternal ( ) : void ;
getVisibilityState ( ) : ಠ_ಠ.clutz.goog.labs.dom.PageVisibilityState | null ;
isHidden ( ) : boolean ;
isSupported ( ) : boolean ;
}
}
declare module 'goog:goog.labs.dom.PageVisibilityMonitor' {
import alias = ಠ_ಠ.clutz.goog.labs.dom.PageVisibilityMonitor;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.labs.dom {
/**
* The different visibility states.
*/
type PageVisibilityState = string &{clutzEnumBrand: never} ;
var PageVisibilityState : {
HIDDEN : PageVisibilityState ,
PRERENDER : PageVisibilityState ,
UNLOADED : PageVisibilityState ,
VISIBLE : PageVisibilityState ,
};
}
declare module 'goog:goog.labs.dom.PageVisibilityState' {
import alias = ಠ_ಠ.clutz.goog.labs.dom.PageVisibilityState;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.labs.userAgent.browser {
function getVersion ( ) : string ;
function isAndroidBrowser ( ) : boolean ;
function isChrome ( ) : boolean ;
function isCoast ( ) : boolean ;
function isEdge ( ) : boolean ;
function isFirefox ( ) : boolean ;
function isIE ( ) : boolean ;
function isIosWebview ( ) : boolean ;
function isOpera ( ) : boolean ;
function isSafari ( ) : boolean ;
/**
* For more information, see:
* http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
*/
function isSilk ( ) : boolean ;
function isVersionOrHigher (version : string | number ) : boolean ;
}
declare module 'goog:goog.labs.userAgent.browser' {
import alias = ಠ_ಠ.clutz.goog.labs.userAgent.browser;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.labs.userAgent.engine {
function getVersion ( ) : string ;
function isEdge ( ) : boolean ;
function isGecko ( ) : boolean ;
function isPresto ( ) : boolean ;
function isTrident ( ) : boolean ;
function isVersionOrHigher (version : string | number ) : boolean ;
function isWebKit ( ) : boolean ;
}
declare module 'goog:goog.labs.userAgent.engine' {
import alias = ಠ_ಠ.clutz.goog.labs.userAgent.engine;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.labs.userAgent.platform {
/**
* The version of the platform. We only determine the version for Windows,
* Mac, and Chrome OS. It doesn't make much sense on Linux. For Windows, we only
* look at the NT version. Non-NT-based versions (e.g. 95, 98, etc.) are given
* version 0.0.
*/
function getVersion ( ) : string ;
function isAndroid ( ) : boolean ;
function isChromeOS ( ) : boolean ;
function isIos ( ) : boolean ;
function isIpad ( ) : boolean ;
function isIphone ( ) : boolean ;
function isIpod ( ) : boolean ;
/**
* Note: ChromeOS is not considered to be Linux as it does not report itself
* as Linux in the user agent string.
*/
function isLinux ( ) : boolean ;
function isMacintosh ( ) : boolean ;
function isVersionOrHigher (version : string | number ) : boolean ;
function isWindows ( ) : boolean ;
}
declare module 'goog:goog.labs.userAgent.platform' {
import alias = ಠ_ಠ.clutz.goog.labs.userAgent.platform;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.labs.userAgent.util {
/**
* Parses the user agent into tuples for each section.
*/
function extractVersionTuples (userAgent : string ) : string [] [] ;
function getUserAgent ( ) : string ;
function matchUserAgent (str : string ) : boolean ;
function matchUserAgentIgnoreCase (str : string ) : boolean ;
/**
* Applications may override browser detection on the built in
* navigator.userAgent object by setting this string. Set to null to use the
* browser object instead.
* @param opt_userAgent The User-Agent override.
*/
function setUserAgent (opt_userAgent ? : string | null ) : void ;
}
declare module 'goog:goog.labs.userAgent.util' {
import alias = ಠ_ಠ.clutz.goog.labs.userAgent.util;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.log {
var ENABLED : boolean ;
var ROOT_LOGGER_NAME : string ;
/**
* Adds a handler to the logger. This doesn't use the event system because
* we want to be able to add logging to the event system.
* @param handler Handler function to add.
*/
function addHandler (logger : ಠ_ಠ.clutz.goog.debug.Logger | null , handler : Function | null ) : void ;
/**
* Logs a message at the Level.SEVERE level.
* If the logger is currently enabled for the given message level then the
* given message is forwarded to all the registered output Handler objects.
* @param msg The message to log.
* @param opt_exception An exception associated with the message.
*/
function error (logger : ಠ_ಠ.clutz.goog.debug.Logger | null , msg : string | ( ( ) => string ) , opt_exception ? : GlobalError | null ) : void ;
/**
* Logs a message at the Level.Fine level.
* If the logger is currently enabled for the given message level then the
* given message is forwarded to all the registered output Handler objects.
* @param msg The message to log.
* @param opt_exception An exception associated with the message.
*/
function fine (logger : ಠ_ಠ.clutz.goog.debug.Logger | null , msg : string | ( ( ) => string ) , opt_exception ? : GlobalError | null ) : void ;
/**
* Finds or creates a logger for a named subsystem. If a logger has already been
* created with the given name it is returned. Otherwise a new logger is
* created. If a new logger is created its log level will be configured based
* on the goog.debug.LogManager configuration and it will configured to also
* send logging output to its parent's handlers.
* @param name A name for the logger. This should be a dot-separated name and should normally be based on the package name or class name of the subsystem, such as goog.net.BrowserChannel.
* @param opt_level If provided, override the default logging level with the provided level.
*/
function getLogger (name : string , opt_level ? : ಠ_ಠ.clutz.goog.debug.Logger.Level | null ) : ಠ_ಠ.clutz.goog.debug.Logger | null ;
/**
* Logs a message at the Level.INFO level.
* If the logger is currently enabled for the given message level then the
* given message is forwarded to all the registered output Handler objects.
* @param msg The message to log.
* @param opt_exception An exception associated with the message.
*/
function info (logger : ಠ_ಠ.clutz.goog.debug.Logger | null , msg : string | ( ( ) => string ) , opt_exception ? : GlobalError | null ) : void ;
/**
* Logs a message. If the logger is currently enabled for the
* given message level then the given message is forwarded to all the
* registered output Handler objects.
* @param level One of the level identifiers.
* @param msg The message to log.
* @param opt_exception An exception associated with the message.
*/
function log (logger : ಠ_ಠ.clutz.goog.debug.Logger | null , level : ಠ_ಠ.clutz.goog.debug.Logger.Level | null , msg : string | ( ( ) => string ) , opt_exception ? : null | GlobalObject ) : void ;
/**
* Removes a handler from the logger. This doesn't use the event system because
* we want to be able to add logging to the event system.
* @param handler Handler function to remove.
*/
function removeHandler (logger : ಠ_ಠ.clutz.goog.debug.Logger | null , handler : Function | null ) : boolean ;
/**
* Logs a message at the Level.WARNING level.
* If the logger is currently enabled for the given message level then the
* given message is forwarded to all the registered output Handler objects.
* @param msg The message to log.
* @param opt_exception An exception associated with the message.
*/
function warning (logger : ಠ_ಠ.clutz.goog.debug.Logger | null , msg : string | ( ( ) => string ) , opt_exception ? : GlobalError | null ) : void ;
}
declare module 'goog:goog.log' {
import alias = ಠ_ಠ.clutz.goog.log;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.log {
type Level = ಠ_ಠ.clutz.goog.debug.Logger.Level ;
var Level : typeof ಠ_ಠ.clutz.goog.debug.Logger.Level ;
}
declare module 'goog:goog.log.Level' {
import alias = ಠ_ಠ.clutz.goog.log.Level;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.log {
type LogRecord = ಠ_ಠ.clutz.goog.debug.LogRecord ;
var LogRecord : typeof ಠ_ಠ.clutz.goog.debug.LogRecord ;
}
declare module 'goog:goog.log.LogRecord' {
import alias = ಠ_ಠ.clutz.goog.log.LogRecord;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.log {
type Logger = ಠ_ಠ.clutz.goog.debug.Logger ;
var Logger : typeof ಠ_ಠ.clutz.goog.debug.Logger ;
}
declare module 'goog:goog.log.Logger' {
import alias = ಠ_ಠ.clutz.goog.log.Logger;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.math {
/**
* Computes the angle between two points (x1,y1) and (x2,y2).
* Angle zero points in the +X direction, 90 degrees points in the +Y
* direction (down) and from there we grow clockwise towards 360 degrees.
* @param x1 x of first point.
* @param y1 y of first point.
* @param x2 x of second point.
* @param y2 y of second point.
*/
function angle (x1 : number , y1 : number , x2 : number , y2 : number ) : number ;
/**
* Computes the difference between startAngle and endAngle (angles in degrees).
* @param startAngle Start angle in degrees.
* @param endAngle End angle in degrees.
*/
function angleDifference (startAngle : number , endAngle : number ) : number ;
/**
* For a given angle and radius, finds the X portion of the offset.
* @param degrees Angle in degrees (zero points in +X direction).
* @param radius Radius.
*/
function angleDx (degrees : number , radius : number ) : number ;
/**
* For a given angle and radius, finds the Y portion of the offset.
* @param degrees Angle in degrees (zero points in +X direction).
* @param radius Radius.
*/
function angleDy (degrees : number , radius : number ) : number ;
/**
* Returns the arithmetic mean of the arguments.
* @param var_args Numbers to average.
*/
function average ( ...var_args : ( number | undefined ) [] ) : number ;
/**
* Takes a number and clamps it to within the provided bounds.
* @param value The input number.
* @param min The minimum value to return.
* @param max The maximum value to return.
*/
function clamp (value : number , min : number , max : number ) : number ;
/**
* Returns whether the supplied number is finite and not NaN.
* @param num The number to test.
*/
function isFiniteNumber (num : number ) : boolean ;
/**
* Returns whether the supplied number represents an integer, i.e. that is has
* no fractional component. No range-checking is performed on the number.
* @param num The number to test.
*/
function isInt (num : number ) : boolean ;
function isNegativeZero (num : number ) : boolean ;
/**
* Performs linear interpolation between values a and b. Returns the value
* between a and b proportional to x (when x is between 0 and 1. When x is
* outside this range, the return value is a linear extrapolation).
* @param a A number.
* @param b A number.
* @param x The proportion between a and b.
*/
function lerp (a : number , b : number , x : number ) : number ;
/**
* Returns the precise value of floor(log10(num)).
* Simpler implementations didn't work because of floating point rounding
* errors. For example
* <ul>
* <li>Math.floor(Math.log(num) / Math.LN10) is off by one for num == 1e+3.
* <li>Math.floor(Math.log(num) * Math.LOG10E) is off by one for num == 1e+15.
* <li>Math.floor(Math.log10(num)) is off by one for num == 1e+15 - 1.
* </ul>
* @param num A floating point number.
*/
function log10Floor (num : number ) : number ;
/**
* JavaScript implementation of Longest Common Subsequence problem.
* http://en.wikipedia.org/wiki/Longest_common_subsequence
*
* Returns the longest possible array that is subarray of both of given arrays.
* @param array1 First array of objects.
* @param array2 Second array of objects.
* @param opt_compareFn Function that acts as a custom comparator for the array ojects. Function should return true if objects are equal, otherwise false.
* @param opt_collectorFn Function used to decide what to return as a result subsequence. It accepts 2 arguments: index of common element in the first array and index in the second. The default function returns element from the first array.
*/
function longestCommonSubsequence < S , T > (array1 : ArrayLike < S > | null , array2 : ArrayLike < T > | null , opt_compareFn ? : Function | null , opt_collectorFn ? : Function | null ) : ( S | T ) [] ;
/**
* The % operator in JavaScript returns the remainder of a / b, but differs from
* some other languages in that the result will have the same sign as the
* dividend. For example, -1 % 8 == -1, whereas in some other languages
* (such as Python) the result would be 7. This function emulates the more
* correct modulo behavior, which is useful for certain applications such as
* calculating an offset index in a circular list.
* @param a The dividend.
* @param b The divisor.
*/
function modulo (a : number , b : number ) : number ;
/**
* Tests whether the two values are equal to each other, within a certain
* tolerance to adjust for floating point errors.
* @param a A number.
* @param b A number.
* @param opt_tolerance Optional tolerance range. Defaults to 0.000001. If specified, should be greater than 0.
*/
function nearlyEquals (a : number , b : number , opt_tolerance ? : number ) : boolean ;
/**
* Returns a random integer greater than or equal to 0 and less than {@code a}.
* @param a The upper bound for the random integer (exclusive).
*/
function randomInt (a : number ) : number ;
/**
* A tweaked variant of {@code Math.ceil}. See {@code goog.math.safeFloor} for
* details.
* @param num A number.
* @param opt_epsilon An infinitesimally small positive number, the rounding error to tolerate.
*/
function safeCeil (num : number , opt_epsilon ? : number ) : number ;
/**
* A tweaked variant of {@code Math.floor} which tolerates if the passed number
* is infinitesimally smaller than the closest integer. It often happens with
* the results of floating point calculations because of the finite precision
* of the intermediate results. For example {@code Math.floor(Math.log(1000) /
* Math.LN10) == 2}, not 3 as one would expect.
* @param num A number.
* @param opt_epsilon An infinitesimally small positive number, the rounding error to tolerate.
*/
function safeFloor (num : number , opt_epsilon ? : number ) : number ;
/**
* Returns the unbiased sample variance of the arguments. For a definition,
* see e.g. http://en.wikipedia.org/wiki/Variance
* @param var_args Number samples to analyze.
*/
function sampleVariance ( ...var_args : ( number | undefined ) [] ) : number ;
/**
* Returns the sign of a number as per the "sign" or "signum" function.
* @param x The number to take the sign of.
*/
function sign (x : number ) : number ;
/**
* Normalizes an angle to be in range [0-360). Angles outside this range will
* be normalized to be the equivalent angle with that range.
* @param angle Angle in degrees.
*/
function standardAngle (angle : number ) : number ;
/**
* Normalizes an angle to be in range [0-2*PI). Angles outside this range will
* be normalized to be the equivalent angle with that range.
* @param angle Angle in radians.
*/
function standardAngleInRadians (angle : number ) : number ;
/**
* Returns the sample standard deviation of the arguments. For a definition of
* sample standard deviation, see e.g.
* http://en.wikipedia.org/wiki/Standard_deviation
* @param var_args Number samples to analyze.
*/
function standardDeviation ( ...var_args : ( number | undefined ) [] ) : number ;
/**
* Returns the sum of the arguments.
* @param var_args Numbers to add.
*/
function sum ( ...var_args : ( number | undefined ) [] ) : number ;
/**
* Converts radians to degrees.
* @param angleRadians Angle in radians.
*/
function toDegrees (angleRadians : number ) : number ;
/**
* Converts degrees to radians.
* @param angleDegrees Angle in degrees.
*/
function toRadians (angleDegrees : number ) : number ;
/**
* Returns a random number greater than or equal to {@code a} and less than
* {@code b}.
* @param a The lower bound for the random number (inclusive).
* @param b The upper bound for the random number (exclusive).
*/
function uniformRandom (a : number , b : number ) : number ;
}
declare module 'goog:goog.math' {
import alias = ಠ_ಠ.clutz.goog.math;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.math {
/**
* Class for representing coordinates and positions.
*/
class Coordinate extends Coordinate_Instance {
/**
* Returns the angle from the origin to a coordinate.
* @param a A Coordinate.
*/
static azimuth (a : ಠ_ಠ.clutz.goog.math.Coordinate ) : number ;
/**
* Returns the difference between two coordinates as a new
* goog.math.Coordinate.
* @param a A Coordinate.
* @param b A Coordinate.
*/
static difference (a : ಠ_ಠ.clutz.goog.math.Coordinate , b : ಠ_ಠ.clutz.goog.math.Coordinate ) : ಠ_ಠ.clutz.goog.math.Coordinate ;
/**
* Returns the distance between two coordinates.
* @param a A Coordinate.
* @param b A Coordinate.
*/
static distance (a : ಠ_ಠ.clutz.goog.math.Coordinate , b : ಠ_ಠ.clutz.goog.math.Coordinate ) : number ;
/**
* Compares coordinates for equality.
* @param a A Coordinate.
* @param b A Coordinate.
*/
static equals (a : ಠ_ಠ.clutz.goog.math.Coordinate | null , b : ಠ_ಠ.clutz.goog.math.Coordinate | null ) : boolean ;
/**
* Returns the magnitude of a coordinate.
* @param a A Coordinate.
*/
static magnitude (a : ಠ_ಠ.clutz.goog.math.Coordinate ) : number ;
/**
* Returns the squared distance between two coordinates. Squared distances can
* be used for comparisons when the actual value is not required.
*
* Performance note: eliminating the square root is an optimization often used
* in lower-level languages, but the speed difference is not nearly as
* pronounced in JavaScript (only a few percent.)
* @param a A Coordinate.
* @param b A Coordinate.
*/
static squaredDistance (a : ಠ_ಠ.clutz.goog.math.Coordinate , b : ಠ_ಠ.clutz.goog.math.Coordinate ) : number ;
/**
* Returns the sum of two coordinates as a new goog.math.Coordinate.
* @param a A Coordinate.
* @param b A Coordinate.
*/
static sum (a : ಠ_ಠ.clutz.goog.math.Coordinate , b : ಠ_ಠ.clutz.goog.math.Coordinate ) : ಠ_ಠ.clutz.goog.math.Coordinate ;
}
class Coordinate_Instance {
private noStructuralTyping_: any;
/**
* Class for representing coordinates and positions.
* @param opt_x Left, defaults to 0.
* @param opt_y Top, defaults to 0.
*/
constructor (opt_x ? : number , opt_y ? : number ) ;
/**
* X-value
*/
x : number ;
/**
* Y-value
*/
y : number ;
/**
* Rounds the x and y fields to the next larger integer values.
*/
ceil ( ) : ಠ_ಠ.clutz.goog.math.Coordinate ;
/**
* Returns a new copy of the coordinate.
*/
clone ( ) : ಠ_ಠ.clutz.goog.math.Coordinate ;
/**
* Returns whether the specified value is equal to this coordinate.
* @param other Some other value.
*/
equals (other : any ) : boolean ;
/**
* Rounds the x and y fields to the next smaller integer values.
*/
floor ( ) : ಠ_ಠ.clutz.goog.math.Coordinate ;
/**
* Rotates this coordinate clockwise about the origin (or, optionally, the given
* center) by the given angle, in degrees.
* @param degrees The angle by which to rotate this coordinate clockwise about the given center, in degrees.
* @param opt_center The center of rotation. Defaults to (0, 0) if not given.
*/
rotateDegrees (degrees : number , opt_center ? : ಠ_ಠ.clutz.goog.math.Coordinate ) : void ;
/**
* Rotates this coordinate clockwise about the origin (or, optionally, the given
* center) by the given angle, in radians.
* @param radians The angle by which to rotate this coordinate clockwise about the given center, in radians.
* @param opt_center The center of rotation. Defaults to (0, 0) if not given.
*/
rotateRadians (radians : number , opt_center ? : ಠ_ಠ.clutz.goog.math.Coordinate ) : void ;
/**
* Rounds the x and y fields to the nearest integer values.
*/
round ( ) : ಠ_ಠ.clutz.goog.math.Coordinate ;
/**
* Scales this coordinate by the given scale factors. The x and y values are
* scaled by {@code sx} and {@code opt_sy} respectively. If {@code opt_sy}
* is not given, then {@code sx} is used for both x and y.
* @param sx The scale factor to use for the x dimension.
* @param opt_sy The scale factor to use for the y dimension.
*/
scale (sx : number , opt_sy ? : number ) : ಠ_ಠ.clutz.goog.math.Coordinate ;
/**
* Returns a nice string representing the coordinate.
*/
toString ( ) : string ;
/**
* Translates this box by the given offsets. If a {@code goog.math.Coordinate}
* is given, then the x and y values are translated by the coordinate's x and y.
* Otherwise, x and y are translated by {@code tx} and {@code opt_ty}
* respectively.
* @param tx The value to translate x by or the the coordinate to translate this coordinate by.
* @param opt_ty The value to translate y by.
*/
translate (tx : number | ಠ_ಠ.clutz.goog.math.Coordinate | null , opt_ty ? : number ) : ಠ_ಠ.clutz.goog.math.Coordinate ;
}
}
declare module 'goog:goog.math.Coordinate' {
import alias = ಠ_ಠ.clutz.goog.math.Coordinate;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.math {
class ExponentialBackoff extends ExponentialBackoff_Instance {
}
class ExponentialBackoff_Instance {
private noStructuralTyping_: any;
constructor (initialValue : number , maxValue : number , opt_randomFactor ? : number , opt_backoffFactor ? : number , opt_decayFactor ? : number ) ;
/**
* Initiates a backoff.
*/
backoff ( ) : void ;
/**
* Initiates a decay.
*/
decay ( ) : void ;
getBackoffCount ( ) : number ;
getDecayCount ( ) : number ;
getValue ( ) : number ;
/**
* Resets the backoff value to its initial value.
*/
reset ( ) : void ;
}
}
declare module 'goog:goog.math.ExponentialBackoff' {
import alias = ಠ_ಠ.clutz.goog.math.ExponentialBackoff;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.math {
/**
* Class for representing sizes consisting of a width and height. Undefined
* width and height support is deprecated and results in compiler warning.
*/
class Size extends Size_Instance {
/**
* Compares sizes for equality.
* @param a A Size.
* @param b A Size.
*/
static equals (a : ಠ_ಠ.clutz.goog.math.Size | null , b : ಠ_ಠ.clutz.goog.math.Size | null ) : boolean ;
}
class Size_Instance {
private noStructuralTyping_: any;
/**
* Class for representing sizes consisting of a width and height. Undefined
* width and height support is deprecated and results in compiler warning.
* @param width Width.
* @param height Height.
*/
constructor (width : number , height : number ) ;
/**
* Height
*/
height : number ;
/**
* Width
*/
width : number ;
area ( ) : number ;
aspectRatio ( ) : number ;
/**
* Clamps the width and height parameters upward to integer values.
*/
ceil ( ) : ಠ_ಠ.clutz.goog.math.Size ;
clone ( ) : ಠ_ಠ.clutz.goog.math.Size ;
fitsInside (target : ಠ_ಠ.clutz.goog.math.Size ) : boolean ;
/**
* Clamps the width and height parameters downward to integer values.
*/
floor ( ) : ಠ_ಠ.clutz.goog.math.Size ;
getLongest ( ) : number ;
getShortest ( ) : number ;
isEmpty ( ) : boolean ;
perimeter ( ) : number ;
/**
* Rounds the width and height parameters to integer values.
*/
round ( ) : ಠ_ಠ.clutz.goog.math.Size ;
/**
* Scales this size by the given scale factors. The width and height are scaled
* by {@code sx} and {@code opt_sy} respectively. If {@code opt_sy} is not
* given, then {@code sx} is used for both the width and height.
* @param sx The scale factor to use for the width.
* @param opt_sy The scale factor to use for the height.
*/
scale (sx : number , opt_sy ? : number ) : ಠ_ಠ.clutz.goog.math.Size ;
/**
* Uniformly scales the size to perfectly cover the dimensions of a given size.
* If the size is already larger than the target, it will be scaled down to the
* minimum size at which it still covers the entire target. The original aspect
* ratio will be preserved.
*
* This function assumes that both Sizes contain strictly positive dimensions.
* @param target The target size.
*/
scaleToCover (target : ಠ_ಠ.clutz.goog.math.Size ) : ಠ_ಠ.clutz.goog.math.Size ;
/**
* Uniformly scales the size to fit inside the dimensions of a given size. The
* original aspect ratio will be preserved.
*
* This function assumes that both Sizes contain strictly positive dimensions.
* @param target The target size.
*/
scaleToFit (target : ಠ_ಠ.clutz.goog.math.Size ) : ಠ_ಠ.clutz.goog.math.Size ;
/**
* Returns a nice string representing size.
*/
toString ( ) : string ;
}
}
declare module 'goog:goog.math.Size' {
import alias = ಠ_ಠ.clutz.goog.math.Size;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog {
/**
* Decorator around functions that caches the inner function's return values.
*
* To cache parameterless functions, see goog.functions.cacheReturnValue.
* @param f The function to wrap. Its return value may only depend on its arguments and 'this' context. There may be further restrictions on the arguments depending on the capabilities of the serializer used.
* @param opt_serializer A function to serialize f's arguments. It must have the same signature as goog.memoize.simpleSerializer. It defaults to that function.
*/
function memoize (f : Function | null , opt_serializer ? : (a : number , b : GlobalObject | null ) => string ) : Function ;
}
declare module 'goog:goog.memoize' {
import alias = ಠ_ಠ.clutz.goog.memoize;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.net {
/**
* A class for handling browser cookies.
*/
class Cookies extends Cookies_Instance {
/**
* Static constant for the size of cookies. Per the spec, there's a 4K limit
* to the size of a cookie. To make sure users can't break this limit, we
* should truncate long cookies at 3950 bytes, to be extra careful with dumb
* browsers/proxies that interpret 4K as 4000 rather than 4096.
*/
static MAX_COOKIE_LENGTH : number ;
/**
* Getter for the static instance of goog.net.Cookies.
*/
static getInstance ( ) : ಠ_ಠ.clutz.goog.net.Cookies ;
}
class Cookies_Instance {
private noStructuralTyping_: any;
/**
* A class for handling browser cookies.
* @param context The context document to get/set cookies on.
*/
constructor (context : Document | null ) ;
/**
* Removes all cookies for this document. Note that this will only remove
* cookies from the current path and domain. If there are cookies set using a
* subpath and/or another domain these will still be there.
*/
clear ( ) : void ;
/**
* Returns whether there is a cookie with the given name.
* @param key The name of the cookie to test for.
*/
containsKey (key : string ) : boolean ;
/**
* Returns whether there is a cookie with the given value. (This is an O(n)
* operation.)
* @param value The value to check for.
*/
containsValue (value : string ) : boolean ;
/**
* Returns the value for the first cookie with the given name.
* @param name The name of the cookie to get.
* @param opt_default If not found this is returned instead.
*/
get (name : string , opt_default ? : string ) : string | undefined ;
getCount ( ) : number ;
/**
* Gets the names for all the cookies.
*/
getKeys ( ) : string [] | null ;
/**
* Gets the values for all the cookies.
*/
getValues ( ) : string [] | null ;
isEmpty ( ) : boolean ;
/**
* Returns true if cookies are enabled.
*/
isEnabled ( ) : boolean ;
/**
* We do not allow '=', ';', or white space in the name.
*
* NOTE: The following are allowed by this method, but should be avoided for
* cookies handled by the server.
* - any name starting with '$'
* - 'Comment'
* - 'Domain'
* - 'Expires'
* - 'Max-Age'
* - 'Path'
* - 'Secure'
* - 'Version'
* @param name Cookie name.
*/
isValidName (name : string ) : boolean ;
/**
* We do not allow ';' or line break in the value.
*
* Spec does not mention any illegal characters, but in practice semi-colons
* break parsing and line breaks truncate the name.
* @param value Cookie value.
*/
isValidValue (value : string ) : boolean ;
/**
* Removes and expires a cookie.
* @param name The cookie name.
* @param opt_path The path of the cookie, or null to expire a cookie set at the full request path. If not provided, the default is '/' (i.e. path=/).
* @param opt_domain The domain of the cookie, or null to expire a cookie set at the full request host name. If not provided, the default is null (i.e. cookie at full request host name).
*/
remove (name : string , opt_path ? : string , opt_domain ? : string ) : boolean ;
/**
* Sets a cookie. The max_age can be -1 to set a session cookie. To remove and
* expire cookies, use remove() instead.
*
* Neither the {@code name} nor the {@code value} are encoded in any way. It is
* up to the callers of {@code get} and {@code set} (as well as all the other
* methods) to handle any possible encoding and decoding.
* @param name The cookie name.
* @param value The cookie value.
* @param opt_maxAge The max age in seconds (from now). Use -1 to set a session cookie. If not provided, the default is -1 (i.e. set a session cookie).
* @param opt_path The path of the cookie. If not present then this uses the full request path.
* @param opt_domain The domain of the cookie, or null to not specify a domain attribute (browser will use the full request host name). If not provided, the default is null (i.e. let browser use full request host name).
* @param opt_secure Whether the cookie should only be sent over a secure channel.
*/
set (name : string , value : string , opt_maxAge ? : number , opt_path ? : string | null , opt_domain ? : string | null , opt_secure ? : boolean ) : void ;
}
}
declare module 'goog:goog.net.Cookies' {
import alias = ಠ_ಠ.clutz.goog.net.Cookies;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.net {
/**
* A factory of XML http request objects that supports cross domain requests.
* This class should be instantiated and passed as the parameter of a
* goog.net.XhrIo constructor to allow cross-domain requests in every browser.
*/
class CorsXmlHttpFactory extends CorsXmlHttpFactory_Instance {
}
class CorsXmlHttpFactory_Instance extends ಠ_ಠ.clutz.goog.net.XmlHttpFactory_Instance {
createInstance ( ) : ಠ_ಠ.clutz.goog.net.XhrLike | XMLHttpRequest ;
internalGetOptions ( ) : GlobalObject | null ;
}
}
declare module 'goog:goog.net.CorsXmlHttpFactory' {
import alias = ಠ_ಠ.clutz.goog.net.CorsXmlHttpFactory;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.net {
/**
* Default factory to use when creating xhr objects. You probably shouldn't be
* instantiating this directly, but rather using it via goog.net.XmlHttp.
*/
class DefaultXmlHttpFactory extends DefaultXmlHttpFactory_Instance {
}
class DefaultXmlHttpFactory_Instance extends ಠ_ಠ.clutz.goog.net.XmlHttpFactory_Instance {
createInstance ( ) : ಠ_ಠ.clutz.goog.net.XhrLike | XMLHttpRequest ;
internalGetOptions ( ) : GlobalObject | null ;
}
}
declare module 'goog:goog.net.DefaultXmlHttpFactory' {
import alias = ಠ_ಠ.clutz.goog.net.DefaultXmlHttpFactory;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.net {
/**
* Error codes
*/
enum ErrorCode {
ABORT ,
ACCESS_DENIED ,
CUSTOM_ERROR ,
EXCEPTION ,
FF_SILENT_ERROR ,
FILE_NOT_FOUND ,
HTTP_ERROR ,
NO_ERROR ,
OFFLINE ,
TIMEOUT ,
}
}
declare module 'goog:goog.net.ErrorCode' {
import alias = ಠ_ಠ.clutz.goog.net.ErrorCode;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.net {
/**
* Event names for network events
*/
type EventType = string &{clutzEnumBrand: never} ;
var EventType : {
ABORT : EventType ,
COMPLETE : EventType ,
DOWNLOAD_PROGRESS : EventType ,
ERROR : EventType ,
INCREMENTAL_DATA : EventType ,
PROGRESS : EventType ,
READY : EventType ,
READY_STATE_CHANGE : EventType ,
SUCCESS : EventType ,
TIMEOUT : EventType ,
UPLOAD_PROGRESS : EventType ,
};
}
declare module 'goog:goog.net.EventType' {
import alias = ಠ_ಠ.clutz.goog.net.EventType;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.net {
/**
* HTTP Status Codes defined in RFC 2616 and RFC 6585.
*/
enum HttpStatus {
ACCEPTED ,
BAD_GATEWAY ,
BAD_REQUEST ,
CONFLICT ,
CONTINUE ,
CREATED ,
EXPECTATION_FAILED ,
FORBIDDEN ,
FOUND ,
GATEWAY_TIMEOUT ,
GONE ,
HTTP_VERSION_NOT_SUPPORTED ,
INTERNAL_SERVER_ERROR ,
LENGTH_REQUIRED ,
METHOD_NOT_ALLOWED ,
MOVED_PERMANENTLY ,
MULTIPLE_CHOICES ,
NETWORK_AUTHENTICATION_REQUIRED ,
NON_AUTHORITATIVE_INFORMATION ,
NOT_ACCEPTABLE ,
NOT_FOUND ,
NOT_IMPLEMENTED ,
NOT_MODIFIED ,
NO_CONTENT ,
OK ,
PARTIAL_CONTENT ,
PAYMENT_REQUIRED ,
PRECONDITION_FAILED ,
PRECONDITION_REQUIRED ,
PROXY_AUTHENTICATION_REQUIRED ,
QUIRK_IE_NO_CONTENT ,
REQUEST_ENTITY_TOO_LARGE ,
REQUEST_HEADER_FIELDS_TOO_LARGE ,
REQUEST_RANGE_NOT_SATISFIABLE ,
REQUEST_TIMEOUT ,
REQUEST_URI_TOO_LONG ,
RESET_CONTENT ,
SEE_OTHER ,
SERVICE_UNAVAILABLE ,
SWITCHING_PROTOCOLS ,
TEMPORARY_REDIRECT ,
TOO_MANY_REQUESTS ,
UNAUTHORIZED ,
UNSUPPORTED_MEDIA_TYPE ,
USE_PROXY ,
}
}
declare module 'goog:goog.net.HttpStatus' {
import alias = ಠ_ಠ.clutz.goog.net.HttpStatus;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.net {
/**
* An adapter around Internet Explorer's XDomainRequest object that makes it
* look like a standard XMLHttpRequest. This can be used instead of
* XMLHttpRequest to support CORS.
*/
class IeCorsXhrAdapter extends IeCorsXhrAdapter_Instance {
}
class IeCorsXhrAdapter_Instance implements ಠ_ಠ.clutz.goog.net.XhrLike {
private noStructuralTyping_: any;
/**
* The simulated ready state change callback function.
*/
onreadystatechange : Function | null ;
/**
* The simulated ready state.
*/
readyState : number ;
/**
* The simulated response text parameter.
*/
responseText : string ;
responseXML : null ;
/**
* The simulated status code
*/
status : number ;
statusText : null ;
abort ( ) : void ;
/**
* Returns the response headers from the server. This implemntation only returns
* the 'content-type' header.
*/
getAllResponseHeaders ( ) : string ;
/**
* Returns the value of the response header identified by key. This
* implementation only supports the 'content-type' header.
* @param key The request header to fetch. If this parameter is set to 'content-type' (case-insensitive), this function returns the value of the 'content-type' request header. If this parameter is set to any other value, this function always returns an empty string.
*/
getResponseHeader (key : string ) : string ;
/**
* Opens a connection to the provided URL.
* @param method The HTTP method to use. Valid methods include GET and POST.
* @param url The URL to contact. The authority of this URL must match the authority of the current page's URL (e.g. http or https).
* @param opt_async Whether the request is asynchronous, defaulting to true. XDomainRequest does not support syncronous requests, so setting it to false will actually raise an exception.
*/
open (method : string , url : string , opt_async ? : boolean | null , a ? : string | null , b ? : string | null ) : void ;
/**
* Sends the request to the remote server. Before calling this function, always
* call {@link open}.
* @param opt_content The content to send as POSTDATA, if any. Only string data is supported by this implementation.
*/
send (opt_content ? : ArrayBuffer | null | ArrayBufferView | Blob | Document | FormData | string ) : void ;
/**
* Sets a request header to send to the remote server. Because this
* implementation does not support request headers, this function does nothing.
* @param key The name of the HTTP header to set. Ignored.
* @param value The value to set for the HTTP header. Ignored.
*/
setRequestHeader (key : string , value : string ) : void ;
}
}
declare module 'goog:goog.net.IeCorsXhrAdapter' {
import alias = ಠ_ಠ.clutz.goog.net.IeCorsXhrAdapter;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.net {
/**
* An xhr factory subclass which can be constructed using two factory methods.
* This exists partly to allow the preservation of goog.net.XmlHttp.setFactory()
* with an unchanged signature.
*/
class WrapperXmlHttpFactory extends WrapperXmlHttpFactory_Instance {
}
class WrapperXmlHttpFactory_Instance extends ಠ_ಠ.clutz.goog.net.XmlHttpFactory_Instance {
/**
* An xhr factory subclass which can be constructed using two factory methods.
* This exists partly to allow the preservation of goog.net.XmlHttp.setFactory()
* with an unchanged signature.
* @param xhrFactory A function which returns a new XHR object.
* @param optionsFactory A function which returns the options associated with xhr objects from this factory.
*/
constructor (xhrFactory : ( ) => ಠ_ಠ.clutz.goog.net.XhrLike | XMLHttpRequest , optionsFactory : ( ) => GlobalObject ) ;
createInstance ( ) : ಠ_ಠ.clutz.goog.net.XhrLike | XMLHttpRequest ;
getOptions ( ) : GlobalObject | null ;
}
}
declare module 'goog:goog.net.WrapperXmlHttpFactory' {
import alias = ಠ_ಠ.clutz.goog.net.WrapperXmlHttpFactory;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.net {
/**
* Basic class for handling XMLHttpRequests.
*/
class XhrIo extends XhrIo_Instance {
/**
* The Content-Transfer-Encoding HTTP header name
*/
static CONTENT_TRANSFER_ENCODING : string ;
/**
* The Content-Type HTTP header name
*/
static CONTENT_TYPE_HEADER : string ;
/**
* The Content-Type HTTP header value for a url-encoded form
*/
static FORM_CONTENT_TYPE : string ;
/**
* The pattern matching the 'http' and 'https' URI schemes
*/
static HTTP_SCHEME_PATTERN : RegExp ;
/**
* The methods that typically come along with form data. We set different
* headers depending on whether the HTTP action is one of these.
*/
static METHODS_WITH_FORM_DATA : string [] ;
/**
* Disposes all non-disposed instances of goog.net.XhrIo created by
* {@link goog.net.XhrIo.send}.
* {@link goog.net.XhrIo.send} cleans up the goog.net.XhrIo instance
* it creates when the request completes or fails. However, if
* the request never completes, then the goog.net.XhrIo is not disposed.
* This can occur if the window is unloaded before the request completes.
* We could have {@link goog.net.XhrIo.send} return the goog.net.XhrIo
* it creates and make the client of {@link goog.net.XhrIo.send} be
* responsible for disposing it in this case. However, this makes things
* significantly more complicated for the client, and the whole point
* of {@link goog.net.XhrIo.send} is that it's simple and easy to use.
* Clients of {@link goog.net.XhrIo.send} should call
* {@link goog.net.XhrIo.cleanup} when doing final
* cleanup on window unload.
*/
static cleanup ( ) : void ;
/**
* Installs exception protection for all entry point introduced by
* goog.net.XhrIo instances which are not protected by
* {@link goog.debug.ErrorHandler#protectWindowSetTimeout},
* {@link goog.debug.ErrorHandler#protectWindowSetInterval}, or
* {@link goog.events.protectBrowserEventEntryPoint}.
* @param errorHandler Error handler with which to protect the entry point(s).
*/
static protectEntryPoints (errorHandler : any | null ) : void ;
/**
* Static send that creates a short lived instance of XhrIo to send the
* request.
* @param url Uri to make request to.
* @param opt_callback Callback function for when request is complete.
* @param opt_method Send method, default: GET.
* @param opt_content Body data.
* @param opt_headers Map of headers to add to the request.
* @param opt_timeoutInterval Number of milliseconds after which an incomplete request will be aborted; 0 means no timeout is set.
* @param opt_withCredentials Whether to send credentials with the request. Default to false. See {@link goog.net.XhrIo#setWithCredentials}.
*/
static send (url : string | any | null , opt_callback ? : ( (a : any ) => any ) | null , opt_method ? : string , opt_content ? : ArrayBuffer | null | ArrayBufferView | Blob | Document | FormData | string , opt_headers ? : GlobalObject | null , opt_timeoutInterval ? : number , opt_withCredentials ? : boolean ) : ಠ_ಠ.clutz.goog.net.XhrIo ;
}
class XhrIo_Instance extends ಠ_ಠ.clutz.goog.events.EventTarget_Instance {
/**
* Basic class for handling XMLHttpRequests.
* @param opt_xmlHttpFactory Factory to use when creating XMLHttpRequest objects.
*/
constructor (opt_xmlHttpFactory ? : ಠ_ಠ.clutz.goog.net.XmlHttpFactory | null ) ;
/**
* Map of default headers to add to every request, use:
* XhrIo.headers.set(name, value)
*/
headers : ಠ_ಠ.clutz.goog.structs.Map < any , any > ;
/**
* Abort the current XMLHttpRequest
* @param opt_failureCode Optional error code to use - defaults to ABORT.
*/
abort (opt_failureCode ? : ಠ_ಠ.clutz.goog.net.ErrorCode ) : void ;
/**
* Creates a new XHR object.
*/
createXhr ( ) : ಠ_ಠ.clutz.goog.net.XhrLike | XMLHttpRequest ;
/**
* Nullifies all callbacks to reduce risks of leaks.
*/
disposeInternal ( ) : void ;
/**
* Gets the text of all the headers in the response.
* Will only return correct result when called from the context of a callback
* and the request has completed.
*/
getAllResponseHeaders ( ) : string ;
/**
* Gets the text of all the headers in the response. As opposed to
* {@link #getAllResponseHeaders}, this method does not require that the request
* has completed.
*/
getAllStreamingResponseHeaders ( ) : string ;
/**
* Get the last error message
*/
getLastError ( ) : string ;
/**
* Get the last error message
*/
getLastErrorCode ( ) : ಠ_ಠ.clutz.goog.net.ErrorCode ;
/**
* Get the last Uri that was requested
*/
getLastUri ( ) : string ;
/**
* Gets whether progress events are enabled.
*/
getProgressEventsEnabled ( ) : boolean ;
/**
* Get the readystate from the Xhr object
* Will only return correct result when called from the context of a callback
*/
getReadyState ( ) : ಠ_ಠ.clutz.goog.net.XmlHttp.ReadyState ;
/**
* Get the response as the type specificed by {@link #setResponseType}. At time
* of writing, this is only directly supported in very recent versions of WebKit
* (10.0.612.1 dev and later). If the field is not supported directly, we will
* try to emulate it.
*
* Emulating the response means following the rules laid out at
* http://www.w3.org/TR/XMLHttpRequest/#the-response-attribute
*
* On browsers with no support for this (Chrome < 10, Firefox < 4, etc), only
* response types of DEFAULT or TEXT may be used, and the response returned will
* be the text response.
*
* On browsers with Mozilla's draft support for array buffers (Firefox 4, 5),
* only response types of DEFAULT, TEXT, and ARRAY_BUFFER may be used, and the
* response returned will be either the text response or the Mozilla
* implementation of the array buffer response.
*
* On browsers will full support, any valid response type supported by the
* browser may be used, and the response provided by the browser will be
* returned.
*/
getResponse ( ) : any ;
/**
* Get the response body from the Xhr object. This property is only available
* in IE since version 7 according to MSDN:
* http://msdn.microsoft.com/en-us/library/ie/ms534368(v=vs.85).aspx
* Will only return correct result when called from the context of a callback.
*
* One option is to construct a VBArray from the returned object and convert
* it to a JavaScript array using the toArray method:
* {@code (new window['VBArray'](xhrIo.getResponseBody())).toArray()}
* This will result in an array of numbers in the range of [0..255]
*
* Another option is to use the VBScript CStr method to convert it into a
* string as outlined in http://stackoverflow.com/questions/1919972
*/
getResponseBody ( ) : GlobalObject | null ;
/**
* Get the value of the response-header with the given name from the Xhr object
* Will only return correct result when called from the context of a callback
* and the request has completed
* @param key The name of the response-header to retrieve.
*/
getResponseHeader (key : string ) : string | undefined ;
/**
* Returns all response headers as a key-value map.
* Multiple values for the same header key can be combined into one,
* separated by a comma and a space.
* Note that the native getResponseHeader method for retrieving a single header
* does a case insensitive match on the header name. This method does not
* include any case normalization logic, it will just return a key-value
* representation of the headers.
* See: http://www.w3.org/TR/XMLHttpRequest/#the-getresponseheader()-method
*/
getResponseHeaders ( ) : { [ key: string ]: string } ;
/**
* Get the response and evaluates it as JSON from the Xhr object
* Will only return correct result when called from the context of a callback
* @param opt_xssiPrefix Optional XSSI prefix string to use for stripping of the response before parsing. This needs to be set only if your backend server prepends the same prefix string to the JSON response.
*/
getResponseJson (opt_xssiPrefix ? : string ) : GlobalObject | null | undefined ;
/**
* Get the response text from the Xhr object
* Will only return correct result when called from the context of a callback.
*/
getResponseText ( ) : string ;
/**
* Gets the desired type for the response.
*/
getResponseType ( ) : ಠ_ಠ.clutz.goog.net.XhrIo.ResponseType ;
/**
* Get the response XML from the Xhr object
* Will only return correct result when called from the context of a callback.
*/
getResponseXml ( ) : Document | null ;
/**
* Get the status from the Xhr object
* Will only return correct result when called from the context of a callback
*/
getStatus ( ) : number ;
/**
* Get the status text from the Xhr object
* Will only return correct result when called from the context of a callback
*/
getStatusText ( ) : string ;
/**
* Get the value of the response-header with the given name from the Xhr object.
* As opposed to {@link #getResponseHeader}, this method does not require that
* the request has completed.
* @param key The name of the response-header to retrieve.
*/
getStreamingResponseHeader (key : string ) : string | null ;
/**
* Returns the number of milliseconds after which an incomplete request will be
* aborted, or 0 if no timeout is set.
*/
getTimeoutInterval ( ) : number ;
/**
* Gets whether a "credentialed" request is to be sent.
*/
getWithCredentials ( ) : boolean ;
isActive ( ) : boolean ;
isComplete ( ) : boolean ;
isSuccess ( ) : boolean ;
/**
* Instance send that actually uses XMLHttpRequest to make a server call.
* @param url Uri to make request to.
* @param opt_method Send method, default: GET.
* @param opt_content Body data.
* @param opt_headers Map of headers to add to the request.
*/
send (url : string | any | null , opt_method ? : string , opt_content ? : ArrayBuffer | null | ArrayBufferView | Blob | Document | FormData | string , opt_headers ? : GlobalObject | null ) : void ;
/**
* Sets whether progress events are enabled for this request. Note
* that progress events require pre-flight OPTIONS request handling
* for CORS requests, and may cause trouble with older browsers. See
* progressEventsEnabled_ for details.
* @param enabled Whether progress events should be enabled.
*/
setProgressEventsEnabled (enabled : boolean ) : void ;
/**
* Sets the desired type for the response. At time of writing, this is only
* supported in very recent versions of WebKit (10.0.612.1 dev and later).
*
* If this is used, the response may only be accessed via {@link #getResponse}.
* @param type The desired type for the response.
*/
setResponseType (type : ಠ_ಠ.clutz.goog.net.XhrIo.ResponseType ) : void ;
/**
* Sets the number of milliseconds after which an incomplete request will be
* aborted and a {@link goog.net.EventType.TIMEOUT} event raised; 0 means no
* timeout is set.
* @param ms Timeout interval in milliseconds; 0 means none.
*/
setTimeoutInterval (ms : number ) : void ;
/**
* Sets whether a "credentialed" request that is aware of cookie and
* authentication information should be made. This option is only supported by
* browsers that support HTTP Access Control. As of this writing, this option
* is not supported in IE.
* @param withCredentials Whether this should be a "credentialed" request.
*/
setWithCredentials (withCredentials : boolean ) : void ;
}
}
declare module 'goog:goog.net.XhrIo' {
import alias = ಠ_ಠ.clutz.goog.net.XhrIo;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.net.XhrIo {
/**
* Response types that may be requested for XMLHttpRequests.
*/
type ResponseType = string &{clutzEnumBrand: never} ;
var ResponseType : {
ARRAY_BUFFER : ResponseType ,
BLOB : ResponseType ,
DEFAULT : ResponseType ,
DOCUMENT : ResponseType ,
TEXT : ResponseType ,
};
}
declare module 'goog:goog.net.XhrIo.ResponseType' {
import alias = ಠ_ಠ.clutz.goog.net.XhrIo.ResponseType;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.net {
/**
* Interface for the common parts of XMLHttpRequest.
*
* Mostly copied from externs/w3c_xml.js.
*/
interface XhrLike {
abort ( ) : void ;
getAllResponseHeaders ( ) : string ;
getResponseHeader (header : string ) : string ;
onreadystatechange ? : ( ( ) => any ) | null ;
open (method : string , url : string , opt_async ? : boolean | null , opt_user ? : string | null , opt_password ? : string | null ) : void ;
readyState : number ;
responseText : string ;
responseXML : Document | null ;
send (opt_data ? : ArrayBuffer | null | ArrayBufferView | Blob | Document | FormData | string ) : void ;
setRequestHeader (header : string , value : string ) : void ;
status : number ;
statusText : string ;
}
}
declare namespace ಠ_ಠ.clutz.goog.net.XhrLike {
type OrNative = ಠ_ಠ.clutz.goog.net.XhrLike | XMLHttpRequest ;
}
declare module 'goog:goog.net.XhrLike' {
import alias = ಠ_ಠ.clutz.goog.net.XhrLike;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.net {
/**
* Static class for creating XMLHttpRequest objects.
*/
function XmlHttp ( ) : ಠ_ಠ.clutz.goog.net.XhrLike | XMLHttpRequest ;
}
declare module 'goog:goog.net.XmlHttp' {
import alias = ಠ_ಠ.clutz.goog.net.XmlHttp;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.net.XmlHttp {
/**
* Type of options that an XmlHttp object can have.
*/
enum OptionType {
LOCAL_REQUEST_ERROR ,
USE_NULL_FUNCTION ,
}
}
declare module 'goog:goog.net.XmlHttp.OptionType' {
import alias = ಠ_ಠ.clutz.goog.net.XmlHttp.OptionType;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.net.XmlHttp {
/**
* Status constants for XMLHTTP, matches:
* https://msdn.microsoft.com/en-us/library/ms534361(v=vs.85).aspx
*/
enum ReadyState {
COMPLETE ,
INTERACTIVE ,
LOADED ,
LOADING ,
UNINITIALIZED ,
}
}
declare module 'goog:goog.net.XmlHttp.ReadyState' {
import alias = ಠ_ಠ.clutz.goog.net.XmlHttp.ReadyState;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.net.XmlHttpDefines {
var ASSUME_NATIVE_XHR : boolean ;
}
declare module 'goog:goog.net.XmlHttpDefines' {
import alias = ಠ_ಠ.clutz.goog.net.XmlHttpDefines;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.net {
/**
* Abstract base class for an XmlHttpRequest factory.
*/
class XmlHttpFactory extends XmlHttpFactory_Instance {
}
class XmlHttpFactory_Instance {
private noStructuralTyping_: any;
createInstance ( ) : ಠ_ಠ.clutz.goog.net.XhrLike | XMLHttpRequest ;
getOptions ( ) : GlobalObject | null ;
/**
* Override this method in subclasses to preserve the caching offered by
* getOptions().
*/
internalGetOptions ( ) : GlobalObject | null ;
}
}
declare module 'goog:goog.net.XmlHttpFactory' {
import alias = ಠ_ಠ.clutz.goog.net.XmlHttpFactory;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.net {
/**
* A static default instance.
*/
var cookies : ಠ_ಠ.clutz.goog.net.Cookies ;
}
declare module 'goog:goog.net.cookies' {
import alias = ಠ_ಠ.clutz.goog.net.cookies;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.object {
/**
* Adds a key-value pair to the object. Throws an exception if the key is
* already in use. Use set if you want to change an existing pair.
* @param obj The object to which to add the key-value pair.
* @param key The key to add.
* @param val The value to add.
*/
function add < K , V > (obj : { [ /* warning: coerced from K */ key: string ]: V } | null , key : string , val : V ) : void ;
/**
* Removes all key value pairs from the object/map/hash.
* @param obj The object to clear.
*/
function clear (obj : GlobalObject | null ) : void ;
/**
* Returns a shallow clone of the object.
* @param obj Object to clone.
*/
function clone < K , V > (obj : { [ /* warning: coerced from K */ key: string ]: V } | null ) : { [ /* warning: coerced from K */ key: string ]: V } ;
/**
* Whether the object/hash/map contains the given object as a value.
* An alias for goog.object.containsValue(obj, val).
* @param obj The object in which to look for val.
* @param val The object for which to check.
*/
function contains < K , V > (obj : { [ /* warning: coerced from K */ key: string ]: V } | null , val : V ) : boolean ;
/**
* Whether the object/map/hash contains the given key.
* @param obj The object in which to look for key.
* @param key The key for which to check.
*/
function containsKey (obj : GlobalObject | null , key : any ) : boolean ;
/**
* Whether the object/map/hash contains the given value. This is O(n).
* @param obj The object in which to look for val.
* @param val The value for which to check.
*/
function containsValue < K , V > (obj : { [ /* warning: coerced from K */ key: string ]: V } | null , val : V ) : boolean ;
/**
* Creates a new object built from the key-value pairs provided as arguments.
* @param var_args If only one argument is provided and it is an array then this is used as the arguments, otherwise even arguments are used as the property names and odd arguments are used as the property values.
*/
function create ( ...var_args : any [] ) : GlobalObject ;
/**
* Creates an immutable view of the underlying object, if the browser
* supports immutable objects.
*
* In default mode, writes to this view will fail silently. In strict mode,
* they will throw an error.
* @param obj An object.
*/
function createImmutableView < K , V > (obj : { [ /* warning: coerced from K */ key: string ]: V } ) : { [ /* warning: coerced from K */ key: string ]: V } ;
/**
* Creates a new object where the property names come from the arguments but
* the value is always set to true
* @param var_args If only one argument is provided and it is an array then this is used as the arguments, otherwise the arguments are used as the property names.
*/
function createSet ( ...var_args : any [] ) : GlobalObject ;
/**
* Compares two objects for equality using === on the values.
*/
function equals < K , V > (a : { [ /* warning: coerced from K */ key: string ]: V } , b : { [ /* warning: coerced from K */ key: string ]: V } ) : boolean ;
/**
* Calls a function for each element in an object/map/hash. If
* all calls return true, returns true. If any call returns false, returns
* false at this point and does not continue to check the remaining elements.
* @param obj The object to check.
* @param f The function to call for every element. This function takes 3 arguments (the value, the key and the object) and should return a boolean.
* @param opt_obj This is used as the 'this' object within f.
*/
function every < T , K , V > (obj : { [ /* warning: coerced from K */ key: string ]: V } | null , f : ( (a : V , b : any , c : { [ /* warning: coerced from K */ key: string ]: V } | null ) => boolean ) | null , opt_obj ? : T ) : boolean ;
/**
* Extends an object with another object.
* This operates 'in-place'; it does not create a new Object.
*
* Example:
* var o = {};
* goog.object.extend(o, {a: 0, b: 1});
* o; // {a: 0, b: 1}
* goog.object.extend(o, {b: 2, c: 3});
* o; // {a: 0, b: 2, c: 3}
* @param target The object to modify. Existing properties will be overwritten if they are also present in one of the objects in {@code var_args}.
* @param var_args The objects from which values will be copied.
*/
function extend (target : GlobalObject | null , ...var_args : ( GlobalObject | null | undefined ) [] ) : void ;
/**
* Calls a function for each element in an object/map/hash. If that call returns
* true, adds the element to a new object.
* @param obj The object over which to iterate.
* @param f The function to call for every element. This function takes 3 arguments (the value, the key and the object) and should return a boolean. If the return value is true the element is added to the result object. If it is false the element is not included.
* @param opt_obj This is used as the 'this' object within f.
*/
function filter < T , K , V > (obj : { [ /* warning: coerced from K */ key: string ]: V } | null , f : (a : V , b : any , c : { [ /* warning: coerced from K */ key: string ]: V } | null ) => boolean , opt_obj ? : T ) : { [ /* warning: coerced from K */ key: string ]: V } ;
/**
* Searches an object for an element that satisfies the given condition and
* returns its key.
* @param obj The object to search in.
* @param f The function to call for every element. Takes 3 arguments (the value, the key and the object) and should return a boolean.
* @param opt_this An optional "this" context for the function.
*/
function findKey < T , K , V > (obj : { [ /* warning: coerced from K */ key: string ]: V } | null , f : (a : V , b : string , c : { [ /* warning: coerced from K */ key: string ]: V } | null ) => boolean , opt_this ? : T ) : string | undefined ;
/**
* Searches an object for an element that satisfies the given condition and
* returns its value.
* @param obj The object to search in.
* @param f The function to call for every element. Takes 3 arguments (the value, the key and the object) and should return a boolean.
* @param opt_this An optional "this" context for the function.
*/
function findValue < T , K , V > (obj : { [ /* warning: coerced from K */ key: string ]: V } | null , f : (a : V , b : string , c : { [ /* warning: coerced from K */ key: string ]: V } | null ) => boolean , opt_this ? : T ) : V ;
/**
* Calls a function for each element in an object/map/hash.
* @param obj The object over which to iterate.
* @param f The function to call for every element. This function takes 3 arguments (the value, the key and the object) and the return value is ignored.
* @param opt_obj This is used as the 'this' object within f.
*/
function forEach < T , K , V > (obj : { [ /* warning: coerced from K */ key: string ]: V } | null , f : (a : V , b : any , c : { [ /* warning: coerced from K */ key: string ]: V } | null ) => any , opt_obj ? : T ) : void ;
/**
* Returns the value for the given key.
* @param obj The object from which to get the value.
* @param key The key for which to get the value.
* @param opt_val The value to return if no item is found for the given key (default is undefined).
*/
function get < K , V , R > (obj : { [ /* warning: coerced from K */ key: string ]: V } | null , key : string , opt_val ? : R ) : V | R | undefined ;
/**
* Get all properties names on a given Object regardless of enumerability.
*
* <p> If the browser does not support {@code Object.getOwnPropertyNames} nor
* {@code Object.getPrototypeOf} then this is equivalent to using {@code
* goog.object.getKeys}
* @param obj The object to get the properties of.
* @param opt_includeObjectPrototype Whether properties defined on {@code Object.prototype} should be included in the result.
* @param opt_includeFunctionPrototype Whether properties defined on {@code Function.prototype} should be included in the result.
*/
function getAllPropertyNames (obj : GlobalObject | null , opt_includeObjectPrototype ? : boolean , opt_includeFunctionPrototype ? : boolean ) : string [] ;
/**
* Returns one key from the object map, if any exists.
* For map literals the returned key will be the first one in most of the
* browsers (a know exception is Konqueror).
* @param obj The object to pick a key from.
*/
function getAnyKey (obj : GlobalObject | null ) : string | undefined ;
/**
* Returns one value from the object map, if any exists.
* For map literals the returned value will be the first one in most of the
* browsers (a know exception is Konqueror).
* @param obj The object to pick a value from.
*/
function getAnyValue < K , V > (obj : { [ /* warning: coerced from K */ key: string ]: V } | null ) : V | undefined ;
/**
* Returns the number of key-value pairs in the object map.
* @param obj The object for which to get the number of key-value pairs.
*/
function getCount (obj : GlobalObject | null ) : number ;
/**
* Returns the keys of the object/map/hash.
* @param obj The object from which to get the keys.
*/
function getKeys (obj : GlobalObject | null ) : string [] ;
/**
* Get a value from an object multiple levels deep. This is useful for
* pulling values from deeply nested objects, such as JSON responses.
* Example usage: getValueByKeys(jsonObj, 'foo', 'entries', 3)
* @param obj An object to get the value from. Can be array-like.
* @param var_args A number of keys (as strings, or numbers, for array-like objects). Can also be specified as a single array of keys.
*/
function getValueByKeys (obj : GlobalObject , ...var_args : ( string | number | ArrayLike < number | string > | undefined ) [] ) : any ;
/**
* Returns the values of the object/map/hash.
* @param obj The object from which to get the values.
*/
function getValues < K , V > (obj : { [ /* warning: coerced from K */ key: string ]: V } | null ) : V [] ;
/**
* Whether two values are not observably distinguishable. This
* correctly detects that 0 is not the same as -0 and two NaNs are
* practically equivalent.
*
* The implementation is as suggested by harmony:egal proposal.
* @param v The first value to compare.
* @param v2 The second value to compare.
*/
function is (v : any , v2 : any ) : boolean ;
/**
* Whether the object/map/hash is empty.
* @param obj The object to test.
*/
function isEmpty (obj : GlobalObject | null ) : boolean ;
function isImmutableView (obj : GlobalObject ) : boolean ;
/**
* For every element in an object/map/hash calls a function and inserts the
* result into a new object.
* @param obj The object over which to iterate.
* @param f The function to call for every element. This function takes 3 arguments (the value, the key and the object) and should return something. The result will be inserted into a new object.
* @param opt_obj This is used as the 'this' object within f.
*/
function map < T , K , V , R > (obj : { [ /* warning: coerced from K */ key: string ]: V } | null , f : (a : V , b : any , c : { [ /* warning: coerced from K */ key: string ]: V } | null ) => R , opt_obj ? : T ) : { [ /* warning: coerced from K */ key: string ]: R } ;
/**
* Removes a key-value pair based on the key.
* @param obj The object from which to remove the key.
* @param key The key to remove.
*/
function remove (obj : GlobalObject | null , key : any ) : boolean ;
/**
* Adds a key-value pair to the object/map/hash.
* @param obj The object to which to add the key-value pair.
* @param key The key to add.
* @param value The value to add.
*/
function set < K , V > (obj : { [ /* warning: coerced from K */ key: string ]: V } | null , key : string , value : V ) : void ;
/**
* Adds a key-value pair to the object/map/hash if it doesn't exist yet.
* @param obj The object to which to add the key-value pair.
* @param key The key to add.
* @param value The value to add if the key wasn't present.
*/
function setIfUndefined < K , V > (obj : { [ /* warning: coerced from K */ key: string ]: V } | null , key : string , value : V ) : V ;
/**
* Sets a key and value to an object if the key is not set. The value will be
* the return value of the given function. If the key already exists, the
* object will not be changed and the function will not be called (the function
* will be lazily evaluated -- only called if necessary).
*
* This function is particularly useful for use with a map used a as a cache.
* @param obj The object to which to add the key-value pair.
* @param key The key to add.
* @param f The value to add if the key wasn't present.
*/
function setWithReturnValueIfNotSet < K , V > (obj : { [ /* warning: coerced from K */ key: string ]: V } , key : string , f : ( ) => V ) : V ;
/**
* Calls a function for each element in an object/map/hash. If any
* call returns true, returns true (without checking the rest). If
* all calls return false, returns false.
* @param obj The object to check.
* @param f The function to call for every element. This function takes 3 arguments (the value, the key and the object) and should return a boolean.
* @param opt_obj This is used as the 'this' object within f.
*/
function some < T , K , V > (obj : { [ /* warning: coerced from K */ key: string ]: V } | null , f : (a : V , b : any , c : { [ /* warning: coerced from K */ key: string ]: V } | null ) => boolean , opt_obj ? : T ) : boolean ;
/**
* Returns a new object in which all the keys and values are interchanged
* (keys become values and values become keys). If multiple keys map to the
* same value, the chosen transposed value is implementation-dependent.
* @param obj The object to transpose.
*/
function transpose (obj : GlobalObject | null ) : GlobalObject ;
/**
* Clones a value. The input may be an Object, Array, or basic type. Objects and
* arrays will be cloned recursively.
*
* WARNINGS:
* <code>goog.object.unsafeClone</code> does not detect reference loops. Objects
* that refer to themselves will cause infinite recursion.
*
* <code>goog.object.unsafeClone</code> is unaware of unique identifiers, and
* copies UIDs created by <code>getUid</code> into cloned results.
* @param obj The value to clone.
*/
function unsafeClone < T > (obj : T ) : T ;
}
declare module 'goog:goog.object' {
import alias = ಠ_ಠ.clutz.goog.object;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.promise {
/**
* Resolver interface for promises. The resolver is a convenience interface that
* bundles the promise and its associated resolve and reject functions together,
* for cases where the resolver needs to be persisted internally.
*/
interface Resolver < TYPE > {
/**
* The promise that created this resolver.
*/
promise : ಠ_ಠ.clutz.goog.Promise < any , any > ;
/**
* Rejects this resolver with the specified reason.
*/
reject (a ? : any ) : void ;
/**
* Resolves this resolver with the specified value.
*/
resolve (a ? : TYPE | null | { then : any } ) : any ;
}
}
declare module 'goog:goog.promise.Resolver' {
import alias = ಠ_ಠ.clutz.goog.promise.Resolver;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.reflect {
/**
* Retrieves a value from a cache given a key. The compiler provides special
* consideration for this call such that it is generally considered side-effect
* free. However, if the {@code opt_keyFn} or {@code valueFn} have side-effects
* then the entire call is considered to have side-effects.
*
* Conventionally storing the value on the cache would be considered a
* side-effect and preclude unused calls from being pruned, ie. even if
* the value was never used, it would still always be stored in the cache.
*
* Providing a side-effect free {@code valueFn} and {@code opt_keyFn}
* allows unused calls to {@code goog.reflect.cache} to be pruned.
* @param cacheObj The object that contains the cached values.
* @param key The key to lookup in the cache. If it is not string or number then a {@code opt_keyFn} should be provided. The key is also used as the parameter to the {@code valueFn}.
* @param valueFn The value provider to use to calculate the value to store in the cache. This function should be side-effect free to take advantage of the optimization.
* @param opt_keyFn The key provider to determine the cache map key. This should be used if the given key is not a string or number. If not provided then the given key is used. This function should be side-effect free to take advantage of the optimization.
*/
function cache < K , V > (cacheObj : { [ /* warning: coerced from K */ key: string ]: V } , key : any , valueFn : (a : any ) => V , opt_keyFn ? : (a : any ) => K ) : V ;
/**
* Check if a property can be accessed without throwing an exception.
* @param obj The owner of the property.
* @param prop The property name.
*/
function canAccessProperty (obj : GlobalObject | null , prop : string ) : boolean ;
/**
* Syntax for object literal casts.
* @param type Type to cast to.
* @param object Object literal to cast.
*/
function object (type : Function , object : GlobalObject | null ) : GlobalObject | null ;
/**
* Syntax for renaming property strings.
* @param prop Name of the property
* @param object Instance of the object whose type will be used for renaming
*/
function objectProperty (prop : string , object : GlobalObject ) : string ;
/**
* To assert to the compiler that an operation is needed when it would
* otherwise be stripped. For example:
* <code>
* // Force a layout
* goog.reflect.sinkValue(dialog.offsetHeight);
* </code>
*/
function sinkValue < T > (x : T ) : T ;
}
declare module 'goog:goog.reflect' {
import alias = ಠ_ಠ.clutz.goog.reflect;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.string {
var DETECT_DOUBLE_ESCAPING : boolean ;
var FORCE_NON_DOM_HTML_UNESCAPING : boolean ;
/**
* Concatenates string expressions. This is useful
* since some browsers are very inefficient when it comes to using plus to
* concat strings. Be careful when using null and undefined here since
* these will not be included in the result. If you need to represent these
* be sure to cast the argument to a String first.
* For example:
* <pre>buildString('a', 'b', 'c', 'd') -> 'abcd'
* buildString(null, undefined) -> ''
* </pre>
* @param var_args A list of strings to concatenate. If not a string, it will be casted to one.
*/
function buildString ( ...var_args : any [] ) : string ;
/**
* Replaces Windows and Mac new lines with unix style: \r or \r\n with \n.
* @param str The string to in which to canonicalize newlines.
*/
function canonicalizeNewlines (str : string ) : string ;
/**
* Capitalizes a string, i.e. converts the first letter to uppercase
* and all other letters to lowercase, e.g.:
*
* goog.string.capitalize('one') => 'One'
* goog.string.capitalize('ONE') => 'One'
* goog.string.capitalize('one two') => 'One two'
*
* Note that this function does not trim initial whitespace.
* @param str String value to capitalize.
*/
function capitalize (str : string ) : string ;
/**
* A string comparator that ignores case.
* -1 = str1 less than str2
* 0 = str1 equals str2
* 1 = str1 greater than str2
* @param str1 The string to compare.
* @param str2 The string to compare {@code str1} to.
*/
function caseInsensitiveCompare (str1 : string , str2 : string ) : number ;
/**
* Determines whether a string contains a substring, ignoring case.
* @param str The string to search.
* @param subString The substring to search for.
*/
function caseInsensitiveContains (str : string , subString : string ) : boolean ;
/**
* Case-insensitive suffix-checker.
* @param str The string to check.
* @param suffix A string to look for at the end of {@code str}.
*/
function caseInsensitiveEndsWith (str : string , suffix : string ) : boolean ;
/**
* Case-insensitive equality checker.
* @param str1 First string to check.
* @param str2 Second string to check.
*/
function caseInsensitiveEquals (str1 : string , str2 : string ) : boolean ;
/**
* Case-insensitive prefix-checker.
* @param str The string to check.
* @param prefix A string to look for at the end of {@code str}.
*/
function caseInsensitiveStartsWith (str : string , prefix : string ) : boolean ;
/**
* Removes the breaking spaces from the left and right of the string and
* collapses the sequences of breaking spaces in the middle into single spaces.
* The original and the result strings render the same way in HTML.
* @param str A string in which to collapse spaces.
*/
function collapseBreakingSpaces (str : string ) : string ;
/**
* Converts multiple whitespace chars (spaces, non-breaking-spaces, new lines
* and tabs) to a single space, and strips leading and trailing whitespace.
* @param str Input string.
*/
function collapseWhitespace (str : string ) : string ;
/**
* Compares two version numbers.
* @param version1 Version of first item.
* @param version2 Version of second item.
*/
function compareVersions (version1 : string | number , version2 : string | number ) : number ;
/**
* Determines whether a string contains a substring.
* @param str The string to search.
* @param subString The substring to search for.
*/
function contains (str : string , subString : string ) : boolean ;
/**
* Returns the non-overlapping occurrences of ss in s.
* If either s or ss evalutes to false, then returns zero.
* @param s The string to look in.
* @param ss The string to look for.
*/
function countOf (s : string , ss : string ) : number ;
/**
* Generates and returns a string which is unique in the current document.
* This is useful, for example, to create unique IDs for DOM elements.
*/
function createUniqueString ( ) : string ;
/**
* Computes the Levenshtein edit distance between two strings.
*/
function editDistance (a : string , b : string ) : number ;
/**
* Fast suffix-checker.
* @param str The string to check.
* @param suffix A string to look for at the end of {@code str}.
*/
function endsWith (str : string , suffix : string ) : boolean ;
/**
* Takes a character and returns the escaped string for that character. For
* example escapeChar(String.fromCharCode(15)) -> "\\x0E".
* @param c The character to escape.
*/
function escapeChar (c : string ) : string ;
/**
* Takes a string and returns the escaped string for that input string.
* @param str The string to escape.
*/
function escapeString (str : string ) : string ;
/**
* String comparison function that handles non-negative integer and fractional
* numbers in a way humans might expect. Using this function, the string
* 'File 2.jpg' sorts before 'File 10.jpg', and '3.14' before '3.2'. Equivalent
* to {@link goog.string.intAwareCompare} apart from the way how it interprets
* dots.
* @param str1 The string to compare in a numerically sensitive way.
* @param str2 The string to compare {@code str1} to.
*/
function floatAwareCompare (str1 : string , str2 : string ) : number ;
/**
* Returns a string with at least 64-bits of randomness.
*
* Doesn't trust Javascript's random function entirely. Uses a combination of
* random and current timestamp, and then encodes the string in base-36 to
* make it shorter.
*/
function getRandomString ( ) : string ;
/**
* String hash function similar to java.lang.String.hashCode().
* The hash code for a string is computed as
* s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
* where s[i] is the ith character of the string and n is the length of
* the string. We mod the result to make it between 0 (inclusive) and 2^32
* (exclusive).
* @param str A string.
*/
function hashCode (str : string ) : number ;
/**
* Escapes double quote '"' and single quote '\'' characters in addition to
* '&', '<', and '>' so that a string can be included in an HTML tag attribute
* value within double or single quotes.
*
* It should be noted that > doesn't need to be escaped for the HTML or XML to
* be valid, but it has been decided to escape it for consistency with other
* implementations.
*
* With goog.string.DETECT_DOUBLE_ESCAPING, this function escapes also the
* lowercase letter "e".
*
* NOTE(user):
* HtmlEscape is often called during the generation of large blocks of HTML.
* Using statics for the regular expressions and strings is an optimization
* that can more than half the amount of time IE spends in this function for
* large apps, since strings and regexes both contribute to GC allocations.
*
* Testing for the presence of a character before escaping increases the number
* of function calls, but actually provides a speed increase for the average
* case -- since the average case often doesn't require the escaping of all 4
* characters and indexOf() is much cheaper than replace().
* The worst case does suffer slightly from the additional calls, therefore the
* opt_isLikelyToContainHtmlChars option has been included for situations
* where all 4 HTML entities are very likely to be present and need escaping.
*
* Some benchmarks (times tended to fluctuate +-0.05ms):
* FireFox IE6
* (no chars / average (mix of cases) / all 4 chars)
* no checks 0.13 / 0.22 / 0.22 0.23 / 0.53 / 0.80
* indexOf 0.08 / 0.17 / 0.26 0.22 / 0.54 / 0.84
* indexOf + re test 0.07 / 0.17 / 0.28 0.19 / 0.50 / 0.85
*
* An additional advantage of checking if replace actually needs to be called
* is a reduction in the number of object allocations, so as the size of the
* application grows the difference between the various methods would increase.
* @param str string to be escaped.
* @param opt_isLikelyToContainHtmlChars Don't perform a check to see if the character needs replacing - use this option if you expect each of the characters to appear often. Leave false if you expect few html characters to occur in your strings, such as if you are escaping HTML.
*/
function htmlEscape (str : string , opt_isLikelyToContainHtmlChars ? : boolean ) : string ;
/**
* String comparison function that handles non-negative integer numbers in a
* way humans might expect. Using this function, the string 'File 2.jpg' sorts
* before 'File 10.jpg', and 'Version 1.9' before 'Version 1.10'. The comparison
* is mostly case-insensitive, though strings that are identical except for case
* are sorted with the upper-case strings before lower-case.
*
* This comparison function is up to 50x slower than either the default or the
* case-insensitive compare. It should not be used in time-critical code, but
* should be fast enough to sort several hundred short strings (like filenames)
* with a reasonable delay.
* @param str1 The string to compare in a numerically sensitive way.
* @param str2 The string to compare {@code str1} to.
*/
function intAwareCompare (str1 : string , str2 : string ) : number ;
/**
* Checks if a string contains all letters.
* @param str string to check.
*/
function isAlpha (str : string ) : boolean ;
/**
* Checks if a string contains only numbers or letters.
* @param str string to check.
*/
function isAlphaNumeric (str : string ) : boolean ;
/**
* Checks if a string is all breaking whitespace.
* @param str The string to check.
*/
function isBreakingWhitespace (str : string ) : boolean ;
/**
* Checks if a string is empty or contains only whitespaces.
* @param str The string to check.
*/
function isEmpty (a : string ) : boolean ;
/**
* Checks if a string is empty or contains only whitespaces.
* @param str The string to check.
*/
function isEmptyOrWhitespace (str : string ) : boolean ;
/**
* Checks if a string is null, undefined, empty or contains only whitespaces.
* @param str The string to check.
*/
function isEmptyOrWhitespaceSafe (str : any ) : boolean ;
/**
* Checks if a string is null, undefined, empty or contains only whitespaces.
* @param str The string to check.
*/
function isEmptySafe (a : any ) : boolean ;
/**
* Checks if a string is empty.
* @param str The string to check.
*/
function isEmptyString (str : string ) : boolean ;
/**
* Returns whether the given string is lower camel case (e.g. "isFooBar").
*
* Note that this assumes the string is entirely letters.
* @param str String to test.
*/
function isLowerCamelCase (str : string ) : boolean ;
/**
* Checks if a string contains only numbers.
* @param str string to check. If not a string, it will be casted to one.
*/
function isNumeric (str : any ) : boolean ;
/**
* Checks if a character is a space character.
* @param ch Character to check.
*/
function isSpace (ch : string ) : boolean ;
/**
* Checks if a character is a valid unicode character.
* @param ch Character to check.
*/
function isUnicodeChar (ch : string ) : boolean ;
/**
* Returns whether the given string is upper camel case (e.g. "FooBarBaz").
*
* Note that this assumes the string is entirely letters.
* @param str String to test.
*/
function isUpperCamelCase (str : string ) : boolean ;
/**
* Finds the characters to the right of the last instance of any separator
*
* This function is similar to goog.string.path.baseName, except it can take a
* list of characters to split the string on. It will return the rightmost
* grouping of characters to the right of any separator as a left-to-right
* oriented string.
* @param str The string
* @param separators A list of separator characters
*/
function lastComponent (str : string , separators : string | string [] ) : string ;
/**
* Returns a string representation of the given object, with
* null and undefined being returned as the empty string.
* @param obj The object to convert.
*/
function makeSafe (obj : any ) : string ;
/**
* Converts \n to <br>s or <br />s.
* @param str The string in which to convert newlines.
* @param opt_xml Whether to use XML compatible tags.
*/
function newLineToBr (str : string , opt_xml ? : boolean ) : string ;
/**
* Normalizes spaces in a string, replacing all consecutive spaces and tabs
* with a single space. Replaces non-breaking space with a space.
* @param str The string in which to normalize spaces.
*/
function normalizeSpaces (str : string ) : string ;
/**
* Normalizes whitespace in a string, replacing all whitespace chars with
* a space.
* @param str The string in which to normalize whitespace.
*/
function normalizeWhitespace (str : string ) : string ;
/**
* Alias for {@link goog.string.floatAwareCompare}.
*/
function numerateCompare (a : string , b : string ) : number ;
/**
* Pads number to given length and optionally rounds it to a given precision.
* For example:
* <pre>padNumber(1.25, 2, 3) -> '01.250'
* padNumber(1.25, 2) -> '01.25'
* padNumber(1.25, 2, 1) -> '01.3'
* padNumber(1.25, 0) -> '1.25'</pre>
* @param num The number to pad.
* @param length The desired length.
* @param opt_precision The desired precision.
*/
function padNumber (num : number , length : number , opt_precision ? : number ) : string ;
/**
* Parse a string in decimal or hexidecimal ('0xFFFF') form.
*
* To parse a particular radix, please use parseInt(string, radix) directly. See
* https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/parseInt
*
* This is a wrapper for the built-in parseInt function that will only parse
* numbers as base 10 or base 16. Some JS implementations assume strings
* starting with "0" are intended to be octal. ES3 allowed but discouraged
* this behavior. ES5 forbids it. This function emulates the ES5 behavior.
*
* For more information, see Mozilla JS Reference: http://goo.gl/8RiFj
* @param value The value to be parsed.
*/
function parseInt (value : string | number | null | undefined ) : number ;
/**
* Preserve spaces that would be otherwise collapsed in HTML by replacing them
* with non-breaking space Unicode characters.
* @param str The string in which to preserve whitespace.
*/
function preserveSpaces (str : string ) : string ;
/**
* Encloses a string in double quotes and escapes characters so that the
* string is a valid JS string. The resulting string is safe to embed in
* `<script>` tags as "<" is escaped.
* @param s The string to quote.
*/
function quote (s : string ) : string ;
/**
* Escapes characters in the string that are not safe to use in a RegExp.
* @param s The string to escape. If not a string, it will be casted to one.
*/
function regExpEscape (s : any ) : string ;
/**
* Removes the first occurrence of a substring from a string.
* @param str The base string from which to remove.
* @param substr The string to remove.
*/
function remove (str : string , substr : string ) : string ;
/**
* Removes all occurrences of a substring from a string.
* @param s The base string from which to remove.
* @param ss The string to remove.
*/
function removeAll (s : string , ss : string ) : string ;
/**
* Removes a substring of a specified length at a specific
* index in a string.
* @param s The base string from which to remove.
* @param index The index at which to remove the substring.
* @param stringLength The length of the substring to remove.
*/
function removeAt (s : string , index : number , stringLength : number ) : string ;
/**
* Repeats a string n times.
* @param string The string to repeat.
* @param length The number of times to repeat.
*/
function repeat (a : string , b : number ) : string ;
/**
* Replaces all occurrences of a substring of a string with a new substring.
* @param s The base string from which to remove.
* @param ss The string to replace.
* @param replacement The replacement string.
*/
function replaceAll (s : string , ss : string , replacement : string ) : string ;
/**
* Splits a string on a separator a limited number of times.
*
* This implementation is more similar to Python or Java, where the limit
* parameter specifies the maximum number of splits rather than truncating
* the number of results.
*
* See http://docs.python.org/2/library/stdtypes.html#str.split
* See JavaDoc: http://goo.gl/F2AsY
* See Mozilla reference: http://goo.gl/dZdZs
* @param str String to split.
* @param separator The separator.
* @param limit The limit to the number of splits. The resulting array will have a maximum length of limit+1. Negative numbers are the same as zero.
*/
function splitLimit (str : string , separator : string , limit : number ) : string [] ;
/**
* Fast prefix-checker.
* @param str The string to check.
* @param prefix A string to look for at the start of {@code str}.
*/
function startsWith (str : string , prefix : string ) : boolean ;
/**
* Takes a string and replaces newlines with a space. Multiple lines are
* replaced with a single space.
* @param str The string from which to strip newlines.
*/
function stripNewlines (str : string ) : string ;
/**
* Strip quote characters around a string. The second argument is a string of
* characters to treat as quotes. This can be a single character or a string of
* multiple character and in that case each of those are treated as possible
* quote characters. For example:
*
* <pre>
* goog.string.stripQuotes('"abc"', '"`') --> 'abc'
* goog.string.stripQuotes('`abc`', '"`') --> 'abc'
* </pre>
* @param str The string to strip.
* @param quoteChars The quote characters to strip.
*/
function stripQuotes (str : string , quoteChars : string ) : string ;
/**
* Does simple python-style string substitution.
* subs("foo%s hot%s", "bar", "dog") becomes "foobar hotdog".
* @param str The string containing the pattern.
* @param var_args The items to substitute into the pattern.
*/
function subs (str : string , ...var_args : any [] ) : string ;
/**
* Converts a string from selector-case to camelCase (e.g. from
* "multi-part-string" to "multiPartString"), useful for converting
* CSS selectors and HTML dataset keys to their equivalent JS properties.
* @param str The string in selector-case form.
*/
function toCamelCase (str : string ) : string ;
/**
* Converts the supplied string to a number, which may be Infinity or NaN.
* This function strips whitespace: (toNumber(' 123') === 123)
* This function accepts scientific notation: (toNumber('1e1') === 10)
*
* This is better than Javascript's built-in conversions because, sadly:
* (Number(' ') === 0) and (parseFloat('123a') === 123)
* @param str The string to convert.
*/
function toNumber (str : string ) : number ;
/**
* Converts a string from camelCase to selector-case (e.g. from
* "multiPartString" to "multi-part-string"), useful for converting JS
* style and dataset properties to equivalent CSS selectors and HTML keys.
* @param str The string in camelCase form.
*/
function toSelectorCase (str : string ) : string ;
/**
* Converts a string into TitleCase. First character of the string is always
* capitalized in addition to the first letter of every subsequent word.
* Words are delimited by one or more whitespaces by default. Custom delimiters
* can optionally be specified to replace the default, which doesn't preserve
* whitespace delimiters and instead must be explicitly included if needed.
*
* Default delimiter => " ":
* goog.string.toTitleCase('oneTwoThree') => 'OneTwoThree'
* goog.string.toTitleCase('one two three') => 'One Two Three'
* goog.string.toTitleCase(' one two ') => ' One Two '
* goog.string.toTitleCase('one_two_three') => 'One_two_three'
* goog.string.toTitleCase('one-two-three') => 'One-two-three'
*
* Custom delimiter => "_-.":
* goog.string.toTitleCase('oneTwoThree', '_-.') => 'OneTwoThree'
* goog.string.toTitleCase('one two three', '_-.') => 'One two three'
* goog.string.toTitleCase(' one two ', '_-.') => ' one two '
* goog.string.toTitleCase('one_two_three', '_-.') => 'One_Two_Three'
* goog.string.toTitleCase('one-two-three', '_-.') => 'One-Two-Three'
* goog.string.toTitleCase('one...two...three', '_-.') => 'One...Two...Three'
* goog.string.toTitleCase('one. two. three', '_-.') => 'One. two. three'
* goog.string.toTitleCase('one-two.three', '_-.') => 'One-Two.Three'
* @param str String value in camelCase form.
* @param opt_delimiters Custom delimiter character set used to distinguish words in the string value. Each character represents a single delimiter. When provided, default whitespace delimiter is overridden and must be explicitly included if needed.
*/
function toTitleCase (str : string , opt_delimiters ? : string ) : string ;
/**
* Trims white spaces to the left and right of a string.
* @param str The string to trim.
*/
function trim (a : string ) : string ;
/**
* Trims whitespaces at the left end of a string.
* @param str The string to left trim.
*/
function trimLeft (str : string ) : string ;
/**
* Trims whitespaces at the right end of a string.
* @param str The string to right trim.
*/
function trimRight (str : string ) : string ;
/**
* Truncates a string to a certain length and adds '...' if necessary. The
* length also accounts for the ellipsis, so a maximum length of 10 and a string
* 'Hello World!' produces 'Hello W...'.
* @param str The string to truncate.
* @param chars Max number of characters.
* @param opt_protectEscapedCharacters Whether to protect escaped characters from being cut off in the middle.
*/
function truncate (str : string , chars : number , opt_protectEscapedCharacters ? : boolean ) : string ;
/**
* Truncate a string in the middle, adding "..." if necessary,
* and favoring the beginning of the string.
* @param str The string to truncate the middle of.
* @param chars Max number of characters.
* @param opt_protectEscapedCharacters Whether to protect escaped characters from being cutoff in the middle.
* @param opt_trailingChars Optional number of trailing characters to leave at the end of the string, instead of truncating as close to the middle as possible.
*/
function truncateMiddle (str : string , chars : number , opt_protectEscapedCharacters ? : boolean , opt_trailingChars ? : number ) : string ;
/**
* Unescapes an HTML string.
* @param str The string to unescape.
*/
function unescapeEntities (str : string ) : string ;
/**
* Unescapes a HTML string using the provided document.
* @param str The string to unescape.
* @param document A document to use in escaping the string.
*/
function unescapeEntitiesWithDocument (str : string , document : Document ) : string ;
/**
* URL-decodes the string. We need to specially handle '+'s because
* the javascript library doesn't convert them to spaces.
* @param str The string to url decode.
*/
function urlDecode (str : string ) : string ;
/**
* URL-encodes a string
* @param str The string to url-encode.
*/
function urlEncode (str : any ) : string ;
/**
* Do escaping of whitespace to preserve spatial formatting. We use character
* entity #160 to make it safer for xml.
* @param str The string in which to escape whitespace.
* @param opt_xml Whether to use XML compatible tags.
*/
function whitespaceEscape (str : string , opt_xml ? : boolean ) : string ;
}
declare module 'goog:goog.string' {
import alias = ಠ_ಠ.clutz.goog.string;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.string {
/**
* Wrapper for compile-time-constant strings.
*
* Const is a wrapper for strings that can only be created from program
* constants (i.e., string literals). This property relies on a custom Closure
* compiler check that {@code goog.string.Const.from} is only invoked on
* compile-time-constant expressions.
*
* Const is useful in APIs whose correct and secure use requires that certain
* arguments are not attacker controlled: Compile-time constants are inherently
* under the control of the application and not under control of external
* attackers, and hence are safe to use in such contexts.
*
* Instances of this type must be created via its factory method
* {@code goog.string.Const.from} and not by invoking its constructor. The
* constructor intentionally takes no parameters and the type is immutable;
* hence only a default instance corresponding to the empty string can be
* obtained via constructor invocation.
*/
class Const extends Const_Instance {
/**
* A Const instance wrapping the empty string.
*/
static EMPTY : ಠ_ಠ.clutz.goog.string.Const ;
/**
* Creates a Const object from a compile-time constant string.
*
* It is illegal to invoke this function on an expression whose
* compile-time-contant value cannot be determined by the Closure compiler.
*
* Correct invocations include,
* <pre>
* var s = goog.string.Const.from('hello');
* var t = goog.string.Const.from('hello' + 'world');
* </pre>
*
* In contrast, the following are illegal:
* <pre>
* var s = goog.string.Const.from(getHello());
* var t = goog.string.Const.from('hello' + world);
* </pre>
* @param s A constant string from which to create a Const.
*/
static from (s : string ) : ಠ_ಠ.clutz.goog.string.Const ;
/**
* Performs a runtime check that the provided object is indeed an instance
* of {@code goog.string.Const}, and returns its value.
* @param stringConst The object to extract from.
*/
static unwrap (stringConst : ಠ_ಠ.clutz.goog.string.Const ) : string ;
}
class Const_Instance implements ಠ_ಠ.clutz.goog.string.TypedString {
private noStructuralTyping_: any;
/**
* Returns this Const's value a string.
*
* IMPORTANT: In code where it is security-relevant that an object's type is
* indeed {@code goog.string.Const}, use {@code goog.string.Const.unwrap}
* instead of this method.
*/
getTypedStringValue ( ) : string ;
implementsGoogStringTypedString : boolean ;
/**
* Returns a debug-string representation of this value.
*
* To obtain the actual string value wrapped inside an object of this type,
* use {@code goog.string.Const.unwrap}.
*/
toString ( ) : string ;
}
}
declare module 'goog:goog.string.Const' {
import alias = ಠ_ಠ.clutz.goog.string.Const;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.string {
/**
* Wrapper for strings that conform to a data type or language.
*
* Implementations of this interface are wrappers for strings, and typically
* associate a type contract with the wrapped string. Concrete implementations
* of this interface may choose to implement additional run-time type checking,
* see for example {@code goog.html.SafeHtml}. If available, client code that
* needs to ensure type membership of an object should use the type's function
* to assert type membership, such as {@code goog.html.SafeHtml.unwrap}.
*/
interface TypedString {
/**
* Retrieves this wrapped string's value.
*/
getTypedStringValue ( ) : string ;
/**
* Interface marker of the TypedString interface.
*
* This property can be used to determine at runtime whether or not an object
* implements this interface. All implementations of this interface set this
* property to {@code true}.
*/
implementsGoogStringTypedString : boolean ;
}
}
declare module 'goog:goog.string.TypedString' {
import alias = ಠ_ಠ.clutz.goog.string.TypedString;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.string {
/**
* Common Unicode string characters.
*/
type Unicode = string &{clutzEnumBrand: never} ;
var Unicode : {
NBSP : Unicode ,
};
}
declare module 'goog:goog.string.Unicode' {
import alias = ಠ_ಠ.clutz.goog.string.Unicode;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.structs {
/**
* Removes all the elements from the collection.
* @param col The collection-like object.
*/
function clear (col : GlobalObject | null ) : void ;
/**
* Whether the collection contains the given value. This is O(n) and uses
* equals (==) to test the existence.
* @param col The collection-like object.
* @param val The value to check for.
*/
function contains (col : GlobalObject | null , val : any ) : boolean ;
/**
* Calls f for each value in a collection. If all calls return true this return
* true this returns true. If any returns false this returns false at this point
* and does not continue to check the remaining values.
* @param col The collection-like object.
* @param f The function to call for every value. This function takes 3 arguments (the value, the key or undefined if the collection has no notion of keys, and the collection) and should return a boolean.
* @param opt_obj The object to be used as the value of 'this' within {@code f}.
*/
function every < T , S > (col : S , f : (a : any , b : any , c : S ) => boolean , opt_obj ? : T ) : boolean ;
/**
* Calls a function for every value in the collection. When a call returns true,
* adds the value to a new collection (Array is returned by default).
* @param col The collection-like object.
* @param f The function to call for every value. This function takes 3 arguments (the value, the key or undefined if the collection has no notion of keys, and the collection) and should return a Boolean. If the return value is true the value is added to the result collection. If it is false the value is not included.
* @param opt_obj The object to be used as the value of 'this' within {@code f}.
*/
function filter < T , S > (col : S , f : (a : any , b : any , c : S ) => boolean , opt_obj ? : T ) : GlobalObject ;
/**
* Calls a function for each value in a collection. The function takes
* three arguments; the value, the key and the collection.
* @param col The collection-like object.
* @param f The function to call for every value. This function takes 3 arguments (the value, the key or undefined if the collection has no notion of keys, and the collection) and the return value is irrelevant.
* @param opt_obj The object to be used as the value of 'this' within {@code f}.
*/
function forEach < T , S > (col : S , f : (a : any , b : any , c : S ) => any , opt_obj ? : T ) : void ;
/**
* Returns the number of values in the collection-like object.
* @param col The collection-like object.
*/
function getCount (col : GlobalObject | null ) : number ;
/**
* Returns the keys of the collection. Some collections have no notion of
* keys/indexes and this function will return undefined in those cases.
* @param col The collection-like object.
*/
function getKeys (col : GlobalObject | null ) : any [] | undefined ;
/**
* Returns the values of the collection-like object.
* @param col The collection-like object.
*/
function getValues (col : GlobalObject | null ) : any [] ;
/**
* Whether the collection is empty.
* @param col The collection-like object.
*/
function isEmpty (col : GlobalObject | null ) : boolean ;
/**
* Calls a function for every value in the collection and adds the result into a
* new collection (defaults to creating a new Array).
* @param col The collection-like object.
* @param f The function to call for every value. This function takes 3 arguments (the value, the key or undefined if the collection has no notion of keys, and the collection) and should return something. The result will be used as the value in the new collection.
* @param opt_obj The object to be used as the value of 'this' within {@code f}.
*/
function map < T , S , V > (col : S , f : (a : any , b : any , c : S ) => V , opt_obj ? : T ) : { [ /* warning: coerced from ? */ key: string ]: V } | V [] ;
/**
* Calls f for each value in a collection. If any call returns true this returns
* true (without checking the rest). If all returns false this returns false.
* @param col The collection-like object.
* @param f The function to call for every value. This function takes 3 arguments (the value, the key or undefined if the collection has no notion of keys, and the collection) and should return a boolean.
* @param opt_obj The object to be used as the value of 'this' within {@code f}.
*/
function some < T , S > (col : S , f : (a : any , b : any , c : S ) => boolean , opt_obj ? : T ) : boolean ;
}
declare module 'goog:goog.structs' {
import alias = ಠ_ಠ.clutz.goog.structs;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.structs {
/**
* Class for Hash Map datastructure.
*/
class Map < K , V > extends Map_Instance < K , V > {
/**
* Default equality test for values.
* @param a The first value.
* @param b The second value.
*/
static defaultEquals (a : any , b : any ) : boolean ;
}
class Map_Instance < K , V > {
private noStructuralTyping_: any;
/**
* Class for Hash Map datastructure.
* @param opt_map Map or Object to initialize the map with.
* @param var_args If 2 or more arguments are present then they will be used as key-value pairs.
*/
constructor (opt_map ? : any , ...var_args : any [] ) ;
/**
* Returns an iterator that iterates over the values or the keys in the map.
* This throws an exception if the map was mutated since the iterator was
* created.
* @param opt_keys True to iterate over the keys. False to iterate over the values. The default value is false.
*/
__iterator__ (opt_keys ? : boolean ) : ಠ_ಠ.clutz.goog.iter.Iterator < any > ;
/**
* Adds multiple key-value pairs from another goog.structs.Map or Object.
* @param map Object containing the data to add.
*/
addAll (map : GlobalObject | null ) : void ;
/**
* Removes all key-value pairs from the map.
*/
clear ( ) : void ;
/**
* Clones a map and returns a new map.
*/
clone ( ) : ಠ_ಠ.clutz.goog.structs.Map < any , any > ;
/**
* Whether the map contains the given key.
* @param key The key to check for.
*/
containsKey (key : any ) : boolean ;
/**
* Whether the map contains the given value. This is O(n).
* @param val The value to check for.
*/
containsValue (val : V ) : boolean ;
/**
* Whether this map is equal to the argument map.
* @param otherMap The map against which to test equality.
* @param opt_equalityFn Optional equality function to test equality of values. If not specified, this will test whether the values contained in each map are identical objects.
*/
equals (otherMap : ಠ_ಠ.clutz.goog.structs.Map < any , any > | null , opt_equalityFn ? : (a : V , b : V ) => boolean ) : boolean ;
/**
* Calls the given function on each entry in the map.
* @param opt_obj The value of "this" inside f.
*/
forEach < T > (f : (a : V , b : K , c : ಠ_ಠ.clutz.goog.structs.Map < K , V > | null ) => any , opt_obj ? : T ) : void ;
/**
* Returns the value for the given key. If the key is not found and the default
* value is not given this will return {@code undefined}.
* @param key The key to get the value for.
* @param opt_val The value to return if no item is found for the given key, defaults to undefined.
*/
get < DEFAULT > (key : any , opt_val ? : DEFAULT ) : V | DEFAULT ;
getCount ( ) : number ;
/**
* Returns an iterator that iterates over the keys in the map. Removal of keys
* while iterating might have undesired side effects.
*/
getKeyIterator ( ) : ಠ_ಠ.clutz.goog.iter.Iterator < any > ;
/**
* Returns the keys of the map.
*/
getKeys ( ) : string [] ;
/**
* Returns an iterator that iterates over the values in the map. Removal of
* keys while iterating might have undesired side effects.
*/
getValueIterator ( ) : ಠ_ಠ.clutz.goog.iter.Iterator < any > ;
/**
* Returns the values of the map.
*/
getValues ( ) : V [] ;
isEmpty ( ) : boolean ;
/**
* Removes a key-value pair based on the key. This is O(logN) amortized due to
* updating the keys array whenever the count becomes half the size of the keys
* in the keys array.
* @param key The key to remove.
*/
remove (key : any ) : boolean ;
/**
* Adds a key-value pair to the map.
* @param key The key.
* @param value The value to add.
*/
set (key : any , value : V ) : any ;
toObject ( ) : GlobalObject ;
/**
* Returns a new map in which all the keys and values are interchanged
* (keys become values and values become keys). If multiple keys map to the
* same value, the chosen transposed value is implementation-dependent.
*
* It acts very similarly to {goog.object.transpose(Object)}.
*/
transpose ( ) : ಠ_ಠ.clutz.goog.structs.Map < any , any > ;
}
}
declare module 'goog:goog.structs.Map' {
import alias = ಠ_ಠ.clutz.goog.structs.Map;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.uri.utils {
/**
* Appends a single URI parameter.
*
* Repeated calls to this can exhibit quadratic behavior in IE6 due to the
* way string append works, though it should be limited given the 2kb limit.
* @param uri The original URI, which may already have query data.
* @param key The key, which must already be URI encoded.
* @param opt_value The value, which will be stringized and encoded (assumed not already to be encoded). If omitted, undefined, or null, the key will be added as a valueless parameter.
*/
function appendParam (uri : string , key : string , opt_value ? : any ) : string ;
/**
* Appends URI parameters to an existing URI.
*
* The variable arguments may contain alternating keys and values. Keys are
* assumed to be already URI encoded. The values should not be URI-encoded,
* and will instead be encoded by this function.
* <pre>
* appendParams('http://www.foo.com?existing=true',
* 'key1', 'value1',
* 'key2', 'value?willBeEncoded',
* 'key3', ['valueA', 'valueB', 'valueC'],
* 'key4', null);
* result: 'http://www.foo.com?existing=true&' +
* 'key1=value1&' +
* 'key2=value%3FwillBeEncoded&' +
* 'key3=valueA&key3=valueB&key3=valueC'
* </pre>
*
* A single call to this function will not exhibit quadratic behavior in IE,
* whereas multiple repeated calls may, although the effect is limited by
* fact that URL's generally can't exceed 2kb.
* @param uri The original URI, which may already have query data.
* @param var_args An array or argument list conforming to goog.uri.utils.QueryArray.
*/
function appendParams (uri : string , ...var_args : any [] ) : string ;
/**
* Appends query parameters from a map.
* @param uri The original URI, which may already have query data.
* @param map An object where keys are URI-encoded parameter keys, and the values are arbitrary types or arrays. Keys with a null value are dropped.
*/
function appendParamsFromMap (uri : string , map : { [ /* warning: coerced from ? */ key: string ]: any } ) : string ;
/**
* Generates a URI path using a given URI and a path with checks to
* prevent consecutive "//". The baseUri passed in must not contain
* query or fragment identifiers. The path to append may not contain query or
* fragment identifiers.
* @param baseUri URI to use as the base.
* @param path Path to append.
*/
function appendPath (baseUri : string , path : string ) : string ;
/**
* Builds a URI string from already-encoded parts.
*
* No encoding is performed. Any component may be omitted as either null or
* undefined.
* @param opt_scheme The scheme such as 'http'.
* @param opt_userInfo The user name before the '@'.
* @param opt_domain The domain such as 'www.google.com', already URI-encoded.
* @param opt_port The port number.
* @param opt_path The path, already URI-encoded. If it is not empty, it must begin with a slash.
* @param opt_queryData The URI-encoded query data.
* @param opt_fragment The URI-encoded fragment identifier.
*/
function buildFromEncodedParts (opt_scheme ? : string | null , opt_userInfo ? : string | null , opt_domain ? : string | null , opt_port ? : string | number | null , opt_path ? : string | null , opt_queryData ? : string | null , opt_fragment ? : string | null ) : string ;
/**
* Builds a query data string from a sequence of alternating keys and values.
* Currently generates "&key&" for empty args.
* @param keysAndValues Alternating keys and values. See the QueryArray typedef.
* @param opt_startIndex A start offset into the arary, defaults to 0.
*/
function buildQueryData (keysAndValues : ArrayLike < any > , opt_startIndex ? : number ) : string ;
/**
* Builds a query data string from a map.
* Currently generates "&key&" for empty args.
* @param map An object where keys are URI-encoded parameter keys, and the values are arbitrary types or arrays. Keys with a null value are dropped.
*/
function buildQueryDataFromMap (map : { [ key: string ]: any } ) : string ;
function getDomain (uri : string ) : string | null ;
function getDomainEncoded (uri : string ) : string | null ;
/**
* Gets the effective scheme for the URL. If the URL is relative then the
* scheme is derived from the page's location.
* @param uri The URI to examine.
*/
function getEffectiveScheme (uri : string ) : string ;
function getFragment (uri : string ) : string | null ;
function getFragmentEncoded (uri : string ) : string | null ;
/**
* Extracts everything up to the port of the URI.
* @param uri The URI string.
*/
function getHost (uri : string ) : string ;
/**
* Returns the origin for a given URL.
* @param uri The URI string.
*/
function getOrigin (uri : string ) : string ;
/**
* Gets the first value of a query parameter.
* @param uri The URI to process. May contain a fragment.
* @param keyEncoded The URI-encoded key. Case-sensitive.
*/
function getParamValue (uri : string , keyEncoded : string ) : string | null ;
/**
* Gets all values of a query parameter.
* @param uri The URI to process. May contain a fragment.
* @param keyEncoded The URI-encoded key. Case-sensitive.
*/
function getParamValues (uri : string , keyEncoded : string ) : string [] ;
function getPath (uri : string ) : string | null ;
/**
* Extracts the path of the URL and everything after.
* @param uri The URI string.
*/
function getPathAndAfter (uri : string ) : string ;
function getPathEncoded (uri : string ) : string | null ;
function getPort (uri : string ) : number | null ;
function getQueryData (uri : string ) : string | null ;
function getScheme (uri : string ) : string | null ;
function getUserInfo (uri : string ) : string | null ;
function getUserInfoEncoded (uri : string ) : string | null ;
/**
* Determines if the URI contains a specific key.
*
* Performs no object instantiations.
* @param uri The URI to process. May contain a fragment identifier.
* @param keyEncoded The URI-encoded key. Case-sensitive.
*/
function hasParam (uri : string , keyEncoded : string ) : boolean ;
/**
* Ensures that two URI's have the exact same domain, scheme, and port.
*
* Unlike the version in goog.Uri, this checks protocol, and therefore is
* suitable for checking against the browser's same-origin policy.
* @param uri1 The first URI.
* @param uri2 The second URI.
*/
function haveSameDomain (uri1 : string , uri2 : string ) : boolean ;
/**
* Sets the zx parameter of a URI to a random value.
* @param uri Any URI.
*/
function makeUnique (uri : string ) : string ;
/**
* Parses encoded query parameters and calls callback function for every
* parameter found in the string.
*
* Missing value of parameter (e.g. “…&key&…”) is treated as if the value was an
* empty string. Keys may be empty strings (e.g. “…&=value&…”) which also means
* that “…&=&…” and “…&&…” will result in an empty key and value.
* @param encodedQuery Encoded query string excluding question mark at the beginning.
* @param callback Function called for every parameter found in query string. The first argument (name) will not be urldecoded (so the function is consistent with buildQueryData), but the second will. If the parameter has no value (i.e. “=” was not present) the second argument (value) will be an empty string.
*/
function parseQueryData (encodedQuery : string , callback : (a : string , b : string ) => any ) : void ;
/**
* Gets the URI with the fragment identifier removed.
* @param uri The URI to examine.
*/
function removeFragment (uri : string ) : string ;
/**
* Removes all instances of a query parameter.
* @param uri The URI to process. Must not contain a fragment.
* @param keyEncoded The URI-encoded key.
*/
function removeParam (uri : string , keyEncoded : string ) : string ;
function setFragmentEncoded (uri : string , fragment : string | null ) : string ;
/**
* Replaces all existing definitions of a parameter with a single definition.
*
* Repeated calls to this can exhibit quadratic behavior due to the need to
* find existing instances and reconstruct the string, though it should be
* limited given the 2kb limit. Consider using appendParams or setParamsFromMap
* to update multiple parameters in bulk.
* @param uri The original URI, which may already have query data.
* @param keyEncoded The key, which must already be URI encoded.
* @param value The value, which will be stringized and encoded (assumed not already to be encoded).
*/
function setParam (uri : string , keyEncoded : string , value : any ) : string ;
/**
* Effeciently set or remove multiple query parameters in a URI. Order of
* unchanged parameters will not be modified, all updated parameters will be
* appended to the end of the query. Params with values of null or undefined are
* removed.
* @param uri The URI to process.
* @param params A list of parameters to update. If null or undefined, the param will be removed.
*/
function setParamsFromMap (uri : string , params : { [ key: string ]: any } ) : string ;
/**
* Replaces the path.
* @param uri URI to use as the base.
* @param path New path.
*/
function setPath (uri : string , path : string ) : string ;
/**
* Splits a URI into its component parts.
*
* Each component can be accessed via the component indices; for example:
* <pre>
* goog.uri.utils.split(someStr)[goog.uri.utils.ComponentIndex.QUERY_DATA];
* </pre>
* @param uri The URI string to examine.
*/
function split (uri : string ) : ( string | undefined ) [] ;
}
declare module 'goog:goog.uri.utils' {
import alias = ಠ_ಠ.clutz.goog.uri.utils;
export = alias;
}
declare namespace ಠ_ಠ.clutz.goog.uri.utils {
/**
* The index of each URI component in the return value of goog.uri.utils.split.
*/
enum ComponentIndex {
DOMAIN ,
FRAGMENT ,
PATH ,
PORT ,
QUERY_DATA ,
SCHEME ,
USER_INFO ,
}
}
declare module 'goog:goog.uri.utils.ComponentIndex' {
import alias = ಠ_ಠ.clutz.goog.uri.utils.ComponentIndex;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.uri.utils {
/**
* An array representing a set of query parameters with alternating keys
* and values.
*
* Keys are assumed to be URI encoded already and live at even indices. See
* goog.uri.utils.QueryValue for details on how parameter values are encoded.
*
* Example:
* <pre>
* var data = [
* // Simple param: ?name=BobBarker
* 'name', 'BobBarker',
* // Conditional param -- may be omitted entirely.
* 'specialDietaryNeeds', hasDietaryNeeds() ? getDietaryNeeds() : null,
* // Multi-valued param: &house=LosAngeles&house=NewYork&house=null
* 'house', ['LosAngeles', 'NewYork', null]
* ];
* </pre>
*/
type QueryArray = any [] ;
}
declare module 'goog:goog.uri.utils.QueryArray' {
import alias = ಠ_ಠ.clutz.goog.uri.utils.QueryArray;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.uri.utils {
/**
* Supported query parameter values by the parameter serializing utilities.
*
* If a value is null or undefined, the key-value pair is skipped, as an easy
* way to omit parameters conditionally. Non-array parameters are converted
* to a string and URI encoded. Array values are expanded into multiple
* &key=value pairs, with each element stringized and URI-encoded.
*/
type QueryValue = any ;
}
declare module 'goog:goog.uri.utils.QueryValue' {
import alias = ಠ_ಠ.clutz.goog.uri.utils.QueryValue;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.uri.utils {
/**
* Standard supported query parameters.
*/
type StandardQueryParam = string &{clutzEnumBrand: never} ;
var StandardQueryParam : {
RANDOM : StandardQueryParam ,
};
}
declare module 'goog:goog.uri.utils.StandardQueryParam' {
import alias = ಠ_ಠ.clutz.goog.uri.utils.StandardQueryParam;
export default alias;
}
declare namespace ಠ_ಠ.clutz.goog.userAgent {
/**
* Whether the user agent is running on Android.
*/
var ANDROID : boolean ;
var ASSUME_ANDROID : boolean ;
var ASSUME_ANY_VERSION : boolean ;
var ASSUME_EDGE : boolean ;
var ASSUME_GECKO : boolean ;
var ASSUME_IE : boolean ;
var ASSUME_IPAD : boolean ;
var ASSUME_IPHONE : boolean ;
var ASSUME_IPOD : boolean ;
var ASSUME_LINUX : boolean ;
var ASSUME_MAC : boolean ;
var ASSUME_MOBILE_WEBKIT : boolean ;
var ASSUME_OPERA : boolean ;
var ASSUME_WEBKIT : boolean ;
var ASSUME_WINDOWS : boolean ;
var ASSUME_X11 : boolean ;
/**
* For IE version < 7, documentMode is undefined, so attempt to use the
* CSS1Compat property to see if we are in standards mode. If we are in
* standards mode, treat the browser version as the document mode. Otherwise,
* IE is emulating version 5.
*/
var DOCUMENT_MODE : number | undefined ;
/**
* Whether the user agent is Microsoft Edge.
*/
var EDGE : boolean ;
/**
* Whether the user agent is MS Internet Explorer or MS Edge.
*/
var EDGE_OR_IE : boolean ;
/**
* Whether the user agent is Gecko. Gecko is the rendering engine used by
* Mozilla, Firefox, and others.
*/
var GECKO : boolean ;
/**
* Whether the user agent is Internet Explorer.
*/
var IE : boolean ;
/**
* Whether the user agent is running on iOS.
*/
var IOS : boolean ;
/**
* Whether the user agent is running on an iPad.
*/
var IPAD : boolean ;
/**
* Whether the user agent is running on an iPhone.
*/
var IPHONE : boolean ;
/**
* Whether the user agent is running on an iPod.
*/
var IPOD : boolean ;
/**
* Whether the user agent is running on a Linux operating system.
*
* Note that goog.userAgent.LINUX considers ChromeOS to be Linux,
* while goog.labs.userAgent.platform considers ChromeOS and
* Linux to be different OSes.
*/
var LINUX : boolean ;
/**
* Whether the user agent is running on a Macintosh operating system.
*/
var MAC : boolean ;
/**
* Whether the user agent is running on a mobile device.
*
* TODO(nnaze): Consider deprecating MOBILE when labs.userAgent
* is promoted as the gecko/webkit logic is likely inaccurate.
*/
var MOBILE : boolean ;
/**
* Whether the user agent is Opera.
*/
var OPERA : boolean ;
/**
* The platform (operating system) the user agent is running on. Default to
* empty string because navigator.platform may not be defined (on Rhino, for
* example).
*/
var PLATFORM : string ;
/**
* Used while transitioning code to use WEBKIT instead.
*/
var SAFARI : boolean ;
/**
* The version of the user agent. This is a string because it might contain
* 'b' (as in beta) as well as multiple dots.
*/
var VERSION : string ;
/**
* Whether the user agent is WebKit. WebKit is the rendering engine that
* Safari, Android and others use.
*/
var WEBKIT : boolean ;
/**
* Whether the user agent is running on a Windows operating system.
*/
var WINDOWS : boolean ;
/**
* Whether the user agent is running on a X11 windowing system.
*/
var X11 : boolean ;
/**
* Compares two version numbers.
* @param v1 Version of first item.
* @param v2 Version of second item.
*/
function compare (v1 : string , v2 : string ) : number ;
/**
* TODO(nnaze): Change type to "Navigator" and update compilation targets.
*/
function getNavigator ( ) : GlobalObject | null ;
/**
* Returns the userAgent string for the current browser.
*/
function getUserAgentString ( ) : string ;
/**
* Deprecated alias to {@code goog.userAgent.isDocumentModeOrHigher}.
* @param version The version to check.
*/
function isDocumentMode (a : number ) : boolean ;
/**
* Whether the IE effective document mode is higher or the same as the given
* document mode version.
* NOTE: Only for IE, return false for another browser.
* @param documentMode The document mode version to check.
*/
function isDocumentModeOrHigher (documentMode : number ) : boolean ;
/**
* Deprecated alias to {@code goog.userAgent.isVersionOrHigher}.
* @param version The version to check.
*/
function isVersion (a : string | number ) : boolean ;
/**
* Whether the user agent version is higher or the same as the given version.
* NOTE: When checking the version numbers for Firefox and Safari, be sure to
* use the engine's version, not the browser's version number. For example,
* Firefox 3.0 corresponds to Gecko 1.9 and Safari 3.0 to Webkit 522.11.
* Opera and Internet Explorer versions match the product release number.<br>
* @param version The version to check.
*/
function isVersionOrHigher (version : string | number ) : boolean ;
}
declare module 'goog:goog.userAgent' {
import alias = ಠ_ಠ.clutz.goog.userAgent;
export = alias;
}
declare namespace ಠ_ಠ.clutz {
interface Body {
arrayBuffer ( ) : Promise < ArrayBuffer > ;
blob ( ) : Promise < Blob > ;
bodyUsed : boolean ;
formData ( ) : Promise < FormData > ;
json ( ) : Promise < any > ;
text ( ) : Promise < string > ;
}
}
declare namespace ಠ_ಠ.clutz {
class ByteLengthQueuingStrategy extends ByteLengthQueuingStrategy_Instance {
}
class ByteLengthQueuingStrategy_Instance {
private noStructuralTyping_: any;
constructor (config : { highWaterMark : number } ) ;
/**
* If we don't want to be strict we can define chunk as {*}
* and return as {number|undefined}
*/
size (chunk : { byteLength : number } ) : number ;
}
}
declare namespace ಠ_ಠ.clutz {
class CountQueuingStrategy extends CountQueuingStrategy_Instance {
}
class CountQueuingStrategy_Instance {
private noStructuralTyping_: any;
constructor (config : { highWaterMark : number } ) ;
size (chunk : any ) : number ;
}
}
declare namespace ಠ_ಠ.clutz {
class DirectoryEntry extends DirectoryEntry_Instance {
}
class DirectoryEntry_Instance extends Entry_Instance {
createReader ( ) : DirectoryReader ;
getDirectory (path : string , options ? : FileSystemFlags , successCallback ? : (a : DirectoryEntry ) => any , errorCallback ? : (a : FileError ) => any ) : void ;
getFile (path : string , options ? : FileSystemFlags , successCallback ? : (a : FileEntry ) => any , errorCallback ? : (a : FileError ) => any ) : void ;
removeRecursively (successCallback : ( ) => any , errorCallback ? : (a : FileError ) => any ) : void ;
}
}
declare namespace ಠ_ಠ.clutz {
class DirectoryReader extends DirectoryReader_Instance {
}
class DirectoryReader_Instance {
private noStructuralTyping_: any;
readEntries (successCallback : (a : Entry [] ) => any , errorCallback ? : (a : FileError ) => any ) : void ;
}
}
declare namespace ಠ_ಠ.clutz {
class Entry extends Entry_Instance {
}
class Entry_Instance {
private noStructuralTyping_: any;
copyTo (parent : DirectoryEntry , newName ? : string , successCallback ? : (a : Entry ) => any , errorCallback ? : (a : FileError ) => any ) : void ;
filesystem : FileSystem ;
fullPath : string ;
getMetadata (successCallback : (a : Metadata ) => any , errorCallback ? : (a : FileError ) => any ) : void ;
getParent (successCallback : (a : Entry ) => any , errorCallback ? : (a : FileError ) => any ) : void ;
isDirectory : boolean ;
isFile : boolean ;
moveTo (parent : DirectoryEntry , newName ? : string , successCallback ? : (a : Entry ) => any , errorCallback ? : (a : FileError ) => any ) : void ;
name : string ;
remove (successCallback : ( ) => any , errorCallback ? : (a : FileError ) => any ) : void ;
toURL (mimeType ? : string ) : string ;
}
}
declare namespace ಠ_ಠ.clutz {
class FileEntry extends FileEntry_Instance {
}
class FileEntry_Instance extends Entry_Instance {
createWriter (successCallback : (a : FileWriter ) => any , errorCallback ? : (a : FileError ) => any ) : void ;
file (successCallback : (a : File ) => any , errorCallback ? : (a : FileError ) => any ) : void ;
}
}
declare namespace ಠ_ಠ.clutz {
class FileError extends FileError_Instance {
static ABORT_ERR : number ;
static ENCODING_ERR : number ;
static INVALID_MODIFICATION_ERR : number ;
static INVALID_STATE_ERR : number ;
static NOT_FOUND_ERR : number ;
static NOT_READABLE_ERR : number ;
static NO_MODIFICATION_ALLOWED_ERR : number ;
static PATH_EXISTS_ERR : number ;
static QUOTA_EXCEEDED_ERR : number ;
static SECURITY_ERR : number ;
static SYNTAX_ERR : number ;
static TYPE_MISMATCH_ERR : number ;
}
class FileError_Instance extends DOMError {
ABORT_ERR : number ;
ENCODING_ERR : number ;
INVALID_MODIFICATION_ERR : number ;
INVALID_STATE_ERR : number ;
NOT_FOUND_ERR : number ;
NOT_READABLE_ERR : number ;
NO_MODIFICATION_ALLOWED_ERR : number ;
PATH_EXISTS_ERR : number ;
QUOTA_EXCEEDED_ERR : number ;
SECURITY_ERR : number ;
SYNTAX_ERR : number ;
TYPE_MISMATCH_ERR : number ;
code : number ;
}
}
declare namespace ಠ_ಠ.clutz {
class FileSaver extends FileSaver_Instance {
}
class FileSaver_Instance {
private noStructuralTyping_: any;
DONE : number ;
INIT : number ;
WRITING : number ;
abort ( ) : void ;
error : FileError | null ;
onabort : ( (a : ProgressEvent ) => any ) | null ;
onerror : ( (a : ProgressEvent ) => any ) | null ;
onprogress : ( (a : ProgressEvent ) => any ) | null ;
onwrite : ( (a : ProgressEvent ) => any ) | null ;
onwriteend : ( (a : ProgressEvent ) => any ) | null ;
onwritestart : ( (a : ProgressEvent ) => any ) | null ;
readyState : number ;
}
}
declare namespace ಠ_ಠ.clutz {
class FileSystem extends FileSystem_Instance {
}
class FileSystem_Instance {
private noStructuralTyping_: any;
name : string ;
root : DirectoryEntry ;
}
}
declare namespace ಠ_ಠ.clutz {
interface FileSystemFlags {
create ? : boolean ;
exclusive ? : boolean ;
}
}
declare namespace ಠ_ಠ.clutz {
class FileWriter extends FileWriter_Instance {
}
class FileWriter_Instance extends FileSaver_Instance {
length : number ;
position : number ;
seek (offset : number ) : void ;
truncate (size : number ) : void ;
write (blob : Blob ) : void ;
}
}
declare namespace ಠ_ಠ.clutz {
class Headers extends Headers_Instance {
}
class Headers_Instance implements Iterable < string [] > {
private noStructuralTyping_: any;
constructor (opt_headersInit ? : Headers | string [] [] | IObject < string , string > ) ;
//!! Symbol.iterator inserted by Clutz for Iterable subtype
[Symbol.iterator](): Iterator < string [] > ;
append (name : string , value : string ) : void ;
delete (name : string ) : void ;
entries ( ) : IterableIterator < string [] > ;
get (name : string ) : string | null ;
getAll (name : string ) : string [] ;
has (name : string ) : boolean ;
keys ( ) : Iterator < string > ;
set (name : string , value : string ) : void ;
values ( ) : Iterator < string > ;
}
}
declare namespace ಠ_ಠ.clutz {
class Image extends Image_Instance {
}
class Image_Instance extends HTMLImageElement {
constructor (opt_width ? : number , opt_height ? : number ) ;
}
}
declare namespace ಠ_ಠ.clutz {
/**
* This is the constructor for Intersection Observer objects.
*/
class IntersectionObserver extends IntersectionObserver_Instance {
}
class IntersectionObserver_Instance {
private noStructuralTyping_: any;
/**
* This is the constructor for Intersection Observer objects.
* @param handler The callback for the observer.
* @param opt_options The object defining the thresholds, etc.
*/
constructor (handler : (a : IntersectionObserverEntry [] , b : IntersectionObserver ) => any , opt_options ? : { root ? : Element , rootMargin ? : string , threshold ? : number [] | number } ) ;
/**
* Disconnect.
*/
disconnect ( ) : any ;
/**
* This is used to set which element to observe.
* @param element The element to observe.
*/
observe (element : Element ) : void ;
/**
* The root Element to use for intersection, or null if the observer uses the
* implicit root.
*/
root : Element | null ;
/**
* Offsets applied to the intersection root’s bounding box, effectively growing
* or shrinking the box that is used to calculate intersections.
*/
rootMargin : string ;
/**
* Take records.
*/
takeRecords ( ) : IntersectionObserverEntry [] ;
/**
* A list of thresholds, sorted in increasing numeric order, where each
* threshold is a ratio of intersection area to bounding box area of an observed
* target.
*/
thresholds : number [] ;
/**
* This is used to stop observing a given element.
* @param element The elmenent to stop observing.
*/
unobserve (element : Element ) : void ;
}
}
declare namespace ಠ_ಠ.clutz {
/**
* These contain the information provided from a change event.
*/
interface IntersectionObserverEntry {
/**
* The rectangle describing the element being observed.
*/
boundingClientRect : { bottom : number , height : number , left : number , right : number , top : number , width : number } ;
/**
* Ratio of intersectionRect area to boundingClientRect area.
*/
intersectionRatio : number ;
/**
* The rectangle describing the intersection between the observed element and
* the viewport.
*/
intersectionRect : { bottom : number , height : number , left : number , right : number , top : number , width : number } ;
/**
* Whether or not the target is intersecting with the root.
*/
isIntersecting : boolean ;
/**
* The root intersection rectangle, if target belongs to the same unit of
* related similar-origin browsing contexts as the intersection root, null
* otherwise.
*/
rootBounds : { bottom : number , height : number , left : number , right : number , top : number , width : number } ;
/**
* The Element whose intersection with the intersection root changed.
*/
target : Element ;
/**
* The time the change was observed.
*/
time : number ;
}
}
declare namespace ಠ_ಠ.clutz {
/**
* Metadata interface.
*/
class Metadata extends Metadata_Instance {
}
class Metadata_Instance {
private noStructuralTyping_: any;
modificationTime : Date ;
size : number ;
}
}
declare namespace ಠ_ಠ.clutz {
interface PipeOptions {
preventAbort ? : boolean ;
preventCancel ? : boolean ;
preventClose ? : boolean ;
}
}
declare namespace ಠ_ಠ.clutz {
/**
* The ReadableByteStreamController constructor cannot be used directly;
* it only works on a ReadableStream that is in the middle of being constructed.
*/
interface ReadableByteStreamController {
byobRequest : ReadableStreamBYOBRequest ;
close ( ) : void ;
desiredSize : number ;
enqueue (chunk : ArrayBufferView ) : void ;
error (err : any ) : void ;
}
}
declare namespace ಠ_ಠ.clutz {
class ReadableStream extends ReadableStream_Instance {
}
class ReadableStream_Instance {
private noStructuralTyping_: any;
constructor (opt_underlyingSource ? : ReadableStreamSource , opt_queuingStrategy ? : CountQueuingStrategy | ByteLengthQueuingStrategy | { highWaterMark : number , size ? : (a : any ) => number } ) ;
cancel (reason : any ) : Promise < undefined > ;
getReader (opt_options ? : { mode ? : string } ) : ReadableStreamDefaultReader | ReadableStreamBYOBReader ;
locked : boolean ;
pipeThrough (transform : TransformStream , opt_options ? : PipeOptions ) : ReadableStream ;
pipeTo (dest : WritableStream , opt_options ? : PipeOptions ) : Promise < undefined > ;
tee ( ) : ReadableStream [] ;
}
}
declare namespace ಠ_ಠ.clutz {
/**
* The ReadableStreamBYOBReader constructor is generally not meant to be used
* directly; instead, a stream’s getReader() method should be used.
*/
interface ReadableStreamBYOBReader {
cancel (reason : any ) : Promise < any > ;
closed : Promise < undefined > ;
read (view : ArrayBufferView ) : Promise < { done : boolean , value : any } > ;
releaseLock ( ) : void ;
}
}
declare namespace ಠ_ಠ.clutz {
interface ReadableStreamBYOBRequest {
respond (bytesWritten : number ) : void ;
respondWithNewView (view : ArrayBufferView ) : void ;
view : ArrayBufferView ;
}
}
declare namespace ಠ_ಠ.clutz {
/**
* The ReadableStreamDefaultController constructor cannot be used directly;
* it only works on a ReadableStream that is in the middle of being constructed.
*/
interface ReadableStreamDefaultController {
close ( ) : void ;
desiredSize : number ;
enqueue (chunk : any ) : void ;
error (err : any ) : void ;
}
}
declare namespace ಠ_ಠ.clutz {
/**
* The ReadableStreamDefaultReader constructor is generally not meant to be used directly;
* instead, a stream’s getReader() method should be used.
*/
interface ReadableStreamDefaultReader {
cancel (reason : any ) : Promise < any > ;
closed : Promise < undefined > ;
read ( ) : Promise < { done : boolean , value : any } > ;
releaseLock ( ) : void ;
}
}
declare namespace ಠ_ಠ.clutz {
interface ReadableStreamSource {
autoAllocateChunkSize ? : number ;
cancel ? : (a : any ) => Promise < any > | undefined ;
pull ? : (a : ReadableByteStreamController | ReadableStreamDefaultController ) => PromiseLike < any > | undefined ;
start ? : (a : ReadableByteStreamController | ReadableStreamDefaultController ) => PromiseLike < any > | undefined ;
type ? : string ;
}
}
declare namespace ಠ_ಠ.clutz {
class Request extends Request_Instance {
}
class Request_Instance implements Body {
private noStructuralTyping_: any;
constructor (input : Request | string , opt_init ? : RequestInit ) ;
arrayBuffer ( ) : Promise < ArrayBuffer > ;
blob ( ) : Promise < Blob > ;
bodyUsed : any ;
cache : string ;
clone ( ) : Request ;
credentials : string ;
destination : string ;
formData ( ) : Promise < FormData > ;
headers : Headers ;
integrity : string ;
json ( ) : Promise < any > ;
method : string ;
mode : string ;
redirect : string ;
referrer : string ;
text ( ) : Promise < string > ;
type : string ;
url : string ;
}
}
declare namespace ಠ_ಠ.clutz {
interface RequestInit {
body ? : Blob | ArrayBuffer | ArrayBufferView | FormData | string | null ;
cache ? : string ;
credentials ? : string ;
headers ? : Headers | string [] [] | IObject < string , string > ;
integrity ? : string ;
method ? : string ;
mode ? : string ;
redirect ? : string ;
referrer ? : string ;
referrerPolicy ? : string ;
window ? : null ;
}
}
declare namespace ಠ_ಠ.clutz {
class Response extends Response_Instance {
static error ( ) : Response ;
static redirect (url : string , opt_status ? : number ) : Response ;
}
class Response_Instance implements Body {
private noStructuralTyping_: any;
constructor (opt_body ? : Blob | ArrayBuffer | ArrayBufferView | FormData | string | ReadableStream | null , opt_init ? : ResponseInit ) ;
arrayBuffer ( ) : Promise < ArrayBuffer > ;
blob ( ) : Promise < Blob > ;
body : ReadableStream | null ;
bodyUsed : any ;
clone ( ) : Response ;
formData ( ) : Promise < FormData > ;
headers : Headers ;
json ( ) : Promise < any > ;
ok : boolean ;
redirected : boolean ;
status : number ;
statusText : string ;
text ( ) : Promise < string > ;
trailer : Promise < Headers > ;
type : string ;
url : string ;
}
}
declare namespace ಠ_ಠ.clutz {
interface ResponseInit {
headers ? : Headers | string [] [] | IObject < string , string > ;
status ? : number ;
statusText ? : string ;
}
}
declare namespace ಠ_ಠ.clutz {
interface TransformStream {
readable : ReadableStream ;
writable : WritableStream ;
}
}
declare namespace ಠ_ಠ.clutz {
interface WorkerLocation {
hash : string ;
host : string ;
hostname : string ;
href : string ;
origin : string ;
pathname : string ;
port : string ;
protocol : string ;
search : string ;
}
}
declare namespace ಠ_ಠ.clutz {
class WritableStream extends WritableStream_Instance {
}
class WritableStream_Instance {
private noStructuralTyping_: any;
constructor (opt_underlyingSink ? : WritableStreamSink , opt_queuingStrategy ? : CountQueuingStrategy | ByteLengthQueuingStrategy | { highWaterMark : number , size ? : (a : any ) => number } ) ;
abort (reason : any ) : Promise < undefined > ;
getWriter ( ) : WritableStreamDefaultWriter ;
locked : boolean ;
}
}
declare namespace ಠ_ಠ.clutz {
/**
* The WritableStreamDefaultController constructor cannot be used directly;
* it only works on a WritableStream that is in the middle of being constructed.
*/
interface WritableStreamDefaultController {
error (err : any ) : Promise < undefined > ;
}
}
declare namespace ಠ_ಠ.clutz {
interface WritableStreamDefaultWriter {
abort (reason : any ) : Promise < undefined > ;
close ( ) : Promise < undefined > ;
closed : Promise < undefined > ;
desiredSize : number ;
ready : Promise < number > ;
releaseLock ( ) : void ;
write (chunk : any ) : Promise < undefined > ;
}
}
declare namespace ಠ_ಠ.clutz {
interface WritableStreamSink {
abort ? : (a : any ) => PromiseLike < any > | undefined ;
close ? : ( ) => PromiseLike < any > | undefined ;
start ? : (a : WritableStreamDefaultController ) => PromiseLike < any > | undefined ;
write ? : (a : WritableStreamDefaultController ) => PromiseLike < any > | undefined ;
}
}
declare namespace ಠ_ಠ.clutz.window {
/**
* Callback for the IntersectionObserver.
*/
type IntersectionObserverCallback = (a : IntersectionObserverEntry [] , b : IntersectionObserver ) => any ;
}
declare namespace ಠ_ಠ.clutz.window {
/**
* Options for the IntersectionObserver.
*/
type IntersectionObserverInit = { root ? : Element , rootMargin ? : string , threshold ? : number [] | number } ;
}
declare namespace ಠ_ಠ.clutz.window {
type IteratorResult = { done : boolean , value : any } ;
}
declare namespace ಠ_ಠ.clutz.window {
type QueuingStrategy = CountQueuingStrategy | ByteLengthQueuingStrategy | { highWaterMark : number , size ? : (a : any ) => number } ;
}
declare namespace ಠ_ಠ.clutz.goog.defineClass {
type ClassDescriptor = { constructor ? : Function , statics ? : GlobalObject | null } ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment