@ezychat/web 0.1.73 → 0.1.76

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.
Files changed (28) hide show
  1. package/dist-lib/chunks/{admin-CYW5ewdl.js → admin-CwS6ahLc.js} +1 -1
  2. package/dist-lib/chunks/{admin-BTzz29_M.js → admin-p6QRa2DG.js} +1 -1
  3. package/dist-lib/chunks/{inbox-BhNcoSW9.js → inbox-C9xTxE6Y.js} +122 -2
  4. package/dist-lib/chunks/{inbox-D0mcktjU.js → inbox-D-koJMyr.js} +122 -2
  5. package/dist-lib/ezychat-web.css +1 -1
  6. package/dist-lib/index.js +7572 -6283
  7. package/dist-lib/sw-routes.ts +90 -0
  8. package/dist-lib/sw.ts +40 -0
  9. package/dist-lib/types/admin/BusinessTemplateCard.d.ts +11 -3
  10. package/dist-lib/types/admin/business-templates-data.d.ts +117 -0
  11. package/dist-lib/types/admin/business-templates.d.ts +48 -93
  12. package/dist-lib/types/api/ai-groups.d.ts +22 -0
  13. package/dist-lib/types/api/ai-templates.d.ts +145 -0
  14. package/dist-lib/types/api/group-admin.d.ts +77 -0
  15. package/dist-lib/types/api/queries.d.ts +8 -1
  16. package/dist-lib/types/api/query-client.d.ts +3 -0
  17. package/dist-lib/types/api/query-persist.d.ts +43 -0
  18. package/dist-lib/types/api/socket.d.ts +8 -0
  19. package/dist-lib/types/api/voice.d.ts +2 -2
  20. package/dist-lib/types/auth/user-caches.d.ts +2 -0
  21. package/dist-lib/types/i18n/resources.d.ts +144 -0
  22. package/dist-lib/types/inbox/FixEnglish.d.ts +27 -0
  23. package/dist-lib/types/inbox/GroupAdmin.d.ts +16 -0
  24. package/dist-lib/types/inbox/GroupAdminDialogs.d.ts +23 -0
  25. package/dist-lib/types/inbox/GroupAdminShared.d.ts +60 -0
  26. package/dist-lib/types/inbox/ProfileImageContext.d.ts +1 -2
  27. package/dist-lib/types/sw-routes.d.ts +42 -0
  28. package/package.json +6 -2
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Group management (design docs/features/group-management/design.md): what an EzyChat admin may
3
+ * change in a WhatsApp group from Group info. The answer carries the connection's `caps`; the UI
4
+ * shows only those actions, never by inbox type. Changes are never queued (offline → 503).
5
+ */
6
+ export declare const groupAdminKey: (jid: string) => readonly ["group-admin", string];
7
+ export declare function useGroupAdmin(jid: string, enabled?: boolean): import("@tanstack/react-query").UseQueryResult<{
8
+ caps: {
9
+ editInfo: boolean;
10
+ addMembers: boolean;
11
+ inviteOnly: boolean;
12
+ removeMembers: boolean;
13
+ admins: boolean;
14
+ inviteLink: boolean;
15
+ resetInviteLink: boolean;
16
+ settings: ("locked" | "announce" | "memberAdd" | "approval")[];
17
+ joinRequests: boolean;
18
+ maxMembers: number | null;
19
+ nameMax: number;
20
+ descriptionMax: number;
21
+ };
22
+ canManage: boolean;
23
+ online: boolean;
24
+ myRole: "admin" | "member" | "superadmin" | null;
25
+ settings: {
26
+ announce?: boolean | undefined;
27
+ locked?: boolean | undefined;
28
+ memberAdd?: "all" | "admins" | undefined;
29
+ approval?: boolean | undefined;
30
+ };
31
+ inviteLink: string | null;
32
+ requests: {
33
+ jid: string;
34
+ phone: string | null;
35
+ name: string | null;
36
+ at: number | null;
37
+ }[];
38
+ changes: {
39
+ at: number;
40
+ byUserId: number | null;
41
+ byName: string | null;
42
+ action: "description" | "setting" | "rename" | "member_add" | "member_invite" | "member_remove" | "admin_promote" | "admin_demote" | "invite_reset" | "join_approve" | "join_reject";
43
+ memberJid: string | null;
44
+ memberName: string | null;
45
+ setting: "locked" | "announce" | "memberAdd" | "approval" | null;
46
+ value: boolean | "all" | "admins" | null;
47
+ }[];
48
+ size: number | null;
49
+ }, Error>;
50
+ export declare const useEditGroup: (jid: string) => import("@tanstack/react-query").UseMutationResult<unknown, Error, {
51
+ name?: string | undefined;
52
+ description?: string | undefined;
53
+ }, unknown>;
54
+ /** Exactly one number (digits with country code). `invite_needed`: offer Send invite. */
55
+ export declare const useAddGroupMember: (jid: string) => import("@tanstack/react-query").UseMutationResult<{
56
+ result: "added" | "invite_needed";
57
+ memberJid: string;
58
+ }, Error, string, unknown>;
59
+ export declare const useSendGroupInvite: (jid: string) => import("@tanstack/react-query").UseMutationResult<unknown, Error, string, unknown>;
60
+ export declare const useRemoveGroupMember: (jid: string) => import("@tanstack/react-query").UseMutationResult<unknown, Error, string, unknown>;
61
+ export declare const useSetGroupMemberAdmin: (jid: string) => import("@tanstack/react-query").UseMutationResult<unknown, Error, {
62
+ member: string;
63
+ admin: boolean;
64
+ }, unknown>;
65
+ export declare function useResetGroupInvite(jid: string): import("@tanstack/react-query").UseMutationResult<{
66
+ inviteLink: string;
67
+ }, Error, unknown, unknown>;
68
+ export declare function useGroupSettings(jid: string): import("@tanstack/react-query").UseMutationResult<unknown, Error, Partial<{
69
+ announce: boolean;
70
+ locked: boolean;
71
+ memberAdd: "all" | "admins";
72
+ approval: boolean;
73
+ }>, unknown>;
74
+ export declare const useGroupJoinRequest: (jid: string) => import("@tanstack/react-query").UseMutationResult<unknown, Error, {
75
+ member: string;
76
+ approve: boolean;
77
+ }, unknown>;
@@ -126,7 +126,14 @@ export declare function useChangePassword(): import("@tanstack/react-query").Use
126
126
  currentPassword: string;
127
127
  newPassword: string;
128
128
  }, unknown>;
129
- export declare function useChats(filters: ChatFilters): import("@tanstack/react-query").UseInfiniteQueryResult<InfiniteData<{
129
+ /**
130
+ * `holdCached`: while true, a list that is already on screen (kept from the last visit or loaded
131
+ * earlier) does not refresh; a list with nothing to show still loads at once. The realtime
132
+ * connection sets it until it joins, because joining reloads every list (one load, not two).
133
+ */
134
+ export declare function useChats(filters: ChatFilters, opts?: {
135
+ holdCached?: boolean;
136
+ }): import("@tanstack/react-query").UseInfiniteQueryResult<InfiniteData<{
130
137
  chats: {
131
138
  jid: string;
132
139
  inboxId: number;
@@ -0,0 +1,3 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ /** The app's one QueryClient (tests use it too, so they run with the real defaults). */
3
+ export declare function createQueryClient(): QueryClient;
@@ -0,0 +1,43 @@
1
+ import { type QueryClient, type QueryKey } from '@tanstack/react-query';
2
+ export type KeyValueStorage = Pick<Storage, 'getItem' | 'setItem' | 'removeItem' | 'key' | 'length'>;
3
+ /** A saved copy older than this is not shown. */
4
+ export declare const PERSIST_MAX_AGE_MS: number;
5
+ /** Saves are grouped: at most one write per this delay. */
6
+ export declare const SAVE_DELAY_MS = 1000;
7
+ /** The id of the last user seen on this device (to notice a different user signing in). */
8
+ export declare const LAST_USER_KEY = "ezy.last-user";
9
+ interface QueryLike {
10
+ queryKey: QueryKey;
11
+ state: {
12
+ status: string;
13
+ data: unknown;
14
+ };
15
+ }
16
+ /** `localStorage`, or null where the browser refuses it. */
17
+ export declare function browserStorage(): KeyValueStorage | null;
18
+ /** The first screen only: user, setup status, inboxes, settings and chat lists without a search. */
19
+ export declare function shouldPersistQuery(query: QueryLike): boolean;
20
+ /**
21
+ * Before the first render: puts the last user's saved copy into the cache, marked stale so every
22
+ * kept query loads again as soon as it is used. A copy that is too old, from another build or not
23
+ * this user's is removed instead.
24
+ */
25
+ export declare function restorePersistedQueries(qc: QueryClient, { storage, buster, now, }: {
26
+ storage: KeyValueStorage | null;
27
+ buster: string;
28
+ now?: number;
29
+ }): void;
30
+ /**
31
+ * Saves the kept queries of the signed-in user while the app runs. When the session ends (sign-out,
32
+ * a 401 for a disabled user or a revoked session) the saved copy is removed and `clearCaches` runs
33
+ * (it removes the photo and file caches); when a different user signs in, the earlier user's data
34
+ * also leaves memory. `clearCaches` runs once per user who leaves.
35
+ */
36
+ export declare function startQueryPersistence(qc: QueryClient, { storage, buster, clearCaches, }: {
37
+ storage: KeyValueStorage | null;
38
+ buster: string;
39
+ clearCaches: () => void;
40
+ }): () => void;
41
+ /** Removes every user's saved copy (sign-out). */
42
+ export declare function dropPersistedQueries(storage: KeyValueStorage | null): void;
43
+ export {};
@@ -7,9 +7,17 @@ export interface TypingEntry {
7
7
  }
8
8
  export interface RealtimeValue {
9
9
  connected: boolean;
10
+ /**
11
+ * Lists may refresh now: the live connection is up (or there is none to wait for, or it did not
12
+ * come within SOCKET_WAIT_MS). While it is down, a list already on screen waits for it: the
13
+ * connection reloads every list when it joins, so loading before would load twice.
14
+ */
15
+ refreshReady: boolean;
10
16
  typing: Record<string, TypingEntry[]>;
11
17
  emitTyping(jid: string): void;
12
18
  }
19
+ /** How long a kept chat list waits for the live connection before it loads anyway. */
20
+ export declare const SOCKET_WAIT_MS = 4000;
13
21
  /**
14
22
  * When a load of `queryKey` is running, load it again after it ends: that load was answered before
15
23
  * the event that called this, so its result would hide the event's change. (React Query reuses a
@@ -7,7 +7,7 @@ export declare function useVoiceStatus(): import("@tanstack/react-query").UseQue
7
7
  state: "error" | "not_installed" | "downloading" | "installed";
8
8
  receivedBytes: number;
9
9
  totalBytes: number;
10
- error: "network" | "unknown" | "write" | "disk_space" | "verification" | "redirect" | null;
10
+ error: "network" | "redirect" | "unknown" | "write" | "disk_space" | "verification" | null;
11
11
  };
12
12
  cloudAvailable: boolean;
13
13
  }, Error>;
@@ -27,7 +27,7 @@ export declare function useVoiceAction(): import("@tanstack/react-query").UseMut
27
27
  state: "error" | "not_installed" | "downloading" | "installed";
28
28
  receivedBytes: number;
29
29
  totalBytes: number;
30
- error: "network" | "unknown" | "write" | "disk_space" | "verification" | "redirect" | null;
30
+ error: "network" | "redirect" | "unknown" | "write" | "disk_space" | "verification" | null;
31
31
  };
32
32
  cloudAvailable: boolean;
33
33
  }, Error, VoiceAction, unknown>;
@@ -0,0 +1,2 @@
1
+ /** Never throws or hangs: sign-out must finish even where the browser refuses storage or caches. */
2
+ export declare function clearUserCaches(): Promise<void>;
@@ -1482,6 +1482,127 @@ export declare const enResources: {
1482
1482
  admin: string;
1483
1483
  noName: string;
1484
1484
  };
1485
+ groupAdmin: {
1486
+ title: string;
1487
+ agentOnly: string;
1488
+ notAdminTitle: string;
1489
+ notAdminBody: string;
1490
+ offline: string;
1491
+ inviteOnly: string;
1492
+ inviteOnlyNoMax: string;
1493
+ edit: string;
1494
+ add: string;
1495
+ link: string;
1496
+ invite: string;
1497
+ settings: string;
1498
+ full: string;
1499
+ requests_one: string;
1500
+ requests_other: string;
1501
+ approve: string;
1502
+ reject: string;
1503
+ approved: string;
1504
+ editTitle: string;
1505
+ editHint: string;
1506
+ name: string;
1507
+ description: string;
1508
+ descriptionPlaceholder: string;
1509
+ saved: string;
1510
+ cancel: string;
1511
+ save: string;
1512
+ done: string;
1513
+ addTitle: string;
1514
+ addHint: string;
1515
+ phone: string;
1516
+ banRisk: string;
1517
+ addButton: string;
1518
+ addedToast: string;
1519
+ privacyTitle: string;
1520
+ privacyBody: string;
1521
+ sendInvite: string;
1522
+ invitedTitle: string;
1523
+ invitedBody: string;
1524
+ linkTitle: string;
1525
+ linkHint: string;
1526
+ linkHintApi: string;
1527
+ linkApproval: string;
1528
+ copy: string;
1529
+ copied: string;
1530
+ reset: string;
1531
+ resetTitle: string;
1532
+ resetBody: string;
1533
+ resetConfirm: string;
1534
+ resetDone: string;
1535
+ settingsTitle: string;
1536
+ settingsHint: string;
1537
+ settingsApi: string;
1538
+ set: {
1539
+ announce: string;
1540
+ announceHint: string;
1541
+ locked: string;
1542
+ lockedHint: string;
1543
+ memberAdd: string;
1544
+ onlyAdmins: string;
1545
+ everyone: string;
1546
+ approval: string;
1547
+ approvalHint: string;
1548
+ };
1549
+ history: string;
1550
+ historyNote: string;
1551
+ log: {
1552
+ name: string;
1553
+ description: string;
1554
+ added: string;
1555
+ invited: string;
1556
+ removed: string;
1557
+ promoted: string;
1558
+ demoted: string;
1559
+ linkReset: string;
1560
+ approved: string;
1561
+ rejected: string;
1562
+ setting: {
1563
+ announce: string;
1564
+ locked: string;
1565
+ memberAdd: string;
1566
+ approval: string;
1567
+ };
1568
+ someone: string;
1569
+ someMember: string;
1570
+ };
1571
+ memberActions: string;
1572
+ ownerNote: string;
1573
+ makeAdmin: string;
1574
+ removeAdmin: string;
1575
+ remove: string;
1576
+ promoted: string;
1577
+ demoted: string;
1578
+ removed: string;
1579
+ removeTitle: string;
1580
+ removeBody: string;
1581
+ removeBodyApi: string;
1582
+ removeConfirm: string;
1583
+ demoteTitle: string;
1584
+ demoteBody: string;
1585
+ demoteConfirm: string;
1586
+ err: {
1587
+ offline: string;
1588
+ notAdmin: string;
1589
+ already: string;
1590
+ notOnWhatsApp: string;
1591
+ tooMany: string;
1592
+ owner: string;
1593
+ notSupported: string;
1594
+ notMember: string;
1595
+ full: string;
1596
+ inviteExpired: string;
1597
+ inboxRemoved: string;
1598
+ failed: string;
1599
+ };
1600
+ historyEmpty: string;
1601
+ settingsNone: string;
1602
+ linkUnavailable: string;
1603
+ tipTitle: string;
1604
+ tipBody: string;
1605
+ };
1485
1606
  };
1486
1607
  admin: {
1487
1608
  title: string;
@@ -2689,6 +2810,7 @@ export declare const enResources: {
2689
2810
  services: string;
2690
2811
  shops: string;
2691
2812
  education: string;
2813
+ operations: string;
2692
2814
  };
2693
2815
  noMatch: string;
2694
2816
  dental: {
@@ -2831,6 +2953,28 @@ export declare const enResources: {
2831
2953
  contextName: string;
2832
2954
  contextText: string;
2833
2955
  };
2956
+ groupAgentTag: string;
2957
+ groupSetupNew: string;
2958
+ groupSetupExisting: string;
2959
+ groupSetupNext: string;
2960
+ groupSetupDone: string;
2961
+ groupSetupFailed: string;
2962
+ claims: {
2963
+ name: string;
2964
+ description: string;
2965
+ keywords: string;
2966
+ agentName: string;
2967
+ focus: string;
2968
+ handoffRules: string;
2969
+ contextName: string;
2970
+ contextText: string;
2971
+ };
2972
+ source: {
2973
+ loaded: string;
2974
+ builtin: string;
2975
+ offline: string;
2976
+ };
2977
+ worksWith: string;
2834
2978
  };
2835
2979
  resolution: {
2836
2980
  title: string;
@@ -28,6 +28,27 @@ export declare function shiftIssues<T extends {
28
28
  }>(issues: T[], before: string, after: string): T[];
29
29
  /** Applies the marks that have a fix (they never overlap); a mark whose text changed is skipped. */
30
30
  export declare function applyFixes(text: string, issues: readonly FixIssue[], pick?: string): string;
31
+ /**
32
+ * What a fix adds when it only inserts text ("email" → "email." adds "."; "email" → "your email"
33
+ * adds "your "), else ''.
34
+ */
35
+ export declare function insertedText(original: string, replacement: string): string;
36
+ /** A fix applied in this draft: where its text now stands, and what it inserted. */
37
+ interface AppliedFix {
38
+ start: number;
39
+ end: number;
40
+ inserted: string;
41
+ }
42
+ /**
43
+ * The grammar marks of one answer: in order, never two on the same text (the first wins), and
44
+ * never the same insertion again where this draft already got it ("email." + "." → "email..").
45
+ */
46
+ export declare function grammarMarks(issues: readonly {
47
+ start: number;
48
+ end: number;
49
+ original: string;
50
+ replacement: string;
51
+ }[], applied: readonly AppliedFix[]): FixIssue[];
31
52
  export declare function useFixEnglish(text: string, { jid, status, chatName, teamWords, disabled, }: {
32
53
  jid: string | null;
33
54
  status: FixEnglishStatus | undefined;
@@ -39,6 +60,11 @@ export declare function useFixEnglish(text: string, { jid, status, chatName, tea
39
60
  issues: FixIssue[];
40
61
  fixable: FixIssue[];
41
62
  grammarStatus: GrammarStatus;
63
+ /**
64
+ * The text with these fixes applied (`pick` for a choice in the card), remembered for this
65
+ * draft so a later check never offers the same insertion at the same place again.
66
+ */
67
+ apply(current: string, list: readonly FixIssue[], pick?: string): string;
42
68
  ignore(issue: FixIssue): void;
43
69
  };
44
70
  /**
@@ -86,3 +112,4 @@ export declare function FixEnglishButton({ count, marks, grammarStatus, grammar,
86
112
  onFixAll(): void;
87
113
  onUndo(): void;
88
114
  }): import("react").JSX.Element;
115
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { GroupInfoResponse, GroupMember } from '@ezychat/shared';
2
+ /**
3
+ * Manage group (design docs/features/group-management/design.md): EzyChat admins change a WhatsApp
4
+ * group from Group info, with only the actions this connection supports (`caps`, never a type
5
+ * name) while the linked number is a group admin; agents and non-admin numbers see why they can't.
6
+ */
7
+ export declare function GroupAdminBar({ data }: Readonly<{
8
+ data: GroupInfoResponse;
9
+ }>): import("react").JSX.Element | null;
10
+ /** Member details: make / remove group admin and remove from the group. Never for me. */
11
+ export declare function MemberAdminActions({ groupJid, member, label, onRemoved, }: Readonly<{
12
+ groupJid: string;
13
+ member: GroupMember;
14
+ label: string;
15
+ onRemoved(): void;
16
+ }>): import("react").JSX.Element | null;
@@ -0,0 +1,23 @@
1
+ import { type GroupAdminResponse, type GroupChange, type GroupInfoResponse } from '@ezychat/shared';
2
+ import { type T } from './GroupAdminShared';
3
+ export declare function EditGroupDialog({ jid, data, view, onClose, }: Readonly<{
4
+ jid: string;
5
+ data: GroupInfoResponse;
6
+ view: GroupAdminResponse;
7
+ onClose(): void;
8
+ }>): import("react").JSX.Element;
9
+ export declare function AddMemberDialog({ jid, onClose }: Readonly<{
10
+ jid: string;
11
+ onClose(): void;
12
+ }>): import("react").JSX.Element;
13
+ export declare function InviteLinkDialog({ jid, view, onClose, }: Readonly<{
14
+ jid: string;
15
+ view: GroupAdminResponse;
16
+ onClose(): void;
17
+ }>): import("react").JSX.Element;
18
+ export declare function changeLine(c: GroupChange, t: T): string;
19
+ export declare function GroupSettingsDialog({ jid, view, onClose, }: Readonly<{
20
+ jid: string;
21
+ view: GroupAdminResponse;
22
+ onClose(): void;
23
+ }>): import("react").JSX.Element;
@@ -0,0 +1,60 @@
1
+ import type { useTranslation } from 'react-i18next';
2
+ import type { GroupAdminCaps, GroupAdminResponse } from '@ezychat/shared';
3
+ export type T = ReturnType<typeof useTranslation<'inbox'>>['t'];
4
+ export declare function groupAdminErrorText(err: unknown, t: T): string;
5
+ /** Whether the connection lets EzyChat change anything in this group. */
6
+ export declare function hasAnyGroupCap(caps: GroupAdminCaps): boolean;
7
+ /** Why nothing can be changed right now: one reason, in this order. */
8
+ export type GroupAdminBlock = 'agent' | 'notAdmin' | 'offline' | null;
9
+ export declare function groupAdminBlock(view: GroupAdminResponse): GroupAdminBlock;
10
+ /** The admin view of a group, and whether this user may change it now. */
11
+ export declare function useGroupAdminState(jid: string): {
12
+ view: {
13
+ caps: {
14
+ editInfo: boolean;
15
+ addMembers: boolean;
16
+ inviteOnly: boolean;
17
+ removeMembers: boolean;
18
+ admins: boolean;
19
+ inviteLink: boolean;
20
+ resetInviteLink: boolean;
21
+ settings: ("locked" | "announce" | "memberAdd" | "approval")[];
22
+ joinRequests: boolean;
23
+ maxMembers: number | null;
24
+ nameMax: number;
25
+ descriptionMax: number;
26
+ };
27
+ canManage: boolean;
28
+ online: boolean;
29
+ myRole: "admin" | "member" | "superadmin" | null;
30
+ settings: {
31
+ announce?: boolean | undefined;
32
+ locked?: boolean | undefined;
33
+ memberAdd?: "all" | "admins" | undefined;
34
+ approval?: boolean | undefined;
35
+ };
36
+ inviteLink: string | null;
37
+ requests: {
38
+ jid: string;
39
+ phone: string | null;
40
+ name: string | null;
41
+ at: number | null;
42
+ }[];
43
+ changes: {
44
+ at: number;
45
+ byUserId: number | null;
46
+ byName: string | null;
47
+ action: "description" | "setting" | "rename" | "member_add" | "member_invite" | "member_remove" | "admin_promote" | "admin_demote" | "invite_reset" | "join_approve" | "join_reject";
48
+ memberJid: string | null;
49
+ memberName: string | null;
50
+ setting: "locked" | "announce" | "memberAdd" | "approval" | null;
51
+ value: boolean | "all" | "admins" | null;
52
+ }[];
53
+ size: number | null;
54
+ } | undefined;
55
+ anyCap: boolean;
56
+ block: GroupAdminBlock;
57
+ can: boolean;
58
+ };
59
+ /** Members besides the business number (the count the Business API limit uses). */
60
+ export declare function othersCount(view: GroupAdminResponse, fallbackSize: number): number;
@@ -1,5 +1,4 @@
1
- /** One connection generation shared by every photo, including list and conversation copies. */
1
+ /** Photos load only while WhatsApp is connected; shared by list and conversation copies. */
2
2
  export declare const ProfileImageContext: import("react").Context<{
3
3
  ready: boolean;
4
- revision: number;
5
4
  }>;
@@ -0,0 +1,42 @@
1
+ /** Contact and group member photos. */
2
+ export declare const AVATAR_CACHE = "ezy-avatars-v1";
3
+ /** Message files (`/api/media/:id`). */
4
+ export declare const MEDIA_CACHE = "ezy-media-v1";
5
+ /** Every version of the per-user caches: removed on sign-out and when another user signs in. */
6
+ export declare const USER_CACHE_PREFIXES: readonly ["ezy-avatars-", "ezy-media-"];
7
+ /** Message the page posts to the service worker to remove the per-user caches. */
8
+ export declare const CLEAR_USER_CACHES = "clear-user-caches";
9
+ export declare const AVATAR_LIMITS: {
10
+ maxEntries: number;
11
+ maxAgeSeconds: number;
12
+ };
13
+ export declare const MEDIA_LIMITS: {
14
+ maxEntries: number;
15
+ maxAgeSeconds: number;
16
+ };
17
+ type RouteRequest = Pick<Request, 'method' | 'cache' | 'headers'>;
18
+ export declare function isAvatarRequest(url: URL, request: RouteRequest, origin: string): boolean;
19
+ /**
20
+ * Byte-range requests (audio and video players) stay on the network: a cached whole file cannot
21
+ * answer them, and a partial (206) answer is never stored.
22
+ */
23
+ export declare function isMediaRequest(url: URL, request: RouteRequest, origin: string): boolean;
24
+ /** Workbox plugin: never store a response the server marked `no-store` (e.g. a flagged file). */
25
+ export declare const noStorePlugin: {
26
+ cacheWillUpdate: ({ response }: {
27
+ response: Response;
28
+ }) => Promise<Response | null>;
29
+ };
30
+ /** Largest message file the phone keeps: one long video must not fill the phone's storage. */
31
+ export declare const MEDIA_MAX_BYTES: number;
32
+ /** Workbox plugin for message files: never store one larger than MEDIA_MAX_BYTES. */
33
+ export declare const mediaSizePlugin: {
34
+ cacheWillUpdate: ({ response }: {
35
+ response: Response;
36
+ }) => Promise<Response | null>;
37
+ };
38
+ export declare function isClearUserCachesMessage(data: unknown): boolean;
39
+ export declare function isUserCacheName(name: string): boolean;
40
+ /** Removes the photo and file caches; the app's own precache stays. */
41
+ export declare function deleteUserCaches(storage: Pick<CacheStorage, 'keys' | 'delete'>): Promise<void>;
42
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ezychat/web",
3
- "version": "0.1.73",
3
+ "version": "0.1.76",
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.73",
43
+ "@ezychat/shared": "0.1.76",
44
44
  "@fontsource-variable/inter": "^5.3.0",
45
45
  "@tanstack/react-query": "^5.105.0",
46
46
  "@types/react": "^19.3.0",
@@ -81,7 +81,11 @@
81
81
  "tailwindcss": "^4.3.3",
82
82
  "vite": "^8.3.5",
83
83
  "vite-plugin-pwa": "^2.0.0",
84
+ "workbox-cacheable-response": "^7.4.1",
85
+ "workbox-expiration": "^7.4.1",
84
86
  "workbox-precaching": "^7.4.1",
87
+ "workbox-routing": "^7.4.1",
88
+ "workbox-strategies": "^7.4.1",
85
89
  "workbox-window": "^7.4.1"
86
90
  }
87
91
  }