@uppy/xhr-upload
Advanced tools
Comparing version 3.3.0 to 3.3.1
# @uppy/xhr-upload | ||
## 3.3.1 | ||
Released: 2023-07-06 | ||
Included in: Uppy v3.11.0 | ||
- @uppy/xhr-upload: export `Headers` type (Masum ULU / #4549) | ||
## 3.3.0 | ||
@@ -4,0 +11,0 @@ |
function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; } | ||
var id = 0; | ||
function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; } | ||
import BasePlugin from '@uppy/core/lib/BasePlugin.js'; | ||
import UploaderPlugin from '@uppy/core/lib/UploaderPlugin.js'; | ||
import { nanoid } from 'nanoid/non-secure'; | ||
@@ -16,3 +16,3 @@ import { Provider, RequestClient, Socket } from '@uppy/companion-client'; | ||
const packageJson = { | ||
"version": "3.3.0" | ||
"version": "3.3.1" | ||
}; | ||
@@ -52,10 +52,8 @@ import locale from './locale.js'; | ||
} | ||
var _queueRequestSocketToken = /*#__PURE__*/_classPrivateFieldLooseKey("queueRequestSocketToken"); | ||
var _upload = /*#__PURE__*/_classPrivateFieldLooseKey("upload"); | ||
var _requestSocketToken = /*#__PURE__*/_classPrivateFieldLooseKey("requestSocketToken"); | ||
var _uploadRemote = /*#__PURE__*/_classPrivateFieldLooseKey("uploadRemote"); | ||
var _uploadBundle = /*#__PURE__*/_classPrivateFieldLooseKey("uploadBundle"); | ||
var _uploadFiles = /*#__PURE__*/_classPrivateFieldLooseKey("uploadFiles"); | ||
var _handleUpload = /*#__PURE__*/_classPrivateFieldLooseKey("handleUpload"); | ||
export default class XHRUpload extends BasePlugin { | ||
export default class XHRUpload extends UploaderPlugin { | ||
constructor(uppy, _opts) { | ||
@@ -69,14 +67,5 @@ super(uppy, _opts); | ||
}); | ||
// NOTE! Keep this duplicated code in sync with other plugins | ||
// TODO we should probably abstract this into a common function | ||
Object.defineProperty(this, _uploadRemote, { | ||
value: _uploadRemote2 | ||
}); | ||
Object.defineProperty(this, _upload, { | ||
value: _upload2 | ||
}); | ||
Object.defineProperty(this, _queueRequestSocketToken, { | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, _requestSocketToken, { | ||
@@ -208,5 +197,5 @@ writable: true, | ||
this.uploaderEvents = Object.create(null); | ||
_classPrivateFieldLooseBase(this, _queueRequestSocketToken)[_queueRequestSocketToken] = this.requests.wrapPromiseFunction(_classPrivateFieldLooseBase(this, _requestSocketToken)[_requestSocketToken], { | ||
this.setQueueRequestSocketToken(this.requests.wrapPromiseFunction(_classPrivateFieldLooseBase(this, _requestSocketToken)[_requestSocketToken], { | ||
priority: -1 | ||
}); | ||
})); | ||
} | ||
@@ -545,27 +534,2 @@ getOptions(file) { | ||
} | ||
async function _uploadRemote2(file, options) { | ||
// TODO: we could rewrite this to use server-sent events instead of creating WebSockets. | ||
try { | ||
if (file.serverToken) { | ||
return await this.connectToServerSocket(file); | ||
} | ||
const serverToken = await _classPrivateFieldLooseBase(this, _queueRequestSocketToken)[_queueRequestSocketToken](file, options).abortOn(options == null ? void 0 : options.signal); | ||
if (!this.uppy.getState().files[file.id]) return undefined; | ||
this.uppy.setFileState(file.id, { | ||
serverToken | ||
}); | ||
return await this.connectToServerSocket(this.uppy.getFile(file.id)); | ||
} catch (err) { | ||
var _err$cause; | ||
if ((err == null ? void 0 : (_err$cause = err.cause) == null ? void 0 : _err$cause.name) !== 'AbortError') { | ||
this.uppy.setFileState(file.id, { | ||
serverToken: undefined | ||
}); | ||
this.uppy.emit('upload-error', file, err); | ||
throw err; | ||
} | ||
// The file upload was aborted, it’s not an error | ||
return undefined; | ||
} | ||
} | ||
function _uploadBundle2(files) { | ||
@@ -666,3 +630,3 @@ return new Promise((resolve, reject) => { | ||
this.uppy.on('file-removed', removedHandler); | ||
const uploadPromise = _classPrivateFieldLooseBase(this, _uploadRemote)[_uploadRemote](file, { | ||
const uploadPromise = this.uploadRemoteFile(file, { | ||
signal: controller.signal | ||
@@ -669,0 +633,0 @@ }); |
{ | ||
"name": "@uppy/xhr-upload", | ||
"description": "Plain and simple classic HTML multipart form uploads with Uppy, as well as uploads using the HTTP PUT method.", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"license": "MIT", | ||
@@ -28,3 +28,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@uppy/companion-client": "^3.1.3", | ||
"@uppy/companion-client": "^3.2.0", | ||
"@uppy/utils": "^5.4.0", | ||
@@ -38,4 +38,4 @@ "nanoid": "^4.0.0" | ||
"peerDependencies": { | ||
"@uppy/core": "^3.2.1" | ||
"@uppy/core": "^3.3.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import BasePlugin from '@uppy/core/lib/BasePlugin.js' | ||
import UploaderPlugin from '@uppy/core/lib/UploaderPlugin.js' | ||
import { nanoid } from 'nanoid/non-secure' | ||
@@ -49,8 +49,6 @@ import { Provider, RequestClient, Socket } from '@uppy/companion-client' | ||
export default class XHRUpload extends BasePlugin { | ||
export default class XHRUpload extends UploaderPlugin { | ||
// eslint-disable-next-line global-require | ||
static VERSION = packageJson.version | ||
#queueRequestSocketToken | ||
constructor (uppy, opts) { | ||
@@ -133,3 +131,3 @@ super(uppy, opts) | ||
this.uploaderEvents = Object.create(null) | ||
this.#queueRequestSocketToken = this.requests.wrapPromiseFunction(this.#requestSocketToken, { priority: -1 }) | ||
this.setQueueRequestSocketToken(this.requests.wrapPromiseFunction(this.#requestSocketToken, { priority: -1 })) | ||
} | ||
@@ -378,27 +376,2 @@ | ||
// NOTE! Keep this duplicated code in sync with other plugins | ||
// TODO we should probably abstract this into a common function | ||
async #uploadRemote (file, options) { | ||
// TODO: we could rewrite this to use server-sent events instead of creating WebSockets. | ||
try { | ||
if (file.serverToken) { | ||
return await this.connectToServerSocket(file) | ||
} | ||
const serverToken = await this.#queueRequestSocketToken(file, options).abortOn(options?.signal) | ||
if (!this.uppy.getState().files[file.id]) return undefined | ||
this.uppy.setFileState(file.id, { serverToken }) | ||
return await this.connectToServerSocket(this.uppy.getFile(file.id)) | ||
} catch (err) { | ||
if (err?.cause?.name !== 'AbortError') { | ||
this.uppy.setFileState(file.id, { serverToken: undefined }) | ||
this.uppy.emit('upload-error', file, err) | ||
throw err | ||
} | ||
// The file upload was aborted, it’s not an error | ||
return undefined | ||
} | ||
} | ||
async connectToServerSocket (file) { | ||
@@ -609,3 +582,3 @@ return new Promise((resolve, reject) => { | ||
const uploadPromise = this.#uploadRemote(file, { signal: controller.signal }) | ||
const uploadPromise = this.uploadRemoteFile(file, { signal: controller.signal }) | ||
@@ -612,0 +585,0 @@ this.requests.wrapSyncFunction(() => { |
import type { PluginOptions, BasePlugin, UppyFile } from '@uppy/core' | ||
import XHRUploadLocale from './generatedLocale' | ||
type Headers = { | ||
[name: string]: string | number | ||
} | ||
export type Headers = { | ||
[name: string]: string | number | ||
} | ||
@@ -8,0 +8,0 @@ export interface XHRUploadOptions extends PluginOptions { |
Sorry, the diff of this file is not supported yet
104518
1362