Deprecate js globals

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2019-10-04 11:40:35 +02:00
parent 9d6a58e6ae
commit af995b8ab9
No known key found for this signature in database
GPG Key ID: F941078878347C0C
3 changed files with 22 additions and 21 deletions

View File

@ -787,7 +787,7 @@ function B(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
var Ne=function(){void 0===window.TESTING&&console.warn.apply(console,arguments)},Be=function(e,t){var n=e,i=function(){return Ne("The ".concat(t," library is deprecated! It will be removed in nextcloud 19.")),n.apply(this,arguments)};return Object.assign(i,n),i},Re=function(e,t,n){void 0!==window[e]&&delete window[e],Object.defineProperty(window,e,{get:function(){return Ne(n?"".concat(e," is deprecated: ").concat(n):"".concat(e," is deprecated")),t()}})};window._=c.a,window.$=a.a,window.autosize=ee.a,window.Backbone=ne.a,window.Clipboard=re.a,window.ClipboardJS=re.a,window.dav=se.a,Re("DOMPurify",(function(){return le.a}),"The global DOMPurify is deprecated, ship your own"),window.Handlebars=ce.a,window.jstimezonedetect=he.a,window.jstz=he.a,window.jQuery=a.a,window.marked=Be(pe.a,"marked"),window.md5=ge.a,window.moment=h.a,window.OC=l.a,Re("initCore",(function(){return Z}),"this is an internal function"),Re("oc_appswebroots",(function(){return l.a.appswebroots}),"use OC.appswebroots instead"),Re("oc_capabilities",l.a.getCapabilities,"use OC.getCapabilities instead"),Re("oc_config",(function(){return l.a.config}),"use OC.config instead"),Re("oc_current_user",(function(){return l.a.getCurrentUser().uid}),"use OC.getCurrentUser().uid instead"),Re("oc_debug",(function(){return l.a.debug}),"use OC.debug instead"),Re("oc_defaults",(function(){return l.a.theme}),"use OC.theme instead"),Re("oc_isadmin",l.a.isUserAdmin,"use OC.isUserAdmin() instead"),Re("oc_requesttoken",(function(){return Object(J.a)()}),"use OC.requestToken instead"),Re("oc_webroot",(function(){return l.a.webroot}),"use OC.getRootPath() instead"),Re("OCDialogs",(function(){return l.a.dialogs}),"use OC.dialogs instead"),window.OCP=He,window.OCA=Ie.a,window.escapeHTML=Be(ze.a,"escapeHTML"),window.formatDate=Be(( var Ne=function(){void 0===window.TESTING&&console.warn.apply(console,arguments)},Be=function(e,t,n){var i=e,r=function(){return Ne("The ".concat(t," library is deprecated! It will be removed in nextcloud ").concat(n,".")),i.apply(this,arguments)};return Object.assign(r,i),r},Re=function(e,t,n){void 0!==window[e]&&delete window[e],Object.defineProperty(window,e,{get:function(){return Ne(n?"".concat(e," is deprecated: ").concat(n):"".concat(e," is deprecated")),t()}})};window._=c.a,window.$=a.a,Re("autosize",(function(){return ee.a}),"please ship your own, this will be removed in Nextcloud 20"),Re("Backbone",(function(){return ne.a}),"please ship your own, this will be removed in Nextcloud 20"),Re("Clipboard",(function(){return re.a}),"please ship your own, this will be removed in Nextcloud 20"),Re("ClipboardJS",(function(){return re.a}),"please ship your own, this will be removed in Nextcloud 20"),window.dav=se.a,Re("DOMPurify",(function(){return le.a}),"The global DOMPurify is deprecated, ship your own"),Re("Handlebars",(function(){return ce.a}),"please ship your own, this will be removed in Nextcloud 20"),Re("jstimezonedetect",(function(){return he.a}),"please ship your own, this will be removed in Nextcloud 20"),Re("jstz",(function(){return he.a}),"please ship your own, this will be removed in Nextcloud 20"),window.jQuery=a.a,window.marked=Be(pe.a,"marked",19),Re("md5",(function(){return ge.a}),"please ship your own, this will be removed in Nextcloud 20"),Re("moment",(function(){return h.a}),"please ship your own, this will be removed in Nextcloud 20"),window.OC=l.a,Re("initCore",(function(){return Z}),"this is an internal function"),Re("oc_appswebroots",(function(){return l.a.appswebroots}),"use OC.appswebroots instead"),Re("oc_capabilities",l.a.getCapabilities,"use OC.getCapabilities instead"),Re("oc_config",(function(){return l.a.config}),"use OC.config instead"),Re("oc_current_user",(function(){return l.a.getCurrentUser().uid}),"use OC.getCurrentUser().uid instead"),Re("oc_debug",(function(){return l.a.debug}),"use OC.debug instead"),Re("oc_defaults",(function(){return l.a.theme}),"use OC.theme instead"),Re("oc_isadmin",l.a.isUserAdmin,"use OC.isUserAdmin() instead"),Re("oc_requesttoken",(function(){return Object(J.a)()}),"use OC.requestToken instead"),Re("oc_webroot",(function(){return l.a.webroot}),"use OC.getRootPath() instead"),Re("OCDialogs",(function(){return l.a.dialogs}),"use OC.dialogs instead"),window.OCP=He,window.OCA=Ie.a,window.escapeHTML=Be(ze.a,"escapeHTML",19),window.formatDate=Be((
/* /*
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
* *
@ -828,7 +828,7 @@ function(e){return console.warn("formatDate is deprecated, use OC.Util.formatDat
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/),"formatDate"),window.getURLParameter=Be((function(e){return decodeURIComponent((new RegExp("[?|&]"+e+"=([^&;]+?)(&|#|;|$)").exec(location.search)||[,""])[1].replace(/\+/g,"%20"))||""}),"getURLParameter"),window.humanFileSize=Be(Fe.a,"humanFileSize"),window.relative_modified_date=Be((function(e){return console.warn("relativeModifiedDate is deprecated, use OC.Util.relativeModifiedDate instead"),l.a.Util.relativeModifiedDate(1e3*e)}),"relative_modified_date"),a.a.fn.select2=Be(a.a.fn.select2,"select2"),window.t=c.a.bind(l.a.L10N.translate,l.a.L10N),window.n=c.a.bind(l.a.L10N.translatePlural,l.a.L10N), */),"formatDate",19),window.getURLParameter=Be((function(e){return decodeURIComponent((new RegExp("[?|&]"+e+"=([^&;]+?)(&|#|;|$)").exec(location.search)||[,""])[1].replace(/\+/g,"%20"))||""}),"getURLParameter",19),window.humanFileSize=Be(Fe.a,"humanFileSize",19),window.relative_modified_date=Be((function(e){return console.warn("relativeModifiedDate is deprecated, use OC.Util.relativeModifiedDate instead"),l.a.Util.relativeModifiedDate(1e3*e)}),"relative_modified_date",19),a.a.fn.select2=Be(a.a.fn.select2,"select2",19),window.t=c.a.bind(l.a.L10N.translate,l.a.L10N),window.n=c.a.bind(l.a.L10N.translatePlural,l.a.L10N),
/* /*
* @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at> * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
* *

File diff suppressed because one or more lines are too long

View File

@ -73,12 +73,13 @@ const warnIfNotTesting = function() {
* *
* @param {Function} func the library to deprecate * @param {Function} func the library to deprecate
* @param {String} funcName the name of the library * @param {String} funcName the name of the library
* @param {Int} version the version this gets removed
* @returns {function} * @returns {function}
*/ */
const deprecate = (func, funcName) => { const deprecate = (func, funcName, version) => {
const oldFunc = func const oldFunc = func
const newFunc = function() { const newFunc = function() {
warnIfNotTesting(`The ${funcName} library is deprecated! It will be removed in nextcloud 19.`) warnIfNotTesting(`The ${funcName} library is deprecated! It will be removed in nextcloud ${version}.`)
return oldFunc.apply(this, arguments) return oldFunc.apply(this, arguments)
} }
Object.assign(newFunc, oldFunc) Object.assign(newFunc, oldFunc)
@ -104,19 +105,19 @@ const setDeprecatedProp = (global, cb, msg) => {
window['_'] = _ window['_'] = _
window['$'] = $ window['$'] = $
window['autosize'] = autosize setDeprecatedProp('autosize', () => autosize, 'please ship your own, this will be removed in Nextcloud 20')
window['Backbone'] = Backbone setDeprecatedProp('Backbone', () => Backbone, 'please ship your own, this will be removed in Nextcloud 20')
window['Clipboard'] = ClipboardJS setDeprecatedProp('Clipboard', () => ClipboardJS, 'please ship your own, this will be removed in Nextcloud 20')
window['ClipboardJS'] = ClipboardJS setDeprecatedProp('ClipboardJS', () => ClipboardJS, 'please ship your own, this will be removed in Nextcloud 20')
window['dav'] = dav window['dav'] = dav
setDeprecatedProp('DOMPurify', () => DOMPurify, 'The global DOMPurify is deprecated, ship your own') setDeprecatedProp('DOMPurify', () => DOMPurify, 'The global DOMPurify is deprecated, ship your own')
window['Handlebars'] = Handlebars setDeprecatedProp('Handlebars', () => Handlebars, 'please ship your own, this will be removed in Nextcloud 20')
window['jstimezonedetect'] = jstimezonedetect setDeprecatedProp('jstimezonedetect', () => jstimezonedetect, 'please ship your own, this will be removed in Nextcloud 20')
window['jstz'] = jstimezonedetect setDeprecatedProp('jstz', () => jstimezonedetect, 'please ship your own, this will be removed in Nextcloud 20')
window['jQuery'] = $ window['jQuery'] = $
window['marked'] = deprecate(marked, 'marked') window['marked'] = deprecate(marked, 'marked', 19)
window['md5'] = md5 setDeprecatedProp('md5', () => md5, 'please ship your own, this will be removed in Nextcloud 20')
window['moment'] = moment setDeprecatedProp('moment', () => moment, 'please ship your own, this will be removed in Nextcloud 20')
window['OC'] = OC window['OC'] = OC
setDeprecatedProp('initCore', () => initCore, 'this is an internal function') setDeprecatedProp('initCore', () => initCore, 'this is an internal function')
@ -132,12 +133,12 @@ setDeprecatedProp('oc_webroot', () => OC.webroot, 'use OC.getRootPath() instead'
setDeprecatedProp('OCDialogs', () => OC.dialogs, 'use OC.dialogs instead') setDeprecatedProp('OCDialogs', () => OC.dialogs, 'use OC.dialogs instead')
window['OCP'] = OCP window['OCP'] = OCP
window['OCA'] = OCA window['OCA'] = OCA
window['escapeHTML'] = deprecate(escapeHTML, 'escapeHTML') window['escapeHTML'] = deprecate(escapeHTML, 'escapeHTML', 19)
window['formatDate'] = deprecate(formatDate, 'formatDate') window['formatDate'] = deprecate(formatDate, 'formatDate', 19)
window['getURLParameter'] = deprecate(getURLParameter, 'getURLParameter') window['getURLParameter'] = deprecate(getURLParameter, 'getURLParameter', 19)
window['humanFileSize'] = deprecate(humanFileSize, 'humanFileSize') window['humanFileSize'] = deprecate(humanFileSize, 'humanFileSize', 19)
window['relative_modified_date'] = deprecate(relativeModifiedDate, 'relative_modified_date') window['relative_modified_date'] = deprecate(relativeModifiedDate, 'relative_modified_date', 19)
$.fn.select2 = deprecate($.fn.select2, 'select2') $.fn.select2 = deprecate($.fn.select2, 'select2', 19)
/** /**
* translate a string * translate a string