New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

document-process-manager

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

document-process-manager - npm Package Compare versions

Comparing version 1.1.6 to 1.1.7

65

development/sockets/socket/index.js
import { URL } from 'node:url'
import { Buffer } from 'node:buffer'
import WebSocket, { WebSocketServer } from 'ws'
import { WebSocketServer } from 'ws'
import MessageAdapter from './messageAdapter/index.js'

@@ -9,11 +9,6 @@ export default class Socket extends EventTarget {

#webSocketServer
#webSocket
#_webSocket
#active = false
#messageAdapters
#url
#_boundConnection
#boundOpen
#boundClose
#boundError
#boundMessage
constructor($settings, $sockets) {

@@ -24,10 +19,5 @@ super()

this.active = this.#settings.active
this.#boundOpen = this.#open.bind(this)
this.#boundClose = this.#close.bind(this)
this.#boundError = this.#error.bind(this)
this.#boundMessage = this.#message.bind(this)
}
get active() { return this.#active }
set active($active) {
if(this.#active === $active) { return }
if($active === true) {

@@ -37,3 +27,3 @@ this.webSocketServer

else if($active === false) {
this.webSocketServer.close()
this.webSocketServer?.close()
this.#webSocketServer = undefined

@@ -65,26 +55,25 @@ this.#webSocket = undefined

})
this.#webSocketServer.on('connection', this.#boundConnection)
this.#webSocketServer.on('connection', this.#websocketServerConnection.bind(this))
this.#webSocketServer.on('close', this.#websocketServerClose.bind(this))
this.#webSocketServer.on('error', this.#websocketServerError.bind(this))
return this.#webSocketServer
}
get webSocket() { return this.#webSocket }
set webSocket($webSocket) {
if(this.#webSocket !== undefined) return
this.#webSocket = $webSocket
this.#webSocket.on('open', this.#boundOpen)
this.#webSocket.on('close', this.#boundClose)
this.#webSocket.on('error', this.#boundError)
this.#webSocket.on('message', this.#boundMessage)
get #webSocket() { return this.#_webSocket }
set #webSocket($webSocket) {
if($webSocket === undefined) { this.#_webSocket = undefined }
else {
this.#_webSocket = $webSocket
this.#_webSocket.on('message', this.#websocketMessage.bind(this))
this.#_webSocket.on('error', this.#websocketError.bind(this))
this.#_webSocket.on('open', this.#websocketOpen.bind(this))
this.#_webSocket.on('close', this.#websocketClose.bind(this))
}
}
get #boundConnection() {
if(this.#_boundConnection !== undefined) { return this.#_boundConnection }
this.#_boundConnection = this.#connection.bind(this)
return this.#_boundConnection
}
#connection($ws) {
this.webSocket = $ws
}
#open($event) { console.log("#open", $event) }
#close($event) { console.log("#close", $event) }
#error() { console.error("#error", ...arguments) }
#message($data, $isBinary) {
#websocketServerConnection($ws) { this.#webSocket = $ws }
#websocketServerClose() { this.#webSocket = undefined }
#websocketServerError($error) { console.error($error) }
#websocketOpen() {}
#websocketClose() {}
#websocketError($error) { console.error($error) }
#websocketMessage($data, $isBinary) {
iterateAdapters:

@@ -96,3 +85,5 @@ for(const [

const message = $messageAdapter.message($data, $isBinary)
return message(this.webSocket, $data, $isBinary)
const { type, detail } = message(this.#webSocket, $data, $isBinary)
const messageEvent = new CustomEvent(type, { detail })
this.dispatchEvent(messageEvent)
}

@@ -106,3 +97,5 @@ catch($err) { /* console.log($err) */ }

for(const [$adapterName, $adapter] of this.#settings.messageAdapters) {
const adapter = new MessageAdapter($adapter, this)
let adapter
if($adapter instanceof MessageAdapter) { adapter = adapter }
else { adapter = new MessageAdapter($adapter, this) }
messageAdapters.push([$adapterName, adapter])

@@ -109,0 +102,0 @@ }

@@ -5,3 +5,3 @@ {

"description": "Document Process Manager (DPM)",
"version": "1.1.6",
"version": "1.1.7",
"license": "ISC",

@@ -8,0 +8,0 @@ "type": "module",

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