mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-12 05:50:00 -04:00
add npm stuff, dist/
folder
This commit is contained in:
parent
ac3a135fff
commit
15304a80fe
22 changed files with 50951 additions and 11 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,7 +2,7 @@ node_modules
|
|||
dist.js
|
||||
dist.js.map
|
||||
dist.html
|
||||
dist/
|
||||
*/dist/
|
||||
admin-creds.json
|
||||
server/config.json
|
||||
.firebaserrc
|
||||
|
|
8
dist/Transport.d.ts
vendored
Normal file
8
dist/Transport.d.ts
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
export declare abstract class Transport {
|
||||
onopen: () => void;
|
||||
onclose: () => void;
|
||||
ondata: (data: ArrayBuffer) => void;
|
||||
constructor(onopen: () => void, onclose: () => void);
|
||||
abstract send(data: ArrayBuffer): void;
|
||||
abstract close(): void;
|
||||
}
|
18433
dist/client.cjs
vendored
Normal file
18433
dist/client.cjs
vendored
Normal file
File diff suppressed because it is too large
Load diff
18417
dist/client.mjs
vendored
Normal file
18417
dist/client.mjs
vendored
Normal file
File diff suppressed because it is too large
Load diff
8
dist/client/src/AdriftClient.d.ts
vendored
Normal file
8
dist/client/src/AdriftClient.d.ts
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
import { BareHeaders, BareResponse, Client, GetRequestHeadersCallback, MetaCallback, ReadyStateCallback, WebSocketImpl } from "bare-client-custom";
|
||||
import { Connection } from "./Connection";
|
||||
export declare class AdriftBareClient extends Client {
|
||||
private connection;
|
||||
constructor(connection: Connection);
|
||||
request(method: string, requestHeaders: BareHeaders, body: BodyInit | null, remote: URL, cache: string | undefined, duplex: string | undefined, signal: AbortSignal | undefined, arrayBufferImpl: ArrayBufferConstructor): Promise<BareResponse>;
|
||||
connect(remote: URL, protocols: string | string[], getRequestHeaders: GetRequestHeadersCallback, onMeta: MetaCallback, onReadyState: ReadyStateCallback, webSocketImpl: WebSocketImpl, arrayBufferImpl: ArrayBufferConstructor): WebSocket;
|
||||
}
|
36
dist/client/src/Connection.d.ts
vendored
Normal file
36
dist/client/src/Connection.d.ts
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
import { C2SRequestType, HTTPResponsePayload, ProtoBareHeaders, Transport } from "protocol";
|
||||
type OpenWSMeta = {
|
||||
onopen: (protocol: string) => void;
|
||||
onclose: (code: number, reason: string, wasClean: boolean) => void;
|
||||
onmessage: (data: ReadableStream, isBinary: boolean) => void;
|
||||
onerror: (message: string) => void;
|
||||
};
|
||||
export declare class Connection {
|
||||
transport: Transport;
|
||||
initialized: boolean;
|
||||
requestCallbacks: Record<number, Function>;
|
||||
openRequestStreams: Record<number, ReadableStreamDefaultController<any>>;
|
||||
openingSockets: Record<number, OpenWSMeta>;
|
||||
openSockets: Record<number, OpenWSMeta>;
|
||||
wsMsgStreams: Record<number, ReadableStreamDefaultController<any>>;
|
||||
counter: number;
|
||||
static uninitializedError(): void;
|
||||
constructor(transport: Transport);
|
||||
initialize(): Promise<void>;
|
||||
nextSeq(): number;
|
||||
ondata(data: ArrayBuffer): void;
|
||||
send(requestID: number, type: C2SRequestType, data?: ArrayBuffer | Blob): Promise<void>;
|
||||
httprequest(data: {
|
||||
method: string;
|
||||
requestHeaders: ProtoBareHeaders;
|
||||
remote: URL;
|
||||
}, body: ReadableStream<ArrayBuffer | Uint8Array> | null): Promise<{
|
||||
payload: HTTPResponsePayload;
|
||||
body: ArrayBuffer;
|
||||
}>;
|
||||
wsconnect(url: URL, protocols: string | string[], onopen: (protocol: string) => void, onclose: (code: number, reason: string, wasClean: boolean) => void, onmessage: (data: ReadableStream, isBinary: boolean) => void, onerror: (message: string) => void, arrayBufferImpl: ArrayBufferConstructor): {
|
||||
send: (data: any) => void;
|
||||
close: (code?: number, reason?: string) => void;
|
||||
};
|
||||
}
|
||||
export {};
|
8
dist/client/src/DevWsTransport.d.ts
vendored
Normal file
8
dist/client/src/DevWsTransport.d.ts
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
import { Transport } from "protocol";
|
||||
export declare class DevWsTransport extends Transport {
|
||||
ws: WebSocket;
|
||||
constructor(onopen: () => void, onclose: () => void);
|
||||
onmessage(msg: MessageEvent<any>): void;
|
||||
send(data: ArrayBuffer): void;
|
||||
close(): void;
|
||||
}
|
23
dist/client/src/RTCTransport.d.ts
vendored
Normal file
23
dist/client/src/RTCTransport.d.ts
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { Transport } from "protocol";
|
||||
export type Offer = {
|
||||
offer: any;
|
||||
localCandidates: any;
|
||||
};
|
||||
export type Answer = {
|
||||
answer: any;
|
||||
candidates: any;
|
||||
};
|
||||
export declare class RTCTransport extends Transport {
|
||||
onopen: () => void;
|
||||
onclose: () => void;
|
||||
onconnectionstatechange: () => void;
|
||||
onsignalingstatechange: () => void;
|
||||
onicegatheringstatechange: () => void;
|
||||
peer: RTCPeerConnection;
|
||||
dataChannel: RTCDataChannel;
|
||||
constructor(onopen: () => void, onclose: () => void, onconnectionstatechange: () => void, onsignalingstatechange: () => void, onicegatheringstatechange: () => void);
|
||||
send(data: ArrayBuffer): void;
|
||||
close(): void;
|
||||
createOffer(): Promise<Promise<Offer>>;
|
||||
answer(answer: any, candidates: any): Promise<void>;
|
||||
}
|
3
dist/client/src/SignalFirebase.d.ts
vendored
Normal file
3
dist/client/src/SignalFirebase.d.ts
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
import { Answer } from "./RTCTransport";
|
||||
export declare function signalSwarm(offer: string): Promise<Answer>;
|
||||
export declare function signalAccount(offer: string): Promise<Answer>;
|
6
dist/client/src/index.d.ts
vendored
Normal file
6
dist/client/src/index.d.ts
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
export { AdriftBareClient } from "./AdriftClient";
|
||||
export { Connection } from "./Connection";
|
||||
export { DevWsTransport } from "./DevWsTransport";
|
||||
export { RTCTransport } from "./RTCTransport";
|
||||
export * as SignalFirebase from "./SignalFirebase";
|
||||
export declare function downloadShortcut(name: string, title: string): void;
|
57
dist/index.d.ts
vendored
Normal file
57
dist/index.d.ts
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
export type ObjectValues<T> = T[keyof T];
|
||||
export declare const C2SRequestTypes: {
|
||||
readonly HTTPRequestStart: 0;
|
||||
readonly HTTPRequestChunk: 1;
|
||||
readonly HTTPRequestEnd: 2;
|
||||
readonly WSOpen: 3;
|
||||
readonly WSClose: 4;
|
||||
readonly WSSendText: 5;
|
||||
readonly WSSendBinary: 6;
|
||||
};
|
||||
export type C2SRequestType = ObjectValues<typeof C2SRequestTypes>;
|
||||
export declare const S2CRequestTypes: {
|
||||
readonly HTTPResponseStart: 0;
|
||||
readonly HTTPResponseChunk: 1;
|
||||
readonly HTTPResponseEnd: 2;
|
||||
readonly WSOpen: 3;
|
||||
readonly WSClose: 4;
|
||||
readonly WSTextStart: 5;
|
||||
readonly WSBinaryStart: 6;
|
||||
readonly WSDataChunk: 7;
|
||||
readonly WSDataEnd: 8;
|
||||
readonly WSError: 9;
|
||||
};
|
||||
export type S2CRequestType = ObjectValues<typeof S2CRequestTypes>;
|
||||
export type ProtoBareHeaders = Record<string, string | string[]>;
|
||||
export type HTTPRequestPayload = {
|
||||
method: string;
|
||||
requestHeaders: ProtoBareHeaders;
|
||||
remote: URL;
|
||||
hasBody: boolean;
|
||||
};
|
||||
export type HTTPResponsePayload = {
|
||||
status: number;
|
||||
statusText: string;
|
||||
headers: ProtoBareHeaders;
|
||||
};
|
||||
export type C2SWSOpenPayload = {
|
||||
url: string;
|
||||
protocols: string | string[];
|
||||
};
|
||||
export type S2CWSOpenPayload = {
|
||||
protocol: string;
|
||||
};
|
||||
export type WSClosePayload = {
|
||||
code: number;
|
||||
reason: string;
|
||||
wasClean: boolean;
|
||||
};
|
||||
export type WSErrorPayload = {
|
||||
message: string;
|
||||
};
|
||||
export declare const MAX_CHUNK_SIZE: number;
|
||||
export declare const S2C_HELLO_OK = ":3";
|
||||
export declare const C2S_HELLO = "haiii ";
|
||||
export declare const S2C_HELLO_ERR = ":< ";
|
||||
export declare const PROTOCOL_VERSION = "3.0";
|
||||
export { Transport } from "./Transport";
|
69
dist/protocol.cjs
vendored
Normal file
69
dist/protocol.cjs
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// protocol/src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
C2SRequestTypes: () => C2SRequestTypes,
|
||||
C2S_HELLO: () => C2S_HELLO,
|
||||
MAX_CHUNK_SIZE: () => MAX_CHUNK_SIZE,
|
||||
PROTOCOL_VERSION: () => PROTOCOL_VERSION,
|
||||
S2CRequestTypes: () => S2CRequestTypes,
|
||||
S2C_HELLO_ERR: () => S2C_HELLO_ERR,
|
||||
S2C_HELLO_OK: () => S2C_HELLO_OK,
|
||||
Transport: () => Transport
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
|
||||
// protocol/src/Transport.ts
|
||||
var Transport = class {
|
||||
constructor(onopen, onclose) {
|
||||
this.onopen = onopen;
|
||||
this.onclose = onclose;
|
||||
}
|
||||
ondata = () => {
|
||||
};
|
||||
};
|
||||
|
||||
// protocol/src/index.ts
|
||||
var C2SRequestTypes = {
|
||||
HTTPRequestStart: 0,
|
||||
HTTPRequestChunk: 1,
|
||||
HTTPRequestEnd: 2,
|
||||
WSOpen: 3,
|
||||
WSClose: 4,
|
||||
WSSendText: 5,
|
||||
WSSendBinary: 6
|
||||
};
|
||||
var S2CRequestTypes = {
|
||||
HTTPResponseStart: 0,
|
||||
HTTPResponseChunk: 1,
|
||||
HTTPResponseEnd: 2,
|
||||
WSOpen: 3,
|
||||
WSClose: 4,
|
||||
WSTextStart: 5,
|
||||
WSBinaryStart: 6,
|
||||
WSDataChunk: 7,
|
||||
WSDataEnd: 8,
|
||||
WSError: 9
|
||||
};
|
||||
var MAX_CHUNK_SIZE = 12 * 1024;
|
||||
var S2C_HELLO_OK = ":3";
|
||||
var C2S_HELLO = "haiii ";
|
||||
var S2C_HELLO_ERR = ":< ";
|
||||
var PROTOCOL_VERSION = "3.0";
|
47
dist/protocol.mjs
vendored
Normal file
47
dist/protocol.mjs
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// protocol/src/Transport.ts
|
||||
var Transport = class {
|
||||
constructor(onopen, onclose) {
|
||||
this.onopen = onopen;
|
||||
this.onclose = onclose;
|
||||
}
|
||||
ondata = () => {
|
||||
};
|
||||
};
|
||||
|
||||
// protocol/src/index.ts
|
||||
var C2SRequestTypes = {
|
||||
HTTPRequestStart: 0,
|
||||
HTTPRequestChunk: 1,
|
||||
HTTPRequestEnd: 2,
|
||||
WSOpen: 3,
|
||||
WSClose: 4,
|
||||
WSSendText: 5,
|
||||
WSSendBinary: 6
|
||||
};
|
||||
var S2CRequestTypes = {
|
||||
HTTPResponseStart: 0,
|
||||
HTTPResponseChunk: 1,
|
||||
HTTPResponseEnd: 2,
|
||||
WSOpen: 3,
|
||||
WSClose: 4,
|
||||
WSTextStart: 5,
|
||||
WSBinaryStart: 6,
|
||||
WSDataChunk: 7,
|
||||
WSDataEnd: 8,
|
||||
WSError: 9
|
||||
};
|
||||
var MAX_CHUNK_SIZE = 12 * 1024;
|
||||
var S2C_HELLO_OK = ":3";
|
||||
var C2S_HELLO = "haiii ";
|
||||
var S2C_HELLO_ERR = ":< ";
|
||||
var PROTOCOL_VERSION = "3.0";
|
||||
export {
|
||||
C2SRequestTypes,
|
||||
C2S_HELLO,
|
||||
MAX_CHUNK_SIZE,
|
||||
PROTOCOL_VERSION,
|
||||
S2CRequestTypes,
|
||||
S2C_HELLO_ERR,
|
||||
S2C_HELLO_OK,
|
||||
Transport
|
||||
};
|
8
dist/protocol/src/Transport.d.ts
vendored
Normal file
8
dist/protocol/src/Transport.d.ts
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
export declare abstract class Transport {
|
||||
onopen: () => void;
|
||||
onclose: () => void;
|
||||
ondata: (data: ArrayBuffer) => void;
|
||||
constructor(onopen: () => void, onclose: () => void);
|
||||
abstract send(data: ArrayBuffer): void;
|
||||
abstract close(): void;
|
||||
}
|
57
dist/protocol/src/index.d.ts
vendored
Normal file
57
dist/protocol/src/index.d.ts
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
export type ObjectValues<T> = T[keyof T];
|
||||
export declare const C2SRequestTypes: {
|
||||
readonly HTTPRequestStart: 0;
|
||||
readonly HTTPRequestChunk: 1;
|
||||
readonly HTTPRequestEnd: 2;
|
||||
readonly WSOpen: 3;
|
||||
readonly WSClose: 4;
|
||||
readonly WSSendText: 5;
|
||||
readonly WSSendBinary: 6;
|
||||
};
|
||||
export type C2SRequestType = ObjectValues<typeof C2SRequestTypes>;
|
||||
export declare const S2CRequestTypes: {
|
||||
readonly HTTPResponseStart: 0;
|
||||
readonly HTTPResponseChunk: 1;
|
||||
readonly HTTPResponseEnd: 2;
|
||||
readonly WSOpen: 3;
|
||||
readonly WSClose: 4;
|
||||
readonly WSTextStart: 5;
|
||||
readonly WSBinaryStart: 6;
|
||||
readonly WSDataChunk: 7;
|
||||
readonly WSDataEnd: 8;
|
||||
readonly WSError: 9;
|
||||
};
|
||||
export type S2CRequestType = ObjectValues<typeof S2CRequestTypes>;
|
||||
export type ProtoBareHeaders = Record<string, string | string[]>;
|
||||
export type HTTPRequestPayload = {
|
||||
method: string;
|
||||
requestHeaders: ProtoBareHeaders;
|
||||
remote: URL;
|
||||
hasBody: boolean;
|
||||
};
|
||||
export type HTTPResponsePayload = {
|
||||
status: number;
|
||||
statusText: string;
|
||||
headers: ProtoBareHeaders;
|
||||
};
|
||||
export type C2SWSOpenPayload = {
|
||||
url: string;
|
||||
protocols: string | string[];
|
||||
};
|
||||
export type S2CWSOpenPayload = {
|
||||
protocol: string;
|
||||
};
|
||||
export type WSClosePayload = {
|
||||
code: number;
|
||||
reason: string;
|
||||
wasClean: boolean;
|
||||
};
|
||||
export type WSErrorPayload = {
|
||||
message: string;
|
||||
};
|
||||
export declare const MAX_CHUNK_SIZE: number;
|
||||
export declare const S2C_HELLO_OK = ":3";
|
||||
export declare const C2S_HELLO = "haiii ";
|
||||
export declare const S2C_HELLO_ERR = ":< ";
|
||||
export declare const PROTOCOL_VERSION = "3.0";
|
||||
export { Transport } from "./Transport";
|
22
esbuild.package.js
Normal file
22
esbuild.package.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
const { dtsPlugin } = require("esbuild-plugin-d.ts");
|
||||
const { build } = require("esbuild");
|
||||
|
||||
|
||||
for (let project of ["client", "protocol"]) {
|
||||
build({
|
||||
bundle: true,
|
||||
format: "esm",
|
||||
entryPoints: [`./${project}/src/index.ts`],
|
||||
outfile: `./dist/${project}.mjs`,
|
||||
})
|
||||
build({
|
||||
bundle: true,
|
||||
format: "cjs",
|
||||
entryPoints: [`./${project}/src/index.ts`],
|
||||
outfile: `./dist/${project}.cjs`,
|
||||
plugins: [dtsPlugin({
|
||||
outDir: `./dist/${project}`,
|
||||
tsconfig: "tsconfig.json"
|
||||
})]
|
||||
})
|
||||
}
|
|
@ -79,7 +79,6 @@
|
|||
// TODO: error handling here
|
||||
await connection.initialize();
|
||||
let bare = new AdriftBareClient(connection);
|
||||
console.log(setBareClientImplementation);
|
||||
setBareClientImplementation(bare);
|
||||
state = ReadyState.Connected;
|
||||
}
|
||||
|
|
41
package.json
41
package.json
|
@ -1,19 +1,46 @@
|
|||
{
|
||||
"name": "adrift",
|
||||
"name": "@mercuryworkshop/adrift",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"workspace": [
|
||||
"workspaces": [
|
||||
"protocol",
|
||||
"server",
|
||||
"frontend",
|
||||
"client",
|
||||
"firebase-config"
|
||||
"client"
|
||||
],
|
||||
"exports": {
|
||||
"./protocol": {
|
||||
"types": "./dist/protocol/index.d.ts",
|
||||
"node": {
|
||||
"require": "./dist/protocol.cjs",
|
||||
"import": "./dist/protocol.mjs"
|
||||
},
|
||||
"browser": {
|
||||
"require": "./dist/protocol.cjs",
|
||||
"import": "./dist/protocol.mjs"
|
||||
}
|
||||
},
|
||||
"./browser": {
|
||||
"types": "./dist/browser/index.d.ts",
|
||||
"node": {
|
||||
"require": "./dist/browser.cjs",
|
||||
"import": "./dist/browser.mjs"
|
||||
},
|
||||
"browser": {
|
||||
"require": "./dist/browser.cjs",
|
||||
"import": "./dist/browser.mjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.19.2",
|
||||
"esbuild-plugin-d.ts": "^1.1.0",
|
||||
"estrella": "^1.4.1",
|
||||
"tsc": "^2.0.4"
|
||||
}
|
||||
}
|
13706
pnpm-lock.yaml
generated
Normal file
13706
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -9,4 +9,4 @@
|
|||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "adrift",
|
||||
"name": "adrift-server",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "src/main.ts",
|
||||
|
|
6
tsconfig.json
Normal file
6
tsconfig.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationDir": "./dist",
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue