-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* main: Introduce `ValidateableFile` & move `MinimalRequiredUppyFile` into utils (#4944) uppy: fix bundle builder (#4950) @uppy/core: improve `UIPluginOptions` types (#4946) @uppy/companion-client: fix body/url on upload-success (#4922) @uppy/utils: remove EventManager circular reference (#4949)
- Loading branch information
Showing
16 changed files
with
414 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* Create a wrapper around an event emitter with a `remove` method to remove | ||
* all events that were added using the wrapped emitter. | ||
*/ | ||
export default class EventManager { | ||
#uppy | ||
|
||
#events = [] | ||
|
||
constructor (uppy) { | ||
this.#uppy = uppy | ||
} | ||
|
||
on (event, fn) { | ||
this.#events.push([event, fn]) | ||
return this.#uppy.on(event, fn) | ||
} | ||
|
||
remove () { | ||
for (const [event, fn] of this.#events.splice(0)) { | ||
this.#uppy.off(event, fn) | ||
} | ||
} | ||
|
||
onFilePause (fileID, cb) { | ||
this.on('upload-pause', (targetFileID, isPaused) => { | ||
if (fileID === targetFileID) { | ||
cb(isPaused) | ||
} | ||
}) | ||
} | ||
|
||
onFileRemove (fileID, cb) { | ||
this.on('file-removed', (file) => { | ||
if (fileID === file.id) cb(file.id) | ||
}) | ||
} | ||
|
||
onPause (fileID, cb) { | ||
this.on('upload-pause', (targetFileID, isPaused) => { | ||
if (fileID === targetFileID) { | ||
// const isPaused = this.#uppy.pauseResume(fileID) | ||
cb(isPaused) | ||
} | ||
}) | ||
} | ||
|
||
onRetry (fileID, cb) { | ||
this.on('upload-retry', (targetFileID) => { | ||
if (fileID === targetFileID) { | ||
cb() | ||
} | ||
}) | ||
} | ||
|
||
onRetryAll (fileID, cb) { | ||
this.on('retry-all', () => { | ||
if (!this.#uppy.getFile(fileID)) return | ||
cb() | ||
}) | ||
} | ||
|
||
onPauseAll (fileID, cb) { | ||
this.on('pause-all', () => { | ||
if (!this.#uppy.getFile(fileID)) return | ||
cb() | ||
}) | ||
} | ||
|
||
onCancelAll (fileID, eventHandler) { | ||
this.on('cancel-all', (...args) => { | ||
if (!this.#uppy.getFile(fileID)) return | ||
eventHandler(...args) | ||
}) | ||
} | ||
|
||
onResumeAll (fileID, cb) { | ||
this.on('resume-all', () => { | ||
if (!this.#uppy.getFile(fileID)) return | ||
cb() | ||
}) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.