@uppy/core
Advanced tools
Comparing version 3.10.1 to 3.11.0
# @uppy/core | ||
## 3.11.0 | ||
Released: 2024-04-29 | ||
Included in: Uppy v3.25.0 | ||
- @uppy/core: add instance ID to generated IDs (Merlijn Vos / #5080) | ||
- @uppy/core: reference updated i18n in Restricter (Merlijn Vos / #5118) | ||
## 3.10.1 | ||
@@ -4,0 +12,0 @@ |
@@ -32,4 +32,4 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
class Restricter { | ||
constructor(getOpts, i18n) { | ||
this.i18n = i18n; | ||
constructor(getOpts, getI18n) { | ||
this.getI18n = getI18n; | ||
this.getOpts = () => { | ||
@@ -54,3 +54,3 @@ var _opts$restrictions; | ||
if (nonGhostFiles.length + addingFiles.length > maxNumberOfFiles) { | ||
throw new RestrictionError(`${this.i18n('youCanOnlyUploadX', { | ||
throw new RestrictionError(`${this.getI18n()('youCanOnlyUploadX', { | ||
smart_count: maxNumberOfFiles | ||
@@ -70,3 +70,3 @@ })}`); | ||
if (totalFilesSize > maxTotalFileSize) { | ||
throw new RestrictionError(this.i18n('exceedsSize', { | ||
throw new RestrictionError(this.getI18n()('exceedsSize', { | ||
size: prettierBytes(maxTotalFileSize), | ||
@@ -102,3 +102,3 @@ file: addingFile.name | ||
const allowedFileTypesString = allowedFileTypes.join(', '); | ||
throw new RestrictionError(this.i18n('youCanOnlyUploadFileTypes', { | ||
throw new RestrictionError(this.getI18n()('youCanOnlyUploadFileTypes', { | ||
types: allowedFileTypesString | ||
@@ -113,3 +113,3 @@ }), { | ||
if (maxFileSize && file.size != null && file.size > maxFileSize) { | ||
throw new RestrictionError(this.i18n('exceedsSize', { | ||
throw new RestrictionError(this.getI18n()('exceedsSize', { | ||
size: prettierBytes(maxFileSize), | ||
@@ -124,3 +124,3 @@ file: file.name | ||
if (minFileSize && file.size != null && file.size < minFileSize) { | ||
throw new RestrictionError(this.i18n('inferiorSize', { | ||
throw new RestrictionError(this.getI18n()('inferiorSize', { | ||
size: prettierBytes(minFileSize) | ||
@@ -143,3 +143,3 @@ }), { | ||
if (minNumberOfFiles && Object.keys(files).length < minNumberOfFiles) { | ||
throw new RestrictionError(this.i18n('youHaveToAtLeastSelectX', { | ||
throw new RestrictionError(this.getI18n()('youHaveToAtLeastSelectX', { | ||
smart_count: minNumberOfFiles | ||
@@ -150,3 +150,3 @@ })); | ||
getMissingRequiredMetaFields(file) { | ||
const error = new RestrictionError(this.i18n('missingRequiredMetaFieldOnFile', { | ||
const error = new RestrictionError(this.getI18n()('missingRequiredMetaFieldOnFile', { | ||
fileName: file.name | ||
@@ -153,0 +153,0 @@ })); |
@@ -27,3 +27,3 @@ let _Symbol$for, _Symbol$for2; | ||
const packageJson = { | ||
"version": "3.10.1" | ||
"version": "3.11.0" | ||
}; | ||
@@ -290,3 +290,3 @@ import locale from "./locale.js"; | ||
}); | ||
_classPrivateFieldLooseBase(this, _restricter)[_restricter] = new Restricter(() => this.opts, this.i18n); | ||
_classPrivateFieldLooseBase(this, _restricter)[_restricter] = new Restricter(() => this.opts, () => this.i18n); | ||
_classPrivateFieldLooseBase(this, _storeUnsubscribe)[_storeUnsubscribe] = this.store.subscribe( | ||
@@ -1300,3 +1300,3 @@ // eslint-disable-next-line | ||
const fileExtension = getFileNameAndExtension(fileName).extension; | ||
const id = getSafeFileId(file); | ||
const id = getSafeFileId(file, this.getID()); | ||
const meta = file.meta || {}; | ||
@@ -1303,0 +1303,0 @@ meta.name = fileName; |
{ | ||
"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": "3.10.1", | ||
"version": "3.11.0", | ||
"license": "MIT", | ||
@@ -29,3 +29,3 @@ "main": "lib/index.js", | ||
"@uppy/store-default": "^3.2.2", | ||
"@uppy/utils": "^5.7.5", | ||
"@uppy/utils": "^5.9.0", | ||
"lodash": "^4.17.21", | ||
@@ -32,0 +32,0 @@ "mime-match": "^1.0.2", |
@@ -19,3 +19,3 @@ /* eslint-disable class-methods-use-this */ | ||
import type { Body, Meta } from '@uppy/utils/lib/UppyFile' | ||
import type { State, UnknownPlugin, Uppy } from './Uppy' | ||
import type { State, UnknownPlugin, Uppy } from './Uppy.js' | ||
@@ -22,0 +22,0 @@ export type PluginOpts = { |
@@ -7,3 +7,3 @@ import type { Meta, Body, UppyFile } from '@uppy/utils/lib/UppyFile' | ||
_UppyEventMap, | ||
} from './Uppy' | ||
} from './Uppy.js' | ||
@@ -10,0 +10,0 @@ /** |
import { vi } from 'vitest' // eslint-disable-line import/no-extraneous-dependencies | ||
import UIPlugin from '../UIPlugin.ts' | ||
import type Uppy from '../Uppy.ts' | ||
import type Uppy from '../Uppy.js' | ||
@@ -5,0 +5,0 @@ type mock = ReturnType<typeof vi.fn> |
import { vi } from 'vitest' // eslint-disable-line import/no-extraneous-dependencies | ||
import UIPlugin from '../UIPlugin.ts' | ||
import type Uppy from '../Uppy.ts' | ||
import type Uppy from '../Uppy.js' | ||
@@ -5,0 +5,0 @@ type mock = ReturnType<typeof vi.fn> |
import UIPlugin from '../UIPlugin.ts' | ||
import type Uppy from '../Uppy.ts' | ||
import type Uppy from '../Uppy.js' | ||
@@ -4,0 +4,0 @@ export default class InvalidPluginWithoutName extends UIPlugin<any, any, any> { |
import UIPlugin from '../UIPlugin.ts' | ||
import type Uppy from '../Uppy.ts' | ||
import type Uppy from '../Uppy.js' | ||
@@ -4,0 +4,0 @@ export default class InvalidPluginWithoutType extends UIPlugin<any, any, any> { |
@@ -6,6 +6,5 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
import match from 'mime-match' | ||
import Translator from '@uppy/utils/lib/Translator' | ||
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile' | ||
import type { I18n } from '@uppy/utils/lib/Translator' | ||
import type { State, NonNullableUppyOptions } from './Uppy' | ||
import type { State, NonNullableUppyOptions } from './Uppy.js' | ||
@@ -62,8 +61,11 @@ export type Restrictions = { | ||
class Restricter<M extends Meta, B extends Body> { | ||
i18n: Translator['translate'] | ||
getI18n: () => I18n | ||
getOpts: () => NonNullableUppyOptions<M, B> | ||
constructor(getOpts: () => NonNullableUppyOptions<M, B>, i18n: I18n) { | ||
this.i18n = i18n | ||
constructor( | ||
getOpts: () => NonNullableUppyOptions<M, B>, | ||
getI18n: () => I18n, | ||
) { | ||
this.getI18n = getI18n | ||
this.getOpts = (): NonNullableUppyOptions<M, B> => { | ||
@@ -93,3 +95,3 @@ const opts = getOpts() | ||
throw new RestrictionError( | ||
`${this.i18n('youCanOnlyUploadX', { | ||
`${this.getI18n()('youCanOnlyUploadX', { | ||
smart_count: maxNumberOfFiles, | ||
@@ -114,3 +116,3 @@ })}`, | ||
throw new RestrictionError( | ||
this.i18n('exceedsSize', { | ||
this.getI18n()('exceedsSize', { | ||
size: prettierBytes(maxTotalFileSize), | ||
@@ -148,3 +150,3 @@ file: addingFile.name, | ||
throw new RestrictionError( | ||
this.i18n('youCanOnlyUploadFileTypes', { | ||
this.getI18n()('youCanOnlyUploadFileTypes', { | ||
types: allowedFileTypesString, | ||
@@ -160,3 +162,3 @@ }), | ||
throw new RestrictionError( | ||
this.i18n('exceedsSize', { | ||
this.getI18n()('exceedsSize', { | ||
size: prettierBytes(maxFileSize), | ||
@@ -172,3 +174,3 @@ file: file.name, | ||
throw new RestrictionError( | ||
this.i18n('inferiorSize', { | ||
this.getI18n()('inferiorSize', { | ||
size: prettierBytes(minFileSize), | ||
@@ -195,3 +197,5 @@ }), | ||
throw new RestrictionError( | ||
this.i18n('youHaveToAtLeastSelectX', { smart_count: minNumberOfFiles }), | ||
this.getI18n()('youHaveToAtLeastSelectX', { | ||
smart_count: minNumberOfFiles, | ||
}), | ||
) | ||
@@ -206,3 +210,3 @@ } | ||
const error = new RestrictionError<M, B>( | ||
this.i18n('missingRequiredMetaFieldOnFile', { fileName: file.name }), | ||
this.getI18n()('missingRequiredMetaFieldOnFile', { fileName: file.name }), | ||
) | ||
@@ -209,0 +213,0 @@ const { requiredMetaFields } = this.getOpts().restrictions |
@@ -8,4 +8,4 @@ /* eslint-disable class-methods-use-this */ | ||
import BasePlugin from './BasePlugin.ts' | ||
import type { PluginOpts } from './BasePlugin.ts' | ||
import type { State } from './Uppy.ts' | ||
import type { PluginOpts } from './BasePlugin.js' | ||
import type { State } from './Uppy.js' | ||
@@ -12,0 +12,0 @@ /** |
@@ -6,2 +6,3 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import Uppy, { UIPlugin } from '..' | ||
// eslint-disable-next-line no-restricted-syntax | ||
import type { | ||
@@ -8,0 +9,0 @@ UploadedUppyFile, |
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 too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
478332
8201
Updated@uppy/utils@^5.9.0