Socket
Socket
Sign inDemoInstall

y-protocols

Package Overview
Dependencies
2
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

8

awareness.d.ts

@@ -32,2 +32,6 @@ export const outdatedTimeout: 30000;

/**
* @type {number}
*/
clientID: number;
/**
* Maps from client id to client state

@@ -68,4 +72,4 @@ * @type {Map<number, Object<string, any>>}

}
export function removeAwarenessStates(awareness: Awareness, clients: number[], origin: any): void;
export function encodeAwarenessUpdate(awareness: Awareness, clients: number[], states?: Map<number, {
export function removeAwarenessStates(awareness: Awareness, clients: Array<number>, origin: any): void;
export function encodeAwarenessUpdate(awareness: Awareness, clients: Array<number>, states?: Map<number, {
[x: string]: any;

@@ -72,0 +76,0 @@ }>): Uint8Array;

@@ -47,2 +47,6 @@ /**

/**
* @type {number}
*/
this.clientID = doc.clientID
/**
* Maps from client id to client state

@@ -58,3 +62,3 @@ * @type {Map<number, Object<string, any>>}

const now = time.getUnixTime()
if (this.getLocalState() !== null && (outdatedTimeout / 2 <= now - /** @type {{lastUpdated:number}} */ (this.meta.get(doc.clientID)).lastUpdated)) {
if (this.getLocalState() !== null && (outdatedTimeout / 2 <= now - /** @type {{lastUpdated:number}} */ (this.meta.get(this.clientID)).lastUpdated)) {
// renew local clock

@@ -68,3 +72,3 @@ this.setLocalState(this.getLocalState())

this.meta.forEach((meta, clientid) => {
if (clientid !== doc.clientID && outdatedTimeout <= now - meta.lastUpdated && this.states.has(clientid)) {
if (clientid !== this.clientID && outdatedTimeout <= now - meta.lastUpdated && this.states.has(clientid)) {
remove.push(clientid)

@@ -82,6 +86,10 @@ }

}
destroy () {
this.emit('destroy', [this])
this.setLocalState(null)
super.destroy()
clearInterval(this._checkInterval)
}
/**

@@ -91,4 +99,5 @@ * @return {Object<string,any>|null}

getLocalState () {
return this.states.get(this.doc.clientID) || null
return this.states.get(this.clientID) || null
}
/**

@@ -98,3 +107,3 @@ * @param {Object<string,any>|null} state

setLocalState (state) {
const clientID = this.doc.clientID
const clientID = this.clientID
const currLocalMeta = this.meta.get(clientID)

@@ -133,2 +142,3 @@ const clock = currLocalMeta === undefined ? 0 : currLocalMeta.clock + 1

}
/**

@@ -145,2 +155,3 @@ * @param {string} field

}
/**

@@ -168,3 +179,3 @@ * @return {Map<number,Object<string,any>>}

awareness.states.delete(clientID)
if (clientID === awareness.doc.clientID) {
if (clientID === awareness.clientID) {
const curMeta = /** @type {MetaClientState} */ (awareness.meta.get(clientID))

@@ -255,3 +266,3 @@ awareness.meta.set(clientID, {

// never let a remote client remove this local state
if (clientID === awareness.doc.clientID && awareness.getLocalState() != null) {
if (clientID === awareness.clientID && awareness.getLocalState() != null) {
// remote client removed the local state. Do not remote state. Broadcast a message indicating

@@ -258,0 +269,0 @@ // that this client still exists by increasing the clock

{
"name": "y-protocols",
"version": "1.0.1",
"version": "1.0.2",
"description": "Yjs encoding protocols",

@@ -46,10 +46,12 @@ "type": "module",

"dependencies": {
"lib0": "^0.2.28"
"lib0": "^0.2.35"
},
"devDependencies": {
"concurrently": "^5.2.0",
"rollup": "^1.29.0",
"concurrently": "^5.3.0",
"rollup": "^2.30.0",
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.1",
"standard": "^12.0.1",
"typescript": "^3.8.3",
"yjs": "^13.0.4"
"typescript": "^3.9.7",
"yjs": "^13.4.9"
},

@@ -56,0 +58,0 @@ "peerDependenies": {

@@ -39,2 +39,4 @@ # Yjs Protocols

<dl>
<b><code>clientID:number</code></b>
<dd>A unique identifier that identifies this client.</dd>
<b><code>getLocalState():Object&lt;string,any&gt;|null</code></b>

@@ -41,0 +43,0 @@ <dd>Get the local awareness state.</dd>

@@ -5,6 +5,6 @@ /**

/**
* Core Yjs defines three message types:
* Core Yjs defines two message types:
* • YjsSyncStep1: Includes the State Set of the sending client. When received, the client should reply with YjsSyncStep2.
* • YjsSyncStep2: Includes all missing structs and the complete delete set. When received, the the client is assured that
* it received all information from the remote client.
* • YjsSyncStep2: Includes all missing structs and the complete delete set. When received, the client is assured that it
* received all information from the remote client.
*

@@ -11,0 +11,0 @@ * In a peer-to-peer network, you may want to introduce a SyncDone message type. Both parties should initiate the connection

@@ -14,6 +14,6 @@ /**

/**
* Core Yjs defines three message types:
* Core Yjs defines two message types:
* • YjsSyncStep1: Includes the State Set of the sending client. When received, the client should reply with YjsSyncStep2.
* • YjsSyncStep2: Includes all missing structs and the complete delete set. When received, the the client is assured that
* it received all information from the remote client.
* • YjsSyncStep2: Includes all missing structs and the complete delete set. When received, the client is assured that it
* received all information from the remote client.
*

@@ -20,0 +20,0 @@ * In a peer-to-peer network, you may want to introduce a SyncDone message type. Both parties should initiate the connection

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc