@mescius/js-collaboration-presence 18.0.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 +18 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +1 -0
- package/package.json +32 -0
- package/wrapper.mjs +7 -0
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# SpreadJS Collaboration Plugin
|
|
2
|
+
|
|
3
|
+
The js collaboration presence package is one of the plugins for [SpreadJS](https://developer.mescius.com/spreadjs).
|
|
4
|
+
|
|
5
|
+
Extends SpreadJS with support for collaboration
|
|
6
|
+
|
|
7
|
+
For a detailed listing of SpreadJS sub-libraries and plug-ins, please see [Using SpreadJS Libraries](https://developer.mescius.com/spreadjs/docs/getstarted/modules).
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
```sh
|
|
11
|
+
npm install @mescius/js-collaboration-presence
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Getting more help
|
|
15
|
+
Visit the SpreadJS home page to get more info about the library:
|
|
16
|
+
[https://developer.mescius.com/spreadjs](https://developer.mescius.com/spreadjs)
|
|
17
|
+
|
|
18
|
+
You can ask any question about SpreadJS using the [SpreadJS Forum](https://developer.mescius.com/forums/spreadjs).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IFeature } from "@mescius/js-collaboration";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Presence feature
|
|
5
|
+
* @example
|
|
6
|
+
* const httpServer = createServer();
|
|
7
|
+
* const server = new Server({ httpServer });
|
|
8
|
+
* server.useFeature(OT.documentFeature());
|
|
9
|
+
* server.useFeature(presenceFeature());
|
|
10
|
+
*/
|
|
11
|
+
export declare function presenceFeature(): IFeature;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,s){if("object"==typeof exports&&"object"==typeof module)module.exports=s();else if("function"==typeof define&&define.amd)define([],s);else{var r=s();for(var t in r)("object"==typeof exports?exports:e)[t]=r[t]}}(this,(()=>(()=>{"use strict";var e={658:(e,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.PresenceManager=void 0,s.PresenceManager=class{constructor(){this._presences=new Map}get presences(){return this._presences}getPresence(e){return this._presences.get(e)}setPresence(e,s){this._presences.set(e,s)}removePresence(e){this._presences.delete(e)}}},17:(e,s,r)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Presence=void 0;const t=r(773);s.Presence=class{constructor(){this.presences={}}messageHandler(e,s){if("string"!=typeof s)return;const r=JSON.parse(s);switch(r.a){case t.Actions.update:this._handleUpdateMsg(e,r);break;case t.Actions.remove:this._handleRemoveMsg(e);break;case t.Actions.subscribe:this._handleSubscribeMsg(e)}}disconnect(e){this._handleRemoveMsg(e)}_handleUpdateMsg(e,s){if(!("presence"in s))return void this._handleRemoveMsg(e);const r=s.presence,n=(0,t.createPresences)([e.id],[r]);this._has(e.id)?(this.presences[e.id]=r,this._broadCast(e,{a:t.Actions.update,presences:n})):(this.presences[e.id]=r,this._broadCast(e,{a:t.Actions.add,presences:n}))}_handleSubscribeMsg(e){this._send(e,{a:t.Actions.subscribe,presences:this.presences})}_handleRemoveMsg(e){this._has(e.id)&&(delete this.presences[e.id],this._broadCast(e,{a:t.Actions.remove,presencesIds:[e.id]}))}_send(e,s){e.send(JSON.stringify(s),t.PRESENCE_MESSAGE_TYPE)}_broadCast(e,s){e.broadcast(JSON.stringify(s),t.PRESENCE_MESSAGE_TYPE,!0)}_has(e){return e in this.presences}}},773:(e,s)=>{var r;Object.defineProperty(s,"__esModule",{value:!0}),s.PRESENCE_MESSAGE_TYPE=s.Actions=void 0,s.createPresences=function(e,s){const r={};for(let t=0;t<e.length;t++)r[e[t]]=s[t];return r},function(e){e.subscribe="s",e.unsubscribe="u",e.update="d",e.add="a",e.remove="r"}(r||(s.Actions=r={})),s.PRESENCE_MESSAGE_TYPE="p"}},s={};function r(t){var n=s[t];if(void 0!==n)return n.exports;var o=s[t]={exports:{}};return e[t](o,o.exports,r),o.exports}var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.presenceFeature=function(e){return e=null!=e?e:new s.PresenceManager,{middlewares:{message:async(s,r)=>{var t;if(s.type!==o.PRESENCE_MESSAGE_TYPE)return await r();null===(t=e.getPresence(s.roomId))||void 0===t||t.messageHandler(s.connection,s.data)}},hooks:{createRoom:s=>{const r=new n.Presence;e.setPresence(s.roomId,r)},destroyRoom:s=>{e.removePresence(s.roomId)},leaveRoom:s=>{var r;null===(r=e.getPresence(s.roomId))||void 0===r||r.disconnect(s.connection)}}}};const s=r(658),n=r(17),o=r(773)})(),t})()));
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mescius/js-collaboration-presence",
|
|
3
|
+
"version": "18.0.0",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"import": "./wrapper.mjs",
|
|
9
|
+
"require": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"js-collaboration-presence",
|
|
13
|
+
"js-collaboration",
|
|
14
|
+
"collaboration",
|
|
15
|
+
"presence",
|
|
16
|
+
"spread",
|
|
17
|
+
"sheet",
|
|
18
|
+
"javascript",
|
|
19
|
+
"excel",
|
|
20
|
+
"spreadjs"
|
|
21
|
+
],
|
|
22
|
+
"author": {
|
|
23
|
+
"email": "us.sales@mescius.com",
|
|
24
|
+
"name": "MESCIUS inc"
|
|
25
|
+
},
|
|
26
|
+
"license": "Commercial",
|
|
27
|
+
"description": "SpreadJS Collaboration plugin",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@mescius/js-collaboration": "18.0.0"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://developer.mescius.com/spreadjs"
|
|
32
|
+
}
|