Skip to content

Commit

Permalink
fix: remove CBOR
Browse files Browse the repository at this point in the history
Using CBOR forces us to choose between #1271 and #1247. Our complicated
importing and bundling situation makes using this library very hard.

CBOR support has been undocumented, and we are not aware of significant
usage in the wild. Therefore, we do not consider this a breaking change.
To make our expectations clearer, this PR also marks MessagePack as
`experimental`.

We will improve our importing and bundling situation before
reintroducing CBOR via a plugin.

Closes #1271
  • Loading branch information
jonasgloning committed May 14, 2024
1 parent 76bf9cd commit badc9e8
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 240 deletions.
2 changes: 0 additions & 2 deletions e2e/datachannel/serialization.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ const serialization = params.get("serialization");
(async () => {
let serializers = {};
try {
const { Cbor } = await import("/dist/serializer.cbor.mjs");
const { MsgPack } = await import("/dist/serializer.msgpack.mjs");
serializers = {
Cbor,
MsgPack,
};
} catch (e) {
Expand Down
35 changes: 0 additions & 35 deletions e2e/datachannel/serialization_cbor.spec.ts

This file was deleted.

9 changes: 0 additions & 9 deletions lib/cborPeer.ts

This file was deleted.

75 changes: 0 additions & 75 deletions lib/dataconnection/StreamConnection/Cbor.ts

This file was deleted.

4 changes: 1 addition & 3 deletions lib/exports.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export { util, type Util } from "./util";
import { Peer } from "./peer";
import { CborPeer } from "./cborPeer";
import { MsgPackPeer } from "./msgPackPeer";

export type { PeerEvents, PeerOptions } from "./peer";
Expand All @@ -19,11 +18,10 @@ export * from "./enums";

export { BufferedConnection } from "./dataconnection/BufferedConnection/BufferedConnection";
export { StreamConnection } from "./dataconnection/StreamConnection/StreamConnection";
export { Cbor } from "./dataconnection/StreamConnection/Cbor";
export { MsgPack } from "./dataconnection/StreamConnection/MsgPack";
export type { SerializerMapping } from "./peer";

export { Peer, MsgPackPeer, CborPeer };
export { Peer, MsgPackPeer };

export { PeerError } from "./peerError";
export default Peer;
3 changes: 3 additions & 0 deletions lib/msgPackPeer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Peer, type SerializerMapping } from "./peer";
import { MsgPack } from "./exports";

/**
* @experimental
*/
export class MsgPackPeer extends Peer {
override _serializers: SerializerMapping = {
MsgPack,
Expand Down
106 changes: 2 additions & 104 deletions package-lock.json

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

12 changes: 0 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
"module": "dist/bundler.mjs",
"browser-minified": "dist/peerjs.min.js",
"browser-unminified": "dist/peerjs.js",
"browser-minified-cbor": "dist/serializer.cbor.mjs",
"browser-minified-msgpack": "dist/serializer.msgpack.mjs",
"types": "dist/types.d.ts",
"engines": {
Expand Down Expand Up @@ -150,16 +149,6 @@
},
"source": "lib/global.ts"
},
"browser-minified-cbor": {
"context": "browser",
"outputFormat": "esmodule",
"isLibrary": true,
"optimize": true,
"engines": {
"browsers": "chrome >= 83, edge >= 83, firefox >= 102, safari >= 15"
},
"source": "lib/dataconnection/StreamConnection/Cbor.ts"
},
"browser-minified-msgpack": {
"context": "browser",
"outputFormat": "esmodule",
Expand Down Expand Up @@ -216,7 +205,6 @@
},
"dependencies": {
"@msgpack/msgpack": "^2.8.0",
"cbor-x": "1.5.4",
"eventemitter3": "^4.0.7",
"peerjs-js-binarypack": "^2.1.0",
"webrtc-adapter": "^9.0.0"
Expand Down

0 comments on commit badc9e8

Please sign in to comment.