@tinycloud/web-sdk 3.7.0-beta.4 → 3.7.0
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/panel-data.cjs +1 -1
- package/dist/panel-data.mjs +1 -1
- package/package.json +6 -6
package/dist/panel-data.cjs
CHANGED
|
@@ -1 +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:()=>
|
|
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:()=>D,livePanelData:()=>S,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 d(e,t){return"received"===e.direction?"received":(r=t,s(e.delegateDid)===s(r)?"this-app":"to-others");var r}function c(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,k={account:["overview"],delegations:["delegations"],storage:["storage"]};const b=new WeakMap,w=new WeakMap;function m(e){for(const t of[...w.get(e)??[]])t()}function D(e,t={}){const i=b.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 b=e=>{let t=s.get(e);return t||(t={at:0,checkedAt:0,refreshing:!1},s.set(e,t)),t},w=e=>{for(const t of k[e])for(const e of i)e(t)};function m(e,t){const r=b(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,w(e),"account"!==e||"error"!==r.value?.state||r.retried||(r.retried=!0,r.retryTimer=setTimeout(()=>{r.retryTimer=void 0,o===u&&m(e,t)},l)))});return r.inflight=n,r.refreshing=!0,w(e),n}function D(e,t){return"ready"!==t.state?t:{...t,freshness:{updatedAt:e.at,refreshing:e.refreshing,lastError:e.lastError}}}async function S(e,t,r,o=!1){const n=b(e);if(void 0===n.value||o){const t=u;return await m(e,r),t!==u||void 0===n.value?{state:"loading"}:D(n,n.value)}return Date.now()-n.checkedAt>t&&m(e,r),D(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:d(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:c(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(),S("delegations",y,()=>A())]),s=g(t,"spaces");if("string"==typeof s)return a(s);const d=g(n,"applications");if("string"==typeof d)return a(d);const c="ready"===i.state?i.data.rows:void 0,l=c?.filter(e=>"granted"===e.direction).length??0,u=c?.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!==d?{applications:d}:{},...void 0!==s?{spaces:s}:{},grantedDelegations:l,receivedDelegations:u,appName:r})}async function O(){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:()=>S("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")):S("delegations",y,()=>A()),async revoke(t){const r=u,o=await e.delegations.status(t);if(r!==u)return{ok:!1,code:"stale"};if(o.ok&&"revoked"===o.data.status)return{ok:!1,code:"not-revocable"};const n=await e.delegations.revoke(t);if(r!==u)return{ok:!1,code:"stale"};if(!1===n.ok){if("NOT_FOUND"!==n.error.code)return{ok:!1,code:n.error.code};let e;if(b("account").at=0,await m("delegations",async()=>e=await A()),r!==u)return{ok:!1,code:"stale"};const o="ready"===e?.state?e.data:void 0,a=o?.rows.find(e=>e.cid===t);return{ok:!1,code:void 0!==o&&(void 0===a?void 0===o.nextCursor:"revoked"===a.status)?"NOT_FOUND":"REVOCATION_FAILED"}}return b("account").at=0,await m("delegations",()=>A()),r!==u?{ok:!1,code:"stale"}:{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=>S("storage",p,O,!0===e?.fresh)}}(s,e,t.appName?.()??""),w=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)});b.set(e,{source:f,prefetch:w}),e.onReset(()=>{b.delete(e),m(e)}),m(e)}function S(e){return b.get(e)?.source}function A(e,t){let r=w.get(e);return void 0===r&&(r=new Set,w.set(e,r)),r.add(t),()=>{r.delete(t)}}module.exports=t})();
|
package/dist/panel-data.mjs
CHANGED
|
@@ -1 +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
|
|
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 a(e){const t=e.indexOf("#");return-1!==t&&-1===e.indexOf("#",t+1)?e.slice(0,t):e}function i(e,t){return"received"===e.direction?"received":(r=t,a(e.delegateDid)===a(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 u={account:["overview"],delegations:["delegations"],storage:["storage"]};const l=new WeakMap,f=new WeakMap;function g(e){for(const t of[...f.get(e)??[]])t()}function v(e,a={}){const c=l.get(e);if(c)return void(a.now&&c.prefetch.intent());const{host:f,gate:v}=a;if(!f||!v||!e.signedIn())return;const p=e.data??function(e,t,a){const c=new Set,l=new Map;let f=0;const g=new Set;t.onReset(()=>{for(const e of l.values())clearTimeout(e.retryTimer);f+=1,l.clear(),g.clear()});const v=e=>{let t=l.get(e);return t||(t={at:0,checkedAt:0,refreshing:!1},l.set(e,t)),t},p=e=>{for(const t of u[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,a=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=a,r.refreshing=!0,p(e),a}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 a=f,c=await e.delegations.query({direction:"all",limit:50,...t?{cursor:t}:{}});if(a!==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:i(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,i]=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 u="ready"===i.state?i.data.rows:void 0,l=u?.filter(e=>"granted"===e.direction).length??0,f=u?.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:l,receivedDelegations:f,appName:a})}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:a,reason:i}=e.state;return r({source:"real",fieldSources:{lastSyncedAt:"stub",folders:"stub",pending:"stub",bytesOnDevice:"stub"},requested:o,effective:a,...void 0!==i?{reason:i}:{},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(o.ok&&"revoked"===o.data.status)return{ok:!1,code:"not-revocable"};const n=await e.delegations.revoke(t);if(r!==f)return{ok:!1,code:"stale"};if(!1===n.ok){if("NOT_FOUND"!==n.error.code)return{ok:!1,code:n.error.code};let e;if(v("account").at=0,await y("delegations",async()=>e=await w()),r!==f)return{ok:!1,code:"stale"};const o="ready"===e?.state?e.data:void 0,a=o?.rows.find(e=>e.cid===t);return{ok:!1,code:void 0!==o&&(void 0===a?void 0===o.nextCursor:"revoked"===a.status)?"NOT_FOUND":"REVOCATION_FAILED"}}return v("account").at=0,await y("delegations",()=>w()),r!==f?{ok:!1,code:"stale"}:{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,a.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)});l.set(e,{source:p,prefetch:y}),e.onReset(()=>{l.delete(e),g(e)}),g(e)}function p(e){return l.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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinycloud/web-sdk",
|
|
3
|
-
"version": "3.7.0
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "A set of tools and utilities to help you build your app with TinyCloud.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -66,11 +66,11 @@
|
|
|
66
66
|
"@multiformats/multiaddr": "^13.0.1",
|
|
67
67
|
"@multiformats/multiaddr-to-uri": "^12.0.0",
|
|
68
68
|
"@noble/curves": "^1.9.7",
|
|
69
|
-
"@tinycloud/node-sdk": "3.7.0
|
|
70
|
-
"@tinycloud/replica": "0.3.4
|
|
71
|
-
"@tinycloud/sdk-core": "3.7.0
|
|
72
|
-
"@tinycloud/share-envelope": "1.3.0
|
|
73
|
-
"@tinycloud/share-sdk": "1.4.0
|
|
69
|
+
"@tinycloud/node-sdk": "3.7.0",
|
|
70
|
+
"@tinycloud/replica": "0.3.4",
|
|
71
|
+
"@tinycloud/sdk-core": "3.7.0",
|
|
72
|
+
"@tinycloud/share-envelope": "1.3.0",
|
|
73
|
+
"@tinycloud/share-sdk": "1.4.0",
|
|
74
74
|
"@tinycloud/web-sdk-wasm": "1.7.7",
|
|
75
75
|
"axios": "^1.7.9",
|
|
76
76
|
"viem": "^2.45.0",
|