@univerjs-pro/collaboration-comment-database-memory 1.0.0-insiders.20260805-b15e7f3 → 1.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/README.zh-CN.md +24 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +4 -7
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @univerjs-pro/collaboration-comment-database-memory
|
|
2
|
+
|
|
3
|
+
English | [简体中文](./README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
An in-process `ICommentDatabaseAdapter` for tests, local development, and temporary Thread Comment Services.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add \
|
|
9
|
+
@univerjs-pro/collaboration-comment-service \
|
|
10
|
+
@univerjs-pro/collaboration-comment-database-memory
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
const database = new MemoryCommentDatabaseAdapter();
|
|
15
|
+
const commentService = new UniverCommentService({ database });
|
|
16
|
+
|
|
17
|
+
await commentService.dispose();
|
|
18
|
+
await database.dispose();
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The Adapter serializes operations per Unit and implements the same concurrency-version checks as the SQLite Adapter.
|
|
22
|
+
|
|
23
|
+
All comments are lost when the process exits, and state is not shared between Node.js processes. Use SQLite or another persistent Adapter for persistent production data.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @univerjs-pro/collaboration-comment-database-memory
|
|
2
|
+
|
|
3
|
+
[English](./README.md) | [简体中文](./README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
进程内 `ICommentDatabaseAdapter`,适合测试、本地开发和临时 Thread Comment Service。
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add \
|
|
9
|
+
@univerjs-pro/collaboration-comment-service \
|
|
10
|
+
@univerjs-pro/collaboration-comment-database-memory
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
const database = new MemoryCommentDatabaseAdapter();
|
|
15
|
+
const commentService = new UniverCommentService({ database });
|
|
16
|
+
|
|
17
|
+
await commentService.dispose();
|
|
18
|
+
await database.dispose();
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Adapter 按 Unit 串行操作,并实现与 SQLite Adapter 相同的并发版本检查。
|
|
22
|
+
|
|
23
|
+
进程退出后所有评论丢失,多个 Node.js 进程也不共享状态。持久化生产数据应使用 SQLite
|
|
24
|
+
或其他持久化 Adapter。
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object['defineProperty'](exports,Symbol['toStringTag'],{'value':'Module'});let e=require('node:crypto'),t=require('@univerjs/protocol');var n=class{['_units']=new Map();['_queues']=new Map();['_calls']=new Set();['_state']='running';['_disposePromise'];['createRoot'](
|
|
1
|
+
Object['defineProperty'](exports,Symbol['toStringTag'],{'value':'Module'});let e=require('node:crypto'),t=require('@univerjs/protocol');var n=class{['_units']=new Map();['_queues']=new Map();['_calls']=new Set();['_state']='running';['_disposePromise'];['createRoot'](_0x5be4b8,_0x4e930a){return this['_call'](()=>this['_enqueue'](_0x5be4b8['unitID'],()=>{let _0x455210=this['_unit'](_0x5be4b8['unitID']);if(_0x455210['has'](_0x5be4b8['threadID']))return{'status':'duplicate'};let _0x40be39=Date['now'](),_0x1f3e2f={..._0x5be4b8,'replyID':_0x5be4b8['threadID'],'mentions':[..._0x5be4b8['mentions']],'solved':t['CommentSolvedStatus']['OpenOrReOpen'],'createdAt':_0x40be39,'updatedAt':_0x40be39,'generation':(0x0,e['randomUUID'])()};return _0x455210['set'](_0x1f3e2f['replyID'],_0x1f3e2f),{'status':'created','record':r(_0x1f3e2f)};}));}['createReply'](_0x121c7f,_0x58344e){return this['_call'](()=>this['_enqueue'](_0x121c7f['unitID'],()=>{let _0x5e17ff=this['_unit'](_0x121c7f['unitID']);if(_0x5e17ff['has'](_0x121c7f['replyID']))return{'status':'duplicate'};let _0x46990e=_0x5e17ff['get'](_0x121c7f['threadID']);if(!_0x46990e||_0x46990e['replyID']!==_0x46990e['threadID'])return{'status':'not-found'};if(_0x46990e['solved']!==t['CommentSolvedStatus']['OpenOrReOpen'])return{'status':'closed'};let _0x5b826c=Date['now'](),_0x16f521={..._0x121c7f,'mentions':[..._0x121c7f['mentions']],'solved':_0x46990e['solved'],'createdAt':_0x5b826c,'updatedAt':_0x5b826c,'generation':(0x0,e['randomUUID'])()};return _0x5e17ff['set'](_0x16f521['replyID'],_0x16f521),{'status':'created','record':r(_0x16f521)};}));}['getComment'](_0x2c4e34,_0x43f220){return this['_call'](()=>this['_enqueue'](_0x2c4e34['unitID'],()=>{let _0xf41f73=this['_units']['get'](_0x2c4e34['unitID'])?.['get'](_0x2c4e34['replyID']);return _0xf41f73?.['threadID']===_0x2c4e34['threadID']?r(_0xf41f73):null;}));}['listThreads'](_0x2ff58d,_0x25660a){return this['_call'](()=>this['_enqueue'](_0x2ff58d['unitID'],()=>{let _0x4901d4=new Set(_0x2ff58d['threadIDs']);return[...this['_units']['get'](_0x2ff58d['unitID'])?.['values']()??[]]['filter'](_0x50501d=>_0x4901d4['size']===0x0||_0x4901d4['has'](_0x50501d['threadID']))['sort'](i)['map'](r);}));}['editComment'](_0x2189df,_0x45c591){return this['_call'](()=>this['_enqueue'](_0x2189df['unitID'],()=>{let _0x3b6bf3=this['_units']['get'](_0x2189df['unitID']),_0x5cec17=_0x3b6bf3?.['get'](_0x2189df['replyID']),_0x240295=_0x3b6bf3?.['get'](_0x2189df['threadID']);if(!_0x5cec17||_0x5cec17['threadID']!==_0x2189df['threadID']||!_0x240295)return{'status':'not-found'};if(_0x240295['solved']!==t['CommentSolvedStatus']['OpenOrReOpen'])return{'status':'closed'};if(_0x5cec17['authorUserID']!==_0x2189df['expectedAuthorUserID'])return{'status':'author-mismatch'};if(_0x5cec17['content']===_0x2189df['content']&&a(_0x5cec17['mentions'],_0x2189df['mentions']))return{'status':'unchanged','record':r(_0x5cec17)};let _0x204e94={..._0x5cec17,'content':_0x2189df['content'],'mentions':[..._0x2189df['mentions']],'updatedAt':Math['max'](Date['now'](),_0x5cec17['updatedAt']+0x1)};return _0x3b6bf3['set'](_0x2189df['replyID'],_0x204e94),{'status':'edited','record':r(_0x204e94)};}));}['setThreadSolved'](_0x39844b,_0x215603){return this['_call'](()=>this['_enqueue'](_0x39844b['unitID'],()=>{let _0x1046a6=this['_units']['get'](_0x39844b['unitID']),_0x444df1=_0x1046a6?.['get'](_0x39844b['threadID']);return!_0x444df1||_0x444df1['replyID']!==_0x444df1['threadID']?{'status':'not-found'}:_0x444df1['solved']===_0x39844b['solved']?{'status':'unchanged'}:(_0x1046a6['set'](_0x39844b['threadID'],{..._0x444df1,'solved':_0x39844b['solved'],'updatedAt':Math['max'](Date['now'](),_0x444df1['updatedAt']+0x1)}),{'status':'updated'});}));}['deleteComment'](_0x276570,_0x41bad9){return this['_call'](()=>this['_enqueue'](_0x276570['unitID'],()=>{let _0x3d0617=this['_units']['get'](_0x276570['unitID']),_0x1225ce=_0x276570['replyID']??_0x276570['threadID'],_0x565221=_0x3d0617?.['get'](_0x1225ce);if(!_0x565221||_0x565221['threadID']!==_0x276570['threadID'])return{'status':'not-found'};if(_0x565221['generation']!==_0x276570['expectedGeneration'])return{'status':'generation-mismatch'};if(_0x276570['replyID']===void 0x0){for(let [_0x3c4892,_0x4c1c1f]of _0x3d0617)_0x4c1c1f['threadID']===_0x276570['threadID']&&_0x3d0617['delete'](_0x3c4892);}else _0x3d0617['delete'](_0x276570['replyID']);return _0x3d0617['size']===0x0&&this['_units']['delete'](_0x276570['unitID']),{'status':'deleted'};}));}['dispose'](){return this['_disposePromise']?this['_disposePromise']:(this['_state']='disposing',this['_disposePromise']=((async()=>{await Promise['allSettled']([...this['_calls']]),this['_queues']['clear'](),this['_state']='disposed';})()),this['_disposePromise']);}['_unit'](_0x2d7088){let _0x3d1ae6=this['_units']['get'](_0x2d7088);if(_0x3d1ae6)return _0x3d1ae6;let _0x15a541=new Map();return this['_units']['set'](_0x2d7088,_0x15a541),_0x15a541;}['_enqueue'](_0x5607ab,_0x5a284b){let _0x7b0e44=(this['_queues']['get'](_0x5607ab)??Promise['resolve']())['catch'](()=>void 0x0)['then'](_0x5a284b),_0x186f61=_0x7b0e44['then'](()=>void 0x0,()=>void 0x0);return this['_queues']['set'](_0x5607ab,_0x186f61),_0x186f61['finally'](()=>{this['_queues']['get'](_0x5607ab)===_0x186f61&&this['_queues']['delete'](_0x5607ab);}),_0x7b0e44;}['_call'](_0x428204){if(this['_state']!=='running')return Promise['reject'](Error('Memory\x20Comment\x20Database\x20Adapter\x20is\x20'+this['_state']));let _0x30eeab=_0x428204();return this['_calls']['add'](_0x30eeab),_0x30eeab['finally'](()=>this['_calls']['delete'](_0x30eeab))['catch'](()=>void 0x0),_0x30eeab;}};function r(_0xb5fdd){return{..._0xb5fdd,'mentions':[..._0xb5fdd['mentions']]};}function i(_0x590fbc,_0x44c578){let _0x110e60=_0x590fbc['threadID']['localeCompare'](_0x44c578['threadID']);return _0x110e60===0x0?_0x590fbc['replyID']===_0x590fbc['threadID']?-0x1:_0x44c578['replyID']===_0x44c578['threadID']?0x1:_0x590fbc['createdAt']-_0x44c578['createdAt']||_0x590fbc['replyID']['localeCompare'](_0x44c578['replyID']):_0x110e60;}function a(_0x539616,_0x12a8c4){return _0x539616['length']===_0x12a8c4['length']&&_0x539616['every']((_0x31fc30,_0x4f7068)=>_0x31fc30===_0x12a8c4[_0x4f7068]);}exports['MemoryCommentDatabaseAdapter']=n;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x3b7196,_0x38ea0f){const _0x43757f=_0x7e60,_0x92411=_0x3b7196();while(!![]){try{const _0x277aaf=parseInt(_0x43757f(0xb5))/0x1+-parseInt(_0x43757f(0xb9))/0x2+-parseInt(_0x43757f(0xb8))/0x3+parseInt(_0x43757f(0xba))/0x4*(parseInt(_0x43757f(0xbd))/0x5)+parseInt(_0x43757f(0xbc))/0x6*(-parseInt(_0x43757f(0xbb))/0x7)+parseInt(_0x43757f(0xb7))/0x8+parseInt(_0x43757f(0xb6))/0x9;if(_0x277aaf===_0x38ea0f)break;else _0x92411['push'](_0x92411['shift']());}catch(_0xb681f5){_0x92411['push'](_0x92411['shift']());}}}(_0x2d32,0x766a5));function _0x2d32(){const _0x5567c4=['235998eMIxqY','150kfYPIG','3018485Kbcbgp','674898xaNECG','9804996tAdXDA','2149688mJnFse','1511349zLidws','1610176hsxqQr','4YjRrwO'];_0x2d32=function(){return _0x5567c4;};return _0x2d32();}import _0x50741a from'./index.cjs';function _0x7e60(_0x27e8d6,_0x4b0bc0){_0x27e8d6=_0x27e8d6-0xb5;const _0x2d32eb=_0x2d32();let _0x7e604c=_0x2d32eb[_0x27e8d6];return _0x7e604c;}const facadeExport0=_0x50741a['MemoryCommentDatabaseAdapter'];export{facadeExport0 as MemoryCommentDatabaseAdapter};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs-pro/collaboration-comment-database-memory",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-
|
|
4
|
+
"version": "1.0.0-rc.0",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -16,10 +16,7 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@univerjs-pro/collaboration-comment-service": "1.0.0-
|
|
20
|
-
"@univerjs/protocol": "1.0.0-
|
|
21
|
-
},
|
|
22
|
-
"publishConfig": {
|
|
23
|
-
"access": "public"
|
|
19
|
+
"@univerjs-pro/collaboration-comment-service": "1.0.0-rc.0",
|
|
20
|
+
"@univerjs/protocol": "1.0.0-rc.0"
|
|
24
21
|
}
|
|
25
|
-
}
|
|
22
|
+
}
|