Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@uppy/transloadit

Package Overview
Dependencies
Maintainers
6
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uppy/transloadit - npm Package Compare versions

Comparing version 3.2.1 to 3.3.0

8

CHANGELOG.md
# @uppy/transloadit
## 3.3.0
Released: 2023-09-05
Included in: Uppy v3.15.0
- @uppy/transloadit: Emit assembly progress events (Marius / #4603)
- @uppy/transloadit: remove Socket.io (Antoine du Hamel / #4281)
## 3.2.1

@@ -4,0 +12,0 @@

77

lib/Assembly.js

@@ -5,7 +5,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; }

import Emitter from 'component-emitter';
import { io } from 'socket.io-client';
import has from '@uppy/utils/lib/hasProperty';
import NetworkError from '@uppy/utils/lib/NetworkError';
import fetchWithNetworkError from '@uppy/utils/lib/fetchWithNetworkError';
import parseUrl from './parseUrl.js';
const ASSEMBLY_UPLOADING = 'ASSEMBLY_UPLOADING';

@@ -35,3 +33,2 @@ const ASSEMBLY_EXECUTING = 'ASSEMBLY_EXECUTING';

var _connectServerSentEvents = /*#__PURE__*/_classPrivateFieldLooseKey("connectServerSentEvents");
var _connectSocket = /*#__PURE__*/_classPrivateFieldLooseKey("connectSocket");
var _onError = /*#__PURE__*/_classPrivateFieldLooseKey("onError");

@@ -57,3 +54,3 @@ var _beginPolling = /*#__PURE__*/_classPrivateFieldLooseKey("beginPolling");

/**
* Reload assembly status. Useful if the socket doesn't work.
* Reload assembly status. Useful if SSE doesn't work.
*

@@ -68,4 +65,4 @@ * Pass `diff: false` to avoid emitting diff events, instead only emitting

* Begin polling for assembly status changes. This sends a request to the
* assembly status endpoint every so often, if the socket is not connected.
* If the socket connection fails or takes a long time, we won't miss any
* assembly status endpoint every so often, if SSE connection failed.
* If the SSE connection fails or takes a long time, we won't miss any
* events.

@@ -79,5 +76,2 @@ */

});
Object.defineProperty(this, _connectSocket, {
value: _connectSocket2
});
Object.defineProperty(this, _connectServerSentEvents, {

@@ -106,4 +100,2 @@ value: _connectServerSentEvents2

this.status = assembly;
// The socket.io connection.
this.socket = null;
// The interval timer for full status updates.

@@ -118,3 +110,2 @@ this.pollInterval = null;

_classPrivateFieldLooseBase(this, _connectServerSentEvents)[_connectServerSentEvents]();
_classPrivateFieldLooseBase(this, _connectSocket)[_connectSocket]();
_classPrivateFieldLooseBase(this, _beginPolling)[_beginPolling]();

@@ -147,6 +138,2 @@ }

}
if (this.socket) {
this.socket.disconnect();
this.socket = null;
}
clearInterval(this.pollInterval);

@@ -203,2 +190,6 @@ this.pollInterval = null;

});
_classPrivateFieldLooseBase(this, _sse)[_sse].addEventListener('assembly_execution_progress', e => {
const details = JSON.parse(e.data);
this.emit('execution-progress', details);
});
_classPrivateFieldLooseBase(this, _sse)[_sse].addEventListener('assembly_error', e => {

@@ -218,48 +209,2 @@ try {

}
function _connectSocket2() {
const parsed = parseUrl(this.status.websocket_url);
const socket = io(parsed.origin, {
transports: ['websocket'],
path: parsed.pathname
});
socket.on('connect', () => {
socket.emit('assembly_connect', {
id: this.status.assembly_id
});
this.emit('connect');
});
socket.on('connect_error', () => {
socket.disconnect();
this.socket = null;
});
socket.on('assembly_finished', () => {
_classPrivateFieldLooseBase(this, _onFinished)[_onFinished]();
});
socket.on('assembly_upload_finished', file => {
this.emit('upload', file);
this.status.uploads.push(file);
});
socket.on('assembly_uploading_finished', () => {
this.emit('executing');
});
socket.on('assembly_upload_meta_data_extracted', () => {
this.emit('metadata');
_classPrivateFieldLooseBase(this, _fetchStatus)[_fetchStatus]({
diff: false
});
});
socket.on('assembly_result_finished', (stepName, result) => {
var _this$status$results2, _this$status$results3;
this.emit('result', stepName, result);
((_this$status$results3 = (_this$status$results2 = this.status.results)[stepName]) != null ? _this$status$results3 : _this$status$results2[stepName] = []).push(result);
});
socket.on('assembly_error', status => {
// Refetch for updated status code
_classPrivateFieldLooseBase(this, _fetchStatus)[_fetchStatus]({
diff: false
});
_classPrivateFieldLooseBase(this, _onError)[_onError](status);
});
this.socket = socket;
}
function _onError2(status) {

@@ -271,5 +216,3 @@ this.emit('error', Object.assign(new Error(status.msg), status));

this.pollInterval = setInterval(() => {
if (!this.socket || !this.socket.connected) {
_classPrivateFieldLooseBase(this, _fetchStatus)[_fetchStatus]();
}
_classPrivateFieldLooseBase(this, _fetchStatus)[_fetchStatus]();
}, 2000);

@@ -326,6 +269,6 @@ }

if (nowExecuting) {
// Without WebSockets, this is our only way to tell if uploading finished.
// Without SSE, this is our only way to tell if uploading finished.
// Hence, we emit this just before the 'upload's and before the 'metadata'
// event for the most intuitive ordering, corresponding to the _usual_
// ordering (if not guaranteed) that you'd get on the WebSocket.
// ordering (if not guaranteed) that you'd get on SSE.
this.emit('executing');

@@ -332,0 +275,0 @@ }

@@ -15,3 +15,3 @@ function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }

const packageJson = {
"version": "3.2.1"
"version": "3.3.0"
};

@@ -919,2 +919,23 @@ const sendErrorToConsole = originalErr => err => {

});
assembly.on('execution-progress', details => {
this.uppy.emit('transloadit:execution-progress', details);
if (details.progress_combined != null) {
// TODO: Transloadit emits progress information for the entire Assembly combined
// (progress_combined) and for each imported/uploaded file (progress_per_original_file).
// Uppy's current design requires progress to be set for each file, which is then
// averaged to get the total progress (see calculateProcessingProgress.js).
// Therefore, we currently set the combined progres for every file, so that this is
// the same value that is displayed to the end user, although we have more accurate
// per-file progress as well. We cannot use this here or otherwise progress from
// imported files would not be counted towards the total progress because imported
// files are not registered with Uppy.
for (const file of this.uppy.getFiles()) {
this.uppy.emit('postprocess-progress', file, {
mode: 'determinate',
value: details.progress_combined / 100,
message: this.i18n('encoding')
});
}
}
});
if (this.opts.waitForEncoding) {

@@ -921,0 +942,0 @@ assembly.on('result', (stepName, result) => {

{
"name": "@uppy/transloadit",
"description": "The Transloadit plugin can be used to upload files to Transloadit for all kinds of processing, such as transcoding video, resizing images, zipping/unzipping, and more",
"version": "3.2.1",
"version": "3.3.0",
"license": "MIT",

@@ -31,11 +31,10 @@ "main": "lib/index.js",

"dependencies": {
"@uppy/companion-client": "^3.3.0",
"@uppy/companion-client": "^3.4.0",
"@uppy/provider-views": "^3.5.0",
"@uppy/tus": "^3.1.3",
"@uppy/utils": "^5.4.3",
"component-emitter": "^1.2.1",
"socket.io-client": "^4.1.3"
"@uppy/tus": "^3.2.0",
"@uppy/utils": "^5.5.0",
"component-emitter": "^1.2.1"
},
"peerDependencies": {
"@uppy/core": "^3.4.0"
"@uppy/core": "^3.5.0"
},

@@ -42,0 +41,0 @@ "devDependencies": {

import Emitter from 'component-emitter'
import { io } from 'socket.io-client'
import has from '@uppy/utils/lib/hasProperty'
import NetworkError from '@uppy/utils/lib/NetworkError'
import fetchWithNetworkError from '@uppy/utils/lib/fetchWithNetworkError'
import parseUrl from './parseUrl.js'

@@ -46,4 +44,2 @@ const ASSEMBLY_UPLOADING = 'ASSEMBLY_UPLOADING'

this.status = assembly
// The socket.io connection.
this.socket = null
// The interval timer for full status updates.

@@ -60,3 +56,2 @@ this.pollInterval = null

this.#connectServerSentEvents()
this.#connectSocket()
this.#beginPolling()

@@ -116,2 +111,7 @@ }

this.#sse.addEventListener('assembly_execution_progress', (e) => {
const details = JSON.parse(e.data)
this.emit('execution-progress', details)
})
this.#sse.addEventListener('assembly_error', (e) => {

@@ -128,54 +128,2 @@ try {

#connectSocket () {
const parsed = parseUrl(this.status.websocket_url)
const socket = io(parsed.origin, {
transports: ['websocket'],
path: parsed.pathname,
})
socket.on('connect', () => {
socket.emit('assembly_connect', {
id: this.status.assembly_id,
})
this.emit('connect')
})
socket.on('connect_error', () => {
socket.disconnect()
this.socket = null
})
socket.on('assembly_finished', () => {
this.#onFinished()
})
socket.on('assembly_upload_finished', (file) => {
this.emit('upload', file)
this.status.uploads.push(file)
})
socket.on('assembly_uploading_finished', () => {
this.emit('executing')
})
socket.on('assembly_upload_meta_data_extracted', () => {
this.emit('metadata')
this.#fetchStatus({ diff: false })
})
socket.on('assembly_result_finished', (stepName, result) => {
this.emit('result', stepName, result)
;(this.status.results[stepName] ??= []).push(result)
})
socket.on('assembly_error', (status) => {
// Refetch for updated status code
this.#fetchStatus({ diff: false })
this.#onError(status)
})
this.socket = socket
}
#onError (status) {

@@ -188,4 +136,4 @@ this.emit('error', Object.assign(new Error(status.msg), status))

* Begin polling for assembly status changes. This sends a request to the
* assembly status endpoint every so often, if the socket is not connected.
* If the socket connection fails or takes a long time, we won't miss any
* assembly status endpoint every so often, if SSE connection failed.
* If the SSE connection fails or takes a long time, we won't miss any
* events.

@@ -195,5 +143,3 @@ */

this.pollInterval = setInterval(() => {
if (!this.socket || !this.socket.connected) {
this.#fetchStatus()
}
this.#fetchStatus()
}, 2000)

@@ -203,3 +149,3 @@ }

/**
* Reload assembly status. Useful if the socket doesn't work.
* Reload assembly status. Useful if SSE doesn't work.
*

@@ -286,6 +232,6 @@ * Pass `diff: false` to avoid emitting diff events, instead only emitting

if (nowExecuting) {
// Without WebSockets, this is our only way to tell if uploading finished.
// Without SSE, this is our only way to tell if uploading finished.
// Hence, we emit this just before the 'upload's and before the 'metadata'
// event for the most intuitive ordering, corresponding to the _usual_
// ordering (if not guaranteed) that you'd get on the WebSocket.
// ordering (if not guaranteed) that you'd get on SSE.
this.emit('executing')

@@ -334,6 +280,2 @@ }

}
if (this.socket) {
this.socket.disconnect()
this.socket = null
}
clearInterval(this.pollInterval)

@@ -340,0 +282,0 @@ this.pollInterval = null

@@ -600,2 +600,25 @@ import hasProperty from '@uppy/utils/lib/hasProperty'

assembly.on('execution-progress', (details) => {
this.uppy.emit('transloadit:execution-progress', details)
if (details.progress_combined != null) {
// TODO: Transloadit emits progress information for the entire Assembly combined
// (progress_combined) and for each imported/uploaded file (progress_per_original_file).
// Uppy's current design requires progress to be set for each file, which is then
// averaged to get the total progress (see calculateProcessingProgress.js).
// Therefore, we currently set the combined progres for every file, so that this is
// the same value that is displayed to the end user, although we have more accurate
// per-file progress as well. We cannot use this here or otherwise progress from
// imported files would not be counted towards the total progress because imported
// files are not registered with Uppy.
for (const file of this.uppy.getFiles()) {
this.uppy.emit('postprocess-progress', file, {
mode: 'determinate',
value: details.progress_combined / 100,
message: this.i18n('encoding'),
})
}
}
})
if (this.opts.waitForEncoding) {

@@ -602,0 +625,0 @@ assembly.on('result', (stepName, result) => {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc