Browse Source

Merge pull request #17402 from nextcloud/td/js_deprecate/jstimezonedetect

Deprecate a lot of global js
tags/v18.0.0beta1
Roeland Jago Douma 4 years ago
parent
commit
b076e3a17d
No account linked to committer's email address
3 changed files with 22 additions and 21 deletions
  1. 2
    2
      core/js/dist/main.js
  2. 1
    1
      core/js/dist/main.js.map
  3. 19
    18
      core/src/globals.js

+ 2
- 2
core/js/dist/main.js 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
* 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>
*
@@ -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
* 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>
*

+ 1
- 1
core/js/dist/main.js.map
File diff suppressed because it is too large
View File


+ 19
- 18
core/src/globals.js View File

@@ -73,12 +73,13 @@ const warnIfNotTesting = function() {
*
* @param {Function} func the library to deprecate
* @param {String} funcName the name of the library
* @param {Int} version the version this gets removed
* @returns {function}
*/
const deprecate = (func, funcName) => {
const deprecate = (func, funcName, version) => {
const oldFunc = func
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)
}
Object.assign(newFunc, oldFunc)
@@ -104,19 +105,19 @@ const setDeprecatedProp = (global, cb, msg) => {

window['_'] = _
window['$'] = $
window['autosize'] = autosize
window['Backbone'] = Backbone
window['Clipboard'] = ClipboardJS
window['ClipboardJS'] = ClipboardJS
setDeprecatedProp('autosize', () => autosize, 'please ship your own, this will be removed in Nextcloud 20')
setDeprecatedProp('Backbone', () => Backbone, 'please ship your own, this will be removed in Nextcloud 20')
setDeprecatedProp('Clipboard', () => ClipboardJS, 'please ship your own, this will be removed in Nextcloud 20')
setDeprecatedProp('ClipboardJS', () => ClipboardJS, 'please ship your own, this will be removed in Nextcloud 20')
window['dav'] = dav
setDeprecatedProp('DOMPurify', () => DOMPurify, 'The global DOMPurify is deprecated, ship your own')
window['Handlebars'] = Handlebars
window['jstimezonedetect'] = jstimezonedetect
window['jstz'] = jstimezonedetect
setDeprecatedProp('Handlebars', () => Handlebars, 'please ship your own, this will be removed in Nextcloud 20')
setDeprecatedProp('jstimezonedetect', () => jstimezonedetect, 'please ship your own, this will be removed in Nextcloud 20')
setDeprecatedProp('jstz', () => jstimezonedetect, 'please ship your own, this will be removed in Nextcloud 20')
window['jQuery'] = $
window['marked'] = deprecate(marked, 'marked')
window['md5'] = md5
window['moment'] = moment
window['marked'] = deprecate(marked, 'marked', 19)
setDeprecatedProp('md5', () => md5, 'please ship your own, this will be removed in Nextcloud 20')
setDeprecatedProp('moment', () => moment, 'please ship your own, this will be removed in Nextcloud 20')

window['OC'] = OC
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')
window['OCP'] = OCP
window['OCA'] = OCA
window['escapeHTML'] = deprecate(escapeHTML, 'escapeHTML')
window['formatDate'] = deprecate(formatDate, 'formatDate')
window['getURLParameter'] = deprecate(getURLParameter, 'getURLParameter')
window['humanFileSize'] = deprecate(humanFileSize, 'humanFileSize')
window['relative_modified_date'] = deprecate(relativeModifiedDate, 'relative_modified_date')
$.fn.select2 = deprecate($.fn.select2, 'select2')
window['escapeHTML'] = deprecate(escapeHTML, 'escapeHTML', 19)
window['formatDate'] = deprecate(formatDate, 'formatDate', 19)
window['getURLParameter'] = deprecate(getURLParameter, 'getURLParameter', 19)
window['humanFileSize'] = deprecate(humanFileSize, 'humanFileSize', 19)
window['relative_modified_date'] = deprecate(relativeModifiedDate, 'relative_modified_date', 19)
$.fn.select2 = deprecate($.fn.select2, 'select2', 19)

/**
* translate a string

Loading…
Cancel
Save