@veltdev/sdk-staging 6.0.0-beta.11 → 6.0.0-beta.12

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 (61) hide show
  1. package/app/models/data/config.data.model.d.ts +121 -0
  2. package/chunk-2JYR3ESH.js +1 -0
  3. package/{chunk-PB4ALOQE.js → chunk-45CK3G4S.js} +1 -1
  4. package/{chunk-LCEYWVFK.js → chunk-63NMA3AQ.js} +1 -1
  5. package/chunk-6ILQARGU.js +1 -0
  6. package/{chunk-RGP2XXJF.js → chunk-6LUTL3DR.js} +1 -1
  7. package/{chunk-N4JJS2HM.js → chunk-6RA26UDR.js} +1 -1
  8. package/{chunk-CGYAGTFW.js → chunk-6WCUWRDH.js} +1 -1
  9. package/{chunk-HUBK3P3B.js → chunk-A6QXRF3G.js} +1 -1
  10. package/chunk-ATB2ZI7G.js +1 -0
  11. package/chunk-BCSVTVMJ.js +167 -0
  12. package/{chunk-WKIVFT2P.js → chunk-BSYABMZE.js} +1 -1
  13. package/{chunk-QHZMUGU5.js → chunk-CECXGS4N.js} +1 -1
  14. package/chunk-DAHES7KJ.js +1 -0
  15. package/{chunk-PRVNVPMV.js → chunk-DEGPUOWQ.js} +1 -1
  16. package/{chunk-X7LR472K.js → chunk-FLGROJQW.js} +1 -1
  17. package/{chunk-SXJORH53.js → chunk-G4N6XTDS.js} +1 -1
  18. package/{chunk-7JE6EGDW.js → chunk-GW63A52V.js} +1 -1
  19. package/{chunk-ZHTTBUVQ.js → chunk-HEIW3Q3Z.js} +1 -1
  20. package/{chunk-YV7SDT6E.js → chunk-HRHOJT33.js} +1 -1
  21. package/{chunk-NW4FJLNA.js → chunk-HZBOX5Z7.js} +4 -4
  22. package/{chunk-S5GDEY2K.js → chunk-IE6GR57U.js} +1 -1
  23. package/{chunk-Y346MJJR.js → chunk-KAYQA4GH.js} +1 -1
  24. package/{chunk-CP4KMRG3.js → chunk-KBKI4VKD.js} +1 -1
  25. package/{chunk-G3BNRB7R.js → chunk-NBO7Z72Y.js} +1 -1
  26. package/{chunk-A6I5J2N4.js → chunk-NVZIS23N.js} +2 -2
  27. package/chunk-S4SWAWDX.js +13 -0
  28. package/{chunk-D5PWD4RY.js → chunk-SLIE6W2D.js} +1 -1
  29. package/{chunk-IOU2B2OU.js → chunk-TJFCTUCM.js} +1 -1
  30. package/{chunk-5IHISLEM.js → chunk-TNSFEAOB.js} +1 -1
  31. package/{chunk-ZMO3MMN3.js → chunk-UQ2QOHQZ.js} +1 -1
  32. package/{chunk-XNMJJJRI.js → chunk-WXTTF7HW.js} +1 -1
  33. package/{chunk-WV6TZ6ZA.js → chunk-Z54SH2OU.js} +1 -1
  34. package/{chunk-7NW5DBIX.js → chunk-ZZK5UGYN.js} +1 -1
  35. package/package.json +1 -1
  36. package/velt-activity-log.js +1 -1
  37. package/velt-area.js +1 -1
  38. package/velt-arrow.js +2 -2
  39. package/velt-comment.js +6 -6
  40. package/velt-crdt.js +1 -1
  41. package/velt-cursor.js +2 -2
  42. package/velt-huddle.js +3 -3
  43. package/velt-live-state-sync.js +2 -2
  44. package/velt-notification.js +1 -1
  45. package/velt-presence.js +1 -1
  46. package/velt-reaction.js +1 -1
  47. package/velt-recorder.js +1 -1
  48. package/velt-rewriter.js +2 -2
  49. package/velt-selection.js +1 -1
  50. package/velt-tag.js +1 -1
  51. package/velt-user-invite.js +1 -1
  52. package/velt-user-request.js +1 -1
  53. package/velt-video-player.js +1 -1
  54. package/velt-views.js +3 -3
  55. package/velt.js +264 -20
  56. package/chunk-2CQTKYCO.js +0 -13
  57. package/chunk-A5F7PTHM.js +0 -167
  58. package/chunk-CR55B3BL.js +0 -1
  59. package/chunk-EMJBJXH6.js +0 -1
  60. package/chunk-NGDGJUUI.js +0 -1
  61. package/chunk-SQUHH2JX.js +0 -1
@@ -0,0 +1,13 @@
1
+ import{b as Y}from"./chunk-G4N6XTDS.js";import{$ as j,Bf as D,C as A,E as g,Fi as _,Gi as x,Hi as Q,Id as w,Kd as y,L as S,Ld as U,M as B,Md as O,S as F,T as H,W as E,ca as b,ci as W,di as L,g as $,ih as P,ki as R,l as C,li as M,p as k,r as u,si as N,v as m,w as z,xi as K}from"./chunk-BCSVTVMJ.js";var he=(()=>{let p=class p{constructor(e,t,r,a,s,c,n,i,d,o){this.authService=e,this.commonDbService=t,this.databaseService=r,this.docService=a,this.domService=s,this.loggingService=c,this.metadataService=n,this.commonDbUtils=i,this.configService=d,this.realtimeAdapter=o,this.HEARTBEAT_DURATION=5*1e3,this.heartbeatEnabled$=new C(!1),this.subscriptions=[],this.heartbeatCreatedTimestamps=new Map,this.initializedHeartbeatIds=new Set;try{this.loggingService.log("%c[WB] Creating CLASS: HeartbeatService","color: blue;"),this.heartbeatEnabled$.pipe(S()).subscribe(h=>{h?this.setupHeartbeat():this.teardownHeartbeat()}),this.docService.addPreDocumentIdChangeFunction("heartbeat-service",h=>h?.documentId?this.removeDocumentHeartbeat(h):Promise.resolve())}catch(h){this.loggingService.catch("Error in HeartbeatService constructor: ",h)}}setupWebWorker(e){try{let t=`
2
+ let intervalId;
3
+ self.addEventListener('message', (event) => {
4
+ if (event.data === 'start') {
5
+ if (intervalId) clearInterval(intervalId);
6
+ intervalId = setInterval(() => {
7
+ self.postMessage('tick');
8
+ }, ${e});
9
+ } else if (event.data === 'stop') {
10
+ if (intervalId) clearInterval(intervalId);
11
+ }
12
+ });
13
+ `;if(typeof Worker<"u"){let r=new Blob([t],{type:"application/javascript"});return new Worker(URL.createObjectURL(r))}return}catch(t){this.loggingService.catch("Error in HeartbeatService setupWebWorker: ",t);return}}setupHeartbeat(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: setupHeartbeat","color: green;"),this.worker=this.setupWebWorker(this.HEARTBEAT_DURATION),this.worker){this.worker.onmessage=()=>{this.authService.getUser()&&this.sendHeartbeat()};let r=this.authService.getUser$().subscribe(a=>{a?(this.worker?.postMessage("start"),this.sendHeartbeat()):this.worker?.postMessage("stop")});this.subscriptions.push(r)}else{let r=this.authService.getUser$().pipe(H(a=>a?A(this.HEARTBEAT_DURATION).pipe(F(0)):k)).subscribe(()=>this.sendHeartbeat());this.subscriptions.push(r)}let e=this.docService.getDocumentPaths$().pipe(g(r=>!!r),E(()=>this.sendHeartbeat())).subscribe();this.subscriptions.push(e);let t=z([this.databaseService.getDb().pipe(g(r=>!!r)),this.authService.getUser$(),this.docService.getDocumentPaths$()]).pipe(B(),E(([[r,a,s],[c,n,i]])=>{if(n&&i){let d=this.domService.getTabId();if(d){let o=this.generateHeartbeatId(n.userId,d),h={id:o,organizationId:i.organizationId},I=this.commonDbUtils.getDocumentPath({feature:"heartbeat",properties:h,defaultDocumentPaths:i,apiKey:this.configService.getApiKey(),useFirestore:!1});if(I&&c&&this.realtimeAdapter.rtdbOnDisconnectSet("heartbeat",this.realtimeAdapter.rtdbRef(c,I),null),i.documentId){let l={id:o,documentId:i.documentId,organizationId:i.organizationId},v=this.commonDbUtils.getDocumentPath({feature:"heartbeatByDocument",properties:l,defaultDocumentPaths:i,apiKey:this.configService.getApiKey(),useFirestore:!1});v&&c&&this.realtimeAdapter.rtdbOnDisconnectSet("heartbeat",this.realtimeAdapter.rtdbRef(c,v),null)}if(s&&s.documentId&&s.documentId!==i.documentId){let l={id:o,documentId:s.documentId,organizationId:s.organizationId,skipFirestore:!0};this.commonDbService.deleteData({feature:"heartbeatByDocument",properties:l})}}}})).subscribe();this.subscriptions.push(t)}catch(e){this.loggingService.catch("Error in HeartbeatService setupHeartbeat: ",e)}}teardownHeartbeat(){try{this.loggingService.log("%c[WB] Calling FUNCTION: teardownHeartbeat","color: green;"),this.worker&&(this.worker.postMessage("stop"),this.worker.terminate(),this.worker=void 0),this.subscriptions.forEach(e=>e.unsubscribe()),this.subscriptions=[],this.heartbeatCreatedTimestamps.clear(),this.initializedHeartbeatIds.clear()}catch(e){this.loggingService.catch("Error in HeartbeatService teardownHeartbeat: ",e)}}sendHeartbeat(){try{this.loggingService.log("%c[WB] Calling HeartbeatService FUNCTION: sendHeartbeat","color: green;");let e=this.authService.getUser(),t=this.docService.getDocumentPaths(),r=this.domService.getTabId();if(e&&t&&r){let a=Date.now(),s=this.generateHeartbeatId(e.userId,r),c=this.docService.getBaseMetadata("heartbeat"),n=c.documentId,i=t.organizationId,d=`${s}_${i}`,o=n?`${s}_${i}_${n}`:null,h=this.heartbeatCreatedTimestamps.get(d)??a;this.heartbeatCreatedTimestamps.has(d)||this.heartbeatCreatedTimestamps.set(d,h);let I=!this.initializedHeartbeatIds.has(d),l={id:s,createdTimestamp:h,lastUpdatedTimestamp:a,userId:e.userId,veltUserId:D(e.userId),tabId:r,metadata:c};if(I?(this.commonDbService.setData({feature:"heartbeat",properties:{id:l.id,skipFirestore:!0},data:l}),this.initializedHeartbeatIds.add(d)):this.commonDbService.updateData({feature:"heartbeat",properties:{id:l.id,skipFirestore:!0},data:l}),n&&o){let v=this.heartbeatCreatedTimestamps.get(o)??a;this.heartbeatCreatedTimestamps.has(o)||this.heartbeatCreatedTimestamps.set(o,v);let G=!this.initializedHeartbeatIds.has(o),f={id:s,createdTimestamp:v,lastUpdatedTimestamp:a,userId:e.userId,veltUserId:D(e.userId),tabId:r,metadata:c};G?(this.commonDbService.setData({feature:"heartbeatByDocument",properties:{id:f.id,skipFirestore:!0,documentId:n},data:f}),this.initializedHeartbeatIds.add(o)):this.commonDbService.updateData({feature:"heartbeatByDocument",properties:{id:f.id,skipFirestore:!0,documentId:n},data:f})}}}catch(e){this.loggingService.catch("Error in HeartbeatService sendHeartbeat: ",e)}}generateHeartbeatId(e,t){return D(e+"_"+t)}getHeartbeatData(e){try{let t=this.docService.getDocumentPaths(),r=e?.organizationId||t?.organizationId,a=e?.documentId,s,c={organizationId:r,skipFirestore:!0,useQuery:!0};if(a?(s="allHeartbeatsByDocument",c.documentId=a):s="allHeartbeats",!t)return u(null);if(e?.userId){let n=e?.limit??50;return c.rtdbQuery=[U("userId"),w(e.userId),y(n)],this.commonDbService.dbListener({feature:s,properties:c}).pipe(g(i=>!!i?.data),m(i=>i?.data),m(i=>i?Object.values(i??{}).map(d=>d):null),m(i=>{if(i){let d=e?.lastUpdatedTimestamp?.$gte??Date.now()-15e3;return i.filter(o=>!(d&&o.lastUpdatedTimestamp<d))}return i}))}else{let n=e?.orderBy??"lastUpdatedTimestamp",i=e?.lastUpdatedTimestamp?.$gte??Date.now()-15e3,d=e?.limit??50;return c.rtdbQuery=[U(n),O(i),y(d)],this.commonDbService.dbListener({feature:s,properties:c}).pipe(g(o=>!!o?.data),m(o=>o?.data),m(o=>o?Object.values(o??{}).map(h=>h):null))}}catch(t){return this.loggingService.catch("Error in HeartbeatService getHeartbeatData: ",t),u(null)}}getSpecificHeartbeat(e){try{let t=this.generateHeartbeatId(e.userId,e.tabId),a=this.docService.getDocumentPaths()?.organizationId;if(!a)return u(null);let s,c={id:t,organizationId:a,skipFirestore:!0};return e.documentId?(s="heartbeatByDocument",c.documentId=e.documentId):s="heartbeat",this.commonDbService.dbListener({feature:s,properties:c}).pipe(g(n=>!!n?.data),m(n=>n?.data),S((n,i)=>n?.lastUpdatedTimestamp===i?.lastUpdatedTimestamp))}catch(t){return this.loggingService.catch("Error in HeartbeatService getSpecificHeartbeat: ",t),u(null)}}removeDocumentHeartbeat(e){return $(this,null,function*(){try{let t=this.authService.getUser()?.userId,r=this.domService.getTabId();if(t&&r&&e?.documentId){let a=this.generateHeartbeatId(t,r),s=`${a}_${e.organizationId}_${e.documentId}`;this.heartbeatCreatedTimestamps.delete(s),this.initializedHeartbeatIds.delete(s),yield this.commonDbService.deleteData({feature:"heartbeatByDocument",properties:{id:a,documentId:e.documentId,organizationId:e.organizationId,skipFirestore:!0}})}return Promise.resolve()}catch(t){return this.loggingService.catch("Error in HeartbeatService removeDocumentHeartbeat: ",t),Promise.resolve()}})}getHeartbeat(e){try{return(e?.userId?u(e.userId):this.authService.getUser$().pipe(m(r=>r?.userId))).pipe(H(r=>r?this.docService.getDocumentPaths$().pipe(H(a=>a?this.getHeartbeatData({userId:r,documentId:a.documentId,organizationId:a.organizationId}):u(null))):u(null)),m(r=>({data:r})),S(P))}catch(t){return this.loggingService.catch("Error in HeartbeatService getHeartbeat: ",t),u({data:null})}}enableHeartbeat(){try{if(this.heartbeatEnabled$.value===!0)return;this.heartbeatEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in HeartbeatService enableHeartbeat: ",e)}}disableHeartbeat(){try{if(this.heartbeatEnabled$.value===!1)return;this.heartbeatEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in HeartbeatService disableHeartbeat: ",e)}}getHeartbeatEnabled$(){try{return this.heartbeatEnabled$.asObservable()}catch(e){return this.loggingService.catch("Error in HeartbeatService getHeartbeatEnabled$: ",e),u(!1)}}getHeartbeatEnabled(){try{return this.heartbeatEnabled$.value}catch(e){return this.loggingService.catch("Error in HeartbeatService getHeartbeatEnabled: ",e),!1}}ngOnDestroy(){try{this.teardownHeartbeat()}catch(e){this.loggingService.catch("Error in HeartbeatService ngOnDestroy: ",e)}}};p.\u0275fac=function(t){return new(t||p)(b(M),b(Q),b(N),b(K),b(R),b(W),b(Y),b(_),b(L),b(x))},p.\u0275prov=j({token:p,factory:p.\u0275fac,providedIn:"root"});let T=p;return T})();export{he as a};