@uppy/core
Advanced tools
Comparing version 2.2.0 to 2.3.0
# @uppy/core | ||
## 2.3.0 | ||
Released: 2022-05-30 | ||
Included in: Uppy v2.11.0 | ||
- @uppy/angular,@uppy/audio,@uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/box,@uppy/core,@uppy/dashboard,@uppy/drag-drop,@uppy/dropbox,@uppy/facebook,@uppy/file-input,@uppy/form,@uppy/golden-retriever,@uppy/google-drive,@uppy/image-editor,@uppy/informer,@uppy/instagram,@uppy/onedrive,@uppy/progress-bar,@uppy/react,@uppy/redux-dev-tools,@uppy/robodog,@uppy/screen-capture,@uppy/status-bar,@uppy/store-default,@uppy/store-redux,@uppy/thumbnail-generator,@uppy/transloadit,@uppy/tus,@uppy/unsplash,@uppy/url,@uppy/vue,@uppy/webcam,@uppy/xhr-upload,@uppy/zoom: doc: update bundler recommendation (Antoine du Hamel / #3763) | ||
- @uppy/core: refactor to ESM (Antoine du Hamel / #3744) | ||
## 2.2.0 | ||
@@ -4,0 +12,0 @@ |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -9,5 +11,5 @@ * Core plugin logic that all plugins share. | ||
*/ | ||
const Translator = require('@uppy/utils/lib/Translator'); | ||
const Translator = require("@uppy/utils/lib/Translator"); | ||
module.exports = class BasePlugin { | ||
class BasePlugin { | ||
constructor(uppy, opts) { | ||
@@ -96,2 +98,4 @@ if (opts === void 0) { | ||
}; | ||
} | ||
module.exports = BasePlugin; |
@@ -1,2 +0,4 @@ | ||
module.exports = function getFileName(fileType, fileDescriptor) { | ||
"use strict"; | ||
function getFileName(fileType, fileDescriptor) { | ||
if (fileDescriptor.name) { | ||
@@ -11,2 +13,4 @@ return fileDescriptor.name; | ||
return 'noname'; | ||
}; | ||
} | ||
module.exports = getFileName; |
@@ -1,17 +0,42 @@ | ||
'use strict'; | ||
"use strict"; | ||
const Uppy = require('./Uppy'); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Uppy = exports.UIPlugin = exports.BasePlugin = void 0; | ||
Object.defineProperty(exports, "debugLogger", { | ||
enumerable: true, | ||
get: function () { | ||
return _loggers.debugLogger; | ||
} | ||
}); | ||
const UIPlugin = require('./UIPlugin'); | ||
var _loggers = require("./loggers.js"); | ||
const BasePlugin = require('./BasePlugin'); | ||
module.exports = require('./Uppy.js'); | ||
const { | ||
debugLogger | ||
} = require('./loggers'); | ||
const _0 = require("./UIPlugin.js"); | ||
module.exports = Uppy; | ||
module.exports.Uppy = Uppy; | ||
module.exports.UIPlugin = UIPlugin; | ||
module.exports.BasePlugin = BasePlugin; | ||
module.exports.debugLogger = debugLogger; | ||
exports.UIPlugin = _0; | ||
const _1 = require("./BasePlugin.js"); | ||
exports.BasePlugin = _1; | ||
// TODO: remove all the following in the next major | ||
/* eslint-disable import/first */ | ||
const Uppy = require("./Uppy.js"); | ||
exports.Uppy = Uppy; | ||
const UIPlugin = require("./UIPlugin.js"); | ||
const BasePlugin = require("./BasePlugin.js"); | ||
// Backward compatibility: we want those to keep being accessible as static | ||
// properties of `Uppy` to avoid a breaking change. | ||
Uppy.Uppy = Uppy; | ||
Uppy.UIPlugin = UIPlugin; | ||
Uppy.BasePlugin = BasePlugin; | ||
Uppy.debugLogger = _loggers.debugLogger; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
module.exports = { | ||
@@ -2,0 +4,0 @@ strings: { |
@@ -0,3 +1,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.justErrorsLogger = exports.debugLogger = void 0; | ||
/* eslint-disable no-console */ | ||
const getTimeStamp = require('@uppy/utils/lib/getTimeStamp'); // Swallow all logs, except errors. | ||
const getTimeStamp = require("@uppy/utils/lib/getTimeStamp"); // Swallow all logs, except errors. | ||
// default if logger is not set or debug: false | ||
@@ -19,2 +26,3 @@ | ||
exports.justErrorsLogger = justErrorsLogger; | ||
const debugLogger = { | ||
@@ -43,5 +51,2 @@ debug: function () { | ||
}; | ||
module.exports = { | ||
justErrorsLogger, | ||
debugLogger | ||
}; | ||
exports.debugLogger = debugLogger; |
@@ -1,4 +0,9 @@ | ||
const UIPlugin = require('../UIPlugin'); | ||
"use strict"; | ||
module.exports = class TestSelector1 extends UIPlugin { | ||
var _globals = require("@jest/globals"); | ||
// eslint-disable-line import/no-extraneous-dependencies | ||
const UIPlugin = require("../UIPlugin.js"); | ||
class TestSelector1 extends UIPlugin { | ||
constructor(uppy, opts) { | ||
@@ -10,5 +15,5 @@ super(uppy, opts); | ||
this.mocks = { | ||
run: jest.fn(), | ||
update: jest.fn(), | ||
uninstall: jest.fn() | ||
run: _globals.jest.fn(), | ||
update: _globals.jest.fn(), | ||
uninstall: _globals.jest.fn() | ||
}; | ||
@@ -35,2 +40,4 @@ } | ||
}; | ||
} | ||
module.exports = TestSelector1; |
@@ -1,4 +0,9 @@ | ||
const UIPlugin = require('../UIPlugin'); | ||
"use strict"; | ||
module.exports = class TestSelector2 extends UIPlugin { | ||
var _globals = require("@jest/globals"); | ||
// eslint-disable-line import/no-extraneous-dependencies | ||
const UIPlugin = require("../UIPlugin.js"); | ||
class TestSelector2 extends UIPlugin { | ||
constructor(uppy, opts) { | ||
@@ -10,5 +15,5 @@ super(uppy, opts); | ||
this.mocks = { | ||
run: jest.fn(), | ||
update: jest.fn(), | ||
uninstall: jest.fn() | ||
run: _globals.jest.fn(), | ||
update: _globals.jest.fn(), | ||
uninstall: _globals.jest.fn() | ||
}; | ||
@@ -35,2 +40,4 @@ } | ||
}; | ||
} | ||
module.exports = TestSelector2; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
module.exports = {}; |
@@ -1,4 +0,6 @@ | ||
const UIPlugin = require('../UIPlugin'); | ||
"use strict"; | ||
module.exports = class InvalidPluginWithoutName extends UIPlugin { | ||
const UIPlugin = require("../UIPlugin.js"); | ||
class InvalidPluginWithoutName extends UIPlugin { | ||
constructor(uppy, opts) { | ||
@@ -19,2 +21,4 @@ super(uppy, opts); | ||
}; | ||
} | ||
module.exports = InvalidPluginWithoutName; |
@@ -1,4 +0,6 @@ | ||
const UIPlugin = require('../UIPlugin'); | ||
"use strict"; | ||
module.exports = class InvalidPluginWithoutType extends UIPlugin { | ||
const UIPlugin = require("../UIPlugin.js"); | ||
class InvalidPluginWithoutType extends UIPlugin { | ||
constructor(uppy, opts) { | ||
@@ -19,2 +21,4 @@ super(uppy, opts); | ||
}; | ||
} | ||
module.exports = InvalidPluginWithoutType; |
@@ -0,7 +1,14 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.defaultOptions = exports.RestrictionError = exports.Restricter = void 0; | ||
/* eslint-disable max-classes-per-file, class-methods-use-this */ | ||
/* global AggregateError */ | ||
const prettierBytes = require('@transloadit/prettier-bytes'); | ||
const prettierBytes = require("@transloadit/prettier-bytes"); | ||
const match = require('mime-match'); | ||
const match = require("mime-match"); | ||
@@ -17,2 +24,3 @@ const defaultOptions = { | ||
}; | ||
exports.defaultOptions = defaultOptions; | ||
@@ -27,2 +35,4 @@ class RestrictionError extends Error { | ||
exports.RestrictionError = RestrictionError; | ||
if (typeof AggregateError === 'undefined') { | ||
@@ -159,6 +169,2 @@ // eslint-disable-next-line no-global-assign | ||
module.exports = { | ||
Restricter, | ||
defaultOptions, | ||
RestrictionError | ||
}; | ||
exports.Restricter = Restricter; |
@@ -1,8 +0,8 @@ | ||
// Edge 15.x does not fire 'progress' events on uploads. | ||
// See https://github.com/transloadit/uppy/issues/945 | ||
// And https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12224510/ | ||
module.exports = function supportsUploadProgress(userAgent) { | ||
"use strict"; | ||
function supportsUploadProgress(userAgent) { | ||
// Allow passing in userAgent for tests | ||
if (userAgent == null) { | ||
userAgent = typeof navigator !== 'undefined' ? navigator.userAgent : null; | ||
if (userAgent == null && typeof navigator !== 'undefined') { | ||
// eslint-disable-next-line no-param-reassign | ||
userAgent = navigator.userAgent; | ||
} // Assume it works because basically everything supports progress events. | ||
@@ -33,2 +33,7 @@ | ||
return false; | ||
}; | ||
} | ||
// Edge 15.x does not fire 'progress' events on uploads. | ||
// See https://github.com/transloadit/uppy/issues/945 | ||
// And https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12224510/ | ||
module.exports = supportsUploadProgress; |
@@ -0,1 +1,5 @@ | ||
"use strict"; | ||
var _preact = require("preact"); | ||
function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; } | ||
@@ -7,11 +11,7 @@ | ||
const { | ||
render | ||
} = require('preact'); | ||
const findDOMElement = require("@uppy/utils/lib/findDOMElement"); | ||
const findDOMElement = require('@uppy/utils/lib/findDOMElement'); | ||
const getTextDirection = require("@uppy/utils/lib/getTextDirection"); | ||
const getTextDirection = require('@uppy/utils/lib/getTextDirection'); | ||
const BasePlugin = require('./BasePlugin'); | ||
const BasePlugin = require("./BasePlugin.js"); | ||
/** | ||
@@ -90,3 +90,3 @@ * Defer a frequent call to the microtask queue. | ||
if (!this.uppy.getPlugin(this.id)) return; | ||
render(this.render(state), uppyRootElement); | ||
(0, _preact.render)(this.render(state), uppyRootElement); | ||
this.afterUpdate(); | ||
@@ -103,3 +103,3 @@ }); | ||
render(this.render(this.uppy.getState()), uppyRootElement); | ||
(0, _preact.render)(this.render(this.uppy.getState()), uppyRootElement); | ||
this.el = uppyRootElement; | ||
@@ -125,3 +125,2 @@ targetElement.appendChild(uppyRootElement); // Set the text direction if the page has not defined one. | ||
targetPlugin = p; | ||
return false; | ||
} | ||
@@ -128,0 +127,0 @@ }); |
@@ -1,6 +0,9 @@ | ||
/* eslint-disable max-classes-per-file */ | ||
"use strict"; | ||
/* global AggregateError */ | ||
'use strict'; | ||
var _nonSecure = require("nanoid/non-secure"); | ||
var _loggers = require("./loggers.js"); | ||
var _Restricter = require("./Restricter.js"); | ||
let _Symbol$for, _Symbol$for2; | ||
@@ -14,37 +17,28 @@ | ||
const Translator = require('@uppy/utils/lib/Translator'); | ||
/* eslint-disable max-classes-per-file */ | ||
const ee = require('namespace-emitter'); | ||
/* global AggregateError */ | ||
const Translator = require("@uppy/utils/lib/Translator"); | ||
const { | ||
nanoid | ||
} = require('nanoid/non-secure'); | ||
const ee = require("namespace-emitter"); | ||
const throttle = require('lodash.throttle'); | ||
const throttle = require("lodash.throttle"); | ||
const DefaultStore = require('@uppy/store-default'); | ||
const DefaultStore = require("@uppy/store-default"); | ||
const getFileType = require('@uppy/utils/lib/getFileType'); | ||
const getFileType = require("@uppy/utils/lib/getFileType"); | ||
const getFileNameAndExtension = require('@uppy/utils/lib/getFileNameAndExtension'); | ||
const getFileNameAndExtension = require("@uppy/utils/lib/getFileNameAndExtension"); | ||
const generateFileID = require('@uppy/utils/lib/generateFileID'); | ||
const generateFileID = require("@uppy/utils/lib/generateFileID"); | ||
const supportsUploadProgress = require('./supportsUploadProgress'); | ||
const supportsUploadProgress = require("./supportsUploadProgress.js"); | ||
const getFileName = require('./getFileName'); | ||
const getFileName = require("./getFileName.js"); | ||
const { | ||
justErrorsLogger, | ||
debugLogger | ||
} = require('./loggers'); | ||
const packageJson = { | ||
"version": "2.3.0" | ||
}; | ||
const { | ||
Restricter, | ||
defaultOptions: defaultRestrictionOptions, | ||
RestrictionError | ||
} = require('./Restricter'); | ||
const locale = require('./locale'); // Exported from here. | ||
const locale = require("./locale.js"); | ||
/** | ||
@@ -99,4 +93,2 @@ * Uppy Core module. | ||
class Uppy { | ||
// eslint-disable-next-line global-require | ||
/** @type {Record<string, BasePlugin[]>} */ | ||
@@ -186,3 +178,3 @@ | ||
debug: false, | ||
restrictions: defaultRestrictionOptions, | ||
restrictions: _Restricter.defaultOptions, | ||
meta: {}, | ||
@@ -192,3 +184,3 @@ onBeforeFileAdded: currentFile => currentFile, | ||
store: DefaultStore(), | ||
logger: justErrorsLogger, | ||
logger: _loggers.justErrorsLogger, | ||
infoTimeout: 5000 | ||
@@ -209,3 +201,3 @@ }; // Merge default options with the ones set by user, | ||
} else if (_opts && _opts.debug) { | ||
this.opts.logger = debugLogger; | ||
this.opts.logger = _loggers.debugLogger; | ||
} | ||
@@ -243,3 +235,3 @@ | ||
}); | ||
_classPrivateFieldLooseBase(this, _restricter)[_restricter] = new Restricter(() => this.opts, this.i18n); | ||
_classPrivateFieldLooseBase(this, _restricter)[_restricter] = new _Restricter.Restricter(() => this.opts, this.i18n); | ||
_classPrivateFieldLooseBase(this, _storeUnsubscribe)[_storeUnsubscribe] = this.store.subscribe((prevState, nextState, patch) => { | ||
@@ -1311,3 +1303,3 @@ this.emit('state-update', prevState, nextState, patch); | ||
if (!_classPrivateFieldLooseBase(this, _checkRequiredMetaFields)[_checkRequiredMetaFields](files)) { | ||
throw new RestrictionError(this.i18n('missingRequiredMetaField')); | ||
throw new _Restricter.RestrictionError(this.i18n('missingRequiredMetaField')); | ||
} | ||
@@ -1401,3 +1393,3 @@ }).catch(err => { | ||
if (allowNewUpload === false) { | ||
const error = new RestrictionError(this.i18n('noMoreFilesAllowed')); | ||
const error = new _Restricter.RestrictionError(this.i18n('noMoreFilesAllowed')); | ||
@@ -1420,3 +1412,3 @@ _classPrivateFieldLooseBase(this, _informAndEmit)[_informAndEmit](error, file); | ||
if (this.checkIfFileAlreadyExists(fileID)) { | ||
const error = new RestrictionError(this.i18n('noDuplicates', { | ||
const error = new _Restricter.RestrictionError(this.i18n('noDuplicates', { | ||
fileName | ||
@@ -1461,3 +1453,3 @@ })); | ||
// Don’t show UI info for this error, as it should be done by the developer | ||
const error = new RestrictionError('Cannot add the file because onBeforeFileAdded returned false.'); | ||
const error = new _Restricter.RestrictionError('Cannot add the file because onBeforeFileAdded returned false.'); | ||
this.emit('restriction-failed', fileDescriptor, error); | ||
@@ -1686,3 +1678,3 @@ throw error; | ||
const uploadID = nanoid(); | ||
const uploadID = (0, _nonSecure.nanoid)(); | ||
this.emit('upload', { | ||
@@ -1809,3 +1801,3 @@ id: uploadID, | ||
Uppy.VERSION = "2.2.0"; | ||
Uppy.VERSION = packageJson.version; | ||
module.exports = Uppy; |
{ | ||
"name": "@uppy/core", | ||
"description": "Core module for the extensible JavaScript file upload widget with support for drag&drop, resumable uploads, previews, restrictions, file processing/encoding, remote providers like Instagram, Dropbox, Google Drive, S3 and more :dog:", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"license": "MIT", | ||
@@ -9,2 +9,3 @@ "main": "lib/index.js", | ||
"types": "types/index.d.ts", | ||
"type": "module", | ||
"keywords": [ | ||
@@ -25,4 +26,4 @@ "file uploader", | ||
"@transloadit/prettier-bytes": "0.0.7", | ||
"@uppy/store-default": "^2.0.3", | ||
"@uppy/utils": "^4.0.7", | ||
"@uppy/store-default": "^2.1.0", | ||
"@uppy/utils": "^4.1.0", | ||
"lodash.throttle": "^4.1.1", | ||
@@ -33,3 +34,6 @@ "mime-match": "^1.0.2", | ||
"preact": "^10.5.13" | ||
}, | ||
"devDependencies": { | ||
"@jest/globals": "^27.4.2" | ||
} | ||
} |
@@ -35,4 +35,2 @@ # @uppy/core | ||
We recommend installing from npm and then using a module bundler such as [Webpack](https://webpack.js.org/), [Browserify](http://browserify.org/) or [Rollup.js](http://rollupjs.org/). | ||
Alternatively, you can also use this plugin in a pre-built bundle from Transloadit’s CDN: Edgly. In that case `Uppy` will attach itself to the global `window.Uppy` object. See the [main Uppy documentation](https://uppy.io/docs/#Installation) for instructions. | ||
@@ -39,0 +37,0 @@ |
@@ -10,5 +10,5 @@ /** | ||
const Translator = require('@uppy/utils/lib/Translator') | ||
import Translator from '@uppy/utils/lib/Translator' | ||
module.exports = class BasePlugin { | ||
export default class BasePlugin { | ||
constructor (uppy, opts = {}) { | ||
@@ -15,0 +15,0 @@ this.uppy = uppy |
@@ -1,2 +0,2 @@ | ||
module.exports = function getFileName (fileType, fileDescriptor) { | ||
export default function getFileName (fileType, fileDescriptor) { | ||
if (fileDescriptor.name) { | ||
@@ -3,0 +3,0 @@ return fileDescriptor.name |
@@ -1,12 +0,20 @@ | ||
'use strict' | ||
export { default } from './Uppy.js' | ||
export { default as UIPlugin } from './UIPlugin.js' | ||
export { default as BasePlugin } from './BasePlugin.js' | ||
export { debugLogger } from './loggers.js' | ||
const Uppy = require('./Uppy') | ||
const UIPlugin = require('./UIPlugin') | ||
const BasePlugin = require('./BasePlugin') | ||
const { debugLogger } = require('./loggers') | ||
// TODO: remove all the following in the next major | ||
/* eslint-disable import/first */ | ||
import Uppy from './Uppy.js' | ||
import UIPlugin from './UIPlugin.js' | ||
import BasePlugin from './BasePlugin.js' | ||
import { debugLogger } from './loggers.js' | ||
module.exports = Uppy | ||
module.exports.Uppy = Uppy | ||
module.exports.UIPlugin = UIPlugin | ||
module.exports.BasePlugin = BasePlugin | ||
module.exports.debugLogger = debugLogger | ||
// Backward compatibility: we want those to keep being accessible as static | ||
// properties of `Uppy` to avoid a breaking change. | ||
Uppy.Uppy = Uppy | ||
Uppy.UIPlugin = UIPlugin | ||
Uppy.BasePlugin = BasePlugin | ||
Uppy.debugLogger = debugLogger | ||
export { Uppy } |
@@ -1,2 +0,2 @@ | ||
module.exports = { | ||
export default { | ||
strings: { | ||
@@ -3,0 +3,0 @@ addBulkFilesFailed: { |
/* eslint-disable no-console */ | ||
const getTimeStamp = require('@uppy/utils/lib/getTimeStamp') | ||
import getTimeStamp from '@uppy/utils/lib/getTimeStamp' | ||
@@ -20,5 +20,5 @@ // Swallow all logs, except errors. | ||
module.exports = { | ||
export { | ||
justErrorsLogger, | ||
debugLogger, | ||
} |
@@ -1,4 +0,5 @@ | ||
const UIPlugin = require('../UIPlugin') | ||
import { jest } from '@jest/globals' // eslint-disable-line import/no-extraneous-dependencies | ||
import UIPlugin from '../UIPlugin.js' | ||
module.exports = class TestSelector1 extends UIPlugin { | ||
export default class TestSelector1 extends UIPlugin { | ||
constructor (uppy, opts) { | ||
@@ -5,0 +6,0 @@ super(uppy, opts) |
@@ -1,4 +0,5 @@ | ||
const UIPlugin = require('../UIPlugin') | ||
import { jest } from '@jest/globals' // eslint-disable-line import/no-extraneous-dependencies | ||
import UIPlugin from '../UIPlugin.js' | ||
module.exports = class TestSelector2 extends UIPlugin { | ||
export default class TestSelector2 extends UIPlugin { | ||
constructor (uppy, opts) { | ||
@@ -5,0 +6,0 @@ super(uppy, opts) |
@@ -1,1 +0,1 @@ | ||
module.exports = {} | ||
export default {} |
@@ -1,4 +0,4 @@ | ||
const UIPlugin = require('../UIPlugin') | ||
import UIPlugin from '../UIPlugin.js' | ||
module.exports = class InvalidPluginWithoutName extends UIPlugin { | ||
export default class InvalidPluginWithoutName extends UIPlugin { | ||
constructor (uppy, opts) { | ||
@@ -5,0 +5,0 @@ super(uppy, opts) |
@@ -1,4 +0,4 @@ | ||
const UIPlugin = require('../UIPlugin') | ||
import UIPlugin from '../UIPlugin.js' | ||
module.exports = class InvalidPluginWithoutType extends UIPlugin { | ||
export default class InvalidPluginWithoutType extends UIPlugin { | ||
constructor (uppy, opts) { | ||
@@ -5,0 +5,0 @@ super(uppy, opts) |
/* eslint-disable max-classes-per-file, class-methods-use-this */ | ||
/* global AggregateError */ | ||
const prettierBytes = require('@transloadit/prettier-bytes') | ||
const match = require('mime-match') | ||
import prettierBytes from '@transloadit/prettier-bytes' | ||
import match from 'mime-match' | ||
@@ -125,2 +125,2 @@ const defaultOptions = { | ||
module.exports = { Restricter, defaultOptions, RestrictionError } | ||
export { Restricter, defaultOptions, RestrictionError } |
// Edge 15.x does not fire 'progress' events on uploads. | ||
// See https://github.com/transloadit/uppy/issues/945 | ||
// And https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12224510/ | ||
module.exports = function supportsUploadProgress (userAgent) { | ||
export default function supportsUploadProgress (userAgent) { | ||
// Allow passing in userAgent for tests | ||
if (userAgent == null) { | ||
userAgent = typeof navigator !== 'undefined' ? navigator.userAgent : null | ||
if (userAgent == null && typeof navigator !== 'undefined') { | ||
// eslint-disable-next-line no-param-reassign | ||
userAgent = navigator.userAgent | ||
} | ||
@@ -9,0 +10,0 @@ // Assume it works because basically everything supports progress events. |
@@ -1,2 +0,3 @@ | ||
const supportsUploadProgress = require('./supportsUploadProgress') | ||
import { describe, expect, it } from '@jest/globals' | ||
import supportsUploadProgress from './supportsUploadProgress.js' | ||
@@ -3,0 +4,0 @@ describe('supportsUploadProgress', () => { |
@@ -1,6 +0,6 @@ | ||
const { render } = require('preact') | ||
const findDOMElement = require('@uppy/utils/lib/findDOMElement') | ||
const getTextDirection = require('@uppy/utils/lib/getTextDirection') | ||
import { render } from 'preact' | ||
import findDOMElement from '@uppy/utils/lib/findDOMElement' | ||
import getTextDirection from '@uppy/utils/lib/getTextDirection' | ||
const BasePlugin = require('./BasePlugin') | ||
import BasePlugin from './BasePlugin.js' | ||
@@ -101,3 +101,2 @@ /** | ||
targetPlugin = p | ||
return false | ||
} | ||
@@ -153,2 +152,2 @@ }) | ||
module.exports = UIPlugin | ||
export default UIPlugin |
@@ -1,3 +0,4 @@ | ||
const UIPlugin = require('./UIPlugin') | ||
const Core = require('./index') | ||
import { describe, expect, it } from '@jest/globals' | ||
import UIPlugin from './UIPlugin.js' | ||
import Core from './index.js' | ||
@@ -4,0 +5,0 @@ describe('UIPlugin', () => { |
/* eslint-disable max-classes-per-file */ | ||
/* global AggregateError */ | ||
'use strict' | ||
const Translator = require('@uppy/utils/lib/Translator') | ||
const ee = require('namespace-emitter') | ||
const { nanoid } = require('nanoid/non-secure') | ||
const throttle = require('lodash.throttle') | ||
const DefaultStore = require('@uppy/store-default') | ||
const getFileType = require('@uppy/utils/lib/getFileType') | ||
const getFileNameAndExtension = require('@uppy/utils/lib/getFileNameAndExtension') | ||
const generateFileID = require('@uppy/utils/lib/generateFileID') | ||
const supportsUploadProgress = require('./supportsUploadProgress') | ||
const getFileName = require('./getFileName') | ||
const { justErrorsLogger, debugLogger } = require('./loggers') | ||
const { | ||
import Translator from '@uppy/utils/lib/Translator' | ||
import ee from 'namespace-emitter' | ||
import { nanoid } from 'nanoid/non-secure' | ||
import throttle from 'lodash.throttle' | ||
import DefaultStore from '@uppy/store-default' | ||
import getFileType from '@uppy/utils/lib/getFileType' | ||
import getFileNameAndExtension from '@uppy/utils/lib/getFileNameAndExtension' | ||
import generateFileID from '@uppy/utils/lib/generateFileID' | ||
import supportsUploadProgress from './supportsUploadProgress.js' | ||
import getFileName from './getFileName.js' | ||
import { justErrorsLogger, debugLogger } from './loggers.js' | ||
import { | ||
Restricter, | ||
defaultOptions: defaultRestrictionOptions, | ||
defaultOptions as defaultRestrictionOptions, | ||
RestrictionError, | ||
} = require('./Restricter') | ||
} from './Restricter.js' | ||
const locale = require('./locale') | ||
import packageJson from '../package.json' | ||
import locale from './locale.js' | ||
// Exported from here. | ||
/** | ||
@@ -33,4 +30,3 @@ * Uppy Core module. | ||
class Uppy { | ||
// eslint-disable-next-line global-require | ||
static VERSION = require('../package.json').version | ||
static VERSION = packageJson.version | ||
@@ -1563,2 +1559,2 @@ /** @type {Record<string, BasePlugin[]>} */ | ||
module.exports = Uppy | ||
export default Uppy |
/* eslint no-console: "off", no-restricted-syntax: "off" */ | ||
const fs = require('fs') | ||
const path = require('path') | ||
const prettierBytes = require('@transloadit/prettier-bytes') | ||
const Core = require('./index') | ||
const UIPlugin = require('./UIPlugin') | ||
const AcquirerPlugin1 = require('./mocks/acquirerPlugin1') | ||
const AcquirerPlugin2 = require('./mocks/acquirerPlugin2') | ||
const InvalidPlugin = require('./mocks/invalidPlugin') | ||
const InvalidPluginWithoutId = require('./mocks/invalidPluginWithoutId') | ||
const InvalidPluginWithoutType = require('./mocks/invalidPluginWithoutType') | ||
const DeepFrozenStore = require('../../../../e2e/cypress/fixtures/DeepFrozenStore.js') | ||
import { afterEach, beforeEach, describe, expect, it, jest, xit } from '@jest/globals' | ||
jest.mock('nanoid/non-secure', () => { | ||
return { nanoid: () => 'cjd09qwxb000dlql4tp4doz8h' } | ||
}) | ||
jest.mock('@uppy/utils/lib/findDOMElement', () => { | ||
return () => null | ||
}) | ||
import fs from 'node:fs' | ||
import prettierBytes from '@transloadit/prettier-bytes' | ||
import Core from '../lib/index.js' | ||
import UIPlugin from '../lib/UIPlugin.js' | ||
import AcquirerPlugin1 from './mocks/acquirerPlugin1.js' | ||
import AcquirerPlugin2 from './mocks/acquirerPlugin2.js' | ||
import InvalidPlugin from './mocks/invalidPlugin.js' | ||
import InvalidPluginWithoutId from './mocks/invalidPluginWithoutId.js' | ||
import InvalidPluginWithoutType from './mocks/invalidPluginWithoutType.js' | ||
import DeepFrozenStore from '../../../../e2e/cypress/fixtures/DeepFrozenStore.mjs' | ||
const sampleImage = fs.readFileSync(path.join(__dirname, '../../../../e2e/cypress/fixtures/images/image.jpg')) | ||
const sampleImage = fs.readFileSync(new URL('../../../../e2e/cypress/fixtures/images/image.jpg', import.meta.url)) | ||
describe('src/Core', () => { | ||
const RealCreateObjectUrl = global.URL.createObjectURL | ||
const RealCreateObjectUrl = globalThis.URL.createObjectURL | ||
beforeEach(() => { | ||
global.URL.createObjectURL = jest.fn().mockReturnValue('newUrl') | ||
globalThis.URL.createObjectURL = jest.fn().mockReturnValue('newUrl') | ||
}) | ||
afterEach(() => { | ||
global.URL.createObjectURL = RealCreateObjectUrl | ||
globalThis.URL.createObjectURL = RealCreateObjectUrl | ||
}) | ||
@@ -1101,3 +1095,3 @@ | ||
type: 'application/octet-stream', | ||
data: new File([Buffer.alloc(1000)], { type: 'application/octet-stream' }), | ||
data: new File([new Uint8Array(1000)], { type: 'application/octet-stream' }), | ||
}) | ||
@@ -1720,3 +1714,3 @@ | ||
name: 'test.jpg', | ||
data: new Blob([Buffer.alloc(2 * maxFileSize)]), | ||
data: new Blob([new Uint8Array(2 * maxFileSize)]), | ||
} | ||
@@ -1771,7 +1765,7 @@ const errorMessage = core.i18n('exceedsSize', { file: file.name, size: prettierBytes(maxFileSize) }) | ||
describe('updateOnlineStatus', () => { | ||
const RealNavigatorOnline = global.window.navigator.onLine | ||
const RealNavigatorOnline = globalThis.window.navigator.onLine | ||
function mockNavigatorOnline (status) { | ||
Object.defineProperty( | ||
global.window.navigator, | ||
globalThis.window.navigator, | ||
'onLine', | ||
@@ -1786,3 +1780,3 @@ { | ||
afterEach(() => { | ||
global.window.navigator.onLine = RealNavigatorOnline | ||
globalThis.window.navigator.onLine = RealNavigatorOnline | ||
}) | ||
@@ -1789,0 +1783,0 @@ |
@@ -1,2 +0,1 @@ | ||
/* eslint-disable max-classes-per-file */ | ||
import * as UppyUtils from '@uppy/utils' | ||
@@ -3,0 +2,0 @@ |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { expectError, expectType } from 'tsd' | ||
@@ -2,0 +3,0 @@ import DefaultStore from '@uppy/store-default' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
371031
60
6439
0
Yes
1
44
Updated@uppy/store-default@^2.1.0
Updated@uppy/utils@^4.1.0