Skip to content

Commit

Permalink
bump dependencies, use esm, and use conditional imports from lib0 & y…
Browse files Browse the repository at this point in the history
…-protocols
  • Loading branch information
dmonad committed May 22, 2021
1 parent 465d64b commit f6bd2c8
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 71 deletions.
6 changes: 3 additions & 3 deletions bin/server.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
72 changes: 36 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 14 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions src/crypto.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
30 changes: 15 additions & 15 deletions src/y-webrtc.js
Original file line number Diff line number Diff line change
@@ -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'

Expand Down

0 comments on commit f6bd2c8

Please sign in to comment.