@micromerce/media-fileuploader 1.0.1894 → 1.0.1900
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +76 -1397
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/FileUploader/FileUploader.i18n.test.d.ts +1 -0
- package/dist/cjs/types/FileUploader/FileUploader.styles.test.d.ts +1 -0
- package/dist/cjs/types/FileUploader/FileUploader.upload.test.d.ts +1 -0
- package/dist/cjs/types/FileUploader/utils/fakeTus.d.ts +62 -0
- package/dist/cjs/types/FileUploader.stories.d.ts +1 -1
- package/dist/cjs/types/main.d.ts +2 -2
- package/dist/esm/index.js +76 -1397
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/FileUploader/FileUploader.i18n.test.d.ts +1 -0
- package/dist/esm/types/FileUploader/FileUploader.styles.test.d.ts +1 -0
- package/dist/esm/types/FileUploader/FileUploader.upload.test.d.ts +1 -0
- package/dist/esm/types/FileUploader/utils/fakeTus.d.ts +62 -0
- package/dist/esm/types/FileUploader.stories.d.ts +1 -1
- package/dist/esm/types/main.d.ts +2 -2
- package/dist/index.d.ts +3 -1
- package/package.json +19 -14
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A stand-in for @uppy/tus, used by FileUploader.upload.test.tsx.
|
|
3
|
+
*
|
|
4
|
+
* It is a real Uppy uploader plugin rather than a jest.fn(), on purpose: the
|
|
5
|
+
* component's error and progress handling depends on Uppy's *internal* event
|
|
6
|
+
* chain, not just on its own listeners. For a per-file failure Uppy core
|
|
7
|
+
* receives `upload-error` first, logs it through `opts.logger.error` (which the
|
|
8
|
+
* component wires to its own error state) and then re-emits a wrapped `error`,
|
|
9
|
+
* and the component's own `upload-error` listener runs after all of that. That
|
|
10
|
+
* ordering is what decides which message the user ends up seeing, and it is
|
|
11
|
+
* exactly what a major Uppy upgrade changes silently. Driving the events through
|
|
12
|
+
* `uppy.emit` keeps the whole chain under test.
|
|
13
|
+
*
|
|
14
|
+
* Faithful to @uppy/tus 3.x in two details that matter:
|
|
15
|
+
* - per-file failures do not reject the uploader (Tus collects them with
|
|
16
|
+
* Promise.allSettled), so the global `error` event is not raised by us;
|
|
17
|
+
* - `onBeforeRequest` / `onAfterResponse` are invoked with the same shape the
|
|
18
|
+
* tus HttpRequest exposes, so the header and response-body contract is real.
|
|
19
|
+
*/
|
|
20
|
+
import { BasePlugin } from '@uppy/core';
|
|
21
|
+
export type FakeTusScenario = 'success' | 'uploadError' | 'fileTooLarge';
|
|
22
|
+
export interface FakeTusProgressStep {
|
|
23
|
+
bytesUploaded: number;
|
|
24
|
+
bytesTotal: number;
|
|
25
|
+
uploadStarted: number | null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Lets a test hold the upload open between the progress events and the success
|
|
29
|
+
* event. Without it the fake emits everything in one tick, React batches the
|
|
30
|
+
* state updates and the intermediate progress state is never rendered — so any
|
|
31
|
+
* assertion about "while uploading" would silently test the finished state.
|
|
32
|
+
*/
|
|
33
|
+
export declare const createGate: () => {
|
|
34
|
+
promise: Promise<void>;
|
|
35
|
+
release: () => void;
|
|
36
|
+
};
|
|
37
|
+
export declare const tusStub: {
|
|
38
|
+
scenario: FakeTusScenario;
|
|
39
|
+
/** Body the media service answers with; the component reads url/name off it. */
|
|
40
|
+
response: {
|
|
41
|
+
url: string;
|
|
42
|
+
name: string;
|
|
43
|
+
};
|
|
44
|
+
/** Message for the plain `uploadError` scenario. */
|
|
45
|
+
errorMessage: string;
|
|
46
|
+
/** Progress events to replay, in order. */
|
|
47
|
+
progressSteps: FakeTusProgressStep[];
|
|
48
|
+
/** Awaited after the progress events and before success, when set. */
|
|
49
|
+
gate: Promise<void>;
|
|
50
|
+
/** Everything the component pushed through `onBeforeRequest`. */
|
|
51
|
+
requestHeaders: Record<string, string>;
|
|
52
|
+
/** Options the component passed to `uppy.use(Tus, …)`. */
|
|
53
|
+
pluginOptions: any;
|
|
54
|
+
reset(): void;
|
|
55
|
+
};
|
|
56
|
+
export declare class FakeTus extends BasePlugin<any, any, any> {
|
|
57
|
+
constructor(uppy: any, opts: any);
|
|
58
|
+
install(): void;
|
|
59
|
+
uninstall(): void;
|
|
60
|
+
handleUpload(fileIDs: string[]): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
export default FakeTus;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { StoryObj } from '@storybook/react';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: (props: import(".").IFileUploader) =>
|
|
5
|
+
component: (props: import(".").IFileUploader) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
6
6
|
parameters: {
|
|
7
7
|
layout: string;
|
|
8
8
|
};
|
package/dist/cjs/types/main.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
import { IFileUploader } from './FileUploader/FileUploader';
|
|
3
|
-
export declare const FileUploaderComponent: (props: IFileUploader) =>
|
|
3
|
+
export declare const FileUploaderComponent: (props: IFileUploader) => ReactElement;
|