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

@uppy/xhr-upload

Package Overview
Dependencies
Maintainers
5
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uppy/xhr-upload - npm Package Compare versions

Comparing version 4.2.1 to 4.2.2

8

CHANGELOG.md
# @uppy/xhr-upload
## 4.2.2
Released: 2024-10-31
Included in: Uppy v4.6.0
- @uppy/xhr-upload: fix stale file references in events (Merlijn Vos / #5499)
- @uppy/aws-s3,@uppy/box,@uppy/companion-client,@uppy/core,@uppy/dashboard,@uppy/drag-drop,@uppy/dropbox,@uppy/facebook,@uppy/file-input,@uppy/form,@uppy/golden-retriever,@uppy/google-drive,@uppy/google-photos,@uppy/image-editor,@uppy/informer,@uppy/instagram,@uppy/locales,@uppy/onedrive,@uppy/progress-bar,@uppy/provider-views,@uppy/react-native,@uppy/react,@uppy/redux-dev-tools,@uppy/screen-capture,@uppy/status-bar,@uppy/store-default,@uppy/store-redux,@uppy/svelte,@uppy/thumbnail-generator,@uppy/transloadit,@uppy/tus,@uppy/unsplash,@uppy/url,@uppy/utils,@uppy/vue,@uppy/webcam,@uppy/xhr-upload,@uppy/zoom: Fix links (Anthony Veaudry / #5492)
## 4.2.1

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

15

lib/index.js

@@ -21,3 +21,3 @@ function _classPrivateFieldLooseBase(e, t) { if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); return e; }

const packageJson = {
"version": "4.2.1"
"version": "4.2.2"
};

@@ -182,4 +182,7 @@ import locale from "./locale.js";

if (event.lengthComputable) {
for (const file of files) {
for (const {
id
} of files) {
var _file$progress$upload;
const file = this.uppy.getFile(id);
this.uppy.emit('upload-progress', file, {

@@ -204,4 +207,6 @@ uploadStarted: (_file$progress$upload = file.progress.uploadStarted) != null ? _file$progress$upload : 0,

const uploadURL = typeof ((_body2 = body) == null ? void 0 : _body2.url) === 'string' ? body.url : undefined;
for (const file of files) {
this.uppy.emit('upload-success', file, {
for (const {
id
} of files) {
this.uppy.emit('upload-success', this.uppy.getFile(id), {
status: res.status,

@@ -220,3 +225,3 @@ body,

for (const file of files) {
this.uppy.emit('upload-error', file, buildResponseError(request, error), request);
this.uppy.emit('upload-error', this.uppy.getFile(file.id), buildResponseError(request, error), request);
}

@@ -223,0 +228,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": "4.2.1",
"version": "4.2.2",
"license": "MIT",

@@ -27,4 +27,4 @@ "main": "lib/index.js",

"dependencies": {
"@uppy/companion-client": "^4.1.0",
"@uppy/utils": "^6.0.3"
"@uppy/companion-client": "^4.1.1",
"@uppy/utils": "^6.0.4"
},

@@ -36,4 +36,4 @@ "devDependencies": {

"peerDependencies": {
"@uppy/core": "^4.2.2"
"@uppy/core": "^4.2.3"
}
}

@@ -6,3 +6,3 @@ # @uppy/xhr-upload

[![npm version](https://img.shields.io/npm/v/@uppy/xhr-upload.svg?style=flat-square)](https://www.npmjs.com/package/@uppy/xhr-upload)
![CI status for Uppy tests](https://github.com/transloadit/uppy/workflows/Tests/badge.svg)
![CI status for Uppy tests](https://github.com/transloadit/uppy/workflows/CI/badge.svg)
![CI status for Companion tests](https://github.com/transloadit/uppy/workflows/Companion/badge.svg)

@@ -9,0 +9,0 @@ ![CI status for browser tests](https://github.com/transloadit/uppy/workflows/End-to-end%20tests/badge.svg)

import { vi, describe, it, expect } from 'vitest'
import nock from 'nock'
import Core from '@uppy/core'
import Core, { type UppyEventMap } from '@uppy/core'
import XHRUpload from './index.ts'

@@ -64,2 +64,54 @@

it('should send response object over upload-error event', async () => {
nock('https://fake-endpoint.uppy.io')
.defaultReplyHeaders({
'access-control-allow-method': 'POST',
'access-control-allow-origin': '*',
})
.options('/')
.reply(204, {})
.post('/')
.reply(400, { status: 400, message: 'Oh no' })
const core = new Core()
const shouldRetry = vi.fn(() => false)
core.use(XHRUpload, {
id: 'XHRUpload',
endpoint: 'https://fake-endpoint.uppy.io',
shouldRetry,
})
const id = core.addFile({
type: 'image/png',
source: 'test',
name: 'test.jpg',
data: new Blob([new Uint8Array(8192)]),
})
const event = new Promise<
Parameters<UppyEventMap<any, any>['upload-error']>
>((resolve) => {
core.once('upload-error', (...args) => resolve(args))
})
await Promise.all([
core.upload(),
event.then(([file, , response]) => {
const newFile = core.getFile(id)
// error and response are set inside upload-error in core.
// When we subscribe to upload-error it is emitted before
// these properties are set in core. Ideally we'd have an internal
// emitter which calls an external one but it is what it is.
delete newFile.error
delete newFile.response
// This is still useful to test because other properties
// might have changed in the meantime
expect(file).toEqual(newFile)
expect(response).toBeInstanceOf(XMLHttpRequest)
}),
])
expect(shouldRetry).toHaveBeenCalledTimes(1)
})
describe('headers', () => {

@@ -66,0 +118,0 @@ it('can be a function', async () => {

@@ -221,3 +221,4 @@ import BasePlugin from '@uppy/core/lib/BasePlugin.js'

if (event.lengthComputable) {
for (const file of files) {
for (const { id } of files) {
const file = this.uppy.getFile(id)
this.uppy.emit('upload-progress', file, {

@@ -245,4 +246,4 @@ uploadStarted: file.progress.uploadStarted ?? 0,

for (const file of files) {
this.uppy.emit('upload-success', file, {
for (const { id } of files) {
this.uppy.emit('upload-success', this.uppy.getFile(id), {
status: res.status,

@@ -265,3 +266,3 @@ body,

'upload-error',
file,
this.uppy.getFile(file.id),
buildResponseError(request, error),

@@ -268,0 +269,0 @@ request,

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