@micromerce/media-fileuploader 1.0.1893 → 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.
@@ -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) => JSX.Element;
5
+ component: (props: import(".").IFileUploader) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
6
6
  parameters: {
7
7
  layout: string;
8
8
  };
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
1
+ import { ReactElement } from 'react';
2
2
  import { IFileUploader } from './FileUploader/FileUploader';
3
- export declare const FileUploaderComponent: (props: IFileUploader) => JSX.Element;
3
+ export declare const FileUploaderComponent: (props: IFileUploader) => ReactElement;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  /// <reference types="react" />
2
+ import { ReactElement } from 'react';
3
+
2
4
  type mode = 'stateful' | 'stateless';
3
5
 
4
6
  type endpoint = {
@@ -33,6 +35,6 @@ interface IFileUploader {
33
35
  authorizationHeader?: authorizationHeader;
34
36
  }
35
37
 
36
- declare const FileUploaderComponent: (props: IFileUploader) => JSX.Element;
38
+ declare const FileUploaderComponent: (props: IFileUploader) => ReactElement;
37
39
 
38
40
  export { FileUploaderComponent as FileUploader, type IFileUploader };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromerce/media-fileuploader",
3
- "version": "1.0.1893",
3
+ "version": "1.0.1900",
4
4
  "homepage": "https://www.micromerce.com",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -10,25 +10,20 @@
10
10
  "types": "dist/index.d.ts",
11
11
  "scripts": {
12
12
  "watch": "npm run lint && rollup -c -w",
13
- "build": "npm run lint && rimraf dist && rollup -c",
13
+ "build": "npm run lint && rimraf dist && rollup -c && npm run verify",
14
+ "verify": "npm run verify:bundle && npm run verify:types",
14
15
  "dev": "storybook dev -p 6006",
15
16
  "build-storybook": "storybook build",
16
17
  "test": "jest --runInBand --no-cache",
18
+ "verify:bundle": "jest --config jest.bundle.config.js --runInBand --no-cache",
19
+ "verify:types": "tsc -p verify/tsconfig.consumer.json",
17
20
  "test:generate-output": "jest --json --outputFile=.jest-test-results.json || true",
18
- "lint": "eslint src/**.*",
21
+ "lint": "eslint src verify --ext .ts,.tsx,.js,.jsx",
19
22
  "storybook": "storybook dev -p 6006"
20
23
  },
21
- "dependencies": {
22
- "@react-icons/all-files": "4.1.0",
23
- "@uppy/core": "3.10.0",
24
- "@uppy/drag-drop": "3.1.0",
25
- "@uppy/react": "3.3.0",
26
- "@uppy/tus": "3.5.4",
27
- "i18next": "22.4.15",
28
- "i18next-browser-languagedetector": "7.0.1",
29
- "pretty-bytes": "6.1.1",
30
- "react-i18next": "12.2.2",
31
- "styled-components": "5.3.10"
24
+ "peerDependencies": {
25
+ "react": ">=18",
26
+ "react-dom": ">=18"
32
27
  },
33
28
  "devDependencies": {
34
29
  "@babel/plugin-transform-react-jsx": "^7.23.4",
@@ -37,6 +32,7 @@
37
32
  "@babel/preset-react": "7.24.1",
38
33
  "@babel/preset-typescript": "7.24.1",
39
34
  "@chromatic-com/storybook": "^1.3.3",
35
+ "@react-icons/all-files": "4.1.0",
40
36
  "@rollup/plugin-alias": "5.1.0",
41
37
  "@rollup/plugin-babel": "6.0.4",
42
38
  "@rollup/plugin-commonjs": "^25.0.7",
@@ -61,6 +57,10 @@
61
57
  "@types/react-dom": "18.2.1",
62
58
  "@types/styled-components": "5.1.26",
63
59
  "@typescript-eslint/parser": "5.59.1",
60
+ "@uppy/core": "3.10.0",
61
+ "@uppy/drag-drop": "3.1.0",
62
+ "@uppy/react": "3.3.0",
63
+ "@uppy/tus": "3.5.4",
64
64
  "babel-jest": "29.7.0",
65
65
  "buffer": "^6.0.3",
66
66
  "eslint": "8.39.0",
@@ -71,16 +71,21 @@
71
71
  "eslint-plugin-storybook": "^0.8.0",
72
72
  "eslint-plugin-testing-library": "5.10.3",
73
73
  "hawk": "^9.0.2",
74
+ "i18next": "22.4.15",
75
+ "i18next-browser-languagedetector": "7.0.1",
74
76
  "jest": "29.7.0",
75
77
  "jest-environment-jsdom": "29.7.0",
78
+ "pretty-bytes": "6.1.1",
76
79
  "react": "^18.2.0",
77
80
  "react-dom": "^18.2.0",
81
+ "react-i18next": "12.2.2",
78
82
  "rollup": "^4.62.2",
79
83
  "rollup-plugin-analyzer": "^4.0.0",
80
84
  "rollup-plugin-dts": "^6.1.0",
81
85
  "rollup-plugin-peer-deps-external": "^2.2.4",
82
86
  "rollup-plugin-polyfill-node": "^0.13.0",
83
87
  "storybook": "^8.0.8",
88
+ "styled-components": "5.3.10",
84
89
  "ts-jest": "29.1.2",
85
90
  "ts-node": "10.9.1",
86
91
  "tslib": "^2.6.2",