bump dependencies, use esm, and use conditional imports from lib0 & y-protocols

This commit is contained in:
Kevin Jahns 2021-05-22 15:02:51 +02:00
parent 465d64b543
commit f6bd2c813d
7 changed files with 76 additions and 70 deletions

View file

@ -1,8 +1,8 @@
#!/usr/bin/env node
const ws = require('ws')
const http = require('http')
const map = require('lib0/dist/map.cjs')
import ws from 'ws'
import http from 'http'
import * as map from 'lib0/map'
const wsReadyStateConnecting = 0
const wsReadyStateOpen = 1

View file

@ -4,8 +4,8 @@ import * as Y from 'yjs'
import { WebrtcProvider } from '../src/y-webrtc.js'
const ydoc = new Y.Doc()
const provider = new WebrtcProvider('prosemirror', ydoc)
const yarray = ydoc.get('prosemirror', Y.XmlFragment)
const provider = new WebrtcProvider('webrtc-test', ydoc, { signaling: ['ws://localhost:4444'] })
const yarray = ydoc.getArray()
provider.on('synced', synced => {
// NOTE: This is only called when a different browser connects to this client

70
package-lock.json generated
View file

@ -105,9 +105,9 @@
}
},
"@types/simple-peer": {
"version": "9.6.1",
"resolved": "https://registry.npmjs.org/@types/simple-peer/-/simple-peer-9.6.1.tgz",
"integrity": "sha512-WdXxmHW+m0NaD5XPGlp5AB7raq+NUWX/+/aQvDcoOx0qiP78QmDdk015W29uoyvGhyiJCb9dZJuI2Oi39zGRfg==",
"version": "9.6.3",
"resolved": "https://registry.npmjs.org/@types/simple-peer/-/simple-peer-9.6.3.tgz",
"integrity": "sha512-zrXEBch9tF4NgkZDsGR3c1D0kq99M1bBCjzEyL0PVfEWzCIXrK64TuxRz3XKOx1B0KoEQ9kTs+AhMDuQaHy5RQ==",
"dev": true,
"requires": {
"@types/node": "*"
@ -506,9 +506,9 @@
"dev": true
},
"err-code": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz",
"integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA=="
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/err-code/-/err-code-3.0.1.tgz",
"integrity": "sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA=="
},
"error-ex": {
"version": "1.3.2",
@ -1391,9 +1391,9 @@
"dev": true
},
"isomorphic.js": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/isomorphic.js/-/isomorphic.js-0.1.5.tgz",
"integrity": "sha512-MkX5lLQApx/8IAIU31PKvpAZosnu2Jqcj1rM8TzxyA4CR96tv3SgMKQNTCxL58G7696Q57zd7ubHV/hTg+5fNA=="
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/isomorphic.js/-/isomorphic.js-0.2.4.tgz",
"integrity": "sha512-Y4NjZceAwaPXctwsHgNsmfuPxR8lJ3f8X7QTAkhltrX4oGIv+eTlgHLXn4tWysC9zGTi929gapnPp+8F8cg7nA=="
},
"jest-worker": {
"version": "24.9.0",
@ -1460,11 +1460,11 @@
}
},
"lib0": {
"version": "0.2.34",
"resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.34.tgz",
"integrity": "sha512-cqsVIMPgFlDtgQcpkt7HOY6W3sbYPIe3qxMnbRSwHTgiQancgm+TRDPx28mC6GUZ6lG6Nr0bIWf4Nog6dWUNUg==",
"version": "0.2.42",
"resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.42.tgz",
"integrity": "sha512-8BNM4MiokEKzMvSxTOC3gnCBisJH+jL67CnSnqzHv3jli3pUvGC8wz+0DQ2YvGr4wVQdb2R2uNNPw9LEpVvJ4Q==",
"requires": {
"isomorphic.js": "^0.1.3"
"isomorphic.js": "^0.2.4"
}
},
"load-json-file": {
@ -1961,9 +1961,9 @@
"dev": true
},
"queue-microtask": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.2.tgz",
"integrity": "sha512-dB15eXv3p2jDlbOiNLyMabYg1/sXvppd8DP2J3EOCQ0AkuSXCW2tP7mnVouVLJKgUMY6yP0kcQDVpLCN13h4Xg=="
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="
},
"randombytes": {
"version": "2.1.0",
@ -2252,15 +2252,15 @@
"dev": true
},
"simple-peer": {
"version": "9.9.3",
"resolved": "https://registry.npmjs.org/simple-peer/-/simple-peer-9.9.3.tgz",
"integrity": "sha512-T3wuv0UqBpDTV0x0pJPPsz4thy0tC0fTOHE4g9+AF43RUxxT+MWeXVtdQcK5Xuzv/XTVrB2NrGzdfO1IFBqOkw==",
"version": "9.11.0",
"resolved": "https://registry.npmjs.org/simple-peer/-/simple-peer-9.11.0.tgz",
"integrity": "sha512-qvdNu/dGMHBm2uQ7oLhQBMhYlrOZC1ywXNCH/i8I4etxR1vrjCnU6ZSQBptndB1gcakjo2+w4OHo7Sjza1SHxg==",
"requires": {
"buffer": "^6.0.2",
"debug": "^4.2.0",
"err-code": "^2.0.3",
"get-browser-rtc": "^1.0.2",
"queue-microtask": "^1.2.0",
"buffer": "^6.0.3",
"debug": "^4.3.1",
"err-code": "^3.0.1",
"get-browser-rtc": "^1.1.0",
"queue-microtask": "^1.2.3",
"randombytes": "^2.1.0",
"readable-stream": "^3.6.0"
},
@ -2544,9 +2544,9 @@
"dev": true
},
"typescript": {
"version": "3.9.7",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz",
"integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==",
"version": "3.9.9",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.9.tgz",
"integrity": "sha512-kdMjTiekY+z/ubJCATUPlRDl39vXYiMV9iyeMuEuXZh2we6zz80uovNN2WlAxmmdE/Z/YQe+EbOEXB5RHEED3w==",
"dev": true
},
"union": {
@ -2663,11 +2663,11 @@
"dev": true
},
"y-protocols": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/y-protocols/-/y-protocols-1.0.1.tgz",
"integrity": "sha512-QP3fCM7c2gGfUi2nqf8gspyO4VW23zv3kNqPNdD3wNxMbuNQenMyoDVZYEo12jzR4RQ3aaDfPK62Sf31SVOmfg==",
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/y-protocols/-/y-protocols-1.0.5.tgz",
"integrity": "sha512-Wil92b7cGk712lRHDqS4T90IczF6RkcvCwAD0A2OPg+adKmOe+nOiT/N2hvpQIWS3zfjmtL4CPaH5sIW1Hkm/A==",
"requires": {
"lib0": "^0.2.28"
"lib0": "^0.2.42"
}
},
"y18n": {
@ -2705,12 +2705,12 @@
}
},
"yjs": {
"version": "13.4.6",
"resolved": "https://registry.npmjs.org/yjs/-/yjs-13.4.6.tgz",
"integrity": "sha512-BBHviAh3RTgp5Us4SubcAyxXFaLQ/552DzR0z3YZT1/HZLCpJc57cf6X0ZuuCGs8RFkgISYrbIFMrZ1L1NTzPA==",
"version": "13.5.6",
"resolved": "https://registry.npmjs.org/yjs/-/yjs-13.5.6.tgz",
"integrity": "sha512-0ebPpLB/zizJbWaFUDRarWbXiXYD0OMDOCa8ZqkVVWQzeIoMRbmbNwB3suZ9YwD0bV4Su9RLn8M/bvGzIwX3hA==",
"dev": true,
"requires": {
"lib0": "^0.2.33"
"lib0": "^0.2.41"
}
}
}

View file

@ -2,14 +2,20 @@
"name": "y-webrtc",
"version": "10.1.8",
"description": "WebRTC provider for Yjs",
"type": "module",
"main": "./dist/y-webrtc.cjs",
"types": "./dist/src/y-webrtc.d.ts",
"module": "./src/y-webrtc.js",
"unpkg": "./src/y-webrtc.mjs",
"sideEffects": false,
"funding": {
"type": "GitHub Sponsors ❤",
"url": "https://github.com/sponsors/dmonad"
},
"exports": {
"import": "./src/y-webrtc.js",
"require": "./dist/y-webrtc.cjs"
},
"scripts": {
"clean": "rm -rf dist",
"start": "node ./bin/server.js",
@ -50,30 +56,30 @@
]
},
"dependencies": {
"lib0": "^0.2.34",
"simple-peer": "^9.9.3",
"y-protocols": "^1.0.1"
"lib0": "^0.2.42",
"simple-peer": "^9.11.0",
"y-protocols": "^1.0.5"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-node-resolve": "^7.1.3",
"@types/simple-peer": "^9.6.1",
"@types/simple-peer": "^9.6.3",
"concurrently": "^5.3.0",
"http-server": "^0.12.3",
"rollup": "^1.32.1",
"rollup-cli": "^1.0.9",
"rollup-plugin-terser": "^5.3.1",
"standard": "^14.3.4",
"typescript": "^3.9.7",
"yjs": "^13.4.6"
"typescript": "^3.9.9",
"yjs": "^13.5.6"
},
"peerDependenies": {
"yjs": "^13.4.6"
"yjs": "^13.5.6"
},
"optionalDependencies": {
"ws": "^7.2.0"
},
"engines": {
"node": ">=10"
"node": ">=12"
}
}

View file

@ -98,9 +98,9 @@ export default [
sourcemap: true,
paths: path => {
if (/^lib0\//.test(path)) {
return `lib0/dist${path.slice(4, -3)}.cjs`
return `lib0/dist${path.slice(4)}.cjs`
} else if (/^y-protocols\//.test(path)) {
return `y-protocols/dist${path.slice(11, -3)}.cjs`
return `y-protocols/dist${path.slice(11)}.cjs`
}
return path
}

View file

@ -1,10 +1,10 @@
/* eslint-env browser */
import * as encoding from 'lib0/encoding.js'
import * as decoding from 'lib0/decoding.js'
import * as promise from 'lib0/promise.js'
import * as error from 'lib0/error.js'
import * as string from 'lib0/string.js'
import * as encoding from 'lib0/encoding'
import * as decoding from 'lib0/decoding'
import * as promise from 'lib0/promise'
import * as error from 'lib0/error'
import * as string from 'lib0/string'
/**
* @param {string} secret

View file

@ -1,22 +1,22 @@
import * as ws from 'lib0/websocket.js'
import * as map from 'lib0/map.js'
import * as error from 'lib0/error.js'
import * as random from 'lib0/random.js'
import * as encoding from 'lib0/encoding.js'
import * as decoding from 'lib0/decoding.js'
import { Observable } from 'lib0/observable.js'
import * as logging from 'lib0/logging.js'
import * as promise from 'lib0/promise.js'
import * as bc from 'lib0/broadcastchannel.js'
import * as buffer from 'lib0/buffer.js'
import * as math from 'lib0/math.js'
import { createMutex } from 'lib0/mutex.js'
import * as ws from 'lib0/websocket'
import * as map from 'lib0/map'
import * as error from 'lib0/error'
import * as random from 'lib0/random'
import * as encoding from 'lib0/encoding'
import * as decoding from 'lib0/decoding'
import { Observable } from 'lib0/observable'
import * as logging from 'lib0/logging'
import * as promise from 'lib0/promise'
import * as bc from 'lib0/broadcastchannel'
import * as buffer from 'lib0/buffer'
import * as math from 'lib0/math'
import { createMutex } from 'lib0/mutex'
import * as Y from 'yjs' // eslint-disable-line
import Peer from 'simple-peer/simplepeer.min.js'
import * as syncProtocol from 'y-protocols/sync.js'
import * as awarenessProtocol from 'y-protocols/awareness.js'
import * as syncProtocol from 'y-protocols/sync'
import * as awarenessProtocol from 'y-protocols/awareness'
import * as cryptoutils from './crypto.js'