include node_modules so release .zip is deployable

This commit is contained in:
2023-11-24 17:44:25 -05:00
parent 6c86cfe5d2
commit 8b11c41267
8963 changed files with 874175 additions and 1 deletions
+61
View File
@@ -0,0 +1,61 @@
import { EventTarget } from "./events/EventTarget";
export declare class WebSocket extends EventTarget<WebSocketEventMap> {
/**
* @hidden
*/
private client_;
/**
* @hidden
*/
private connection_;
/**
* @hidden
*/
private on_;
/**
* @hidden
*/
private state_;
constructor(url: string, protocols?: string | string[]);
close(code?: number, reason?: string): void;
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
readonly url: string;
readonly protocol: string;
readonly extensions: string;
readonly readyState: number;
readonly bufferedAmount: number;
readonly binaryType: string;
onopen: Listener<"open">;
onclose: Listener<"close">;
onmessage: Listener<"message">;
onerror: Listener<"error">;
/**
* @hidden
*/
private _Set_on;
/**
* @hidden
*/
private _Handle_connect;
/**
* @hidden
*/
private _Handle_close;
/**
* @hidden
*/
private _Handle_message;
/**
* @hidden
*/
private _Handle_error;
}
export declare namespace WebSocket {
const CONNECTING = 0;
const OPEN = 1;
const CLOSING = 2;
const CLOSED = 3;
}
declare type Listener<K extends keyof WebSocketEventMap> = (event: WebSocketEventMap[K]) => void;
export {};
//# sourceMappingURL=WebSocket.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"WebSocket.d.ts","sourceRoot":"","sources":["../src/WebSocket.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMnD,qBAAa,SAAU,SAAQ,WAAW,CAAC,iBAAiB,CAAC;IAE5D;;OAEG;IACH,OAAO,CAAC,OAAO,CAAS;IAExB;;OAEG;IACH,OAAO,CAAC,WAAW,CAAa;IAEhC;;OAEG;IACH,OAAO,CAAC,GAAG,CAAqC;IAEhD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAS;gBAKJ,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;IAyBtD,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAiB3C,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,GAAG,eAAe,GAAG,IAAI;aAuB/D,GAAG,EAAI,MAAM;aAKb,QAAQ,EAAI,MAAM;aAOlB,UAAU,EAAI,MAAM;aAOpB,UAAU,EAAI,MAAM;aAKpB,cAAc,EAAI,MAAM;aAKxB,UAAU,EAAI,MAAM;IAQpB,MAAM,EAAI,QAAQ,CAAC,MAAM,CAAC;IAI1B,OAAO,EAAI,QAAQ,CAAC,OAAO,CAAC;IAI5B,SAAS,EAAI,QAAQ,CAAC,SAAS,CAAC;IAIhC,OAAO,EAAI,QAAQ,CAAC,OAAO,CAAC;IAsBvC;;OAEG;IACH,OAAO,CAAC,OAAO;IAaf;;OAEG;IACH,OAAO,CAAC,eAAe;IAavB;;OAEG;IACH,OAAO,CAAC,aAAa;IAarB;;OAEG;IACH,OAAO,CAAC,eAAe;IAYvB;;OAEG;IACH,OAAO,CAAC,aAAa;CAarB;AAED,yBAAiB,SAAS,CAC1B;IACQ,MAAM,UAAU,IAAI,CAAC;IACrB,MAAM,IAAI,IAAI,CAAC;IACf,MAAM,OAAO,IAAI,CAAC;IAClB,MAAM,MAAM,IAAI,CAAC;CACxB;AAED,aAAK,QAAQ,CAAC,CAAC,SAAS,MAAM,iBAAiB,IAAI,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC"}
+242
View File
@@ -0,0 +1,242 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var websocket_1 = require("websocket");
var EventTarget_1 = require("./events/EventTarget");
var Event_1 = require("./events/Event");
var CloseEvent_1 = require("./events/CloseEvent");
var MessageEvent_1 = require("./events/MessageEvent");
var ErrorEvent_1 = require("./events/ErrorEvent");
var WebSocket = /** @class */ (function (_super) {
__extends(WebSocket, _super);
/* ----------------------------------------------------------------
CONSTRUCTORS
---------------------------------------------------------------- */
function WebSocket(url, protocols) {
var _this = _super.call(this) || this;
_this.on_ = {};
_this.state_ = WebSocket.CONNECTING;
//----
// CLIENT
//----
// PREPARE SOCKET
_this.client_ = new websocket_1.client();
_this.client_.on("connect", _this._Handle_connect.bind(_this));
_this.client_.on("connectFailed", _this._Handle_error.bind(_this));
if (typeof protocols === "string")
protocols = [protocols];
// DO CONNECT
_this.client_.connect(url, protocols);
return _this;
}
WebSocket.prototype.close = function (code, reason) {
this.state_ = WebSocket.CLOSING;
if (code === undefined)
this.connection_.sendCloseFrame();
else
this.connection_.sendCloseFrame(code, reason, true);
};
/* ================================================================
ACCESSORS
- SENDER
- PROPERTIES
- LISTENERS
===================================================================
SENDER
---------------------------------------------------------------- */
WebSocket.prototype.send = function (data) {
if (typeof data.valueOf() === "string")
this.connection_.sendUTF(data);
else {
var buffer = void 0;
if (data instanceof Buffer)
buffer = data;
else if (data instanceof Blob)
buffer = new Buffer(data, "blob");
else if (data.buffer)
buffer = new Buffer(data.buffer);
else
buffer = new Buffer(data);
this.connection_.sendBytes(buffer);
}
};
Object.defineProperty(WebSocket.prototype, "url", {
/* ----------------------------------------------------------------
PROPERTIES
---------------------------------------------------------------- */
get: function () {
return this.client_.url.href;
},
enumerable: true,
configurable: true
});
Object.defineProperty(WebSocket.prototype, "protocol", {
get: function () {
return this.client_.protocols
? this.client_.protocols[0]
: "";
},
enumerable: true,
configurable: true
});
Object.defineProperty(WebSocket.prototype, "extensions", {
get: function () {
return this.connection_ && this.connection_.extensions
? this.connection_.extensions[0].name
: "";
},
enumerable: true,
configurable: true
});
Object.defineProperty(WebSocket.prototype, "readyState", {
get: function () {
return this.state_;
},
enumerable: true,
configurable: true
});
Object.defineProperty(WebSocket.prototype, "bufferedAmount", {
get: function () {
return this.connection_.bytesWaitingToFlush;
},
enumerable: true,
configurable: true
});
Object.defineProperty(WebSocket.prototype, "binaryType", {
get: function () {
return "arraybuffer";
},
enumerable: true,
configurable: true
});
Object.defineProperty(WebSocket.prototype, "onopen", {
/* ----------------------------------------------------------------
LISTENERS
---------------------------------------------------------------- */
get: function () {
return this.on_.open;
},
set: function (listener) {
this._Set_on("open", listener);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WebSocket.prototype, "onclose", {
get: function () {
return this.on_.close;
},
set: function (listener) {
this._Set_on("close", listener);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WebSocket.prototype, "onmessage", {
get: function () {
return this.on_.message;
},
set: function (listener) {
this._Set_on("message", listener);
},
enumerable: true,
configurable: true
});
Object.defineProperty(WebSocket.prototype, "onerror", {
get: function () {
return this.on_.error;
},
set: function (listener) {
this._Set_on("error", listener);
},
enumerable: true,
configurable: true
});
/**
* @hidden
*/
WebSocket.prototype._Set_on = function (type, listener) {
if (this.on_[type])
this.removeEventListener(type, this.on_[type]);
this.addEventListener(type, listener);
this.on_[type] = listener;
};
/* ----------------------------------------------------------------
SOCKET HANDLERS
---------------------------------------------------------------- */
/**
* @hidden
*/
WebSocket.prototype._Handle_connect = function (connection) {
this.connection_ = connection;
this.state_ = WebSocket.OPEN;
this.connection_.on("message", this._Handle_message.bind(this));
this.connection_.on("error", this._Handle_error.bind(this));
this.connection_.on("close", this._Handle_close.bind(this));
var event = new Event_1.Event("open", EVENT_INIT);
this.dispatchEvent(event);
};
/**
* @hidden
*/
WebSocket.prototype._Handle_close = function (code, reason) {
var event = new CloseEvent_1.CloseEvent("close", __assign({}, EVENT_INIT, { code: code, reason: reason }));
this.state_ = WebSocket.CLOSED;
this.dispatchEvent(event);
};
/**
* @hidden
*/
WebSocket.prototype._Handle_message = function (message) {
var event = new MessageEvent_1.MessageEvent("message", __assign({}, EVENT_INIT, { data: message.binaryData
? message.binaryData
: message.utf8Data }));
this.dispatchEvent(event);
};
/**
* @hidden
*/
WebSocket.prototype._Handle_error = function (error) {
var event = new ErrorEvent_1.ErrorEvent("error", __assign({}, EVENT_INIT, { error: error, message: error.message }));
if (this.state_ === WebSocket.CONNECTING)
this.state_ = WebSocket.CLOSED;
this.dispatchEvent(event);
};
return WebSocket;
}(EventTarget_1.EventTarget));
exports.WebSocket = WebSocket;
(function (WebSocket) {
WebSocket.CONNECTING = 0;
WebSocket.OPEN = 1;
WebSocket.CLOSING = 2;
WebSocket.CLOSED = 3;
})(WebSocket = exports.WebSocket || (exports.WebSocket = {}));
exports.WebSocket = WebSocket;
var EVENT_INIT = {
bubbles: false,
cancelable: false
};
//# sourceMappingURL=WebSocket.js.map
+7
View File
@@ -0,0 +1,7 @@
import { Event } from "./Event";
export declare class CloseEvent extends Event {
readonly code: number;
readonly reason: string;
constructor(type: string, init?: CloseEventInit);
}
//# sourceMappingURL=CloseEvent.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"CloseEvent.d.ts","sourceRoot":"","sources":["../../src/events/CloseEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,UAAW,SAAQ,KAAK;IAEpC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEZ,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,cAAc;CAItD"}
+25
View File
@@ -0,0 +1,25 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Event_1 = require("./Event");
var CloseEvent = /** @class */ (function (_super) {
__extends(CloseEvent, _super);
function CloseEvent(type, init) {
return _super.call(this, type, init) || this;
}
return CloseEvent;
}(Event_1.Event));
exports.CloseEvent = CloseEvent;
//# sourceMappingURL=CloseEvent.js.map
+7
View File
@@ -0,0 +1,7 @@
import { Event } from "./Event";
export declare class ErrorEvent extends Event {
readonly error: any;
readonly message: string;
constructor(type: string, init?: ErrorEventInit);
}
//# sourceMappingURL=ErrorEvent.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ErrorEvent.d.ts","sourceRoot":"","sources":["../../src/events/ErrorEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,UAAW,SAAQ,KAAK;IAEpC,SAAgB,KAAK,EAAE,GAAG,CAAC;IAC3B,SAAgB,OAAO,EAAE,MAAM,CAAC;gBAEb,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,cAAc;CAItD"}
+25
View File
@@ -0,0 +1,25 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Event_1 = require("./Event");
var ErrorEvent = /** @class */ (function (_super) {
__extends(ErrorEvent, _super);
function ErrorEvent(type, init) {
return _super.call(this, type, init) || this;
}
return ErrorEvent;
}(Event_1.Event));
exports.ErrorEvent = ErrorEvent;
//# sourceMappingURL=ErrorEvent.js.map
+7
View File
@@ -0,0 +1,7 @@
export declare class Event {
readonly target: EventTarget;
readonly type: string;
readonly timeStamp: number;
constructor(type: string, init?: EventInit);
}
//# sourceMappingURL=Event.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Event.d.ts","sourceRoot":"","sources":["../../src/events/Event.ts"],"names":[],"mappings":"AAAA,qBAAa,KAAK;IAEjB,SAAgB,MAAM,EAAE,WAAW,CAAC;IACpC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,SAAS,EAAE,MAAM,CAAC;gBAEf,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS;CAMjD"}
+12
View File
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Event = /** @class */ (function () {
function Event(type, init) {
this.type = type;
if (init)
Object.assign(this, init);
}
return Event;
}());
exports.Event = Event;
//# sourceMappingURL=Event.js.map
+16
View File
@@ -0,0 +1,16 @@
import { Event } from "./Event";
export declare class EventTarget<Types extends object = {}> {
/**
* @hidden
*/
private listeners_;
/**
* @hidden
*/
private created_at_;
constructor();
dispatchEvent(event: Event): void;
addEventListener<K extends keyof Types>(type: K, listener: Types[K]): void;
removeEventListener<K extends keyof Types>(type: string, listener: Types[K]): void;
}
//# sourceMappingURL=EventTarget.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"EventTarget.d.ts","sourceRoot":"","sources":["../../src/events/EventTarget.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,WAAW,CAAC,KAAK,SAAS,MAAM,GAAG,EAAE;IAEjD;;OAEG;IACH,OAAO,CAAC,UAAU,CAAqC;IAEvD;;OAEG;IACH,OAAO,CAAC,WAAW,CAAO;;IAQnB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAgBjC,gBAAgB,CAAC,CAAC,SAAS,MAAM,KAAK,EAC3C,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI;IAS7B,mBAAmB,CAAC,CAAC,SAAS,MAAM,KAAK,EAC9C,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI;CAUzC"}
+61
View File
@@ -0,0 +1,61 @@
"use strict";
var __values = (this && this.__values) || function (o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
};
Object.defineProperty(exports, "__esModule", { value: true });
var HashSet_1 = require("tstl/container/HashSet");
var HashMap_1 = require("tstl/container/HashMap");
var EventTarget = /** @class */ (function () {
function EventTarget() {
this.listeners_ = new HashMap_1.HashMap();
this.created_at_ = new Date();
}
EventTarget.prototype.dispatchEvent = function (event) {
var e_1, _a;
// FIND LISTENERS
var it = this.listeners_.find(event.type);
if (it.equals(this.listeners_.end()))
return;
// SET DEFAULT ARGUMENTS
event.target = this;
event.timeStamp = new Date().getTime() - this.created_at_.getTime();
try {
// CALL THE LISTENERS
for (var _b = __values(it.second), _c = _b.next(); !_c.done; _c = _b.next()) {
var listener = _c.value;
listener(event);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
};
EventTarget.prototype.addEventListener = function (type, listener) {
var it = this.listeners_.find(type);
if (it.equals(this.listeners_.end()))
it = this.listeners_.emplace(type, new HashSet_1.HashSet()).first;
it.second.insert(listener);
};
EventTarget.prototype.removeEventListener = function (type, listener) {
var it = this.listeners_.find(type);
if (it.equals(this.listeners_.end()))
return;
it.second.erase(listener);
if (it.second.empty())
this.listeners_.erase(it);
};
return EventTarget;
}());
exports.EventTarget = EventTarget;
//# sourceMappingURL=EventTarget.js.map
+6
View File
@@ -0,0 +1,6 @@
import { Event } from "./Event";
export declare class MessageEvent extends Event {
readonly data: any;
constructor(type: string, init?: MessageEventInit);
}
//# sourceMappingURL=MessageEvent.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"MessageEvent.d.ts","sourceRoot":"","sources":["../../src/events/MessageEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,YAAa,SAAQ,KAAK;IAEtC,SAAgB,IAAI,EAAE,GAAG,CAAC;gBAEP,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB;CAIxD"}
+25
View File
@@ -0,0 +1,25 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Event_1 = require("./Event");
var MessageEvent = /** @class */ (function (_super) {
__extends(MessageEvent, _super);
function MessageEvent(type, init) {
return _super.call(this, type, init) || this;
}
return MessageEvent;
}(Event_1.Event));
exports.MessageEvent = MessageEvent;
//# sourceMappingURL=MessageEvent.js.map
+2
View File
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
+6
View File
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var node_1 = require("tstl/utility/node");
if (node_1.is_node())
global.WebSocket = require("./WebSocket").WebSocket;
//# sourceMappingURL=index.js.map