Socket
Socket
Sign inDemoInstall

y-protocols

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

y-protocols - npm Package Compare versions

Comparing version 0.2.3 to 1.0.0

awareness.test.d.ts

30

awareness.js

@@ -10,2 +10,3 @@ /**

import { Observable } from 'lib0/observable.js'
import * as f from 'lib0/function.js'
import * as Y from 'yjs' // eslint-disable-line

@@ -95,2 +96,3 @@

const clock = currLocalMeta === undefined ? 0 : currLocalMeta.clock + 1
const prevState = this.states.get(clientID)
if (state === null) {

@@ -107,11 +109,20 @@ this.states.delete(clientID)

const updated = []
const filteredUpdated = []
const removed = []
if (state === null) {
removed.push(clientID)
} else if (currLocalMeta === undefined) {
added.push(clientID)
} else if (prevState == null) {
if (state != null) {
added.push(clientID)
}
} else {
updated.push(clientID)
if (!f.equalityDeep(prevState, state)) {
filteredUpdated.push(clientID)
}
}
this.emit('change', [{ added, updated, removed }, 'local'])
if (added.length > 0 || filteredUpdated.length > 0 || removed.length > 0) {
this.emit('change', [{ added, updated: filteredUpdated, removed }, 'local'])
}
this.emit('update', [{ added, updated, removed }, 'local'])
}

@@ -163,2 +174,3 @@ /**

awareness.emit('change', [{ added: [], updated: [], removed }, origin])
awareness.emit('update', [{ added: [], updated: [], removed }, origin])
}

@@ -197,2 +209,3 @@ }

const updated = []
const filteredUpdated = []
const removed = []

@@ -205,2 +218,3 @@ const len = decoding.readVarUint(decoder)

const clientMeta = awareness.meta.get(clientID)
const prevState = awareness.states.get(clientID)
const currClock = clientMeta === undefined ? 0 : clientMeta.clock

@@ -229,2 +243,5 @@ if (currClock < clock || (currClock === clock && state === null && awareness.states.has(clientID))) {

} else if (state !== null) {
if (!f.equalityDeep(state, prevState)) {
filteredUpdated.push(clientID)
}
updated.push(clientID)

@@ -234,4 +251,9 @@ }

}
if (added.length > 0 || filteredUpdated.length > 0 || removed.length > 0) {
awareness.emit('change', [{
added, updated: filteredUpdated, removed
}, origin])
}
if (added.length > 0 || updated.length > 0 || removed.length > 0) {
awareness.emit('change', [{
awareness.emit('update', [{
added, updated, removed

@@ -238,0 +260,0 @@ }, origin])

14

package.json
{
"name": "y-protocols",
"version": "0.2.3",
"version": "1.0.0",
"description": "Yjs encoding protocols",
"type": "module",
"funding": {
"type": "GitHub Sponsors ❤",
"url": "https://github.com/sponsors/dmonad"
},
"files": [

@@ -15,5 +19,6 @@ "dist/*",

"dist": "rm -rf dist && rollup -c",
"test": "npm run lint",
"test": "npm run lint && npm run dist && node dist/test.cjs",
"lint": "standard && tsc",
"types": "tsc --outDir .",
"debug": "rollup -c && concurrently 'rollup -wc' 'http-server -o test.html'",
"preversion": "npm run dist && npm run test && npm run types",

@@ -42,7 +47,6 @@ "postpublish": "npm run clean"

"dependencies": {
"lib0": "^0.2.20"
"lib0": "^0.2.28"
},
"devDependencies": {
"rollup": "^1.1.2",
"rollup-cli": "^1.0.9",
"rollup": "^1.29.0",
"standard": "^12.0.1",

@@ -49,0 +53,0 @@ "typescript": "^3.8.3",

@@ -48,3 +48,3 @@ # Yjs Protocols

<dd>
Only update a single field on the local awareness object. Does not do
Only update a single field on the local awareness object. Does not do
anything if the local state is not set.

@@ -62,4 +62,12 @@ </dd>

<dd>
Listen to remote and local changes on the awareness instance.
Listen to remote and local state changes on the awareness instance.
</dd>
<b><code>
on('update', ({ added: Array&lt;number&gt;, updated: Array&lt;number&gt;
removed: Array&lt;number&gt; }, [transactionOrigin:any]) => ..)
</code></b>
<dd>
Listen to remote and local awareness changes on the awareness instance.
This event is called even when the awarenes state does not change.
</dd>
</dl>

@@ -66,0 +74,0 @@

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc