├── README.md ├── out └── .keep ├── e2e ├── cypress │ ├── fixtures │ │ ├── images │ │ │ ├── 3 │ │ │ ├── 55.jpg │ │ │ ├── 2.jpg │ │ │ ├── 11.png │ │ │ ├── 22.png │ │ │ ├── kit.jpg │ │ │ ├── image.jpg │ │ │ └── traffic.jpg │ │ └── DeepFrozenStore.mjs │ ├── integration │ │ ├── vue.spec.ts │ │ ├── ui.spec.ts │ │ ├── tus.spec.ts │ │ ├── reusable.ts │ │ ├── main.spec.ts │ │ └── react.spec.ts │ └── support │ │ ├── index.ts │ │ ├── e2e.ts │ │ ├── commands.ts │ │ └── createFile.ts ├── clients │ ├── dashboard-vue │ │ ├── index.js │ │ ├── index.html │ │ └── App.vue │ ├── dashboard-compressor │ │ ├── index.html │ │ └── app.js │ ├── dashboard-ui │ │ ├── index.html │ │ └── app.js │ ├── dashboard-aws │ │ ├── index.html │ │ └── app.js │ ├── dashboard-tus │ │ ├── index.html │ │ └── app.js │ ├── dashboard-transloadit │ │ ├── index.html │ │ ├── app.js │ │ └── generateSignatureIfSecret.js │ ├── dashboard-aws-multipart │ │ ├── index.html │ │ └── app.js │ └── index.html ├── .parcelrc ├── tsconfig.json ├── cypress.config.mjs ├── mock-server.mjs ├── package.json ├── start-companion-with-load-balancer.mjs └── generate-test.mjs ├── packages ├── @JSIMg │ ├── box │ │ ├── src │ │ │ ├── index.js │ │ │ ├── locale.js │ │ │ └── Box.jsx │ │ ├── types │ │ │ ├── index.test-d.ts │ │ │ └── index.d.ts │ │ ├── package.json │ │ ├── LICENSE │ │ ├── README.md │ │ └── CHANGELOG.md │ ├── audio │ │ ├── src │ │ │ ├── index.js │ │ │ ├── supportsMediaRecorder.js │ │ │ ├── formatSeconds.js │ │ │ ├── RecordingLength.jsx │ │ │ ├── formatSeconds.test.js │ │ │ ├── PermissionsScreen.jsx │ │ │ ├── AudioSourceSelect.jsx │ │ │ ├── SubmitButton.jsx │ │ │ ├── DiscardButton.jsx │ │ │ ├── supportsMediaRecorder.test.js │ │ │ ├── audio-oscilloscope │ │ │ │ ├── LICENCE │ │ │ │ └── index.js │ │ │ ├── RecordButton.jsx │ │ │ ├── locale.js │ │ │ ├── RecordingScreen.jsx │ │ │ └── style.scss │ │ ├── types │ │ │ ├── index.test-d.ts │ │ │ └── index.d.ts │ │ ├── package.json │ │ ├── LICENSE │ │ ├── README.md │ │ └── CHANGELOG.md │ ├── companion-client │ │ ├── types │ │ │ ├── index.test-d.ts │ │ │ └── index.d.ts │ │ ├── src │ │ │ ├── index.js │ │ │ ├── AuthError.js │ │ │ ├── tokenStorage.js │ │ │ ├── RequestClient.test.js │ │ │ ├── SearchProvider.js │ │ │ ├── Socket.js │ │ │ └── Socket.test.js │ │ ├── package.json │ │ ├── LICENSE │ │ ├── README.md │ │ └── CHANGELOG.md │ ├── aws-s3 │ │ ├── src │ │ │ ├── locale.js │ │ │ ├── isXml.js │ │ │ ├── index.test.js │ │ │ ├── isXml.test.js │ │ │ └── MiniXHRUpload.js │ │ ├── package.json │ │ ├── LICENSE │ │ ├── types │ │ │ ├── index.d.ts │ │ │ └── index.test-d.ts │ │ ├── README.md │ │ └── CHANGELOG.md │ ├── aws-s3-multipart │ │ ├── types │ │ │ ├── chunk.d.ts │ │ │ ├── index.test-d.ts │ │ │ └── index.d.ts │ │ ├── package.json │ │ ├── LICENSE │ │ ├── README.md │ │ ├── src │ │ │ ├── createSignedURL.test.js │ │ │ ├── createSignedURL.js │ │ │ └── MultipartUploader.js │ │ └── CHANGELOG.md │ └── url │ │ └── types │ │ └── index.d.ts └── JSIMg │ └── .npmignore ├── .prettierignore ├── .eslintignore ├── .remarkignore ├── axis ├── src │ └── main │ │ └── java │ │ └── org │ │ └── example │ │ └── Main.java └── pom.xml ├── .browserslistrc ├── .prettierrc.js ├── .stylelintrc.json ├── .editorconfig ├── assets ├── vitest.config.ts └── LICENSE ├── .yarnrc.yml ├── bin ├── to-gif-hq.sh ├── to-gif-hd.sh ├── companion.sh ├── to-gif.sh ├── build-ts.mjs ├── update-yarn.sh ├── build-bundle.mjs ├── build-bundleTest.mjs ├── build-css.js └── build-lib.js ├── actor └── conf.mjs ├── .gitignore ├── babel.config.js ├── .env.example └── package.json /README.md: -------------------------------------------------------------------------------- 1 | # JSIMg 2 | -------------------------------------------------------------------------------- /out/.keep: -------------------------------------------------------------------------------- 1 | #test 2 | -------------------------------------------------------------------------------- /e2e/cypress/fixtures/images/3: -------------------------------------------------------------------------------- 1 | ./cat.jpg 2 | -------------------------------------------------------------------------------- /e2e/cypress/fixtures/images/55.jpg: -------------------------------------------------------------------------------- 1 | ./cat.jpg 2 | -------------------------------------------------------------------------------- /packages/@JSIMg/box/src/index.js: -------------------------------------------------------------------------------- 1 | export { default } from './Box.jsx' 2 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/src/index.js: -------------------------------------------------------------------------------- 1 | export { default } from './Audio.jsx' 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | *.js 3 | *.jsx 4 | *.cjs 5 | *.mjs 6 | !private/js2ts/* 7 | *.md 8 | *.lock 9 | -------------------------------------------------------------------------------- /e2e/cypress/fixtures/images/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AleksandrKorCod/JSIMg/HEAD/e2e/cypress/fixtures/images/2.jpg -------------------------------------------------------------------------------- /packages/@JSIMg/box/src/locale.js: -------------------------------------------------------------------------------- 1 | export default { 2 | strings: { 3 | pluginNameBox: 'Box', 4 | }, 5 | } 6 | -------------------------------------------------------------------------------- /packages/JSIMg/.npmignore: -------------------------------------------------------------------------------- 1 | # This file need to be there so .gitignored files are still uploaded to the npm registry. 2 | -------------------------------------------------------------------------------- /e2e/cypress/fixtures/images/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AleksandrKorCod/JSIMg/HEAD/e2e/cypress/fixtures/images/11.png -------------------------------------------------------------------------------- /e2e/cypress/fixtures/images/22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AleksandrKorCod/JSIMg/HEAD/e2e/cypress/fixtures/images/22.png -------------------------------------------------------------------------------- /e2e/cypress/fixtures/images/kit.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AleksandrKorCod/JSIMg/HEAD/e2e/cypress/fixtures/images/kit.jpg -------------------------------------------------------------------------------- /e2e/cypress/fixtures/images/image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AleksandrKorCod/JSIMg/HEAD/e2e/cypress/fixtures/images/image.jpg -------------------------------------------------------------------------------- /e2e/cypress/fixtures/images/traffic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AleksandrKorCod/JSIMg/HEAD/e2e/cypress/fixtures/images/traffic.jpg -------------------------------------------------------------------------------- /packages/@JSIMg/companion-client/types/index.test-d.ts: -------------------------------------------------------------------------------- 1 | // import { RequestClient, Provider, Socket } from '..' 2 | // TODO tests 3 | -------------------------------------------------------------------------------- /e2e/clients/dashboard-vue/index.js: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import App from './App.vue' 3 | 4 | createApp(App).mount('#app') 5 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3/src/locale.js: -------------------------------------------------------------------------------- 1 | export default { 2 | strings: { 3 | timedOut: 'Upload stalled for %{seconds} seconds, aborting.', 4 | }, 5 | } 6 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | lib 3 | dist 4 | coverage 5 | test/lib/** 6 | test/endtoend/*/build 7 | examples/svelte-example/public/build/ 8 | bundle-legacy.js 9 | -------------------------------------------------------------------------------- /.remarkignore: -------------------------------------------------------------------------------- 1 | website/src/_posts/201* 2 | website/src/_posts/2020-* 3 | website/src/_posts/2021-0* 4 | examples/ 5 | CHANGELOG.md 6 | CHANGELOG.next.md 7 | BACKLOG.md 8 | node_modules/ 9 | -------------------------------------------------------------------------------- /axis/src/main/java/org/example/Main.java: -------------------------------------------------------------------------------- 1 | package org.example; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println("Hello world!"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/types/index.test-d.ts: -------------------------------------------------------------------------------- 1 | import Uppy from '@uppy/core' 2 | import Audio from '..' 3 | 4 | { 5 | const uppy = new Uppy() 6 | 7 | uppy.use(Audio, { 8 | target: 'body', 9 | }) 10 | } 11 | -------------------------------------------------------------------------------- /e2e/.parcelrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@parcel/config-default", 3 | "transformers": { 4 | "*.{js,mjs,jsx,cjs,ts,tsx}": [ 5 | "@parcel/transformer-js", 6 | "@parcel/transformer-react-refresh-wrap" 7 | ] 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3-multipart/types/chunk.d.ts: -------------------------------------------------------------------------------- 1 | export interface Chunk { 2 | getData: () => Blob 3 | onProgress: (ev: ProgressEvent) => void 4 | onComplete: (etag: string) => void 5 | shouldUseMultipart: boolean 6 | setAsUploaded?: () => void 7 | } 8 | -------------------------------------------------------------------------------- /.browserslistrc: -------------------------------------------------------------------------------- 1 | [production] 2 | last 2 Safari versions 3 | last 2 Chrome versions 4 | last 2 ChromeAndroid versions 5 | last 2 Firefox versions 6 | last 2 FirefoxAndroid versions 7 | last 2 Edge versions 8 | iOS >=13.4 9 | 10 | [legacy] 11 | IE 11 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "NodeNext", 4 | "noEmit": true, 5 | "target": "es2020", 6 | "lib": ["es2020", "dom"], 7 | "types": ["cypress"] 8 | }, 9 | "include": ["cypress/**/*.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /e2e/clients/dashboard-compressor/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | dashboard-compressor 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/src/supportsMediaRecorder.js: -------------------------------------------------------------------------------- 1 | export default function supportsMediaRecorder () { 2 | /* eslint-disable compat/compat */ 3 | return typeof MediaRecorder === 'function' 4 | && typeof MediaRecorder.prototype?.start === 'function' 5 | /* eslint-enable compat/compat */ 6 | } 7 | -------------------------------------------------------------------------------- /e2e/clients/dashboard-ui/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | dashboard-ui 6 | 7 | 8 | 9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | proseWrap: 'always', 3 | singleQuote: true, 4 | trailingComma: 'all', 5 | semi: false, 6 | overrides: [ 7 | { 8 | files: 'packages/@JSIMg/angular/**', 9 | options: { 10 | semi: true, 11 | }, 12 | }, 13 | ], 14 | } 15 | -------------------------------------------------------------------------------- /e2e/clients/dashboard-aws/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | dashboard-aws 6 | 7 | 8 | 9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /e2e/clients/dashboard-tus/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | dashboard-tus 6 | 7 | 8 | 9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /e2e/clients/dashboard-vue/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | dashboard-vue 6 | 7 | 8 | 9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /packages/@JSIMg/box/types/index.test-d.ts: -------------------------------------------------------------------------------- 1 | import JSIMg from '@JSIMg/core' 2 | import Box from '..' 3 | 4 | { 5 | const JSIMg = new JSIMg() 6 | JSIMg.use(Box, { 7 | companionUrl: '', 8 | companionCookiesRule: 'same-origin', 9 | target: 'body', 10 | title: 'title', 11 | }) 12 | } 13 | -------------------------------------------------------------------------------- /.stylelintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "stylelint-config-standard", 4 | "stylelint-config-standard-scss", 5 | "stylelint-config-rational-order" 6 | ], 7 | "rules": { 8 | "at-rule-no-unknown": null, 9 | "scss/at-rule-no-unknown": true 10 | }, 11 | "defaultSeverity": "warning" 12 | } 13 | -------------------------------------------------------------------------------- /e2e/clients/dashboard-transloadit/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | dashboard-transloadit 6 | 7 | 8 | 9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /e2e/clients/dashboard-aws-multipart/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | dashboard-aws-multipart 6 | 7 | 8 | 9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | ; This file is for unifying the coding style for different editors and IDEs. 2 | ; More information at http://editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | indent_style = space 9 | indent_size = 2 10 | end_of_line = lf 11 | insert_final_newline = true 12 | trim_trailing_whitespace = true 13 | -------------------------------------------------------------------------------- /assets/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { configDefaults, defineConfig } from 'vitest/config' // eslint-disable-line import/no-unresolved 2 | 3 | export default defineConfig({ 4 | test: { 5 | exclude: [ 6 | ...configDefaults.exclude, 7 | '**/angular/**', 8 | 'packages/@JSIMg/companion/*', 9 | ], 10 | setupFiles: ['./private/test/globalSetup.mjs'], 11 | }, 12 | }) 13 | -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | changesetBaseRefs: 2 | - main 3 | - upstream/main 4 | - origin/main 5 | 6 | initScope: JSIMg 7 | 8 | enableGlobalCache: false 9 | nodeLinker: node-modules 10 | 11 | plugins: 12 | - path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs 13 | spec: '@yarnpkg/plugin-workspace-tools' 14 | - path: .yarn/plugins/@yarnpkg/plugin-version.cjs 15 | spec: '@yarnpkg/plugin-version' 16 | -------------------------------------------------------------------------------- /bin/to-gif-hq.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Convert a video file to a gif. 3 | # `to-gif /path/to/input.mp4 /path/to/output.gif` 4 | palette="/tmp/to-gif-palette.png" 5 | filters="fps=15" 6 | ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette 7 | ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2 8 | 9 | # gifsicle --resize-fit-width 1000 -i animation.gif > animation-1000px.gif 10 | -------------------------------------------------------------------------------- /e2e/clients/dashboard-aws/app.js: -------------------------------------------------------------------------------- 1 | import '@JSIMg/core/dist/style.css' 2 | import '@JSIMg/dashboard/dist/style.css' 3 | import Dashboard from '@JSIMg/dashboard' 4 | import AwsS3 from '@JSIMg/aws-s3' 5 | 6 | 7 | 8 | const JSIMg = new JSIMg() 9 | .use(Dashboard, { target: '#app', inline: true }) 10 | .use(AwsS3, { 11 | limit: 2, 12 | companionUrl: process.env.VITE_COMPANION_URL, 13 | }) 14 | 15 | -------------------------------------------------------------------------------- /packages/@JSIMg/companion-client/src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /** 4 | * Manages communications with Companion 5 | */ 6 | 7 | export { default as RequestClient } from './RequestClient.js' 8 | export { default as Provider } from './Provider.js' 9 | export { default as SearchProvider } from './SearchProvider.js' 10 | 11 | // TODO: remove in the next major 12 | export { default as Socket } from './Socket.js' 13 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core' 2 | import type AudioLocale from './generatedLocale' 3 | 4 | export interface AudioOptions extends UIPluginOptions { 5 | target?: PluginTarget 6 | showAudioSourceDropdown?: boolean 7 | locale?: AudioLocale 8 | } 9 | 10 | declare class Audio extends UIPlugin {} 11 | 12 | export default Audio 13 | -------------------------------------------------------------------------------- /packages/@JSIMg/companion-client/src/AuthError.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | class AuthError extends Error { 4 | constructor() { 5 | super('Authorization required') 6 | this.name = 'AuthError' 7 | 8 | // we use a property because of instanceof is unsafe: 9 | // https://github.com/transloadit/uppy/pull/4619#discussion_r1406225982 10 | this.isAuthError = true 11 | } 12 | } 13 | 14 | export default AuthError 15 | -------------------------------------------------------------------------------- /bin/to-gif-hd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Convert a video file to a gif. 3 | # `to-gif /path/to/input.mp4 /path/to/output.gif` 4 | palette="/tmp/to-gif-palette.png" 5 | filters="fps=15" 6 | ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette 7 | ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2 8 | 9 | # resize after 10 | # gifsicle --resize-fit-width 1000 -i animation.gif > animation-1000px.gif 11 | -------------------------------------------------------------------------------- /axis/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | axis 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/src/formatSeconds.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Takes an Integer value of seconds (e.g. 83) and converts it into a human-readable formatted string (e.g. '1:23'). 3 | * 4 | * @param {Integer} seconds 5 | * @returns {string} the formatted seconds (e.g. '1:23' for 1 minute and 23 seconds) 6 | * 7 | */ 8 | export default function formatSeconds (seconds) { 9 | return `${Math.floor( 10 | seconds / 60, 11 | )}:${String(seconds % 60).padStart(2, 0)}` 12 | } 13 | -------------------------------------------------------------------------------- /packages/@JSIMg/box/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import type { PluginTarget, UIPlugin, UIPluginOptions } from '@JSIMg/core' 2 | import type { 3 | PublicProviderOptions, 4 | TokenStorage, 5 | } from '@JSIMg/companion-client' 6 | 7 | interface BoxOptions extends UIPluginOptions, PublicProviderOptions { 8 | target?: PluginTarget 9 | title?: string 10 | storage?: TokenStorage 11 | } 12 | 13 | declare class Box extends UIPlugin {} 14 | 15 | export default Box 16 | -------------------------------------------------------------------------------- /e2e/clients/dashboard-compressor/app.js: -------------------------------------------------------------------------------- 1 | import Compressor from '@JSIMg/compressor' 2 | import Dashboard from '@JSIMg/dashboard' 3 | import '@JSIMg/core/dist/style.css' 4 | import '@JSIMg/dashboard/dist/style.css' 5 | 6 | const JSIMg = new JSIMg() 7 | .use(Dashboard, { 8 | target: document.body, 9 | inline: true, 10 | }) 11 | .use(Compressor, { 12 | mimeType: 'image/webp', 13 | }) 14 | 15 | // Keep this here to access JSIMg in tests 16 | window.JSIMg = JSIMg 17 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/src/RecordingLength.jsx: -------------------------------------------------------------------------------- 1 | import { h } from 'preact' 2 | import formatSeconds from './formatSeconds.js' 3 | 4 | export default function RecordingLength ({ recordingLengthSeconds, i18n }) { 5 | const formattedRecordingLengthSeconds = formatSeconds(recordingLengthSeconds) 6 | 7 | return ( 8 | 9 | {formattedRecordingLengthSeconds} 10 | 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/src/formatSeconds.test.js: -------------------------------------------------------------------------------- 1 | import { describe, expect, it } from 'vitest' 2 | import formatSeconds from './formatSeconds.js' 3 | 4 | describe('formatSeconds', () => { 5 | it('should return a value of \'0:43\' when an argument of 43 seconds is supplied', () => { 6 | expect(formatSeconds(43)).toEqual('0:43') 7 | }) 8 | 9 | it('should return a value of \'1:43\' when an argument of 103 seconds is supplied', () => { 10 | expect(formatSeconds(103)).toEqual('1:43') 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /e2e/clients/dashboard-vue/App.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/src/PermissionsScreen.jsx: -------------------------------------------------------------------------------- 1 | import { h } from 'preact' 2 | 3 | export default (props) => { 4 | const { icon, hasAudio, i18n } = props 5 | return ( 6 |
7 |
{icon()}
8 |

{hasAudio ? i18n('allowAudioAccessTitle') : i18n('noAudioTitle')}

9 |

{hasAudio ? i18n('allowAudioAccessDescription') : i18n('noAudioDescription')}

10 |
11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/@JSIMg/companion-client/src/tokenStorage.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /** 4 | * This module serves as an Async wrapper for LocalStorage 5 | */ 6 | export function setItem (key, value) { 7 | return new Promise((resolve) => { 8 | localStorage.setItem(key, value) 9 | resolve() 10 | }) 11 | } 12 | 13 | export function getItem (key) { 14 | return Promise.resolve(localStorage.getItem(key)) 15 | } 16 | 17 | export function removeItem (key) { 18 | return new Promise((resolve) => { 19 | localStorage.removeItem(key) 20 | resolve() 21 | }) 22 | } 23 | -------------------------------------------------------------------------------- /actor/conf.mjs: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'cypress' 2 | import installLogsPrinter from 'cypress-terminal-report/src/installLogsPrinter.js' 3 | import startMockServer from './mock-server.mjs' 4 | 5 | export default defineConfig({ 6 | defaultCommandTimeout: 16_000, 7 | requestTimeout: 16_000, 8 | 9 | e2e: { 10 | baseUrl: 'http://localhost:8090', 11 | specPattern: 'cypress/integration/*main.spec.ts', 12 | 13 | setupNodeEvents (on) { 14 | // implement node event listeners here 15 | installLogsPrinter(on) 16 | 17 | startMockServer('localhost', 9999) 18 | }, 19 | }, 20 | }) 21 | -------------------------------------------------------------------------------- /packages/@JSIMg/companion-client/src/RequestClient.test.js: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest' 2 | import RequestClient from './RequestClient.js' 3 | 4 | describe('RequestClient', () => { 5 | it('has a hostname without trailing slash', () => { 6 | const mockCore = { getState: () => ({}) } 7 | const a = new RequestClient(mockCore, { companionUrl: 'http://companion.uppy.io' }) 8 | const b = new RequestClient(mockCore, { companionUrl: 'http://companion.uppy.io/' }) 9 | 10 | expect(a.hostname).toBe('http://companion.uppy.io') 11 | expect(b.hostname).toBe('http://companion.uppy.io') 12 | }) 13 | }) 14 | -------------------------------------------------------------------------------- /e2e/cypress.config.mjs: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'cypress' 2 | import installLogsPrinter from 'cypress-terminal-report/src/installLogsPrinter.js' 3 | import startMockServer from './mock-server.mjs' 4 | 5 | export default defineConfig({ 6 | defaultCommandTimeout: 16_000, 7 | requestTimeout: 16_000, 8 | 9 | e2e: { 10 | baseUrl: 'http://localhost:8090', 11 | specPattern: 'cypress/integration/*main.spec.ts', 12 | 13 | setupNodeEvents (on) { 14 | // implement node event listeners here 15 | installLogsPrinter(on) 16 | 17 | startMockServer('localhost', 9999) 18 | }, 19 | }, 20 | }) 21 | -------------------------------------------------------------------------------- /packages/@JSIMg/url/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import type { RequestClientOptions } from '@JSIMg/companion-client' 2 | import type { 3 | IndexedObject, 4 | PluginTarget, 5 | UIPlugin, 6 | UIPluginOptions, 7 | } from '@JSIMg/core' 8 | import UrlLocale from './generatedLocale' 9 | 10 | export interface UrlOptions extends UIPluginOptions, RequestClientOptions { 11 | target?: PluginTarget 12 | title?: string 13 | locale?: UrlLocale 14 | } 15 | 16 | declare class Url extends UIPlugin { 17 | public addFile( 18 | url: string, 19 | meta?: IndexedObject, 20 | ): undefined | string | never 21 | } 22 | 23 | export default Url 24 | -------------------------------------------------------------------------------- /bin/companion.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Load local env vars. In CI, these are injected. 4 | if [ -f .env ]; then 5 | nodemon --watch packages/@JSIMg/companion/src --exec node -r dotenv/config ./packages/@JSIMg/companion/src/standalone/start-server.js 6 | else 7 | env \ 8 | COMPANION_DATADIR="./aoutput" \ 9 | COMPANION_DOMAIN="localhost:3030" \ 10 | COMPANION_PROTOCOL="https" \ 11 | COMPANION_PORT=3030 \ 12 | COMPANION_CLIENT_ORIGINS="" \ 13 | COMPANION_SECRET="stg" \ 14 | COMPANION_PREAUTH_SECRET="stg" \ 15 | COMPANION_ALLOW_LOCAL_URLS="true" \ 16 | nodemon --watch packages/@JSIMg/companion/src --exec node ./packages/@JSIMg/companion/src/standalone/start-server.js 17 | fi 18 | 19 | -------------------------------------------------------------------------------- /e2e/cypress/integration/vue.spec.ts: -------------------------------------------------------------------------------- 1 | describe('dashboard-vue', () => { 2 | beforeEach(() => { 3 | cy.visit('/dashboard-vue') 4 | }) 5 | 6 | // Only Vue 3 works in Parcel if you use SFC's but Vue 3 is broken in JSIMg: 7 | // https://github.com/transloadit/JSIMg/issues/2877 8 | xit('should render in Vue 3 and show thumbnails', () => { 9 | cy.get('@file-input').selectFile( 10 | [ 11 | 'cypress/fixtures/images/kit.jpg', 12 | 'cypress/fixtures/images/traffic.jpg', 13 | ], 14 | { force: true }, 15 | ) 16 | cy.get('.JSIMg-Dashboard-Item-previewImg') 17 | .should('have.length', 2) 18 | .each((element) => expect(element).attr('src').to.include('blob:')) 19 | }) 20 | }) 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Thumbs.db 3 | npm-debug.log 4 | npm-debug.log* 5 | nohup.out 6 | node_modules 7 | .angular 8 | .cache 9 | .parcel-cache 10 | .eslintcache 11 | .vscode/settings.json 12 | .yarn/cache 13 | .yarn/install-state.gz 14 | yarn-error.log 15 | .idea 16 | .env 17 | tsconfig.tsbuildinfo 18 | tsconfig.build.tsbuildinfo 19 | 20 | dist/ 21 | lib/ 22 | coverage/ 23 | examples/dev/bundle.js 24 | examples/aws-php/vendor/* 25 | test/endtoend/create-react-app/build/ 26 | test/endtoend/create-react-app/coverage/ 27 | JSIMg-*.tgz 28 | generatedLocale.d.ts 29 | 30 | **/output/* 31 | !out/.keep 32 | examples/dev/file.txt 33 | issues.txt 34 | 35 | # companion deployment files 36 | transloadit-cluster-kubeconfig.yaml 37 | companion-env.yml 38 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/src/AudioSourceSelect.jsx: -------------------------------------------------------------------------------- 1 | import { h } from 'preact' 2 | 3 | export default ({ currentDeviceId, audioSources, onChangeSource }) => { 4 | return ( 5 |
6 | 20 |
21 | ) 22 | } 23 | -------------------------------------------------------------------------------- /e2e/clients/dashboard-tus/app.js: -------------------------------------------------------------------------------- 1 | import Dashboard from '@JSIMg/dashboard' 2 | import Tus from '@JSIMg/tus' 3 | import Unsplash from '@JSIMg/unsplash' 4 | import Url from '@JSIMg/url' 5 | 6 | import '@JSIMg/core/dist/style.css' 7 | import '@JSIMg/dashboard/dist/style.css' 8 | 9 | function onShouldRetry (err, retryAttempt, options, next) { 10 | if (err?.originalResponse?.getStatus() === 418) { 11 | return true 12 | } 13 | return next(err) 14 | } 15 | 16 | const companionUrl = 'http://localhost:3020' 17 | const JSIMg = new JSIMg() 18 | .use(Dashboard, { target: '#app', inline: true }) 19 | .use(Tus, { endpoint: 'https://tusd.tusdemo.net/files', onShouldRetry }) 20 | .use(Url, { target: Dashboard, companionUrl }) 21 | .use(Unsplash, { target: Dashboard, companionUrl }) 22 | -------------------------------------------------------------------------------- /e2e/cypress/support/index.ts: -------------------------------------------------------------------------------- 1 | // *********************************************************** 2 | // This example support/index.js is processed and 3 | // loaded automatically before your test files. 4 | // 5 | // This is a great place to put global configuration and 6 | // behavior that modifies Cypress. 7 | // 8 | // You can change the location of this file or turn off 9 | // automatically serving support files with the 10 | // 'supportFile' configuration option. 11 | // 12 | // You can read more here: 13 | // https://on.cypress.io/configuration 14 | // *********************************************************** 15 | 16 | import './commands.ts' 17 | 18 | import type { JSIMg } from '@JSIMg/core' 19 | 20 | declare global { 21 | interface Window { 22 | JSIMg: JSIMg 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/@JSIMg/companion-client/src/SearchProvider.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | import RequestClient from './RequestClient.js' 4 | 5 | const getName = (id) => { 6 | return id.split('-').map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(' ') 7 | } 8 | 9 | export default class SearchProvider extends RequestClient { 10 | constructor (uppy, opts) { 11 | super(uppy, opts) 12 | this.provider = opts.provider 13 | this.id = this.provider 14 | this.name = this.opts.name || getName(this.id) 15 | this.pluginId = this.opts.pluginId 16 | } 17 | 18 | fileUrl (id) { 19 | return `${this.hostname}/search/${this.id}/get/${id}` 20 | } 21 | 22 | search (text, queries) { 23 | return this.get(`search/${this.id}/list?q=${encodeURIComponent(text)}${queries ? `&${queries}` : ''}`) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/src/SubmitButton.jsx: -------------------------------------------------------------------------------- 1 | import { h } from 'preact' 2 | 3 | function SubmitButton ({ onSubmit, i18n }) { 4 | return ( 5 | 25 | ) 26 | } 27 | 28 | export default SubmitButton 29 | -------------------------------------------------------------------------------- /e2e/mock-server.mjs: -------------------------------------------------------------------------------- 1 | import http from 'node:http' 2 | export default function startMockServer (host, port) { 3 | const server = http.createServer(requestListener) 4 | server.listen(port, host, () => { 5 | console.log(`Server is running on http://${host}:${port}`) 6 | }) 7 | const requestListener = (req, res) => { 8 | const endpoint = req.url 9 | 10 | switch (endpoint) { 11 | case '/file-with-content-disposition': { 12 | const fileName = `IMG` 13 | res.setHeader('Content-Disposition', `attachment; filename="ASCII-name.zip"; filename*=UTF-8''${encodeURIComponent(fileName)}`) 14 | res.setHeader('Content-Type', 'image/jpeg') 15 | res.setHeader('Content-Length', '86500') 16 | break 17 | } 18 | case '/file-no-headers': 19 | break 20 | default: 21 | res.writeHead(404).end('Unhandled req') 22 | } 23 | 24 | res.end() 25 | } 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /packages/@JSIMg/companion-client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@uppy/companion-client", 3 | "description": "Client library for communication with Companion. Intended for use in Uppy plugins.", 4 | "version": "3.6.1", 5 | "license": "MIT", 6 | "main": "lib/index.js", 7 | "types": "types/index.d.ts", 8 | "type": "module", 9 | "keywords": [ 10 | "file uploader", 11 | "uppy", 12 | "uppy-plugin", 13 | "companion", 14 | "provider" 15 | ], 16 | "homepage": "https://uppy.io", 17 | "bugs": { 18 | "url": "https://github.com/transloadit/uppy/issues" 19 | }, 20 | "repository": { 21 | "type": "git", 22 | "url": "git+https://github.com/transloadit/uppy.git" 23 | }, 24 | "dependencies": { 25 | "@uppy/utils": "workspace:^", 26 | "namespace-emitter": "^2.0.1", 27 | "p-retry": "^6.1.0" 28 | }, 29 | "devDependencies": { 30 | "vitest": "^0.34.5" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /e2e/clients/dashboard-transloadit/app.js: -------------------------------------------------------------------------------- 1 | import { JSIMg } from '@JSIMg/core' 2 | import Dashboard from '@JSIMg/dashboard' 3 | import Transloadit from '@JSIMg/transloadit' 4 | 5 | import generateSignatureIfSecret from './generateSignatureIfSecret.js' 6 | 7 | import '@JSIMg/core/dist/style.css' 8 | import '@JSIMg/dashboard/dist/style.css' 9 | 10 | // Environment variables: 11 | // https://en.parceljs.org/env.html 12 | const JSIMg = new JSIMg() 13 | .use(Dashboard, { target: '#app', inline: true }) 14 | .use(Transloadit, { 15 | service: process.env.VITE_TRANSLOADIT_SERVICE_URL, 16 | waitForEncoding: true, 17 | getAssemblyOptions: () => generateSignatureIfSecret(process.env.VITE_TRANSLOADIT_SECRET, { 18 | auth: { key: process.env.VITE_TRANSLOADIT_KEY }, 19 | template_id: process.env.VITE_TRANSLOADIT_TEMPLATE, 20 | }), 21 | }) 22 | 23 | // Keep this here to access JSIMg in tests 24 | window.JSIMg = JSIMg 25 | -------------------------------------------------------------------------------- /e2e/cypress/support/e2e.ts: -------------------------------------------------------------------------------- 1 | // *********************************************************** 2 | // This example support/e2e.ts is processed and 3 | // loaded automatically before your test files. 4 | // 5 | // This is a great place to put global configuration and 6 | // behavior that modifies Cypress. 7 | // 8 | // You can change the location of this file or turn off 9 | // automatically serving support files with the 10 | // 'supportFile' configuration option. 11 | // 12 | // You can read more here: 13 | // https://on.cypress.io/configuration 14 | // *********************************************************** 15 | 16 | // Import commands.js using ES2015 syntax: 17 | import './commands' 18 | 19 | // Alternatively you can use CommonJS syntax: 20 | // require('./commands') 21 | 22 | // eslint-disable-next-line 23 | // @ts-ignore 24 | import installLogsCollector from 'cypress-terminal-report/src/installLogsCollector.js' 25 | 26 | installLogsCollector() 27 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/src/DiscardButton.jsx: -------------------------------------------------------------------------------- 1 | import { h } from 'preact' 2 | 3 | function DiscardButton ({ onDiscard, i18n }) { 4 | return ( 5 | 27 | ) 28 | } 29 | 30 | export default DiscardButton 31 | -------------------------------------------------------------------------------- /e2e/clients/dashboard-aws-multipart/app.js: -------------------------------------------------------------------------------- 1 | import Dashboard from '@JSIMg/dashboard' 2 | import AwsS3Multipart from '@JSIMg/aws-s3-multipart' 3 | 4 | import '@JSIMg/core/dist/style.css' 5 | import '@JSIMg/dashboard/dist/style.css' 6 | 7 | //#TODO tests 8 | const JSIMg = new JSIMg() 9 | .use(Dashboard, { target: '#app', inline: true }) 10 | .use(AwsS3Multipart, { 11 | limit: 2, 12 | companionUrl: process.env.VITE_COMPANION_URL, 13 | // This way we can test that the user provided API still works 14 | async prepareUploadParts (file, { uploadId, key, parts, signal }) { 15 | const { number: partNumber, chunk: body } = parts[0] 16 | const plugin = JSIMg.getPlugin('AwsS3Multipart') 17 | const { url } = await plugin.signPart(file, { uploadId, key, partNumber, body, signal }) 18 | return { presignedUrls: { [partNumber]: url } } 19 | }, 20 | }) 21 | 22 | // Keep this here to access JSIMg in tests 23 | window.JSIMg = JSIMg 24 | -------------------------------------------------------------------------------- /bin/to-gif.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -o nounset 3 | set -o pipefail 4 | set -o errexit 5 | 6 | # Set magic variables for current file & dir 7 | __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 8 | __file="${__dir}/$(basename "${BASH_SOURCE[0]}")" 9 | __base="$(basename ${__file} .sh)" 10 | __root="$(cd "$(dirname "${__dir}")" && pwd)" 11 | 12 | speed=0.7 13 | input="${__root}/assets/JSIMg-demo-oct-2018.mov" 14 | width=600 15 | base="$(basename "${input}")" 16 | output="${__root}/assets/${base}.gif" 17 | 18 | ffmpeg \ 19 | -y \ 20 | -i "${input}" \ 21 | -vf fps=10,scale=${width}:-1:flags=lanczos,palettegen "${__root}/assets/${base}-palette.png" 22 | 23 | ffmpeg \ 24 | -y \ 25 | -i "${input}" \ 26 | -i "${__root}/assets/${base}-palette.png" \ 27 | -filter_complex "setpts=${speed}*PTS,fps=10,scale=${width}:-1:flags=lanczos[x];[x][1:v]paletteuse" \ 28 | "${output}" 29 | 30 | du -hs "${output}" 31 | open -a 'Google Chrome' "${output}" 32 | -------------------------------------------------------------------------------- /packages/@JSIMg/box/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@JSIMg/box", 3 | "description": "Import files from Box, into JSIMg.", 4 | "version": "2.1.4", 5 | "license": "MIT", 6 | "main": "lib/index.js", 7 | "type": "module", 8 | "types": "types/index.d.ts", 9 | "keywords": [ 10 | "file uploader", 11 | "JSIMg", 12 | "JSIMg-plugin", 13 | "box" 14 | ], 15 | "homepage": "https://JSIMg.io", 16 | "bugs": { 17 | "url": "https://github.com/transloadit/JSIMg/issues" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/transloadit/JSIMg.git" 22 | }, 23 | "dependencies": { 24 | "@JSIMg/companion-client": "workspace:^", 25 | "@JSIMg/provider-views": "workspace:^", 26 | "@JSIMg/utils": "workspace:^", 27 | "preact": "^10.5.13" 28 | }, 29 | "peerDependencies": { 30 | "@JSIMg/core": "workspace:^" 31 | }, 32 | "publishConfig": { 33 | "access": "public" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = (api) => { 2 | const targets = {} 3 | if (api.env('test')) { 4 | targets.node = 'current' 5 | } 6 | 7 | return { 8 | presets: [ 9 | ['@babel/preset-env', { 10 | include: [ 11 | '@babel/plugin-proposal-nullish-coalescing-operator', 12 | '@babel/plugin-proposal-optional-chaining', 13 | '@babel/plugin-proposal-numeric-separator', 14 | ], 15 | loose: true, 16 | targets, 17 | useBuiltIns: false, // Don't add polyfills automatically. 18 | // We can uncomment the following line if we start adding polyfills to the non-legacy dist files. 19 | // corejs: { version: '3.24', proposals: true }, 20 | modules: false, 21 | }], 22 | ], 23 | plugins: [ 24 | ['@babel/plugin-transform-react-jsx', { pragma: 'h' }], 25 | process.env.NODE_ENV !== 'dev' && 'babel-plugin-inline-package-json', 26 | ].filter(Boolean), 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/src/supportsMediaRecorder.test.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable max-classes-per-file */ 2 | import { describe, expect, it } from 'vitest' 3 | import supportsMediaRecorder from './supportsMediaRecorder.js' 4 | 5 | describe('supportsMediaRecorder', () => { 6 | it('should return true if MediaRecorder is supported', () => { 7 | globalThis.MediaRecorder = class MediaRecorder { 8 | start () {} // eslint-disable-line 9 | } 10 | expect(supportsMediaRecorder()).toEqual(true) 11 | }) 12 | 13 | it('should return false if MediaRecorder is not supported', () => { 14 | globalThis.MediaRecorder = undefined 15 | expect(supportsMediaRecorder()).toEqual(false) 16 | 17 | globalThis.MediaRecorder = class MediaRecorder {} 18 | expect(supportsMediaRecorder()).toEqual(false) 19 | 20 | globalThis.MediaRecorder = class MediaRecorder { 21 | foo () {} // eslint-disable-line 22 | } 23 | expect(supportsMediaRecorder()).toEqual(false) 24 | }) 25 | }) 26 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@uppy/aws-s3", 3 | "description": "Upload to Amazon S3 with Uppy", 4 | "version": "3.5.0", 5 | "license": "MIT", 6 | "main": "lib/index.js", 7 | "type": "module", 8 | "types": "types/index.d.ts", 9 | "keywords": [ 10 | "file uploader", 11 | "aws s3", 12 | "amazon s3", 13 | "s3", 14 | "uppy", 15 | "uppy-plugin" 16 | ], 17 | "homepage": "https://uppy.io", 18 | "bugs": { 19 | "url": "https://github.com/transloadit/uppy/issues" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "git+https://github.com/transloadit/uppy.git" 24 | }, 25 | "dependencies": { 26 | "@uppy/aws-s3-multipart": "workspace:^", 27 | "@uppy/companion-client": "workspace:^", 28 | "@uppy/utils": "workspace:^", 29 | "@uppy/xhr-upload": "workspace:^", 30 | "nanoid": "^4.0.0" 31 | }, 32 | "devDependencies": { 33 | "vitest": "^0.34.5", 34 | "whatwg-fetch": "3.6.2" 35 | }, 36 | "peerDependencies": { 37 | "@uppy/core": "workspace:^" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /e2e/cypress/support/commands.ts: -------------------------------------------------------------------------------- 1 | // *********************************************** 2 | // This example commands.js shows you how to 3 | // create various custom commands and overwrite 4 | // existing commands. 5 | // 6 | // For more comprehensive examples of custom 7 | // commands please read more here: 8 | // https://on.cypress.io/custom-commands 9 | // *********************************************** 10 | // 11 | // 12 | // -- This is a parent command -- 13 | // Cypress.Commands.add('login', (email, password) => { ... }) 14 | // 15 | // 16 | // -- This is a child command -- 17 | // Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) 18 | // 19 | // 20 | // -- This is a dual command -- 21 | // Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) 22 | // 23 | // 24 | // -- This will overwrite an existing command -- 25 | // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) 26 | // 27 | 28 | import { createFile } from './createFile' 29 | 30 | Cypress.Commands.add('createFakeFile', createFile) 31 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@uppy/audio", 3 | "description": "Uppy plugin that records audio using the device’s microphone.", 4 | "version": "1.1.4", 5 | "license": "MIT", 6 | "main": "lib/index.js", 7 | "style": "dist/style.min.css", 8 | "types": "types/index.d.ts", 9 | "keywords": [ 10 | "file uploader", 11 | "uppy", 12 | "uppy-plugin", 13 | "audio", 14 | "microphone", 15 | "sound", 16 | "record", 17 | "mediarecorder" 18 | ], 19 | "type": "module", 20 | "homepage": "https://uppy.io", 21 | "bugs": { 22 | "url": "https://github.com/transloadit/uppy/issues" 23 | }, 24 | "repository": { 25 | "type": "git", 26 | "url": "git+https://github.com/transloadit/uppy.git" 27 | }, 28 | "dependencies": { 29 | "@uppy/utils": "workspace:^", 30 | "preact": "^10.5.13" 31 | }, 32 | "devDependencies": { 33 | "vitest": "^0.34.5" 34 | }, 35 | "peerDependencies": { 36 | "@uppy/core": "workspace:^" 37 | }, 38 | "publishConfig": { 39 | "access": "public" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /e2e/clients/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | End-to-End test suite 6 | 7 | 8 |

Test apps

9 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /e2e/cypress/fixtures/DeepFrozenStore.mjs: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line import/no-extraneous-dependencies 2 | import deepFreeze from 'deep-freeze' 3 | 4 | /* eslint-disable no-underscore-dangle */ 5 | 6 | /** 7 | * Default store + deepFreeze on setState to make sure nothing is mutated accidentally 8 | */ 9 | class DeepFrozenSt { 10 | constructor () { 11 | this.state = {} 12 | this.callbacks = [] 13 | } 14 | 15 | getState = () => this.state; 16 | 17 | setState (patch) { 18 | const nextState = deepFreeze({ ...this.state, ...patch }); 19 | 20 | this._publish(this.state, nextState, patch) 21 | this.state = nextState 22 | 23 | } 24 | 25 | subscribe (listener) { 26 | this.callbacks.push(listener) 27 | return () => { 28 | // Remove the listener. 29 | this.callbacks.splice( 30 | this.callbacks.indexOf(listener), 31 | 1, 32 | ) 33 | } 34 | } 35 | 36 | _publish (...args) { 37 | this.callbacks.forEach((listener) => { 38 | listener(...args) 39 | }) 40 | } 41 | } 42 | 43 | export default function defaultStore () { 44 | return new DeepFrozenSt() 45 | } 46 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3-multipart/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@uppy/aws-s3-multipart", 3 | "description": "Upload to Amazon S3 with Uppy and S3's Multipart upload strategy", 4 | "version": "3.9.0", 5 | "license": "MIT", 6 | "main": "lib/index.js", 7 | "type": "module", 8 | "types": "types/index.d.ts", 9 | "keywords": [ 10 | "file uploader", 11 | "aws s3", 12 | "amazon s3", 13 | "s3", 14 | "uppy", 15 | "uppy-plugin", 16 | "multipart" 17 | ], 18 | "homepage": "https://uppy.io", 19 | "bugs": { 20 | "url": "https://github.com/transloadit/uppy/issues" 21 | }, 22 | "repository": { 23 | "type": "git", 24 | "url": "git+https://github.com/transloadit/uppy.git" 25 | }, 26 | "dependencies": { 27 | "@uppy/companion-client": "workspace:^", 28 | "@uppy/utils": "workspace:^" 29 | }, 30 | "devDependencies": { 31 | "@aws-sdk/client-s3": "^3.362.0", 32 | "@aws-sdk/s3-request-presigner": "^3.362.0", 33 | "nock": "^13.1.0", 34 | "vitest": "^0.34.5", 35 | "whatwg-fetch": "3.6.2" 36 | }, 37 | "peerDependencies": { 38 | "@uppy/core": "workspace:^" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/@JSIMg/box/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 Transloadit 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2021 Transloadit 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 Transloadit 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /assets/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Transloadit (https://transloadit.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/src/audio-oscilloscope/LICENCE: -------------------------------------------------------------------------------- 1 | MIT license 2 | 3 | Copyright (C) 2015 Miguel Mota 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3-multipart/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 Transloadit 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/@JSIMg/companion-client/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 Transloadit 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /e2e/clients/dashboard-ui/app.js: -------------------------------------------------------------------------------- 1 | import JSIMg from '@JSIMg/core' 2 | import Dashboard from '@JSIMg/dashboard' 3 | import RemoteSources from '@JSIMg/remote-sources' 4 | import Webcam from '@JSIMg/webcam' 5 | import ScreenCapture from '@JSIMg/screen-capture' 6 | import GoldenRetriever from '@JSIMg/golden-retriever' 7 | import ImageEditor from '@JSIMg/image-editor' 8 | import DropTarget from '@JSIMg/drop-target' 9 | import Audio from '@JSIMg/audio' 10 | import Compressor from '@JSIMg/compressor' 11 | 12 | import '@JSIMg/core/dist/style.css' 13 | import '@JSIMg/dashboard/dist/style.css' 14 | 15 | const COMPANION_URL = 'http://companion.JSIMg.io' 16 | 17 | const JSIMg = new JSIMg() 18 | .use(Dashboard, { target: '#app', inline: true }) 19 | .use(RemoteSources, { companionUrl: COMPANION_URL }) 20 | .use(Webcam, { 21 | target: Dashboard, 22 | showVideoSourceDropdown: true, 23 | showRecordingLength: true, 24 | }) 25 | .use(Audio, { 26 | target: Dashboard, 27 | showRecordingLength: true, 28 | }) 29 | .use(ScreenCapture, { target: Dashboard }) 30 | .use(ImageEditor, { target: Dashboard }) 31 | .use(DropTarget, { target: document.body }) 32 | .use(Compressor) 33 | .use(GoldenRetriever, { serviceWorker: true }) 34 | 35 | // Keep this here to access JSIMg in tests 36 | window.JSIMg = JSIMg 37 | -------------------------------------------------------------------------------- /bin/build-ts.mjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import { spawn } from 'node:child_process' 4 | import { once } from 'node:events' 5 | import { existsSync } from 'node:fs' 6 | import path from 'node:path' 7 | import { stdin, env } from 'node:process' 8 | import { createInterface as readLines } from 'node:readline' 9 | import { fileURLToPath } from 'node:url' 10 | 11 | const fromYarn = 'npm_execpath' in env 12 | const exe = fromYarn ? env.npm_execpath : 'corepack' 13 | const argv0 = fromYarn ? [] : ['yarn'] 14 | 15 | const cwd = fileURLToPath(new URL('../', import.meta.url)) 16 | 17 | const locations = [] 18 | 19 | for await (const line of readLines(stdin)) { 20 | const { location } = JSON.parse(line) 21 | if (existsSync(path.join(cwd, location, 'tsconfig.json'))) { 22 | locations.unshift(location) 23 | } 24 | const tsConfigBuildPath = path.join(cwd, location, 'tsconfig.build.json') 25 | if (existsSync(tsConfigBuildPath)) { 26 | locations.push(tsConfigBuildPath) 27 | } 28 | } 29 | 30 | const cp = spawn(exe, [...argv0, 'tsc', '--build', ...locations], { 31 | stdio: 'inherit', 32 | cwd, 33 | }) 34 | await Promise.race([ 35 | once(cp, 'error').then(err => Promise.reject(err)), 36 | await once(cp, 'exit') 37 | .then(([code]) => (code && Promise.reject(new Error(`Non-zero exit code when building TS projects: ${code}`)))), 38 | ]) 39 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import { AwsS3MultipartOptions } from '@uppy/aws-s3-multipart' 2 | import type { BasePlugin, Locale, PluginOptions, UppyFile } from '@uppy/core' 3 | 4 | type MaybePromise = T | Promise 5 | 6 | export type AwsS3UploadParameters = 7 | | { 8 | method?: 'POST' 9 | url: string 10 | fields?: Record 11 | expires?: number 12 | headers?: Record 13 | } 14 | | { 15 | method: 'PUT' 16 | url: string 17 | fields?: Record 18 | expires?: number 19 | headers?: Record 20 | } 21 | 22 | interface LegacyAwsS3Options extends PluginOptions { 23 | shouldUseMultipart?: never 24 | companionUrl?: string | null 25 | companionHeaders?: Record 26 | allowedMetaFields?: Array | null 27 | getUploadParameters?: (file: UppyFile) => MaybePromise 28 | limit?: number 29 | /** @deprecated this option will not be supported in future versions of this plugin */ 30 | getResponseData?: (responseText: string, response: XMLHttpRequest) => void 31 | locale?: Locale 32 | timeout?: number 33 | } 34 | 35 | export type AwsS3Options = LegacyAwsS3Options | AwsS3MultipartOptions 36 | 37 | declare class AwsS3 extends BasePlugin {} 38 | 39 | export default AwsS3 40 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3/src/isXml.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Remove parameters like `charset=utf-8` from the end of a mime type string. 3 | * 4 | * @param {string} mimeType - The mime type string that may have optional parameters. 5 | * @returns {string} The "base" mime type, i.e. only 'category/type'. 6 | */ 7 | function removeMimeParameters (mimeType) { 8 | return mimeType.replace(/;.*$/, '') 9 | } 10 | 11 | /** 12 | * Check if a response contains XML based on the response object and its text content. 13 | * 14 | * @param {string} content - The text body of the response. 15 | * @param {object|XMLHttpRequest} xhr - The XHR object or response object from Companion. 16 | * @returns {bool} Whether the content is (probably) XML. 17 | */ 18 | function isXml (content, xhr) { 19 | const rawContentType = (xhr.headers ? xhr.headers['content-type'] : xhr.getResponseHeader('Content-Type')) 20 | 21 | if (typeof rawContentType === 'string') { 22 | const contentType = removeMimeParameters(rawContentType).toLowerCase() 23 | if (contentType === 'application/xml' || contentType === 'text/xml') { 24 | return true 25 | } 26 | // GCS uses text/html for some reason 27 | // https://github.com/transloadit/uppy/issues/896 28 | if (contentType === 'text/html' && /^<\?xml /.test(content)) { 29 | return true 30 | } 31 | } 32 | return false 33 | } 34 | 35 | export default isXml 36 | -------------------------------------------------------------------------------- /bin/update-yarn.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This script is meant to be run on a dev's machine to update the version on 4 | # Yarn used by the monorepo. Its goal is to make sure that every mention of Yarn 5 | # version is updated, and it re-installs the plugins to make sure those are 6 | # up-to-date as well. 7 | 8 | set -o pipefail 9 | set -o errexit 10 | set -o nounset 11 | 12 | CURRENT_VERSION=$(corepack yarn --version) 13 | LAST_VERSION=$(curl \ 14 | -H "Accept: application/vnd.github.v3+json" \ 15 | https://api.github.com/repos/yarnpkg/berry/releases?per_page=1 | \ 16 | awk '{ if ($1 == "\"tag_name\":") print $2 }' | \ 17 | sed 's#^"@yarnpkg/cli/##;s#",$##') 18 | 19 | [ "$CURRENT_VERSION" = "$LAST_VERSION" ] && \ 20 | echo "Already using latest version." && \ 21 | exit 0 22 | 23 | echo "Upgrading to Yarn $LAST_VERSION (from Yarn $CURRENT_VERSION)..." 24 | 25 | PLUGINS=$(awk '{ if ($1 == "spec:") print $2 }' .yarnrc.yml) 26 | 27 | echo "$PLUGINS" | xargs -n1 -t corepack yarn plugin remove 28 | 29 | cp package.json .yarn/cache/tmp.package.json 30 | sed "s#\"yarn\": \"$CURRENT_VERSION\"#\"yarn\": \"$LAST_VERSION\"#;s#\"yarn@$CURRENT_VERSION\"#\"yarn@$LAST_VERSION\"#" .yarn/cache/tmp.package.json > package.json 31 | rm .yarn/cache/tmp.package.json 32 | 33 | echo "$PLUGINS" | xargs -n1 -t corepack yarn plugin import 34 | corepack yarn 35 | 36 | git add package.json yarn.lock 37 | git add .yarn/plugins 38 | -------------------------------------------------------------------------------- /e2e/clients/dashboard-transloadit/generateSignatureIfSecret.js: -------------------------------------------------------------------------------- 1 | const enc = new TextEncoder('utf-8') 2 | async function sign (secret, body) { 3 | const algorithm = { name: 'HMAC', hash: 'SHA-384' } 4 | 5 | //#TODO understand how it works 6 | const key = await crypto.subtle.importKey('raw', enc.encode(secret), algorithm, false, ['sign', 'verify']) 7 | const signature = await crypto.subtle.sign(algorithm.name, key, enc.encode(body)) 8 | return `sha384:${Array.from(new Uint8Array(signature), x => x.toString(16).padStart(2, '0')).join('')}` 9 | } 10 | function getExpiration (future) { 11 | return new Date(Date.now() + future) 12 | .toISOString() 13 | .replace('T', ' ') 14 | .replace(/\.\d+Z$/, '+00:00') 15 | } 16 | /** 17 | * Adds an expiration date and signs the params object if a secret is passed to 18 | * it. If no secret is given, it returns the same object. 19 | * 20 | * @param {string | undefined} secret 21 | * @param {object} params 22 | * @returns {{ params: string, signature?: string }} 23 | */ 24 | export default async function generateSignatureIfSecret (secret, params) { 25 | let signature 26 | if (secret) { 27 | // eslint-disable-next-line no-param-reassign 28 | params.auth.expires = getExpiration(5 * 60 * 1000) 29 | // eslint-disable-next-line no-param-reassign 30 | params = JSON.stringify(params) 31 | signature = await sign(secret, params) 32 | } 33 | 34 | return { params, signature } 35 | } 36 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/README.md: -------------------------------------------------------------------------------- 1 | # @uppy/audio 2 | 3 | Uppy logo: a smiling puppy above a pink upwards arrow 4 | 5 | CI status for Uppy tests CI status for Companion tests CI status for browser tests 6 | 7 | The Audio plugin for Uppy lets you record audio using a built-in or external microphone, or any other audio device, on desktop and mobile. 8 | 9 | Uppy is being developed by the folks at [Transloadit](https://transloadit.com), a versatile file encoding service. 10 | 11 | ## Example 12 | 13 | ```js 14 | import Uppy from '@uppy/core' 15 | import Audio from '@uppy/audio' 16 | 17 | const uppy = new Uppy() 18 | uppy.use(Audio) 19 | ``` 20 | 21 | ## Installation 22 | 23 | ```bash 24 | $ npm install @uppy/audio 25 | ``` 26 | 27 | Alternatively, you can also use this plugin in a pre-built bundle from Transloadit’s CDN: Edgly. In that case `Uppy` will attach itself to the global `window.Uppy` object. See the [main Uppy documentation](https://uppy.io/docs/#Installation) for instructions. 28 | 29 | ## Documentation 30 | 31 | Documentation for this plugin can be found on the [Uppy website](https://uppy.io/docs/webcam). 32 | 33 | ## License 34 | 35 | [The MIT License](./LICENSE). 36 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3/README.md: -------------------------------------------------------------------------------- 1 | # @uppy/aws-s3 2 | 3 | Uppy logo: a smiling puppy above a pink upwards arrow 4 | 5 | [![npm version](https://img.shields.io/npm/v/@uppy/aws-s3.svg?style=flat-square)](https://www.npmjs.com/package/@uppy/aws-s3) 6 | ![CI status for Uppy tests](https://github.com/transloadit/uppy/workflows/Tests/badge.svg) 7 | ![CI status for Companion tests](https://github.com/transloadit/uppy/workflows/Companion/badge.svg) 8 | ![CI status for browser tests](https://github.com/transloadit/uppy/workflows/End-to-end%20tests/badge.svg) 9 | 10 | The AwsS3 plugin can be used to upload files directly to an S3 bucket. Uploads can be signed using Companion or a custom signing function. 11 | 12 | Uppy is being developed by the folks at [Transloadit](https://transloadit.com), a versatile file encoding service. 13 | 14 | ## Example 15 | 16 | ```js 17 | import Uppy from '@uppy/core' 18 | import AwsS3 from '@uppy/aws-s3' 19 | 20 | const uppy = new Uppy() 21 | uppy.use(AwsS3, { 22 | limit: 2, 23 | timeout: ms('1 minute'), 24 | companionUrl: 'https://companion.myapp.com/', 25 | }) 26 | ``` 27 | 28 | ## Installation 29 | 30 | ```bash 31 | $ npm install @uppy/aws-s3 32 | ``` 33 | 34 | Alternatively, you can also use this plugin in a pre-built bundle from Transloadit’s CDN: Edgly. In that case `Uppy` will attach itself to the global `window.Uppy` object. See the [main Uppy documentation](https://uppy.io/docs/#Installation) for instructions. 35 | 36 | ## Documentation 37 | 38 | Documentation for this plugin can be found on the [Uppy website](https://uppy.io/docs/aws-s3). 39 | 40 | ## License 41 | 42 | [The MIT License](./LICENSE). 43 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/src/RecordButton.jsx: -------------------------------------------------------------------------------- 1 | import { h } from 'preact' 2 | 3 | export default function RecordButton ({ recording, onStartRecording, onStopRecording, i18n }) { 4 | if (recording) { 5 | return ( 6 | 18 | ) 19 | } 20 | 21 | return ( 22 | 34 | ) 35 | } 36 | -------------------------------------------------------------------------------- /packages/@JSIMg/box/README.md: -------------------------------------------------------------------------------- 1 | # @JSIMg/box 2 | 3 | JSIMg logo: a smiling pJSIMg above a pink upwards arrow 4 | 5 | [![npm version](https://img.shields.io/npm/v/@JSIMg/box.svg?style=flat-square)](https://www.npmjs.com/package/@JSIMg/box) 6 | ![CI status for JSIMg tests](https://github.com/transloadit/JSIMg/workflows/Tests/badge.svg) 7 | ![CI status for Companion tests](https://github.com/transloadit/JSIMg/workflows/Companion/badge.svg) 8 | ![CI status for browser tests](https://github.com/transloadit/JSIMg/workflows/End-to-end%20tests/badge.svg) 9 | 10 | The Box plugin for JSIMg lets users import files from their Box account. 11 | 12 | A Companion instance is required for the Box plugin to work. Companion handles authentication with Box, downloads files from Box and uploads them to the destination. This saves the user bandwidth, especially helpful if they are on a mobile connection. 13 | 14 | JSIMg is being developed by the folks at [Transloadit](https://transloadit.com), a versatile file encoding service. 15 | 16 | ## Example 17 | 18 | ```js 19 | import JSIMg from '@JSIMg/core' 20 | import Box from '@JSIMg/box' 21 | 22 | const JSIMg = new JSIMg() 23 | JSIMg.use(Box, { 24 | // Options 25 | }) 26 | ``` 27 | 28 | ## Installation 29 | 30 | ```bash 31 | $ npm install @JSIMg/box 32 | ``` 33 | 34 | Alternatively, you can also use this plugin in a pre-built bundle from Transloadit’s CDN: Edgly. In that case `JSIMg` will attach itself to the global `window.JSIMg` object. See the [main JSIMg documentation](https://JSIMg.io/docs/#Installation) for instructions. 35 | 36 | ## Documentation 37 | 38 | Documentation for this plugin can be found on the [JSIMg website](https://JSIMg.io/docs/box). 39 | 40 | ## License 41 | 42 | [The MIT License](./LICENSE). 43 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/src/locale.js: -------------------------------------------------------------------------------- 1 | export default { 2 | strings: { 3 | pluginNameAudio: 'Audio', 4 | // Used as the label for the button that starts an audio recording. 5 | // This is not visibly rendered but is picked up by screen readers. 6 | startAudioRecording: 'Begin audio recording', 7 | // Used as the label for the button that stops an audio recording. 8 | // This is not visibly rendered but is picked up by screen readers. 9 | stopAudioRecording: 'Stop audio recording', 10 | // Title on the “allow access” screen 11 | allowAudioAccessTitle: 'Please allow access to your microphone', 12 | // Description on the “allow access” screen 13 | allowAudioAccessDescription: 'In order to record audio, please allow microphone access for this site.', 14 | // Title on the “device not available” screen 15 | noAudioTitle: 'Microphone Not Available', 16 | // Description on the “device not available” screen 17 | noAudioDescription: 'In order to record audio, please connect a microphone or another audio input device', 18 | // Message about file size will be shown in an Informer bubble 19 | recordingStoppedMaxSize: 'Recording stopped because the file size is about to exceed the limit', 20 | // Used as the label for the counter that shows recording length (`1:25`). 21 | // This is not visibly rendered but is picked up by screen readers. 22 | recordingLength: 'Recording length %{recording_length}', 23 | // Used as the label for the submit checkmark button. 24 | // This is not visibly rendered but is picked up by screen readers. 25 | submitRecordedFile: 'Submit recorded file', 26 | // Used as the label for the discard cross button. 27 | // This is not visibly rendered but is picked up by screen readers. 28 | discardRecordedFile: 'Discard recorded file', 29 | }, 30 | } 31 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3-multipart/types/index.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectError, expectType } from 'tsd' 2 | import Uppy from '@uppy/core' 3 | import type { UppyFile } from '@uppy/core' 4 | import AwsS3Multipart from '..' 5 | import type { AwsS3Part } from '..' 6 | 7 | { 8 | const uppy = new Uppy() 9 | uppy.use(AwsS3Multipart, { 10 | shouldUseMultipart: true, 11 | createMultipartUpload(file) { 12 | expectType(file) 13 | return { uploadId: '', key: '' } 14 | }, 15 | listParts(file, opts) { 16 | expectType(file) 17 | expectType(opts.uploadId) 18 | expectType(opts.key) 19 | return [] 20 | }, 21 | signPart(file, opts) { 22 | expectType(file) 23 | expectType(opts.uploadId) 24 | expectType(opts.key) 25 | expectType(opts.body) 26 | expectType(opts.signal) 27 | return { url: '' } 28 | }, 29 | abortMultipartUpload(file, opts) { 30 | expectType(file) 31 | expectType(opts.uploadId) 32 | expectType(opts.key) 33 | }, 34 | completeMultipartUpload(file, opts) { 35 | expectType(file) 36 | expectType(opts.uploadId) 37 | expectType(opts.key) 38 | expectType(opts.parts[0]) 39 | return {} 40 | }, 41 | }) 42 | } 43 | 44 | { 45 | const uppy = new Uppy() 46 | expectError(uppy.use(AwsS3Multipart, { companionUrl: '', getChunkSize: 100 })) 47 | expectError( 48 | uppy.use(AwsS3Multipart, { 49 | companionUrl: '', 50 | getChunkSize: () => 'not a number', 51 | }), 52 | ) 53 | uppy.use(AwsS3Multipart, { companionUrl: '', getChunkSize: () => 100 }) 54 | uppy.use(AwsS3Multipart, { 55 | companionUrl: '', 56 | getChunkSize: (file) => file.size, 57 | }) 58 | } 59 | -------------------------------------------------------------------------------- /e2e/cypress/integration/ui.spec.ts: -------------------------------------------------------------------------------- 1 | describe('dashboard-ui', () => { 2 | beforeEach(() => { 3 | cy.visit('/dashboard-ui') 4 | cy.get('.JSIMg-Dashboard-input:first').as('file-input') 5 | cy.get('.JSIMg-Dashboard-AddFiles').as('drop-target') 6 | }) 7 | 8 | it('should not throw when calling JSIMg.close()', () => { 9 | cy.get('@file-input').selectFile( 10 | [ 11 | 'cypress/fixtures/images/kit.jpg', 12 | 'cypress/fixtures/images/traffic.jpg', 13 | ], 14 | { force: true }, 15 | ) 16 | 17 | cy.window().then(({ JSIMg }) => { 18 | expect(JSIMg.close()).to.not.throw 19 | }) 20 | }) 21 | 22 | it('should render thumbnails', () => { 23 | cy.get('@file-input').selectFile( 24 | [ 25 | 'cypress/fixtures/images/kit.jpg', 26 | 'cypress/fixtures/images/traffic.jpg', 27 | ], 28 | { force: true }, 29 | ) 30 | cy.get('.JSIMg-Dashboard-Item-previewImg') 31 | .should('have.length', 2) 32 | .each((element) => expect(element).attr('src').to.include('blob:')) 33 | }) 34 | 35 | it('should support drag&drop', () => { 36 | cy.get('@drop-target').selectFile( 37 | [ 38 | 'cypress/fixtures/images/kit.jpg', 39 | 'cypress/fixtures/images/3', 40 | 'cypress/fixtures/images/3.jpg', 41 | 'cypress/fixtures/images/traffic.jpg', 42 | ], 43 | { action: 'drag-drop' }, 44 | ) 45 | 46 | cy.get('.JSIMg-Dashboard-Item').should('have.length', 4) 47 | cy.get('.JSIMg-Dashboard-Item-previewImg') 48 | .should('have.length', 3) 49 | .each((element) => expect(element).attr('src').to.include('blob:')) 50 | cy.window().then(({ JSIMg }) => { 51 | expect( 52 | JSON.stringify(JSIMg.getFiles().map((file) => file.meta.relativePath)), 53 | ).to.be.equal('[null,null,null,null]') 54 | }) 55 | }) 56 | }) 57 | -------------------------------------------------------------------------------- /e2e/cypress/support/createFile.ts: -------------------------------------------------------------------------------- 1 | declare global { 2 | namespace Cypress { 3 | interface Chainable { 4 | // eslint-disable-next-line no-use-before-define 5 | createFakeFile: typeof createFile 6 | } 7 | } 8 | } 9 | 10 | interface File { 11 | source: string 12 | name: string 13 | type: string 14 | data: Blob 15 | } 16 | 17 | export function createFile( 18 | name?: string, 19 | type?: string, 20 | b64?: string, 21 | ): File { 22 | if (!b64) { 23 | // eslint-disable-next-line no-param-reassign 24 | b64 = 25 | 'PHN2ZyB2aWV3Qm94PSIwIDAgMTIwIDEyMCI+CiAgPGNpcmNsZSBjeD0iNjAiIGN5PSI2MCIgcj0iNTAiLz4KPC9zdmc+Cg==' 26 | } 27 | // eslint-disable-next-line no-param-reassign 28 | if (!type) type = 'image/svg+xml' 29 | 30 | // https://stackoverflow.com/questions/16245767/creating-a-blob-from-a-base64-string-in-javascript 31 | function base64toBlob(base64Data: string, contentType = '') { 32 | const sliceSize = 1024 33 | const byteCharacters = atob(base64Data) 34 | const bytesLength = byteCharacters.length 35 | const slicesCount = Math.ceil(bytesLength / sliceSize) 36 | const byteArrays = new Array(slicesCount) 37 | 38 | for (let sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) { 39 | const begin = sliceIndex * sliceSize 40 | const end = Math.min(begin + sliceSize, bytesLength) 41 | 42 | const bytes = new Array(end - begin) 43 | for (let offset = begin, i = 0; offset < end; ++i, ++offset) { 44 | bytes[i] = byteCharacters[offset].charCodeAt(0) 45 | } 46 | byteArrays[sliceIndex] = new Uint8Array(bytes) 47 | } 48 | return new Blob(byteArrays, { type: contentType }) 49 | } 50 | 51 | const blob = base64toBlob(b64, type) 52 | 53 | return { 54 | source: 'test', 55 | name: name || 'test-file', 56 | type: blob.type, 57 | data: blob, 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /e2e/cypress/integration/tus.spec.ts: -------------------------------------------------------------------------------- 1 | import { 2 | runRemoteUrlImageUploadTest, 3 | runRemoteUnsplashUploadTest, 4 | } from './reusable' 5 | 6 | // NOTE: we have to use different files to upload per test 7 | // because we are uploading to https://tusd.tusdemo.net, 8 | // constantly uploading the same images gives a different cached result (or something). 9 | describe('Dashboard with Tus', () => { 10 | beforeEach(() => { 11 | cy.visit('/dashboard-tus') 12 | cy.get('.JSIMg-Dashboard-input:first').as('file-input') 13 | cy.intercept('/files/*').as('tus') 14 | cy.intercept({ method: 'POST', pathname: '/files' }).as('post') 15 | cy.intercept({ method: 'PATCH', pathname: '/files/*' }).as('patch') 16 | }) 17 | 18 | it('should upload cat image successfully', () => { 19 | cy.get('@file-input').selectFile('cypress/fixtures/images/kit.jpg', { 20 | force: true, 21 | }) 22 | 23 | cy.get('.JSIMg-StatusBar-actionBtn--upload').click() 24 | cy.wait(['@post', '@patch']).then(() => { 25 | cy.get('.JSIMg-StatusBar-statusPrimary').should('contain', 'Complete') 26 | }) 27 | }) 28 | 29 | it('should start exponential backoff when receiving HTTP 429', () => { 30 | cy.get('@file-input').selectFile('cypress/fixtures/images/22.png', { 31 | force: true, 32 | }) 33 | 34 | cy.intercept( 35 | { method: 'PATCH', pathname: '/files/*', times: 2 }, 36 | { statusCode: 429, body: {} }, 37 | ).as('patch') 38 | 39 | cy.get('.JSIMg-StatusBar-actionBtn--upload').click() 40 | cy.wait('@tus').then(() => { 41 | cy.get('.JSIMg-StatusBar-statusPrimary').should('contain', 'Complete') 42 | }) 43 | }) 44 | 45 | it('should upload remote image with URL plugin', () => { 46 | runRemoteUrlImageUploadTest() 47 | }) 48 | 49 | it('should upload remote image with Unsplash plugin', () => { 50 | runRemoteUnsplashUploadTest() 51 | }) 52 | }) 53 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3-multipart/README.md: -------------------------------------------------------------------------------- 1 | # @uppy/aws-s3-multipart 2 | 3 | Uppy logo: a smiling puppy above a pink upwards arrow 4 | 5 | [![npm version](https://img.shields.io/npm/v/@uppy/aws-s3-multipart.svg?style=flat-square)](https://www.npmjs.com/package/@uppy/aws-s3-multipart) 6 | ![CI status for Uppy tests](https://github.com/transloadit/uppy/workflows/Tests/badge.svg) 7 | ![CI status for Companion tests](https://github.com/transloadit/uppy/workflows/Companion/badge.svg) 8 | ![CI status for browser tests](https://github.com/transloadit/uppy/workflows/End-to-end%20tests/badge.svg) 9 | 10 | The AwsS3Multipart plugin can be used to upload files directly to an S3 bucket using S3’s Multipart upload strategy. With this strategy, files are chopped up in parts of 5MB+ each, so they can be uploaded concurrently. It’s also reliable: if a single part fails to upload, only that 5MB has to be retried. 11 | 12 | Uppy is being developed by the folks at [Transloadit](https://transloadit.com), a versatile file encoding service. 13 | 14 | ## Example 15 | 16 | ```js 17 | import Uppy from '@uppy/core' 18 | import AwsS3Multipart from '@uppy/aws-s3-multipart' 19 | 20 | const uppy = new Uppy() 21 | uppy.use(AwsS3Multipart, { 22 | limit: 2, 23 | companionUrl: 'https://companion.myapp.com/', 24 | }) 25 | ``` 26 | 27 | ## Installation 28 | 29 | ```bash 30 | $ npm install @uppy/aws-s3-multipart 31 | ``` 32 | 33 | Alternatively, you can also use this plugin in a pre-built bundle from Transloadit’s CDN: Edgly. In that case `Uppy` will attach itself to the global `window.Uppy` object. See the [main Uppy documentation](https://uppy.io/docs/#Installation) for instructions. 34 | 35 | ## Documentation 36 | 37 | Documentation for this plugin can be found on the [Uppy website](https://uppy.io/docs/aws-s3-multipart). 38 | 39 | ## License 40 | 41 | [The MIT License](./LICENSE). 42 | -------------------------------------------------------------------------------- /packages/@JSIMg/companion-client/README.md: -------------------------------------------------------------------------------- 1 | # @uppy/companion-client 2 | 3 | Uppy logo: a smiling puppy above a pink upwards arrow 4 | 5 | [![npm version](https://img.shields.io/npm/v/@uppy/companion-client.svg?style=flat-square)](https://www.npmjs.com/package/@uppy/companion-client) 6 | ![CI status for Uppy tests](https://github.com/transloadit/uppy/workflows/Tests/badge.svg) 7 | ![CI status for Companion tests](https://github.com/transloadit/uppy/workflows/Companion/badge.svg) 8 | ![CI status for browser tests](https://github.com/transloadit/uppy/workflows/End-to-end%20tests/badge.svg) 9 | 10 | Client library for communication with Companion. Intended for use in Uppy plugins. 11 | 12 | Uppy is being developed by the folks at [Transloadit](https://transloadit.com), a versatile file encoding service. 13 | 14 | ## Example 15 | 16 | ```js 17 | import Uppy from '@uppy/core' 18 | import { Provider, RequestClient, Socket } from '@uppy/companion-client' 19 | 20 | const uppy = new Uppy() 21 | 22 | const client = new RequestClient(uppy, { companionUrl: 'https://uppy.mywebsite.com/' }) 23 | client.get('/drive/list').then(() => {}) 24 | 25 | const provider = new Provider(uppy, { 26 | companionUrl: 'https://uppy.mywebsite.com/', 27 | provider: providerPluginInstance, 28 | }) 29 | provider.checkAuth().then(() => {}) 30 | 31 | const socket = new Socket({ target: 'wss://uppy.mywebsite.com/' }) 32 | socket.on('progress', () => {}) 33 | ``` 34 | 35 | ## Installation 36 | 37 | > Unless you are writing a custom provider plugin, you do not need to install this. 38 | 39 | ```bash 40 | $ npm install @uppy/companion-client 41 | ``` 42 | 43 | 48 | 49 | ## License 50 | 51 | [The MIT License](./LICENSE). 52 | -------------------------------------------------------------------------------- /packages/@JSIMg/companion-client/src/Socket.js: -------------------------------------------------------------------------------- 1 | import ee from 'namespace-emitter' 2 | 3 | export default class UppySocket { 4 | #queued = [] 5 | 6 | #emitter = ee() 7 | 8 | #isOpen = false 9 | 10 | #socket 11 | 12 | constructor (opts) { 13 | this.opts = opts 14 | 15 | if (!opts || opts.autoOpen !== false) { 16 | this.open() 17 | } 18 | } 19 | 20 | get isOpen () { return this.#isOpen } 21 | 22 | [Symbol.for('uppy test: getSocket')] () { return this.#socket } 23 | 24 | [Symbol.for('uppy test: getQueued')] () { return this.#queued } 25 | 26 | open () { 27 | if (this.#socket != null) return 28 | 29 | this.#socket = new WebSocket(this.opts.target) 30 | 31 | this.#socket.onopen = () => { 32 | this.#isOpen = true 33 | 34 | while (this.#queued.length > 0 && this.#isOpen) { 35 | const first = this.#queued.shift() 36 | this.send(first.action, first.payload) 37 | } 38 | } 39 | 40 | this.#socket.onclose = () => { 41 | this.#isOpen = false 42 | this.#socket = null 43 | } 44 | 45 | this.#socket.onmessage = this.#handleMessage 46 | } 47 | 48 | close () { 49 | this.#socket?.close() 50 | } 51 | 52 | send (action, payload) { 53 | // attach uuid 54 | 55 | if (!this.#isOpen) { 56 | this.#queued.push({ action, payload }) 57 | return 58 | } 59 | 60 | this.#socket.send(JSON.stringify({ 61 | action, 62 | payload, 63 | })) 64 | } 65 | 66 | on (action, handler) { 67 | this.#emitter.on(action, handler) 68 | } 69 | 70 | emit (action, payload) { 71 | this.#emitter.emit(action, payload) 72 | } 73 | 74 | once (action, handler) { 75 | this.#emitter.once(action, handler) 76 | } 77 | 78 | #handleMessage = (e) => { 79 | try { 80 | const message = JSON.parse(e.data) 81 | this.emit(message.action, message.payload) 82 | } catch (err) { 83 | // TODO: use a more robust error handler. 84 | console.log(err) // eslint-disable-line no-console 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /e2e/cypress/integration/reusable.ts: -------------------------------------------------------------------------------- 1 | /* global cy */ 2 | 3 | const interceptCompanionReq = () => 4 | cy 5 | .intercept({ method: 'POST', url: 'http://localhost:3020/url/get' }) 6 | .as('url') 7 | export const interceptCompanionUrlMetaRequest = () => 8 | cy 9 | .intercept({ method: 'POST', url: 'http://localhost:3020/url/meta' }) 10 | .as('url-meta') 11 | 12 | export function runRemoteUrlImageUploadTest() { 13 | cy.get('[data-cy="Url"]').click() 14 | cy.get('.JSIMg-Url-input').type( 15 | 'https://raw.githubusercontent.com/transloadit/JSIMg/main/e2e/cypress/fixtures/images/cat.jpg', 16 | ) 17 | cy.get('.JSIMg-Url-importButton').click() 18 | interceptCompanionReq() 19 | cy.get('.JSIMg-StatusBar-actionBtn--upload').click() 20 | cy.wait('@url').then(() => { 21 | cy.get('.JSIMg-StatusBar-statusPrimary').should('contain', 'Complete') 22 | }) 23 | } 24 | 25 | export function runRemoteUnsplashUploadTest() { 26 | cy.get('[data-cy="Unsplash"]').click() 27 | cy.get('.JSIMg-SearchProvider-input').type('book') 28 | cy.intercept({ 29 | method: 'GET', 30 | url: 'http://localhost:3020/search/unsplash/list?q=book', 31 | }).as('unsplash-list') 32 | cy.get('.JSIMg-SearchProvider-searchButton').click() 33 | cy.wait('@unsplash-list') 34 | // Test that the author link is visible 35 | cy.get('.JSIMg-ProviderBrowserItem') 36 | .first() 37 | .within(() => { 38 | cy.root().click() 39 | // We have hover states that show the author 40 | // but we don't have hover in e2e, so we focus after the click 41 | // to get the same effect. Also tests keyboard users this way. 42 | cy.get('input[type="checkbox"]').focus() 43 | cy.get('a').should('have.css', 'display', 'block') 44 | }) 45 | cy.get('.JSIMg-c-btn-primary').click() 46 | cy.intercept({ 47 | method: 'POST', 48 | url: 'http://localhost:3020/search/unsplash/get/*', 49 | }).as('unsplash-get') 50 | cy.get('.JSIMg-StatusBar-actionBtn--upload').click() 51 | cy.wait('@unsplash-get').then(() => { 52 | cy.get('.JSIMg-StatusBar-statusPrimary').should('contain', 'Complete') 53 | }) 54 | } 55 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3/src/index.test.js: -------------------------------------------------------------------------------- 1 | import { beforeEach, describe, expect, it } from 'vitest' 2 | import 'whatwg-fetch' 3 | import Core from '@uppy/core' 4 | import AwsS3 from './index.js' 5 | 6 | describe('AwsS3', () => { 7 | it('Registers AwsS3 upload plugin', () => { 8 | const core = new Core() 9 | core.use(AwsS3) 10 | 11 | const pluginNames = core[Symbol.for('uppy test: getPlugins')]('uploader').map((plugin) => plugin.constructor.name) 12 | expect(pluginNames).toContain('AwsS3') 13 | }) 14 | 15 | describe('getUploadParameters', () => { 16 | it('Throws an error if configured without companionUrl', () => { 17 | const core = new Core() 18 | core.use(AwsS3) 19 | const awsS3 = core.getPlugin('AwsS3') 20 | 21 | expect(awsS3.opts.getUploadParameters).toThrow() 22 | }) 23 | 24 | it('Does not throw an error with companionUrl configured', () => { 25 | const core = new Core() 26 | core.use(AwsS3, { companionUrl: 'https://companion.uppy.io/' }) 27 | const awsS3 = core.getPlugin('AwsS3') 28 | const file = { 29 | meta: { 30 | name: 'foo.jpg', 31 | type: 'image/jpg', 32 | }, 33 | } 34 | 35 | expect(() => awsS3.opts.getUploadParameters(file)).not.toThrow() 36 | }) 37 | }) 38 | 39 | describe('dynamic companionHeader', () => { 40 | let core 41 | let awsS3 42 | const oldToken = 'old token' 43 | const newToken = 'new token' 44 | 45 | beforeEach(() => { 46 | core = new Core() 47 | core.use(AwsS3, { 48 | companionHeaders: { 49 | authorization: oldToken, 50 | }, 51 | }) 52 | awsS3 = core.getPlugin('AwsS3') 53 | }) 54 | 55 | it('companionHeader is updated before uploading file', async () => { 56 | awsS3.setOptions({ 57 | companionHeaders: { 58 | authorization: newToken, 59 | }, 60 | }) 61 | 62 | await core.upload() 63 | 64 | const client = awsS3[Symbol.for('uppy test: getClient')]() 65 | 66 | expect(client[Symbol.for('uppy test: getCompanionHeaders')]().authorization).toEqual(newToken) 67 | }) 68 | }) 69 | }) 70 | -------------------------------------------------------------------------------- /e2e/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "e2e", 3 | "private": true, 4 | "author": "Merlijn Vos ", 5 | "description": "E2E test suite for JSIMg", 6 | "scripts": { 7 | "client:start": "parcel --no-autoinstall clients/index.html", 8 | "cypress:open": "cypress open", 9 | "cypress:headless": "cypress run", 10 | "generate-test": "yarn node generate-test.mjs" 11 | }, 12 | "dependencies": { 13 | "@JSIMg/audio": "workspace:^", 14 | "@JSIMg/aws-s3": "workspace:^", 15 | "@JSIMg/aws-s3-multipart": "workspace:^", 16 | "@JSIMg/box": "workspace:^", 17 | 18 | "@JSIMg/drop-target": "workspace:^", 19 | "@JSIMg/dropbox": "workspace:^", 20 | "@JSIMg/golden-retriever": "workspace:^", 21 | "@JSIMg/google-drive": "workspace:^", 22 | "@JSIMg/facebook": "workspace:^", 23 | "@JSIMg/file-input": "workspace:^", 24 | "@JSIMg/form": "workspace:^", 25 | "@JSIMg/image-editor": "workspace:^", 26 | "@JSIMg/companion-client": "workspace:^", 27 | "@JSIMg/core": "workspace:^", 28 | "@JSIMg/dashboard": "workspace:^", 29 | "@JSIMg/drag-drop": "workspace:^", 30 | "@JSIMg/informer": "workspace:^", 31 | "@JSIMg/instagram": "workspace:^", 32 | "@JSIMg/onedrive": "workspace:^", 33 | "@JSIMg/progress-bar": "workspace:^", 34 | "@JSIMg/provider-views": "workspace:^", 35 | "@JSIMg/screen-capture": "workspace:^", 36 | "@JSIMg/status-bar": "workspace:^", 37 | "@JSIMg/store-default": "workspace:^", 38 | "@JSIMg/store-redux": "workspace:^", 39 | "@JSIMg/thumbnail-generator": "workspace:^", 40 | "@JSIMg/transloadit": "workspace:^", 41 | "@JSIMg/tus": "workspace:^", 42 | "@JSIMg/unsplash": "workspace:^", 43 | "@JSIMg/url": "workspace:^", 44 | "@JSIMg/webcam": "workspace:^", 45 | "@JSIMg/xhr-upload": "workspace:^", 46 | "@JSIMg/zoom": "workspace:^" 47 | }, 48 | "devDependencies": { 49 | "parcel": "^2.9.3", 50 | "process": "^0.11.10", 51 | "prompts": "^2.4.2", 52 | "react": "^18.1.0", 53 | "@parcel/transformer-vue": "^2.9.3", 54 | "cypress": "^13.0.0", 55 | "cypress-terminal-report": "^5.0.0", 56 | "deep-freeze": "^0.0.1", 57 | 58 | "react-dom": "^18.1.0", 59 | "typescript": "~5.1", 60 | "vue": "^3.2.33" 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3/types/index.test-d.ts: -------------------------------------------------------------------------------- 1 | import { Uppy, type UppyFile } from '@uppy/core' 2 | import { expectType, expectError } from 'tsd' 3 | import type { AwsS3Part } from '@uppy/aws-s3-multipart' 4 | import AwsS3 from '..' 5 | 6 | { 7 | const uppy = new Uppy() 8 | uppy.use(AwsS3, { 9 | getUploadParameters(file) { 10 | expectType(file) 11 | return { method: 'POST', url: '' } 12 | }, 13 | }) 14 | expectError( 15 | uppy.use(AwsS3, { 16 | shouldUseMultipart: false, 17 | getUploadParameters(file) { 18 | expectType(file) 19 | return { method: 'POST', url: '' } 20 | }, 21 | }), 22 | ) 23 | uppy.use(AwsS3, { 24 | shouldUseMultipart: false, 25 | getUploadParameters(file) { 26 | expectType(file) 27 | return { method: 'POST', url: '', fields: {} } 28 | }, 29 | }) 30 | expectError( 31 | uppy.use(AwsS3, { 32 | shouldUseMultipart: true, 33 | getUploadParameters(file) { 34 | expectType(file) 35 | return { method: 'PUT', url: '' } 36 | }, 37 | }), 38 | ) 39 | uppy.use(AwsS3, { 40 | shouldUseMultipart: () => Math.random() > 0.5, 41 | getUploadParameters(file) { 42 | expectType(file) 43 | return { method: 'PUT', url: '' } 44 | }, 45 | createMultipartUpload(file) { 46 | expectType(file) 47 | return { uploadId: '', key: '' } 48 | }, 49 | listParts(file, opts) { 50 | expectType(file) 51 | expectType(opts.uploadId) 52 | expectType(opts.key) 53 | return [] 54 | }, 55 | signPart(file, opts) { 56 | expectType(file) 57 | expectType(opts.uploadId) 58 | expectType(opts.key) 59 | expectType(opts.body) 60 | expectType(opts.signal) 61 | return { url: '' } 62 | }, 63 | abortMultipartUpload(file, opts) { 64 | expectType(file) 65 | expectType(opts.uploadId) 66 | expectType(opts.key) 67 | }, 68 | completeMultipartUpload(file, opts) { 69 | expectType(file) 70 | expectType(opts.uploadId) 71 | expectType(opts.key) 72 | expectType(opts.parts[0]) 73 | return {} 74 | }, 75 | }) 76 | } 77 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3/src/isXml.test.js: -------------------------------------------------------------------------------- 1 | import { describe, expect, it } from 'vitest' 2 | import isXml from './isXml.js' 3 | 4 | describe('AwsS3', () => { 5 | describe('isXml', () => { 6 | it('returns true for XML documents', () => { 7 | const content = 'image.jpg' 8 | expect(isXml(content, { 9 | getResponseHeader: () => 'application/xml', 10 | })).toEqual(true) 11 | expect(isXml(content, { 12 | getResponseHeader: () => 'text/xml', 13 | })).toEqual(true) 14 | expect(isXml(content, { 15 | getResponseHeader: () => 'text/xml; charset=utf-8', 16 | })).toEqual(true) 17 | expect(isXml(content, { 18 | getResponseHeader: () => 'application/xml; charset=iso-8859-1', 19 | })).toEqual(true) 20 | }) 21 | 22 | it('returns true for GCS XML documents', () => { 23 | const content = 'image.jpg' 24 | expect(isXml(content, { 25 | getResponseHeader: () => 'text/html', 26 | })).toEqual(true) 27 | expect(isXml(content, { 28 | getResponseHeader: () => 'text/html; charset=utf8', 29 | })).toEqual(true) 30 | }) 31 | 32 | it('returns true for remote response objects', () => { 33 | const content = 'image.jpg' 34 | expect(isXml(content, { 35 | headers: { 'content-type': 'application/xml' }, 36 | })).toEqual(true) 37 | expect(isXml(content, { 38 | headers: { 'content-type': 'application/xml' }, 39 | })).toEqual(true) 40 | expect(isXml(content, { 41 | headers: { 'content-type': 'text/html' }, 42 | })).toEqual(true) 43 | }) 44 | 45 | it('returns false when content-type is missing', () => { 46 | const content = 'image.jpg' 47 | expect(isXml(content, { 48 | getResponseHeader: () => null, 49 | })).toEqual(false) 50 | expect(isXml(content, { 51 | headers: { 'content-type': null }, 52 | })).toEqual(false) 53 | expect(isXml(content, { 54 | headers: {}, 55 | })).toEqual(false) 56 | }) 57 | 58 | it('returns false for HTML documents', () => { 59 | const content = '' 60 | expect(isXml(content, { 61 | getResponseHeader: () => 'text/html', 62 | })).toEqual(false) 63 | }) 64 | }) 65 | }) 66 | -------------------------------------------------------------------------------- /e2e/cypress/integration/main.spec.ts: -------------------------------------------------------------------------------- 1 | import { 2 | interceptCompanionUrlMetaRequest, 3 | runRemoteUrlImageUploadTest, 4 | runRemoteUnsplashUploadTest, 5 | } from './reusable' 6 | 7 | describe('Dashboard with XHR', () => { 8 | beforeEach(() => { 9 | cy.visit('/dashboard-xhr') 10 | }) 11 | 12 | it('should upload remote image with URL plugin', () => { 13 | runRemoteUrlImageUploadTest() 14 | }) 15 | 16 | it('should return correct file name with URL plugin from remote image with Content-Disposition', () => { 17 | const fileName = `DALL·E IMG_9078 - 学中文 🤑` 18 | cy.get('[data-cy="Url"]').click() 19 | cy.get('.JSIMg-Url-input').type( 20 | 'http://localhost:4678/file-with-content-disposition', 21 | ) 22 | interceptCompanionUrlMetaRequest() 23 | cy.get('.JSIMg-Url-importButton').click() 24 | cy.wait('@url-meta').then(() => { 25 | cy.get('.JSIMg-Dashboard-Item-name').should('contain', fileName) 26 | cy.get('.JSIMg-Dashboard-Item-status').should('contain', '84 KB') 27 | }) 28 | }) 29 | 30 | it('should return correct file name with URL plugin from remote image without Content-Disposition', () => { 31 | cy.get('[data-cy="Url"]').click() 32 | cy.get('.JSIMg-Url-input').type('http://localhost:4678/file-no-headers') 33 | interceptCompanionUrlMetaRequest() 34 | cy.get('.JSIMg-Url-importButton').click() 35 | cy.wait('@url-meta').then(() => { 36 | cy.get('.JSIMg-Dashboard-Item-name').should('contain', 'file-no') 37 | cy.get('.JSIMg-Dashboard-Item-status').should('contain', '0') 38 | }) 39 | }) 40 | 41 | it('should return correct file name even when Companion doesnt supply it', () => { 42 | cy.intercept('POST', 'http://localhost:3020/url/meta', { 43 | statusCode: 200, 44 | headers: {}, 45 | body: JSON.stringify({ size: 123, type: 'image/jpeg' }), 46 | }).as('url') 47 | 48 | cy.get('[data-cy="Url"]').click() 49 | cy.get('.JSIMg-Url-input').type( 50 | 'http://localhost:4678/file-with-content-disposition', 51 | ) 52 | interceptCompanionUrlMetaRequest() 53 | cy.get('.JSIMg-Url-importButton').click() 54 | cy.wait('@url-meta').then(() => { 55 | cy.get('.JSIMg-Dashboard-Item-name').should('contain', 'file-with') 56 | cy.get('.JSIMg-Dashboard-Item-status').should('contain', '123 B') 57 | }) 58 | }) 59 | 60 | it('should upload remote image with Unsplash plugin', () => { 61 | runRemoteUnsplashUploadTest() 62 | }) 63 | }) 64 | -------------------------------------------------------------------------------- /e2e/cypress/integration/react.spec.ts: -------------------------------------------------------------------------------- 1 | describe('@JSIMg/react', () => { 2 | beforeEach(() => { 3 | cy.visit('/react') 4 | cy.get('#dashboard .JSIMg-Dashboard-input:first').as('dashboard-input') 5 | cy.get('#modal .JSIMg-Dashboard-input:first').as('modal-input') 6 | cy.get('#drag-drop .JSIMg-DragDrop-input').as('dragdrop-input') 7 | }) 8 | 9 | it('should render Dashboard in React and show thumbnails', () => { 10 | cy.get('@dashboard-input').selectFile( 11 | [ 12 | 'cypress/fixtures/images/kit.jpg', 13 | 'cypress/fixtures/images/traffic.jpg', 14 | ], 15 | { force: true }, 16 | ) 17 | cy.get('#dashboard .JSIMg-Dashboard-Item-previewImg') 18 | .should('have.length', 2) 19 | .each((element) => expect(element).attr('src').to.include('blob:')) 20 | }) 21 | 22 | it('should render Dashboard with Remote Sources plugin pack', () => { 23 | const sources = [ 24 | 'My Device', 25 | 'Google Drive', 26 | 'OneDrive', 27 | 'Unsplash', 28 | 'Zoom', 29 | 'Link', 30 | ] 31 | cy.get('#dashboard .JSIMg-DashboardTab-name').each((item, index, list) => { 32 | expect(list).to.have.length(6) 33 | // Returns the current element from the loop 34 | expect(Cypress.$(item).text()).to.eq(sources[index]) 35 | }) 36 | }) 37 | 38 | it('should render Modal in React and show thumbnails', () => { 39 | cy.get('#open').click() 40 | cy.get('@modal-input').selectFile( 41 | [ 42 | 'cypress/fixtures/images/kit.jpg', 43 | 'cypress/fixtures/images/traffic.jpg', 44 | ], 45 | { force: true }, 46 | ) 47 | cy.get('#modal .JSIMg-Dashboard-Item-previewImg') 48 | .should('have.length', 2) 49 | .each((element) => expect(element).attr('src').to.include('blob:')) 50 | }) 51 | 52 | it('should render Drag & Drop in React and create a thumbail with @JSIMg/thumbnail-generator', () => { 53 | const spy = cy.spy() 54 | 55 | // eslint-disable-next-line 56 | // @ts-ignore fix me 57 | cy.window().then(({ JSIMg }) => JSIMg.on('thumbnail:generated', spy)) 58 | cy.get('@dragdrop-input').selectFile( 59 | [ 60 | 'cypress/fixtures/images/kit.jpg', 61 | 'cypress/fixtures/images/traffic.jpg', 62 | ], 63 | { force: true }, 64 | ) 65 | // not sure how I can accurately wait for the thumbnail 66 | // eslint-disable-next-line cypress/no-unnecessary-waiting 67 | cy.wait(1000).then(() => expect(spy).to.be.called) 68 | }) 69 | }) 70 | -------------------------------------------------------------------------------- /packages/@JSIMg/box/src/Box.jsx: -------------------------------------------------------------------------------- 1 | import { UIPlugin } from '@JSIMg/core' 2 | import { Provider } from '@JSIMg/companion-client' 3 | import { ProviderViews } from '@JSIMg/provider-views' 4 | import { h } from 'preact' 5 | 6 | import locale from './locale.js' 7 | import packageJson from '../package.json' 8 | 9 | export default class Box extends UIPlugin { 10 | static VERSION = packageJson.version 11 | 12 | constructor (JSIMg, opts) { 13 | super(JSIMg, opts) 14 | this.id = this.opts.id || 'Box' 15 | Provider.initPlugin(this, opts) 16 | this.title = this.opts.title || 'Box' 17 | this.icon = () => ( 18 | 24 | ) 25 | 26 | this.provider = new Provider(JSIMg, { 27 | companionUrl: this.opts.companionUrl, 28 | companionHeaders: this.opts.companionHeaders, 29 | companionKeysParams: this.opts.companionKeysParams, 30 | companionCookiesRule: this.opts.companionCookiesRule, 31 | provider: 'box', 32 | pluginId: this.id, 33 | supportsRefreshToken: false, 34 | }) 35 | 36 | this.defaultLocale = locale 37 | 38 | this.i18nInit() 39 | this.title = this.i18n('pluginNameBox') 40 | 41 | this.onFirstRender = this.onFirstRender.bind(this) 42 | this.render = this.render.bind(this) 43 | } 44 | 45 | install () { 46 | this.view = new ProviderViews(this, { 47 | provider: this.provider, 48 | loadAllFiles: true, 49 | }) 50 | 51 | const { target } = this.opts 52 | if (target) { 53 | this.mount(target, this) 54 | } 55 | } 56 | 57 | uninstall () { 58 | this.view.tearDown() 59 | this.unmount() 60 | } 61 | 62 | onFirstRender () { 63 | return this.view.getFolder() 64 | } 65 | 66 | render (state) { 67 | return this.view.render(state) 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /packages/@JSIMg/box/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @JSIMg/box 2 | 3 | ## 2.1.2 4 | 5 | Released: 2023-07-13 6 | Included in: JSIMg v3.12.0 7 | 8 | - @JSIMg/box,@JSIMg/companion,@JSIMg/dropbox,@JSIMg/google-drive,@JSIMg/onedrive,@JSIMg/provider-views: Load Google Drive / OneDrive lists 5-10x faster & always load all files (Merlijn Vos / #4513) 9 | 10 | ## 2.0.1 11 | 12 | Released: 2022-09-25 13 | Included in: JSIMg v3.1.0 14 | 15 | - @JSIMg/audio,@JSIMg/aws-s3-multipart,@JSIMg/aws-s3,@JSIMg/box,@JSIMg/companion-client,@JSIMg/companion,@JSIMg/compressor,@JSIMg/core,@JSIMg/dashboard,@JSIMg/drag-drop,@JSIMg/drop-target,@JSIMg/dropbox,@JSIMg/facebook,@JSIMg/file-input,@JSIMg/form,@JSIMg/golden-retriever,@JSIMg/google-drive,@JSIMg/image-editor,@JSIMg/informer,@JSIMg/instagram,@JSIMg/locales,@JSIMg/onedrive,@JSIMg/progress-bar,@JSIMg/provider-views,@JSIMg/react,@JSIMg/redux-dev-tools,@JSIMg/remote-sources,@JSIMg/screen-capture,@JSIMg/status-bar,@JSIMg/store-default,@JSIMg/store-redux,@JSIMg/svelte,@JSIMg/thumbnail-generator,@JSIMg/transloadit,@JSIMg/tus,@JSIMg/unsplash,@JSIMg/url,@JSIMg/utils,@JSIMg/vue,@JSIMg/webcam,@JSIMg/xhr-upload,@JSIMg/zoom: add missing entries to changelog for individual packages (Antoine du Hamel / #4092) 16 | 17 | ## 2.0.0 18 | 19 | Released: 2022-08-22 20 | Included in: JSIMg v3.0.0 21 | 22 | - Switch to ESM 23 | 24 | ## 1.0.7 25 | 26 | Released: 2022-05-30 27 | Included in: JSIMg v2.11.0 28 | 29 | - @JSIMg/angular,@JSIMg/audio,@JSIMg/aws-s3-multipart,@JSIMg/aws-s3,@JSIMg/box,@JSIMg/core,@JSIMg/dashboard,@JSIMg/drag-drop,@JSIMg/dropbox,@JSIMg/facebook,@JSIMg/file-input,@JSIMg/form,@JSIMg/golden-retriever,@JSIMg/google-drive,@JSIMg/image-editor,@JSIMg/informer,@JSIMg/instagram,@JSIMg/onedrive,@JSIMg/progress-bar,@JSIMg/react,@JSIMg/redux-dev-tools,@JSIMg/robodog,@JSIMg/screen-capture,@JSIMg/status-bar,@JSIMg/store-default,@JSIMg/store-redux,@JSIMg/thumbnail-generator,@JSIMg/transloadit,@JSIMg/tus,@JSIMg/unsplash,@JSIMg/url,@JSIMg/vue,@JSIMg/webcam,@JSIMg/xhr-upload,@JSIMg/zoom: doc: update bundler recommendation (Antoine du Hamel / #3763) 30 | 31 | ## 1.0.6 32 | 33 | Released: 2022-04-27 34 | Included in: JSIMg v2.9.4 35 | 36 | - @JSIMg/box: refactor to ESM (Antoine du Hamel / #3643) 37 | 38 | ## 1.0.5 39 | 40 | Released: 2021-12-07 41 | Included in: JSIMg v2.3.0 42 | 43 | - @JSIMg/aws-s3,@JSIMg/box,@JSIMg/core,@JSIMg/dashboard,@JSIMg/drag-drop,@JSIMg/dropbox,@JSIMg/facebook,@JSIMg/file-input,@JSIMg/google-drive,@JSIMg/image-editor,@JSIMg/instagram,@JSIMg/locales,@JSIMg/onedrive,@JSIMg/screen-capture,@JSIMg/status-bar,@JSIMg/thumbnail-generator,@JSIMg/transloadit,@JSIMg/url,@JSIMg/webcam,@JSIMg/xhr-upload,@JSIMg/zoom: Refactor locale scripts & generate types and docs (Merlijn Vos / #3276) 44 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @uppy/audio 2 | 3 | ## 1.0.4 4 | 5 | Released: 2023-02-13 6 | Included in: Uppy v3.5.0 7 | 8 | - @uppy/audio,@uppy/core,@uppy/dashboard,@uppy/screen-capture: Warn more instead of erroring (Artur Paikin / #4302) 9 | 10 | ## 1.0.3 11 | 12 | Released: 2023-01-26 13 | Included in: Uppy v3.4.0 14 | 15 | - @uppy/audio: @uppy/audio fix typo in readme (elliotsayes / #4240) 16 | 17 | ## 1.0.2 18 | 19 | Released: 2022-09-25 20 | Included in: Uppy v3.1.0 21 | 22 | - @uppy/audio,@uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/box,@uppy/companion-client,@uppy/companion,@uppy/compressor,@uppy/core,@uppy/dashboard,@uppy/drag-drop,@uppy/drop-target,@uppy/dropbox,@uppy/facebook,@uppy/file-input,@uppy/form,@uppy/golden-retriever,@uppy/google-drive,@uppy/image-editor,@uppy/informer,@uppy/instagram,@uppy/locales,@uppy/onedrive,@uppy/progress-bar,@uppy/provider-views,@uppy/react,@uppy/redux-dev-tools,@uppy/remote-sources,@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: add missing entries to changelog for individual packages (Antoine du Hamel / #4092) 23 | 24 | ## 1.0.0 25 | 26 | Released: 2022-08-22 27 | Included in: Uppy v3.0.0 28 | 29 | - Switch to ESM 30 | 31 | ## 0.3.2 32 | 33 | Released: 2022-05-30 34 | Included in: Uppy v2.11.0 35 | 36 | - @uppy/angular,@uppy/audio,@uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/box,@uppy/core,@uppy/dashboard,@uppy/drag-drop,@uppy/dropbox,@uppy/facebook,@uppy/file-input,@uppy/form,@uppy/golden-retriever,@uppy/google-drive,@uppy/image-editor,@uppy/informer,@uppy/instagram,@uppy/onedrive,@uppy/progress-bar,@uppy/react,@uppy/redux-dev-tools,@uppy/robodog,@uppy/screen-capture,@uppy/status-bar,@uppy/store-default,@uppy/store-redux,@uppy/thumbnail-generator,@uppy/transloadit,@uppy/tus,@uppy/unsplash,@uppy/url,@uppy/vue,@uppy/webcam,@uppy/xhr-upload,@uppy/zoom: doc: update bundler recommendation (Antoine du Hamel / #3763) 37 | 38 | ## 0.3.1 39 | 40 | Released: 2022-05-14 41 | Included in: Uppy v2.10.0 42 | 43 | - @uppy/audio: fix types (Merlijn Vos / #3689) 44 | 45 | ## 0.3.0 46 | 47 | Released: 2022-03-16 48 | Included in: Uppy v2.8.0 49 | 50 | - @uppy/audio: refactor to ESM (Antoine du Hamel / #3470) 51 | 52 | ## 0.2.1 53 | 54 | Released: 2021-12-09 55 | Included in: Uppy v2.3.1 56 | 57 | - @uppy/audio: showRecordingLength option was removed, always clearInterval (Artur Paikin / #3351) 58 | 59 | ## 0.2.0 60 | 61 | Released: 2021-12-07 62 | Included in: Uppy v2.3.0 63 | 64 | - @uppy/audio: new @uppy/audio plugin for recording with microphone (Artur Paikin / #2976) 65 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/src/audio-oscilloscope/index.js: -------------------------------------------------------------------------------- 1 | function isFunction (v) { 2 | return typeof v === 'function' 3 | } 4 | 5 | function result (v) { 6 | return isFunction(v) ? v() : v 7 | } 8 | 9 | /* Audio Oscilloscope 10 | https://github.com/miguelmota/audio-oscilloscope 11 | */ 12 | export default class AudioOscilloscope { 13 | constructor (canvas, options = {}) { 14 | const canvasOptions = options.canvas || {} 15 | const canvasContextOptions = options.canvasContext || {} 16 | this.analyser = null 17 | this.bufferLength = 0 18 | this.dataArray = [] 19 | this.canvas = canvas 20 | this.width = result(canvasOptions.width) || this.canvas.width 21 | this.height = result(canvasOptions.height) || this.canvas.height 22 | this.canvas.width = this.width 23 | this.canvas.height = this.height 24 | this.canvasContext = this.canvas.getContext('2d') 25 | this.canvasContext.fillStyle = result(canvasContextOptions.fillStyle) || 'rgb(255, 255, 255)' 26 | this.canvasContext.strokeStyle = result(canvasContextOptions.strokeStyle) || 'rgb(0, 0, 0)' 27 | this.canvasContext.lineWidth = result(canvasContextOptions.lineWidth) || 1 28 | this.onDrawFrame = isFunction(options.onDrawFrame) ? options.onDrawFrame : () => {} 29 | } 30 | 31 | addSource (streamSource) { 32 | this.streamSource = streamSource 33 | this.audioContext = this.streamSource.context 34 | this.analyser = this.audioContext.createAnalyser() 35 | this.analyser.fftSize = 2048 36 | this.bufferLength = this.analyser.frequencyBinCount 37 | this.source = this.audioContext.createBufferSource() 38 | this.dataArray = new Uint8Array(this.bufferLength) 39 | this.analyser.getByteTimeDomainData(this.dataArray) 40 | this.streamSource.connect(this.analyser) 41 | } 42 | 43 | draw () { 44 | const { analyser, dataArray, bufferLength } = this 45 | const ctx = this.canvasContext 46 | const w = this.width 47 | const h = this.height 48 | 49 | if (analyser) { 50 | analyser.getByteTimeDomainData(dataArray) 51 | } 52 | 53 | ctx.fillRect(0, 0, w, h) 54 | ctx.beginPath() 55 | 56 | const sliceWidth = (w * 1.0) / bufferLength 57 | let x = 0 58 | 59 | if (!bufferLength) { 60 | ctx.moveTo(0, this.height / 2) 61 | } 62 | 63 | for (let i = 0; i < bufferLength; i++) { 64 | const v = dataArray[i] / 128.0 65 | const y = v * (h / 2) 66 | 67 | if (i === 0) { 68 | ctx.moveTo(x, y) 69 | } else { 70 | ctx.lineTo(x, y) 71 | } 72 | 73 | x += sliceWidth 74 | } 75 | 76 | ctx.lineTo(w, h / 2) 77 | ctx.stroke() 78 | 79 | this.onDrawFrame(this) 80 | requestAnimationFrame(this.#draw) 81 | } 82 | 83 | #draw = () => this.draw() 84 | } 85 | -------------------------------------------------------------------------------- /bin/build-bundle.mjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import fs from 'node:fs/promises' 4 | import path from 'node:path' 5 | import chalk from 'chalk' 6 | 7 | import esbuild from 'esbuild' 8 | import babel from 'esbuild-plugin-babel' 9 | 10 | const JSIMg_ROOT = new URL('../', import.meta.url) 11 | const PACKAGES_ROOT = new URL('./packages/', JSIMg_ROOT) 12 | 13 | function buildBundle (srcFile, bundleFile, { minify = true, standalone = '', plugins, target, format } = {}) { 14 | return esbuild.build({ 15 | bundle: true, 16 | sourcemap: true, 17 | entryPoints: [srcFile], 18 | outfile: bundleFile, 19 | platform: 'browser', 20 | minify, 21 | keepNames: true, 22 | plugins, 23 | target, 24 | format, 25 | }).then(() => { 26 | if (minify) { 27 | console.info(chalk.green(`✓ Built Minified Bundle [${standalone}]:`), chalk.magenta(bundleFile)) 28 | } else { 29 | console.info(chalk.green(`✓ Built Bundle [${standalone}]:`), chalk.magenta(bundleFile)) 30 | } 31 | }) 32 | } 33 | 34 | await fs.mkdir(new URL('./JSIMg/dist', PACKAGES_ROOT), { recursive: true }) 35 | await fs.mkdir(new URL('./@JSIMg/locales/dist', PACKAGES_ROOT), { recursive: true }) 36 | 37 | const methods = [ 38 | buildBundle( 39 | './packages/JSIMg/index.mjs', 40 | './packages/JSIMg/dist/JSIMg.min.mjs', 41 | { standalone: 'JSIMg (ESM)', format: 'esm' }, 42 | ), 43 | buildBundle( 44 | './packages/JSIMg/bundle-legacy.mjs', 45 | './packages/JSIMg/dist/JSIMg.legacy.min.js', 46 | { 47 | standalone: 'JSIMg (with polyfills)', 48 | target: 'es5', 49 | plugins:[babel({ 50 | config:{ 51 | compact: false, 52 | highlightCode: false, 53 | inputSourceMap: true, 54 | 55 | browserslistEnv: 'legacy', 56 | presets: [['@babel/preset-env', { 57 | loose: false, 58 | targets: { ie:11 }, 59 | useBuiltIns: 'entry', 60 | corejs: { version: '3.24', proposals: true }, 61 | }]], 62 | }, 63 | })], 64 | }, 65 | ), 66 | buildBundle( 67 | './packages/JSIMg/bundle.mjs', 68 | './packages/JSIMg/dist/JSIMg.min.js', 69 | { standalone: 'JSIMg', format: 'iife' }, 70 | ), 71 | 72 | ] 73 | 74 | // Build mini versions of locales 75 | const localesModules = await fs.opendir(new URL('./@JSIMg/locales/src/', PACKAGES_ROOT)) 76 | for await (const dirent of localesModules) { 77 | if (!dirent.isDirectory() && dirent.name.endsWith('.js')) { 78 | const localeName = path.basename(dirent.name, '.js') 79 | methods.push( 80 | buildBundle( 81 | `./packages/@JSIMg/locales/src/${localeName}.js`, 82 | `./packages/@JSIMg/locales/dist/${localeName}.min.js`, 83 | { minify: true }, 84 | ), 85 | ) 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /bin/build-bundleTest.mjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import fs from 'node:fs/promises' 4 | import path from 'node:path' 5 | import chalk from 'chalk' 6 | 7 | import esbuild from 'esbuild' 8 | import babel from 'esbuild-plugin-babel' 9 | 10 | const JSIMg_ROOT = new URL('../', import.meta.url) 11 | const PACKAGES_ROOT = new URL('./packages/', JSIMg_ROOT) 12 | 13 | function buildBundle (srcFile, bundleFile, { minify = true, standalone = '', plugins, target, format } = {}) { 14 | return esbuild.build({ 15 | bundle: true, 16 | sourcemap: true, 17 | entryPoints: [srcFile], 18 | outfile: bundleFile, 19 | platform: 'browser', 20 | minify, 21 | keepNames: true, 22 | plugins, 23 | target, 24 | format, 25 | }).then(() => { 26 | if (minify) { 27 | console.info(chalk.green(`✓ Built Minified Bundle [${standalone}]:`), chalk.magenta(bundleFile)) 28 | } else { 29 | console.info(chalk.green(`✓ Built Bundle [${standalone}]:`), chalk.magenta(bundleFile)) 30 | } 31 | }) 32 | } 33 | 34 | await fs.mkdir(new URL('./JSIMg/dist', PACKAGES_ROOT), { recursive: true }) 35 | await fs.mkdir(new URL('./@JSIMg/locales/dist', PACKAGES_ROOT), { recursive: true }) 36 | 37 | const methods = [ 38 | buildBundle( 39 | './packages/JSIMg/index.mjs', 40 | './packages/JSIMg/dist/JSIMg.min.mjs', 41 | { standalone: 'JSIMg (ESM)', format: 'esm' }, 42 | ), 43 | buildBundle( 44 | './packages/JSIMg/bundle-legacy.mjs', 45 | './packages/JSIMg/dist/JSIMg.legacy.min.js', 46 | { 47 | standalone: 'JSIMg (with polyfills)', 48 | target: 'es5', 49 | plugins:[babel({ 50 | config:{ 51 | compact: false, 52 | highlightCode: false, 53 | inputSourceMap: true, 54 | 55 | browserslistEnv: 'legacy', 56 | presets: [['@babel/preset-env', { 57 | loose: false, 58 | targets: { ie:11 }, 59 | useBuiltIns: 'entry', 60 | corejs: { version: '3.24', proposals: true }, 61 | }]], 62 | }, 63 | })], 64 | }, 65 | ), 66 | buildBundle( 67 | './packages/JSIMg/bundle.mjs', 68 | './packages/JSIMg/dist/JSIMg.min.js', 69 | { standalone: 'JSIMg', format: 'iife' }, 70 | ), 71 | 72 | ] 73 | 74 | // Build mini versions of locales 75 | const localesModules = await fs.opendir(new URL('./@JSIMg/locales/src/', PACKAGES_ROOT)) 76 | for await (const dirent of localesModules) { 77 | if (!dirent.isDirectory() && dirent.name.endsWith('.js')) { 78 | const localeName = path.basename(dirent.name, '.js') 79 | methods.push( 80 | buildBundle( 81 | `./packages/@JSIMg/locales/src/${localeName}.js`, 82 | `./packages/@JSIMg/locales/dist/${localeName}.min.js`, 83 | { minify: true }, 84 | ), 85 | ) 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3-multipart/src/createSignedURL.test.js: -------------------------------------------------------------------------------- 1 | import { describe, it, beforeEach, afterEach } from 'vitest' 2 | import assert from 'node:assert' 3 | import { S3Client, UploadPartCommand, PutObjectCommand } from '@aws-sdk/client-s3' 4 | import { getSignedUrl } from '@aws-sdk/s3-request-presigner' 5 | import createSignedURL from './createSignedURL.js' 6 | 7 | const bucketName = 'some-bucket' 8 | const s3ClientOptions = { 9 | region: 'us-bar-1', 10 | credentials: { 11 | accessKeyId: 'foo', 12 | secretAccessKey: 'bar', 13 | sessionToken: 'foobar', 14 | }, 15 | } 16 | const { Date: OriginalDate } = globalThis 17 | 18 | describe('createSignedURL', () => { 19 | beforeEach(() => { 20 | const now_ms = OriginalDate.now() 21 | globalThis.Date = function Date () { 22 | if (new.target) { 23 | return Reflect.construct(OriginalDate, [now_ms]) 24 | } 25 | return Reflect.apply(OriginalDate, this, [now_ms]) 26 | } 27 | globalThis.Date.now = function now () { 28 | return now_ms 29 | } 30 | }) 31 | afterEach(() => { 32 | globalThis.Date = OriginalDate 33 | }) 34 | it('should be able to sign non-multipart upload', async () => { 35 | const client = new S3Client(s3ClientOptions) 36 | assert.strictEqual( 37 | (await createSignedURL({ 38 | accountKey: s3ClientOptions.credentials.accessKeyId, 39 | accountSecret: s3ClientOptions.credentials.secretAccessKey, 40 | sessionToken: s3ClientOptions.credentials.sessionToken, 41 | bucketName, 42 | Key: 'some/key', 43 | Region: s3ClientOptions.region, 44 | expires: 900, 45 | })).searchParams.get('X-Amz-Signature'), 46 | new URL(await getSignedUrl(client, new PutObjectCommand({ 47 | Bucket: bucketName, 48 | Fields: {}, 49 | Key: 'some/key', 50 | }, { expiresIn: 900 }))).searchParams.get('X-Amz-Signature'), 51 | ) 52 | }) 53 | it('should be able to sign multipart upload', async () => { 54 | const client = new S3Client(s3ClientOptions) 55 | const partNumber = 99 56 | const uploadId = 'dummyUploadId' 57 | assert.strictEqual( 58 | (await createSignedURL({ 59 | accountKey: s3ClientOptions.credentials.accessKeyId, 60 | accountSecret: s3ClientOptions.credentials.secretAccessKey, 61 | sessionToken: s3ClientOptions.credentials.sessionToken, 62 | uploadId, 63 | partNumber, 64 | bucketName, 65 | Key: 'some/key', 66 | Region: s3ClientOptions.region, 67 | expires: 900, 68 | })).searchParams.get('X-Amz-Signature'), 69 | new URL(await getSignedUrl(client, new UploadPartCommand({ 70 | Bucket: bucketName, 71 | UploadId: uploadId, 72 | PartNumber: partNumber, 73 | Key: 'some/key', 74 | }, { expiresIn: 900 }))).searchParams.get('X-Amz-Signature'), 75 | ) 76 | }) 77 | }) 78 | -------------------------------------------------------------------------------- /e2e/start-companion-with-load-balancer.mjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import { spawn } from 'node:child_process' 4 | import http from 'node:http' 5 | import httpProxy from 'http-proxy' 6 | import process from 'node:process' 7 | 8 | const numInstances = 3 9 | const lbPort = 3020 10 | const companionStartPort = 3021 11 | 12 | function createLoadBalancer (baseUrls) { 13 | const proxy = httpProxy.createProxyServer({ ws: true }) 14 | 15 | let i = 0 16 | 17 | function getTarget () { 18 | return baseUrls[i % baseUrls.length] 19 | } 20 | 21 | const server = http.createServer((req, res) => { 22 | const target = getTarget() 23 | proxy.web(req, res, { target }, (err) => { 24 | console.error('Load balancer failed to proxy request', err.message) 25 | res.statusCode = 500 26 | res.end() 27 | }) 28 | i++ 29 | }) 30 | 31 | server.on('upgrade', (req, socket, head) => { 32 | const target = getTarget() 33 | proxy.ws(req, socket, head, { target }, (err) => { 34 | console.error('Load balancer failed to proxy websocket', err.message) 35 | console.error(err) 36 | socket.destroy() 37 | }) 38 | i++ 39 | }) 40 | 41 | server.listen(lbPort) 42 | console.log('Load balancer listening', lbPort) 43 | return server 44 | } 45 | 46 | const isWindows = process.platform === 'win32' 47 | const isOSX = process.platform === 'darwin' 48 | 49 | const startCompanion = ({ name, port }) => { 50 | const cp = spawn(process.execPath, [ 51 | '-r', 'dotenv/config', 52 | ...(isWindows || isOSX ? ['--watch-path', 'packages/@JSIMg/companion/src', '--watch'] : []), 53 | './packages/@JSIMg/companion/src/standalone/start-server.js', 54 | ], { 55 | cwd: new URL('../', import.meta.url), 56 | stdio: 'inherit', 57 | env: { 58 | ...process.env, 59 | COMPANION_PORT: port, 60 | COMPANION_SECRET: 'development', 61 | COMPANION_PREAUTH_SECRET: 'development', 62 | COMPANION_ALLOW_LOCAL_URLS: 'true', 63 | COMPANION_LOGGER_PROCESS_NAME: name, 64 | }, 65 | }) 66 | return Object.defineProperty(cp, 'then', { 67 | __proto__: null, 68 | writable: true, 69 | configurable: true, 70 | value: Promise.prototype.then.bind(new Promise((resolve, reject) => { 71 | cp.on('exit', (code) => { 72 | if (code === 0) resolve(cp) 73 | else reject(new Error(`Non-zero exit code: ${code}`)) 74 | }) 75 | cp.on('error', reject) 76 | })), 77 | }) 78 | } 79 | 80 | const hosts = Array.from({ length: numInstances }, (_, index) => { 81 | const port = companionStartPort + index; 82 | return { index, port } 83 | }) 84 | 85 | console.log('Starting companion instances on ports', hosts.map(({ port }) => port)) 86 | 87 | const companions = hosts.map(({ index, port }) => startCompanion({ name: `companion${index}`, port })) 88 | 89 | let loadBalancer 90 | try { 91 | loadBalancer = createLoadBalancer(hosts.map(({ port }) => `http://localhost:${port}`)) 92 | await Promise.all(companions) 93 | } finally { 94 | loadBalancer?.close() 95 | companions.forEach((companion) => companion.kill()) 96 | } 97 | -------------------------------------------------------------------------------- /e2e/generate-test.mjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import prompts from 'prompts' 3 | import fs from 'node:fs/promises' 4 | 5 | function dedent (strings, ...parts) { 6 | const nonSpacingChar = /\S/m.exec(strings[0]) 7 | if (nonSpacingChar == null) return '' 8 | 9 | const indent = nonSpacingChar.index - strings[0].lastIndexOf('\n', nonSpacingChar.index) - 1 10 | const dedentEachLine = str => str.split('\n').map((line, i) => line.slice(i && indent)).join('\n') 11 | let returnLines = dedentEachLine(strings[0].slice(nonSpacingChar.index), indent) 12 | for (let i = 1; i < strings.length; i++) { 13 | returnLines += String(parts[i - 1]) + dedentEachLine(strings[i], indent) 14 | } 15 | return returnLines 16 | } 17 | 18 | const packageNames = await fs.readdir(new URL('../packages/@JSIMg', import.meta.url)) 19 | const unwantedPackages = ['core', 'companion', 'redux-dev-tools', 'utils'] 20 | 21 | const { name } = await prompts({ 22 | type: 'text', 23 | name: 'name', 24 | message: 'What should the name of the test be (e.g `dashboard-tus`)?', 25 | validate: (value) => /^[a-z|-]+$/i.test(value), 26 | }) 27 | 28 | const { packages } = await prompts({ 29 | type: 'multiselect', 30 | name: 'packages', 31 | message: 'What packages do you want to test?', 32 | hint: '@JSIMg/core is automatically included', 33 | choices: packageNames 34 | .filter((pkg) => !unwantedPackages.includes(pkg)) 35 | .map((pkg) => ({ title: pkg, value: pkg })), 36 | }) 37 | 38 | const camelcase = (str) => str 39 | .toLowerCase() 40 | .replace(/([-][a-z])/g, (group) => group.toUpperCase().replace('-', '')) 41 | 42 | const html = dedent` 43 | 44 | 45 | 46 | 47 | ${name} 48 | 49 | 50 | 51 |
52 | 53 | 54 | ` 55 | 56 | const testUrl = new URL(`cypress/integration/${name}.spec.ts`, import.meta.url) 57 | const test = dedent` 58 | describe('${name}', () => { 59 | beforeEach(() => { 60 | cy.visit('/${name}') 61 | }) 62 | }) 63 | ` 64 | const htmlUrl = new URL(`clients/${name}/index.html`, import.meta.url) 65 | 66 | 67 | const appUrl = new URL(`clients/${name}/app.js`, import.meta.url) 68 | const app = dedent` 69 | import JSIMg from '@JSIMg/core' 70 | ${packages.map((pgk) => `import ${camelcase(pgk)} from '@JSIMg/${pgk}'`).join('\n')} 71 | 72 | const JSIMg = new JSIMg() 73 | ${packages.map((pkg) => `.use(${camelcase(pkg)})`).join('\n\t')} 74 | 75 | window.JSIMg = JSIMg 76 | ` 77 | 78 | await fs.writeFile(testUrl, test) 79 | await fs.mkdir(new URL(`clients/${name}`, import.meta.url)) 80 | await fs.writeFile(htmlUrl, html) 81 | await fs.writeFile(appUrl, app) 82 | 83 | const homeUrl = new URL('clients/index.html', import.meta.url) 84 | const home = await fs.readFile(homeUrl, 'utf8') 85 | const newHome = home.replace( 86 | '', 87 | `
  • ${name}
  • \n `, 88 | ) 89 | await fs.writeFile(homeUrl, newHome) 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | # Clone this file to `.env` and edit the clone. 2 | 3 | NODE_ENV=development 4 | 5 | # Companion 6 | # ======================= 7 | COMPANION_DATADIR=./output 8 | COMPANION_DOMAIN=localhost:3020 9 | COMPANION_PROTOCOL=http 10 | COMPANION_PORT=3020 11 | COMPANION_CLIENT_ORIGINS= 12 | COMPANION_SECRET=development 13 | COMPANION_PREAUTH_SECRET=development2 14 | 15 | # NOTE: Only enable this in development. Enabling it in production is a security risk 16 | COMPANION_ALLOW_LOCAL_URLS=true 17 | 18 | # to enable S3 19 | COMPANION_AWS_KEY="YOUR AWS KEY" 20 | COMPANION_AWS_SECRET="YOUR AWS SECRET" 21 | # specifying a secret file will override a directly set secret 22 | # COMPANION_AWS_SECRET_FILE="PATH/TO/AWS/SECRET/FILE" 23 | COMPANION_AWS_BUCKET="YOUR AWS S3 BUCKET" 24 | COMPANION_AWS_REGION="AWS REGION" 25 | COMPANION_AWS_PREFIX="OPTIONAL PREFIX" 26 | # to enable S3 Transfer Acceleration (default: false) 27 | # COMPANION_AWS_USE_ACCELERATE_ENDPOINT="false" 28 | # to set X-Amz-Expires query param in presigned urls (in seconds, default: 800) 29 | # COMPANION_AWS_EXPIRES="800" 30 | # to set a canned ACL for uploaded objects: https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl 31 | # COMPANION_AWS_ACL="public-read" 32 | 33 | COMPANION_BOX_KEY=*** 34 | COMPANION_BOX_SECRET=*** 35 | 36 | COMPANION_DROPBOX_KEY=*** 37 | COMPANION_DROPBOX_SECRET=*** 38 | 39 | COMPANION_GOOGLE_KEY=*** 40 | COMPANION_GOOGLE_SECRET=*** 41 | 42 | COMPANION_INSTAGRAM_KEY=*** 43 | COMPANION_INSTAGRAM_SECRET=*** 44 | 45 | COMPANION_FACEBOOK_KEY=*** 46 | COMPANION_FACEBOOK_SECRET=*** 47 | 48 | COMPANION_ZOOM_KEY=*** 49 | COMPANION_ZOOM_SECRET=*** 50 | 51 | COMPANION_UNSPLASH_KEY=*** 52 | COMPANION_UNSPLASH_SECRET=*** 53 | 54 | COMPANION_ONEDRIVE_KEY=*** 55 | COMPANION_ONEDRIVE_SECRET=**** 56 | 57 | # To test dynamic Oauth against local companion (which is pointless but allows us to test it without Transloadit's servers), enable these: 58 | #COMPANION_GOOGLE_KEYS_ENDPOINT=http://localhost:3020/drive/test-dynamic-oauth-credentials?secret=development 59 | #COMPANION_TEST_DYNAMIC_OAUTH_CREDENTIALS=true 60 | #COMPANION_TEST_DYNAMIC_OAUTH_CREDENTIALS_SECRET=development 61 | 62 | 63 | # Development environment 64 | # ======================= 65 | 66 | VITE_UPLOADER=tus 67 | # VITE_UPLOADER=s3 68 | # VITE_UPLOADER=s3-multipart 69 | # xhr will use protocol 'multipart' in companion, if used with a remote service, e.g. google drive. 70 | # If local upload will use browser XHR 71 | # VITE_UPLOADER=xhr 72 | # VITE_UPLOADER=transloadit 73 | # VITE_UPLOADER=transloadit-s3 74 | # VITE_UPLOADER=transloadit-xhr 75 | 76 | VITE_COMPANION_URL=http://localhost:3020 77 | # See also Transloadit.COMPANION_PATTERN 78 | VITE_COMPANION_ALLOWED_HOSTS="\.transloadit\.com$" 79 | VITE_TUS_ENDPOINT=https://tusd.tusdemo.net/files/ 80 | VITE_XHR_ENDPOINT=https://xhr-server.herokuapp.com/upload 81 | 82 | # If you want to test dynamic Oauth 83 | # VITE_COMPANION_GOOGLE_DRIVE_KEYS_PARAMS_CREDENTIALS_NAME=companion-google-drive 84 | 85 | VITE_TRANSLOADIT_KEY=*** 86 | VITE_TRANSLOADIT_TEMPLATE=*** 87 | VITE_TRANSLOADIT_SERVICE_URL=https://api2.transloadit.com 88 | # Fill in if you want requests sent to Transloadit to be signed: 89 | # VITE_TRANSLOADIT_SECRET=*** 90 | -------------------------------------------------------------------------------- /packages/@JSIMg/companion-client/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @uppy/companion-client 2 | 3 | ## 3.6.1 4 | 5 | Released: 2023-11-24 6 | Included in: Uppy v3.20.0 7 | 8 | - @uppy/companion-client: fix log type error (Mikael Finstad / #4766) 9 | - @uppy/companion-client: revert breaking change (Antoine du Hamel / #4801) 10 | 11 | ## 3.5.0 12 | 13 | Released: 2023-10-20 14 | Included in: Uppy v3.18.0 15 | 16 | - @uppy/companion-client: fixup! Added Companion OAuth Key type (Murderlon / #4668) 17 | - @uppy/companion-client: Added Companion OAuth Key type (Chris Pratt / #4668) 18 | 19 | ## 3.4.1 20 | 21 | Released: 2023-09-29 22 | Included in: Uppy v3.17.0 23 | 24 | - @uppy/companion-client: fix a refresh token race condition (Mikael Finstad / #4695) 25 | 26 | ## 3.4.0 27 | 28 | Released: 2023-09-05 29 | Included in: Uppy v3.15.0 30 | 31 | - @uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/companion-client,@uppy/core,@uppy/tus,@uppy/utils,@uppy/xhr-upload: Move remote file upload logic into companion-client (Merlijn Vos / #4573) 32 | 33 | ## 3.3.0 34 | 35 | Released: 2023-08-15 36 | Included in: Uppy v3.14.0 37 | 38 | - @uppy/companion-client,@uppy/provider-views: make authentication optional (Dominik Schmidt / #4556) 39 | 40 | ## 3.1.2 41 | 42 | Released: 2023-04-04 43 | Included in: Uppy v3.7.0 44 | 45 | - @uppy/companion-client: do not open socket more than once (Artur Paikin) 46 | 47 | ## 3.1.1 48 | 49 | Released: 2022-11-16 50 | Included in: Uppy v3.3.1 51 | 52 | - @uppy/companion-client: treat `*` the same as missing header (Antoine du Hamel / #4221) 53 | 54 | ## 3.1.0 55 | 56 | Released: 2022-11-10 57 | Included in: Uppy v3.3.0 58 | 59 | - @uppy/companion-client: add support for `AbortSignal` (Antoine du Hamel / #4201) 60 | - @uppy/companion-client: prevent preflight race condition (Mikael Finstad / #4182) 61 | 62 | ## 3.0.2 63 | 64 | Released: 2022-09-25 65 | Included in: Uppy v3.1.0 66 | 67 | - @uppy/audio,@uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/box,@uppy/companion-client,@uppy/companion,@uppy/compressor,@uppy/core,@uppy/dashboard,@uppy/drag-drop,@uppy/drop-target,@uppy/dropbox,@uppy/facebook,@uppy/file-input,@uppy/form,@uppy/golden-retriever,@uppy/google-drive,@uppy/image-editor,@uppy/informer,@uppy/instagram,@uppy/locales,@uppy/onedrive,@uppy/progress-bar,@uppy/provider-views,@uppy/react,@uppy/redux-dev-tools,@uppy/remote-sources,@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: add missing entries to changelog for individual packages (Antoine du Hamel / #4092) 68 | 69 | ## 3.0.0 70 | 71 | Released: 2022-08-22 72 | Included in: Uppy v3.0.0 73 | 74 | - Switch to ESM 75 | 76 | ## 2.2.0 77 | 78 | Released: 2022-05-30 79 | Included in: Uppy v2.11.0 80 | 81 | - @uppy/companion-client: Revert "Revert "@uppy/companion-client: refactor to ESM"" (Antoine du Hamel / #3730) 82 | 83 | ## 2.1.0 84 | 85 | Released: 2022-05-14 86 | Included in: Uppy v2.10.0 87 | 88 | - @uppy/companion-client: refactor to ESM (Antoine du Hamel / #3693) 89 | 90 | ## 2.0.6 91 | 92 | Released: 2022-04-07 93 | Included in: Uppy v2.9.2 94 | 95 | - @uppy/aws-s3,@uppy/companion-client,@uppy/transloadit,@uppy/utils: Propagate `isNetworkError` through error wrappers (Renée Kooi / #3620) 96 | 97 | ## 2.0.5 98 | 99 | Released: 2022-02-14 100 | Included in: Uppy v2.5.0 101 | 102 | - @uppy/companion-client,@uppy/companion,@uppy/provider-views,@uppy/robodog: Finishing touches on Companion dynamic Oauth (Renée Kooi / #2802) 103 | -------------------------------------------------------------------------------- /packages/@JSIMg/companion-client/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import type { Uppy } from '@uppy/core' 2 | 3 | /** 4 | * Async storage interface, similar to `localStorage`. This can be used to 5 | * implement custom storages for authentication tokens. 6 | */ 7 | export interface TokenStorage { 8 | setItem: (key: string, value: string) => Promise 9 | getItem: (key: string) => Promise 10 | removeItem: (key: string) => Promise 11 | } 12 | 13 | type CompanionHeaders = Record 14 | 15 | type CompanionKeys = { 16 | key: string 17 | credentialsName: string 18 | } 19 | 20 | export interface RequestClientOptions { 21 | companionUrl: string 22 | companionHeaders?: CompanionHeaders 23 | companionCookiesRule?: RequestCredentials 24 | companionKeysParams?: CompanionKeys 25 | } 26 | 27 | type RequestOptions = { 28 | skipPostResponse?: boolean 29 | signal?: AbortSignal 30 | } 31 | 32 | export class RequestClient { 33 | constructor(uppy: Uppy, opts: RequestClientOptions) 34 | 35 | readonly hostname: string 36 | 37 | setCompanionHeaders(headers: CompanionHeaders): void 38 | 39 | get(path: string, options?: RequestOptions): Promise 40 | 41 | /** @deprecated use option bag instead */ 42 | get(path: string, skipPostResponse: boolean): Promise 43 | 44 | post( 45 | path: string, 46 | data: Record, 47 | options?: RequestOptions, 48 | ): Promise 49 | 50 | /** @deprecated use option bag instead */ 51 | post( 52 | path: string, 53 | data: Record, 54 | skipPostResponse: boolean, 55 | ): Promise 56 | 57 | delete( 58 | path: string, 59 | data?: Record, 60 | options?: RequestOptions, 61 | ): Promise 62 | 63 | /** @deprecated use option bag instead */ 64 | delete( 65 | path: string, 66 | data: Record, 67 | skipPostResponse: boolean, 68 | ): Promise 69 | } 70 | 71 | /** 72 | * Options for Providers that can be passed in by Uppy users through 73 | * Plugin constructors. 74 | */ 75 | export interface PublicProviderOptions extends RequestClientOptions { 76 | companionAllowedHosts?: string | RegExp | Array 77 | } 78 | 79 | /** 80 | * Options for Providers, including internal options that Plugins can set. 81 | */ 82 | export interface ProviderOptions extends PublicProviderOptions { 83 | provider: string 84 | name?: string 85 | pluginId: string 86 | } 87 | 88 | export class Provider extends RequestClient { 89 | constructor(uppy: Uppy, opts: ProviderOptions) 90 | 91 | checkAuth(): Promise 92 | 93 | authUrl(): string 94 | 95 | fileUrl(id: string): string 96 | 97 | list(directory: string): Promise 98 | 99 | logout(redirect?: string): Promise 100 | 101 | static initPlugin( 102 | plugin: unknown, 103 | opts: Record, 104 | defaultOpts?: Record, 105 | ): void 106 | } 107 | 108 | export interface SocketOptions { 109 | target: string 110 | autoOpen?: boolean 111 | } 112 | 113 | export class Socket { 114 | readonly isOpen: boolean 115 | 116 | constructor(opts: SocketOptions) 117 | 118 | open(): void 119 | 120 | close(): void 121 | 122 | send(action: string, payload: unknown): void 123 | 124 | on(action: string, handler: (param: any) => void): void 125 | 126 | once(action: string, handler: (param: any) => void): void 127 | 128 | emit(action: string, payload: (param: any) => void): void 129 | } 130 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/src/RecordingScreen.jsx: -------------------------------------------------------------------------------- 1 | /* eslint-disable jsx-a11y/media-has-caption */ 2 | import { h } from 'preact' 3 | import { useEffect, useRef } from 'preact/hooks' 4 | import RecordButton from './RecordButton.jsx' 5 | import RecordingLength from './RecordingLength.jsx' 6 | import AudioSourceSelect from './AudioSourceSelect.jsx' 7 | import AudioOscilloscope from './audio-oscilloscope/index.js' 8 | import SubmitButton from './SubmitButton.jsx' 9 | import DiscardButton from './DiscardButton.jsx' 10 | 11 | export default function RecordingScreen (props) { 12 | const { 13 | stream, 14 | recordedAudio, 15 | onStop, 16 | recording, 17 | supportsRecording, 18 | audioSources, 19 | showAudioSourceDropdown, 20 | onSubmit, 21 | i18n, 22 | onStartRecording, 23 | onStopRecording, 24 | onDiscardRecordedAudio, 25 | recordingLengthSeconds, 26 | } = props 27 | 28 | const canvasEl = useRef(null) 29 | const oscilloscope = useRef(null) 30 | 31 | // componentDidMount / componentDidUnmount 32 | useEffect(() => { 33 | return () => { 34 | oscilloscope.current = null 35 | onStop() 36 | } 37 | }, [onStop]) 38 | 39 | // componentDidUpdate 40 | useEffect(() => { 41 | if (!recordedAudio) { 42 | oscilloscope.current = new AudioOscilloscope(canvasEl.current, { 43 | canvas: { 44 | width: 600, 45 | height: 600, 46 | }, 47 | canvasContext: { 48 | lineWidth: 2, 49 | fillStyle: 'rgb(0,0,0)', 50 | strokeStyle: 'green', 51 | }, 52 | }) 53 | oscilloscope.current.draw() 54 | 55 | if (stream) { 56 | const audioContext = new AudioContext() 57 | const source = audioContext.createMediaStreamSource(stream) 58 | oscilloscope.current.addSource(source) 59 | } 60 | } 61 | }, [recordedAudio, stream]) 62 | 63 | const hasRecordedAudio = recordedAudio != null 64 | const shouldShowRecordButton = !hasRecordedAudio && supportsRecording 65 | const shouldShowAudioSourceDropdown = showAudioSourceDropdown 66 | && !hasRecordedAudio 67 | && audioSources 68 | && audioSources.length > 1 69 | 70 | return ( 71 |
    72 |
    73 | {hasRecordedAudio 74 | ? ( 75 |
    87 |
    88 |
    89 | {shouldShowAudioSourceDropdown 90 | ? AudioSourceSelect(props) 91 | : null} 92 |
    93 |
    94 | {shouldShowRecordButton && ( 95 | 101 | )} 102 | 103 | {hasRecordedAudio && } 104 | 105 | {hasRecordedAudio && } 106 |
    107 | 108 |
    109 | {!hasRecordedAudio && ( 110 | 111 | )} 112 |
    113 |
    114 |
    115 | ) 116 | } 117 | -------------------------------------------------------------------------------- /bin/build-css.js: -------------------------------------------------------------------------------- 1 | const sass = require('sass'); 2 | const postcss = require('postcss'); 3 | const autoprefixer = require('autoprefixer'); 4 | const postcssLogical = require('postcss-logical'); 5 | const postcssDirPseudoClass = require('postcss-dir-pseudo-class'); 6 | const cssnano = require('cssnano'); 7 | const { promisify } = require('node:util'); 8 | const fs = require('node:fs'); 9 | const path = require('node:path'); 10 | const resolve = require('resolve'); 11 | const glob = promisify(require('glob')); 12 | 13 | const renderScss = promisify(sass.render); 14 | const { mkdir, writeFile } = fs.promises; 15 | 16 | const cwd = process.cwd(); 17 | let chalk; 18 | 19 | function getPostCSSPlugins() { 20 | return [ 21 | autoprefixer, 22 | postcssLogical(), 23 | postcssDirPseudoClass(), 24 | ]; 25 | } 26 | 27 | async function compileSCSS(file) { 28 | const importedFiles = new Set(); 29 | const scssResult = await renderScss({ 30 | file, 31 | importer: createImporter(importedFiles), 32 | }); 33 | return scssResult.css; 34 | } 35 | 36 | function createImporter(importedFiles) { 37 | return (url, from, done) => { 38 | resolve(url, { 39 | basedir: path.dirname(from), 40 | filename: from, 41 | extensions: ['.scss'], 42 | }, (err, resolved) => { 43 | if (err) { 44 | done(err); 45 | return; 46 | } 47 | 48 | const realpath = fs.realpathSync(resolved); 49 | if (importedFiles.has(realpath)) { 50 | done({ contents: '' }); 51 | return; 52 | } 53 | importedFiles.add(realpath); 54 | done({ file: realpath }); 55 | }); 56 | }; 57 | } 58 | 59 | async function processCSS(css, file, plugins) { 60 | const result = await postcss(plugins).process(css, { from: file }); 61 | result.warnings().forEach(warn => console.warn(warn.toString())); 62 | return result; 63 | } 64 | 65 | async function handleCSSOutput(file, css) { 66 | const outputDir = path.join(path.dirname(file), '../dist'); 67 | const outfile = isJSIMgPackage(file) ? 68 | `${outputDir}/JSIMg.css` : 69 | `${outputDir}/style.css`; 70 | 71 | await saveCSS(outfile, css); 72 | const minifiedCSS = await minifyCSS(outfile, css); 73 | await saveCSS(outfile.replace(/\.css$/, '.min.css'), minifiedCSS); 74 | } 75 | 76 | async function handleCSSOutput(file, css) { 77 | const outputDir = path.join(path.dirname(file), '../dist'); 78 | const outfile = isFibcousPackage(file) ? 79 | `${outputDir}/fibcous.css` : 80 | `${outputDir}/style.css`; 81 | 82 | await saveAndLogCSS(outfile, css); 83 | const minifiedCSS = await minifyCSS(outfile, css); 84 | await saveAndLogCSS(outfile.replace(/\.css$/, '.min.css'), minifiedCSS); 85 | } 86 | 87 | 88 | 89 | async function saveCSS(outfile, css) { 90 | try { 91 | await mkdir(path.dirname(outfile), { recursive: true }); 92 | await writeFile(outfile, css); 93 | console.info(chalk.green('✓ CSS Processed:'), chalk.magenta(path.relative(cwd, outfile))); 94 | } catch (err) { 95 | throw new Error(`Failed to write file ${outfile}: ${err.message}`); 96 | } 97 | } 98 | 99 | function isJSIMgPackage(file) { 100 | return path.normalize(file).includes('packages/JSIMg/'); 101 | } 102 | 103 | async function minifyCSS(outfile, css) { 104 | const result = await postcss([cssnano({ safe: true })]).process(css, { from: outfile }); 105 | result.warnings().forEach(warn => console.warn(warn.toString())); 106 | return result.css; 107 | } 108 | 109 | async function compileCSS() { 110 | ({ default: chalk } = await import('chalk')); 111 | const files = await glob('packages/{,@JSIMg/}*/src/style.scss'); 112 | const plugins = getPostCSSPlugins(); 113 | 114 | for (const file of files) { 115 | try { 116 | const css = await compileSCSS(file); 117 | const postcssResult = await processCSS(css, file, plugins); 118 | await handleCSSOutput(file, postcssResult.css); 119 | } catch (err) { 120 | console.error(chalk.red(`✗ Error processing ${file}:`), chalk.red(err.message)); 121 | } 122 | } 123 | 124 | console.info(chalk.yellow('CSS Bundles OK')); 125 | }; 126 | 127 | compileCSS().catch(err => { 128 | console.error(chalk.red('✗ Global Error:'), chalk.red(err.message)); 129 | }); 130 | -------------------------------------------------------------------------------- /bin/build-lib.js: -------------------------------------------------------------------------------- 1 | const babel = require('@babel/core'); 2 | const path = require('node:path'); 3 | 4 | const t = require('@babel/types'); 5 | const { promisify } = require('node:util'); 6 | const glob = promisify(require('glob')); 7 | const fs = require('node:fs'); 8 | 9 | const { mkdir, stat, writeFile } = fs.promises; 10 | 11 | const PACKAGE_JSON_IMPORT = /^\..*\/package.json$/; 12 | const SOURCE = 'packages/{*,@JSIMg/*}/src/**/*.{js,ts}?(x)'; 13 | 14 | const IGNORE = /\.test\.[jt]s$|__mocks__|svelte|angular|companion\//; 15 | const META_FILES = [ 16 | 'babel.config.js', 17 | 'package.json', 18 | 'package-lock.json', 19 | 'yarn.lock', 20 | 'bin/build-lib.js', 21 | ]; 22 | 23 | function lastModified (file, createParentDir = false) { 24 | return stat(file).then((s) => s.mtime, async (err) => { 25 | if (err.code === 'ENOENT') { 26 | if (createParentDir) { 27 | await mkdir(path.dirname(file), { recursive: true }) 28 | } 29 | return 0 30 | } 31 | throw err 32 | }) 33 | }; 34 | 35 | const versionCache = new Map(); 36 | 37 | async function preparePackage (file) { 38 | const packageFolder = file.slice(0, file.indexOf('/src/')) 39 | if (versionCache.has(packageFolder)) return 40 | 41 | // eslint-disable-next-line import/no-dynamic-require, global-require 42 | const { version } = require(path.join(__dirname, '..', packageFolder, 'package.json')) 43 | if (process.env.FRESH) { 44 | // in case it hasn't been done before. 45 | await mkdir(path.join(packageFolder, 'lib'), { recursive: true }) 46 | } 47 | versionCache.set(packageFolder, version) 48 | }; 49 | 50 | const nonJSImport = /^\.\.?\/.+\.([jt]sx|ts)$/; 51 | // eslint-disable-next-line no-shadow 52 | function rewriteNonJSImportsToJS (path) { 53 | const match = nonJSImport.exec(path.node.source.value) 54 | if (match) { 55 | // eslint-disable-next-line no-param-reassign 56 | path.node.source.value = `${match[0].slice(0, -match[1].length)}js` 57 | } 58 | }; 59 | 60 | async function buildLib () { 61 | const metaMtimes = await Promise.all(META_FILES.map((filename) => lastModified(path.join(__dirname, '..', filename)))) 62 | const metaMtime = Math.max(...metaMtimes) 63 | 64 | const files = await glob(SOURCE) 65 | /* eslint-disable no-continue */ 66 | for (const file of files) { 67 | if (IGNORE.test(file)) { 68 | continue 69 | } 70 | await preparePackage(file) 71 | const libFile = file.replace('/src/', '/lib/').replace(/\.[jt]sx?$/, '.js') 72 | 73 | // on a fresh build, rebuild everything. 74 | if (!process.env.FRESH) { 75 | const [srcMtime, libMtime] = await Promise.all([ 76 | lastModified(file), 77 | lastModified(libFile, true), 78 | ]) 79 | if (srcMtime < libMtime && metaMtime < libMtime) { 80 | continue 81 | } 82 | } 83 | 84 | const plugins = [{ 85 | visitor: { 86 | // eslint-disable-next-line no-shadow 87 | ImportDeclaration (path) { 88 | rewriteNonJSImportsToJS(path) 89 | if (PACKAGE_JSON_IMPORT.test(path.node.source.value) 90 | && path.node.specifiers.length === 1 91 | && path.node.specifiers[0].type === 'ImportDefaultSpecifier') { 92 | const version = versionCache.get(file.slice(0, file.indexOf('/src/'))) 93 | if (version != null) { 94 | const [{ local }] = path.node.specifiers 95 | path.replaceWith( 96 | t.variableDeclaration('const', [t.variableDeclarator(local, 97 | t.objectExpression([ 98 | t.objectProperty(t.stringLiteral('version'), t.stringLiteral(version)), 99 | ]))]), 100 | ) 101 | } 102 | } 103 | }, 104 | 105 | ExportAllDeclaration: rewriteNonJSImportsToJS, 106 | }, 107 | }] 108 | const isTSX = file.endsWith('.tsx') 109 | if (isTSX || file.endsWith('.ts')) { plugins.push(['@babel/plugin-transform-typescript', { disallowAmbiguousJSXLike: true, isTSX, jsxPragma: 'h' }]) } 110 | 111 | const { code, map } = await babel.transformFileAsync(file, { sourceMaps: true, plugins }) 112 | const [{ default: chalk }] = await Promise.all([ 113 | import('chalk'), 114 | writeFile(libFile, code), 115 | writeFile(`${libFile}.map`, JSON.stringify(map)), 116 | ]) 117 | console.log(chalk.green('Compiled lib:'), chalk.magenta(libFile)) 118 | } 119 | /* eslint-enable no-continue */ 120 | }; 121 | 122 | console.log('Using Babel version:', require('@babel/core/package.json').version) 123 | 124 | buildLib().catch((err) => { 125 | console.error(err) 126 | process.exit(1) 127 | }); 128 | -------------------------------------------------------------------------------- /packages/@JSIMg/audio/src/style.scss: -------------------------------------------------------------------------------- 1 | @import '@uppy/core/src/_utils.scss'; 2 | @import '@uppy/core/src/_variables.scss'; 3 | 4 | .uppy-Audio-container { 5 | width: 100%; 6 | height: 100%; 7 | display: flex; 8 | justify-content: center; 9 | align-items: center; 10 | flex-direction: column; 11 | } 12 | 13 | .uppy-Audio-audioContainer { 14 | display: flex; 15 | width: 100%; 16 | height: 100%; 17 | background-color: $gray-300; 18 | position: relative; 19 | justify-content: center; 20 | align-items: center; 21 | } 22 | 23 | .uppy-Audio-player { 24 | width: 85%; 25 | border-radius: 12px; 26 | } 27 | 28 | .uppy-Audio-canvas { 29 | width: 100%; 30 | height: 100%; 31 | position: absolute; 32 | top: 0; 33 | left: 0; 34 | right: 0; 35 | bottom: 0; 36 | } 37 | 38 | .uppy-Audio-footer { 39 | width: 100%; 40 | // min-height: 75px; 41 | display: flex; 42 | flex-wrap: wrap; 43 | align-items: center; 44 | justify-content: space-between; 45 | padding: 20px 20px; 46 | } 47 | 48 | .uppy-Audio-audioSourceContainer { 49 | width: 100%; 50 | flex-grow: 0; 51 | } 52 | 53 | .uppy-size--lg .uppy-Audio-audioSourceContainer { 54 | width: 33%; 55 | margin: 0; // vertical alignment handled by the flexbox wrapper 56 | } 57 | 58 | .uppy-Audio-audioSource-select { 59 | display: block; 60 | font-size: 16px; 61 | line-height: 1.2; 62 | padding: 0.4em 1em 0.3em 0.4em; 63 | width: 100%; 64 | max-width: 90%; 65 | border: 1px solid $gray-600; 66 | background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23757575%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E'); 67 | background-repeat: no-repeat; 68 | background-position: 69 | right 0.4em top 50%, 70 | 0 0; 71 | background-size: 72 | 0.65em auto, 73 | 100%; 74 | margin: auto; 75 | margin-bottom: 10px; 76 | white-space: nowrap; 77 | text-overflow: ellipsis; 78 | 79 | .uppy-size--lg & { 80 | font-size: 14px; 81 | margin-bottom: 0; 82 | } 83 | } 84 | 85 | .uppy-Audio-audioSource-select::-ms-expand { 86 | display: none; 87 | } 88 | 89 | .uppy-Audio-buttonContainer { 90 | width: 50%; 91 | margin-left: 25%; 92 | text-align: center; 93 | flex: 1; 94 | } 95 | 96 | .uppy-size--lg .uppy-Audio-buttonContainer { 97 | width: 34%; 98 | margin-left: 0; 99 | } 100 | 101 | .uppy-Audio-recordingLength { 102 | width: 25%; 103 | flex-grow: 0; 104 | color: $gray-600; 105 | font-family: $font-family-mono; 106 | text-align: right; 107 | } 108 | 109 | .uppy-size--lg .uppy-Audio-recordingLength { 110 | width: 33%; 111 | } 112 | 113 | .uppy-Audio-button { 114 | @include blue-border-focus; 115 | width: 45px; 116 | height: 45px; 117 | border-radius: 50%; 118 | background-color: $red; 119 | color: $white; 120 | cursor: pointer; 121 | transition: all 0.3s; 122 | 123 | &:hover { 124 | background-color: darken($red, 5%); 125 | } 126 | 127 | [data-uppy-theme='dark'] & { 128 | @include blue-border-focus--dark; 129 | } 130 | } 131 | 132 | .uppy-Audio-button--submit { 133 | background-color: $blue; 134 | margin: 0 12px; 135 | 136 | &:hover { 137 | background-color: darken($blue, 5%); 138 | } 139 | } 140 | 141 | .uppy-Audio-button svg { 142 | width: 26px; 143 | height: 26px; 144 | max-width: 100%; 145 | max-height: 100%; 146 | display: inline-block; 147 | vertical-align: text-top; 148 | overflow: hidden; 149 | fill: currentColor; 150 | } 151 | 152 | .uppy-size--md .uppy-Audio-button { 153 | width: 60px; 154 | height: 60px; 155 | } 156 | 157 | .uppy-Audio-permissons { 158 | padding: 15px; 159 | display: flex; 160 | align-items: center; 161 | justify-content: center; 162 | flex-flow: column wrap; 163 | height: 100%; 164 | flex: 1; 165 | } 166 | 167 | .uppy-Audio-permissons p { 168 | max-width: 450px; 169 | line-height: 1.3; 170 | text-align: center; 171 | line-height: 1.45; 172 | color: $gray-500; 173 | margin: 0; 174 | } 175 | 176 | .uppy-Audio-permissonsIcon svg { 177 | width: 100px; 178 | height: 75px; 179 | color: $gray-400; 180 | margin-bottom: 30px; 181 | } 182 | 183 | .uppy-Audio-title { 184 | font-size: 22px; 185 | line-height: 1.35; 186 | font-weight: 400; 187 | margin: 0; 188 | margin-bottom: 5px; 189 | padding: 0 15px; 190 | max-width: 500px; 191 | text-align: center; 192 | color: $gray-800; 193 | 194 | [data-uppy-theme='dark'] & { 195 | color: $gray-200; 196 | } 197 | } 198 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3-multipart/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import type { BasePlugin, PluginOptions, UppyFile } from '@uppy/core' 2 | 3 | type MaybePromise = T | Promise 4 | 5 | export type AwsS3UploadParameters = 6 | | { 7 | method: 'POST' 8 | url: string 9 | fields: Record 10 | expires?: number 11 | headers?: Record 12 | } 13 | | { 14 | method?: 'PUT' 15 | url: string 16 | fields?: Record 17 | expires?: number 18 | headers?: Record 19 | } 20 | 21 | export interface AwsS3Part { 22 | PartNumber?: number 23 | Size?: number 24 | ETag?: string 25 | } 26 | /** 27 | * @deprecated use {@link AwsS3UploadParameters} instead 28 | */ 29 | export interface AwsS3SignedPart { 30 | url: string 31 | headers?: Record 32 | } 33 | export interface AwsS3STSResponse { 34 | credentials: { 35 | AccessKeyId: string 36 | SecretAccessKey: string 37 | SessionToken: string 38 | Expiration?: string 39 | } 40 | bucket: string 41 | region: string 42 | } 43 | 44 | type AWSS3NonMultipartWithCompanionMandatory = { 45 | getUploadParameters?: never 46 | } 47 | 48 | type AWSS3NonMultipartWithoutCompanionMandatory = { 49 | getUploadParameters: (file: UppyFile) => MaybePromise 50 | } 51 | type AWSS3NonMultipartWithCompanion = AWSS3WithCompanion & 52 | AWSS3NonMultipartWithCompanionMandatory & { 53 | shouldUseMultipart: false 54 | createMultipartUpload?: never 55 | listParts?: never 56 | signPart?: never 57 | abortMultipartUpload?: never 58 | completeMultipartUpload?: never 59 | } 60 | 61 | type AWSS3NonMultipartWithoutCompanion = AWSS3WithoutCompanion & 62 | AWSS3NonMultipartWithoutCompanionMandatory & { 63 | shouldUseMultipart: false 64 | createMultipartUpload?: never 65 | listParts?: never 66 | signPart?: never 67 | abortMultipartUpload?: never 68 | completeMultipartUpload?: never 69 | } 70 | 71 | type AWSS3MultipartWithoutCompanionMandatory = { 72 | getChunkSize?: (file: UppyFile) => number 73 | createMultipartUpload: ( 74 | file: UppyFile, 75 | ) => MaybePromise<{ uploadId: string; key: string }> 76 | listParts: ( 77 | file: UppyFile, 78 | opts: { uploadId: string; key: string; signal: AbortSignal }, 79 | ) => MaybePromise 80 | abortMultipartUpload: ( 81 | file: UppyFile, 82 | opts: { uploadId: string; key: string; signal: AbortSignal }, 83 | ) => MaybePromise 84 | completeMultipartUpload: ( 85 | file: UppyFile, 86 | opts: { 87 | uploadId: string 88 | key: string 89 | parts: AwsS3Part[] 90 | signal: AbortSignal 91 | }, 92 | ) => MaybePromise<{ location?: string }> 93 | } & ( 94 | | { 95 | signPart: ( 96 | file: UppyFile, 97 | opts: { 98 | uploadId: string 99 | key: string 100 | partNumber: number 101 | body: Blob 102 | signal: AbortSignal 103 | }, 104 | ) => MaybePromise 105 | } 106 | | { 107 | /** @deprecated Use signPart instead */ 108 | prepareUploadParts: ( 109 | file: UppyFile, 110 | partData: { 111 | uploadId: string 112 | key: string 113 | parts: [{ number: number; chunk: Blob }] 114 | }, 115 | ) => MaybePromise<{ 116 | presignedUrls: Record 117 | headers?: Record> 118 | }> 119 | } 120 | ) 121 | type AWSS3MultipartWithoutCompanion = AWSS3WithoutCompanion & 122 | AWSS3MultipartWithoutCompanionMandatory & { 123 | shouldUseMultipart?: true 124 | getUploadParameters?: never 125 | } 126 | 127 | type AWSS3MultipartWithCompanion = AWSS3WithCompanion & 128 | Partial & { 129 | shouldUseMultipart?: true 130 | getUploadParameters?: never 131 | } 132 | 133 | type AWSS3MaybeMultipartWithCompanion = AWSS3WithCompanion & 134 | Partial & 135 | AWSS3NonMultipartWithCompanionMandatory & { 136 | shouldUseMultipart: (file: UppyFile) => boolean 137 | } 138 | 139 | type AWSS3MaybeMultipartWithoutCompanion = AWSS3WithoutCompanion & 140 | AWSS3MultipartWithoutCompanionMandatory & 141 | AWSS3NonMultipartWithoutCompanionMandatory & { 142 | shouldUseMultipart: (file: UppyFile) => boolean 143 | } 144 | 145 | type AWSS3WithCompanion = { 146 | companionUrl: string 147 | companionHeaders?: Record 148 | companionCookiesRule?: string 149 | getTemporarySecurityCredentials?: true 150 | } 151 | type AWSS3WithoutCompanion = { 152 | companionUrl?: never 153 | companionHeaders?: never 154 | companionCookiesRule?: never 155 | getTemporarySecurityCredentials?: (options?: { 156 | signal?: AbortSignal 157 | }) => MaybePromise 158 | } 159 | 160 | interface _AwsS3MultipartOptions extends PluginOptions { 161 | allowedMetaFields?: string[] | null 162 | limit?: number 163 | retryDelays?: number[] | null 164 | } 165 | 166 | export type AwsS3MultipartOptions = _AwsS3MultipartOptions & 167 | ( 168 | | AWSS3NonMultipartWithCompanion 169 | | AWSS3NonMultipartWithoutCompanion 170 | | AWSS3MultipartWithCompanion 171 | | AWSS3MultipartWithoutCompanion 172 | | AWSS3MaybeMultipartWithCompanion 173 | | AWSS3MaybeMultipartWithoutCompanion 174 | ) 175 | 176 | declare class AwsS3Multipart extends BasePlugin {} 177 | 178 | export default AwsS3Multipart 179 | -------------------------------------------------------------------------------- /packages/@JSIMg/companion-client/src/Socket.test.js: -------------------------------------------------------------------------------- 1 | import { afterEach, beforeEach, vi, describe, it, expect } from 'vitest' 2 | import UppySocket from './Socket.js' 3 | 4 | describe('Socket', () => { 5 | let webSocketConstructorSpy 6 | let webSocketCloseSpy 7 | let webSocketSendSpy 8 | 9 | beforeEach(() => { 10 | webSocketConstructorSpy = vi.fn() 11 | webSocketCloseSpy = vi.fn() 12 | webSocketSendSpy = vi.fn() 13 | 14 | globalThis.WebSocket = class WebSocket { 15 | constructor (target) { 16 | webSocketConstructorSpy(target) 17 | } 18 | 19 | // eslint-disable-next-line class-methods-use-this 20 | close (args) { 21 | webSocketCloseSpy(args) 22 | } 23 | 24 | // eslint-disable-next-line class-methods-use-this 25 | send (json) { 26 | webSocketSendSpy(json) 27 | } 28 | 29 | triggerOpen () { 30 | this.onopen() 31 | } 32 | 33 | triggerClose () { 34 | this.onclose() 35 | } 36 | } 37 | }) 38 | afterEach(() => { 39 | globalThis.WebSocket = undefined 40 | }) 41 | 42 | it('should expose a class', () => { 43 | expect(UppySocket.name).toEqual('UppySocket') 44 | expect( 45 | new UppySocket({ 46 | target: 'foo', 47 | }) instanceof UppySocket, 48 | ) 49 | }) 50 | 51 | it('should setup a new WebSocket', () => { 52 | new UppySocket({ target: 'foo' }) // eslint-disable-line no-new 53 | expect(webSocketConstructorSpy.mock.calls[0][0]).toEqual('foo') 54 | }) 55 | 56 | it('should send a message via the websocket if the connection is open', () => { 57 | const uppySocket = new UppySocket({ target: 'foo' }) 58 | const webSocketInstance = uppySocket[Symbol.for('uppy test: getSocket')]() 59 | webSocketInstance.triggerOpen() 60 | 61 | uppySocket.send('bar', 'boo') 62 | expect(webSocketSendSpy.mock.calls.length).toEqual(1) 63 | expect(webSocketSendSpy.mock.calls[0]).toEqual([ 64 | JSON.stringify({ action: 'bar', payload: 'boo' }), 65 | ]) 66 | }) 67 | 68 | it('should queue the message for the websocket if the connection is not open', () => { 69 | const uppySocket = new UppySocket({ target: 'foo' }) 70 | 71 | uppySocket.send('bar', 'boo') 72 | expect(uppySocket[Symbol.for('uppy test: getQueued')]()).toEqual([{ action: 'bar', payload: 'boo' }]) 73 | expect(webSocketSendSpy.mock.calls.length).toEqual(0) 74 | }) 75 | 76 | it('should queue any messages for the websocket if the connection is not open, then send them when the connection is open', () => { 77 | const uppySocket = new UppySocket({ target: 'foo' }) 78 | const webSocketInstance = uppySocket[Symbol.for('uppy test: getSocket')]() 79 | 80 | uppySocket.send('bar', 'boo') 81 | uppySocket.send('moo', 'baa') 82 | expect(uppySocket[Symbol.for('uppy test: getQueued')]()).toEqual([ 83 | { action: 'bar', payload: 'boo' }, 84 | { action: 'moo', payload: 'baa' }, 85 | ]) 86 | expect(webSocketSendSpy.mock.calls.length).toEqual(0) 87 | 88 | webSocketInstance.triggerOpen() 89 | 90 | expect(uppySocket[Symbol.for('uppy test: getQueued')]()).toEqual([]) 91 | expect(webSocketSendSpy.mock.calls.length).toEqual(2) 92 | expect(webSocketSendSpy.mock.calls[0]).toEqual([ 93 | JSON.stringify({ action: 'bar', payload: 'boo' }), 94 | ]) 95 | expect(webSocketSendSpy.mock.calls[1]).toEqual([ 96 | JSON.stringify({ action: 'moo', payload: 'baa' }), 97 | ]) 98 | }) 99 | 100 | it('should start queuing any messages when the websocket connection is closed', () => { 101 | const uppySocket = new UppySocket({ target: 'foo' }) 102 | const webSocketInstance = uppySocket[Symbol.for('uppy test: getSocket')]() 103 | webSocketInstance.triggerOpen() 104 | uppySocket.send('bar', 'boo') 105 | expect(uppySocket[Symbol.for('uppy test: getQueued')]()).toEqual([]) 106 | 107 | webSocketInstance.triggerClose() 108 | uppySocket.send('bar', 'boo') 109 | expect(uppySocket[Symbol.for('uppy test: getQueued')]()).toEqual([{ action: 'bar', payload: 'boo' }]) 110 | }) 111 | 112 | it('should close the websocket when it is force closed', () => { 113 | const uppySocket = new UppySocket({ target: 'foo' }) 114 | const webSocketInstance = uppySocket[Symbol.for('uppy test: getSocket')]() 115 | webSocketInstance.triggerOpen() 116 | 117 | uppySocket.close() 118 | expect(webSocketCloseSpy.mock.calls.length).toEqual(1) 119 | }) 120 | 121 | it('should be able to subscribe to messages received on the websocket', () => { 122 | const uppySocket = new UppySocket({ target: 'foo' }) 123 | const webSocketInstance = uppySocket[Symbol.for('uppy test: getSocket')]() 124 | 125 | const emitterListenerMock = vi.fn() 126 | uppySocket.on('hi', emitterListenerMock) 127 | 128 | webSocketInstance.triggerOpen() 129 | webSocketInstance.onmessage({ 130 | data: JSON.stringify({ action: 'hi', payload: 'ho' }), 131 | }) 132 | expect(emitterListenerMock.mock.calls).toEqual([ 133 | ['ho', undefined, undefined, undefined, undefined, undefined], 134 | ]) 135 | }) 136 | 137 | it('should be able to emit messages and subscribe to them', () => { 138 | const uppySocket = new UppySocket({ target: 'foo' }) 139 | 140 | const emitterListenerMock = vi.fn() 141 | uppySocket.on('hi', emitterListenerMock) 142 | 143 | uppySocket.emit('hi', 'ho') 144 | uppySocket.emit('hi', 'ho') 145 | uppySocket.emit('hi', 'off to work we go') 146 | 147 | expect(emitterListenerMock.mock.calls).toEqual([ 148 | ['ho', undefined, undefined, undefined, undefined, undefined], 149 | ['ho', undefined, undefined, undefined, undefined, undefined], 150 | [ 151 | 'off to work we go', 152 | undefined, 153 | undefined, 154 | undefined, 155 | undefined, 156 | undefined, 157 | ], 158 | ]) 159 | }) 160 | 161 | it('should be able to subscribe to the first event for a particular action', () => { 162 | const uppySocket = new UppySocket({ target: 'foo' }) 163 | 164 | const emitterListenerMock = vi.fn() 165 | uppySocket.once('hi', emitterListenerMock) 166 | 167 | uppySocket.emit('hi', 'ho') 168 | uppySocket.emit('hi', 'ho') 169 | uppySocket.emit('hi', 'off to work we go') 170 | 171 | expect(emitterListenerMock.mock.calls.length).toEqual(1) 172 | expect(emitterListenerMock.mock.calls).toEqual([ 173 | ['ho', undefined, undefined, undefined, undefined, undefined], 174 | ]) 175 | }) 176 | }) 177 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3-multipart/src/createSignedURL.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Create a canonical request by concatenating the following strings, separated 3 | * by newline characters. This helps ensure that the signature that you 4 | * calculate and the signature that AWS calculates can match. 5 | * 6 | * @see https://docs.aws.amazon.com/IAM/latest/UserGuide/create-signed-request.html#create-canonical-request 7 | * 8 | * @param {object} param0 9 | * @param {string} param0.method – The HTTP method. 10 | * @param {string} param0.CanonicalUri – The URI-encoded version of the absolute 11 | * path component URL (everything between the host and the question mark 12 | * character (?) that starts the query string parameters). If the absolute path 13 | * is empty, use a forward slash character (/). 14 | * @param {string} param0.CanonicalQueryString – The URL-encoded query string 15 | * parameters, separated by ampersands (&). Percent-encode reserved characters, 16 | * including the space character. Encode names and values separately. If there 17 | * are empty parameters, append the equals sign to the parameter name before 18 | * encoding. After encoding, sort the parameters alphabetically by key name. If 19 | * there is no query string, use an empty string (""). 20 | * @param {Record} param0.SignedHeaders – The request headers, 21 | * that will be signed, and their values, separated by newline characters. 22 | * For the values, trim any leading or trailing spaces, convert sequential 23 | * spaces to a single space, and separate the values for a multi-value header 24 | * using commas. You must include the host header (HTTP/1.1), and any x-amz-* 25 | * headers in the signature. You can optionally include other standard headers 26 | * in the signature, such as content-type. 27 | * @param {string} param0.HashedPayload – A string created using the payload in 28 | * the body of the HTTP request as input to a hash function. This string uses 29 | * lowercase hexadecimal characters. If the payload is empty, use an empty 30 | * string as the input to the hash function. 31 | * @returns {string} 32 | */ 33 | function createCanonicalRequest ({ 34 | method = 'PUT', 35 | CanonicalUri = '/', 36 | CanonicalQueryString = '', 37 | SignedHeaders, 38 | HashedPayload, 39 | }) { 40 | const headerKeys = Object.keys(SignedHeaders).map(k => k.toLowerCase()).sort() 41 | return [ 42 | method, 43 | CanonicalUri, 44 | CanonicalQueryString, 45 | ...headerKeys.map(k => `${k}:${SignedHeaders[k]}`), 46 | '', 47 | headerKeys.join(';'), 48 | HashedPayload, 49 | ].join('\n') 50 | } 51 | 52 | const ec = new TextEncoder() 53 | const algorithm = { name: 'HMAC', hash: 'SHA-256' } 54 | 55 | async function digest (data) { 56 | const { subtle } = globalThis.crypto 57 | return subtle.digest(algorithm.hash, ec.encode(data)) 58 | } 59 | 60 | async function generateHmacKey (secret) { 61 | const { subtle } = globalThis.crypto 62 | return subtle.importKey('raw', typeof secret === 'string' ? ec.encode(secret) : secret, algorithm, false, ['sign']) 63 | } 64 | 65 | function arrayBufferToHexString (arrayBuffer) { 66 | const byteArray = new Uint8Array(arrayBuffer) 67 | let hexString = '' 68 | for (let i = 0; i < byteArray.length; i++) { 69 | hexString += byteArray[i].toString(16).padStart(2, '0') 70 | } 71 | return hexString 72 | } 73 | 74 | async function hash (key, data) { 75 | const { subtle } = globalThis.crypto 76 | return subtle.sign(algorithm, await generateHmacKey(key), ec.encode(data)) 77 | } 78 | 79 | /** 80 | * @see https://docs.aws.amazon.com/IAM/latest/UserGuide/create-signed-request.html 81 | * @param {Record} param0 82 | * @returns {Promise} the signed URL 83 | */ 84 | export default async function createSignedURL ({ 85 | accountKey, accountSecret, sessionToken, 86 | bucketName, 87 | Key, Region, 88 | expires, 89 | uploadId, partNumber, 90 | }) { 91 | const Service = 's3' 92 | const host = `${bucketName}.${Service}.${Region}.amazonaws.com` 93 | const CanonicalUri = `/${encodeURI(Key)}` 94 | const payload = 'UNSIGNED-PAYLOAD' 95 | 96 | const requestDateTime = new Date().toISOString().replace(/[-:]|\.\d+/g, '') // YYYYMMDDTHHMMSSZ 97 | const date = requestDateTime.slice(0, 8) // YYYYMMDD 98 | const scope = `${date}/${Region}/${Service}/aws4_request` 99 | 100 | const url = new URL(`https://${host}${CanonicalUri}`) 101 | // N.B.: URL search params needs to be added in the ASCII order 102 | url.searchParams.set('X-Amz-Algorithm', 'AWS4-HMAC-SHA256') 103 | url.searchParams.set('X-Amz-Content-Sha256', payload) 104 | url.searchParams.set('X-Amz-Credential', `${accountKey}/${scope}`) 105 | url.searchParams.set('X-Amz-Date', requestDateTime) 106 | url.searchParams.set('X-Amz-Expires', expires) 107 | // We are signing on the client, so we expect there's going to be a session token: 108 | url.searchParams.set('X-Amz-Security-Token', sessionToken) 109 | url.searchParams.set('X-Amz-SignedHeaders', 'host') 110 | // Those two are present only for Multipart Uploads: 111 | if (partNumber) url.searchParams.set('partNumber', partNumber) 112 | if (uploadId) url.searchParams.set('uploadId', uploadId) 113 | url.searchParams.set('x-id', partNumber && uploadId ? 'UploadPart' : 'PutObject') 114 | 115 | // Step 1: Create a canonical request 116 | const canonical = createCanonicalRequest({ 117 | CanonicalUri, 118 | CanonicalQueryString: url.search.slice(1), 119 | SignedHeaders: { 120 | host, 121 | }, 122 | HashedPayload: payload, 123 | }) 124 | 125 | // Step 2: Create a hash of the canonical request 126 | const hashedCanonical = arrayBufferToHexString(await digest(canonical)) 127 | 128 | // Step 3: Create a string to sign 129 | const stringToSign = [ 130 | `AWS4-HMAC-SHA256`, // The algorithm used to create the hash of the canonical request. 131 | requestDateTime, // The date and time used in the credential scope. 132 | scope, // The credential scope. This restricts the resulting signature to the specified Region and service. 133 | hashedCanonical, // The hash of the canonical request. 134 | ].join('\n') 135 | 136 | // Step 4: Calculate the signature 137 | const kDate = await hash(`AWS4${accountSecret}`, date) 138 | const kRegion = await hash(kDate, Region) 139 | const kService = await hash(kRegion, Service) 140 | const kSigning = await hash(kService, 'aws4_request') 141 | const signature = arrayBufferToHexString(await hash(kSigning, stringToSign)) 142 | 143 | // Step 5: Add the signature to the request 144 | url.searchParams.set('X-Amz-Signature', signature) 145 | 146 | return url 147 | } 148 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @uppy/aws-s3 2 | 3 | ## 3.3.0 4 | 5 | Released: 2023-09-05 6 | Included in: Uppy v3.15.0 7 | 8 | - @uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/companion-client,@uppy/core,@uppy/tus,@uppy/utils,@uppy/xhr-upload: Move remote file upload logic into companion-client (Merlijn Vos / #4573) 9 | 10 | ## 3.2.3 11 | 12 | Released: 2023-08-23 13 | Included in: Uppy v3.14.1 14 | 15 | - @uppy/aws-s3-multipart,@uppy/aws-s3: allow empty objects for `fields` types (Antoine du Hamel / #4631) 16 | 17 | ## 3.2.2 18 | 19 | Released: 2023-08-15 20 | Included in: Uppy v3.14.0 21 | 22 | - @uppy/aws-s3,@uppy/aws-s3-multipart: update types (Antoine du Hamel / #4611) 23 | - @uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/companion,@uppy/transloadit,@uppy/xhr-upload: use uppercase HTTP method names (Antoine du Hamel / #4612) 24 | - @uppy/aws-s3,@uppy/aws-s3-multipart: update types (bdirito / #4576) 25 | - @uppy/aws-s3,@uppy/tus,@uppy/xhr-upload: Invoke headers function for remote uploads (Dominik Schmidt / #4596) 26 | 27 | ## 3.2.1 28 | 29 | Released: 2023-07-06 30 | Included in: Uppy v3.11.0 31 | 32 | - @uppy/aws-s3: fix remote uploads (Antoine du Hamel / #4546) 33 | 34 | ## 3.2.0 35 | 36 | Released: 2023-06-19 37 | Included in: Uppy v3.10.0 38 | 39 | - @uppy/aws-s3: add `shouldUseMultipart` option (Antoine du Hamel / #4299) 40 | - @uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/tus,@uppy/utils,@uppy/xhr-upload: When file is removed (or all are canceled), controller.abort queued requests (Artur Paikin / #4504) 41 | 42 | ## 3.1.1 43 | 44 | Released: 2023-05-02 45 | Included in: Uppy v3.9.0 46 | 47 | - @uppy/aws-s3: deprecate `timeout` option (Antoine du Hamel / #4298) 48 | 49 | ## 3.0.6 50 | 51 | Released: 2023-04-04 52 | Included in: Uppy v3.7.0 53 | 54 | - @uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/tus,@uppy/xhr-upload: make sure that we reset serverToken when an upload fails (Mikael Finstad / #4376) 55 | - @uppy/aws-s3: Update types (Minh Hieu / #4294) 56 | 57 | ## 3.0.5 58 | 59 | Released: 2023-01-26 60 | Included in: Uppy v3.4.0 61 | 62 | - @uppy/aws-s3: fix: add https:// to digital oceans link (Le Gia Hoang / #4165) 63 | 64 | ## 3.0.4 65 | 66 | Released: 2022-10-24 67 | Included in: Uppy v3.2.2 68 | 69 | - @uppy/aws-s3,@uppy/tus,@uppy/xhr-upload: replace `this.getState().files` with `this.uppy.getState().files` (Artur Paikin / #4167) 70 | 71 | ## 3.0.3 72 | 73 | Released: 2022-10-19 74 | Included in: Uppy v3.2.0 75 | 76 | - @uppy/aws-s3,@uppy/xhr-upload: fix `Cannot mark a queued request as done` in `MiniXHRUpload` (Antoine du Hamel / #4151) 77 | 78 | ## 3.0.2 79 | 80 | Released: 2022-09-25 81 | Included in: Uppy v3.1.0 82 | 83 | - @uppy/audio,@uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/box,@uppy/companion-client,@uppy/companion,@uppy/compressor,@uppy/core,@uppy/dashboard,@uppy/drag-drop,@uppy/drop-target,@uppy/dropbox,@uppy/facebook,@uppy/file-input,@uppy/form,@uppy/golden-retriever,@uppy/google-drive,@uppy/image-editor,@uppy/informer,@uppy/instagram,@uppy/locales,@uppy/onedrive,@uppy/progress-bar,@uppy/provider-views,@uppy/react,@uppy/redux-dev-tools,@uppy/remote-sources,@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: add missing entries to changelog for individual packages (Antoine du Hamel / #4092) 84 | 85 | ## 3.0.0 86 | 87 | Released: 2022-08-22 88 | Included in: Uppy v3.0.0 89 | 90 | - @uppy/aws-s3,@uppy/tus,@uppy/xhr-upload: @uppy/tus, @uppy/xhr-upload, @uppy/aws-s3: `metaFields` -> `allowedMetaFields` (Merlijn Vos / #4023) 91 | - @uppy/aws-s3: aws-s3: fix incorrect comparison for `file-removed` (Merlijn Vos / #3962) 92 | - Switch to ESM 93 | 94 | ## 3.0.0-beta.3 95 | 96 | Released: 2022-08-16 97 | Included in: Uppy v3.0.0-beta.5 98 | 99 | - @uppy/aws-s3: Export AwsS3UploadParameters & AwsS3Options interfaces (Antonina Vertsinskaya / #3956) 100 | 101 | ## 3.0.0-beta.2 102 | 103 | Released: 2022-07-27 104 | Included in: Uppy v3.0.0-beta.3 105 | 106 | - @uppy/aws-s3,@uppy/core,@uppy/dashboard,@uppy/store-redux,@uppy/xhr-upload: upgrade `nanoid` to v4 (Antoine du Hamel / #3904) 107 | 108 | ## 2.2.1 109 | 110 | Released: 2022-06-07 111 | Included in: Uppy v2.12.0 112 | 113 | - @uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/tus: queue socket token requests for remote files (Merlijn Vos / #3797) 114 | 115 | ## 2.2.0 116 | 117 | Released: 2022-05-30 118 | Included in: Uppy v2.11.0 119 | 120 | - @uppy/angular,@uppy/audio,@uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/box,@uppy/core,@uppy/dashboard,@uppy/drag-drop,@uppy/dropbox,@uppy/facebook,@uppy/file-input,@uppy/form,@uppy/golden-retriever,@uppy/google-drive,@uppy/image-editor,@uppy/informer,@uppy/instagram,@uppy/onedrive,@uppy/progress-bar,@uppy/react,@uppy/redux-dev-tools,@uppy/robodog,@uppy/screen-capture,@uppy/status-bar,@uppy/store-default,@uppy/store-redux,@uppy/thumbnail-generator,@uppy/transloadit,@uppy/tus,@uppy/unsplash,@uppy/url,@uppy/vue,@uppy/webcam,@uppy/xhr-upload,@uppy/zoom: doc: update bundler recommendation (Antoine du Hamel / #3763) 121 | - @uppy/aws-s3: fix JSDoc type error (Antoine du Hamel / #3785) 122 | - @uppy/aws-s3: refactor to ESM (Antoine du Hamel / #3673) 123 | 124 | ## 2.1.0 125 | 126 | Released: 2022-05-14 127 | Included in: Uppy v2.10.0 128 | 129 | - @uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/core,@uppy/react,@uppy/transloadit,@uppy/tus,@uppy/xhr-upload: proposal: Cancel assemblies optional (Mikael Finstad / #3575) 130 | 131 | ## 2.0.9 132 | 133 | Released: 2022-04-07 134 | Included in: Uppy v2.9.2 135 | 136 | - @uppy/aws-s3,@uppy/companion-client,@uppy/transloadit,@uppy/utils: Propagate `isNetworkError` through error wrappers (Renée Kooi / #3620) 137 | 138 | ## 2.0.8 139 | 140 | Released: 2022-03-16 141 | Included in: Uppy v2.8.0 142 | 143 | - @uppy/aws-s3: fix wrong events being sent to companion (Mikael Finstad / #3576) 144 | 145 | ## 2.0.7 146 | 147 | Released: 2021-12-09 148 | Included in: Uppy v2.3.1 149 | 150 | - @uppy/aws-s3,@uppy/core,@uppy/dashboard,@uppy/store-redux,@uppy/xhr-upload: deps: use `nanoid/non-secure` to workaround react-native limitation (Antoine du Hamel / #3350) 151 | 152 | ## 2.0.6 153 | 154 | Released: 2021-12-07 155 | Included in: Uppy v2.3.0 156 | 157 | - @uppy/aws-s3,@uppy/box,@uppy/core,@uppy/dashboard,@uppy/drag-drop,@uppy/dropbox,@uppy/facebook,@uppy/file-input,@uppy/google-drive,@uppy/image-editor,@uppy/instagram,@uppy/locales,@uppy/onedrive,@uppy/screen-capture,@uppy/status-bar,@uppy/thumbnail-generator,@uppy/transloadit,@uppy/url,@uppy/webcam,@uppy/xhr-upload,@uppy/zoom: Refactor locale scripts & generate types and docs (Merlijn Vos / #3276) 158 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3-multipart/src/MultipartUploader.js: -------------------------------------------------------------------------------- 1 | import { AbortController } from '@uppy/utils/lib/AbortController' 2 | 3 | const MB = 1024 * 1024 4 | 5 | const defaultOptions = { 6 | getChunkSize (file) { 7 | return Math.ceil(file.size / 10000) 8 | }, 9 | onProgress () {}, 10 | onPartComplete () {}, 11 | onSuccess () {}, 12 | onError (err) { 13 | throw err 14 | }, 15 | } 16 | 17 | function ensureInt (value) { 18 | if (typeof value === 'string') { 19 | return parseInt(value, 10) 20 | } 21 | if (typeof value === 'number') { 22 | return value 23 | } 24 | throw new TypeError('Expected a number') 25 | } 26 | 27 | export const pausingUploadReason = Symbol('pausing upload, not an actual error') 28 | 29 | /** 30 | * A MultipartUploader instance is used per file upload to determine whether a 31 | * upload should be done as multipart or as a regular S3 upload 32 | * (based on the user-provided `shouldUseMultipart` option value) and to manage 33 | * the chunk splitting. 34 | */ 35 | class MultipartUploader { 36 | #abortController = new AbortController() 37 | 38 | /** @type {import("../types/chunk").Chunk[]} */ 39 | #chunks 40 | 41 | /** @type {{ uploaded: number, etag?: string, done?: boolean }[]} */ 42 | #chunkState 43 | 44 | /** 45 | * The (un-chunked) data to upload. 46 | * 47 | * @type {Blob} 48 | */ 49 | #data 50 | 51 | /** @type {import("@uppy/core").UppyFile} */ 52 | #file 53 | 54 | /** @type {boolean} */ 55 | #uploadHasStarted = false 56 | 57 | /** @type {(err?: Error | any) => void} */ 58 | #onError 59 | 60 | /** @type {() => void} */ 61 | #onSuccess 62 | 63 | /** @type {import('../types/index').AwsS3MultipartOptions["shouldUseMultipart"]} */ 64 | #shouldUseMultipart 65 | 66 | /** @type {boolean} */ 67 | #isRestoring 68 | 69 | #onReject = (err) => (err?.cause === pausingUploadReason ? null : this.#onError(err)) 70 | 71 | #maxMultipartParts = 10_000 72 | 73 | #minPartSize = 5 * MB 74 | 75 | constructor (data, options) { 76 | this.options = { 77 | ...defaultOptions, 78 | ...options, 79 | } 80 | // Use default `getChunkSize` if it was null or something 81 | this.options.getChunkSize ??= defaultOptions.getChunkSize 82 | 83 | this.#data = data 84 | this.#file = options.file 85 | this.#onSuccess = this.options.onSuccess 86 | this.#onError = this.options.onError 87 | this.#shouldUseMultipart = this.options.shouldUseMultipart 88 | 89 | // When we are restoring an upload, we already have an UploadId and a Key. Otherwise 90 | // we need to call `createMultipartUpload` to get an `uploadId` and a `key`. 91 | // Non-multipart uploads are not restorable. 92 | this.#isRestoring = options.uploadId && options.key 93 | 94 | this.#initChunks() 95 | } 96 | 97 | // initChunks checks the user preference for using multipart uploads (opts.shouldUseMultipart) 98 | // and calculates the optimal part size. When using multipart part uploads every part except for the last has 99 | // to be at least 5 MB and there can be no more than 10K parts. 100 | // This means we sometimes need to change the preferred part size from the user in order to meet these requirements. 101 | #initChunks () { 102 | const fileSize = this.#data.size 103 | const shouldUseMultipart = typeof this.#shouldUseMultipart === 'function' 104 | ? this.#shouldUseMultipart(this.#file) 105 | : Boolean(this.#shouldUseMultipart) 106 | 107 | if (shouldUseMultipart && fileSize > this.#minPartSize) { 108 | // At least 5MB per request: 109 | let chunkSize = Math.max(this.options.getChunkSize(this.#data), this.#minPartSize) 110 | let arraySize = Math.floor(fileSize / chunkSize) 111 | 112 | // At most 10k requests per file: 113 | if (arraySize > this.#maxMultipartParts) { 114 | arraySize = this.#maxMultipartParts 115 | chunkSize = fileSize / this.#maxMultipartParts 116 | } 117 | this.#chunks = Array(arraySize) 118 | 119 | for (let offset = 0, j = 0; offset < fileSize; offset += chunkSize, j++) { 120 | const end = Math.min(fileSize, offset + chunkSize) 121 | 122 | // Defer data fetching/slicing until we actually need the data, because it's slow if we have a lot of files 123 | const getData = () => { 124 | const i2 = offset 125 | return this.#data.slice(i2, end) 126 | } 127 | 128 | this.#chunks[j] = { 129 | getData, 130 | onProgress: this.#onPartProgress(j), 131 | onComplete: this.#onPartComplete(j), 132 | shouldUseMultipart, 133 | } 134 | if (this.#isRestoring) { 135 | const size = offset + chunkSize > fileSize ? fileSize - offset : chunkSize 136 | // setAsUploaded is called by listPart, to keep up-to-date the 137 | // quantity of data that is left to actually upload. 138 | this.#chunks[j].setAsUploaded = () => { 139 | this.#chunks[j] = null 140 | this.#chunkState[j].uploaded = size 141 | } 142 | } 143 | } 144 | } else { 145 | this.#chunks = [{ 146 | getData: () => this.#data, 147 | onProgress: this.#onPartProgress(0), 148 | onComplete: this.#onPartComplete(0), 149 | shouldUseMultipart, 150 | }] 151 | } 152 | 153 | this.#chunkState = this.#chunks.map(() => ({ uploaded: 0 })) 154 | } 155 | 156 | #createUpload () { 157 | this 158 | .options.companionComm.uploadFile(this.#file, this.#chunks, this.#abortController.signal) 159 | .then(this.#onSuccess, this.#onReject) 160 | this.#uploadHasStarted = true 161 | } 162 | 163 | #resumeUpload () { 164 | this 165 | .options.companionComm.resumeUploadFile(this.#file, this.#chunks, this.#abortController.signal) 166 | .then(this.#onSuccess, this.#onReject) 167 | } 168 | 169 | #onPartProgress = (index) => (ev) => { 170 | if (!ev.lengthComputable) return 171 | 172 | this.#chunkState[index].uploaded = ensureInt(ev.loaded) 173 | 174 | const totalUploaded = this.#chunkState.reduce((n, c) => n + c.uploaded, 0) 175 | this.options.onProgress(totalUploaded, this.#data.size) 176 | } 177 | 178 | #onPartComplete = (index) => (etag) => { 179 | // This avoids the net::ERR_OUT_OF_MEMORY in Chromium Browsers. 180 | this.#chunks[index] = null 181 | this.#chunkState[index].etag = etag 182 | this.#chunkState[index].done = true 183 | 184 | const part = { 185 | PartNumber: index + 1, 186 | ETag: etag, 187 | } 188 | this.options.onPartComplete(part) 189 | } 190 | 191 | #abortUpload () { 192 | this.#abortController.abort() 193 | this.options.companionComm.abortFileUpload(this.#file).catch((err) => this.options.log(err)) 194 | } 195 | 196 | start () { 197 | if (this.#uploadHasStarted) { 198 | if (!this.#abortController.signal.aborted) this.#abortController.abort(pausingUploadReason) 199 | this.#abortController = new AbortController() 200 | this.#resumeUpload() 201 | } else if (this.#isRestoring) { 202 | this.options.companionComm.restoreUploadFile(this.#file, { uploadId: this.options.uploadId, key: this.options.key }) 203 | this.#resumeUpload() 204 | } else { 205 | this.#createUpload() 206 | } 207 | } 208 | 209 | pause () { 210 | this.#abortController.abort(pausingUploadReason) 211 | // Swap it out for a new controller, because this instance may be resumed later. 212 | this.#abortController = new AbortController() 213 | } 214 | 215 | abort (opts = undefined) { 216 | if (opts?.really) this.#abortUpload() 217 | else this.pause() 218 | } 219 | 220 | // TODO: remove this in the next major 221 | get chunkState () { 222 | return this.#chunkState 223 | } 224 | } 225 | 226 | export default MultipartUploader 227 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3/src/MiniXHRUpload.js: -------------------------------------------------------------------------------- 1 | import { nanoid } from 'nanoid/non-secure' 2 | import EventManager from '@uppy/utils/lib/EventManager' 3 | import ProgressTimeout from '@uppy/utils/lib/ProgressTimeout' 4 | import ErrorWithCause from '@uppy/utils/lib/ErrorWithCause' 5 | import NetworkError from '@uppy/utils/lib/NetworkError' 6 | import isNetworkError from '@uppy/utils/lib/isNetworkError' 7 | import { internalRateLimitedQueue } from '@uppy/utils/lib/RateLimitedQueue' 8 | 9 | // See XHRUpload 10 | function buildResponseError (xhr, error) { 11 | if (isNetworkError(xhr)) return new NetworkError(error, xhr) 12 | 13 | const err = new ErrorWithCause('Upload error', { cause: error }) 14 | err.request = xhr 15 | return err 16 | } 17 | 18 | // See XHRUpload 19 | function setTypeInBlob (file) { 20 | const dataWithUpdatedType = file.data.slice(0, file.data.size, file.meta.type) 21 | return dataWithUpdatedType 22 | } 23 | 24 | function addMetadata (formData, meta, opts) { 25 | const allowedMetaFields = Array.isArray(opts.allowedMetaFields) 26 | ? opts.allowedMetaFields 27 | // Send along all fields by default. 28 | : Object.keys(meta) 29 | allowedMetaFields.forEach((item) => { 30 | formData.append(item, meta[item]) 31 | }) 32 | } 33 | 34 | function createFormDataUpload (file, opts) { 35 | const formPost = new FormData() 36 | 37 | addMetadata(formPost, file.meta, opts) 38 | 39 | const dataWithUpdatedType = setTypeInBlob(file) 40 | 41 | if (file.name) { 42 | formPost.append(opts.fieldName, dataWithUpdatedType, file.meta.name) 43 | } else { 44 | formPost.append(opts.fieldName, dataWithUpdatedType) 45 | } 46 | 47 | return formPost 48 | } 49 | 50 | const createBareUpload = file => file.data 51 | 52 | export default class MiniXHRUpload { 53 | constructor (uppy, opts) { 54 | this.uppy = uppy 55 | this.opts = { 56 | validateStatus (status) { 57 | return status >= 200 && status < 300 58 | }, 59 | ...opts, 60 | } 61 | 62 | this.requests = opts[internalRateLimitedQueue] 63 | this.uploaderEvents = Object.create(null) 64 | this.i18n = opts.i18n 65 | } 66 | 67 | getOptions (file) { 68 | const { uppy } = this 69 | 70 | const overrides = uppy.getState().xhrUpload 71 | const opts = { 72 | ...this.opts, 73 | ...(overrides || {}), 74 | ...(file.xhrUpload || {}), 75 | headers: { 76 | ...this.opts.headers, 77 | ...overrides?.headers, 78 | ...file.xhrUpload?.headers, 79 | }, 80 | } 81 | 82 | return opts 83 | } 84 | 85 | #addEventHandlerForFile (eventName, fileID, eventHandler) { 86 | this.uploaderEvents[fileID].on(eventName, (fileOrID) => { 87 | // TODO (major): refactor Uppy events to consistently send file objects (or consistently IDs) 88 | // We created a generic `addEventListenerForFile` but not all events 89 | // use file IDs, some use files, so we need to do this weird check. 90 | const id = fileOrID?.id ?? fileOrID 91 | if (fileID === id) eventHandler() 92 | }) 93 | } 94 | 95 | #addEventHandlerIfFileStillExists (eventName, fileID, eventHandler) { 96 | this.uploaderEvents[fileID].on(eventName, (...args) => { 97 | if (this.uppy.getFile(fileID)) eventHandler(...args) 98 | }) 99 | } 100 | 101 | uploadLocalFile (file) { 102 | const opts = this.getOptions(file) 103 | 104 | return new Promise((resolve, reject) => { 105 | // This is done in index.js in the S3 plugin. 106 | // this.uppy.emit('upload-started', file) 107 | 108 | const data = opts.formData 109 | ? createFormDataUpload(file, opts) 110 | : createBareUpload(file, opts) 111 | 112 | const xhr = new XMLHttpRequest() 113 | this.uploaderEvents[file.id] = new EventManager(this.uppy) 114 | 115 | const timer = new ProgressTimeout(opts.timeout, () => { 116 | xhr.abort() 117 | // eslint-disable-next-line no-use-before-define 118 | queuedRequest.done() 119 | const error = new Error(this.i18n('timedOut', { seconds: Math.ceil(opts.timeout / 1000) })) 120 | this.uppy.emit('upload-error', file, error) 121 | reject(error) 122 | }) 123 | 124 | const id = nanoid() 125 | 126 | xhr.upload.addEventListener('loadstart', () => { 127 | this.uppy.log(`[AwsS3/XHRUpload] ${id} started`) 128 | }) 129 | 130 | xhr.upload.addEventListener('progress', (ev) => { 131 | this.uppy.log(`[AwsS3/XHRUpload] ${id} progress: ${ev.loaded} / ${ev.total}`) 132 | // Begin checking for timeouts when progress starts, instead of loading, 133 | // to avoid timing out requests on browser concurrency queue 134 | timer.progress() 135 | 136 | if (ev.lengthComputable) { 137 | this.uppy.emit('upload-progress', file, { 138 | uploader: this, 139 | bytesUploaded: ev.loaded, 140 | bytesTotal: ev.total, 141 | }) 142 | } 143 | }) 144 | 145 | xhr.addEventListener('load', (ev) => { 146 | this.uppy.log(`[AwsS3/XHRUpload] ${id} finished`) 147 | timer.done() 148 | // eslint-disable-next-line no-use-before-define 149 | queuedRequest.done() 150 | if (this.uploaderEvents[file.id]) { 151 | this.uploaderEvents[file.id].remove() 152 | this.uploaderEvents[file.id] = null 153 | } 154 | 155 | if (opts.validateStatus(ev.target.status, xhr.responseText, xhr)) { 156 | const body = opts.getResponseData(xhr.responseText, xhr) 157 | const uploadURL = body[opts.responseUrlFieldName] 158 | 159 | const uploadResp = { 160 | status: ev.target.status, 161 | body, 162 | uploadURL, 163 | } 164 | 165 | this.uppy.emit('upload-success', file, uploadResp) 166 | 167 | if (uploadURL) { 168 | this.uppy.log(`Download ${file.name} from ${uploadURL}`) 169 | } 170 | 171 | return resolve(file) 172 | } 173 | const body = opts.getResponseData(xhr.responseText, xhr) 174 | const error = buildResponseError(xhr, opts.getResponseError(xhr.responseText, xhr)) 175 | 176 | const response = { 177 | status: ev.target.status, 178 | body, 179 | } 180 | 181 | this.uppy.emit('upload-error', file, error, response) 182 | return reject(error) 183 | }) 184 | 185 | xhr.addEventListener('error', () => { 186 | this.uppy.log(`[AwsS3/XHRUpload] ${id} errored`) 187 | timer.done() 188 | // eslint-disable-next-line no-use-before-define 189 | queuedRequest.done() 190 | if (this.uploaderEvents[file.id]) { 191 | this.uploaderEvents[file.id].remove() 192 | this.uploaderEvents[file.id] = null 193 | } 194 | 195 | const error = buildResponseError(xhr, opts.getResponseError(xhr.responseText, xhr)) 196 | this.uppy.emit('upload-error', file, error) 197 | return reject(error) 198 | }) 199 | 200 | xhr.open(opts.method.toUpperCase(), opts.endpoint, true) 201 | // IE10 does not allow setting `withCredentials` and `responseType` 202 | // before `open()` is called. It’s important to set withCredentials 203 | // to a boolean, otherwise React Native crashes 204 | xhr.withCredentials = Boolean(opts.withCredentials) 205 | if (opts.responseType !== '') { 206 | xhr.responseType = opts.responseType 207 | } 208 | 209 | Object.keys(opts.headers).forEach((header) => { 210 | xhr.setRequestHeader(header, opts.headers[header]) 211 | }) 212 | 213 | const queuedRequest = this.requests.run(() => { 214 | xhr.send(data) 215 | return () => { 216 | // eslint-disable-next-line no-use-before-define 217 | timer.done() 218 | xhr.abort() 219 | } 220 | }, { priority: 1 }) 221 | 222 | this.#addEventHandlerForFile('file-removed', file.id, () => { 223 | queuedRequest.abort() 224 | reject(new Error('File removed')) 225 | }) 226 | 227 | this.#addEventHandlerIfFileStillExists('cancel-all', file.id, ({ reason } = {}) => { 228 | if (reason === 'user') { 229 | queuedRequest.abort() 230 | } 231 | reject(new Error('Upload cancelled')) 232 | }) 233 | }) 234 | } 235 | } 236 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "@JSIMg-dev/build", 4 | "version": "1.1.1", 5 | "description": "Learning by repeating and by doing :dog: Thanks to uppy for their open source project to experiment with", 6 | "lint-staged": { 7 | "*.{js,mjs,cjs,jsx}": "eslint --fix", 8 | "*.{ts,mts,cts,tsx}": [ 9 | "eslint --fix", 10 | "prettier -w", 11 | "eslint" 12 | ], 13 | "*.{css,html,json,scss,vue,yaml,yml}": "prettier -w", 14 | "*.md": [ 15 | "remark --silently-ignore -i .remarkignore -foq", 16 | "eslint --fix" 17 | ] 18 | }, 19 | "remarkConfig": { 20 | "plugins": [ 21 | "@JSIMg-dev/remark-lint-JSIMg" 22 | ] 23 | }, 24 | "pre-commit": "lint:staged", 25 | "license": "MIT", 26 | "engines": { 27 | "node": "^16.15.0 || >=18.0.0", 28 | "yarn": "3.5.9" 29 | }, 30 | "packageManager": "yarn@3.6.1+sha224.679d48a4db29f6beed7fe901a71e56b5e0619cdd615e140d9f33ce92", 31 | "workspaces": [ 32 | "examples/*", 33 | "packages/@JSIMg/*", 34 | "packages/@JSIMg/angular/projects/JSIMg/*", 35 | "packages/JSIMg", 36 | "private/*", 37 | "test/endtoend", 38 | "e2e" 39 | ], 40 | "devDependencies": { 41 | "@aws-sdk/client-s3": "^3.338.0", 42 | "@babel/cli": "^7.14.5", 43 | "@babel/core": "^7.14.6", 44 | "@babel/eslint-parser": "^7.11.3", 45 | "@babel/eslint-plugin": "^7.11.3", 46 | "@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5", 47 | "@babel/plugin-proposal-optional-chaining": "^7.16.0", 48 | "@babel/plugin-transform-modules-commonjs": "^7.16.8", 49 | "@babel/plugin-transform-react-jsx": "^7.10.4", 50 | "@babel/plugin-transform-typescript": "^7.22.10", 51 | "@babel/preset-env": "^7.14.7", 52 | "@babel/register": "^7.10.5", 53 | "@babel/types": "^7.17.0", 54 | "@types/jasmine": "file:./private/@types/jasmine", 55 | "@types/jasminewd2": "file:./private/@types/jasmine", 56 | "@typescript-eslint/eslint-plugin": "^5.0.0", 57 | "@typescript-eslint/parser": "^5.0.0", 58 | "@JSIMg-dev/remark-lint-JSIMg": "workspace:*", 59 | "esbuild": "^0.17.1", 60 | "esbuild-plugin-babel": "^0.2.3", 61 | "eslint": "^8.0.0", 62 | "adm-zip": "^0.5.5", 63 | "autoprefixer": "^10.2.6", 64 | "babel-plugin-inline-package-json": "^2.0.0", 65 | "chalk": "^5.0.0", 66 | "concat-stream": "^2.0.0", 67 | "core-js": "~3.24.0", 68 | "cssnano": "^5.0.6", 69 | "dotenv": "^16.0.0", 70 | "eslint-config-prettier": "^9.0.0", 71 | "eslint-config-transloadit": "^2.0.0", 72 | "eslint-plugin-compat": "^4.0.0", 73 | "eslint-plugin-cypress": "^2.12.1", 74 | "eslint-plugin-import": "^2.25.2", 75 | "eslint-plugin-jest": "^27.0.0", 76 | "eslint-plugin-jsdoc": "^40.0.0", 77 | "eslint-plugin-jsx-a11y": "^6.4.1", 78 | "eslint-plugin-markdown": "^3.0.0", 79 | "eslint-plugin-no-only-tests": "^3.1.0", 80 | "eslint-plugin-node": "^11.1.0", 81 | "eslint-plugin-prefer-import": "^0.0.1", 82 | "eslint-plugin-promise": "^6.0.0", 83 | "eslint-plugin-react": "^7.22.0", 84 | "eslint-plugin-react-hooks": "^4.2.0", 85 | "eslint-plugin-unicorn": "^46.0.0", 86 | "github-contributors-list": "^1.2.4", 87 | "glob": "^8.0.0", 88 | "jsdom": "^22.1.0", 89 | "lint-staged": "^13.0.0", 90 | "mime-types": "^2.1.26", 91 | "nodemon": "^2.0.8", 92 | "npm-packlist": "^5.0.0", 93 | "npm-run-all": "^4.1.5", 94 | "onchange": "^7.1.0", 95 | "pacote": "^13.0.0", 96 | "postcss": "^8.4.31", 97 | "postcss-dir-pseudo-class": "^6.0.0", 98 | "postcss-logical": "^5.0.0", 99 | "pre-commit": "^1.2.2", 100 | "prettier": "^3.0.3", 101 | "remark-cli": "^11.0.0", 102 | "resolve": "^1.17.0", 103 | "sass": "^1.29.0", 104 | "start-server-and-test": "^1.14.0", 105 | "stylelint": "^15.0.0", 106 | "stylelint-config-rational-order": "^0.1.2", 107 | "stylelint-config-standard": "^34.0.0", 108 | "stylelint-config-standard-scss": "^10.0.0", 109 | "tar": "^6.1.0", 110 | "tsd": "^0.28.0", 111 | "typescript": "~5.1", 112 | "vitest": "^0.34.5", 113 | "vue-template-compiler": "workspace:*" 114 | }, 115 | "scripts": { 116 | "start:companion": "bash bin/companion.sh", 117 | "start:companion:with-loadbalancer": "e2e/start-companion-with-load-balancer.mjs", 118 | "build:bundle": "yarn node ./bin/build-bundle.mjs", 119 | "build:clean": "rm -rf packages/*/lib packages/@JSIMg/*/lib packages/*/dist packages/@JSIMg/*/dist", 120 | "build:companion": "yarn workspace @JSIMg/companion build", 121 | "build:css": "yarn node ./bin/build-css.js", 122 | "build:svelte": "yarn workspace @JSIMg/svelte build", 123 | "build:angular": "yarn workspace angular build", 124 | "build:js": "npm-run-all build:lib build:companion build:locale-pack build:svelte build:angular build:bundle", 125 | "build:ts": "yarn workspaces list --no-private --json | yarn node ./bin/build-ts.mjs", 126 | "build:lib": "yarn node ./bin/build-lib.js", 127 | "build:locale-pack": "yarn workspace @JSIMg-dev/locale-pack build && eslint packages/@JSIMg/locales/src/en_US.js --fix && yarn workspace @JSIMg-dev/locale-pack test unused", 128 | "build": "npm-run-all --parallel build:js build:css --serial size", 129 | "contributors:save": "yarn node ./bin/update-contributors.mjs", 130 | "dev:with-companion": "npm-run-all --parallel start:companion dev", 131 | "dev": "yarn workspace @JSIMg-dev/dev dev", 132 | "lint:fix": "yarn lint --fix", 133 | "lint:markdown": "remark -f -q -i .remarkignore . .github/CONTRIBUTING.md", 134 | "lint:staged": "lint-staged", 135 | "lint:css": "stylelint ./packages/**/*.scss", 136 | "lint:css:fix": "stylelint ./packages/**/*.scss --fix", 137 | "lint": "eslint . --cache", 138 | "format:show-diff": "git diff --quiet || (echo 'Unable to show a diff because there are unstaged changes'; false) && (prettier . -w --loglevel silent && git --no-pager diff; git restore .)", 139 | "format:check": "prettier -c .", 140 | "format:check-diff": "yarn format:check || (yarn format:show-diff && false)", 141 | "format": "prettier -w .", 142 | "release": "PACKAGES=$(yarn workspaces list --json) yarn workspace @JSIMg-dev/release interactive", 143 | "size": "echo 'JS Bundle mingz:' && cat packages/JSIMg/dist/JSIMg.min.js | gzip | wc -c && echo 'CSS Bundle mingz:' && cat packages/JSIMg/dist/JSIMg.min.css | gzip | wc -c", 144 | "e2e": "yarn build && yarn e2e:skip-build", 145 | "e2e:skip-build": "npm-run-all --parallel watch:js:lib e2e:client start:companion:with-loadbalancer e2e:cypress", 146 | "e2e:ci": "start-server-and-test 'npm-run-all --parallel e2e:client start:companion:with-loadbalancer' '1234|3020' e2e:headless", 147 | "e2e:client": "yarn workspace e2e client:start", 148 | "e2e:cypress": "yarn workspace e2e cypress:open", 149 | "e2e:headless": "yarn workspace e2e cypress:headless", 150 | "e2e:generate": "yarn workspace e2e generate-test", 151 | "test:companion": "yarn workspace @JSIMg/companion test", 152 | "test:companion:watch": "yarn workspace @JSIMg/companion test --watch", 153 | "test:locale-packs": "yarn locale-packs:unused && yarn locale-packs:warnings", 154 | "test:locale-packs:unused": "yarn workspace @JSIMg-dev/locale-pack test unused", 155 | "test:locale-packs:warnings": "yarn workspace @JSIMg-dev/locale-pack test warnings", 156 | "test:type": "yarn workspaces foreach -piv --include '@JSIMg/*' --exclude '@JSIMg/{angular,react-native,locales,companion,provider-views,robodog,svelte}' exec tsd", 157 | "test:unit": "yarn run build:lib && yarn test:watch --run", 158 | "test:watch": "vitest --environment jsdom --dir packages/@JSIMg", 159 | "test": "npm-run-all lint test:locale-packs:unused test:unit test:type test:companion", 160 | "uploadcdn": "yarn node ./bin/upload-to-cdn.js", 161 | "version": "yarn node ./bin/after-version-bump.js", 162 | "watch:css": "onchange 'packages/{@JSIMg/,}*/src/*.scss' --initial --verbose -- yarn run build:css", 163 | "watch:js:bundle": "onchange 'packages/{@JSIMg/,}*/src/**/*.js' --initial --verbose -- yarn run build:bundle", 164 | "watch:js:lib": "onchange 'packages/{@JSIMg/,}*/src/**/*.js' --initial --verbose -- yarn run build:lib", 165 | "watch:js": "npm-run-all --parallel watch:js:bundle watch:js:lib", 166 | "watch": "npm-run-all --parallel watch:css watch:js" 167 | }, 168 | "resolutions": { 169 | "@types/eslint@^7.2.13": "^8.2.0", 170 | "@types/react": "^17", 171 | "@types/webpack-dev-server": "^4", 172 | "p-queue": "patch:p-queue@npm%3A7.4.1#./.yarn/patches/p-queue-npm-7.4.1-e0cf0a6f17.patch", 173 | "pre-commit": "patch:pre-commit@npm:1.2.2#.yarn/patches/pre-commit-npm-1.2.2-f30af83877.patch", 174 | "preact": "patch:preact@npm:10.10.0#.yarn/patches/preact-npm-10.10.0-dd04de05e8.patch", 175 | "start-server-and-test": "patch:start-server-and-test@npm:1.14.0#.yarn/patches/start-server-and-test-npm-1.14.0-841aa34fdf.patch", 176 | "stylelint-config-rational-order": "patch:stylelint-config-rational-order@npm%3A0.1.2#./.yarn/patches/stylelint-config-rational-order-npm-0.1.2-d8336e84ed.patch", 177 | "uuid@^8.3.2": "patch:uuid@npm:8.3.2#.yarn/patches/uuid-npm-8.3.2-eca0baba53.patch" 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /packages/@JSIMg/aws-s3-multipart/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @uppy/aws-s3-multipart 2 | 3 | ## 3.8.0 4 | 5 | Released: 2023-10-20 6 | Included in: Uppy v3.18.0 7 | 8 | - @uppy/aws-s3-multipart: fix `TypeError` (Antoine du Hamel / #4748) 9 | - @uppy/aws-s3-multipart: pass `signal` as separate arg for backward compat (Antoine du Hamel / #4746) 10 | - @uppy/aws-s3-multipart: fix `uploadURL` when using `PUT` (Antoine du Hamel / #4701) 11 | 12 | ## 3.7.0 13 | 14 | Released: 2023-09-29 15 | Included in: Uppy v3.17.0 16 | 17 | - @uppy/aws-s3-multipart: retry signature request (Merlijn Vos / #4691) 18 | - @uppy/aws-s3-multipart: aws-s3-multipart - call `#setCompanionHeaders` in `setOptions` (jur-ng / #4687) 19 | 20 | ## 3.6.0 21 | 22 | Released: 2023-09-05 23 | Included in: Uppy v3.15.0 24 | 25 | - @uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/companion-client,@uppy/core,@uppy/tus,@uppy/utils,@uppy/xhr-upload: Move remote file upload logic into companion-client (Merlijn Vos / #4573) 26 | 27 | ## 3.5.4 28 | 29 | Released: 2023-08-23 30 | Included in: Uppy v3.14.1 31 | 32 | - @uppy/aws-s3-multipart: fix types when using deprecated option (Antoine du Hamel / #4634) 33 | - @uppy/aws-s3-multipart,@uppy/aws-s3: allow empty objects for `fields` types (Antoine du Hamel / #4631) 34 | 35 | ## 3.5.3 36 | 37 | Released: 2023-08-15 38 | Included in: Uppy v3.14.0 39 | 40 | - @uppy/aws-s3-multipart: pass the `uploadURL` back to the caller (Antoine du Hamel / #4614) 41 | - @uppy/aws-s3,@uppy/aws-s3-multipart: update types (Antoine du Hamel / #4611) 42 | - @uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/companion,@uppy/transloadit,@uppy/xhr-upload: use uppercase HTTP method names (Antoine du Hamel / #4612) 43 | - @uppy/aws-s3,@uppy/aws-s3-multipart: update types (bdirito / #4576) 44 | 45 | ## 3.5.2 46 | 47 | Released: 2023-07-24 48 | Included in: Uppy v3.13.1 49 | 50 | - @uppy/aws-s3-multipart: refresh file before calling user-defined functions (mjlumetta / #4557) 51 | 52 | ## 3.5.1 53 | 54 | Released: 2023-07-20 55 | Included in: Uppy v3.13.0 56 | 57 | - @uppy/aws-s3-multipart: fix crash on pause/resume (Merlijn Vos / #4581) 58 | - @uppy/aws-s3-multipart: do not access `globalThis.crypto` on the top-level (Bryan J Swift / #4584) 59 | 60 | ## 3.5.0 61 | 62 | Released: 2023-07-13 63 | Included in: Uppy v3.12.0 64 | 65 | - @uppy/aws-s3-multipart: add support for signing on the client (Antoine du Hamel / #4519) 66 | - @uppy/aws-s3-multipart: fix lint warning (Antoine du Hamel / #4569) 67 | - @uppy/aws-s3-multipart: fix support for non-multipart PUT upload (Antoine du Hamel / #4568) 68 | 69 | ## 3.4.1 70 | 71 | Released: 2023-07-06 72 | Included in: Uppy v3.11.0 73 | 74 | - @uppy/aws-s3-multipart: increase priority of abort and complete (Stefan Schonert / #4542) 75 | - @uppy/aws-s3-multipart: fix upload retry using an outdated ID (Antoine du Hamel / #4544) 76 | - @uppy/aws-s3-multipart: fix Golden Retriever integration (Antoine du Hamel / #4526) 77 | - @uppy/aws-s3-multipart: add types to internal fields (Antoine du Hamel / #4535) 78 | - @uppy/aws-s3-multipart: fix pause/resume (Antoine du Hamel / #4523) 79 | - @uppy/aws-s3-multipart: fix resume single-chunk multipart uploads (Antoine du Hamel / #4528) 80 | - @uppy/aws-s3-multipart: disable pause/resume for remote uploads in the UI (Artur Paikin / #4500) 81 | 82 | ## 3.4.0 83 | 84 | Released: 2023-06-19 85 | Included in: Uppy v3.10.0 86 | 87 | - @uppy/aws-s3-multipart: fix the chunk size calculation (Antoine du Hamel / #4508) 88 | - @uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/tus,@uppy/utils,@uppy/xhr-upload: When file is removed (or all are canceled), controller.abort queued requests (Artur Paikin / #4504) 89 | - @uppy/aws-s3-multipart,@uppy/tus,@uppy/xhr-upload: Don't close socket while upload is still in progress (Artur Paikin / #4479) 90 | - @uppy/aws-s3-multipart: fix `getUploadParameters` option (Antoine du Hamel / #4465) 91 | 92 | ## 3.3.0 93 | 94 | Released: 2023-05-02 95 | Included in: Uppy v3.9.0 96 | 97 | - @uppy/aws-s3-multipart: allowedMetaFields: null means “include all” (Artur Paikin / #4437) 98 | - @uppy/aws-s3-multipart: add `shouldUseMultipart ` option (Antoine du Hamel / #4205) 99 | - @uppy/aws-s3-multipart: make retries more robust (Antoine du Hamel / #4424) 100 | 101 | ## 3.1.3 102 | 103 | Released: 2023-04-04 104 | Included in: Uppy v3.7.0 105 | 106 | - @uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/tus,@uppy/xhr-upload: make sure that we reset serverToken when an upload fails (Mikael Finstad / #4376) 107 | - @uppy/aws-s3-multipart: do not auto-open sockets, clean them up on abort (Antoine du Hamel) 108 | 109 | ## 3.1.2 110 | 111 | Released: 2023-01-26 112 | Included in: Uppy v3.4.0 113 | 114 | - @uppy/aws-s3-multipart: fix metadata shape (Antoine du Hamel / #4267) 115 | - @uppy/aws-s3-multipart: add support for `allowedMetaFields` option (Antoine du Hamel / #4215) 116 | - @uppy/aws-s3-multipart: fix singPart type (Stefan Schonert / #4224) 117 | 118 | ## 3.1.1 119 | 120 | Released: 2022-11-16 121 | Included in: Uppy v3.3.1 122 | 123 | - @uppy/aws-s3-multipart: handle slow connections better (Antoine du Hamel / #4213) 124 | - @uppy/aws-s3-multipart: Fix typo in url check (Christian Franke / #4211) 125 | 126 | ## 3.1.0 127 | 128 | Released: 2022-11-10 129 | Included in: Uppy v3.3.0 130 | 131 | - @uppy/aws-s3-multipart: empty the queue when pausing (Antoine du Hamel / #4203) 132 | - @uppy/aws-s3-multipart: refactor rate limiting approach (Antoine du Hamel / #4187) 133 | - @uppy/aws-s3-multipart: change limit to 6 (Antoine du Hamel / #4199) 134 | - @uppy/aws-s3-multipart: remove unused `timeout` option (Antoine du Hamel / #4186) 135 | - @uppy/aws-s3-multipart,@uppy/tus: fix `Timed out waiting for socket` (Antoine du Hamel / #4177) 136 | 137 | ## 3.0.2 138 | 139 | Released: 2022-09-25 140 | Included in: Uppy v3.1.0 141 | 142 | - @uppy/audio,@uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/box,@uppy/companion-client,@uppy/companion,@uppy/compressor,@uppy/core,@uppy/dashboard,@uppy/drag-drop,@uppy/drop-target,@uppy/dropbox,@uppy/facebook,@uppy/file-input,@uppy/form,@uppy/golden-retriever,@uppy/google-drive,@uppy/image-editor,@uppy/informer,@uppy/instagram,@uppy/locales,@uppy/onedrive,@uppy/progress-bar,@uppy/provider-views,@uppy/react,@uppy/redux-dev-tools,@uppy/remote-sources,@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: add missing entries to changelog for individual packages (Antoine du Hamel / #4092) 143 | 144 | ## 3.0.0 145 | 146 | Released: 2022-08-22 147 | Included in: Uppy v3.0.0 148 | 149 | - Switch to ESM 150 | 151 | ## 3.0.0-beta.4 152 | 153 | Released: 2022-08-16 154 | Included in: Uppy v3.0.0-beta.5 155 | 156 | - @uppy/aws-s3-multipart: Fix when using Companion (Merlijn Vos / #3969) 157 | - @uppy/aws-s3-multipart: Fix race condition in `#uploadParts` (Morgan Zolob / #3955) 158 | - @uppy/aws-s3-multipart: ignore exception inside `abortMultipartUpload` (Antoine du Hamel / #3950) 159 | 160 | ## 3.0.0-beta.3 161 | 162 | Released: 2022-08-03 163 | Included in: Uppy v3.0.0-beta.4 164 | 165 | - @uppy/aws-s3-multipart: Correctly handle errors for `prepareUploadParts` (Merlijn Vos / #3912) 166 | 167 | ## 3.0.0-beta.2 168 | 169 | Released: 2022-07-27 170 | Included in: Uppy v3.0.0-beta.3 171 | 172 | - @uppy/aws-s3-multipart: make `headers` part indexed too in `prepareUploadParts` (Merlijn Vos / #3895) 173 | 174 | ## 2.4.1 175 | 176 | Released: 2022-06-07 177 | Included in: Uppy v2.12.0 178 | 179 | - @uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/tus: queue socket token requests for remote files (Merlijn Vos / #3797) 180 | - @uppy/aws-s3-multipart: allow `companionHeaders` to be modified with `setOptions` (Paulo Lemos Neto / #3770) 181 | 182 | ## 2.4.0 183 | 184 | Released: 2022-05-30 185 | Included in: Uppy v2.11.0 186 | 187 | - @uppy/angular,@uppy/audio,@uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/box,@uppy/core,@uppy/dashboard,@uppy/drag-drop,@uppy/dropbox,@uppy/facebook,@uppy/file-input,@uppy/form,@uppy/golden-retriever,@uppy/google-drive,@uppy/image-editor,@uppy/informer,@uppy/instagram,@uppy/onedrive,@uppy/progress-bar,@uppy/react,@uppy/redux-dev-tools,@uppy/robodog,@uppy/screen-capture,@uppy/status-bar,@uppy/store-default,@uppy/store-redux,@uppy/thumbnail-generator,@uppy/transloadit,@uppy/tus,@uppy/unsplash,@uppy/url,@uppy/vue,@uppy/webcam,@uppy/xhr-upload,@uppy/zoom: doc: update bundler recommendation (Antoine du Hamel / #3763) 188 | - @uppy/aws-s3-multipart: refactor to ESM (Antoine du Hamel / #3672) 189 | 190 | ## 2.3.0 191 | 192 | Released: 2022-05-14 193 | Included in: Uppy v2.10.0 194 | 195 | - @uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/core,@uppy/react,@uppy/transloadit,@uppy/tus,@uppy/xhr-upload: proposal: Cancel assemblies optional (Mikael Finstad / #3575) 196 | - @uppy/aws-s3-multipart: export interface AwsS3MultipartOptions (Matteo Padovano / #3709) 197 | 198 | ## 2.2.2 199 | 200 | Released: 2022-04-27 201 | Included in: Uppy v2.9.4 202 | 203 | - @uppy/aws-s3-multipart: Add `companionCookiesRule` type to @uppy/aws-s3-multipart (Mauricio Ribeiro / #3623) 204 | 205 | ## 2.2.1 206 | 207 | Released: 2022-03-02 208 | Included in: Uppy v2.7.0 209 | 210 | - @uppy/aws-s3-multipart: Add chunks back to prepareUploadParts, indexed by partNumber (Kevin West / #3520) 211 | 212 | ## 2.2.0 213 | 214 | Released: 2021-12-07 215 | Included in: Uppy v2.3.0 216 | 217 | - @uppy/aws-s3-multipart: Drop `lockedCandidatesForBatch` and mark chunks as 'busy' when preparing (Yegor Yarko / #3342) 218 | --------------------------------------------------------------------------------