@uppy/utils
Advanced tools
Comparing version 5.8.0 to 5.9.0
# @uppy/utils | ||
## 5.9.0 | ||
Released: 2024-04-29 | ||
Included in: Uppy v3.25.0 | ||
- @uppy/utils: improve return type of `dataURItoFile` (Antoine du Hamel / #5112) | ||
## 5.8.0 | ||
@@ -4,0 +11,0 @@ |
const DATA_URL_PATTERN = /^data:([^/]+\/[^,;]+(?:[^,]*?))(;base64)?,([\s\S]*)$/; | ||
export default function dataURItoBlob(dataURI, opts, toFile) { | ||
function dataURItoBlob(dataURI, opts, toFile) { | ||
var _ref, _opts$mimeType; | ||
@@ -30,2 +30,3 @@ // get the base64 data | ||
}); | ||
} | ||
} | ||
export default dataURItoBlob; |
@@ -17,7 +17,7 @@ import getFileType from "./getFileType.js"; | ||
*/ | ||
export default function generateFileID(file) { | ||
export default function generateFileID(file, instanceId) { | ||
// It's tempting to do `[items].filter(Boolean).join('-')` here, but that | ||
// is slower! simple string concatenation is fast | ||
let id = 'uppy'; | ||
let id = instanceId || 'uppy'; | ||
if (typeof file.name === 'string') { | ||
@@ -49,3 +49,3 @@ id += `-${encodeFilename(file.name.toLowerCase())}`; | ||
} | ||
export function getSafeFileId(file) { | ||
export function getSafeFileId(file, instanceId) { | ||
if (hasFileStableId(file)) return file.id; | ||
@@ -56,3 +56,3 @@ const fileType = getFileType(file); | ||
type: fileType | ||
}); | ||
}, instanceId); | ||
} |
@@ -15,3 +15,5 @@ function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; } | ||
class ProgressTimeout { | ||
constructor(timeout, timeoutHandler) { | ||
constructor(timeout, | ||
// eslint-disable-next-line no-shadow | ||
timeoutHandler) { | ||
Object.defineProperty(this, _aliveTimer, { | ||
@@ -34,3 +36,3 @@ writable: true, | ||
_classPrivateFieldLooseBase(this, _timeout)[_timeout] = timeout; | ||
_classPrivateFieldLooseBase(this, _onTimedOut)[_onTimedOut] = timeoutHandler; | ||
_classPrivateFieldLooseBase(this, _onTimedOut)[_onTimedOut] = () => timeoutHandler(timeout); | ||
} | ||
@@ -37,0 +39,0 @@ progress() { |
{ | ||
"name": "@uppy/utils", | ||
"description": "Shared utility functions for Uppy Core and plugins maintained by the Uppy team.", | ||
"version": "5.8.0", | ||
"version": "5.9.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "types": "types/index.d.ts", |
const DATA_URL_PATTERN = /^data:([^/]+\/[^,;]+(?:[^,]*?))(;base64)?,([\s\S]*)$/ | ||
export default function dataURItoBlob( | ||
type dataURItoBlobOptions = { mimeType?: string; name?: string } | ||
function dataURItoBlob(dataURI: string, opts: dataURItoBlobOptions): Blob | ||
function dataURItoBlob( | ||
dataURI: string, | ||
opts: { mimeType?: string; name?: string }, | ||
opts: dataURItoBlobOptions, | ||
toFile: true, | ||
): File | ||
function dataURItoBlob( | ||
dataURI: string, | ||
opts: dataURItoBlobOptions, | ||
toFile?: boolean, | ||
@@ -33,1 +42,3 @@ ): Blob | File { | ||
} | ||
export default dataURItoBlob |
@@ -6,4 +6,4 @@ import dataURItoBlob from './dataURItoBlob.ts' | ||
opts: { mimeType?: string; name?: string }, | ||
): File | Blob { | ||
): File { | ||
return dataURItoBlob(dataURI, opts, true) | ||
} |
import throttle from 'lodash/throttle.js' | ||
import type { UppyFile } from './UppyFile' | ||
import type { FileProgress } from './FileProgress' | ||
import type { UppyFile } from './UppyFile.js' | ||
import type { FileProgress } from './FileProgress.js' | ||
@@ -5,0 +5,0 @@ function emitSocketProgress( |
@@ -1,2 +0,2 @@ | ||
import type NetworkError from './NetworkError.ts' | ||
import type NetworkError from './NetworkError.js' | ||
import hasProperty from './hasProperty.ts' | ||
@@ -3,0 +3,0 @@ |
@@ -47,3 +47,3 @@ import NetworkError from './NetworkError.ts' | ||
/** Called when no XMLHttpRequest upload progress events have been received for `timeout` ms. */ | ||
onTimeout?: () => void | ||
onTimeout?: (timeout: number) => void | ||
@@ -50,0 +50,0 @@ /** Signal to abort the upload. */ |
@@ -1,2 +0,2 @@ | ||
import type { UppyFile } from './UppyFile' | ||
import type { UppyFile } from './UppyFile.js' | ||
@@ -3,0 +3,0 @@ export function filterNonFailedFiles( |
@@ -1,2 +0,2 @@ | ||
import type { MinimalRequiredUppyFile } from './UppyFile' | ||
import type { MinimalRequiredUppyFile } from './UppyFile.js' | ||
import getFileType from './getFileType.ts' | ||
@@ -24,2 +24,3 @@ | ||
file: MinimalRequiredUppyFile<any, any>, | ||
instanceId: string, | ||
): string { | ||
@@ -29,3 +30,3 @@ // It's tempting to do `[items].filter(Boolean).join('-')` here, but that | ||
let id = 'uppy' | ||
let id = instanceId || 'uppy' | ||
if (typeof file.name === 'string') { | ||
@@ -68,3 +69,6 @@ id += `-${encodeFilename(file.name.toLowerCase())}` | ||
export function getSafeFileId(file: MinimalRequiredUppyFile<any, any>): string { | ||
export function getSafeFileId( | ||
file: MinimalRequiredUppyFile<any, any>, | ||
instanceId: string, | ||
): string { | ||
if (hasFileStableId(file)) return file.id! | ||
@@ -74,6 +78,9 @@ | ||
return generateFileID({ | ||
...file, | ||
type: fileType, | ||
}) | ||
return generateFileID( | ||
{ | ||
...file, | ||
type: fileType, | ||
}, | ||
instanceId, | ||
) | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { FileProgress } from './FileProgress' | ||
import type { FileProgress } from './FileProgress.js' | ||
@@ -3,0 +3,0 @@ export default function getBytesRemaining(fileProgress: FileProgress): number { |
import getSpeed from './getSpeed.ts' | ||
import getBytesRemaining from './getBytesRemaining.ts' | ||
import type { FileProgress } from './FileProgress.ts' | ||
import type { FileProgress } from './FileProgress.js' | ||
@@ -5,0 +5,0 @@ export default function getETA(fileProgress: FileProgress): number { |
import { describe, expect, it } from 'vitest' | ||
import getFileType from './getFileType.ts' | ||
import type { UppyFile } from './UppyFile.ts' | ||
import type { UppyFile } from './UppyFile.js' | ||
@@ -5,0 +5,0 @@ describe('getFileType', () => { |
@@ -1,2 +0,2 @@ | ||
import type { FileProgress, FileProgressStarted } from './FileProgress' | ||
import type { FileProgress, FileProgressStarted } from './FileProgress.js' | ||
@@ -3,0 +3,0 @@ export default function getSpeed(fileProgress: FileProgress): number { |
@@ -18,6 +18,7 @@ /** | ||
timeout: number, | ||
timeoutHandler: Parameters<typeof setTimeout>[0], | ||
// eslint-disable-next-line no-shadow | ||
timeoutHandler: (timeout: number) => void, | ||
) { | ||
this.#timeout = timeout | ||
this.#onTimedOut = timeoutHandler | ||
this.#onTimedOut = () => timeoutHandler(timeout) | ||
} | ||
@@ -24,0 +25,0 @@ |
@@ -1,2 +0,2 @@ | ||
import type { FileProgress } from './FileProgress' | ||
import type { FileProgress } from './FileProgress.js' | ||
@@ -3,0 +3,0 @@ export type Meta = Record<string, unknown> |
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
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
338348
300734
4637
100
1
1
0
22