Skip to content

Commit

Permalink
feat: upgrade to Parcel@2
Browse files Browse the repository at this point in the history
- smaller bundle 
- better source maps
- improved bundler compatibility

Closes #845, #859, #552, #585
  • Loading branch information
jonasgloning committed Apr 27, 2022
1 parent d466926 commit a2e942e
Show file tree
Hide file tree
Showing 15 changed files with 11,613 additions and 16,053 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/prettier.yml
Expand Up @@ -20,4 +20,4 @@ jobs:
${{ runner.os }}-npm-
- name: Run prettier
run: |-
npx prettier --check .
npx prettier --check .
5 changes: 3 additions & 2 deletions .gitignore
Expand Up @@ -14,11 +14,12 @@ results
demo
bower.json
node_modules
.cache
.parcel-cache
.idea
npm-debug.log
.DS_STORE

test/output
.tscache
test/public
.vscode/
.vscode/
218 changes: 0 additions & 218 deletions index.d.ts

This file was deleted.

3 changes: 0 additions & 3 deletions lib/adapter.ts

This file was deleted.

2 changes: 1 addition & 1 deletion lib/dataconnection.ts
Expand Up @@ -11,7 +11,7 @@ import { Peer } from "./peer";
import { BaseConnection } from "./baseconnection";
import { ServerMessage } from "./servermessage";
import { EncodingQueue } from "./encodingQueue";
import { DataConnection as IDataConnection } from "../index";
import type { DataConnection as IDataConnection } from "./dataconnection";

/**
* Wraps a DataChannel between two Peers.
Expand Down
11 changes: 3 additions & 8 deletions lib/exports.ts
@@ -1,13 +1,8 @@
import { util } from "./util";
import { Peer } from "./peer";

export const peerjs = {
Peer,
util,
};
export type { DataConnection } from "./dataconnection";
export type { MediaConnection } from "./mediaconnection";

export { Peer, util };
export default Peer;

(<any>window).peerjs = peerjs;
/** @deprecated Should use peerjs namespace */
(<any>window).Peer = Peer;
9 changes: 9 additions & 0 deletions lib/global.ts
@@ -0,0 +1,9 @@
import { util } from "./util";
import { Peer } from "./peer";

(<any>window).peerjs = {
Peer,
util,
};
/** @deprecated Should use peerjs namespace */
(<any>window).Peer = Peer;
2 changes: 1 addition & 1 deletion lib/mediaconnection.ts
Expand Up @@ -9,7 +9,7 @@ import {
import { Peer } from "./peer";
import { BaseConnection } from "./baseconnection";
import { ServerMessage } from "./servermessage";
import { AnswerOption } from "..";
import type { AnswerOption } from "./optionInterfaces";

/**
* Wraps the streaming interface between two Peers.
Expand Down
21 changes: 21 additions & 0 deletions lib/optionInterfaces.ts
@@ -0,0 +1,21 @@
export interface AnswerOption {
sdpTransform?: Function;
}

export interface PeerJSOption {
key?: string;
host?: string;
port?: number;
path?: string;
secure?: boolean;
token?: string;
config?: RTCConfiguration;
debug?: number;
}

export interface PeerConnectOption {
label?: string;
metadata?: any;
serialization?: string;
reliable?: boolean;
}
2 changes: 1 addition & 1 deletion lib/peer.ts
Expand Up @@ -14,7 +14,7 @@ import {
import { BaseConnection } from "./baseconnection";
import { ServerMessage } from "./servermessage";
import { API } from "./api";
import { PeerConnectOption, PeerJSOption } from "..";
import type { PeerConnectOption, PeerJSOption } from "./optionInterfaces";

class PeerOptions implements PeerJSOption {
debug?: LogLevel; // 1: Errors, 2: Warnings, 3: All logs
Expand Down
2 changes: 1 addition & 1 deletion lib/supports.ts
@@ -1,4 +1,4 @@
import { webRTCAdapter } from "./adapter";
import webRTCAdapter from "webrtc-adapter";

export const Supports = new (class {
readonly isIOS = ["iPad", "iPhone", "iPod"].includes(navigator.platform);
Expand Down
15 changes: 12 additions & 3 deletions lib/util.ts
@@ -1,6 +1,14 @@
import * as BinaryPack from "peerjs-js-binarypack";
import { Supports } from "./supports";
import { UtilSupportsObj } from "..";

interface UtilSupportsObj {
browser: boolean;
webRTC: boolean;
audioVideo: boolean;
data: boolean;
binaryBlob: boolean;
reliable: boolean;
}

const DEFAULT_CONFIG = {
iceServers: [
Expand All @@ -14,7 +22,7 @@ const DEFAULT_CONFIG = {
sdpSemantics: "unified-plan",
};

export const util = new (class {
class Util {
noop(): void {}

readonly CLOUD_HOST = "0.peerjs.com";
Expand Down Expand Up @@ -157,4 +165,5 @@ export const util = new (class {
isSecure(): boolean {
return location.protocol === "https:";
}
})();
}
export const util = new Util();

0 comments on commit a2e942e

Please sign in to comment.