@ezychat/web 0.1.80 → 0.1.82

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.
@@ -18,5 +18,10 @@ export interface ApiInit<T> {
18
18
  * 401 additionally dispatches a `wati:unauthorized` window event.
19
19
  */
20
20
  export declare function api<T = unknown>(path: string, init?: ApiInit<T>): Promise<T>;
21
+ /**
22
+ * POST a form to `/api${path}` with upload progress (fetch reports none): `onProgress` gets the share
23
+ * sent so far. Same answers and errors as `api()`.
24
+ */
25
+ export declare function apiUpload<T = unknown>(path: string, form: FormData, onProgress: (share: number) => void): Promise<T>;
21
26
  /** Friendly, translated message for any thrown error. */
22
27
  export declare function errorMessage(e: unknown): string;
@@ -419,6 +419,11 @@ export interface SendMediaInput {
419
419
  /** A video above the number's video limit goes as a file (a document, full quality). */
420
420
  asFile?: boolean;
421
421
  }
422
+ /**
423
+ * The error a failed upload's bubble keeps: WhatsApp's size refusals by code, a 413 that is not ours
424
+ * (Cloudflare's tunnel limit answers without our JSON) as `tunnel_too_large`, else the message.
425
+ */
426
+ export declare function uploadFailure(e: unknown): string;
422
427
  export declare function useSendMedia(jid: string): import("@tanstack/react-query").UseMutationResult<{
423
428
  id: string;
424
429
  chatJid: string;
@@ -769,6 +769,7 @@ export declare const enResources: {
769
769
  remove: string;
770
770
  caption: string;
771
771
  too_large: string;
772
+ tunnel_limit: string;
772
773
  empty: string;
773
774
  too_many: string;
774
775
  drop: string;
@@ -1022,7 +1023,9 @@ export declare const enResources: {
1022
1023
  too_large: string;
1023
1024
  too_large_as_video: string;
1024
1025
  too_large_for_whatsapp: string;
1026
+ tunnel_too_large: string;
1025
1027
  };
1028
+ uploading: string;
1026
1029
  };
1027
1030
  media: {
1028
1031
  types: {
@@ -44,3 +44,10 @@ export declare function MessageBubble({ message: m, showSender, outboundLabel, q
44
44
  export declare const LARGE_FILE_BYTES: number;
45
45
  /** Why a message was not sent, in plain words. */
46
46
  export declare function failedReason(error: string | null, t: TFunction<['inbox', 'common']>): string;
47
+ /**
48
+ * The upload of a file this browser is sending: a bar and the percentage above the file's
49
+ * "Uploading …" placeholder, until it arrived.
50
+ */
51
+ export declare function UploadingProgress({ clientId }: Readonly<{
52
+ clientId: string | null | undefined;
53
+ }>): React.JSX.Element | null;
@@ -9,22 +9,30 @@ export declare function hasFiles(dt: Pick<DataTransfer, 'types'> | null | undefi
9
9
  export declare function filesFromTransfer(dt: Pick<DataTransfer, 'files'> | null | undefined, now?: () => Date): File[];
10
10
  export type RejectedFile = {
11
11
  file: File;
12
- reason: 'too_large' | 'empty' | 'too_many';
12
+ /** `tunnel_limit`: above what the Cloudflare tunnel passes (it works on this PC or the LAN). */
13
+ reason: 'too_large' | 'empty' | 'too_many' | 'tunnel_limit';
13
14
  /** The limit a `too_large` file went over, in bytes. */
14
15
  limit?: number;
15
16
  };
16
17
  /** What a chat's WhatsApp number takes, per kind of file (`InboxCapabilities.mediaLimits`). */
17
18
  export type MediaLimits = Partial<Record<'video' | 'image' | 'audio' | 'document', number>>;
18
19
  /**
19
- * The largest file of this type the chat's number takes: the app's upload limit, lowered by the
20
- * number's own limit for images, audio and documents. A video is checked against the document
21
- * limit only: above the video limit the server answers `too_large_as_video` (it may go as a file).
20
+ * The largest file of this type the chat's number takes (`mediaLimits`), or undefined when it knows
21
+ * none: the app has no size cap of its own. A video is checked against the document limit only:
22
+ * above the video limit it goes as a file (`videoNeedsFile`).
22
23
  */
23
- export declare function uploadLimitFor(mime: string, limits?: MediaLimits | null): number;
24
+ export declare function uploadLimitFor(mime: string, limits?: MediaLimits | null): number | undefined;
24
25
  /** A video above the number's video limit (it can still go as a file, up to the document limit). */
25
26
  export declare function videoNeedsFile(file: File, limits?: MediaLimits | null): boolean;
27
+ /**
28
+ * The app is open through the internet address (the Cloudflare tunnel), not on this computer or the
29
+ * local network: loopback, private IPv4, IPv6 literals, single-label and `.local` names are local.
30
+ */
31
+ export declare function isTunnelHost(hostname: string): boolean;
26
32
  /** Splits files into the ones that can be sent and the ones refused before any upload. */
27
- export declare function checkAttachments(files: readonly File[], alreadyQueued: number, limits?: MediaLimits | null): {
33
+ export declare function checkAttachments(files: readonly File[], alreadyQueued: number, limits?: MediaLimits | null, opts?: {
34
+ tunnel?: boolean;
35
+ }): {
28
36
  accepted: File[];
29
37
  rejected: RejectedFile[];
30
38
  };
@@ -0,0 +1,6 @@
1
+ /** The share of `clientId`'s file uploaded so far (0..1), or null to clear it. */
2
+ export declare function setUploadProgress(clientId: string, share: number | null): void;
3
+ /** The current share of `clientId`'s upload (0..1), or null. */
4
+ export declare function uploadProgressOf(clientId: string): number | null;
5
+ /** The upload progress of a message's file (0..1), or null when it is not uploading. */
6
+ export declare function useUploadProgress(clientId: string | null | undefined): number | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ezychat/web",
3
- "version": "0.1.80",
3
+ "version": "0.1.82",
4
4
  "type": "module",
5
5
  "description": "EzyChat core: the team inbox web app (React) as a library, with createInboxApp and its extension API.",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "build:lib": "node ../../scripts/build-web-lib.mjs"
41
41
  },
42
42
  "dependencies": {
43
- "@ezychat/shared": "0.1.80",
43
+ "@ezychat/shared": "0.1.82",
44
44
  "@fontsource-variable/inter": "^5.3.0",
45
45
  "@tanstack/react-query": "^5.105.0",
46
46
  "@types/react": "^19.3.0",
@@ -60,8 +60,8 @@
60
60
  "radix-ui": "^1.8.1",
61
61
  "react": "^19.3.1",
62
62
  "react-dom": "^19.3.1",
63
- "react-i18next": "^17.1.9",
64
- "react-router-dom": "^7.18.4",
63
+ "react-i18next": "^17.1.12",
64
+ "react-router-dom": "^7.18.5",
65
65
  "socket.io-client": "^4.8.4",
66
66
  "sonner": "^2.0.8",
67
67
  "tailwind-merge": "^3.7.0",
@@ -69,13 +69,13 @@
69
69
  "vaul": "^1.1.2"
70
70
  },
71
71
  "devDependencies": {
72
- "@tailwindcss/vite": "^4.3.3",
72
+ "@tailwindcss/vite": "^4.3.4",
73
73
  "@testing-library/dom": "^10.4.2",
74
74
  "@testing-library/jest-dom": "^7.0.1",
75
75
  "@testing-library/react": "^16.3.3",
76
76
  "@testing-library/user-event": "^14.6.8",
77
77
  "@types/nspell": "2.1.6",
78
- "@vitejs/plugin-react": "^6.1.2",
78
+ "@vitejs/plugin-react": "^6.2.1",
79
79
  "dictionary-en-gb": "3.0.0",
80
80
  "jsdom": "^30.1.3",
81
81
  "tailwindcss": "^4.3.3",