microsoft-speech-browser-sdk
Version:
Microsoft Speech SDK for browsers
1,415 lines (1,352 loc) • 180 kB
JavaScript
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 17);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(__webpack_require__(20));
__export(__webpack_require__(21));
__export(__webpack_require__(8));
__export(__webpack_require__(22));
__export(__webpack_require__(1));
__export(__webpack_require__(23));
__export(__webpack_require__(9));
__export(__webpack_require__(2));
__export(__webpack_require__(24));
__export(__webpack_require__(10));
__export(__webpack_require__(11));
__export(__webpack_require__(4));
__export(__webpack_require__(12));
__export(__webpack_require__(13));
__export(__webpack_require__(25));
__export(__webpack_require__(26));
__export(__webpack_require__(27));
__export(__webpack_require__(28));
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || (function () {
var 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 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 });
/**
* The error that is thrown when an argument passed in is null.
*
* @export
* @class ArgumentNullError
* @extends {Error}
*/
var ArgumentNullError = /** @class */ (function (_super) {
__extends(ArgumentNullError, _super);
/**
* Creates an instance of ArgumentNullError.
*
* @param {string} argumentName Name of the argument that is null
*
* @memberOf ArgumentNullError
*/
function ArgumentNullError(argumentName) {
var _this = _super.call(this, argumentName) || this;
_this.name = "ArgumentNull";
_this.message = argumentName;
return _this;
}
return ArgumentNullError;
}(Error));
exports.ArgumentNullError = ArgumentNullError;
/**
* The error that is thrown when an invalid operation is performed in the code.
*
* @export
* @class InvalidOperationError
* @extends {Error}
*/
// tslint:disable-next-line:max-classes-per-file
var InvalidOperationError = /** @class */ (function (_super) {
__extends(InvalidOperationError, _super);
/**
* Creates an instance of InvalidOperationError.
*
* @param {string} error The error
*
* @memberOf InvalidOperationError
*/
function InvalidOperationError(error) {
var _this = _super.call(this, error) || this;
_this.name = "InvalidOperation";
_this.message = error;
return _this;
}
return InvalidOperationError;
}(Error));
exports.InvalidOperationError = InvalidOperationError;
/**
* The error that is thrown when an object is disposed.
*
* @export
* @class ObjectDisposedError
* @extends {Error}
*/
// tslint:disable-next-line:max-classes-per-file
var ObjectDisposedError = /** @class */ (function (_super) {
__extends(ObjectDisposedError, _super);
/**
* Creates an instance of ObjectDisposedError.
*
* @param {string} objectName The object that is disposed
* @param {string} error The error
*
* @memberOf ObjectDisposedError
*/
function ObjectDisposedError(objectName, error) {
var _this = _super.call(this, error) || this;
_this.name = objectName + "ObjectDisposed";
_this.message = error;
return _this;
}
return ObjectDisposedError;
}(Error));
exports.ObjectDisposedError = ObjectDisposedError;
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var CreateGuid = function () {
var d = new Date().getTime();
var guid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c === "x" ? r : (r & 0x3 | 0x8)).toString(16);
});
return guid;
};
exports.CreateGuid = CreateGuid;
var CreateNoDashGuid = function () {
return CreateGuid().replace(new RegExp("-", "g"), "").toUpperCase();
};
exports.CreateNoDashGuid = CreateNoDashGuid;
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(__webpack_require__(19));
__export(__webpack_require__(29));
__export(__webpack_require__(30));
__export(__webpack_require__(31));
__export(__webpack_require__(32));
__export(__webpack_require__(33));
__export(__webpack_require__(34));
__export(__webpack_require__(35));
__export(__webpack_require__(36));
__export(__webpack_require__(14));
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Guid_1 = __webpack_require__(2);
var EventType;
(function (EventType) {
EventType[EventType["Debug"] = 0] = "Debug";
EventType[EventType["Info"] = 1] = "Info";
EventType[EventType["Warning"] = 2] = "Warning";
EventType[EventType["Error"] = 3] = "Error";
})(EventType = exports.EventType || (exports.EventType = {}));
var PlatformEvent = /** @class */ (function () {
function PlatformEvent(eventName, eventType) {
this.name = eventName;
this.eventId = Guid_1.CreateNoDashGuid();
this.eventTime = new Date().toISOString();
this.eventType = eventType;
this.metadata = {};
}
Object.defineProperty(PlatformEvent.prototype, "Name", {
get: function () {
return this.name;
},
enumerable: true,
configurable: true
});
Object.defineProperty(PlatformEvent.prototype, "EventId", {
get: function () {
return this.eventId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(PlatformEvent.prototype, "EventTime", {
get: function () {
return this.eventTime;
},
enumerable: true,
configurable: true
});
Object.defineProperty(PlatformEvent.prototype, "EventType", {
get: function () {
return this.eventType;
},
enumerable: true,
configurable: true
});
Object.defineProperty(PlatformEvent.prototype, "Metadata", {
get: function () {
return this.metadata;
},
enumerable: true,
configurable: true
});
return PlatformEvent;
}());
exports.PlatformEvent = PlatformEvent;
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// IMPORTANT - Dont publish internal modules.
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(__webpack_require__(37));
__export(__webpack_require__(38));
__export(__webpack_require__(6));
__export(__webpack_require__(7));
__export(__webpack_require__(39));
__export(__webpack_require__(15));
__export(__webpack_require__(42));
__export(__webpack_require__(43));
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var AuthInfo = /** @class */ (function () {
function AuthInfo(headerName, token) {
this.headerName = headerName;
this.token = token;
}
Object.defineProperty(AuthInfo.prototype, "HeaderName", {
get: function () {
return this.headerName;
},
enumerable: true,
configurable: true
});
Object.defineProperty(AuthInfo.prototype, "Token", {
get: function () {
return this.token;
},
enumerable: true,
configurable: true
});
return AuthInfo;
}());
exports.AuthInfo = AuthInfo;
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || (function () {
var 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 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 Exports_1 = __webpack_require__(0);
var SpeechRecognitionEvent = /** @class */ (function (_super) {
__extends(SpeechRecognitionEvent, _super);
function SpeechRecognitionEvent(eventName, requestId, eventType) {
if (eventType === void 0) { eventType = Exports_1.EventType.Info; }
var _this = _super.call(this, eventName, eventType) || this;
_this.requestId = requestId;
return _this;
}
Object.defineProperty(SpeechRecognitionEvent.prototype, "RequestId", {
get: function () {
return this.requestId;
},
enumerable: true,
configurable: true
});
return SpeechRecognitionEvent;
}(Exports_1.PlatformEvent));
exports.SpeechRecognitionEvent = SpeechRecognitionEvent;
// tslint:disable-next-line:max-classes-per-file
var SpeechRecognitionResultEvent = /** @class */ (function (_super) {
__extends(SpeechRecognitionResultEvent, _super);
function SpeechRecognitionResultEvent(eventName, requestId, result) {
var _this = _super.call(this, eventName, requestId) || this;
_this.result = result;
return _this;
}
Object.defineProperty(SpeechRecognitionResultEvent.prototype, "Result", {
get: function () {
return this.result;
},
enumerable: true,
configurable: true
});
return SpeechRecognitionResultEvent;
}(SpeechRecognitionEvent));
exports.SpeechRecognitionResultEvent = SpeechRecognitionResultEvent;
// tslint:disable-next-line:max-classes-per-file
var RecognitionTriggeredEvent = /** @class */ (function (_super) {
__extends(RecognitionTriggeredEvent, _super);
function RecognitionTriggeredEvent(requestId, audioSourceId, audioNodeId) {
var _this = _super.call(this, "RecognitionTriggeredEvent", requestId) || this;
_this.audioSourceId = audioSourceId;
_this.audioNodeId = audioNodeId;
return _this;
}
Object.defineProperty(RecognitionTriggeredEvent.prototype, "AudioSourceId", {
get: function () {
return this.audioSourceId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(RecognitionTriggeredEvent.prototype, "AudioNodeId", {
get: function () {
return this.audioNodeId;
},
enumerable: true,
configurable: true
});
return RecognitionTriggeredEvent;
}(SpeechRecognitionEvent));
exports.RecognitionTriggeredEvent = RecognitionTriggeredEvent;
// tslint:disable-next-line:max-classes-per-file
var ListeningStartedEvent = /** @class */ (function (_super) {
__extends(ListeningStartedEvent, _super);
function ListeningStartedEvent(requestId, audioSourceId, audioNodeId) {
var _this = _super.call(this, "ListeningStartedEvent", requestId) || this;
_this.audioSourceId = audioSourceId;
_this.audioNodeId = audioNodeId;
return _this;
}
Object.defineProperty(ListeningStartedEvent.prototype, "AudioSourceId", {
get: function () {
return this.audioSourceId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ListeningStartedEvent.prototype, "AudioNodeId", {
get: function () {
return this.audioNodeId;
},
enumerable: true,
configurable: true
});
return ListeningStartedEvent;
}(SpeechRecognitionEvent));
exports.ListeningStartedEvent = ListeningStartedEvent;
// tslint:disable-next-line:max-classes-per-file
var ConnectingToServiceEvent = /** @class */ (function (_super) {
__extends(ConnectingToServiceEvent, _super);
function ConnectingToServiceEvent(requestId, authFetchEventid, connectionId) {
var _this = _super.call(this, "ConnectingToServiceEvent", requestId) || this;
_this.authFetchEventid = authFetchEventid;
_this.connectionId = connectionId;
return _this;
}
Object.defineProperty(ConnectingToServiceEvent.prototype, "AuthFetchEventid", {
get: function () {
return this.authFetchEventid;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ConnectingToServiceEvent.prototype, "ConnectionId", {
get: function () {
return this.connectionId;
},
enumerable: true,
configurable: true
});
return ConnectingToServiceEvent;
}(SpeechRecognitionEvent));
exports.ConnectingToServiceEvent = ConnectingToServiceEvent;
// tslint:disable-next-line:max-classes-per-file
var RecognitionStartedEvent = /** @class */ (function (_super) {
__extends(RecognitionStartedEvent, _super);
function RecognitionStartedEvent(requestId, audioSourceId, audioNodeId, authFetchEventId, connectionId) {
var _this = _super.call(this, "RecognitionStartedEvent", requestId) || this;
_this.audioSourceId = audioSourceId;
_this.audioNodeId = audioNodeId;
_this.authFetchEventId = authFetchEventId;
_this.connectionId = connectionId;
return _this;
}
Object.defineProperty(RecognitionStartedEvent.prototype, "AudioSourceId", {
get: function () {
return this.audioSourceId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(RecognitionStartedEvent.prototype, "AudioNodeId", {
get: function () {
return this.audioNodeId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(RecognitionStartedEvent.prototype, "AuthFetchEventId", {
get: function () {
return this.authFetchEventId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(RecognitionStartedEvent.prototype, "ConnectionId", {
get: function () {
return this.connectionId;
},
enumerable: true,
configurable: true
});
return RecognitionStartedEvent;
}(SpeechRecognitionEvent));
exports.RecognitionStartedEvent = RecognitionStartedEvent;
// tslint:disable-next-line:max-classes-per-file
var SpeechStartDetectedEvent = /** @class */ (function (_super) {
__extends(SpeechStartDetectedEvent, _super);
function SpeechStartDetectedEvent(requestId, result) {
return _super.call(this, "SpeechStartDetectedEvent", requestId, result) || this;
}
return SpeechStartDetectedEvent;
}(SpeechRecognitionResultEvent));
exports.SpeechStartDetectedEvent = SpeechStartDetectedEvent;
// tslint:disable-next-line:max-classes-per-file
var SpeechHypothesisEvent = /** @class */ (function (_super) {
__extends(SpeechHypothesisEvent, _super);
function SpeechHypothesisEvent(requestId, result) {
return _super.call(this, "SpeechHypothesisEvent", requestId, result) || this;
}
return SpeechHypothesisEvent;
}(SpeechRecognitionResultEvent));
exports.SpeechHypothesisEvent = SpeechHypothesisEvent;
// tslint:disable-next-line:max-classes-per-file
var SpeechFragmentEvent = /** @class */ (function (_super) {
__extends(SpeechFragmentEvent, _super);
function SpeechFragmentEvent(requestId, result) {
return _super.call(this, "SpeechFragmentEvent", requestId, result) || this;
}
return SpeechFragmentEvent;
}(SpeechRecognitionResultEvent));
exports.SpeechFragmentEvent = SpeechFragmentEvent;
// tslint:disable-next-line:max-classes-per-file
var SpeechEndDetectedEvent = /** @class */ (function (_super) {
__extends(SpeechEndDetectedEvent, _super);
function SpeechEndDetectedEvent(requestId, result) {
return _super.call(this, "SpeechEndDetectedEvent", requestId, result) || this;
}
return SpeechEndDetectedEvent;
}(SpeechRecognitionResultEvent));
exports.SpeechEndDetectedEvent = SpeechEndDetectedEvent;
// tslint:disable-next-line:max-classes-per-file
var SpeechSimplePhraseEvent = /** @class */ (function (_super) {
__extends(SpeechSimplePhraseEvent, _super);
function SpeechSimplePhraseEvent(requestId, result) {
return _super.call(this, "SpeechSimplePhraseEvent", requestId, result) || this;
}
return SpeechSimplePhraseEvent;
}(SpeechRecognitionResultEvent));
exports.SpeechSimplePhraseEvent = SpeechSimplePhraseEvent;
// tslint:disable-next-line:max-classes-per-file
var SpeechDetailedPhraseEvent = /** @class */ (function (_super) {
__extends(SpeechDetailedPhraseEvent, _super);
function SpeechDetailedPhraseEvent(requestId, result) {
return _super.call(this, "SpeechDetailedPhraseEvent", requestId, result) || this;
}
return SpeechDetailedPhraseEvent;
}(SpeechRecognitionResultEvent));
exports.SpeechDetailedPhraseEvent = SpeechDetailedPhraseEvent;
var RecognitionCompletionStatus;
(function (RecognitionCompletionStatus) {
RecognitionCompletionStatus[RecognitionCompletionStatus["Success"] = 0] = "Success";
RecognitionCompletionStatus[RecognitionCompletionStatus["AudioSourceError"] = 1] = "AudioSourceError";
RecognitionCompletionStatus[RecognitionCompletionStatus["AudioSourceTimeout"] = 2] = "AudioSourceTimeout";
RecognitionCompletionStatus[RecognitionCompletionStatus["AuthTokenFetchError"] = 3] = "AuthTokenFetchError";
RecognitionCompletionStatus[RecognitionCompletionStatus["AuthTokenFetchTimeout"] = 4] = "AuthTokenFetchTimeout";
RecognitionCompletionStatus[RecognitionCompletionStatus["UnAuthorized"] = 5] = "UnAuthorized";
RecognitionCompletionStatus[RecognitionCompletionStatus["ConnectTimeout"] = 6] = "ConnectTimeout";
RecognitionCompletionStatus[RecognitionCompletionStatus["ConnectError"] = 7] = "ConnectError";
RecognitionCompletionStatus[RecognitionCompletionStatus["ClientRecognitionActivityTimeout"] = 8] = "ClientRecognitionActivityTimeout";
RecognitionCompletionStatus[RecognitionCompletionStatus["UnknownError"] = 9] = "UnknownError";
})(RecognitionCompletionStatus = exports.RecognitionCompletionStatus || (exports.RecognitionCompletionStatus = {}));
// tslint:disable-next-line:max-classes-per-file
var RecognitionEndedEvent = /** @class */ (function (_super) {
__extends(RecognitionEndedEvent, _super);
function RecognitionEndedEvent(requestId, audioSourceId, audioNodeId, authFetchEventId, connectionId, serviceTag, status, error) {
var _this = _super.call(this, "RecognitionEndedEvent", requestId, status === RecognitionCompletionStatus.Success ? Exports_1.EventType.Info : Exports_1.EventType.Error) || this;
_this.audioSourceId = audioSourceId;
_this.audioNodeId = audioNodeId;
_this.connectionId = connectionId;
_this.authFetchEventId = authFetchEventId;
_this.status = status;
_this.error = error;
_this.serviceTag = serviceTag;
return _this;
}
Object.defineProperty(RecognitionEndedEvent.prototype, "AudioSourceId", {
get: function () {
return this.audioSourceId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(RecognitionEndedEvent.prototype, "AudioNodeId", {
get: function () {
return this.audioNodeId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(RecognitionEndedEvent.prototype, "AuthFetchEventId", {
get: function () {
return this.authFetchEventId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(RecognitionEndedEvent.prototype, "ConnectionId", {
get: function () {
return this.connectionId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(RecognitionEndedEvent.prototype, "ServiceTag", {
get: function () {
return this.serviceTag;
},
enumerable: true,
configurable: true
});
Object.defineProperty(RecognitionEndedEvent.prototype, "Status", {
get: function () {
return this.status;
},
enumerable: true,
configurable: true
});
Object.defineProperty(RecognitionEndedEvent.prototype, "Error", {
get: function () {
return this.error;
},
enumerable: true,
configurable: true
});
return RecognitionEndedEvent;
}(SpeechRecognitionEvent));
exports.RecognitionEndedEvent = RecognitionEndedEvent;
/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Error_1 = __webpack_require__(1);
var Guid_1 = __webpack_require__(2);
var MessageType;
(function (MessageType) {
MessageType[MessageType["Text"] = 0] = "Text";
MessageType[MessageType["Binary"] = 1] = "Binary";
})(MessageType = exports.MessageType || (exports.MessageType = {}));
var ConnectionMessage = /** @class */ (function () {
function ConnectionMessage(messageType, body, headers, id) {
this.body = null;
if (messageType === MessageType.Text && body && !(typeof (body) === "string")) {
throw new Error_1.InvalidOperationError("Payload must be a string");
}
if (messageType === MessageType.Binary && body && !(body instanceof ArrayBuffer)) {
throw new Error_1.InvalidOperationError("Payload must be ArrayBuffer");
}
this.messageType = messageType;
this.body = body;
this.headers = headers ? headers : {};
this.id = id ? id : Guid_1.CreateNoDashGuid();
}
Object.defineProperty(ConnectionMessage.prototype, "MessageType", {
get: function () {
return this.messageType;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ConnectionMessage.prototype, "Headers", {
get: function () {
return this.headers;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ConnectionMessage.prototype, "Body", {
get: function () {
return this.body;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ConnectionMessage.prototype, "TextBody", {
get: function () {
if (this.messageType === MessageType.Binary) {
throw new Error_1.InvalidOperationError("Not supported for binary message");
}
return this.body;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ConnectionMessage.prototype, "BinaryBody", {
get: function () {
if (this.messageType === MessageType.Text) {
throw new Error_1.InvalidOperationError("Not supported for text message");
}
return this.body;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ConnectionMessage.prototype, "Id", {
get: function () {
return this.id;
},
enumerable: true,
configurable: true
});
return ConnectionMessage;
}());
exports.ConnectionMessage = ConnectionMessage;
/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Error_1 = __webpack_require__(1);
var Guid_1 = __webpack_require__(2);
var EventSource = /** @class */ (function () {
function EventSource(metadata) {
var _this = this;
this.eventListeners = {};
this.isDisposed = false;
this.OnEvent = function (event) {
if (_this.IsDisposed()) {
throw (new Error_1.ObjectDisposedError("EventSource"));
}
if (_this.Metadata) {
for (var paramName in _this.Metadata) {
if (paramName) {
if (event.Metadata) {
if (!event.Metadata[paramName]) {
event.Metadata[paramName] = _this.Metadata[paramName];
}
}
}
}
}
for (var eventId in _this.eventListeners) {
if (eventId && _this.eventListeners[eventId]) {
_this.eventListeners[eventId](event);
}
}
};
this.Attach = function (onEventCallback) {
var id = Guid_1.CreateNoDashGuid();
_this.eventListeners[id] = onEventCallback;
return {
Detach: function () {
delete _this.eventListeners[id];
},
};
};
this.AttachListener = function (listener) {
return _this.Attach(listener.OnEvent);
};
this.IsDisposed = function () {
return _this.isDisposed;
};
this.Dispose = function () {
_this.eventListeners = null;
_this.isDisposed = true;
};
this.metadata = metadata;
}
Object.defineProperty(EventSource.prototype, "Metadata", {
get: function () {
return this.metadata;
},
enumerable: true,
configurable: true
});
return EventSource;
}());
exports.EventSource = EventSource;
/***/ }),
/* 10 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Error_1 = __webpack_require__(1);
var InMemoryStorage = /** @class */ (function () {
function InMemoryStorage() {
var _this = this;
this.store = {};
this.Get = function (key) {
if (!key) {
throw new Error_1.ArgumentNullError("key");
}
return _this.store[key];
};
this.GetOrAdd = function (key, valueToAdd) {
if (!key) {
throw new Error_1.ArgumentNullError("key");
}
if (_this.store[key] === undefined) {
_this.store[key] = valueToAdd;
}
return _this.store[key];
};
this.Set = function (key, value) {
if (!key) {
throw new Error_1.ArgumentNullError("key");
}
_this.store[key] = value;
};
this.Remove = function (key) {
if (!key) {
throw new Error_1.ArgumentNullError("key");
}
if (_this.store[key] !== undefined) {
delete _this.store[key];
}
};
}
return InMemoryStorage;
}());
exports.InMemoryStorage = InMemoryStorage;
/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Error_1 = __webpack_require__(1);
var List = /** @class */ (function () {
function List(list) {
var _this = this;
this.subscriptionIdCounter = 0;
this.addSubscriptions = {};
this.removeSubscriptions = {};
this.disposedSubscriptions = {};
this.disposeReason = null;
this.Get = function (itemIndex) {
_this.ThrowIfDisposed();
return _this.list[itemIndex];
};
this.First = function () {
return _this.Get(0);
};
this.Last = function () {
return _this.Get(_this.Length() - 1);
};
this.Add = function (item) {
_this.ThrowIfDisposed();
_this.InsertAt(_this.list.length, item);
};
this.InsertAt = function (index, item) {
_this.ThrowIfDisposed();
if (index === 0) {
_this.list.unshift(item);
}
else if (index === _this.list.length) {
_this.list.push(item);
}
else {
_this.list.splice(index, 0, item);
}
_this.TriggerSubscriptions(_this.addSubscriptions);
};
this.RemoveFirst = function () {
_this.ThrowIfDisposed();
return _this.RemoveAt(0);
};
this.RemoveLast = function () {
_this.ThrowIfDisposed();
return _this.RemoveAt(_this.Length() - 1);
};
this.RemoveAt = function (index) {
_this.ThrowIfDisposed();
return _this.Remove(index, 1)[0];
};
this.Remove = function (index, count) {
_this.ThrowIfDisposed();
var removedElements = _this.list.splice(index, count);
_this.TriggerSubscriptions(_this.removeSubscriptions);
return removedElements;
};
this.Clear = function () {
_this.ThrowIfDisposed();
_this.Remove(0, _this.Length());
};
this.Length = function () {
_this.ThrowIfDisposed();
return _this.list.length;
};
this.OnAdded = function (addedCallback) {
_this.ThrowIfDisposed();
var subscriptionId = _this.subscriptionIdCounter++;
_this.addSubscriptions[subscriptionId] = addedCallback;
return {
Detach: function () {
delete _this.addSubscriptions[subscriptionId];
},
};
};
this.OnRemoved = function (removedCallback) {
_this.ThrowIfDisposed();
var subscriptionId = _this.subscriptionIdCounter++;
_this.removeSubscriptions[subscriptionId] = removedCallback;
return {
Detach: function () {
delete _this.removeSubscriptions[subscriptionId];
},
};
};
this.OnDisposed = function (disposedCallback) {
_this.ThrowIfDisposed();
var subscriptionId = _this.subscriptionIdCounter++;
_this.disposedSubscriptions[subscriptionId] = disposedCallback;
return {
Detach: function () {
delete _this.disposedSubscriptions[subscriptionId];
},
};
};
this.Join = function (seperator) {
_this.ThrowIfDisposed();
return _this.list.join(seperator);
};
this.ToArray = function () {
var cloneCopy = Array();
_this.list.forEach(function (val) {
cloneCopy.push(val);
});
return cloneCopy;
};
this.Any = function (callback) {
_this.ThrowIfDisposed();
if (callback) {
return _this.Where(callback).Length() > 0;
}
else {
return _this.Length() > 0;
}
};
this.All = function (callback) {
_this.ThrowIfDisposed();
return _this.Where(callback).Length() === _this.Length();
};
this.ForEach = function (callback) {
_this.ThrowIfDisposed();
for (var i = 0; i < _this.Length(); i++) {
callback(_this.list[i], i);
}
};
this.Select = function (callback) {
_this.ThrowIfDisposed();
var selectList = [];
for (var i = 0; i < _this.list.length; i++) {
selectList.push(callback(_this.list[i], i));
}
return new List(selectList);
};
this.Where = function (callback) {
_this.ThrowIfDisposed();
var filteredList = new List();
for (var i = 0; i < _this.list.length; i++) {
if (callback(_this.list[i], i)) {
filteredList.Add(_this.list[i]);
}
}
return filteredList;
};
this.OrderBy = function (compareFn) {
_this.ThrowIfDisposed();
var clonedArray = _this.ToArray();
var orderedArray = clonedArray.sort(compareFn);
return new List(orderedArray);
};
this.OrderByDesc = function (compareFn) {
_this.ThrowIfDisposed();
return _this.OrderBy(function (a, b) { return compareFn(b, a); });
};
this.Clone = function () {
_this.ThrowIfDisposed();
return new List(_this.ToArray());
};
this.Concat = function (list) {
_this.ThrowIfDisposed();
return new List(_this.list.concat(list.ToArray()));
};
this.ConcatArray = function (array) {
_this.ThrowIfDisposed();
return new List(_this.list.concat(array));
};
this.IsDisposed = function () {
return _this.list == null;
};
this.Dispose = function (reason) {
if (!_this.IsDisposed()) {
_this.disposeReason = reason;
_this.list = null;
_this.addSubscriptions = null;
_this.removeSubscriptions = null;
_this.TriggerSubscriptions(_this.disposedSubscriptions);
}
};
this.ThrowIfDisposed = function () {
if (_this.IsDisposed()) {
throw new Error_1.ObjectDisposedError("List", _this.disposeReason);
}
};
this.TriggerSubscriptions = function (subscriptions) {
if (subscriptions) {
for (var subscriptionId in subscriptions) {
if (subscriptionId) {
subscriptions[subscriptionId]();
}
}
}
};
this.list = [];
// copy the list rather than taking as is.
if (list) {
for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
var item = list_1[_i];
this.list.push(item);
}
}
}
return List;
}());
exports.List = List;
/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Error_1 = __webpack_require__(1);
var PromiseState;
(function (PromiseState) {
PromiseState[PromiseState["None"] = 0] = "None";
PromiseState[PromiseState["Resolved"] = 1] = "Resolved";
PromiseState[PromiseState["Rejected"] = 2] = "Rejected";
})(PromiseState = exports.PromiseState || (exports.PromiseState = {}));
var PromiseResult = /** @class */ (function () {
function PromiseResult(promiseResultEventSource) {
var _this = this;
this.ThrowIfError = function () {
if (_this.IsError) {
throw _this.Error;
}
};
promiseResultEventSource.On(function (result) {
if (!_this.isCompleted) {
_this.isCompleted = true;
_this.isError = false;
_this.result = result;
}
}, function (error) {
if (!_this.isCompleted) {
_this.isCompleted = true;
_this.isError = true;
_this.error = error;
}
});
}
Object.defineProperty(PromiseResult.prototype, "IsCompleted", {
get: function () {
return this.isCompleted;
},
enumerable: true,
configurable: true
});
Object.defineProperty(PromiseResult.prototype, "IsError", {
get: function () {
return this.isError;
},
enumerable: true,
configurable: true
});
Object.defineProperty(PromiseResult.prototype, "Error", {
get: function () {
return this.error;
},
enumerable: true,
configurable: true
});
Object.defineProperty(PromiseResult.prototype, "Result", {
get: function () {
return this.result;
},
enumerable: true,
configurable: true
});
return PromiseResult;
}());
exports.PromiseResult = PromiseResult;
// tslint:disable-next-line:max-classes-per-file
var PromiseResultEventSource = /** @class */ (function () {
function PromiseResultEventSource() {
var _this = this;
this.SetResult = function (result) {
_this.onSetResult(result);
};
this.SetError = function (error) {
_this.onSetError(error);
};
this.On = function (onSetResult, onSetError) {
_this.onSetResult = onSetResult;
_this.onSetError = onSetError;
};
}
return PromiseResultEventSource;
}());
exports.PromiseResultEventSource = PromiseResultEventSource;
// tslint:disable-next-line:max-classes-per-file
var PromiseHelper = /** @class */ (function () {
function PromiseHelper() {
}
PromiseHelper.WhenAll = function (promises) {
if (!promises || promises.length === 0) {
throw new Error_1.ArgumentNullError("promises");
}
var deferred = new Deferred();
var errors = [];
var completedPromises = 0;
var checkForCompletion = function () {
completedPromises++;
if (completedPromises === promises.length) {
if (errors.length === 0) {
deferred.Resolve(true);
}
else {
deferred.Reject(errors.join(", "));
}
}
};
for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
var promise = promises_1[_i];
promise.On(function (r) {
checkForCompletion();
}, function (e) {
errors.push(e);
checkForCompletion();
});
}
return deferred.Promise();
};
PromiseHelper.FromResult = function (result) {
var deferred = new Deferred();
deferred.Resolve(result);
return deferred.Promise();
};
PromiseHelper.FromError = function (error) {
var deferred = new Deferred();
deferred.Reject(error);
return deferred.Promise();
};
return PromiseHelper;
}());
exports.PromiseHelper = PromiseHelper;
// TODO: replace with ES6 promises
// tslint:disable-next-line:max-classes-per-file
var Promise = /** @class */ (function () {
function Promise(sink) {
var _this = this;
this.Result = function () {
return _this.sink.Result;
};
this.ContinueWith = function (continuationCallback) {
if (!continuationCallback) {
throw new Error_1.ArgumentNullError("continuationCallback");
}
var continuationDeferral = new Deferred();
_this.sink.on(function (r) {
try {
var continuationResult = continuationCallback(_this.sink.Result);
continuationDeferral.Resolve(continuationResult);
}
catch (e) {
continuationDeferral.Reject("'Unhandled callback error: " + e + "'");
}
}, function (error) {
try {
var continuationResult = continuationCallback(_this.sink.Result);
continuationDeferral.Resolve(continuationResult);
}
catch (e) {
continuationDeferral.Reject("'Unhandled callback error: " + e + ". InnerError: " + error + "'");
}
});
return continuationDeferral.Promise();
};
this.OnSuccessContinueWith = function (continuationCallback) {
if (!continuationCallback) {
throw new Error_1.ArgumentNullError("continuationCallback");
}
var continuationDeferral = new Deferred();
_this.sink.on(function (r) {
try {
var continuationResult = continuationCallback(r);
continuationDeferral.Resolve(continuationResult);
}
catch (e) {
continuationDeferral.Reject("'Unhandled callback error: " + e + "'");
}
}, function (error) {
continuationDeferral.Reject("'Unhandled callback error: " + error + "'");
});
return continuationDeferral.Promise();
};
this.ContinueWithPromise = function (continuationCallback) {
if (!continuationCallback) {
throw new Error_1.ArgumentNullError("continuationCallback");
}
var continuationDeferral = new Deferred();
_this.sink.on(function (r) {
try {
var continuationPromise = continuationCallback(_this.sink.Result);
if (!continuationPromise) {
throw new Error("'Continuation callback did not return promise'");
}
continuationPromise.On(function (continuationResult) {
continuationDeferral.Resolve(continuationResult);
}, function (e) {
continuationDeferral.Reject(e);
});
}
catch (e) {
continuationDeferral.Reject("'Unhandled callback error: " + e + "'");
}
}, function (error) {
try {
var continuationPromise = continuationCallback(_this.sink.Result);
if (!continuationPromise) {
throw new Error("Continuation callback did not return promise");
}
continuationPromise.On(function (continuationResult) {
continuationDeferral.Resolve(continuationResult);
}, function (e) {
continuationDeferral.Reject(e);
});
}
catch (e) {
continuationDeferral.Reject("'Unhandled callback error: " + e + ". InnerError: " + error + "'");
}
});
return continuationDeferral.Promise();
};
this.OnSuccessContinueWithPromise = function (continuationCallback) {
if (!continuationCallback) {
throw new Error_1.ArgumentNullError("continuationCallback");
}
var continuationDeferral = new Deferred();
_this.sink.on(function (r) {
try {
var continuationPromise = continuationCallback(r);
if (!continuationPromise) {
throw new Error("Continuation callback did not return promise");
}
continuationPromise.On(function (continuationResult) {
continuationDeferral.Resolve(continuationResult);
}, function (e) {
continuationDeferral.Reject(e);
});
}
catch (e) {
continuationDeferral.Reject("'Unhandled callback error: " + e + "'");
}
}, function (error) {
continuationDeferral.Reject("'Unhandled callback error: " + error + ".'");
});
return continuationDeferral.Promise();
};
this.On = function (successCallback, errorCallback) {
if (!successCallback) {
throw new Error_1.ArgumentNullError("successCallback");
}
if (!errorCallback) {
throw new Error_1.ArgumentNullError("errorCallback");
}
_this.sink.on(successCallback, errorCallback);
return _this;
};
this.Finally = function (callback) {
if (!callback) {
throw new Error_1.ArgumentNullError("callback");
}
var callbackWrapper = function (_) {
callback();
};
return _this.On(callbackWrapper, callbackWrapper);
};
this.sink = sink;
}
return Promise;
}());
exports.Promise = Promise;
// tslint:disable-next-line:max-classes-per-file
var Deferred = /** @class */ (function () {
function Deferred() {
var _this = this;
this.State = function () {
return _this.sink.State;
};
this.Promise = function () {
return _this.promise;
};
this.Resolve = function (result) {
_this.sink.Resolve(result);
return _this;
};
this.Reject = function (error) {
_this.sink.Reject(error);
return _this;
};
this.sink = new Sink();
this.promise = new Promise(this.sink);
}
return Deferred;
}());
exports.Deferred = Deferred;
// tslint:disable-next-line:max-classes-per-file
var Sink = /** @class */ (function () {
function Sink() {
var _this = this;
this.state = PromiseState.None;
this.promiseResult = null;
this.promiseResultEvents = null;
this.successHandlers = [];
this.errorHandlers = [];
this.Resolve = function (result) {
if (_this.state !== PromiseState.None) {
throw new Error("'Cannot resolve a completed promise'");
}
_this.state = PromiseState.Resolved;
_this.promiseResultEvents.SetResult(result);
for (var i = 0; i < _this.successHandlers.length; i++) {
_this.ExecuteSuccessCallback(result, _this.successHandlers[i], _this.errorHandlers[i]);
}
_this.DetachHandlers();
};
this.Reject = function (error) {
if (_this.state !== PromiseState.None) {
throw new Error("'Cannot reject a completed promise'");
}
_this.state = PromiseState.Rejected;
_this.promiseResultEvents.SetError(error);
for (var _i = 0, _a = _this.errorHandlers; _i < _a.length; _i++) {
var errorHandler = _a[_i];
_this.ExecuteErrorCallback(error, errorHandler);
}
_this.DetachHandlers();
};
this.on = function (successCallback, errorCallback) {
if (successCallback == null) {
successCallback = function (r) { return; };
}
if (_this.state === PromiseState.None) {
_this.successHandlers.push(successCallback);
_this.errorHandlers.push(errorCallback);
}
else {
if (_this.state === PromiseState.Resolved) {
_this.ExecuteSuccessCallback(_this.promiseResult.Result, successCallback, errorCallback);
}