New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mux/mux-uploader

Package Overview
Dependencies
Maintainers
2
Versions
577
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mux/mux-uploader - npm Package Compare versions

Comparing version 0.1.0-canary.10-ce66df5 to 0.1.0-canary.10-d719423

25

CHANGELOG.md

@@ -6,2 +6,27 @@ # Change Log

# [0.1.0-beta.7](https://github.com/muxinc/elements/compare/@mux/mux-uploader@0.1.0-beta.6...@mux/mux-uploader@0.1.0-beta.7) (2022-08-04)
### Bug Fixes
- **mux-uploader:** use narrower type def for uploadstart to avoid type mismatches in dist. ([a56cc06](https://github.com/muxinc/elements/commit/a56cc0609b1051513f5df3eb7e9cb21410fc7bb5))
# [0.1.0-beta.6](https://github.com/muxinc/elements/compare/@mux/mux-uploader@0.1.0-beta.5...@mux/mux-uploader@0.1.0-beta.6) (2022-08-03)
### Features
- **mux-uploader:** Upchunk event type defs. ([248e0e1](https://github.com/muxinc/elements/commit/248e0e1a9edf648113fd6bc7bdf6505c7df8cc4b))
# [0.1.0-beta.5](https://github.com/muxinc/elements/compare/@mux/mux-uploader@0.1.0-beta.4...@mux/mux-uploader@0.1.0-beta.5) (2022-08-02)
### Bug Fixes
- **mux-uploader:** Fix attempt and chunkSuccess event details not being passed. Also make the data passed consistent by using event for all params. ([09d4cf8](https://github.com/muxinc/elements/commit/09d4cf8e22d8de919e175d039c5f0eb9a42b2591))
- **mux-uploader:** Update event and event handler typedefs for greater accuracy of types. ([92f28a5](https://github.com/muxinc/elements/commit/92f28a5828ea3c046fa5a1aa711a038a7444f0dc))
### Features
- **mux-uploader:** Add CSS variables for button border and padding. ([359cd89](https://github.com/muxinc/elements/commit/359cd89472781fc41e33e95574c0d9c845b1d081))
- **mux-uploader:** Add custom event for when upload starts. ([9fd1efc](https://github.com/muxinc/elements/commit/9fd1efc943bcb60efdb51b455d5b9642af86b920))
- **mux-uploader:** Support Upchunk's attempt and chunkSuccess events. ([739a88e](https://github.com/muxinc/elements/commit/739a88e5eda697b8344ef14e3a20b1bef19e1a41))
# [0.1.0-beta.4](https://github.com/muxinc/elements/compare/@mux/mux-uploader@0.1.0-beta.3...@mux/mux-uploader@0.1.0-beta.4) (2022-07-21)

@@ -8,0 +33,0 @@

4

package.json
{
"name": "@mux/mux-uploader",
"version": "0.1.0-canary.10-ce66df5",
"version": "0.1.0-canary.10-d719423",
"description": "An uploader elements to be used with Mux Direct Uploads",

@@ -49,3 +49,3 @@ "main": "./dist/index.cjs",

"dependencies": {
"@mux/upchunk": "^2.3.1"
"@mux/upchunk": "^2.6.0"
},

@@ -52,0 +52,0 @@ "devDependencies": {

@@ -108,3 +108,6 @@ <p align="center">

| `status` | `boolean` | Toggles text status visibility of progress bar. The text that is displayed is a percentage by default. If you prefer just the progress bar with no text upload status, don't include this attribute. | false |
| `dynamic-chunk-size` | `boolean` | Toggles uploading with dynamic chunk sizes. Chunk sizes will change with upload speed to attempt to optimize upload. | false |
---
#### `<mux-uploader-drop>`

@@ -137,3 +140,3 @@

| `chunksuccess` | Fired when an indvidual chunk is successfully uploaded. Sample response: `{ detail: { chunk: Integer, attempts: Integer, response: XhrResponse } }` |
| `error` | Fired when an error occurs in the chunked upload process. |
| `uploaderror` | Fired when an error occurs in the chunked upload process. |
| `progress` | Fired continuously with incremental upload progress. This returns the current percentage of the file that's been uploaded. Sample response: `{ detail: [0..100] }` |

@@ -140,0 +143,0 @@ | `success` | Fired when the entire file has successfully completed uploading. |

@@ -225,4 +225,54 @@ import '@mux/polyfills';

type Endpoint = UpChunk.UpChunk['endpoint'] | undefined | null;
type DynamicChunkSize = UpChunk.UpChunk['dynamicChunkSize'] | undefined;
class MuxUploaderElement extends HTMLElement {
type ErrorDetail = {
message: string;
chunkNumber?: number;
attempts?: number;
};
// NOTE: Progress event is already determined on HTMLElement but have inconsistent types. Should consider renaming events (CJP)
export interface MuxUploaderElementEventMap extends Omit<HTMLElementEventMap, 'progress'> {
uploadstart: CustomEvent<{ file: File; chunkSize: number }>;
chunkattempt: CustomEvent<{
chunkNumber: number;
chunkSize: number;
}>;
chunksuccess: CustomEvent<{
chunk: number;
chunkSize: number;
attempts: number;
timeInterval: number;
// Note: This should be more explicitly typed in Upchunk. (TD).
response: any;
}>;
uploaderror: CustomEvent<ErrorDetail>;
progress: CustomEvent<number>;
success: CustomEvent<undefined | null>;
}
interface MuxUploaderElement extends HTMLElement {
addEventListener<K extends keyof MuxUploaderElementEventMap>(
type: K,
listener: (this: HTMLMediaElement, ev: MuxUploaderElementEventMap[K]) => any,
options?: boolean | AddEventListenerOptions
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions
): void;
removeEventListener<K extends keyof MuxUploaderElementEventMap>(
type: K,
listener: (this: HTMLMediaElement, ev: MuxUploaderElementEventMap[K]) => any,
options?: boolean | EventListenerOptions
): void;
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions
): void;
}
class MuxUploaderElement extends HTMLElement implements MuxUploaderElement {
protected _formatProgress: ((percent: number) => string) | null | undefined;

@@ -334,2 +384,15 @@ protected _filePickerButton: HTMLElement | null | undefined;

get dynamicChunkSize(): DynamicChunkSize {
return this.hasAttribute('dynamic-chunk-size');
}
set dynamicChunkSize(value: DynamicChunkSize) {
if (value === this.hasAttribute('dynamic-chunk-size')) return;
if (value) {
this.setAttribute('dynamic-chunk-size', '');
} else {
this.removeAttribute('dynamic-chunk-size');
}
}
get formatProgress(): (percent: number) => string {

@@ -423,2 +486,3 @@ return this._formatProgress ?? defaultFormatProgress;

const endpoint = this.endpoint;
const dynamicChunkSize = this.dynamicChunkSize;

@@ -432,2 +496,3 @@ if (!endpoint) {

console.error(invalidUrlMessage);
this.dispatchEvent(new CustomEvent('uploaderror', { detail: { message: invalidUrlMessage } }));
// Bail early if no endpoint.

@@ -447,6 +512,7 @@ return;

endpoint,
dynamicChunkSize,
file: evt.detail,
});
this.dispatchEvent(new CustomEvent('uploadstart', { detail: upload }));
this.dispatchEvent(new CustomEvent('uploadstart', { detail: { file: upload.file, chunkSize: upload.chunkSize } }));

@@ -471,3 +537,3 @@ upload.on('attempt', (event) => {

console.error(event.detail.message);
this.dispatchEvent(new CustomEvent('error', event));
this.dispatchEvent(new CustomEvent('uploaderror', event));
});

@@ -474,0 +540,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc