@tinycloud/web-sdk 3.7.0-beta.2 → 3.7.0-beta.3
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/README.md +40 -0
- package/dist/adapters/BrowserNotificationHandler.d.ts +22 -6
- package/dist/authorization/WebSpaceCreationHandler.d.ts +12 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +1 -1
- package/dist/modals.cjs +1 -0
- package/dist/modals.mjs +1 -0
- package/dist/modules/tcw.d.ts +16 -2
- package/dist/notifications/ModalManager.d.ts +21 -7
- package/dist/notifications/PermissionRequestModal.d.ts +8 -1
- package/dist/notifications/SpaceCreationModal.d.ts +8 -1
- package/dist/notifications/dialogFocus.d.ts +39 -0
- package/dist/notifications/index.d.ts +1 -6
- package/dist/notifications/lazy-prompts.d.ts +16 -0
- package/dist/notifications/legacy-config.d.ts +11 -0
- package/dist/notifications/modals-entry.d.ts +7 -0
- package/dist/notifications/modals-registry.d.ts +15 -0
- package/dist/notifications/scrollLock.d.ts +2 -0
- package/dist/notifications/types.d.ts +6 -33
- package/dist/notifications/types.schema.d.ts +7 -148
- package/dist/panel-data.cjs +1 -0
- package/dist/panel-data.mjs +1 -0
- package/dist/panel.cjs +1 -0
- package/dist/panel.mjs +1 -0
- package/dist/ui/api.d.ts +30 -0
- package/dist/ui/button.d.ts +10 -0
- package/dist/ui/client.d.ts +27 -0
- package/dist/ui/config.d.ts +35 -0
- package/dist/ui/data/map.d.ts +23 -0
- package/dist/ui/data/prefetch.d.ts +18 -0
- package/dist/ui/data/real.d.ts +12 -0
- package/dist/ui/data.d.ts +241 -0
- package/dist/ui/frame-guard.d.ts +7 -0
- package/dist/ui/host.d.ts +29 -0
- package/dist/ui/ids.d.ts +7 -0
- package/dist/ui/index.d.ts +38 -0
- package/dist/ui/manage-url.d.ts +8 -0
- package/dist/ui/panel-data-entry.d.ts +28 -0
- package/dist/ui/panel-entry.d.ts +23 -0
- package/dist/ui/panel-modal.d.ts +13 -0
- package/dist/ui/panel-styles.d.ts +10 -0
- package/dist/ui/panel-toasts.d.ts +30 -0
- package/dist/ui/panel.d.ts +42 -0
- package/dist/ui/parts/index.d.ts +4 -0
- package/dist/ui/parts/prompts.d.ts +39 -0
- package/dist/ui/parts/storage-watch.d.ts +11 -0
- package/dist/ui/parts/sync-status.d.ts +7 -0
- package/dist/ui/parts/toasts.d.ts +8 -0
- package/dist/ui/pending.d.ts +13 -0
- package/dist/ui/persistence.d.ts +28 -0
- package/dist/ui/phone.d.ts +14 -0
- package/dist/ui/section-data.d.ts +20 -0
- package/dist/ui/section-dialogs.d.ts +10 -0
- package/dist/ui/sections/account.d.ts +3 -0
- package/dist/ui/sections/account.strings.d.ts +29 -0
- package/dist/ui/sections/activity.d.ts +7 -0
- package/dist/ui/sections/activity.strings.d.ts +46 -0
- package/dist/ui/sections/delegations.d.ts +25 -0
- package/dist/ui/sections/delegations.strings.d.ts +143 -0
- package/dist/ui/sections/freshness-copy.d.ts +17 -0
- package/dist/ui/sections/index.d.ts +4 -0
- package/dist/ui/sections/local-copy.d.ts +3 -0
- package/dist/ui/sections/local-copy.strings.d.ts +70 -0
- package/dist/ui/sections/local-tinycloud.d.ts +9 -0
- package/dist/ui/sections/local-tinycloud.strings.d.ts +48 -0
- package/dist/ui/sections/nodes.d.ts +7 -0
- package/dist/ui/sections/nodes.strings.d.ts +27 -0
- package/dist/ui/sections/placeholder.d.ts +8 -0
- package/dist/ui/sections/status.d.ts +10 -0
- package/dist/ui/sections/storage.d.ts +37 -0
- package/dist/ui/sections/storage.strings.d.ts +37 -0
- package/dist/ui/sections/ui.d.ts +77 -0
- package/dist/ui/sections/view-body.d.ts +23 -0
- package/dist/ui/sign-out-purge.d.ts +39 -0
- package/dist/ui/slots.d.ts +218 -0
- package/dist/ui/status.d.ts +16 -0
- package/dist/ui/storage-state.d.ts +12 -0
- package/dist/ui/strings-panel.d.ts +29 -0
- package/dist/ui/strings.d.ts +76 -0
- package/dist/ui/stub/index.d.ts +48 -0
- package/dist/ui/styles.d.ts +9 -0
- package/dist/ui/toast-store.d.ts +46 -0
- package/dist/ui/view-result.d.ts +6 -0
- package/package.json +13 -4
- package/dist/notifications/ErrorHandler.d.ts +0 -32
- package/dist/notifications/NodeSelectionModal.d.ts +0 -29
- package/dist/notifications/ToastContainer.d.ts +0 -16
- package/dist/notifications/ToastElement.d.ts +0 -22
- package/dist/notifications/ToastManager.d.ts +0 -36
|
@@ -1,152 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Zod schemas for TinyCloud notification and modal types.
|
|
2
|
+
* Zod schemas for TinyCloud notification configuration and modal types.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* notification configuration, and modal types. Types are derived from
|
|
6
|
-
* schemas using z.infer<>.
|
|
4
|
+
* Types are derived from schemas using z.infer<>.
|
|
7
5
|
*
|
|
8
6
|
* @packageDocumentation
|
|
9
7
|
*/
|
|
10
8
|
import { z } from "zod";
|
|
11
9
|
/**
|
|
12
|
-
* Toast
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export type ToastType = z.infer<typeof ToastTypeSchema>;
|
|
16
|
-
/**
|
|
17
|
-
* Toast position on screen.
|
|
18
|
-
*/
|
|
19
|
-
export declare const ToastPositionSchema: z.ZodEnum<["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"]>;
|
|
20
|
-
export type ToastPosition = z.infer<typeof ToastPositionSchema>;
|
|
21
|
-
/**
|
|
22
|
-
* Action button for a toast notification.
|
|
23
|
-
*/
|
|
24
|
-
export declare const ToastActionSchema: z.ZodObject<{
|
|
25
|
-
label: z.ZodString;
|
|
26
|
-
onClick: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>;
|
|
27
|
-
}, "strip", z.ZodTypeAny, {
|
|
28
|
-
label?: string;
|
|
29
|
-
onClick?: (...args: unknown[]) => unknown;
|
|
30
|
-
}, {
|
|
31
|
-
label?: string;
|
|
32
|
-
onClick?: (...args: unknown[]) => unknown;
|
|
33
|
-
}>;
|
|
34
|
-
export type ToastAction = z.infer<typeof ToastActionSchema>;
|
|
35
|
-
/**
|
|
36
|
-
* Toast notification.
|
|
37
|
-
*/
|
|
38
|
-
export declare const ToastSchema: z.ZodObject<{
|
|
39
|
-
id: z.ZodString;
|
|
40
|
-
type: z.ZodEnum<["success", "error", "warning", "info", "loading"]>;
|
|
41
|
-
title: z.ZodString;
|
|
42
|
-
description: z.ZodOptional<z.ZodString>;
|
|
43
|
-
duration: z.ZodOptional<z.ZodNumber>;
|
|
44
|
-
action: z.ZodOptional<z.ZodObject<{
|
|
45
|
-
label: z.ZodString;
|
|
46
|
-
onClick: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>;
|
|
47
|
-
}, "strip", z.ZodTypeAny, {
|
|
48
|
-
label?: string;
|
|
49
|
-
onClick?: (...args: unknown[]) => unknown;
|
|
50
|
-
}, {
|
|
51
|
-
label?: string;
|
|
52
|
-
onClick?: (...args: unknown[]) => unknown;
|
|
53
|
-
}>>;
|
|
54
|
-
timestamp: z.ZodNumber;
|
|
55
|
-
}, "strip", z.ZodTypeAny, {
|
|
56
|
-
description?: string;
|
|
57
|
-
type?: "error" | "success" | "warning" | "info" | "loading";
|
|
58
|
-
id?: string;
|
|
59
|
-
title?: string;
|
|
60
|
-
duration?: number;
|
|
61
|
-
action?: {
|
|
62
|
-
label?: string;
|
|
63
|
-
onClick?: (...args: unknown[]) => unknown;
|
|
64
|
-
};
|
|
65
|
-
timestamp?: number;
|
|
66
|
-
}, {
|
|
67
|
-
description?: string;
|
|
68
|
-
type?: "error" | "success" | "warning" | "info" | "loading";
|
|
69
|
-
id?: string;
|
|
70
|
-
title?: string;
|
|
71
|
-
duration?: number;
|
|
72
|
-
action?: {
|
|
73
|
-
label?: string;
|
|
74
|
-
onClick?: (...args: unknown[]) => unknown;
|
|
75
|
-
};
|
|
76
|
-
timestamp?: number;
|
|
77
|
-
}>;
|
|
78
|
-
export type Toast = z.infer<typeof ToastSchema>;
|
|
79
|
-
/**
|
|
80
|
-
* Toast configuration.
|
|
81
|
-
*/
|
|
82
|
-
export declare const ToastConfigSchema: z.ZodObject<{
|
|
83
|
-
position: z.ZodOptional<z.ZodEnum<["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"]>>;
|
|
84
|
-
duration: z.ZodOptional<z.ZodNumber>;
|
|
85
|
-
maxVisible: z.ZodOptional<z.ZodNumber>;
|
|
86
|
-
}, "strip", z.ZodTypeAny, {
|
|
87
|
-
duration?: number;
|
|
88
|
-
position?: "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
89
|
-
maxVisible?: number;
|
|
90
|
-
}, {
|
|
91
|
-
duration?: number;
|
|
92
|
-
position?: "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
93
|
-
maxVisible?: number;
|
|
94
|
-
}>;
|
|
95
|
-
export type ToastConfig = z.infer<typeof ToastConfigSchema>;
|
|
96
|
-
/**
|
|
97
|
-
* Notification configuration.
|
|
10
|
+
* Notification configuration. Toast placement and visibility are set through
|
|
11
|
+
* `ui`. `.strict()` rejects the removed `popups`, `position`, `duration`, and
|
|
12
|
+
* `maxVisible` keys.
|
|
98
13
|
*/
|
|
99
14
|
export declare const NotificationConfigSchema: z.ZodObject<{
|
|
100
|
-
popups: z.ZodOptional<z.ZodBoolean>;
|
|
101
15
|
throwErrors: z.ZodOptional<z.ZodBoolean>;
|
|
102
|
-
|
|
103
|
-
duration: z.ZodOptional<z.ZodNumber>;
|
|
104
|
-
maxVisible: z.ZodOptional<z.ZodNumber>;
|
|
105
|
-
}, "strip", z.ZodTypeAny, {
|
|
106
|
-
duration?: number;
|
|
107
|
-
position?: "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
108
|
-
maxVisible?: number;
|
|
109
|
-
popups?: boolean;
|
|
16
|
+
}, "strict", z.ZodTypeAny, {
|
|
110
17
|
throwErrors?: boolean;
|
|
111
18
|
}, {
|
|
112
|
-
duration?: number;
|
|
113
|
-
position?: "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
114
|
-
maxVisible?: number;
|
|
115
|
-
popups?: boolean;
|
|
116
19
|
throwErrors?: boolean;
|
|
117
20
|
}>;
|
|
118
|
-
export type NotificationConfig = z.infer<typeof NotificationConfigSchema>;
|
|
119
|
-
/**
|
|
120
|
-
* SDK error detail.
|
|
121
|
-
*/
|
|
122
|
-
export declare const SDKErrorDetailSchema: z.ZodObject<{
|
|
123
|
-
category: z.ZodString;
|
|
124
|
-
message: z.ZodString;
|
|
125
|
-
description: z.ZodOptional<z.ZodString>;
|
|
126
|
-
}, "strip", z.ZodTypeAny, {
|
|
127
|
-
message?: string;
|
|
128
|
-
description?: string;
|
|
129
|
-
category?: string;
|
|
130
|
-
}, {
|
|
131
|
-
message?: string;
|
|
132
|
-
description?: string;
|
|
133
|
-
category?: string;
|
|
134
|
-
}>;
|
|
135
|
-
export type SDKErrorDetail = z.infer<typeof SDKErrorDetailSchema>;
|
|
136
|
-
/**
|
|
137
|
-
* SDK event detail.
|
|
138
|
-
*/
|
|
139
|
-
export declare const SDKEventDetailSchema: z.ZodObject<{
|
|
140
|
-
message: z.ZodString;
|
|
141
|
-
description: z.ZodOptional<z.ZodString>;
|
|
142
|
-
}, "strip", z.ZodTypeAny, {
|
|
143
|
-
message?: string;
|
|
144
|
-
description?: string;
|
|
145
|
-
}, {
|
|
146
|
-
message?: string;
|
|
147
|
-
description?: string;
|
|
148
|
-
}>;
|
|
149
|
-
export type SDKEventDetail = z.infer<typeof SDKEventDetailSchema>;
|
|
150
21
|
/**
|
|
151
22
|
* Options for the space creation modal.
|
|
152
23
|
*/
|
|
@@ -197,18 +68,10 @@ export type ValidationResult<T> = {
|
|
|
197
68
|
ok: false;
|
|
198
69
|
error: ValidationError;
|
|
199
70
|
};
|
|
200
|
-
/**
|
|
201
|
-
* Validates Toast.
|
|
202
|
-
*/
|
|
203
|
-
export declare function validateToast(data: unknown): ValidationResult<Toast>;
|
|
204
|
-
/**
|
|
205
|
-
* Validates ToastConfig.
|
|
206
|
-
*/
|
|
207
|
-
export declare function validateToastConfig(data: unknown): ValidationResult<ToastConfig>;
|
|
208
71
|
/**
|
|
209
72
|
* Validates NotificationConfig.
|
|
210
73
|
*/
|
|
211
|
-
export declare function validateNotificationConfig(data: unknown): ValidationResult<
|
|
74
|
+
export declare function validateNotificationConfig(data: unknown): ValidationResult<z.infer<typeof NotificationConfigSchema>>;
|
|
212
75
|
/**
|
|
213
76
|
* Validates SpaceCreationModalOptions.
|
|
214
77
|
*/
|
|
@@ -217,8 +80,4 @@ export declare function validateSpaceCreationModalOptions(data: unknown): Valida
|
|
|
217
80
|
* Validates SpaceCreationResult.
|
|
218
81
|
*/
|
|
219
82
|
export declare function validateSpaceCreationResult(data: unknown): ValidationResult<SpaceCreationResult>;
|
|
220
|
-
/**
|
|
221
|
-
* Validates SDKErrorDetail.
|
|
222
|
-
*/
|
|
223
|
-
export declare function validateSDKErrorDetail(data: unknown): ValidationResult<SDKErrorDetail>;
|
|
224
83
|
//# sourceMappingURL=types.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{"use strict";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(){return new Promise(e=>{"requestIdleCallback"in globalThis?globalThis.requestIdleCallback(()=>e(),{timeout:3e3}):setTimeout(e,2e3)})}function o(e){return{state:"ready",data:e}}function n(e){return{state:"needs-permission",ability:e}}function a(e){return{state:"error",code:e}}e.r(t),e.d(t,{arm:()=>S,livePanelData:()=>D,onLivePanelDataChange:()=>A});const i=864e5;function s(e){const t=e.indexOf("#");return-1!==t&&-1===e.indexOf("#",t+1)?e.slice(0,t):e}function c(e,t){return"received"===e.direction?"received":(r=t,s(e.delegateDid)===s(r)?"this-app":"to-others");var r}function d(e,t){if(!e)return!1;const r=e.getTime()-t;return r>0&&r<=i}const l=5e3,u="SQL_ERROR",f={spaces:/^(?:SQL query failed: 400 - )?SQLite error: no such table:\s*spaces(?![\w$.\-])/i,applications:/^(?:SQL query failed: 400 - )?SQLite error: no such table:\s*applications(?![\w$.\-])/i};function g(e,t){return!0===e.ok?e.data.length:e.error.code===u&&f[t].test(e.error.message??"")?void 0:e.error.code}const v=6e4,p=6e4,y=1e4,h=50,b={account:["overview"],delegations:["delegations"],storage:["storage"]};const k=new WeakMap,m=new WeakMap;function w(e){for(const t of[...m.get(e)??[]])t()}function S(e,t={}){const i=k.get(e);if(i)return void(t.now&&i.prefetch.intent());const{host:s,gate:u}=t;if(!s||!u||!e.signedIn())return;const f=e.data??function(e,t,r){const i=new Set,s=new Map;let u=0;const f=new Set;t.onReset(()=>{for(const e of s.values())clearTimeout(e.retryTimer);u+=1,s.clear(),f.clear()});const k=e=>{let t=s.get(e);return t||(t={at:0,checkedAt:0,refreshing:!1},s.set(e,t)),t},m=e=>{for(const t of b[e])for(const e of i)e(t)};function w(e,t){const r=k(e);if(r.inflight)return r.inflight;const o=u,n=t().catch(()=>a("unavailable")).then(e=>{o===u&&("error"!==e.state||"ready"!==r.value?.state?(r.value=e,r.at=Date.now(),r.lastError=void 0,"ready"===e.state&&(r.retried=!1,clearTimeout(r.retryTimer),r.retryTimer=void 0)):r.lastError=e.code)}).finally(()=>{o===u&&(r.inflight=void 0,r.checkedAt=Date.now(),r.refreshing=!1,m(e),"account"!==e||"error"!==r.value?.state||r.retried||(r.retried=!0,r.retryTimer=setTimeout(()=>{r.retryTimer=void 0,o===u&&w(e,t)},l)))});return r.inflight=n,r.refreshing=!0,m(e),n}function S(e,t){return"ready"!==t.state?t:{...t,freshness:{updatedAt:e.at,refreshing:e.refreshing,lastError:e.lastError}}}async function D(e,t,r,o=!1){const n=k(e);if(void 0===n.value||o){const t=u;return await w(e,r),t!==u||void 0===n.value?{state:"loading"}:S(n,n.value)}return Date.now()-n.checkedAt>t&&w(e,r),S(n,n.value)}async function A(t){const r=u,i=await e.delegations.query({direction:"all",limit:h,...t?{cursor:t}:{}});if(r!==u)return a("stale");if(!1===i.ok)return"PERMISSION_DENIED"===i.error.code?n("delegation/list"):a(i.error.code);const s=Date.now();return i.data.nextCursor&&f.add(i.data.nextCursor),o({rows:i.data.items.map(t=>function(e,t,r){return{source:"real",cid:e.cid,direction:e.direction,status:e.status,group:c(e,t),label:{text:(o=e.delegateDid,o.length<=22?o:`${o.slice(0,14)}…${o.slice(-6)}`),source:"derived"},delegatorDid:e.delegatorDid,delegateDid:e.delegateDid,resources:e.resources.map(e=>({resource:e.resource,actions:e.actions})),parents:e.parents,issuedAt:e.issuedAt,notBefore:e.notBefore,expiresAt:e.expiresAt,expiringSoon:d(e.expiresAt,r),...void 0!==e.revokedAt?{revokedAt:e.revokedAt}:{},...void 0!==e.revokedBy?{revokedBy:e.revokedBy}:{},...void 0!==e.revokedAncestorCid?{revokedAncestorCid:e.revokedAncestorCid}:{}};var o}(t,e.sessionDid,s)),...i.data.nextCursor?{nextCursor:i.data.nextCursor}:{}})}async function T(){const[t,n,i]=await Promise.all([e.account.index.spaces.list(),e.account.index.applications.list(),D("delegations",y,()=>A())]),s=g(t,"spaces");if("string"==typeof s)return a(s);const c=g(n,"applications");if("string"==typeof c)return a(c);const d="ready"===i.state?i.data.rows:void 0,l=d?.filter(e=>"granted"===e.direction).length??0,u=d?.filter(e=>"received"===e.direction).length??0;return o({source:"real",fieldSources:{grantedDelegations:"derived",receivedDelegations:"derived"},did:e.did,host:e.hosts[0]??"",...void 0!==c?{applications:c}:{},...void 0!==s?{spaces:s}:{},grantedDelegations:l,receivedDelegations:u,appName:r})}async function x(){const t=await e.storage.status();return!1===t.ok?"PERMISSION_DENIED"===t.error.code||"AUTH_UNAUTHORIZED"===t.error.code?n("space/info"):a(t.error.code):o({source:"real",...t.data})}return{subscribe:e=>(i.add(e),()=>{i.delete(e)}),account:()=>D("account",v,T),knownDid:()=>0===u?e.did:void 0,async localNode(){const t=u,r=await e.activeNodeIdentity().catch(()=>{});return t!==u?{state:"loading"}:o({source:"real",fieldSources:{connection:"stub",version:"stub"},connection:"unavailable",...r?{identity:r}:{}})},setLocalNodeEnabled:async()=>({ok:!1,code:"unavailable"}),async localCopy(){const e=t.sync;if(!e)return a("unavailable");const{requested:r,effective:n,reason:i}=e.state;return o({source:"real",fieldSources:{lastSyncedAt:"stub",folders:"stub",pending:"stub",bytesOnDevice:"stub"},requested:r,effective:n,...void 0!==i?{reason:i}:{},folders:[],pending:0})},delegations:e=>e?f.has(e)?A(e):Promise.resolve(a("stale")):D("delegations",y,()=>A()),async revoke(t){const r=u,o=await e.delegations.status(t);if(r!==u)return{ok:!1,code:"stale"};if(!1===o.ok)return{ok:!1,code:o.error.code};if("active"!==o.data.status)return{ok:!1,code:"not-revocable"};const n=await e.delegations.revoke(t);return!1===n.ok?{ok:!1,code:n.error.code}:(k("account").at=0,await w("delegations",()=>A()),{ok:!0,cid:t})},async nodes(){const t=u,r=await e.activeNodeIdentity().catch(()=>{});return t!==u?{state:"loading"}:o(e.hosts.map(e=>{const t=void 0!==r&&r.origin===e;return{source:"real",fieldSources:{kind:"stub",status:"stub",spaces:"stub"},origin:e,kind:"hosted",active:t,...t&&r?{nodeDid:r.nodeDid}:{},status:"ok",spaces:[]}}))},storage:e=>D("storage",p,x,!0===e?.fresh)}}(s,e,t.appName?.()??""),m=function(e){let t="waiting";const r=()=>{"waiting"===t&&(t="pulling",Promise.allSettled([e.data.account(),e.data.delegations(),e.data.storage()]).then(()=>{"pulling"===t&&(t="done")}))};Promise.all([e.idle(),e.registrySettled()]).then(r,r);const o=e.onReset(()=>{t="reset",o()});return{intent:r}}({data:f,registrySettled:()=>u.waitForAccountRegistrySync?.()??Promise.resolve(),idle:r,onReset:t=>e.onReset(t)});k.set(e,{source:f,prefetch:m}),e.onReset(()=>{k.delete(e),w(e)}),w(e)}function D(e){return k.get(e)?.source}function A(e,t){let r=m.get(e);return void 0===r&&(r=new Set,m.set(e,r)),r.add(t),()=>{r.delete(t)}}module.exports=t})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={};function t(){return new Promise(e=>{"requestIdleCallback"in globalThis?globalThis.requestIdleCallback(()=>e(),{timeout:3e3}):setTimeout(e,2e3)})}function r(e){return{state:"ready",data:e}}function o(e){return{state:"needs-permission",ability:e}}function n(e){return{state:"error",code:e}}function i(e){const t=e.indexOf("#");return-1!==t&&-1===e.indexOf("#",t+1)?e.slice(0,t):e}function a(e,t){return"received"===e.direction?"received":(r=t,i(e.delegateDid)===i(r)?"this-app":"to-others");var r}function s(e,t){if(!e)return!1;const r=e.getTime()-t;return r>0&&r<=864e5}e.d=(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);const c={spaces:/^(?:SQL query failed: 400 - )?SQLite error: no such table:\s*spaces(?![\w$.\-])/i,applications:/^(?:SQL query failed: 400 - )?SQLite error: no such table:\s*applications(?![\w$.\-])/i};function d(e,t){return!0===e.ok?e.data.length:"SQL_ERROR"===e.error.code&&c[t].test(e.error.message??"")?void 0:e.error.code}const l={account:["overview"],delegations:["delegations"],storage:["storage"]};const u=new WeakMap,f=new WeakMap;function g(e){for(const t of[...f.get(e)??[]])t()}function v(e,i={}){const c=u.get(e);if(c)return void(i.now&&c.prefetch.intent());const{host:f,gate:v}=i;if(!f||!v||!e.signedIn())return;const p=e.data??function(e,t,i){const c=new Set,u=new Map;let f=0;const g=new Set;t.onReset(()=>{for(const e of u.values())clearTimeout(e.retryTimer);f+=1,u.clear(),g.clear()});const v=e=>{let t=u.get(e);return t||(t={at:0,checkedAt:0,refreshing:!1},u.set(e,t)),t},p=e=>{for(const t of l[e])for(const e of c)e(t)};function y(e,t){const r=v(e);if(r.inflight)return r.inflight;const o=f,i=t().catch(()=>n("unavailable")).then(e=>{o===f&&("error"!==e.state||"ready"!==r.value?.state?(r.value=e,r.at=Date.now(),r.lastError=void 0,"ready"===e.state&&(r.retried=!1,clearTimeout(r.retryTimer),r.retryTimer=void 0)):r.lastError=e.code)}).finally(()=>{o===f&&(r.inflight=void 0,r.checkedAt=Date.now(),r.refreshing=!1,p(e),"account"!==e||"error"!==r.value?.state||r.retried||(r.retried=!0,r.retryTimer=setTimeout(()=>{r.retryTimer=void 0,o===f&&y(e,t)},5e3)))});return r.inflight=i,r.refreshing=!0,p(e),i}function h(e,t){return"ready"!==t.state?t:{...t,freshness:{updatedAt:e.at,refreshing:e.refreshing,lastError:e.lastError}}}async function k(e,t,r,o=!1){const n=v(e);if(void 0===n.value||o){const t=f;return await y(e,r),t!==f||void 0===n.value?{state:"loading"}:h(n,n.value)}return Date.now()-n.checkedAt>t&&y(e,r),h(n,n.value)}async function w(t){const i=f,c=await e.delegations.query({direction:"all",limit:50,...t?{cursor:t}:{}});if(i!==f)return n("stale");if(!1===c.ok)return"PERMISSION_DENIED"===c.error.code?o("delegation/list"):n(c.error.code);const d=Date.now();return c.data.nextCursor&&g.add(c.data.nextCursor),r({rows:c.data.items.map(t=>function(e,t,r){return{source:"real",cid:e.cid,direction:e.direction,status:e.status,group:a(e,t),label:{text:(o=e.delegateDid,o.length<=22?o:`${o.slice(0,14)}…${o.slice(-6)}`),source:"derived"},delegatorDid:e.delegatorDid,delegateDid:e.delegateDid,resources:e.resources.map(e=>({resource:e.resource,actions:e.actions})),parents:e.parents,issuedAt:e.issuedAt,notBefore:e.notBefore,expiresAt:e.expiresAt,expiringSoon:s(e.expiresAt,r),...void 0!==e.revokedAt?{revokedAt:e.revokedAt}:{},...void 0!==e.revokedBy?{revokedBy:e.revokedBy}:{},...void 0!==e.revokedAncestorCid?{revokedAncestorCid:e.revokedAncestorCid}:{}};var o}(t,e.sessionDid,d)),...c.data.nextCursor?{nextCursor:c.data.nextCursor}:{}})}async function b(){const[t,o,a]=await Promise.all([e.account.index.spaces.list(),e.account.index.applications.list(),k("delegations",1e4,()=>w())]),s=d(t,"spaces");if("string"==typeof s)return n(s);const c=d(o,"applications");if("string"==typeof c)return n(c);const l="ready"===a.state?a.data.rows:void 0,u=l?.filter(e=>"granted"===e.direction).length??0,f=l?.filter(e=>"received"===e.direction).length??0;return r({source:"real",fieldSources:{grantedDelegations:"derived",receivedDelegations:"derived"},did:e.did,host:e.hosts[0]??"",...void 0!==c?{applications:c}:{},...void 0!==s?{spaces:s}:{},grantedDelegations:u,receivedDelegations:f,appName:i})}async function m(){const t=await e.storage.status();return!1===t.ok?"PERMISSION_DENIED"===t.error.code||"AUTH_UNAUTHORIZED"===t.error.code?o("space/info"):n(t.error.code):r({source:"real",...t.data})}return{subscribe:e=>(c.add(e),()=>{c.delete(e)}),account:()=>k("account",6e4,b),knownDid:()=>0===f?e.did:void 0,async localNode(){const t=f,o=await e.activeNodeIdentity().catch(()=>{});return t!==f?{state:"loading"}:r({source:"real",fieldSources:{connection:"stub",version:"stub"},connection:"unavailable",...o?{identity:o}:{}})},setLocalNodeEnabled:async()=>({ok:!1,code:"unavailable"}),async localCopy(){const e=t.sync;if(!e)return n("unavailable");const{requested:o,effective:i,reason:a}=e.state;return r({source:"real",fieldSources:{lastSyncedAt:"stub",folders:"stub",pending:"stub",bytesOnDevice:"stub"},requested:o,effective:i,...void 0!==a?{reason:a}:{},folders:[],pending:0})},delegations:e=>e?g.has(e)?w(e):Promise.resolve(n("stale")):k("delegations",1e4,()=>w()),async revoke(t){const r=f,o=await e.delegations.status(t);if(r!==f)return{ok:!1,code:"stale"};if(!1===o.ok)return{ok:!1,code:o.error.code};if("active"!==o.data.status)return{ok:!1,code:"not-revocable"};const n=await e.delegations.revoke(t);return!1===n.ok?{ok:!1,code:n.error.code}:(v("account").at=0,await y("delegations",()=>w()),{ok:!0,cid:t})},async nodes(){const t=f,o=await e.activeNodeIdentity().catch(()=>{});return t!==f?{state:"loading"}:r(e.hosts.map(e=>{const t=void 0!==o&&o.origin===e;return{source:"real",fieldSources:{kind:"stub",status:"stub",spaces:"stub"},origin:e,kind:"hosted",active:t,...t&&o?{nodeDid:o.nodeDid}:{},status:"ok",spaces:[]}}))},storage:e=>k("storage",6e4,m,!0===e?.fresh)}}(f,e,i.appName?.()??""),y=function(e){let t="waiting";const r=()=>{"waiting"===t&&(t="pulling",Promise.allSettled([e.data.account(),e.data.delegations(),e.data.storage()]).then(()=>{"pulling"===t&&(t="done")}))};Promise.all([e.idle(),e.registrySettled()]).then(r,r);const o=e.onReset(()=>{t="reset",o()});return{intent:r}}({data:p,registrySettled:()=>v.waitForAccountRegistrySync?.()??Promise.resolve(),idle:t,onReset:t=>e.onReset(t)});u.set(e,{source:p,prefetch:y}),e.onReset(()=>{u.delete(e),g(e)}),g(e)}function p(e){return u.get(e)?.source}function y(e,t){let r=f.get(e);return void 0===r&&(r=new Set,f.set(e,r)),r.add(t),()=>{r.delete(t)}}export{v as arm,p as livePanelData,y as onLivePanelDataChange};
|