@univerjs/thread-comment 0.16.0 → 0.16.1-insiders.20260311-074e8ca

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/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var $=Object.defineProperty;var j=(s,a,e)=>a in s?$(s,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[a]=e;var l=(s,a,e)=>j(s,typeof a!="symbol"?a+"":a,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),L=require("rxjs");class N extends c.Disposable{constructor(){super();l(this,"_dataSource",null);l(this,"syncUpdateMutationToColla",!0)}set dataSource(e){this._dataSource=e}get dataSource(){return this._dataSource}async getThreadComment(e,t,n){return this._dataSource?(await this._dataSource.listComments(e,t,[n]))[0]:null}async addComment(e){var t;return this._dataSource?this._dataSource.addComment(e):{...e,threadId:(t=e.threadId)!=null?t:e.id}}async updateComment(e){return this._dataSource?this._dataSource.updateComment(e):!0}async resolveComment(e){return this._dataSource?this._dataSource.resolveComment(e):!0}async deleteComment(e,t,n,o){return this._dataSource?this._dataSource.deleteComment(e,t,n,o):!0}async listThreadComments(e,t,n){return this.dataSource?this.dataSource.listComments(e,t,n):!1}saveToSnapshot(e,t){if(this._dataSource){const n={};return Object.keys(e).forEach(o=>{const r=e[o];n[o]=r.map(this.dataSource.saveCommentToSnapshot)}),n}return e}}const p=c.createIdentifier("univer.thread-comment.data-source-service");var H=Object.getOwnPropertyDescriptor,W=(s,a,e,t)=>{for(var n=t>1?void 0:t?H(a,e):a,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(n)||n);return n},E=(s,a)=>(e,t)=>a(e,t,s);exports.ThreadCommentModel=class extends c.Disposable{constructor(e,t){super();l(this,"_commentsMap",new Map);l(this,"_threadMap",new Map);l(this,"_commentUpdate$",new L.Subject);l(this,"commentUpdate$",this._commentUpdate$.asObservable());l(this,"_tasks",[]);this._dataSourceService=e,this._lifecycleService=t,this.disposeWithMe(()=>{this._commentUpdate$.complete()}),this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe(n=>{const o=new Map;n===c.LifecycleStages.Rendered&&(this._tasks.forEach(({unitId:r,subUnitId:m,threadIds:d})=>{let i=o.get(r);i||(i=new Map,o.set(r,i));let h=i.get(m);h||(h=new Set,i.set(m,h));for(const u of d)h.add(u)}),this._tasks=[],o.forEach((r,m)=>{r.forEach((d,i)=>{this.syncThreadComments(m,i,Array.from(d))})}))}))}_ensureCommentMap(e,t){let n=this._commentsMap.get(e);n||(n=new Map,this._commentsMap.set(e,n));let o=n.get(t);return o||(o=new Map,n.set(t,o)),o}ensureMap(e,t){return this._ensureCommentMap(e,t)}_ensureThreadMap(e,t){let n=this._threadMap.get(e);n||(n=new Map,this._threadMap.set(e,n));let o=n.get(t);return o||(o=new Map,n.set(t,o)),o}_replaceComment(e,t,n){const o=this._ensureCommentMap(e,t),r=o.get(n.id);if(r){const{children:m,...d}=n,i={...d,ref:r.ref};o.set(n.id,i),m==null||m.forEach(h=>{o.set(h.id,{...h,ref:""})}),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"syncUpdate",payload:i}),!!n.resolved!=!!r.resolved&&this._commentUpdate$.next({unitId:e,subUnitId:t,type:"resolve",payload:{commentId:n.id,resolved:!!n.resolved}})}}async syncThreadComments(e,t,n){if(this._lifecycleService.stage<c.LifecycleStages.Rendered){this._tasks.push({unitId:e,subUnitId:t,threadIds:n});return}const o=this._ensureThreadMap(e,t),r=this._ensureCommentMap(e,t),m=await this._dataSourceService.listThreadComments(e,t,n);if(!m)return;const d=new Set(n);m.forEach(i=>{this._replaceComment(e,t,i),d.delete(i.threadId)}),d.forEach(i=>{o.delete(i),r.forEach((h,u)=>{h.threadId===i&&r.delete(u)})})}addComment(e,t,n,o){const r=this._ensureCommentMap(e,t),{parentId:m,children:d=[],...i}=n,h={...i,parentId:m===n.id?void 0:m};h.threadId||(h.threadId=h.parentId||h.id);const u=C=>{r.set(C.id,C),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"add",payload:C,isRoot:!C.parentId})};u(h);const U=this._ensureThreadMap(e,t);if(!h.parentId){U.set(h.threadId,h);for(const C of d)u(C)}return o&&this.syncThreadComments(e,t,[h.threadId]),!0}updateComment(e,t,n,o){const m=this._ensureCommentMap(e,t).get(n.commentId);return m&&(m.updated=!0,m.text=n.text,m.attachments=n.attachments,m.updateT=n.updateT,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"update",payload:n,silent:o})),!0}updateCommentRef(e,t,n,o){const m=this._ensureCommentMap(e,t).get(n.commentId);return m?(m.ref=n.ref,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"updateRef",payload:n,silent:o,threadId:m.threadId}),!0):!1}resolveComment(e,t,n,o){const m=this._ensureCommentMap(e,t).get(n);return m?(m.resolved=o,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"resolve",payload:{commentId:n,resolved:o}}),!0):!1}getComment(e,t,n){return this._ensureCommentMap(e,t).get(n)}getRootComment(e,t,n){return this._ensureThreadMap(e,t).get(n)}getThread(e,t,n){const o=this._ensureCommentMap(e,t),r=Array.from(o.values()).filter(h=>h.threadId===n);let m;const d=[],i=new Set;for(const h of r)h.parentId?d.push(h):m=h,i.add(h.personId);if(m)return{root:m,children:d,relativeUsers:i,unitId:e,subUnitId:t,threadId:n}}getCommentWithChildren(e,t,n){const o=this.getComment(e,t,n);if(o)return this.getThread(e,t,o.threadId)}_deleteComment(e,t,n){const o=this._ensureCommentMap(e,t),r=o.get(n);r&&(o.delete(n),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"delete",payload:{commentId:n,isRoot:!r.parentId,comment:r}}))}deleteThread(e,t,n){this._ensureThreadMap(e,t).delete(n),this._ensureCommentMap(e,t).forEach(m=>{m.threadId===n&&this._deleteComment(e,t,m.id)})}deleteComment(e,t,n){const r=this._ensureCommentMap(e,t).get(n);return r&&(r.parentId?this._deleteComment(e,t,n):this.deleteThread(e,t,r.threadId)),!0}deleteUnit(e){const t=this._commentsMap.get(e);t&&t.forEach((n,o)=>{n.forEach(r=>{this.deleteComment(e,o,r.id)})})}getUnit(e){const t=this._threadMap.get(e);if(!t)return[];const n=[];return t.forEach((o,r)=>{o.forEach((m,d)=>{const i=this.getThread(e,r,d);i&&n.push(i)})}),n}getAll(){const e=[];return this._commentsMap.forEach((t,n)=>{e.push({unitId:n,threads:this.getUnit(n)})}),e}};exports.ThreadCommentModel=W([E(0,c.Inject(p)),E(1,c.Inject(c.LifecycleService))],exports.ThreadCommentModel);const g={id:"thread-comment.mutation.add-comment",type:c.CommandType.MUTATION,handler(s,a,e){if(!a)return!1;const t=s.get(exports.ThreadCommentModel),{unitId:n,subUnitId:o,comment:r,sync:m}=a,d=m||(e==null?void 0:e.fromChangeset)&&!r.parentId;return t.addComment(n,o,r,d)}},v={id:"thread-comment.mutation.update-comment",type:c.CommandType.MUTATION,handler(s,a){if(!a)return!1;const e=s.get(exports.ThreadCommentModel),{unitId:t,subUnitId:n,payload:o,silent:r}=a;return e.updateComment(t,n,o,r)}},D={id:"thread-comment.mutation.update-comment-ref",type:c.CommandType.MUTATION,handler(s,a){if(!a)return!1;const e=s.get(exports.ThreadCommentModel),{unitId:t,subUnitId:n,payload:o,silent:r}=a;return e.updateCommentRef(t,n,o,r)}},S={id:"thread-comment.mutation.resolve-comment",type:c.CommandType.MUTATION,handler(s,a){if(!a)return!1;const e=s.get(exports.ThreadCommentModel),{unitId:t,subUnitId:n,resolved:o,commentId:r}=a;return e.resolveComment(t,n,r,o)}},f={id:"thread-comment.mutation.delete-comment",type:c.CommandType.MUTATION,handler(s,a){if(!a)return!1;const e=s.get(exports.ThreadCommentModel),{unitId:t,subUnitId:n,commentId:o}=a;return e.deleteComment(t,n,o)}},O={id:"thread-comment.command.add-comment",type:c.CommandType.COMMAND,async handler(s,a){if(!a)return!1;const e=s.get(c.ICommandService),t=s.get(p),{comment:n}=a,o=await t.addComment(n),r=t.syncUpdateMutationToColla,m=!n.parentId,d={id:g.id,params:{...a,comment:o}};return m?await e.executeCommand(d.id,d.params):e.executeCommand(d.id,d.params,{onlyLocal:!r})}},R={id:"thread-comment.command.update-comment",type:c.CommandType.COMMAND,async handler(s,a){if(!a)return!1;const{unitId:e,subUnitId:t,payload:n}=a,o=s.get(c.ICommandService),r=s.get(exports.ThreadCommentModel),m=s.get(p),d=m.syncUpdateMutationToColla,i=r.getComment(e,t,n.commentId);if(!i)return!1;const{children:h,...u}=i;if(!await m.updateComment({...u,...n}))return!1;const C={id:v.id,params:a};return o.executeCommand(C.id,C.params,{onlyLocal:!d}),!0}},w={id:"thread-comment.command.resolve-comment",type:c.CommandType.COMMAND,async handler(s,a){if(!a)return!1;const{unitId:e,subUnitId:t,resolved:n,commentId:o}=a,r=s.get(p),d=s.get(exports.ThreadCommentModel).getComment(e,t,o),i=r.syncUpdateMutationToColla;return!d||!await r.resolveComment({...d,resolved:n})?!1:s.get(c.ICommandService).executeCommand(S.id,a,{onlyLocal:!i})}},A={id:"thread-comment.command.delete-comment",type:c.CommandType.COMMAND,async handler(s,a){if(!a)return!1;const e=s.get(exports.ThreadCommentModel),t=s.get(p),n=s.get(c.ICommandService),{unitId:o,subUnitId:r,commentId:m}=a,d=t.syncUpdateMutationToColla,i=e.getComment(o,r,m);if(!i||!await t.deleteComment(o,r,i.threadId,m))return!1;const h={id:f.id,params:a};return n.executeCommand(h.id,h.params,{onlyLocal:!d})}},P={id:"thread-comment.command.delete-comment-tree",type:c.CommandType.COMMAND,async handler(s,a){if(!a)return!1;const e=s.get(exports.ThreadCommentModel),t=s.get(c.ICommandService),n=s.get(p),{unitId:o,subUnitId:r,commentId:m}=a,d=e.getCommentWithChildren(o,r,m);return!d||!await n.deleteComment(o,r,d.root.threadId,m)?!1:await t.executeCommand(f.id,{unitId:o,subUnitId:r,commentId:d.root.id})}};function G(s){return c.dayjs(s).format("YYYY/MM/DD HH:mm")}const y="UNIVER_THREAD_COMMENT_PLUGIN";var b=Object.getOwnPropertyDescriptor,J=(s,a,e,t)=>{for(var n=t>1?void 0:t?b(a,e):a,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(n)||n);return n},_=(s,a)=>(e,t)=>a(e,t,s);const x=`SHEET_${y}`;exports.ThreadCommentResourceController=class extends c.Disposable{constructor(a,e,t){super(),this._resourceManagerService=a,this._threadCommentModel=e,this._threadCommentDataSourceService=t,this._initSnapshot()}_initSnapshot(){const a=t=>{const n=this._threadCommentModel.getUnit(t),o={};return n?(n.forEach(r=>{var d;const m=(d=o[r.subUnitId])!=null?d:[];m.push({...r.root,children:r.children}),o[r.subUnitId]=m}),JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(o,t))):""},e=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:x,businesses:[c.UniverInstanceType.UNIVER_SHEET,c.UniverInstanceType.UNIVER_DOC],toJson:t=>a(t),parseJson:t=>e(t),onUnLoad:t=>{this._threadCommentModel.deleteUnit(t)},onLoad:async(t,n)=>{Object.keys(n).forEach(o=>{const r=n[o];r.forEach(m=>{this._threadCommentModel.addComment(t,o,m)}),this._threadCommentModel.syncThreadComments(t,o,r.map(m=>m.threadId))})}}))}};exports.ThreadCommentResourceController=J([_(0,c.IResourceManagerService),_(1,c.Inject(exports.ThreadCommentModel)),_(2,p)],exports.ThreadCommentResourceController);const V="thread-comment.config",I={};var Y=Object.getOwnPropertyDescriptor,k=(s,a,e,t)=>{for(var n=t>1?void 0:t?Y(a,e):a,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(n)||n);return n},T=(s,a)=>(e,t)=>a(e,t,s),M;exports.UniverThreadCommentPlugin=(M=class extends c.Plugin{constructor(a=I,e,t,n){super(),this._config=a,this._injector=e,this._commandService=t,this._configService=n;const{...o}=c.merge({},I,this._config);this._configService.setConfig(V,o)}onStarting(){var a;c.mergeOverrideWithDependencies([[p,{useClass:N}],[exports.ThreadCommentModel],[exports.ThreadCommentResourceController]],(a=this._config)==null?void 0:a.overrides).forEach(e=>{this._injector.add(e)}),[O,R,A,w,P,g,v,D,f,S].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(exports.ThreadCommentResourceController)}},l(M,"pluginName",y),l(M,"type",c.UniverInstanceType.UNIVER_UNKNOWN),M);exports.UniverThreadCommentPlugin=k([T(1,c.Inject(c.Injector)),T(2,c.ICommandService),T(3,c.IConfigService)],exports.UniverThreadCommentPlugin);exports.AddCommentCommand=O;exports.AddCommentMutation=g;exports.DeleteCommentCommand=A;exports.DeleteCommentMutation=f;exports.DeleteCommentTreeCommand=P;exports.IThreadCommentDataSourceService=p;exports.ResolveCommentCommand=w;exports.ResolveCommentMutation=S;exports.SHEET_UNIVER_THREAD_COMMENT_PLUGIN=x;exports.TC_PLUGIN_NAME=y;exports.ThreadCommentDataSourceService=N;exports.UpdateCommentCommand=R;exports.UpdateCommentMutation=v;exports.UpdateCommentRefMutation=D;exports.getDT=G;
1
+ "use strict";var j=Object.defineProperty;var L=(s,a,e)=>a in s?j(s,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[a]=e;var l=(s,a,e)=>L(s,typeof a!="symbol"?a+"":a,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),H=require("rxjs");class D extends c.Disposable{constructor(){super();l(this,"_dataSource",null);l(this,"syncUpdateMutationToColla",!0)}set dataSource(e){this._dataSource=e}get dataSource(){return this._dataSource}async getThreadComment(e,t,n){return this._dataSource?(await this._dataSource.listComments(e,t,[n]))[0]:null}async addComment(e){var t;return this._dataSource?this._dataSource.addComment(e):{...e,threadId:(t=e.threadId)!=null?t:e.id}}async updateComment(e){return this._dataSource?this._dataSource.updateComment(e):!0}async resolveComment(e){return this._dataSource?this._dataSource.resolveComment(e):!0}async deleteComment(e,t,n,o){return this._dataSource?this._dataSource.deleteComment(e,t,n,o):!0}async listThreadComments(e,t,n){return this.dataSource?this.dataSource.listComments(e,t,n):!1}saveToSnapshot(e,t){if(this._dataSource){const n={};return Object.keys(e).forEach(o=>{const r=e[o];n[o]=r.map(this.dataSource.saveCommentToSnapshot)}),n}return e}}const p=c.createIdentifier("univer.thread-comment.data-source-service");var W=Object.getOwnPropertyDescriptor,G=(s,a,e,t)=>{for(var n=t>1?void 0:t?W(a,e):a,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(n)||n);return n},E=(s,a)=>(e,t)=>a(e,t,s);exports.ThreadCommentModel=class extends c.Disposable{constructor(e,t){super();l(this,"_commentsMap",new Map);l(this,"_threadMap",new Map);l(this,"_commentUpdate$",new H.Subject);l(this,"commentUpdate$",this._commentUpdate$.asObservable());l(this,"_tasks",[]);this._dataSourceService=e,this._lifecycleService=t,this.disposeWithMe(()=>{this._commentUpdate$.complete()}),this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe(n=>{const o=new Map;n===c.LifecycleStages.Rendered&&(this._tasks.forEach(({unitId:r,subUnitId:m,threadIds:d})=>{let i=o.get(r);i||(i=new Map,o.set(r,i));let h=i.get(m);h||(h=new Set,i.set(m,h));for(const u of d)h.add(u)}),this._tasks=[],o.forEach((r,m)=>{r.forEach((d,i)=>{this.syncThreadComments(m,i,Array.from(d))})}))}))}_ensureCommentMap(e,t){let n=this._commentsMap.get(e);n||(n=new Map,this._commentsMap.set(e,n));let o=n.get(t);return o||(o=new Map,n.set(t,o)),o}ensureMap(e,t){return this._ensureCommentMap(e,t)}_ensureThreadMap(e,t){let n=this._threadMap.get(e);n||(n=new Map,this._threadMap.set(e,n));let o=n.get(t);return o||(o=new Map,n.set(t,o)),o}_replaceComment(e,t,n){const o=this._ensureCommentMap(e,t),r=o.get(n.id);if(r){const{children:m,...d}=n,i={...d,ref:r.ref};o.set(n.id,i),m==null||m.forEach(h=>{o.set(h.id,{...h,ref:""})}),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"syncUpdate",payload:i}),!!n.resolved!=!!r.resolved&&this._commentUpdate$.next({unitId:e,subUnitId:t,type:"resolve",payload:{commentId:n.id,resolved:!!n.resolved}})}}async syncThreadComments(e,t,n){if(this._lifecycleService.stage<c.LifecycleStages.Rendered){this._tasks.push({unitId:e,subUnitId:t,threadIds:n});return}const o=this._ensureThreadMap(e,t),r=this._ensureCommentMap(e,t),m=await this._dataSourceService.listThreadComments(e,t,n);if(!m)return;const d=new Set(n);m.forEach(i=>{this._replaceComment(e,t,i),d.delete(i.threadId)}),d.forEach(i=>{o.delete(i),r.forEach((h,u)=>{h.threadId===i&&r.delete(u)})})}addComment(e,t,n,o){const r=this._ensureCommentMap(e,t),{parentId:m,children:d=[],...i}=n,h={...i,parentId:m===n.id?void 0:m};h.threadId||(h.threadId=h.parentId||h.id);const u=C=>{r.set(C.id,C),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"add",payload:C,isRoot:!C.parentId})};u(h);const U=this._ensureThreadMap(e,t);if(!h.parentId){U.set(h.threadId,h);for(const C of d)u(C)}return o&&this.syncThreadComments(e,t,[h.threadId]),!0}updateComment(e,t,n,o){const m=this._ensureCommentMap(e,t).get(n.commentId);return m&&(m.updated=!0,m.text=n.text,m.attachments=n.attachments,m.updateT=n.updateT,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"update",payload:n,silent:o})),!0}updateCommentRef(e,t,n,o){const m=this._ensureCommentMap(e,t).get(n.commentId);return m?(m.ref=n.ref,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"updateRef",payload:n,silent:o,threadId:m.threadId}),!0):!1}resolveComment(e,t,n,o){const m=this._ensureCommentMap(e,t).get(n);return m?(m.resolved=o,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"resolve",payload:{commentId:n,resolved:o}}),!0):!1}getComment(e,t,n){return this._ensureCommentMap(e,t).get(n)}getRootComment(e,t,n){return this._ensureThreadMap(e,t).get(n)}getThread(e,t,n){const o=this._ensureCommentMap(e,t),r=Array.from(o.values()).filter(h=>h.threadId===n);let m;const d=[],i=new Set;for(const h of r)h.parentId?d.push(h):m=h,i.add(h.personId);if(m)return{root:m,children:d,relativeUsers:i,unitId:e,subUnitId:t,threadId:n}}getCommentWithChildren(e,t,n){const o=this.getComment(e,t,n);if(o)return this.getThread(e,t,o.threadId)}_deleteComment(e,t,n){const o=this._ensureCommentMap(e,t),r=o.get(n);r&&(o.delete(n),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"delete",payload:{commentId:n,isRoot:!r.parentId,comment:r}}))}deleteThread(e,t,n){this._ensureThreadMap(e,t).delete(n),this._ensureCommentMap(e,t).forEach(m=>{m.threadId===n&&this._deleteComment(e,t,m.id)})}deleteComment(e,t,n){const r=this._ensureCommentMap(e,t).get(n);return r&&(r.parentId?this._deleteComment(e,t,n):this.deleteThread(e,t,r.threadId)),!0}deleteUnit(e){const t=this._commentsMap.get(e);t&&t.forEach((n,o)=>{n.forEach(r=>{this.deleteComment(e,o,r.id)})})}getUnit(e){const t=this._threadMap.get(e);if(!t)return[];const n=[];return t.forEach((o,r)=>{o.forEach((m,d)=>{const i=this.getThread(e,r,d);i&&n.push(i)})}),n}getAll(){const e=[];return this._commentsMap.forEach((t,n)=>{e.push({unitId:n,threads:this.getUnit(n)})}),e}};exports.ThreadCommentModel=G([E(0,c.Inject(p)),E(1,c.Inject(c.LifecycleService))],exports.ThreadCommentModel);const v={id:"thread-comment.mutation.add-comment",type:c.CommandType.MUTATION,handler(s,a,e){if(!a)return!1;const t=s.get(exports.ThreadCommentModel),{unitId:n,subUnitId:o,comment:r,sync:m}=a,d=m||(e==null?void 0:e.fromChangeset)&&!r.parentId;return t.addComment(n,o,r,d)}},g={id:"thread-comment.mutation.update-comment",type:c.CommandType.MUTATION,handler(s,a){if(!a)return!1;const e=s.get(exports.ThreadCommentModel),{unitId:t,subUnitId:n,payload:o,silent:r}=a;return e.updateComment(t,n,o,r)}},O={id:"thread-comment.mutation.update-comment-ref",type:c.CommandType.MUTATION,handler(s,a){if(!a)return!1;const e=s.get(exports.ThreadCommentModel),{unitId:t,subUnitId:n,payload:o,silent:r}=a;return e.updateCommentRef(t,n,o,r)}},S={id:"thread-comment.mutation.resolve-comment",type:c.CommandType.MUTATION,handler(s,a){if(!a)return!1;const e=s.get(exports.ThreadCommentModel),{unitId:t,subUnitId:n,resolved:o,commentId:r}=a;return e.resolveComment(t,n,r,o)}},f={id:"thread-comment.mutation.delete-comment",type:c.CommandType.MUTATION,handler(s,a){if(!a)return!1;const e=s.get(exports.ThreadCommentModel),{unitId:t,subUnitId:n,commentId:o}=a;return e.deleteComment(t,n,o)}},R={id:"thread-comment.command.add-comment",type:c.CommandType.COMMAND,async handler(s,a){if(!a)return!1;const e=s.get(c.ICommandService),t=s.get(p),{comment:n}=a,o=await t.addComment(n),r=t.syncUpdateMutationToColla,m=!n.parentId,d={id:v.id,params:{...a,comment:o}};return m?await e.executeCommand(d.id,d.params):e.executeCommand(d.id,d.params,{onlyLocal:!r})}},w={id:"thread-comment.command.update-comment",type:c.CommandType.COMMAND,async handler(s,a){if(!a)return!1;const{unitId:e,subUnitId:t,payload:n}=a,o=s.get(c.ICommandService),r=s.get(exports.ThreadCommentModel),m=s.get(p),d=m.syncUpdateMutationToColla,i=r.getComment(e,t,n.commentId);if(!i)return!1;const{children:h,...u}=i;if(!await m.updateComment({...u,...n}))return!1;const C={id:g.id,params:a};return o.executeCommand(C.id,C.params,{onlyLocal:!d}),!0}},A={id:"thread-comment.command.resolve-comment",type:c.CommandType.COMMAND,async handler(s,a){if(!a)return!1;const{unitId:e,subUnitId:t,resolved:n,commentId:o}=a,r=s.get(p),d=s.get(exports.ThreadCommentModel).getComment(e,t,o),i=r.syncUpdateMutationToColla;return!d||!await r.resolveComment({...d,resolved:n})?!1:s.get(c.ICommandService).executeCommand(S.id,a,{onlyLocal:!i})}},P={id:"thread-comment.command.delete-comment",type:c.CommandType.COMMAND,async handler(s,a){if(!a)return!1;const e=s.get(exports.ThreadCommentModel),t=s.get(p),n=s.get(c.ICommandService),{unitId:o,subUnitId:r,commentId:m}=a,d=t.syncUpdateMutationToColla,i=e.getComment(o,r,m);if(!i||!await t.deleteComment(o,r,i.threadId,m))return!1;const h={id:f.id,params:a};return n.executeCommand(h.id,h.params,{onlyLocal:!d})}},x={id:"thread-comment.command.delete-comment-tree",type:c.CommandType.COMMAND,async handler(s,a){if(!a)return!1;const e=s.get(exports.ThreadCommentModel),t=s.get(c.ICommandService),n=s.get(p),{unitId:o,subUnitId:r,commentId:m}=a,d=e.getCommentWithChildren(o,r,m);return!d||!await n.deleteComment(o,r,d.root.threadId,m)?!1:await t.executeCommand(f.id,{unitId:o,subUnitId:r,commentId:d.root.id})}};function b(s){return c.dayjs(s).format("YYYY/MM/DD HH:mm")}const y="UNIVER_THREAD_COMMENT_PLUGIN";var k=Object.getOwnPropertyDescriptor,J=(s,a,e,t)=>{for(var n=t>1?void 0:t?k(a,e):a,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(n)||n);return n},_=(s,a)=>(e,t)=>a(e,t,s);const $=`SHEET_${y}`;exports.ThreadCommentResourceController=class extends c.Disposable{constructor(a,e,t){super(),this._resourceManagerService=a,this._threadCommentModel=e,this._threadCommentDataSourceService=t,this._initSnapshot()}_initSnapshot(){const a=t=>{const n=this._threadCommentModel.getUnit(t),o={};return n?(n.forEach(r=>{var d;const m=(d=o[r.subUnitId])!=null?d:[];m.push({...r.root,children:r.children}),o[r.subUnitId]=m}),JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(o,t))):""},e=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:$,businesses:[c.UniverInstanceType.UNIVER_SHEET,c.UniverInstanceType.UNIVER_DOC],toJson:t=>a(t),parseJson:t=>e(t),onUnLoad:t=>{this._threadCommentModel.deleteUnit(t)},onLoad:async(t,n)=>{Object.keys(n).forEach(o=>{const r=n[o];r.forEach(m=>{this._threadCommentModel.addComment(t,o,m)}),this._threadCommentModel.syncThreadComments(t,o,r.map(m=>m.threadId))})}}))}};exports.ThreadCommentResourceController=J([_(0,c.IResourceManagerService),_(1,c.Inject(exports.ThreadCommentModel)),_(2,p)],exports.ThreadCommentResourceController);const V="@univerjs/thread-comment",Y="0.16.1-insiders.20260311-074e8ca",I={name:V,version:Y},B="thread-comment.config",N={};var q=Object.getOwnPropertyDescriptor,K=(s,a,e,t)=>{for(var n=t>1?void 0:t?q(a,e):a,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(n)||n);return n},T=(s,a)=>(e,t)=>a(e,t,s),M;exports.UniverThreadCommentPlugin=(M=class extends c.Plugin{constructor(a=N,e,t,n){super(),this._config=a,this._injector=e,this._commandService=t,this._configService=n;const{...o}=c.merge({},N,this._config);this._configService.setConfig(B,o)}onStarting(){var a;c.mergeOverrideWithDependencies([[p,{useClass:D}],[exports.ThreadCommentModel],[exports.ThreadCommentResourceController]],(a=this._config)==null?void 0:a.overrides).forEach(e=>{this._injector.add(e)}),[R,w,P,A,x,v,g,O,f,S].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(exports.ThreadCommentResourceController)}},l(M,"pluginName",y),l(M,"packageName",I.name),l(M,"version",I.version),l(M,"type",c.UniverInstanceType.UNIVER_UNKNOWN),M);exports.UniverThreadCommentPlugin=K([T(1,c.Inject(c.Injector)),T(2,c.ICommandService),T(3,c.IConfigService)],exports.UniverThreadCommentPlugin);exports.AddCommentCommand=R;exports.AddCommentMutation=v;exports.DeleteCommentCommand=P;exports.DeleteCommentMutation=f;exports.DeleteCommentTreeCommand=x;exports.IThreadCommentDataSourceService=p;exports.ResolveCommentCommand=A;exports.ResolveCommentMutation=S;exports.SHEET_UNIVER_THREAD_COMMENT_PLUGIN=$;exports.TC_PLUGIN_NAME=y;exports.ThreadCommentDataSourceService=D;exports.UpdateCommentCommand=w;exports.UpdateCommentMutation=g;exports.UpdateCommentRefMutation=O;exports.getDT=b;
package/lib/es/index.js CHANGED
@@ -1,13 +1,13 @@
1
- var P = Object.defineProperty;
2
- var L = (s, t, e) => t in s ? P(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var u = (s, t, e) => L(s, typeof t != "symbol" ? t + "" : t, e);
4
- import { createIdentifier as j, Disposable as U, Inject as g, LifecycleService as H, LifecycleStages as O, CommandType as l, ICommandService as f, dayjs as W, IResourceManagerService as J, UniverInstanceType as T, Plugin as G, merge as V, mergeOverrideWithDependencies as Y, Injector as k, IConfigService as B } from "@univerjs/core";
5
- import { Subject as b } from "rxjs";
6
- class K extends U {
1
+ var L = Object.defineProperty;
2
+ var j = (s, t, e) => t in s ? L(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
+ var h = (s, t, e) => j(s, typeof t != "symbol" ? t + "" : t, e);
4
+ import { createIdentifier as H, Disposable as U, Inject as g, LifecycleService as W, LifecycleStages as O, CommandType as l, ICommandService as M, dayjs as k, UniverInstanceType as T, IResourceManagerService as J, Plugin as G, merge as V, mergeOverrideWithDependencies as Y, Injector as B, IConfigService as b } from "@univerjs/core";
5
+ import { Subject as K } from "rxjs";
6
+ class F extends U {
7
7
  constructor() {
8
8
  super();
9
- u(this, "_dataSource", null);
10
- u(this, "syncUpdateMutationToColla", !0);
9
+ h(this, "_dataSource", null);
10
+ h(this, "syncUpdateMutationToColla", !0);
11
11
  }
12
12
  set dataSource(e) {
13
13
  this._dataSource = e;
@@ -45,20 +45,20 @@ class K extends U {
45
45
  return e;
46
46
  }
47
47
  }
48
- const p = j("univer.thread-comment.data-source-service");
49
- var F = Object.getOwnPropertyDescriptor, q = (s, t, e, n) => {
50
- for (var o = n > 1 ? void 0 : n ? F(t, e) : t, r = s.length - 1, a; r >= 0; r--)
48
+ const p = H("univer.thread-comment.data-source-service");
49
+ var q = Object.getOwnPropertyDescriptor, z = (s, t, e, n) => {
50
+ for (var o = n > 1 ? void 0 : n ? q(t, e) : t, r = s.length - 1, a; r >= 0; r--)
51
51
  (a = s[r]) && (o = a(o) || o);
52
52
  return o;
53
53
  }, w = (s, t) => (e, n) => t(e, n, s);
54
54
  let i = class extends U {
55
55
  constructor(t, e) {
56
56
  super();
57
- u(this, "_commentsMap", /* @__PURE__ */ new Map());
58
- u(this, "_threadMap", /* @__PURE__ */ new Map());
59
- u(this, "_commentUpdate$", new b());
60
- u(this, "commentUpdate$", this._commentUpdate$.asObservable());
61
- u(this, "_tasks", []);
57
+ h(this, "_commentsMap", /* @__PURE__ */ new Map());
58
+ h(this, "_threadMap", /* @__PURE__ */ new Map());
59
+ h(this, "_commentUpdate$", new K());
60
+ h(this, "commentUpdate$", this._commentUpdate$.asObservable());
61
+ h(this, "_tasks", []);
62
62
  this._dataSourceService = t, this._lifecycleService = e, this.disposeWithMe(() => {
63
63
  this._commentUpdate$.complete();
64
64
  }), this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe((n) => {
@@ -68,8 +68,8 @@ let i = class extends U {
68
68
  m || (m = /* @__PURE__ */ new Map(), o.set(r, m));
69
69
  let c = m.get(a);
70
70
  c || (c = /* @__PURE__ */ new Set(), m.set(a, c));
71
- for (const h of d)
72
- c.add(h);
71
+ for (const u of d)
72
+ c.add(u);
73
73
  }), this._tasks = [], o.forEach((r, a) => {
74
74
  r.forEach((d, m) => {
75
75
  this.syncThreadComments(a, m, Array.from(d));
@@ -132,8 +132,8 @@ let i = class extends U {
132
132
  a.forEach((m) => {
133
133
  this._replaceComment(t, e, m), d.delete(m.threadId);
134
134
  }), d.forEach((m) => {
135
- o.delete(m), r.forEach((c, h) => {
136
- c.threadId === m && r.delete(h);
135
+ o.delete(m), r.forEach((c, u) => {
136
+ c.threadId === m && r.delete(u);
137
137
  });
138
138
  });
139
139
  }
@@ -143,7 +143,7 @@ let i = class extends U {
143
143
  parentId: a === n.id ? void 0 : a
144
144
  };
145
145
  c.threadId || (c.threadId = c.parentId || c.id);
146
- const h = (C) => {
146
+ const u = (C) => {
147
147
  r.set(C.id, C), this._commentUpdate$.next({
148
148
  unitId: t,
149
149
  subUnitId: e,
@@ -152,12 +152,12 @@ let i = class extends U {
152
152
  isRoot: !C.parentId
153
153
  });
154
154
  };
155
- h(c);
156
- const M = this._ensureThreadMap(t, e);
155
+ u(c);
156
+ const _ = this._ensureThreadMap(t, e);
157
157
  if (!c.parentId) {
158
- M.set(c.threadId, c);
158
+ _.set(c.threadId, c);
159
159
  for (const C of d)
160
- h(C);
160
+ u(C);
161
161
  }
162
162
  return o && this.syncThreadComments(t, e, [c.threadId]), !0;
163
163
  }
@@ -273,11 +273,11 @@ let i = class extends U {
273
273
  }), t;
274
274
  }
275
275
  };
276
- i = q([
276
+ i = z([
277
277
  w(0, g(p)),
278
- w(1, g(H))
278
+ w(1, g(W))
279
279
  ], i);
280
- const R = {
280
+ const x = {
281
281
  id: "thread-comment.mutation.add-comment",
282
282
  type: l.MUTATION,
283
283
  handler(s, t, e) {
@@ -286,7 +286,7 @@ const R = {
286
286
  const n = s.get(i), { unitId: o, subUnitId: r, comment: a, sync: d } = t, m = d || (e == null ? void 0 : e.fromChangeset) && !a.parentId;
287
287
  return n.addComment(o, r, a, m);
288
288
  }
289
- }, x = {
289
+ }, A = {
290
290
  id: "thread-comment.mutation.update-comment",
291
291
  type: l.MUTATION,
292
292
  handler(s, t) {
@@ -295,7 +295,7 @@ const R = {
295
295
  const e = s.get(i), { unitId: n, subUnitId: o, payload: r, silent: a } = t;
296
296
  return e.updateComment(n, o, r, a);
297
297
  }
298
- }, z = {
298
+ }, Q = {
299
299
  id: "thread-comment.mutation.update-comment-ref",
300
300
  type: l.MUTATION,
301
301
  handler(s, t) {
@@ -304,7 +304,7 @@ const R = {
304
304
  const e = s.get(i), { unitId: n, subUnitId: o, payload: r, silent: a } = t;
305
305
  return e.updateCommentRef(n, o, r, a);
306
306
  }
307
- }, A = {
307
+ }, $ = {
308
308
  id: "thread-comment.mutation.resolve-comment",
309
309
  type: l.MUTATION,
310
310
  handler(s, t) {
@@ -322,14 +322,14 @@ const R = {
322
322
  const e = s.get(i), { unitId: n, subUnitId: o, commentId: r } = t;
323
323
  return e.deleteComment(n, o, r);
324
324
  }
325
- }, Q = {
325
+ }, X = {
326
326
  id: "thread-comment.command.add-comment",
327
327
  type: l.COMMAND,
328
328
  async handler(s, t) {
329
329
  if (!t)
330
330
  return !1;
331
- const e = s.get(f), n = s.get(p), { comment: o } = t, r = await n.addComment(o), a = n.syncUpdateMutationToColla, d = !o.parentId, m = {
332
- id: R.id,
331
+ const e = s.get(M), n = s.get(p), { comment: o } = t, r = await n.addComment(o), a = n.syncUpdateMutationToColla, d = !o.parentId, m = {
332
+ id: x.id,
333
333
  params: {
334
334
  ...t,
335
335
  comment: r
@@ -339,32 +339,32 @@ const R = {
339
339
  onlyLocal: !a
340
340
  });
341
341
  }
342
- }, X = {
342
+ }, Z = {
343
343
  id: "thread-comment.command.update-comment",
344
344
  type: l.COMMAND,
345
345
  async handler(s, t) {
346
346
  if (!t)
347
347
  return !1;
348
- const { unitId: e, subUnitId: n, payload: o } = t, r = s.get(f), a = s.get(i), d = s.get(p), m = d.syncUpdateMutationToColla, c = a.getComment(
348
+ const { unitId: e, subUnitId: n, payload: o } = t, r = s.get(M), a = s.get(i), d = s.get(p), m = d.syncUpdateMutationToColla, c = a.getComment(
349
349
  e,
350
350
  n,
351
351
  o.commentId
352
352
  );
353
353
  if (!c)
354
354
  return !1;
355
- const { children: h, ...M } = c;
355
+ const { children: u, ..._ } = c;
356
356
  if (!await d.updateComment({
357
- ...M,
357
+ ..._,
358
358
  ...o
359
359
  }))
360
360
  return !1;
361
361
  const N = {
362
- id: x.id,
362
+ id: A.id,
363
363
  params: t
364
364
  };
365
365
  return r.executeCommand(N.id, N.params, { onlyLocal: !m }), !0;
366
366
  }
367
- }, Z = {
367
+ }, ee = {
368
368
  id: "thread-comment.command.resolve-comment",
369
369
  type: l.COMMAND,
370
370
  async handler(s, t) {
@@ -374,34 +374,34 @@ const R = {
374
374
  return !m || !await a.resolveComment({
375
375
  ...m,
376
376
  resolved: o
377
- }) ? !1 : s.get(f).executeCommand(
378
- A.id,
377
+ }) ? !1 : s.get(M).executeCommand(
378
+ $.id,
379
379
  t,
380
380
  { onlyLocal: !c }
381
381
  );
382
382
  }
383
- }, ee = {
383
+ }, te = {
384
384
  id: "thread-comment.command.delete-comment",
385
385
  type: l.COMMAND,
386
386
  async handler(s, t) {
387
387
  if (!t)
388
388
  return !1;
389
- const e = s.get(i), n = s.get(p), o = s.get(f), { unitId: r, subUnitId: a, commentId: d } = t, m = n.syncUpdateMutationToColla, c = e.getComment(r, a, d);
389
+ const e = s.get(i), n = s.get(p), o = s.get(M), { unitId: r, subUnitId: a, commentId: d } = t, m = n.syncUpdateMutationToColla, c = e.getComment(r, a, d);
390
390
  if (!c || !await n.deleteComment(r, a, c.threadId, d))
391
391
  return !1;
392
- const h = {
392
+ const u = {
393
393
  id: E.id,
394
394
  params: t
395
395
  };
396
- return o.executeCommand(h.id, h.params, { onlyLocal: !m });
396
+ return o.executeCommand(u.id, u.params, { onlyLocal: !m });
397
397
  }
398
- }, te = {
398
+ }, ne = {
399
399
  id: "thread-comment.command.delete-comment-tree",
400
400
  type: l.COMMAND,
401
401
  async handler(s, t) {
402
402
  if (!t)
403
403
  return !1;
404
- const e = s.get(i), n = s.get(f), o = s.get(p), { unitId: r, subUnitId: a, commentId: d } = t, m = e.getCommentWithChildren(r, a, d);
404
+ const e = s.get(i), n = s.get(M), o = s.get(p), { unitId: r, subUnitId: a, commentId: d } = t, m = e.getCommentWithChildren(r, a, d);
405
405
  return !m || !await o.deleteComment(r, a, m.root.threadId, d) ? !1 : await n.executeCommand(E.id, {
406
406
  unitId: r,
407
407
  subUnitId: a,
@@ -409,16 +409,16 @@ const R = {
409
409
  });
410
410
  }
411
411
  };
412
- function he(s) {
413
- return W(s).format("YYYY/MM/DD HH:mm");
412
+ function pe(s) {
413
+ return k(s).format("YYYY/MM/DD HH:mm");
414
414
  }
415
- const $ = "UNIVER_THREAD_COMMENT_PLUGIN";
416
- var ne = Object.getOwnPropertyDescriptor, oe = (s, t, e, n) => {
417
- for (var o = n > 1 ? void 0 : n ? ne(t, e) : t, r = s.length - 1, a; r >= 0; r--)
415
+ const P = "UNIVER_THREAD_COMMENT_PLUGIN";
416
+ var oe = Object.getOwnPropertyDescriptor, re = (s, t, e, n) => {
417
+ for (var o = n > 1 ? void 0 : n ? oe(t, e) : t, r = s.length - 1, a; r >= 0; r--)
418
418
  (a = s[r]) && (o = a(o) || o);
419
419
  return o;
420
420
  }, S = (s, t) => (e, n) => t(e, n, s);
421
- const re = `SHEET_${$}`;
421
+ const ae = `SHEET_${P}`;
422
422
  let v = class extends U {
423
423
  constructor(s, t, e) {
424
424
  super(), this._resourceManagerService = s, this._threadCommentModel = t, this._threadCommentDataSourceService = e, this._initSnapshot();
@@ -445,7 +445,7 @@ let v = class extends U {
445
445
  };
446
446
  this.disposeWithMe(
447
447
  this._resourceManagerService.registerPluginResource({
448
- pluginName: re,
448
+ pluginName: ae,
449
449
  businesses: [T.UNIVER_SHEET, T.UNIVER_DOC],
450
450
  toJson: (e) => s(e),
451
451
  parseJson: (e) => t(e),
@@ -464,31 +464,34 @@ let v = class extends U {
464
464
  );
465
465
  }
466
466
  };
467
- v = oe([
467
+ v = re([
468
468
  S(0, J),
469
469
  S(1, g(i)),
470
470
  S(2, p)
471
471
  ], v);
472
- const ae = "thread-comment.config", D = {};
473
- var se = Object.getOwnPropertyDescriptor, me = (s, t, e, n) => {
474
- for (var o = n > 1 ? void 0 : n ? se(t, e) : t, r = s.length - 1, a; r >= 0; r--)
472
+ const se = "@univerjs/thread-comment", me = "0.16.1-insiders.20260311-074e8ca", D = {
473
+ name: se,
474
+ version: me
475
+ }, ce = "thread-comment.config", I = {};
476
+ var de = Object.getOwnPropertyDescriptor, ie = (s, t, e, n) => {
477
+ for (var o = n > 1 ? void 0 : n ? de(t, e) : t, r = s.length - 1, a; r >= 0; r--)
475
478
  (a = s[r]) && (o = a(o) || o);
476
479
  return o;
477
- }, y = (s, t) => (e, n) => t(e, n, s), _;
478
- let I = (_ = class extends G {
479
- constructor(s = D, t, e, n) {
480
+ }, y = (s, t) => (e, n) => t(e, n, s), f;
481
+ let R = (f = class extends G {
482
+ constructor(s = I, t, e, n) {
480
483
  super(), this._config = s, this._injector = t, this._commandService = e, this._configService = n;
481
484
  const { ...o } = V(
482
485
  {},
483
- D,
486
+ I,
484
487
  this._config
485
488
  );
486
- this._configService.setConfig(ae, o);
489
+ this._configService.setConfig(ce, o);
487
490
  }
488
491
  onStarting() {
489
492
  var s;
490
493
  Y([
491
- [p, { useClass: K }],
494
+ [p, { useClass: F }],
492
495
  [i],
493
496
  [v]
494
497
  ], (s = this._config) == null ? void 0 : s.overrides).forEach(
@@ -496,43 +499,43 @@ let I = (_ = class extends G {
496
499
  this._injector.add(t);
497
500
  }
498
501
  ), [
499
- Q,
500
502
  X,
501
- ee,
502
503
  Z,
503
504
  te,
504
- R,
505
+ ee,
506
+ ne,
505
507
  x,
506
- z,
508
+ A,
509
+ Q,
507
510
  E,
508
- A
511
+ $
509
512
  ].forEach((t) => {
510
513
  this._commandService.registerCommand(t);
511
514
  }), this._injector.get(v);
512
515
  }
513
- }, u(_, "pluginName", $), u(_, "type", T.UNIVER_UNKNOWN), _);
514
- I = me([
515
- y(1, g(k)),
516
- y(2, f),
517
- y(3, B)
518
- ], I);
516
+ }, h(f, "pluginName", P), h(f, "packageName", D.name), h(f, "version", D.version), h(f, "type", T.UNIVER_UNKNOWN), f);
517
+ R = ie([
518
+ y(1, g(B)),
519
+ y(2, M),
520
+ y(3, b)
521
+ ], R);
519
522
  export {
520
- Q as AddCommentCommand,
521
- R as AddCommentMutation,
522
- ee as DeleteCommentCommand,
523
+ X as AddCommentCommand,
524
+ x as AddCommentMutation,
525
+ te as DeleteCommentCommand,
523
526
  E as DeleteCommentMutation,
524
- te as DeleteCommentTreeCommand,
527
+ ne as DeleteCommentTreeCommand,
525
528
  p as IThreadCommentDataSourceService,
526
- Z as ResolveCommentCommand,
527
- A as ResolveCommentMutation,
528
- re as SHEET_UNIVER_THREAD_COMMENT_PLUGIN,
529
- $ as TC_PLUGIN_NAME,
530
- K as ThreadCommentDataSourceService,
529
+ ee as ResolveCommentCommand,
530
+ $ as ResolveCommentMutation,
531
+ ae as SHEET_UNIVER_THREAD_COMMENT_PLUGIN,
532
+ P as TC_PLUGIN_NAME,
533
+ F as ThreadCommentDataSourceService,
531
534
  i as ThreadCommentModel,
532
535
  v as ThreadCommentResourceController,
533
- I as UniverThreadCommentPlugin,
534
- X as UpdateCommentCommand,
535
- x as UpdateCommentMutation,
536
- z as UpdateCommentRefMutation,
537
- he as getDT
536
+ R as UniverThreadCommentPlugin,
537
+ Z as UpdateCommentCommand,
538
+ A as UpdateCommentMutation,
539
+ Q as UpdateCommentRefMutation,
540
+ pe as getDT
538
541
  };
package/lib/index.js CHANGED
@@ -1,13 +1,13 @@
1
- var P = Object.defineProperty;
2
- var L = (s, t, e) => t in s ? P(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var u = (s, t, e) => L(s, typeof t != "symbol" ? t + "" : t, e);
4
- import { createIdentifier as j, Disposable as U, Inject as g, LifecycleService as H, LifecycleStages as O, CommandType as l, ICommandService as f, dayjs as W, IResourceManagerService as J, UniverInstanceType as T, Plugin as G, merge as V, mergeOverrideWithDependencies as Y, Injector as k, IConfigService as B } from "@univerjs/core";
5
- import { Subject as b } from "rxjs";
6
- class K extends U {
1
+ var L = Object.defineProperty;
2
+ var j = (s, t, e) => t in s ? L(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
+ var h = (s, t, e) => j(s, typeof t != "symbol" ? t + "" : t, e);
4
+ import { createIdentifier as H, Disposable as U, Inject as g, LifecycleService as W, LifecycleStages as O, CommandType as l, ICommandService as M, dayjs as k, UniverInstanceType as T, IResourceManagerService as J, Plugin as G, merge as V, mergeOverrideWithDependencies as Y, Injector as B, IConfigService as b } from "@univerjs/core";
5
+ import { Subject as K } from "rxjs";
6
+ class F extends U {
7
7
  constructor() {
8
8
  super();
9
- u(this, "_dataSource", null);
10
- u(this, "syncUpdateMutationToColla", !0);
9
+ h(this, "_dataSource", null);
10
+ h(this, "syncUpdateMutationToColla", !0);
11
11
  }
12
12
  set dataSource(e) {
13
13
  this._dataSource = e;
@@ -45,20 +45,20 @@ class K extends U {
45
45
  return e;
46
46
  }
47
47
  }
48
- const p = j("univer.thread-comment.data-source-service");
49
- var F = Object.getOwnPropertyDescriptor, q = (s, t, e, n) => {
50
- for (var o = n > 1 ? void 0 : n ? F(t, e) : t, r = s.length - 1, a; r >= 0; r--)
48
+ const p = H("univer.thread-comment.data-source-service");
49
+ var q = Object.getOwnPropertyDescriptor, z = (s, t, e, n) => {
50
+ for (var o = n > 1 ? void 0 : n ? q(t, e) : t, r = s.length - 1, a; r >= 0; r--)
51
51
  (a = s[r]) && (o = a(o) || o);
52
52
  return o;
53
53
  }, w = (s, t) => (e, n) => t(e, n, s);
54
54
  let i = class extends U {
55
55
  constructor(t, e) {
56
56
  super();
57
- u(this, "_commentsMap", /* @__PURE__ */ new Map());
58
- u(this, "_threadMap", /* @__PURE__ */ new Map());
59
- u(this, "_commentUpdate$", new b());
60
- u(this, "commentUpdate$", this._commentUpdate$.asObservable());
61
- u(this, "_tasks", []);
57
+ h(this, "_commentsMap", /* @__PURE__ */ new Map());
58
+ h(this, "_threadMap", /* @__PURE__ */ new Map());
59
+ h(this, "_commentUpdate$", new K());
60
+ h(this, "commentUpdate$", this._commentUpdate$.asObservable());
61
+ h(this, "_tasks", []);
62
62
  this._dataSourceService = t, this._lifecycleService = e, this.disposeWithMe(() => {
63
63
  this._commentUpdate$.complete();
64
64
  }), this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe((n) => {
@@ -68,8 +68,8 @@ let i = class extends U {
68
68
  m || (m = /* @__PURE__ */ new Map(), o.set(r, m));
69
69
  let c = m.get(a);
70
70
  c || (c = /* @__PURE__ */ new Set(), m.set(a, c));
71
- for (const h of d)
72
- c.add(h);
71
+ for (const u of d)
72
+ c.add(u);
73
73
  }), this._tasks = [], o.forEach((r, a) => {
74
74
  r.forEach((d, m) => {
75
75
  this.syncThreadComments(a, m, Array.from(d));
@@ -132,8 +132,8 @@ let i = class extends U {
132
132
  a.forEach((m) => {
133
133
  this._replaceComment(t, e, m), d.delete(m.threadId);
134
134
  }), d.forEach((m) => {
135
- o.delete(m), r.forEach((c, h) => {
136
- c.threadId === m && r.delete(h);
135
+ o.delete(m), r.forEach((c, u) => {
136
+ c.threadId === m && r.delete(u);
137
137
  });
138
138
  });
139
139
  }
@@ -143,7 +143,7 @@ let i = class extends U {
143
143
  parentId: a === n.id ? void 0 : a
144
144
  };
145
145
  c.threadId || (c.threadId = c.parentId || c.id);
146
- const h = (C) => {
146
+ const u = (C) => {
147
147
  r.set(C.id, C), this._commentUpdate$.next({
148
148
  unitId: t,
149
149
  subUnitId: e,
@@ -152,12 +152,12 @@ let i = class extends U {
152
152
  isRoot: !C.parentId
153
153
  });
154
154
  };
155
- h(c);
156
- const M = this._ensureThreadMap(t, e);
155
+ u(c);
156
+ const _ = this._ensureThreadMap(t, e);
157
157
  if (!c.parentId) {
158
- M.set(c.threadId, c);
158
+ _.set(c.threadId, c);
159
159
  for (const C of d)
160
- h(C);
160
+ u(C);
161
161
  }
162
162
  return o && this.syncThreadComments(t, e, [c.threadId]), !0;
163
163
  }
@@ -273,11 +273,11 @@ let i = class extends U {
273
273
  }), t;
274
274
  }
275
275
  };
276
- i = q([
276
+ i = z([
277
277
  w(0, g(p)),
278
- w(1, g(H))
278
+ w(1, g(W))
279
279
  ], i);
280
- const R = {
280
+ const x = {
281
281
  id: "thread-comment.mutation.add-comment",
282
282
  type: l.MUTATION,
283
283
  handler(s, t, e) {
@@ -286,7 +286,7 @@ const R = {
286
286
  const n = s.get(i), { unitId: o, subUnitId: r, comment: a, sync: d } = t, m = d || (e == null ? void 0 : e.fromChangeset) && !a.parentId;
287
287
  return n.addComment(o, r, a, m);
288
288
  }
289
- }, x = {
289
+ }, A = {
290
290
  id: "thread-comment.mutation.update-comment",
291
291
  type: l.MUTATION,
292
292
  handler(s, t) {
@@ -295,7 +295,7 @@ const R = {
295
295
  const e = s.get(i), { unitId: n, subUnitId: o, payload: r, silent: a } = t;
296
296
  return e.updateComment(n, o, r, a);
297
297
  }
298
- }, z = {
298
+ }, Q = {
299
299
  id: "thread-comment.mutation.update-comment-ref",
300
300
  type: l.MUTATION,
301
301
  handler(s, t) {
@@ -304,7 +304,7 @@ const R = {
304
304
  const e = s.get(i), { unitId: n, subUnitId: o, payload: r, silent: a } = t;
305
305
  return e.updateCommentRef(n, o, r, a);
306
306
  }
307
- }, A = {
307
+ }, $ = {
308
308
  id: "thread-comment.mutation.resolve-comment",
309
309
  type: l.MUTATION,
310
310
  handler(s, t) {
@@ -322,14 +322,14 @@ const R = {
322
322
  const e = s.get(i), { unitId: n, subUnitId: o, commentId: r } = t;
323
323
  return e.deleteComment(n, o, r);
324
324
  }
325
- }, Q = {
325
+ }, X = {
326
326
  id: "thread-comment.command.add-comment",
327
327
  type: l.COMMAND,
328
328
  async handler(s, t) {
329
329
  if (!t)
330
330
  return !1;
331
- const e = s.get(f), n = s.get(p), { comment: o } = t, r = await n.addComment(o), a = n.syncUpdateMutationToColla, d = !o.parentId, m = {
332
- id: R.id,
331
+ const e = s.get(M), n = s.get(p), { comment: o } = t, r = await n.addComment(o), a = n.syncUpdateMutationToColla, d = !o.parentId, m = {
332
+ id: x.id,
333
333
  params: {
334
334
  ...t,
335
335
  comment: r
@@ -339,32 +339,32 @@ const R = {
339
339
  onlyLocal: !a
340
340
  });
341
341
  }
342
- }, X = {
342
+ }, Z = {
343
343
  id: "thread-comment.command.update-comment",
344
344
  type: l.COMMAND,
345
345
  async handler(s, t) {
346
346
  if (!t)
347
347
  return !1;
348
- const { unitId: e, subUnitId: n, payload: o } = t, r = s.get(f), a = s.get(i), d = s.get(p), m = d.syncUpdateMutationToColla, c = a.getComment(
348
+ const { unitId: e, subUnitId: n, payload: o } = t, r = s.get(M), a = s.get(i), d = s.get(p), m = d.syncUpdateMutationToColla, c = a.getComment(
349
349
  e,
350
350
  n,
351
351
  o.commentId
352
352
  );
353
353
  if (!c)
354
354
  return !1;
355
- const { children: h, ...M } = c;
355
+ const { children: u, ..._ } = c;
356
356
  if (!await d.updateComment({
357
- ...M,
357
+ ..._,
358
358
  ...o
359
359
  }))
360
360
  return !1;
361
361
  const N = {
362
- id: x.id,
362
+ id: A.id,
363
363
  params: t
364
364
  };
365
365
  return r.executeCommand(N.id, N.params, { onlyLocal: !m }), !0;
366
366
  }
367
- }, Z = {
367
+ }, ee = {
368
368
  id: "thread-comment.command.resolve-comment",
369
369
  type: l.COMMAND,
370
370
  async handler(s, t) {
@@ -374,34 +374,34 @@ const R = {
374
374
  return !m || !await a.resolveComment({
375
375
  ...m,
376
376
  resolved: o
377
- }) ? !1 : s.get(f).executeCommand(
378
- A.id,
377
+ }) ? !1 : s.get(M).executeCommand(
378
+ $.id,
379
379
  t,
380
380
  { onlyLocal: !c }
381
381
  );
382
382
  }
383
- }, ee = {
383
+ }, te = {
384
384
  id: "thread-comment.command.delete-comment",
385
385
  type: l.COMMAND,
386
386
  async handler(s, t) {
387
387
  if (!t)
388
388
  return !1;
389
- const e = s.get(i), n = s.get(p), o = s.get(f), { unitId: r, subUnitId: a, commentId: d } = t, m = n.syncUpdateMutationToColla, c = e.getComment(r, a, d);
389
+ const e = s.get(i), n = s.get(p), o = s.get(M), { unitId: r, subUnitId: a, commentId: d } = t, m = n.syncUpdateMutationToColla, c = e.getComment(r, a, d);
390
390
  if (!c || !await n.deleteComment(r, a, c.threadId, d))
391
391
  return !1;
392
- const h = {
392
+ const u = {
393
393
  id: E.id,
394
394
  params: t
395
395
  };
396
- return o.executeCommand(h.id, h.params, { onlyLocal: !m });
396
+ return o.executeCommand(u.id, u.params, { onlyLocal: !m });
397
397
  }
398
- }, te = {
398
+ }, ne = {
399
399
  id: "thread-comment.command.delete-comment-tree",
400
400
  type: l.COMMAND,
401
401
  async handler(s, t) {
402
402
  if (!t)
403
403
  return !1;
404
- const e = s.get(i), n = s.get(f), o = s.get(p), { unitId: r, subUnitId: a, commentId: d } = t, m = e.getCommentWithChildren(r, a, d);
404
+ const e = s.get(i), n = s.get(M), o = s.get(p), { unitId: r, subUnitId: a, commentId: d } = t, m = e.getCommentWithChildren(r, a, d);
405
405
  return !m || !await o.deleteComment(r, a, m.root.threadId, d) ? !1 : await n.executeCommand(E.id, {
406
406
  unitId: r,
407
407
  subUnitId: a,
@@ -409,16 +409,16 @@ const R = {
409
409
  });
410
410
  }
411
411
  };
412
- function he(s) {
413
- return W(s).format("YYYY/MM/DD HH:mm");
412
+ function pe(s) {
413
+ return k(s).format("YYYY/MM/DD HH:mm");
414
414
  }
415
- const $ = "UNIVER_THREAD_COMMENT_PLUGIN";
416
- var ne = Object.getOwnPropertyDescriptor, oe = (s, t, e, n) => {
417
- for (var o = n > 1 ? void 0 : n ? ne(t, e) : t, r = s.length - 1, a; r >= 0; r--)
415
+ const P = "UNIVER_THREAD_COMMENT_PLUGIN";
416
+ var oe = Object.getOwnPropertyDescriptor, re = (s, t, e, n) => {
417
+ for (var o = n > 1 ? void 0 : n ? oe(t, e) : t, r = s.length - 1, a; r >= 0; r--)
418
418
  (a = s[r]) && (o = a(o) || o);
419
419
  return o;
420
420
  }, S = (s, t) => (e, n) => t(e, n, s);
421
- const re = `SHEET_${$}`;
421
+ const ae = `SHEET_${P}`;
422
422
  let v = class extends U {
423
423
  constructor(s, t, e) {
424
424
  super(), this._resourceManagerService = s, this._threadCommentModel = t, this._threadCommentDataSourceService = e, this._initSnapshot();
@@ -445,7 +445,7 @@ let v = class extends U {
445
445
  };
446
446
  this.disposeWithMe(
447
447
  this._resourceManagerService.registerPluginResource({
448
- pluginName: re,
448
+ pluginName: ae,
449
449
  businesses: [T.UNIVER_SHEET, T.UNIVER_DOC],
450
450
  toJson: (e) => s(e),
451
451
  parseJson: (e) => t(e),
@@ -464,31 +464,34 @@ let v = class extends U {
464
464
  );
465
465
  }
466
466
  };
467
- v = oe([
467
+ v = re([
468
468
  S(0, J),
469
469
  S(1, g(i)),
470
470
  S(2, p)
471
471
  ], v);
472
- const ae = "thread-comment.config", D = {};
473
- var se = Object.getOwnPropertyDescriptor, me = (s, t, e, n) => {
474
- for (var o = n > 1 ? void 0 : n ? se(t, e) : t, r = s.length - 1, a; r >= 0; r--)
472
+ const se = "@univerjs/thread-comment", me = "0.16.1-insiders.20260311-074e8ca", D = {
473
+ name: se,
474
+ version: me
475
+ }, ce = "thread-comment.config", I = {};
476
+ var de = Object.getOwnPropertyDescriptor, ie = (s, t, e, n) => {
477
+ for (var o = n > 1 ? void 0 : n ? de(t, e) : t, r = s.length - 1, a; r >= 0; r--)
475
478
  (a = s[r]) && (o = a(o) || o);
476
479
  return o;
477
- }, y = (s, t) => (e, n) => t(e, n, s), _;
478
- let I = (_ = class extends G {
479
- constructor(s = D, t, e, n) {
480
+ }, y = (s, t) => (e, n) => t(e, n, s), f;
481
+ let R = (f = class extends G {
482
+ constructor(s = I, t, e, n) {
480
483
  super(), this._config = s, this._injector = t, this._commandService = e, this._configService = n;
481
484
  const { ...o } = V(
482
485
  {},
483
- D,
486
+ I,
484
487
  this._config
485
488
  );
486
- this._configService.setConfig(ae, o);
489
+ this._configService.setConfig(ce, o);
487
490
  }
488
491
  onStarting() {
489
492
  var s;
490
493
  Y([
491
- [p, { useClass: K }],
494
+ [p, { useClass: F }],
492
495
  [i],
493
496
  [v]
494
497
  ], (s = this._config) == null ? void 0 : s.overrides).forEach(
@@ -496,43 +499,43 @@ let I = (_ = class extends G {
496
499
  this._injector.add(t);
497
500
  }
498
501
  ), [
499
- Q,
500
502
  X,
501
- ee,
502
503
  Z,
503
504
  te,
504
- R,
505
+ ee,
506
+ ne,
505
507
  x,
506
- z,
508
+ A,
509
+ Q,
507
510
  E,
508
- A
511
+ $
509
512
  ].forEach((t) => {
510
513
  this._commandService.registerCommand(t);
511
514
  }), this._injector.get(v);
512
515
  }
513
- }, u(_, "pluginName", $), u(_, "type", T.UNIVER_UNKNOWN), _);
514
- I = me([
515
- y(1, g(k)),
516
- y(2, f),
517
- y(3, B)
518
- ], I);
516
+ }, h(f, "pluginName", P), h(f, "packageName", D.name), h(f, "version", D.version), h(f, "type", T.UNIVER_UNKNOWN), f);
517
+ R = ie([
518
+ y(1, g(B)),
519
+ y(2, M),
520
+ y(3, b)
521
+ ], R);
519
522
  export {
520
- Q as AddCommentCommand,
521
- R as AddCommentMutation,
522
- ee as DeleteCommentCommand,
523
+ X as AddCommentCommand,
524
+ x as AddCommentMutation,
525
+ te as DeleteCommentCommand,
523
526
  E as DeleteCommentMutation,
524
- te as DeleteCommentTreeCommand,
527
+ ne as DeleteCommentTreeCommand,
525
528
  p as IThreadCommentDataSourceService,
526
- Z as ResolveCommentCommand,
527
- A as ResolveCommentMutation,
528
- re as SHEET_UNIVER_THREAD_COMMENT_PLUGIN,
529
- $ as TC_PLUGIN_NAME,
530
- K as ThreadCommentDataSourceService,
529
+ ee as ResolveCommentCommand,
530
+ $ as ResolveCommentMutation,
531
+ ae as SHEET_UNIVER_THREAD_COMMENT_PLUGIN,
532
+ P as TC_PLUGIN_NAME,
533
+ F as ThreadCommentDataSourceService,
531
534
  i as ThreadCommentModel,
532
535
  v as ThreadCommentResourceController,
533
- I as UniverThreadCommentPlugin,
534
- X as UpdateCommentCommand,
535
- x as UpdateCommentMutation,
536
- z as UpdateCommentRefMutation,
537
- he as getDT
536
+ R as UniverThreadCommentPlugin,
537
+ Z as UpdateCommentCommand,
538
+ A as UpdateCommentMutation,
539
+ Q as UpdateCommentRefMutation,
540
+ pe as getDT
538
541
  };
@@ -18,7 +18,7 @@ export type { IAddCommentCommandParams, IDeleteCommentCommandParams, IDeleteComm
18
18
  export { AddCommentMutation, DeleteCommentMutation, ResolveCommentMutation, UpdateCommentMutation, UpdateCommentRefMutation, } from './commands/mutations/comment.mutation';
19
19
  export type { IAddCommentMutationParams, IDeleteCommentMutationParams, IResolveCommentMutationParams, IUpdateCommentMutationParams, IUpdateCommentPayload, IUpdateCommentRefMutationParams, } from './commands/mutations/comment.mutation';
20
20
  export { getDT } from './common/utils';
21
- export type { IUniverThreadCommentConfig } from './controllers/config.schema';
21
+ export type { IUniverThreadCommentConfig } from './config/config';
22
22
  export { SHEET_UNIVER_THREAD_COMMENT_PLUGIN, ThreadCommentResourceController } from './controllers/tc-resource.controller';
23
23
  export { type CommentUpdate, type IThreadInfo, ThreadCommentModel } from './models/thread-comment.model';
24
24
  export { UniverThreadCommentPlugin } from './plugin';
@@ -1,4 +1,4 @@
1
- import { IUniverThreadCommentConfig } from './controllers/config.schema';
1
+ import { IUniverThreadCommentConfig } from './config/config';
2
2
  import { ICommandService, IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
3
3
  export declare class UniverThreadCommentPlugin extends Plugin {
4
4
  private readonly _config;
@@ -6,6 +6,8 @@ export declare class UniverThreadCommentPlugin extends Plugin {
6
6
  protected _commandService: ICommandService;
7
7
  private readonly _configService;
8
8
  static pluginName: string;
9
+ static packageName: string;
10
+ static version: string;
9
11
  static type: UniverInstanceType;
10
12
  constructor(_config: Partial<IUniverThreadCommentConfig> | undefined, _injector: Injector, _commandService: ICommandService, _configService: IConfigService);
11
13
  onStarting(): void;
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.UniverThreadComment={},d.UniverCore,d.rxjs))})(this,(function(d,s,M){"use strict";var B=Object.defineProperty;var q=(d,s,M)=>s in d?B(d,s,{enumerable:!0,configurable:!0,writable:!0,value:M}):d[s]=M;var u=(d,s,M)=>q(d,typeof s!="symbol"?s+"":s,M);var T;class I extends s.Disposable{constructor(){super();u(this,"_dataSource",null);u(this,"syncUpdateMutationToColla",!0)}set dataSource(e){this._dataSource=e}get dataSource(){return this._dataSource}async getThreadComment(e,t,n){return this._dataSource?(await this._dataSource.listComments(e,t,[n]))[0]:null}async addComment(e){var t;return this._dataSource?this._dataSource.addComment(e):{...e,threadId:(t=e.threadId)!=null?t:e.id}}async updateComment(e){return this._dataSource?this._dataSource.updateComment(e):!0}async resolveComment(e){return this._dataSource?this._dataSource.resolveComment(e):!0}async deleteComment(e,t,n,o){return this._dataSource?this._dataSource.deleteComment(e,t,n,o):!0}async listThreadComments(e,t,n){return this.dataSource?this.dataSource.listComments(e,t,n):!1}saveToSnapshot(e,t){if(this._dataSource){const n={};return Object.keys(e).forEach(o=>{const a=e[o];n[o]=a.map(this.dataSource.saveCommentToSnapshot)}),n}return e}}const C=s.createIdentifier("univer.thread-comment.data-source-service");var H=Object.getOwnPropertyDescriptor,W=(c,m,e,t)=>{for(var n=t>1?void 0:t?H(m,e):m,o=c.length-1,a;o>=0;o--)(a=c[o])&&(n=a(n)||n);return n},N=(c,m)=>(e,t)=>m(e,t,c);d.ThreadCommentModel=class extends s.Disposable{constructor(e,t){super();u(this,"_commentsMap",new Map);u(this,"_threadMap",new Map);u(this,"_commentUpdate$",new M.Subject);u(this,"commentUpdate$",this._commentUpdate$.asObservable());u(this,"_tasks",[]);this._dataSourceService=e,this._lifecycleService=t,this.disposeWithMe(()=>{this._commentUpdate$.complete()}),this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe(n=>{const o=new Map;n===s.LifecycleStages.Rendered&&(this._tasks.forEach(({unitId:a,subUnitId:r,threadIds:i})=>{let h=o.get(a);h||(h=new Map,o.set(a,h));let l=h.get(r);l||(l=new Set,h.set(r,l));for(const p of i)l.add(p)}),this._tasks=[],o.forEach((a,r)=>{a.forEach((i,h)=>{this.syncThreadComments(r,h,Array.from(i))})}))}))}_ensureCommentMap(e,t){let n=this._commentsMap.get(e);n||(n=new Map,this._commentsMap.set(e,n));let o=n.get(t);return o||(o=new Map,n.set(t,o)),o}ensureMap(e,t){return this._ensureCommentMap(e,t)}_ensureThreadMap(e,t){let n=this._threadMap.get(e);n||(n=new Map,this._threadMap.set(e,n));let o=n.get(t);return o||(o=new Map,n.set(t,o)),o}_replaceComment(e,t,n){const o=this._ensureCommentMap(e,t),a=o.get(n.id);if(a){const{children:r,...i}=n,h={...i,ref:a.ref};o.set(n.id,h),r==null||r.forEach(l=>{o.set(l.id,{...l,ref:""})}),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"syncUpdate",payload:h}),!!n.resolved!=!!a.resolved&&this._commentUpdate$.next({unitId:e,subUnitId:t,type:"resolve",payload:{commentId:n.id,resolved:!!n.resolved}})}}async syncThreadComments(e,t,n){if(this._lifecycleService.stage<s.LifecycleStages.Rendered){this._tasks.push({unitId:e,subUnitId:t,threadIds:n});return}const o=this._ensureThreadMap(e,t),a=this._ensureCommentMap(e,t),r=await this._dataSourceService.listThreadComments(e,t,n);if(!r)return;const i=new Set(n);r.forEach(h=>{this._replaceComment(e,t,h),i.delete(h.threadId)}),i.forEach(h=>{o.delete(h),a.forEach((l,p)=>{l.threadId===h&&a.delete(p)})})}addComment(e,t,n,o){const a=this._ensureCommentMap(e,t),{parentId:r,children:i=[],...h}=n,l={...h,parentId:r===n.id?void 0:r};l.threadId||(l.threadId=l.parentId||l.id);const p=f=>{a.set(f.id,f),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"add",payload:f,isRoot:!f.parentId})};p(l);const L=this._ensureThreadMap(e,t);if(!l.parentId){L.set(l.threadId,l);for(const f of i)p(f)}return o&&this.syncThreadComments(e,t,[l.threadId]),!0}updateComment(e,t,n,o){const r=this._ensureCommentMap(e,t).get(n.commentId);return r&&(r.updated=!0,r.text=n.text,r.attachments=n.attachments,r.updateT=n.updateT,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"update",payload:n,silent:o})),!0}updateCommentRef(e,t,n,o){const r=this._ensureCommentMap(e,t).get(n.commentId);return r?(r.ref=n.ref,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"updateRef",payload:n,silent:o,threadId:r.threadId}),!0):!1}resolveComment(e,t,n,o){const r=this._ensureCommentMap(e,t).get(n);return r?(r.resolved=o,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"resolve",payload:{commentId:n,resolved:o}}),!0):!1}getComment(e,t,n){return this._ensureCommentMap(e,t).get(n)}getRootComment(e,t,n){return this._ensureThreadMap(e,t).get(n)}getThread(e,t,n){const o=this._ensureCommentMap(e,t),a=Array.from(o.values()).filter(l=>l.threadId===n);let r;const i=[],h=new Set;for(const l of a)l.parentId?i.push(l):r=l,h.add(l.personId);if(r)return{root:r,children:i,relativeUsers:h,unitId:e,subUnitId:t,threadId:n}}getCommentWithChildren(e,t,n){const o=this.getComment(e,t,n);if(o)return this.getThread(e,t,o.threadId)}_deleteComment(e,t,n){const o=this._ensureCommentMap(e,t),a=o.get(n);a&&(o.delete(n),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"delete",payload:{commentId:n,isRoot:!a.parentId,comment:a}}))}deleteThread(e,t,n){this._ensureThreadMap(e,t).delete(n),this._ensureCommentMap(e,t).forEach(r=>{r.threadId===n&&this._deleteComment(e,t,r.id)})}deleteComment(e,t,n){const a=this._ensureCommentMap(e,t).get(n);return a&&(a.parentId?this._deleteComment(e,t,n):this.deleteThread(e,t,a.threadId)),!0}deleteUnit(e){const t=this._commentsMap.get(e);t&&t.forEach((n,o)=>{n.forEach(a=>{this.deleteComment(e,o,a.id)})})}getUnit(e){const t=this._threadMap.get(e);if(!t)return[];const n=[];return t.forEach((o,a)=>{o.forEach((r,i)=>{const h=this.getThread(e,a,i);h&&n.push(h)})}),n}getAll(){const e=[];return this._commentsMap.forEach((t,n)=>{e.push({unitId:n,threads:this.getUnit(n)})}),e}},d.ThreadCommentModel=W([N(0,s.Inject(C)),N(1,s.Inject(s.LifecycleService))],d.ThreadCommentModel);const v={id:"thread-comment.mutation.add-comment",type:s.CommandType.MUTATION,handler(c,m,e){if(!m)return!1;const t=c.get(d.ThreadCommentModel),{unitId:n,subUnitId:o,comment:a,sync:r}=m,i=r||(e==null?void 0:e.fromChangeset)&&!a.parentId;return t.addComment(n,o,a,i)}},g={id:"thread-comment.mutation.update-comment",type:s.CommandType.MUTATION,handler(c,m){if(!m)return!1;const e=c.get(d.ThreadCommentModel),{unitId:t,subUnitId:n,payload:o,silent:a}=m;return e.updateComment(t,n,o,a)}},D={id:"thread-comment.mutation.update-comment-ref",type:s.CommandType.MUTATION,handler(c,m){if(!m)return!1;const e=c.get(d.ThreadCommentModel),{unitId:t,subUnitId:n,payload:o,silent:a}=m;return e.updateCommentRef(t,n,o,a)}},S={id:"thread-comment.mutation.resolve-comment",type:s.CommandType.MUTATION,handler(c,m){if(!m)return!1;const e=c.get(d.ThreadCommentModel),{unitId:t,subUnitId:n,resolved:o,commentId:a}=m;return e.resolveComment(t,n,a,o)}},_={id:"thread-comment.mutation.delete-comment",type:s.CommandType.MUTATION,handler(c,m){if(!m)return!1;const e=c.get(d.ThreadCommentModel),{unitId:t,subUnitId:n,commentId:o}=m;return e.deleteComment(t,n,o)}},O={id:"thread-comment.command.add-comment",type:s.CommandType.COMMAND,async handler(c,m){if(!m)return!1;const e=c.get(s.ICommandService),t=c.get(C),{comment:n}=m,o=await t.addComment(n),a=t.syncUpdateMutationToColla,r=!n.parentId,i={id:v.id,params:{...m,comment:o}};return r?await e.executeCommand(i.id,i.params):e.executeCommand(i.id,i.params,{onlyLocal:!a})}},R={id:"thread-comment.command.update-comment",type:s.CommandType.COMMAND,async handler(c,m){if(!m)return!1;const{unitId:e,subUnitId:t,payload:n}=m,o=c.get(s.ICommandService),a=c.get(d.ThreadCommentModel),r=c.get(C),i=r.syncUpdateMutationToColla,h=a.getComment(e,t,n.commentId);if(!h)return!1;const{children:l,...p}=h;if(!await r.updateComment({...p,...n}))return!1;const f={id:g.id,params:m};return o.executeCommand(f.id,f.params,{onlyLocal:!i}),!0}},w={id:"thread-comment.command.resolve-comment",type:s.CommandType.COMMAND,async handler(c,m){if(!m)return!1;const{unitId:e,subUnitId:t,resolved:n,commentId:o}=m,a=c.get(C),i=c.get(d.ThreadCommentModel).getComment(e,t,o),h=a.syncUpdateMutationToColla;return!i||!await a.resolveComment({...i,resolved:n})?!1:c.get(s.ICommandService).executeCommand(S.id,m,{onlyLocal:!h})}},A={id:"thread-comment.command.delete-comment",type:s.CommandType.COMMAND,async handler(c,m){if(!m)return!1;const e=c.get(d.ThreadCommentModel),t=c.get(C),n=c.get(s.ICommandService),{unitId:o,subUnitId:a,commentId:r}=m,i=t.syncUpdateMutationToColla,h=e.getComment(o,a,r);if(!h||!await t.deleteComment(o,a,h.threadId,r))return!1;const l={id:_.id,params:m};return n.executeCommand(l.id,l.params,{onlyLocal:!i})}},P={id:"thread-comment.command.delete-comment-tree",type:s.CommandType.COMMAND,async handler(c,m){if(!m)return!1;const e=c.get(d.ThreadCommentModel),t=c.get(s.ICommandService),n=c.get(C),{unitId:o,subUnitId:a,commentId:r}=m,i=e.getCommentWithChildren(o,a,r);return!i||!await n.deleteComment(o,a,i.root.threadId,r)?!1:await t.executeCommand(_.id,{unitId:o,subUnitId:a,commentId:i.root.id})}};function G(c){return s.dayjs(c).format("YYYY/MM/DD HH:mm")}const y="UNIVER_THREAD_COMMENT_PLUGIN";var J=Object.getOwnPropertyDescriptor,V=(c,m,e,t)=>{for(var n=t>1?void 0:t?J(m,e):m,o=c.length-1,a;o>=0;o--)(a=c[o])&&(n=a(n)||n);return n},U=(c,m)=>(e,t)=>m(e,t,c);const j=`SHEET_${y}`;d.ThreadCommentResourceController=class extends s.Disposable{constructor(m,e,t){super(),this._resourceManagerService=m,this._threadCommentModel=e,this._threadCommentDataSourceService=t,this._initSnapshot()}_initSnapshot(){const m=t=>{const n=this._threadCommentModel.getUnit(t),o={};return n?(n.forEach(a=>{var i;const r=(i=o[a.subUnitId])!=null?i:[];r.push({...a.root,children:a.children}),o[a.subUnitId]=r}),JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(o,t))):""},e=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:j,businesses:[s.UniverInstanceType.UNIVER_SHEET,s.UniverInstanceType.UNIVER_DOC],toJson:t=>m(t),parseJson:t=>e(t),onUnLoad:t=>{this._threadCommentModel.deleteUnit(t)},onLoad:async(t,n)=>{Object.keys(n).forEach(o=>{const a=n[o];a.forEach(r=>{this._threadCommentModel.addComment(t,o,r)}),this._threadCommentModel.syncThreadComments(t,o,a.map(r=>r.threadId))})}}))}},d.ThreadCommentResourceController=V([U(0,s.IResourceManagerService),U(1,s.Inject(d.ThreadCommentModel)),U(2,C)],d.ThreadCommentResourceController);const b="thread-comment.config",$={};var Y=Object.getOwnPropertyDescriptor,k=(c,m,e,t)=>{for(var n=t>1?void 0:t?Y(m,e):m,o=c.length-1,a;o>=0;o--)(a=c[o])&&(n=a(n)||n);return n},E=(c,m)=>(e,t)=>m(e,t,c);d.UniverThreadCommentPlugin=(T=class extends s.Plugin{constructor(m=$,e,t,n){super(),this._config=m,this._injector=e,this._commandService=t,this._configService=n;const{...o}=s.merge({},$,this._config);this._configService.setConfig(b,o)}onStarting(){var m;s.mergeOverrideWithDependencies([[C,{useClass:I}],[d.ThreadCommentModel],[d.ThreadCommentResourceController]],(m=this._config)==null?void 0:m.overrides).forEach(e=>{this._injector.add(e)}),[O,R,A,w,P,v,g,D,_,S].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(d.ThreadCommentResourceController)}},u(T,"pluginName",y),u(T,"type",s.UniverInstanceType.UNIVER_UNKNOWN),T),d.UniverThreadCommentPlugin=k([E(1,s.Inject(s.Injector)),E(2,s.ICommandService),E(3,s.IConfigService)],d.UniverThreadCommentPlugin),d.AddCommentCommand=O,d.AddCommentMutation=v,d.DeleteCommentCommand=A,d.DeleteCommentMutation=_,d.DeleteCommentTreeCommand=P,d.IThreadCommentDataSourceService=C,d.ResolveCommentCommand=w,d.ResolveCommentMutation=S,d.SHEET_UNIVER_THREAD_COMMENT_PLUGIN=j,d.TC_PLUGIN_NAME=y,d.ThreadCommentDataSourceService=I,d.UpdateCommentCommand=R,d.UpdateCommentMutation=g,d.UpdateCommentRefMutation=D,d.getDT=G,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(s,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],d):(s=typeof globalThis<"u"?globalThis:s||self,d(s.UniverThreadComment={},s.UniverCore,s.rxjs))})(this,(function(s,d,M){"use strict";var q=Object.defineProperty;var K=(s,d,M)=>d in s?q(s,d,{enumerable:!0,configurable:!0,writable:!0,value:M}):s[d]=M;var u=(s,d,M)=>K(s,typeof d!="symbol"?d+"":d,M);var _;class I extends d.Disposable{constructor(){super();u(this,"_dataSource",null);u(this,"syncUpdateMutationToColla",!0)}set dataSource(e){this._dataSource=e}get dataSource(){return this._dataSource}async getThreadComment(e,t,n){return this._dataSource?(await this._dataSource.listComments(e,t,[n]))[0]:null}async addComment(e){var t;return this._dataSource?this._dataSource.addComment(e):{...e,threadId:(t=e.threadId)!=null?t:e.id}}async updateComment(e){return this._dataSource?this._dataSource.updateComment(e):!0}async resolveComment(e){return this._dataSource?this._dataSource.resolveComment(e):!0}async deleteComment(e,t,n,o){return this._dataSource?this._dataSource.deleteComment(e,t,n,o):!0}async listThreadComments(e,t,n){return this.dataSource?this.dataSource.listComments(e,t,n):!1}saveToSnapshot(e,t){if(this._dataSource){const n={};return Object.keys(e).forEach(o=>{const a=e[o];n[o]=a.map(this.dataSource.saveCommentToSnapshot)}),n}return e}}const C=d.createIdentifier("univer.thread-comment.data-source-service");var W=Object.getOwnPropertyDescriptor,G=(c,m,e,t)=>{for(var n=t>1?void 0:t?W(m,e):m,o=c.length-1,a;o>=0;o--)(a=c[o])&&(n=a(n)||n);return n},N=(c,m)=>(e,t)=>m(e,t,c);s.ThreadCommentModel=class extends d.Disposable{constructor(e,t){super();u(this,"_commentsMap",new Map);u(this,"_threadMap",new Map);u(this,"_commentUpdate$",new M.Subject);u(this,"commentUpdate$",this._commentUpdate$.asObservable());u(this,"_tasks",[]);this._dataSourceService=e,this._lifecycleService=t,this.disposeWithMe(()=>{this._commentUpdate$.complete()}),this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe(n=>{const o=new Map;n===d.LifecycleStages.Rendered&&(this._tasks.forEach(({unitId:a,subUnitId:r,threadIds:i})=>{let h=o.get(a);h||(h=new Map,o.set(a,h));let l=h.get(r);l||(l=new Set,h.set(r,l));for(const p of i)l.add(p)}),this._tasks=[],o.forEach((a,r)=>{a.forEach((i,h)=>{this.syncThreadComments(r,h,Array.from(i))})}))}))}_ensureCommentMap(e,t){let n=this._commentsMap.get(e);n||(n=new Map,this._commentsMap.set(e,n));let o=n.get(t);return o||(o=new Map,n.set(t,o)),o}ensureMap(e,t){return this._ensureCommentMap(e,t)}_ensureThreadMap(e,t){let n=this._threadMap.get(e);n||(n=new Map,this._threadMap.set(e,n));let o=n.get(t);return o||(o=new Map,n.set(t,o)),o}_replaceComment(e,t,n){const o=this._ensureCommentMap(e,t),a=o.get(n.id);if(a){const{children:r,...i}=n,h={...i,ref:a.ref};o.set(n.id,h),r==null||r.forEach(l=>{o.set(l.id,{...l,ref:""})}),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"syncUpdate",payload:h}),!!n.resolved!=!!a.resolved&&this._commentUpdate$.next({unitId:e,subUnitId:t,type:"resolve",payload:{commentId:n.id,resolved:!!n.resolved}})}}async syncThreadComments(e,t,n){if(this._lifecycleService.stage<d.LifecycleStages.Rendered){this._tasks.push({unitId:e,subUnitId:t,threadIds:n});return}const o=this._ensureThreadMap(e,t),a=this._ensureCommentMap(e,t),r=await this._dataSourceService.listThreadComments(e,t,n);if(!r)return;const i=new Set(n);r.forEach(h=>{this._replaceComment(e,t,h),i.delete(h.threadId)}),i.forEach(h=>{o.delete(h),a.forEach((l,p)=>{l.threadId===h&&a.delete(p)})})}addComment(e,t,n,o){const a=this._ensureCommentMap(e,t),{parentId:r,children:i=[],...h}=n,l={...h,parentId:r===n.id?void 0:r};l.threadId||(l.threadId=l.parentId||l.id);const p=f=>{a.set(f.id,f),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"add",payload:f,isRoot:!f.parentId})};p(l);const H=this._ensureThreadMap(e,t);if(!l.parentId){H.set(l.threadId,l);for(const f of i)p(f)}return o&&this.syncThreadComments(e,t,[l.threadId]),!0}updateComment(e,t,n,o){const r=this._ensureCommentMap(e,t).get(n.commentId);return r&&(r.updated=!0,r.text=n.text,r.attachments=n.attachments,r.updateT=n.updateT,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"update",payload:n,silent:o})),!0}updateCommentRef(e,t,n,o){const r=this._ensureCommentMap(e,t).get(n.commentId);return r?(r.ref=n.ref,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"updateRef",payload:n,silent:o,threadId:r.threadId}),!0):!1}resolveComment(e,t,n,o){const r=this._ensureCommentMap(e,t).get(n);return r?(r.resolved=o,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"resolve",payload:{commentId:n,resolved:o}}),!0):!1}getComment(e,t,n){return this._ensureCommentMap(e,t).get(n)}getRootComment(e,t,n){return this._ensureThreadMap(e,t).get(n)}getThread(e,t,n){const o=this._ensureCommentMap(e,t),a=Array.from(o.values()).filter(l=>l.threadId===n);let r;const i=[],h=new Set;for(const l of a)l.parentId?i.push(l):r=l,h.add(l.personId);if(r)return{root:r,children:i,relativeUsers:h,unitId:e,subUnitId:t,threadId:n}}getCommentWithChildren(e,t,n){const o=this.getComment(e,t,n);if(o)return this.getThread(e,t,o.threadId)}_deleteComment(e,t,n){const o=this._ensureCommentMap(e,t),a=o.get(n);a&&(o.delete(n),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"delete",payload:{commentId:n,isRoot:!a.parentId,comment:a}}))}deleteThread(e,t,n){this._ensureThreadMap(e,t).delete(n),this._ensureCommentMap(e,t).forEach(r=>{r.threadId===n&&this._deleteComment(e,t,r.id)})}deleteComment(e,t,n){const a=this._ensureCommentMap(e,t).get(n);return a&&(a.parentId?this._deleteComment(e,t,n):this.deleteThread(e,t,a.threadId)),!0}deleteUnit(e){const t=this._commentsMap.get(e);t&&t.forEach((n,o)=>{n.forEach(a=>{this.deleteComment(e,o,a.id)})})}getUnit(e){const t=this._threadMap.get(e);if(!t)return[];const n=[];return t.forEach((o,a)=>{o.forEach((r,i)=>{const h=this.getThread(e,a,i);h&&n.push(h)})}),n}getAll(){const e=[];return this._commentsMap.forEach((t,n)=>{e.push({unitId:n,threads:this.getUnit(n)})}),e}},s.ThreadCommentModel=G([N(0,d.Inject(C)),N(1,d.Inject(d.LifecycleService))],s.ThreadCommentModel);const v={id:"thread-comment.mutation.add-comment",type:d.CommandType.MUTATION,handler(c,m,e){if(!m)return!1;const t=c.get(s.ThreadCommentModel),{unitId:n,subUnitId:o,comment:a,sync:r}=m,i=r||(e==null?void 0:e.fromChangeset)&&!a.parentId;return t.addComment(n,o,a,i)}},g={id:"thread-comment.mutation.update-comment",type:d.CommandType.MUTATION,handler(c,m){if(!m)return!1;const e=c.get(s.ThreadCommentModel),{unitId:t,subUnitId:n,payload:o,silent:a}=m;return e.updateComment(t,n,o,a)}},D={id:"thread-comment.mutation.update-comment-ref",type:d.CommandType.MUTATION,handler(c,m){if(!m)return!1;const e=c.get(s.ThreadCommentModel),{unitId:t,subUnitId:n,payload:o,silent:a}=m;return e.updateCommentRef(t,n,o,a)}},S={id:"thread-comment.mutation.resolve-comment",type:d.CommandType.MUTATION,handler(c,m){if(!m)return!1;const e=c.get(s.ThreadCommentModel),{unitId:t,subUnitId:n,resolved:o,commentId:a}=m;return e.resolveComment(t,n,a,o)}},T={id:"thread-comment.mutation.delete-comment",type:d.CommandType.MUTATION,handler(c,m){if(!m)return!1;const e=c.get(s.ThreadCommentModel),{unitId:t,subUnitId:n,commentId:o}=m;return e.deleteComment(t,n,o)}},O={id:"thread-comment.command.add-comment",type:d.CommandType.COMMAND,async handler(c,m){if(!m)return!1;const e=c.get(d.ICommandService),t=c.get(C),{comment:n}=m,o=await t.addComment(n),a=t.syncUpdateMutationToColla,r=!n.parentId,i={id:v.id,params:{...m,comment:o}};return r?await e.executeCommand(i.id,i.params):e.executeCommand(i.id,i.params,{onlyLocal:!a})}},R={id:"thread-comment.command.update-comment",type:d.CommandType.COMMAND,async handler(c,m){if(!m)return!1;const{unitId:e,subUnitId:t,payload:n}=m,o=c.get(d.ICommandService),a=c.get(s.ThreadCommentModel),r=c.get(C),i=r.syncUpdateMutationToColla,h=a.getComment(e,t,n.commentId);if(!h)return!1;const{children:l,...p}=h;if(!await r.updateComment({...p,...n}))return!1;const f={id:g.id,params:m};return o.executeCommand(f.id,f.params,{onlyLocal:!i}),!0}},w={id:"thread-comment.command.resolve-comment",type:d.CommandType.COMMAND,async handler(c,m){if(!m)return!1;const{unitId:e,subUnitId:t,resolved:n,commentId:o}=m,a=c.get(C),i=c.get(s.ThreadCommentModel).getComment(e,t,o),h=a.syncUpdateMutationToColla;return!i||!await a.resolveComment({...i,resolved:n})?!1:c.get(d.ICommandService).executeCommand(S.id,m,{onlyLocal:!h})}},A={id:"thread-comment.command.delete-comment",type:d.CommandType.COMMAND,async handler(c,m){if(!m)return!1;const e=c.get(s.ThreadCommentModel),t=c.get(C),n=c.get(d.ICommandService),{unitId:o,subUnitId:a,commentId:r}=m,i=t.syncUpdateMutationToColla,h=e.getComment(o,a,r);if(!h||!await t.deleteComment(o,a,h.threadId,r))return!1;const l={id:T.id,params:m};return n.executeCommand(l.id,l.params,{onlyLocal:!i})}},P={id:"thread-comment.command.delete-comment-tree",type:d.CommandType.COMMAND,async handler(c,m){if(!m)return!1;const e=c.get(s.ThreadCommentModel),t=c.get(d.ICommandService),n=c.get(C),{unitId:o,subUnitId:a,commentId:r}=m,i=e.getCommentWithChildren(o,a,r);return!i||!await n.deleteComment(o,a,i.root.threadId,r)?!1:await t.executeCommand(T.id,{unitId:o,subUnitId:a,commentId:i.root.id})}};function k(c){return d.dayjs(c).format("YYYY/MM/DD HH:mm")}const y="UNIVER_THREAD_COMMENT_PLUGIN";var J=Object.getOwnPropertyDescriptor,V=(c,m,e,t)=>{for(var n=t>1?void 0:t?J(m,e):m,o=c.length-1,a;o>=0;o--)(a=c[o])&&(n=a(n)||n);return n},U=(c,m)=>(e,t)=>m(e,t,c);const j=`SHEET_${y}`;s.ThreadCommentResourceController=class extends d.Disposable{constructor(m,e,t){super(),this._resourceManagerService=m,this._threadCommentModel=e,this._threadCommentDataSourceService=t,this._initSnapshot()}_initSnapshot(){const m=t=>{const n=this._threadCommentModel.getUnit(t),o={};return n?(n.forEach(a=>{var i;const r=(i=o[a.subUnitId])!=null?i:[];r.push({...a.root,children:a.children}),o[a.subUnitId]=r}),JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(o,t))):""},e=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:j,businesses:[d.UniverInstanceType.UNIVER_SHEET,d.UniverInstanceType.UNIVER_DOC],toJson:t=>m(t),parseJson:t=>e(t),onUnLoad:t=>{this._threadCommentModel.deleteUnit(t)},onLoad:async(t,n)=>{Object.keys(n).forEach(o=>{const a=n[o];a.forEach(r=>{this._threadCommentModel.addComment(t,o,r)}),this._threadCommentModel.syncThreadComments(t,o,a.map(r=>r.threadId))})}}))}},s.ThreadCommentResourceController=V([U(0,d.IResourceManagerService),U(1,d.Inject(s.ThreadCommentModel)),U(2,C)],s.ThreadCommentResourceController);const $={name:"@univerjs/thread-comment",version:"0.16.1-insiders.20260311-074e8ca"},b="thread-comment.config",L={};var Y=Object.getOwnPropertyDescriptor,B=(c,m,e,t)=>{for(var n=t>1?void 0:t?Y(m,e):m,o=c.length-1,a;o>=0;o--)(a=c[o])&&(n=a(n)||n);return n},E=(c,m)=>(e,t)=>m(e,t,c);s.UniverThreadCommentPlugin=(_=class extends d.Plugin{constructor(m=L,e,t,n){super(),this._config=m,this._injector=e,this._commandService=t,this._configService=n;const{...o}=d.merge({},L,this._config);this._configService.setConfig(b,o)}onStarting(){var m;d.mergeOverrideWithDependencies([[C,{useClass:I}],[s.ThreadCommentModel],[s.ThreadCommentResourceController]],(m=this._config)==null?void 0:m.overrides).forEach(e=>{this._injector.add(e)}),[O,R,A,w,P,v,g,D,T,S].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(s.ThreadCommentResourceController)}},u(_,"pluginName",y),u(_,"packageName",$.name),u(_,"version",$.version),u(_,"type",d.UniverInstanceType.UNIVER_UNKNOWN),_),s.UniverThreadCommentPlugin=B([E(1,d.Inject(d.Injector)),E(2,d.ICommandService),E(3,d.IConfigService)],s.UniverThreadCommentPlugin),s.AddCommentCommand=O,s.AddCommentMutation=v,s.DeleteCommentCommand=A,s.DeleteCommentMutation=T,s.DeleteCommentTreeCommand=P,s.IThreadCommentDataSourceService=C,s.ResolveCommentCommand=w,s.ResolveCommentMutation=S,s.SHEET_UNIVER_THREAD_COMMENT_PLUGIN=j,s.TC_PLUGIN_NAME=y,s.ThreadCommentDataSourceService=I,s.UpdateCommentCommand=R,s.UpdateCommentMutation=g,s.UpdateCommentRefMutation=D,s.getDT=k,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/thread-comment",
3
- "version": "0.16.0",
3
+ "version": "0.16.1-insiders.20260311-074e8ca",
4
4
  "private": false,
5
5
  "description": "Univer thread comment core plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -46,14 +46,14 @@
46
46
  "rxjs": ">=7.0.0"
47
47
  },
48
48
  "dependencies": {
49
- "@univerjs/core": "0.16.0"
49
+ "@univerjs/core": "0.16.1-insiders.20260311-074e8ca"
50
50
  },
51
51
  "devDependencies": {
52
52
  "rxjs": "^7.8.2",
53
53
  "typescript": "^5.9.3",
54
54
  "vite": "^7.3.1",
55
55
  "vitest": "^4.0.18",
56
- "@univerjs-infra/shared": "0.16.0"
56
+ "@univerjs-infra/shared": "0.16.1"
57
57
  },
58
58
  "scripts": {
59
59
  "test": "vitest run",
package/LICENSE DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS