Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"presets": ["es2015"],
"plugins": [
"add-module-exports",
"transform-object-assign",
"es6-promise",
"transform-async-to-generator"
"presets": [
[
"@babel/preset-env",
{
"targets": {
"ie": "11"
}
}
]
]
}
71 changes: 40 additions & 31 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
"$schema": "https://biomejs.dev/schemas/2.4.14/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"ignore": ["test-results/"]
"includes": [
"**",
"!build/**",
"!coverage/**",
"!css/transloadit.css",
"!js/dep/**",
"!node_modules/**",
"!tests/fixtures/**",
"!test-results/**"
]
},
"formatter": {
"enabled": true,
Expand All @@ -19,33 +28,32 @@
"lineWidth": 100,
"attributePosition": "auto",
"bracketSpacing": true,
"ignore": [
"build/",
"css/transloadit.css",
"package.json",
"coverage/**",
"js/dep/",
"**/node_modules/",
"tests/fixtures/",
"test-results/"
"includes": [
"**",
"!**/build/",
"!**/css/transloadit.css",
"!**/package.json",
"!**/coverage/**",
"!**/js/dep/",
"!**/node_modules/",
"!**/tests/fixtures/",
"!**/test-results/"
]
},
"organizeImports": {
"enabled": true
},
"assist": { "actions": { "source": { "organizeImports": "on" } } },
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"complexity": {
"noExtraBooleanCast": "error",
"noMultipleSpacesInRegularExpressionLiterals": "error",
"noUselessConstructor": "error",
"noUselessLoneBlockStatements": "error",
"noUselessRename": "error",
"noUselessTernary": "error",
"noUselessUndefinedInitialization": "error",
"noWith": "error"
"noAdjacentSpacesInRegex": "error",
"noCommaOperator": "error"
},
"correctness": {
"noConstAssign": "error",
Expand All @@ -55,25 +63,25 @@
"noGlobalObjectCalls": "error",
"noInnerDeclarations": "error",
"noInvalidConstructorSuper": "error",
"noNewSymbol": "error",
"noSelfAssign": "error",
"noUndeclaredVariables": "error",
"noUnreachable": "error",
"noUnreachableSuper": "error",
"noUnsafeFinally": "error",
"noUnusedVariables": "error",
"useArrayLiterals": "error",
"useIsNan": "error"
"useIsNan": "error",
"noInvalidBuiltinInstantiation": "error",
"useValidTypeof": "error"
},
"security": {
"noGlobalEval": "error"
},
"style": {
"noCommaOperator": "error",
"noYodaExpression": "error",
"useBlockStatements": "error",
"useConsistentBuiltinInstantiation": "error",
"useSingleVarDeclarator": "error"
"useSingleVarDeclarator": "error",
"useArrayLiterals": "error"
},
"suspicious": {
"noCatchAssign": "error",
Expand All @@ -94,17 +102,18 @@
"noShadowRestrictedNames": "error",
"noSparseArray": "error",
"noUnsafeNegation": "error",
"useValidTypeof": "error"
"noWith": "error"
}
},
"ignore": [
"build/**",
"css/transloadit.css",
"package.json",
"coverage/**",
"js/dep/**",
"node_modules/**",
"test-results/"
"includes": [
"**",
"!**/build/**",
"!**/css/transloadit.css",
"!**/package.json",
"!**/coverage/**",
"!**/js/dep/**",
"!**/node_modules/**",
"!**/test-results/"
]
},
"javascript": {
Expand All @@ -119,6 +128,6 @@
"attributePosition": "auto",
"bracketSpacing": true
},
"globals": ["jQuery", "testhost", "casper", "arguments"]
"globals": ["$", "jQuery", "testhost", "casper", "arguments"]
}
}
14 changes: 2 additions & 12 deletions js/lib/jquery.transloadit.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,31 +382,21 @@ const tus = require('tus-js-client')
}
const upload = new tus.Upload(file, {
endpoint,
// Setting resume to false, may seem a bit counterproductive but you need
// to keep the actual effects of this setting in mind:
// a boolean indicating whether the client should attempt to resume the
// upload if the upload has been started in the past. This includes
// storing the file's fingerprint. Use false to force an entire reupload.
// Right now, always want to upload the entire file for two reasons:
// Right now, we always want to upload the entire file for two reasons:
// 1. Transloadit is not able to use the file uploaded from assembly A
// in assembly B, so we need to transfer the file for each assembly
// again and,
// 2. there is no mechanism for resuming the uploading for an assembly if
// the Uploader object gets destroyed (for example, if the page is
// reloaded) so we do not know to which assembly a file belongs and
// more.
resume: false,
storeFingerprintForResuming: false,
metadata: {
fieldname: nameAttr,
filename: file.name,
assembly_url: assemblyUrl,
},
retryDelays: [0, 1000, 3000, 5000],
fingerprint(_file) {
// Fingerprinting is not necessary any more since we have disabled
// the resuming of previous uploads.
throw new Error('fingerprinting should not happend')
},
onError(error) {
self._xhr = false
// If this is not a connection problem, bubble up the error.
Expand Down
37 changes: 15 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"version": "3.3.5",
"scripts": {
"browserify": "browserify -t [ babelify --presets [ es2015 ] ] js/lib/*.js -o build/jquery.transloadit2-v3-latest.js",
"browserify": "browserify -t babelify js/lib/*.js -o build/jquery.transloadit2-v3-latest.js",
"build": "npm run clean && npm run css && npm run browserify && npm run uglify && npm run inject_comment && npm run gzip && npm run versionify",
"clean": "rm -rf build/*",
"css": "mkdir -p build/css/img && cp css/transloadit.css build/css/transloadit2-v3-latest.css && cp -v css/img/* build/css/img/",
Expand Down Expand Up @@ -39,33 +39,26 @@
"js"
],
"dependencies": {
"@playwright/test": "^1.47.2",
"socket.io-client": "1.7.4",
"tus-js-client": "1.8.0"
"@playwright/test": "^1.59.1",
"socket.io-client": "2.5.0",
"tus-js-client": "^4.3.1"
},
"devDependencies": {
"@biomejs/biome": "^1.9.3",
"@vitest/coverage-v8": "^3.2.4",
"babel-cli": "6.26.0",
"babel-core": "6.26.3",
"babel-plugin-add-module-exports": "1.0.4",
"babel-plugin-es6-promise": "1.1.1",
"babel-plugin-syntax-async-functions": "6.13.0",
"babel-plugin-transform-async-to-generator": "6.24.1",
"babel-plugin-transform-object-assign": "6.22.0",
"babel-preset-es2015": "6.24.1",
"babelify": "8.0.0",
"browserify": "17.0.0",
"es6-promise": "4.2.8",
"jquery": "3.7.1",
"jsdom": "^25.0.1",
"@babel/core": "^7.29.0",
"@babel/preset-env": "^7.29.5",
"@biomejs/biome": "^2.4.14",
"@vitest/coverage-v8": "^4.1.5",
"babelify": "^10.0.0",
"browserify": "^17.0.1",
"jquery": "^4.0.0",
"jsdom": "^29.1.1",
"npm-run-all": "^4.1.5",
"uglify-js": "3.19.3",
"vite": "^6.4.2",
"vitest": "^3.2.4"
"vite": "^8.0.11",
"vitest": "^4.1.5"
},
"resolutions": {
"vite": "6.4.2"
"vite": "8.0.11"
},
"packageManager": "yarn@4.5.0"
}
3 changes: 2 additions & 1 deletion tests/e2e.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// import os from 'os'
import readline from 'readline'

/* eslint-disable max-len,quote-props */
// @ts-check
import { expect, test } from '@playwright/test'
import readline from 'readline'

const BASE_URL = `http://localhost:3000`

Expand Down
18 changes: 17 additions & 1 deletion tests/unit/jquery.transloadit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ vi.mock('../../js/lib/I18n', () => {
})
vi.mock('tus-js-client', () => {
return {
Upload: vi.fn(() => ({
Upload: vi.fn((_file, options) => ({
options,
start: vi.fn(),
abort: vi.fn(),
})),
Expand Down Expand Up @@ -137,5 +138,20 @@ describe('Uploader class', () => {
expect(uploader._assembly.cancel).toHaveBeenCalled()
})

it('should configure tus uploads without resumable URL storage', () => {
uploader._assembly = {
getTusUrl: vi.fn(() => 'https://tus.test.com/files/'),
getHttpsUrl: vi.fn(() => 'https://api2.transloadit.com/assemblies/test'),
getHttpUrl: vi.fn(() => 'http://api2.transloadit.com/assemblies/test'),
}
uploader._renderProgress = vi.fn()

const upload = uploader._addResumableUpload('file', { name: 'test.jpg' })

const uploadOptions = upload.options
expect(uploadOptions.storeFingerprintForResuming).toBe(false)
expect(uploadOptions).not.toHaveProperty('resume')
})

// Add more tests to cover other methods and scenarios
})
Loading
Loading