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 #!/usr/bin/env node
const ws = require('ws') import ws from 'ws'
const http = require('http') import http from 'http'
const map = require('lib0/dist/map.cjs') import * as map from 'lib0/map'
const wsReadyStateConnecting = 0 const wsReadyStateConnecting = 0
const wsReadyStateOpen = 1 const wsReadyStateOpen = 1

View file

@ -4,8 +4,8 @@ import * as Y from 'yjs'
import { WebrtcProvider } from '../src/y-webrtc.js' import { WebrtcProvider } from '../src/y-webrtc.js'
const ydoc = new Y.Doc() const ydoc = new Y.Doc()
const provider = new WebrtcProvider('prosemirror', ydoc) const provider = new WebrtcProvider('webrtc-test', ydoc, { signaling: ['ws://localhost:4444'] })
const yarray = ydoc.get('prosemirror', Y.XmlFragment) const yarray = ydoc.getArray()
provider.on('synced', synced => { provider.on('synced', synced => {
// NOTE: This is only called when a different browser connects to this client // 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": { "@types/simple-peer": {
"version": "9.6.1", "version": "9.6.3",
"resolved": "https://registry.npmjs.org/@types/simple-peer/-/simple-peer-9.6.1.tgz", "resolved": "https://registry.npmjs.org/@types/simple-peer/-/simple-peer-9.6.3.tgz",
"integrity": "sha512-WdXxmHW+m0NaD5XPGlp5AB7raq+NUWX/+/aQvDcoOx0qiP78QmDdk015W29uoyvGhyiJCb9dZJuI2Oi39zGRfg==", "integrity": "sha512-zrXEBch9tF4NgkZDsGR3c1D0kq99M1bBCjzEyL0PVfEWzCIXrK64TuxRz3XKOx1B0KoEQ9kTs+AhMDuQaHy5RQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/node": "*" "@types/node": "*"
@ -506,9 +506,9 @@
"dev": true "dev": true
}, },
"err-code": { "err-code": {
"version": "2.0.3", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz", "resolved": "https://registry.npmjs.org/err-code/-/err-code-3.0.1.tgz",
"integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==" "integrity": "sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA=="
}, },
"error-ex": { "error-ex": {
"version": "1.3.2", "version": "1.3.2",
@ -1391,9 +1391,9 @@
"dev": true "dev": true
}, },
"isomorphic.js": { "isomorphic.js": {
"version": "0.1.5", "version": "0.2.4",
"resolved": "https://registry.npmjs.org/isomorphic.js/-/isomorphic.js-0.1.5.tgz", "resolved": "https://registry.npmjs.org/isomorphic.js/-/isomorphic.js-0.2.4.tgz",
"integrity": "sha512-MkX5lLQApx/8IAIU31PKvpAZosnu2Jqcj1rM8TzxyA4CR96tv3SgMKQNTCxL58G7696Q57zd7ubHV/hTg+5fNA==" "integrity": "sha512-Y4NjZceAwaPXctwsHgNsmfuPxR8lJ3f8X7QTAkhltrX4oGIv+eTlgHLXn4tWysC9zGTi929gapnPp+8F8cg7nA=="
}, },
"jest-worker": { "jest-worker": {
"version": "24.9.0", "version": "24.9.0",
@ -1460,11 +1460,11 @@
} }
}, },
"lib0": { "lib0": {
"version": "0.2.34", "version": "0.2.42",
"resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.34.tgz", "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.42.tgz",
"integrity": "sha512-cqsVIMPgFlDtgQcpkt7HOY6W3sbYPIe3qxMnbRSwHTgiQancgm+TRDPx28mC6GUZ6lG6Nr0bIWf4Nog6dWUNUg==", "integrity": "sha512-8BNM4MiokEKzMvSxTOC3gnCBisJH+jL67CnSnqzHv3jli3pUvGC8wz+0DQ2YvGr4wVQdb2R2uNNPw9LEpVvJ4Q==",
"requires": { "requires": {
"isomorphic.js": "^0.1.3" "isomorphic.js": "^0.2.4"
} }
}, },
"load-json-file": { "load-json-file": {
@ -1961,9 +1961,9 @@
"dev": true "dev": true
}, },
"queue-microtask": { "queue-microtask": {
"version": "1.2.2", "version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.2.tgz", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
"integrity": "sha512-dB15eXv3p2jDlbOiNLyMabYg1/sXvppd8DP2J3EOCQ0AkuSXCW2tP7mnVouVLJKgUMY6yP0kcQDVpLCN13h4Xg==" "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="
}, },
"randombytes": { "randombytes": {
"version": "2.1.0", "version": "2.1.0",
@ -2252,15 +2252,15 @@
"dev": true "dev": true
}, },
"simple-peer": { "simple-peer": {
"version": "9.9.3", "version": "9.11.0",
"resolved": "https://registry.npmjs.org/simple-peer/-/simple-peer-9.9.3.tgz", "resolved": "https://registry.npmjs.org/simple-peer/-/simple-peer-9.11.0.tgz",
"integrity": "sha512-T3wuv0UqBpDTV0x0pJPPsz4thy0tC0fTOHE4g9+AF43RUxxT+MWeXVtdQcK5Xuzv/XTVrB2NrGzdfO1IFBqOkw==", "integrity": "sha512-qvdNu/dGMHBm2uQ7oLhQBMhYlrOZC1ywXNCH/i8I4etxR1vrjCnU6ZSQBptndB1gcakjo2+w4OHo7Sjza1SHxg==",
"requires": { "requires": {
"buffer": "^6.0.2", "buffer": "^6.0.3",
"debug": "^4.2.0", "debug": "^4.3.1",
"err-code": "^2.0.3", "err-code": "^3.0.1",
"get-browser-rtc": "^1.0.2", "get-browser-rtc": "^1.1.0",
"queue-microtask": "^1.2.0", "queue-microtask": "^1.2.3",
"randombytes": "^2.1.0", "randombytes": "^2.1.0",
"readable-stream": "^3.6.0" "readable-stream": "^3.6.0"
}, },
@ -2544,9 +2544,9 @@
"dev": true "dev": true
}, },
"typescript": { "typescript": {
"version": "3.9.7", "version": "3.9.9",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.9.tgz",
"integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==", "integrity": "sha512-kdMjTiekY+z/ubJCATUPlRDl39vXYiMV9iyeMuEuXZh2we6zz80uovNN2WlAxmmdE/Z/YQe+EbOEXB5RHEED3w==",
"dev": true "dev": true
}, },
"union": { "union": {
@ -2663,11 +2663,11 @@
"dev": true "dev": true
}, },
"y-protocols": { "y-protocols": {
"version": "1.0.1", "version": "1.0.5",
"resolved": "https://registry.npmjs.org/y-protocols/-/y-protocols-1.0.1.tgz", "resolved": "https://registry.npmjs.org/y-protocols/-/y-protocols-1.0.5.tgz",
"integrity": "sha512-QP3fCM7c2gGfUi2nqf8gspyO4VW23zv3kNqPNdD3wNxMbuNQenMyoDVZYEo12jzR4RQ3aaDfPK62Sf31SVOmfg==", "integrity": "sha512-Wil92b7cGk712lRHDqS4T90IczF6RkcvCwAD0A2OPg+adKmOe+nOiT/N2hvpQIWS3zfjmtL4CPaH5sIW1Hkm/A==",
"requires": { "requires": {
"lib0": "^0.2.28" "lib0": "^0.2.42"
} }
}, },
"y18n": { "y18n": {
@ -2705,12 +2705,12 @@
} }
}, },
"yjs": { "yjs": {
"version": "13.4.6", "version": "13.5.6",
"resolved": "https://registry.npmjs.org/yjs/-/yjs-13.4.6.tgz", "resolved": "https://registry.npmjs.org/yjs/-/yjs-13.5.6.tgz",
"integrity": "sha512-BBHviAh3RTgp5Us4SubcAyxXFaLQ/552DzR0z3YZT1/HZLCpJc57cf6X0ZuuCGs8RFkgISYrbIFMrZ1L1NTzPA==", "integrity": "sha512-0ebPpLB/zizJbWaFUDRarWbXiXYD0OMDOCa8ZqkVVWQzeIoMRbmbNwB3suZ9YwD0bV4Su9RLn8M/bvGzIwX3hA==",
"dev": true, "dev": true,
"requires": { "requires": {
"lib0": "^0.2.33" "lib0": "^0.2.41"
} }
} }
} }

View file

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

View file

@ -98,9 +98,9 @@ export default [
sourcemap: true, sourcemap: true,
paths: path => { paths: path => {
if (/^lib0\//.test(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)) { } 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 return path
} }

View file

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

View file

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