MooTools 框架的 Google Closure 编译器外部文件
高级优化模式下的 Google Closure 编译器使用一个文件来定义 extern,以防止引用外部库中的符号的变量、属性和函数名称被缩小,从而破坏代码。我的目标是编译使用 MooTools 框架(版本 1.2 和 1.3)的代码,但我无法找到一个“官方”外部文件,该文件可以防止当我的代码被输入到闭包编译器时对 MooTools 函数的引用被混淆。我想出了以下相当基本的自定义 extern 文件,它成功处理了我的文件,但是有更好的替代方案(例如从 MooTools 源自动生成它)吗?
//
// Number
//
/**
* @param {number} min
* @param {number} max
* @return {number}
* @nosideeffects
*/
Number.prototype.limit = function (min, max) {}
/**
* @param {number=} precision
* @return {number}
* @nosideeffects
*/
Number.prototype.round = function (precision) {}
Number.prototype.times = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.toFloat = function () {}
/**
* @param {number=} base
* @return {number}
* @nosideeffects
*/
Number.prototype.toInt = function (base) {}
//
// Number.Math
//
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.abs = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.acos = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.asin = function () {}
/**
* @param {number} x
* @return {number}
* @nosideeffects
*/
Number.prototype.atan2 = function (x) {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.ceil = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.cos = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.exp = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.floor = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.log = function () {}
/**
* @param {...number} x
* @return {number}
* @nosideeffects
*/
Number.prototype.max = function (x) {}
/**
* @param {...number} x
* @return {number}
* @nosideeffects
*/
Number.prototype.min = function (x) {}
/**
* @param {number} x
* @return {number}
* @nosideeffects
*/
Number.prototype.pow = function (x) {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.sin = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.sqrt = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.tan = function () {}
//
// String
//
/**
* @return {boolean}
* @nosideeffects
*/
String.prototype.test = function () {}
/**
* @return {boolean}
* @nosideeffects
*/
String.prototype.contains = function () {}
/**
* @return {string}
* @nosideeffects
* @suppress {duplicate}
*/
String.prototype.trim = function () {}
/**
* @return {string}
* @nosideeffects
*/
String.prototype.clean = function () {}
/**
* @return {string}
* @nosideeffects
*/
String.prototype.camelCase = function () {}
/**
* @return {string}
* @nosideeffects
*/
String.prototype.hyphenate = function () {}
/**
* @return {string}
* @nosideeffects
*/
String.prototype.capitalize = function () {}
/**
* @return {string}
* @nosideeffects
*/
String.prototype.escapeRegExp = function () {}
/**
* @return {number}
* @nosideeffects
*/
String.prototype.toInt = function () {}
/**
* @return {number}
* @nosideeffects
*/
String.prototype.toFloat = function () {}
/**
* @return {(string|Array.<number>)}
* @nosideeffects
*/
String.prototype.hexToRgb = function () {}
/**
* @return {(string|Array.<string>)}
* @nosideeffects
*/
String.prototype.rgbToHex = function () {}
/**
* @return {string}
* @nosideeffects
*/
String.prototype.substitute = function () {}
/**
* @return {string}
* @nosideeffects
*/
String.prototype.stripScripts = function () {}
//
// Array
//
/**
* @param {function(*, number=, Array=) : undefined} fn
* @param {!Object=} bind
*/
Array.prototype.each = function (fn, bind) {}
Array.prototype.invoke = function () {}
/**
* @param {function(*, number=, Array=) : boolean} fn
* @param {!Object=} bind
* @return {boolean}
* @suppress {duplicate}
*/
Array.prototype.every = function (fn, bind) {}
/**
* @param {function(*, number=, Array=) : boolean} fn
* @param {!Object=} bind
* @return {Array}
* @suppress {duplicate}
*/
Array.prototype.filter = function (fn, bind) {}
/**
* @return Array
*/
Array.prototype.clean = function () {}
/**
* @param {*} item
* @param {number} from
* @return number
* @suppress {duplicate}
*/
Array.prototype.indexOf = function (item, from) {}
/**
* @param {function(*, number=, Array=) : *} fn
* @param {!Object=} bind
* @return {Array}
* @suppress {duplicate}
*/
Array.prototype.map = function (fn, bind) {}
/**
* @param {function(*, number=, Array=) : boolean} fn
* @param {!Object=} bind
* @return {boolean}
* @suppress {duplicate}
*/
Array.prototype.some = function (fn, bind) {}
/**
* @param {Array} obj
* @return {Object}
*/
Array.prototype.associate = function (obj) {}
/**
* @param {Object} obj
* @return {Object}
*/
Array.prototype.link = function (obj) {}
/**
* @param {*} item
* @param {number} from
* @return {boolean}
*/
Array.prototype.contains = function (item, from) {}
/**
* @param {Array} other
* @return {Array}
*/
Array.prototype.append = function (other) {}
/**
* @return {*}
*/
Array.prototype.getLast = function () {}
/**
* @return {*}
*/
Array.prototype.getRandom = function () {}
/**
* @param {*} item
* @return {Array}
*/
Array.prototype.include = function (item) {}
/**
* @param {Array} other
* @return {Array}
*/
Array.prototype.combine = function (other) {}
/**
* @param {*} item
* @return {Array}
*/
Array.prototype.erase = function (item) {}
/**
* @return {Array}
*/
Array.prototype.empty = function () {}
/**
* @return {Array}
*/
Array.prototype.flatten = function () {}
/**
* @return {*}
*/
Array.prototype.pick = function () {}
Array.prototype.hexToRgb = function () {}
Array.prototype.rgbToHex = function () {}
// Class
/**
* @constructor
* @param {(!Object|function())} properties
*/
function Class(properties) { }
/**
* @param {!Object} properties
*/
Class.prototype.implement = function (properties) {}
/**
* @constructor
*/
function Events() { }
/**
* @constructor
*/
function Options() { }
//
// Element
//
/**
* @constructor
* @param {(string|Element)} el
* @param {!Object=} properties
* @suppress {duplicate}
*/
function Element(el, properties) { }
/**
* @param {string} tag
* @return {Element}
*/
Element.prototype.getElement = function (tag) {}
/**
* @param {string} tag
* @return {Elements}
*/
Element.prototype.getElements = function (tag) {}
/**
* @param {string} id
* @return {Element}
*/
Element.prototype.getElementById = function (id) {}
/**
* @param {(string|!Object)} property
* @param {*=} value
* @return {Element}
*/
Element.prototype.set = function (property, value) {}
/**
* @param {string} property
* @return {*}
*/
Element.prototype.get = function (property) {}
/**
* @param {string} property
* @return {*}
*/
Element.prototype.erase = function (property) {}
/**
* @param {(string|Element)} match
* @return {boolean}
*/
Element.prototype.match = function (match) {}
/**
* @param {(string|Element)} el
* @return {boolean}
* @suppress {duplicate}
*/
Element.prototype.contains = function (el) {}
/**
* @param {(string|Element)} el
* @param {string=} where
* @return {Element}
*/
Element.prototype.inject = function (el, where) {}
/**
* @param {(string|Element)} el
* @param {string=} where
* @return {Element}
*/
Element.prototype.grab = function (el, where) {}
/**
* @param {(string|Element|Elements)} el
* @param {...(string|Element|Elements)} var_args
* @return {Element}
*/
Element.prototype.adopt = function (el,var_args) {}
/**
* @param {(string|Element)} el
* @param {string=} where
* @return {Element}
*/
Element.prototype.wraps = function (el, where) {}
/**
* @param {string} text
* @param {string=} where
* @return {Element}
*/
Element.prototype.appendText = function (text, where) {}
/**
* @return {undefined}
*/
Element.prototype.dispose = function () {}
/**
* @param {boolean=} contents
* @param {boolean=} keepid
* @return {Element}
*/
Element.prototype.clone = function (contents, keepid) {}
/**
* @param {(string|Element)} el
* @return {Element}
*/
Element.prototype.replaces = function (el) {}
/**
* @param {string} className
* @return {boolean}
*/
Element.prototype.hasClass = function (className) {}
/**
* @param {string} className
* @return {Element}
*/
Element.prototype.addClass = function (className) {}
/**
* @param {string} className
* @return {Element}
*/
Element.prototype.removeClass = function (className) {}
/**
* @param {string} className
* @param {boolean=} force
* @return {Element}
*/
Element.prototype.toggleClass = function (className, force) {}
/**
* @param {string=} match
* @return {Element}
*/
Element.prototype.getPrevious = function (match) {}
/**
* @param {string=} match
* @return {Elements}
*/
Element.prototype.getAllPrevious = function (match) {}
/**
* @param {string=} match
* @return {Element}
*/
Element.prototype.getNext = function (match) {}
/**
* @param {string=} match
* @return {Elements}
*/
Element.prototype.getAllNext = function (match) {}
/**
* @param {string=} match
* @return {Element}
*/
Element.prototype.getFirst = function (match) {}
/**
* @param {string=} match
* @return {Element}
*/
Element.prototype.getLast = function (match) {}
/**
* @param {string=} match
* @return {Element}
*/
Element.prototype.getParent = function (match) {}
/**
* @param {string=} match
* @return {Elements}
*/
Element.prototype.getParents = function (match) {}
/**
* @param {string=} match
* @return {Elements}
*/
Element.prototype.getSiblings = function (match) {}
/**
* @param {string=} match
* @return {Elements}
*/
Element.prototype.getChildren = function (match) {}
/**
* @return {Element}
*/
Element.prototype.empty = function () {}
Element.prototype.destroy = function () {}
/**
* @return {string}
*/
Element.prototype.toQueryString = function () {}
Element.prototype.getSelected = function () {}
/**
* @param {string} property
* @return {string}
*/
Element.prototype.getProperty = function (property) {}
/**
* @param {Array.<string>} properties
* @return {!Object}
*/
Element.prototype.getProperties = function (properties) {}
/**
* @param {string} property
* @param {*} value
* @return {Element}
*/
Element.prototype.setProperty = function (property, value) {}
/**
* @param {!Object} properties
* @return {Element}
*/
Element.prototype.setProperties = function (properties) {}
/**
* @param {string} property
* @return {Element}
*/
Element.prototype.removeProperty = function (property) {}
/**
* @param {Array.<string>} properties
* @return {Element}
*/
Element.prototype.removeProperties = function (properties) {}
/**
* @param {string} key
* @param {*} value
* @return {Element}
*/
Element.prototype.store = function (key, value) {}
/**
* @param {string} key
* @param {*=} def
* @return {*}
*/
Element.prototype.retrieve = function (key, def) {}
/**
* @param {string} key
* @return {Element}
*/
Element.prototype.eliminate = function (key) {}
/**
* @constructor
* @extends Array
*/
function Elements() { }
/**
* @param {(string|!Object)} property
* @param {*=} value
* @return {Element}
*/
Elements.prototype.set = function (property, value) {}
/**
* @param {string} className
* @return {Element}
*/
Elements.prototype.addClass = function (className) {}
/**
* @param {string} className
* @return {Element}
*/
Elements.prototype.removeClass = function (className) {}
/**
* @param {string} className
* @param {boolean=} force
* @return {Element}
*/
Elements.prototype.toggleClass = function (className, force) {}
/**
* @param {(string|Element)} arg
* @return {Element}
*/
function $(arg) {}
/**
* @param {(string|Array|Element|Elements)} arg
* @param {...Element} var_args
* @return {Elements}
*/
function $$(arg, var_args) {}
//
// Element.Style
//
/**
* @param {string} property
* @return {Element}
*/
Element.prototype.setStyle = function (property, value) {}
/**
* @param {string} property
* @return {string}
*/
Element.prototype.getStyle = function (property) {}
/**
* @param {!Object} styles
* @return {Element}
*/
Element.prototype.setStyles = function (styles) {}
/**
* @param {...string} var_args
*/
Element.prototype.getStyles = function (var_args) {}
//
// Element.Event
//
/**
* @param {string} type
* @param {function()} fn
* @return {Element}
*/
Element.prototype.addEvent = function (type, fn) {}
/**
* @param {string} type
* @param {function()} fn
* @return {Element}
*/
Element.prototype.removeEvent = function (type, fn) {}
/**
* @param {!Object} events
* @return {Element}
*/
Element.prototype.addEvents = function (events) {}
/**
* @param {(string|!Object)=} events
* @return {Element}
*/
Element.prototype.removeEvents = function (events) {}
/**
* @param {string} type
* @param {(Array|Object)=} args
* @param {number=} delay
* @return {Element}
*/
Element.prototype.fireEvent = function (type, args, delay) {}
/**
* @param {Element} from
* @param {string} type
* @return {Element}
*/
Element.prototype.cloneEvents = function (from, type) {}
/**
* @param {string} type
* @param {function()} fn
*/
window.addEvent = function (type, fn) {}
/**
* @param {string} type
* @param {function()} fn
*/
window.removeEvent = function (type, fn) {}
/**
* @param {!Object} events
*/
window.addEvents = function (events) {}
/**
* @param {(string|!Object)=} events
*/
window.removeEvents = function (events) {}
/**
* @param {string} type
* @param {(Array|Object)=} args
* @param {number=} delay
*/
window.fireEvent = function (type, args, delay) {}
/**
* @param {Element} from
* @param {string} type
*/
window.cloneEvents = function (from, type) {}
//
// Element.Dimensions
//
Element.prototype.scrollTo = function () {}
Element.prototype.getSize = function () {}
Element.prototype.getScrollSize = function () {}
Element.prototype.getScroll = function () {}
Element.prototype.getPosition = function () {}
Element.prototype.setPosition = function () {}
Element.prototype.getCoordinates = function () {}
Element.prototype.getOffsetParent = function () {}
window.scrollTo = function () {}
window.getSize = function () {}
window.getScrollSize = function () {}
window.getScroll = function () {}
//
// Fx
//
/**
* @constructor
*/
function Fx() {}
/**
* @constructor
* @param {(string|Element)} el
* @param {!Object=} options
*/
Fx.Tween = function (el, options) { }
Fx.Tween.prototype.set = function () { }
Fx.Tween.prototype.start = function () { }
/**
* @constructor
* @param {(string|Element)} el
* @param {!Object=} options
*/
Fx.Morph = function (el, options) { }
/**
* @param {(string|!Object)} properties
* @return {Fx.Morph}
*/
Fx.Morph.prototype.set = function (properties) { }
/**
* @param {(string|!Object)} properties
* @return {Fx.Morph}
*/
Fx.Morph.prototype.start = function (properties) { }
/**
* @return {Element}
*/
Element.prototype.tween = function () {}
/**
* @return {Element}
*/
Element.prototype.morph = function () {}
/**
* @return {Element}
*/
Element.prototype.fade = function () {}
/**
* @return {Element}
*/
Element.prototype.highlight = function () {}
//
// Fx.Transitions
//
/**
* @constructor
*/
Fx.Transitions = function () {}
Fx.Transitions.linear = function () {}
Fx.Transitions.quad = function () {}
Fx.Transitions.cubic = function () {}
Fx.Transitions.quart = function () {}
Fx.Transitions.quint = function () {}
Fx.Transitions.pow = function () {}
Fx.Transitions.expo = function () {}
Fx.Transitions.circ = function () {}
Fx.Transitions.sine = function () {}
Fx.Transitions.back = function () {}
Fx.Transitions.bounce = function () {}
Fx.Transitions.elastic = function () {}
//
// Request
//
/**
* @constructor
* @param {!Object=} options
*/
function Request(options) { }
Request.prototype.setHeader = function () {}
Request.prototype.getHeader = function () {}
Request.prototype.send = function () {}
Request.prototype.post = function () {}
Request.prototype.get = function () {}
Request.prototype.put = function () {}
Request.prototype.cancel = function () {}
Request.prototype.isRunning = function () {}
Element.prototype.send = function () {}
/**
* @constructor
* @extends Request
* @param {!Object=} options
*/
Request.HTML = function (options) { }
/**
* @constructor
* @extends Request
* @param {!Object=} options
*/
Request.JSON = function (options) { }
//
// JSON
//
/**
* @constructor
*/
function JSON() { }
/**
* @param {Object} obj
* @return {string}
*/
JSON.encode = function (obj) {}
/**
* @param {string} string
* @param {boolean=} secure
*/
JSON.decode = function (string, secure) {}
//
// Swiff
//
/**
* @constructor
* @param {string} path
* @param {!Object} options
*/
function Swiff(path, options) { }
//
// Compat
//
/**
* @param {...*} var_args
* @nosideeffects
*/
function $pick(var_args) { }
/**
* @param {...Object} var_args
* @nosideeffects
*/
function $merge(var_args) { }
Google Closure Compiler in advanced optimization mode uses a file to define externs that would prevent variable, property and function names that refer to symbols in an external library to be minified, thereby breaking code. My goal is to compile code that uses the MooTools framework (versions 1.2 and 1.3) yet I am unable to find an "official" extern file that would prevent references to MooTools functions from being obfuscated when my code is fed to the closure compiler. I have come up with the following rather rudimentary custom extern file that successfully processes my file but is there a better alternative (such as auto-generating it from MooTools source)?
//
// Number
//
/**
* @param {number} min
* @param {number} max
* @return {number}
* @nosideeffects
*/
Number.prototype.limit = function (min, max) {}
/**
* @param {number=} precision
* @return {number}
* @nosideeffects
*/
Number.prototype.round = function (precision) {}
Number.prototype.times = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.toFloat = function () {}
/**
* @param {number=} base
* @return {number}
* @nosideeffects
*/
Number.prototype.toInt = function (base) {}
//
// Number.Math
//
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.abs = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.acos = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.asin = function () {}
/**
* @param {number} x
* @return {number}
* @nosideeffects
*/
Number.prototype.atan2 = function (x) {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.ceil = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.cos = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.exp = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.floor = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.log = function () {}
/**
* @param {...number} x
* @return {number}
* @nosideeffects
*/
Number.prototype.max = function (x) {}
/**
* @param {...number} x
* @return {number}
* @nosideeffects
*/
Number.prototype.min = function (x) {}
/**
* @param {number} x
* @return {number}
* @nosideeffects
*/
Number.prototype.pow = function (x) {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.sin = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.sqrt = function () {}
/**
* @return {number}
* @nosideeffects
*/
Number.prototype.tan = function () {}
//
// String
//
/**
* @return {boolean}
* @nosideeffects
*/
String.prototype.test = function () {}
/**
* @return {boolean}
* @nosideeffects
*/
String.prototype.contains = function () {}
/**
* @return {string}
* @nosideeffects
* @suppress {duplicate}
*/
String.prototype.trim = function () {}
/**
* @return {string}
* @nosideeffects
*/
String.prototype.clean = function () {}
/**
* @return {string}
* @nosideeffects
*/
String.prototype.camelCase = function () {}
/**
* @return {string}
* @nosideeffects
*/
String.prototype.hyphenate = function () {}
/**
* @return {string}
* @nosideeffects
*/
String.prototype.capitalize = function () {}
/**
* @return {string}
* @nosideeffects
*/
String.prototype.escapeRegExp = function () {}
/**
* @return {number}
* @nosideeffects
*/
String.prototype.toInt = function () {}
/**
* @return {number}
* @nosideeffects
*/
String.prototype.toFloat = function () {}
/**
* @return {(string|Array.<number>)}
* @nosideeffects
*/
String.prototype.hexToRgb = function () {}
/**
* @return {(string|Array.<string>)}
* @nosideeffects
*/
String.prototype.rgbToHex = function () {}
/**
* @return {string}
* @nosideeffects
*/
String.prototype.substitute = function () {}
/**
* @return {string}
* @nosideeffects
*/
String.prototype.stripScripts = function () {}
//
// Array
//
/**
* @param {function(*, number=, Array=) : undefined} fn
* @param {!Object=} bind
*/
Array.prototype.each = function (fn, bind) {}
Array.prototype.invoke = function () {}
/**
* @param {function(*, number=, Array=) : boolean} fn
* @param {!Object=} bind
* @return {boolean}
* @suppress {duplicate}
*/
Array.prototype.every = function (fn, bind) {}
/**
* @param {function(*, number=, Array=) : boolean} fn
* @param {!Object=} bind
* @return {Array}
* @suppress {duplicate}
*/
Array.prototype.filter = function (fn, bind) {}
/**
* @return Array
*/
Array.prototype.clean = function () {}
/**
* @param {*} item
* @param {number} from
* @return number
* @suppress {duplicate}
*/
Array.prototype.indexOf = function (item, from) {}
/**
* @param {function(*, number=, Array=) : *} fn
* @param {!Object=} bind
* @return {Array}
* @suppress {duplicate}
*/
Array.prototype.map = function (fn, bind) {}
/**
* @param {function(*, number=, Array=) : boolean} fn
* @param {!Object=} bind
* @return {boolean}
* @suppress {duplicate}
*/
Array.prototype.some = function (fn, bind) {}
/**
* @param {Array} obj
* @return {Object}
*/
Array.prototype.associate = function (obj) {}
/**
* @param {Object} obj
* @return {Object}
*/
Array.prototype.link = function (obj) {}
/**
* @param {*} item
* @param {number} from
* @return {boolean}
*/
Array.prototype.contains = function (item, from) {}
/**
* @param {Array} other
* @return {Array}
*/
Array.prototype.append = function (other) {}
/**
* @return {*}
*/
Array.prototype.getLast = function () {}
/**
* @return {*}
*/
Array.prototype.getRandom = function () {}
/**
* @param {*} item
* @return {Array}
*/
Array.prototype.include = function (item) {}
/**
* @param {Array} other
* @return {Array}
*/
Array.prototype.combine = function (other) {}
/**
* @param {*} item
* @return {Array}
*/
Array.prototype.erase = function (item) {}
/**
* @return {Array}
*/
Array.prototype.empty = function () {}
/**
* @return {Array}
*/
Array.prototype.flatten = function () {}
/**
* @return {*}
*/
Array.prototype.pick = function () {}
Array.prototype.hexToRgb = function () {}
Array.prototype.rgbToHex = function () {}
// Class
/**
* @constructor
* @param {(!Object|function())} properties
*/
function Class(properties) { }
/**
* @param {!Object} properties
*/
Class.prototype.implement = function (properties) {}
/**
* @constructor
*/
function Events() { }
/**
* @constructor
*/
function Options() { }
//
// Element
//
/**
* @constructor
* @param {(string|Element)} el
* @param {!Object=} properties
* @suppress {duplicate}
*/
function Element(el, properties) { }
/**
* @param {string} tag
* @return {Element}
*/
Element.prototype.getElement = function (tag) {}
/**
* @param {string} tag
* @return {Elements}
*/
Element.prototype.getElements = function (tag) {}
/**
* @param {string} id
* @return {Element}
*/
Element.prototype.getElementById = function (id) {}
/**
* @param {(string|!Object)} property
* @param {*=} value
* @return {Element}
*/
Element.prototype.set = function (property, value) {}
/**
* @param {string} property
* @return {*}
*/
Element.prototype.get = function (property) {}
/**
* @param {string} property
* @return {*}
*/
Element.prototype.erase = function (property) {}
/**
* @param {(string|Element)} match
* @return {boolean}
*/
Element.prototype.match = function (match) {}
/**
* @param {(string|Element)} el
* @return {boolean}
* @suppress {duplicate}
*/
Element.prototype.contains = function (el) {}
/**
* @param {(string|Element)} el
* @param {string=} where
* @return {Element}
*/
Element.prototype.inject = function (el, where) {}
/**
* @param {(string|Element)} el
* @param {string=} where
* @return {Element}
*/
Element.prototype.grab = function (el, where) {}
/**
* @param {(string|Element|Elements)} el
* @param {...(string|Element|Elements)} var_args
* @return {Element}
*/
Element.prototype.adopt = function (el,var_args) {}
/**
* @param {(string|Element)} el
* @param {string=} where
* @return {Element}
*/
Element.prototype.wraps = function (el, where) {}
/**
* @param {string} text
* @param {string=} where
* @return {Element}
*/
Element.prototype.appendText = function (text, where) {}
/**
* @return {undefined}
*/
Element.prototype.dispose = function () {}
/**
* @param {boolean=} contents
* @param {boolean=} keepid
* @return {Element}
*/
Element.prototype.clone = function (contents, keepid) {}
/**
* @param {(string|Element)} el
* @return {Element}
*/
Element.prototype.replaces = function (el) {}
/**
* @param {string} className
* @return {boolean}
*/
Element.prototype.hasClass = function (className) {}
/**
* @param {string} className
* @return {Element}
*/
Element.prototype.addClass = function (className) {}
/**
* @param {string} className
* @return {Element}
*/
Element.prototype.removeClass = function (className) {}
/**
* @param {string} className
* @param {boolean=} force
* @return {Element}
*/
Element.prototype.toggleClass = function (className, force) {}
/**
* @param {string=} match
* @return {Element}
*/
Element.prototype.getPrevious = function (match) {}
/**
* @param {string=} match
* @return {Elements}
*/
Element.prototype.getAllPrevious = function (match) {}
/**
* @param {string=} match
* @return {Element}
*/
Element.prototype.getNext = function (match) {}
/**
* @param {string=} match
* @return {Elements}
*/
Element.prototype.getAllNext = function (match) {}
/**
* @param {string=} match
* @return {Element}
*/
Element.prototype.getFirst = function (match) {}
/**
* @param {string=} match
* @return {Element}
*/
Element.prototype.getLast = function (match) {}
/**
* @param {string=} match
* @return {Element}
*/
Element.prototype.getParent = function (match) {}
/**
* @param {string=} match
* @return {Elements}
*/
Element.prototype.getParents = function (match) {}
/**
* @param {string=} match
* @return {Elements}
*/
Element.prototype.getSiblings = function (match) {}
/**
* @param {string=} match
* @return {Elements}
*/
Element.prototype.getChildren = function (match) {}
/**
* @return {Element}
*/
Element.prototype.empty = function () {}
Element.prototype.destroy = function () {}
/**
* @return {string}
*/
Element.prototype.toQueryString = function () {}
Element.prototype.getSelected = function () {}
/**
* @param {string} property
* @return {string}
*/
Element.prototype.getProperty = function (property) {}
/**
* @param {Array.<string>} properties
* @return {!Object}
*/
Element.prototype.getProperties = function (properties) {}
/**
* @param {string} property
* @param {*} value
* @return {Element}
*/
Element.prototype.setProperty = function (property, value) {}
/**
* @param {!Object} properties
* @return {Element}
*/
Element.prototype.setProperties = function (properties) {}
/**
* @param {string} property
* @return {Element}
*/
Element.prototype.removeProperty = function (property) {}
/**
* @param {Array.<string>} properties
* @return {Element}
*/
Element.prototype.removeProperties = function (properties) {}
/**
* @param {string} key
* @param {*} value
* @return {Element}
*/
Element.prototype.store = function (key, value) {}
/**
* @param {string} key
* @param {*=} def
* @return {*}
*/
Element.prototype.retrieve = function (key, def) {}
/**
* @param {string} key
* @return {Element}
*/
Element.prototype.eliminate = function (key) {}
/**
* @constructor
* @extends Array
*/
function Elements() { }
/**
* @param {(string|!Object)} property
* @param {*=} value
* @return {Element}
*/
Elements.prototype.set = function (property, value) {}
/**
* @param {string} className
* @return {Element}
*/
Elements.prototype.addClass = function (className) {}
/**
* @param {string} className
* @return {Element}
*/
Elements.prototype.removeClass = function (className) {}
/**
* @param {string} className
* @param {boolean=} force
* @return {Element}
*/
Elements.prototype.toggleClass = function (className, force) {}
/**
* @param {(string|Element)} arg
* @return {Element}
*/
function $(arg) {}
/**
* @param {(string|Array|Element|Elements)} arg
* @param {...Element} var_args
* @return {Elements}
*/
function $(arg, var_args) {}
//
// Element.Style
//
/**
* @param {string} property
* @return {Element}
*/
Element.prototype.setStyle = function (property, value) {}
/**
* @param {string} property
* @return {string}
*/
Element.prototype.getStyle = function (property) {}
/**
* @param {!Object} styles
* @return {Element}
*/
Element.prototype.setStyles = function (styles) {}
/**
* @param {...string} var_args
*/
Element.prototype.getStyles = function (var_args) {}
//
// Element.Event
//
/**
* @param {string} type
* @param {function()} fn
* @return {Element}
*/
Element.prototype.addEvent = function (type, fn) {}
/**
* @param {string} type
* @param {function()} fn
* @return {Element}
*/
Element.prototype.removeEvent = function (type, fn) {}
/**
* @param {!Object} events
* @return {Element}
*/
Element.prototype.addEvents = function (events) {}
/**
* @param {(string|!Object)=} events
* @return {Element}
*/
Element.prototype.removeEvents = function (events) {}
/**
* @param {string} type
* @param {(Array|Object)=} args
* @param {number=} delay
* @return {Element}
*/
Element.prototype.fireEvent = function (type, args, delay) {}
/**
* @param {Element} from
* @param {string} type
* @return {Element}
*/
Element.prototype.cloneEvents = function (from, type) {}
/**
* @param {string} type
* @param {function()} fn
*/
window.addEvent = function (type, fn) {}
/**
* @param {string} type
* @param {function()} fn
*/
window.removeEvent = function (type, fn) {}
/**
* @param {!Object} events
*/
window.addEvents = function (events) {}
/**
* @param {(string|!Object)=} events
*/
window.removeEvents = function (events) {}
/**
* @param {string} type
* @param {(Array|Object)=} args
* @param {number=} delay
*/
window.fireEvent = function (type, args, delay) {}
/**
* @param {Element} from
* @param {string} type
*/
window.cloneEvents = function (from, type) {}
//
// Element.Dimensions
//
Element.prototype.scrollTo = function () {}
Element.prototype.getSize = function () {}
Element.prototype.getScrollSize = function () {}
Element.prototype.getScroll = function () {}
Element.prototype.getPosition = function () {}
Element.prototype.setPosition = function () {}
Element.prototype.getCoordinates = function () {}
Element.prototype.getOffsetParent = function () {}
window.scrollTo = function () {}
window.getSize = function () {}
window.getScrollSize = function () {}
window.getScroll = function () {}
//
// Fx
//
/**
* @constructor
*/
function Fx() {}
/**
* @constructor
* @param {(string|Element)} el
* @param {!Object=} options
*/
Fx.Tween = function (el, options) { }
Fx.Tween.prototype.set = function () { }
Fx.Tween.prototype.start = function () { }
/**
* @constructor
* @param {(string|Element)} el
* @param {!Object=} options
*/
Fx.Morph = function (el, options) { }
/**
* @param {(string|!Object)} properties
* @return {Fx.Morph}
*/
Fx.Morph.prototype.set = function (properties) { }
/**
* @param {(string|!Object)} properties
* @return {Fx.Morph}
*/
Fx.Morph.prototype.start = function (properties) { }
/**
* @return {Element}
*/
Element.prototype.tween = function () {}
/**
* @return {Element}
*/
Element.prototype.morph = function () {}
/**
* @return {Element}
*/
Element.prototype.fade = function () {}
/**
* @return {Element}
*/
Element.prototype.highlight = function () {}
//
// Fx.Transitions
//
/**
* @constructor
*/
Fx.Transitions = function () {}
Fx.Transitions.linear = function () {}
Fx.Transitions.quad = function () {}
Fx.Transitions.cubic = function () {}
Fx.Transitions.quart = function () {}
Fx.Transitions.quint = function () {}
Fx.Transitions.pow = function () {}
Fx.Transitions.expo = function () {}
Fx.Transitions.circ = function () {}
Fx.Transitions.sine = function () {}
Fx.Transitions.back = function () {}
Fx.Transitions.bounce = function () {}
Fx.Transitions.elastic = function () {}
//
// Request
//
/**
* @constructor
* @param {!Object=} options
*/
function Request(options) { }
Request.prototype.setHeader = function () {}
Request.prototype.getHeader = function () {}
Request.prototype.send = function () {}
Request.prototype.post = function () {}
Request.prototype.get = function () {}
Request.prototype.put = function () {}
Request.prototype.cancel = function () {}
Request.prototype.isRunning = function () {}
Element.prototype.send = function () {}
/**
* @constructor
* @extends Request
* @param {!Object=} options
*/
Request.HTML = function (options) { }
/**
* @constructor
* @extends Request
* @param {!Object=} options
*/
Request.JSON = function (options) { }
//
// JSON
//
/**
* @constructor
*/
function JSON() { }
/**
* @param {Object} obj
* @return {string}
*/
JSON.encode = function (obj) {}
/**
* @param {string} string
* @param {boolean=} secure
*/
JSON.decode = function (string, secure) {}
//
// Swiff
//
/**
* @constructor
* @param {string} path
* @param {!Object} options
*/
function Swiff(path, options) { }
//
// Compat
//
/**
* @param {...*} var_args
* @nosideeffects
*/
function $pick(var_args) { }
/**
* @param {...Object} var_args
* @nosideeffects
*/
function $merge(var_args) { }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
全面的扩展文件只是在高级模式下使用闭包编译器的第一步。库本身必须被编写(或修改)才能使用。
externs 文件只能防止一类问题——属性和函数重命名。但是,如果不仔细清理库代码库,某些代码结构可能会在编译后中断。
例如,死代码删除可以轻松删除错误的代码(或保留应删除的代码)。意外的别名可能会阻止大多数优化的发生。 “危险地使用这个”可能会在最毫无戒心的地方破坏代码。
因此,即使您的代码可以编译并与 externs 文件一起正常工作,并不意味着其他 MooTools 程序也可以正常工作。此外,当您不知不觉地使用在编译时中断的功能时,这并不意味着您的程序的下一个版本不会中断。
A comprehensive extens file is just the first step of using the Closure Compiler in Advanced mode. The library itself has to be written (or modified) to be useable.
An externs file merely prevents one sort of problem only -- that of property and function renaming. However, some code constructs may break after compilation if the library code base is not carefully scrubbed.
For example, dead-code removal can easily remove the wrong code (or leave along code that should be removed). Unintended aliases can prevent most optimizations from happening. "Dangerous use of this" can break code in the most unsuspecting places.
Therefore, even if your code compiles and work fine with your externs file, it doesn't mean that other MooTools programs will work fine. Moreover, it doesn't mean that the next revision of your program will not break when you unknowingly uses a feature that breaks under compilation.
闭包编译器贡献的 externs 文件位于 http: //code.google.com/p/closure-compiler/source/browse/#svn%2Ftrunk%2Fcontrib%2Fexterns 。正如您所看到的,其中有许多流行库的外部文件。
如果你有一些可以工作的东西,请继续使用它,也许可以用你的 mootools externs 向闭包编译器人员发送补丁。这样一群人就可以帮助维护它。他们很高兴收到上传到问题的补丁:http://code.google .com/p/closure-compiler/issues/list
The closure compiler contributed externs files go in http://code.google.com/p/closure-compiler/source/browse/#svn%2Ftrunk%2Fcontrib%2Fexterns . As you can see there are a number of externs files for popular libraries in there.
If you have something that work, go ahead and use it, and maybe send a patch to the closure compilers people with your mootools externs. That way a bunch of people can help maintain it. They're happy to receive patches as uploads to issues : http://code.google.com/p/closure-compiler/issues/list