cbcore-ts 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiledScripts/CBCore.d.ts +4 -4
- package/compiledScripts/CBCore.js +2 -1
- package/compiledScripts/CBCore.js.map +2 -2
- package/compiledScripts/CBDataInterfaces.d.ts +4 -4
- package/compiledScripts/CBDataInterfaces.js +1 -0
- package/compiledScripts/CBDataInterfaces.js.map +2 -2
- package/compiledScripts/CBLanguageService.d.ts +4 -4
- package/compiledScripts/CBLanguageService.js +3 -2
- package/compiledScripts/CBLanguageService.js.map +2 -2
- package/compiledScripts/CBServerClient.js +1 -0
- package/compiledScripts/CBServerClient.js.map +2 -2
- package/compiledScripts/CBSocketCallbackHolder.js +4 -1
- package/compiledScripts/CBSocketCallbackHolder.js.map +2 -2
- package/compiledScripts/CBSocketClient.d.ts +1 -1
- package/compiledScripts/CBSocketClient.js +3 -2
- package/compiledScripts/CBSocketClient.js.map +2 -2
- package/compiledScripts/index.js +1 -0
- package/compiledScripts/index.js.map +1 -1
- package/package.json +2 -2
- package/scripts/CBCore.ts +10 -8
- package/scripts/CBDataInterfaces.ts +4 -4
- package/scripts/CBLanguageService.ts +9 -5
- package/scripts/CBServerClient.ts +2 -2
- package/scripts/CBSocketCallbackHolder.ts +10 -12
- package/scripts/CBSocketClient.ts +7 -7
- package/tsconfig.json +5 -3
|
@@ -3,10 +3,10 @@ import { CBLocalizedTextObject, CBUserProfile } from "./CBDataInterfaces";
|
|
|
3
3
|
import { CBServerClient } from "./CBServerClient";
|
|
4
4
|
import { CBSocketClient } from "./CBSocketClient";
|
|
5
5
|
declare interface CBDialogViewShower {
|
|
6
|
-
alert(text: string, dismissCallback?: Function):
|
|
7
|
-
localizedAlert(textObject: CBLocalizedTextObject, dismissCallback?: Function):
|
|
8
|
-
showActionIndicatorDialog(message: string, dismissCallback?: Function):
|
|
9
|
-
hideActionIndicatorDialog():
|
|
6
|
+
alert(text: string, dismissCallback?: Function): void;
|
|
7
|
+
localizedAlert(textObject: CBLocalizedTextObject, dismissCallback?: Function): void;
|
|
8
|
+
showActionIndicatorDialog(message: string, dismissCallback?: Function): void;
|
|
9
|
+
hideActionIndicatorDialog(): void;
|
|
10
10
|
}
|
|
11
11
|
export declare class CBCore extends UIObject {
|
|
12
12
|
private static _sharedInstance;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -105,7 +106,7 @@ const _CBCore = class extends import_uicore_ts.UIObject {
|
|
|
105
106
|
return result;
|
|
106
107
|
}
|
|
107
108
|
get userProfile() {
|
|
108
|
-
|
|
109
|
+
let result = import_uicore_ts.nil;
|
|
109
110
|
try {
|
|
110
111
|
result = JSON.parse(localStorage.getItem("CBUserProfile"));
|
|
111
112
|
} catch (error) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/CBCore.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n FIRST,\n FIRST_OR_NIL,\n IS,\n IS_NOT,\n nil,\n UICore,\n UILink,\n UIObject,\n UIRoute,\n UIViewBroadcastEvent,\n YES\n} from \"../../uicore-ts\"\nimport { CBLanguageService } from \"./CBLanguageService\"\nimport { CBLocalizedTextObject, CBUserProfile } from \"./CBDataInterfaces\"\nimport { CBServerClient } from \"./CBServerClient\"\nimport { CBSocketClient } from \"./CBSocketClient\"\n\n\ndeclare interface CBDialogViewShower {\n \n alert(text: string, dismissCallback?: Function)\n localizedAlert(textObject: CBLocalizedTextObject, dismissCallback?: Function)\n \n showActionIndicatorDialog(message: string, dismissCallback?: Function)\n hideActionIndicatorDialog()\n \n}\n\ndeclare const CBCoreInitializerObject: any\n\n\nexport class CBCore extends UIObject {\n \n private static _sharedInstance: CBCore\n \n viewCores: UICore[] = []\n \n _isUserLoggedIn: boolean = nil\n _cachedMinimizedChatInquiryIDs: string[] = nil\n _socketClient: CBSocketClient = new CBSocketClient(this)\n _serverClient: CBServerClient = new CBServerClient(this)\n \n _functionsToCallForEachSocketClient: (() => void)[] = []\n \n _models: any[] = []\n \n dialogViewShowerClass: CBDialogViewShower = nil\n \n constructor() {\n \n super()\n \n if (CBCoreInitializerObject) {\n \n CBLanguageService.useStoredLanguageValues(CBCoreInitializerObject.languageValues)\n \n }\n \n \n window.addEventListener(\"storage\", function (this: CBCore, event: StorageEvent) {\n \n if (event.newValue == event.oldValue) {\n \n return\n \n }\n \n //console.log(\"\" + event.key + \" changed to \" + event.newValue + \" from \" + event.oldValue);\n \n \n \n if (event.key == \"CBLanguageKey\") {\n \n this.didSetLanguageKey()\n \n }\n \n }.bind(this))\n \n \n //this.checkIfUserIsAuthenticated();\n \n this.didSetLanguageKey()\n \n \n }\n \n \n static initIfNeededWithViewCore(viewCore: UICore) {\n \n CBCore.sharedInstance.viewCores.push(viewCore);\n \n }\n \n \n \n static get sharedInstance() {\n if (!CBCore._sharedInstance) {\n CBCore._sharedInstance = new CBCore()\n }\n return CBCore._sharedInstance\n }\n \n \n \n \n \n static broadcastEventName = {\n \n \"userDidLogIn\": \"UserDidLogIn\",\n \"userDidLogOut\": \"UserDidLogOut\"\n \n }\n \n broadcastMessageInRootViewTree(message: UIViewBroadcastEvent) {\n \n this.viewCores.everyElement.rootViewController.view.broadcastEventInSubtree(message)\n \n }\n \n \n \n \n \n get socketClient() {\n return this._socketClient\n }\n \n get serverClient() {\n return this._serverClient\n }\n \n \n \n \n \n set isUserLoggedIn(isUserLoggedIn: boolean) {\n \n const previousValue = this.isUserLoggedIn\n \n \n localStorage.setItem(\"CBIsUserLoggedIn\", \"\" + isUserLoggedIn)\n \n \n //this._isUserLoggedIn = isUserLoggedIn;\n \n this.didSetIsUserLoggedIn(previousValue)\n \n }\n \n didSetIsUserLoggedIn(previousValue: boolean) {\n \n const isUserLoggedIn = this.isUserLoggedIn\n \n if (isUserLoggedIn && previousValue != isUserLoggedIn) {\n \n // Send message to views\n \n this.broadcastMessageInRootViewTree({\n \n name: CBCore.broadcastEventName.userDidLogIn,\n parameters: nil\n \n })\n \n this.updateLinkTargets()\n \n \n }\n else if (previousValue != isUserLoggedIn) {\n \n \n this.performFunctionWithDelay(0.01, function (this: CBCore) {\n \n UIRoute.currentRoute.routeByRemovingComponentsOtherThanOnesNamed([\n \n \"settings\",\n \"inquiry\"\n \n ]).apply()\n \n this.broadcastMessageInRootViewTree({\n \n name: CBCore.broadcastEventName.userDidLogOut,\n parameters: nil\n \n })\n \n this.updateLinkTargets()\n \n \n }.bind(this))\n \n }\n \n \n }\n \n private updateLinkTargets() {\n \n this.viewCores.everyElement.rootViewController.view.forEachViewInSubtree(function (view) {\n if (view instanceof UILink) {\n view.updateTarget()\n }\n })\n \n }\n \n get isUserLoggedIn() {\n \n const result = (localStorage.getItem(\"CBIsUserLoggedIn\") == \"true\")\n \n return result\n \n }\n \n \n \n get userProfile() {\n
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import {\n FIRST,\n FIRST_OR_NIL,\n IS,\n IS_NOT,\n nil,\n UICore,\n UILink,\n UIObject,\n UIRoute,\n UIViewBroadcastEvent,\n YES\n} from \"../../uicore-ts\"\nimport { CBLanguageService } from \"./CBLanguageService\"\nimport { CBLocalizedTextObject, CBUserProfile } from \"./CBDataInterfaces\"\nimport { CBServerClient } from \"./CBServerClient\"\nimport { CBSocketClient } from \"./CBSocketClient\"\n\n\ndeclare interface CBDialogViewShower {\n \n alert(text: string, dismissCallback?: Function): void\n localizedAlert(textObject: CBLocalizedTextObject, dismissCallback?: Function): void\n \n showActionIndicatorDialog(message: string, dismissCallback?: Function): void\n hideActionIndicatorDialog(): void\n \n}\n\ndeclare const CBCoreInitializerObject: any\n\n\nexport class CBCore extends UIObject {\n \n private static _sharedInstance: CBCore\n \n viewCores: UICore[] = []\n \n _isUserLoggedIn: boolean = nil\n _cachedMinimizedChatInquiryIDs: string[] = nil\n _socketClient: CBSocketClient = new CBSocketClient(this)\n _serverClient: CBServerClient = new CBServerClient(this)\n \n _functionsToCallForEachSocketClient: (() => void)[] = []\n \n _models: any[] = []\n \n dialogViewShowerClass: CBDialogViewShower = nil\n \n constructor() {\n \n super()\n \n if (CBCoreInitializerObject) {\n \n CBLanguageService.useStoredLanguageValues(CBCoreInitializerObject.languageValues)\n \n }\n \n \n window.addEventListener(\"storage\", function (this: CBCore, event: StorageEvent) {\n \n if (event.newValue == event.oldValue) {\n \n return\n \n }\n \n //console.log(\"\" + event.key + \" changed to \" + event.newValue + \" from \" + event.oldValue);\n \n \n \n if (event.key == \"CBLanguageKey\") {\n \n this.didSetLanguageKey()\n \n }\n \n }.bind(this))\n \n \n //this.checkIfUserIsAuthenticated();\n \n this.didSetLanguageKey()\n \n \n }\n \n \n static initIfNeededWithViewCore(viewCore: UICore) {\n \n CBCore.sharedInstance.viewCores.push(viewCore);\n \n }\n \n \n \n static get sharedInstance() {\n if (!CBCore._sharedInstance) {\n CBCore._sharedInstance = new CBCore()\n }\n return CBCore._sharedInstance\n }\n \n \n \n \n \n static broadcastEventName = {\n \n \"userDidLogIn\": \"UserDidLogIn\",\n \"userDidLogOut\": \"UserDidLogOut\"\n \n }\n \n broadcastMessageInRootViewTree(message: UIViewBroadcastEvent) {\n \n this.viewCores.everyElement.rootViewController.view.broadcastEventInSubtree(message)\n \n }\n \n \n \n \n \n get socketClient() {\n return this._socketClient\n }\n \n get serverClient() {\n return this._serverClient\n }\n \n \n \n \n \n set isUserLoggedIn(isUserLoggedIn: boolean) {\n \n const previousValue = this.isUserLoggedIn\n \n \n localStorage.setItem(\"CBIsUserLoggedIn\", \"\" + isUserLoggedIn)\n \n \n //this._isUserLoggedIn = isUserLoggedIn;\n \n this.didSetIsUserLoggedIn(previousValue)\n \n }\n \n didSetIsUserLoggedIn(previousValue: boolean) {\n \n const isUserLoggedIn = this.isUserLoggedIn\n \n if (isUserLoggedIn && previousValue != isUserLoggedIn) {\n \n // Send message to views\n \n this.broadcastMessageInRootViewTree({\n \n name: CBCore.broadcastEventName.userDidLogIn,\n parameters: nil\n \n })\n \n this.updateLinkTargets()\n \n \n }\n else if (previousValue != isUserLoggedIn) {\n \n \n this.performFunctionWithDelay(0.01, function (this: CBCore) {\n \n UIRoute.currentRoute.routeByRemovingComponentsOtherThanOnesNamed([\n \n \"settings\",\n \"inquiry\"\n \n ]).apply()\n \n this.broadcastMessageInRootViewTree({\n \n name: CBCore.broadcastEventName.userDidLogOut,\n parameters: nil\n \n })\n \n this.updateLinkTargets()\n \n \n }.bind(this))\n \n }\n \n \n }\n \n private updateLinkTargets() {\n \n this.viewCores.everyElement.rootViewController.view.forEachViewInSubtree(function (view) {\n if (view instanceof UILink) {\n view.updateTarget()\n }\n })\n \n }\n \n get isUserLoggedIn() {\n \n const result = (localStorage.getItem(\"CBIsUserLoggedIn\") == \"true\")\n \n return result\n \n }\n \n \n \n get userProfile() {\n \n let result = nil\n \n \n try {\n // @ts-ignore\n result = JSON.parse(localStorage.getItem(\"CBUserProfile\"))\n } catch (error) {\n \n }\n \n // if (IS_NOT(result)) {\n \n // // Get userID from inquiryAccessKey if possible\n // var inquiryKey = this.inquiryAccessKey;\n \n // if (IS(inquiryKey)) {\n \n // result = FIRST_OR_NIL(this.inquiriesModel.inquiriesByCurrentUser.firstElement).inquirer\n \n // }\n \n // }\n \n return FIRST_OR_NIL(result)\n \n }\n \n set userProfile(userProfile: CBUserProfile) {\n \n if (IS_NOT(userProfile)) {\n \n localStorage.removeItem(\"CBUserProfile\")\n \n }\n \n localStorage.setItem(\"CBUserProfile\", JSON.stringify(userProfile))\n \n this.didSetUserProfile()\n \n }\n \n didSetUserProfile() {\n \n this.isUserLoggedIn = IS(this.userProfile)\n \n }\n \n \n set languageKey(languageKey: string) {\n \n if (IS_NOT(languageKey)) {\n \n localStorage.removeItem(\"CBLanguageKey\")\n \n }\n \n localStorage.setItem(\"CBLanguageKey\", JSON.stringify(languageKey))\n \n this.didSetLanguageKey()\n \n }\n \n get languageKey() {\n \n const result = FIRST(localStorage.getItem(\"CBLanguageKey\"), CBLanguageService.defaultLanguageKey).replace(\n \"\\\"\",\n \"\"\n ).replace(\"\\\"\", \"\")\n \n \n return result\n \n }\n \n didSetLanguageKey() {\n \n UIRoute.currentRoute.routeWithComponent(\n \"settings\",\n { \"language\": this.languageKey },\n YES\n ).applyByReplacingCurrentRouteInHistory()\n \n }\n \n \n get externalServiceIdentifier(): { accessKey: string; serviceID: string; organizationID: string } {\n \n // @ts-ignore\n const result = JSON.parse(localStorage.getItem(\"CBExternalServiceIdentifier\"))\n \n return result\n \n }\n \n set externalServiceIdentifier(externalServiceIdentifier: { accessKey: string; serviceID: string; organizationID: string }) {\n \n localStorage.setItem(\"CBExternalServiceIdentifier\", JSON.stringify(externalServiceIdentifier))\n \n }\n \n \n reloadSocketConnection() {\n \n // @ts-ignore\n this.socketClient.socket.disconnect()\n \n const messagesToBeSent = this.socketClient._messagesToBeSent.filter(function (messageItem, index, array) {\n \n return (!messageItem.isBoundToUserWithID || messageItem.isBoundToUserWithID ==\n CBCore.sharedInstance.userProfile._id)\n \n })\n \n this._socketClient = new CBSocketClient(this)\n this._socketClient._messagesToBeSent = messagesToBeSent\n \n const socketClient = this._socketClient\n \n this._models.forEach(function (model, index, array) {\n \n model.setSocketClient(socketClient)\n \n })\n \n this._functionsToCallForEachSocketClient.forEach(function (functionToCall, index, array) {\n \n functionToCall()\n \n })\n \n \n \n }\n \n \n callFunctionForEachSocketClient(functionToCall: () => void) {\n this._functionsToCallForEachSocketClient.push(functionToCall)\n functionToCall()\n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAYO;AACP,+BAAkC;AAElC,4BAA+B;AA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A1UO,IAAM,SAAN;AAAM,OA4EF,qBAAqB;AAAA,EAExB,gBAAgB;AAAA,EAChB,iBAAiB;AAErB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -124,10 +124,10 @@ export declare type CBSocketMultipleMessagecompletionFunction = (responseMessage
|
|
|
124
124
|
export interface CBSocketMessageSendResponseFunction<ResponseMessageType = any> extends CBSocketMessageSendResponseFunctionBase<ResponseMessageType> {
|
|
125
125
|
respondingToMainResponse: boolean;
|
|
126
126
|
excludeMessageFromAutomaticConnectionEvents: () => void;
|
|
127
|
-
setResponseValidityDuration(duration: number):
|
|
128
|
-
useStoredResponseWithErrorResponse():
|
|
129
|
-
sendErrorResponse(message?: any, completion?: CBSocketMessageCompletionFunction):
|
|
130
|
-
sendIntermediateResponse(updateMessage: any, completion?: CBSocketMessageCompletionFunction):
|
|
127
|
+
setResponseValidityDuration(duration: number): void;
|
|
128
|
+
useStoredResponseWithErrorResponse(): void;
|
|
129
|
+
sendErrorResponse(message?: any, completion?: CBSocketMessageCompletionFunction): void;
|
|
130
|
+
sendIntermediateResponse(updateMessage: any, completion?: CBSocketMessageCompletionFunction): void;
|
|
131
131
|
confirmStoredResponseHash(responseHash: string, completion?: CBSocketMessageCompletionFunction): boolean;
|
|
132
132
|
}
|
|
133
133
|
export interface CBSocketHandshakeInitMessage {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/CBDataInterfaces.ts"],
|
|
4
|
-
"sourcesContent": ["\n\n\n\n\nexport type CBReferenceID = string;\n\n\nexport interface CBLanguageItem {\n \n value: string;\n languageKey: string;\n itemKey: string;\n \n}\n\n\nexport interface LanguagesData {\n [key: string]: {\n [key: string]: string;\n };\n}\n\n\n\n\n\nexport interface CBFinancialAmount {\n \n amount: number;\n currency: string;\n \n}\n\n\nexport interface CBLocalizedTextObject {\n \n [key: string]: string\n \n}\n\n\nexport interface CBDropdownData<T> {\n \n _id: CBReferenceID;\n name?: CBLocalizedTextObject;\n dropdownCode: string;\n data: CBDropdownDataItem<T>[];\n \n}\n\n\nexport interface CBDropdownDataItem<T> {\n \n _id: CBReferenceID;\n title: CBLocalizedTextObject;\n rowsData?: CBDropdownDataItem<T>[]\n isADropdownDataSection: boolean;\n isADropdownDataRow: boolean;\n \n attachedObject: T\n \n itemCode: string;\n dropdownCode: string;\n \n}\n\n\n\n\n\n\n\nexport interface CBFileAccessor {\n \n fileData: CBFileData;\n createdAt: number;\n \n}\n\n\nexport interface CBFileData {\n \n _id: string;\n \n name: string;\n dataURL: string;\n type: string;\n isLimitedAccess?: boolean;\n accessibleToUsers?: CBUserProfilePublic[];\n \n}\n\nexport enum CBAuthenticationSource {\n \n google = 10,\n facebook = 11,\n emailAccessLink = 200,\n password = 220,\n inquiryAccessLink = 500\n \n}\n\n// AsdAsd\n\nexport interface CBCoreInitializer {\n \n languageValues: LanguagesData;\n defaultLanguageKey: string;\n \n}\n\nexport interface CBLoginKey {\n \n key: string;\n \n accessToken: string;\n \n storeAccessTokenInClient: boolean;\n \n authenticationSource: CBAuthenticationSource;\n \n userID: CBReferenceID;\n \n isValid: boolean;\n \n loginDate?: Date;\n logoutDate?: Date;\n \n createdAt: Date;\n updatedAt: Date;\n \n}\n\nexport interface CBUserPassword {\n \n passwordHash: string;\n \n userID: CBReferenceID;\n \n isValid: boolean;\n \n createdAt: Date;\n updatedAt: Date;\n \n}\n\nexport interface CBAdministratorRightsDescriptor {\n \n userProfile: CBUserProfile;\n \n}\n\nexport interface CBSubscription {\n \n _id: CBReferenceID;\n startDate: Date;\n endDate?: Date;\n \n isIndefinite: boolean;\n \n subscriptionKind: number;// alternatiiv oleks string/objectId, mis viitaks t\u00FC\u00FCbi objektile eraldi tabelis\n createdAt: Date;\n updatedAt: Date;\n \n}\n\n//Asdasd\n\nexport type CBUserProfilePublic = any;\nexport type CBUserProfile = any;\n\n\nexport interface SocketClientInterface {\n \n [x: string]: SocketClientFunction<any, any>;\n \n}\n\n\nexport interface SocketClientResult<ResultType> {\n \n responseMessage: any;\n result: ResultType;\n errorResult: any;\n respondWithMessage: CBSocketMessageSendResponseFunction;\n \n}\n\n\nexport type SocketClientFunction<MessageType, ResultType> = (\n messageData: MessageType,\n completionPolicy?: string,\n isUserBound?: boolean\n) => Promise<SocketClientResult<ResultType>>;\n\nexport type SocketClientNoMessageFunction<ResultType> = (\n messageData?: null,\n completionPolicy?: string,\n isUserBound?: boolean\n) => Promise<SocketClientResult<ResultType>>;\n\n\n\n\n\nexport interface CBSocketMultipleMessageObject<MessageDataType = any> {\n \n key: string;\n message: CBSocketMessage<MessageDataType>;\n \n}\n\n\n// CBSocket communication messages\nexport interface CBSocketMessage<MessageDataType = any> {\n \n identifier: string;\n inResponseToIdentifier?: string;\n keepWaitingForResponses?: boolean;\n \n messageData: MessageDataType;\n \n // This is sent from client to server with requests\n storedResponseHash?: string;\n \n // This is always present on messages sent from the server side\n messageDataHash?: string;\n \n // This tells the client to store this message for future use\n canBeStoredAsResponse?: boolean;\n \n // This tells the client to use the previously stored response\n useStoredResponse?: boolean;\n \n // This tells the client that the response is valid for at least this long in ms\n responseValidityDuration?: number;\n \n}\n\n\nexport interface CBSocketMultipleMessage extends CBSocketMessage<CBSocketMultipleMessageObject[]> {\n \n shouldGroupResponses: boolean;\n \n}\n\n\nexport type CBSocketMessageSendResponseFunctionBase<ResponseMessageType> = (\n responseMessage: ResponseMessageType,\n completion?: CBSocketMessageCompletionFunction\n) => Promise<string>;\n\nexport type CBSocketMessageCompletionFunction = (\n responseMessage: any,\n respondWithMessage: CBSocketMessageSendResponseFunction\n) => void;\nexport type CBSocketMessageHandlerFunction<ResponseMessageType = any> = (\n message: any,\n respondWithMessage: CBSocketMessageSendResponseFunction<ResponseMessageType>\n) => void;\n\nexport type CBSocketMultipleMessagecompletionFunction = (\n responseMessages: any[],\n callcompletionFunctions: () => void\n) => void;\n\n\nexport interface CBSocketMessageSendResponseFunction<ResponseMessageType = any> extends CBSocketMessageSendResponseFunctionBase<ResponseMessageType> {\n respondingToMainResponse: boolean;\n \n excludeMessageFromAutomaticConnectionEvents: () => void;\n \n setResponseValidityDuration(duration: number);\n \n useStoredResponseWithErrorResponse();\n \n sendErrorResponse(message?: any, completion?: CBSocketMessageCompletionFunction);\n \n sendIntermediateResponse(updateMessage: any, completion?: CBSocketMessageCompletionFunction);\n \n // This tells the client to use the stored response if responseHash matches and also enables storing of responses\n // in the client in the first place. Returns true if the hash matched.\n confirmStoredResponseHash(responseHash: string, completion?: CBSocketMessageCompletionFunction): boolean;\n \n}\n\n\n\n// Socket handshake messages\nexport interface CBSocketHandshakeInitMessage {\n \n accessToken?: string;\n userID: CBReferenceID;\n \n loginKey?: string;\n inquiryAccessKey?: string;\n \n instanceIdentifier: string;\n \n}\n\n\nexport interface CBSocketHandshakeResponseMessage {\n \n accepted: boolean;\n \n userProfile?: CBUserProfile;\n \n}\n\n\n\n\n\nexport type TypeWithoutKey<Type, Key> = Pick<Type, Exclude<keyof Type, Key>>;\n\nexport type TypeWithoutID<Type> = TypeWithoutKey<Type, \"_id\">;\n\nexport type Diff<T extends keyof any, U extends keyof any> =\n ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T];\n\nexport type Overwrite<T, U> = Pick<T, Diff<keyof T, keyof U>> & U;\n\nexport type RecursivePartial<T> = {\n [P in keyof T]?:\n T[P] extends (infer U)[] ? RecursivePartial<U>[] :\n T[P] extends object ? RecursivePartial<T[P]> :\n T[P];\n};\n\n\n\n\n\n\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["\n\n\n\n\nexport type CBReferenceID = string;\n\n\nexport interface CBLanguageItem {\n \n value: string;\n languageKey: string;\n itemKey: string;\n \n}\n\n\nexport interface LanguagesData {\n [key: string]: {\n [key: string]: string;\n };\n}\n\n\n\n\n\nexport interface CBFinancialAmount {\n \n amount: number;\n currency: string;\n \n}\n\n\nexport interface CBLocalizedTextObject {\n \n [key: string]: string\n \n}\n\n\nexport interface CBDropdownData<T> {\n \n _id: CBReferenceID;\n name?: CBLocalizedTextObject;\n dropdownCode: string;\n data: CBDropdownDataItem<T>[];\n \n}\n\n\nexport interface CBDropdownDataItem<T> {\n \n _id: CBReferenceID;\n title: CBLocalizedTextObject;\n rowsData?: CBDropdownDataItem<T>[]\n isADropdownDataSection: boolean;\n isADropdownDataRow: boolean;\n \n attachedObject: T\n \n itemCode: string;\n dropdownCode: string;\n \n}\n\n\n\n\n\n\n\nexport interface CBFileAccessor {\n \n fileData: CBFileData;\n createdAt: number;\n \n}\n\n\nexport interface CBFileData {\n \n _id: string;\n \n name: string;\n dataURL: string;\n type: string;\n isLimitedAccess?: boolean;\n accessibleToUsers?: CBUserProfilePublic[];\n \n}\n\nexport enum CBAuthenticationSource {\n \n google = 10,\n facebook = 11,\n emailAccessLink = 200,\n password = 220,\n inquiryAccessLink = 500\n \n}\n\n// AsdAsd\n\nexport interface CBCoreInitializer {\n \n languageValues: LanguagesData;\n defaultLanguageKey: string;\n \n}\n\nexport interface CBLoginKey {\n \n key: string;\n \n accessToken: string;\n \n storeAccessTokenInClient: boolean;\n \n authenticationSource: CBAuthenticationSource;\n \n userID: CBReferenceID;\n \n isValid: boolean;\n \n loginDate?: Date;\n logoutDate?: Date;\n \n createdAt: Date;\n updatedAt: Date;\n \n}\n\nexport interface CBUserPassword {\n \n passwordHash: string;\n \n userID: CBReferenceID;\n \n isValid: boolean;\n \n createdAt: Date;\n updatedAt: Date;\n \n}\n\nexport interface CBAdministratorRightsDescriptor {\n \n userProfile: CBUserProfile;\n \n}\n\nexport interface CBSubscription {\n \n _id: CBReferenceID;\n startDate: Date;\n endDate?: Date;\n \n isIndefinite: boolean;\n \n subscriptionKind: number;// alternatiiv oleks string/objectId, mis viitaks t\u00FC\u00FCbi objektile eraldi tabelis\n createdAt: Date;\n updatedAt: Date;\n \n}\n\n//Asdasd\n\nexport type CBUserProfilePublic = any;\nexport type CBUserProfile = any;\n\n\nexport interface SocketClientInterface {\n \n [x: string]: SocketClientFunction<any, any>;\n \n}\n\n\nexport interface SocketClientResult<ResultType> {\n \n responseMessage: any;\n result: ResultType;\n errorResult: any;\n respondWithMessage: CBSocketMessageSendResponseFunction;\n \n}\n\n\nexport type SocketClientFunction<MessageType, ResultType> = (\n messageData: MessageType,\n completionPolicy?: string,\n isUserBound?: boolean\n) => Promise<SocketClientResult<ResultType>>;\n\nexport type SocketClientNoMessageFunction<ResultType> = (\n messageData?: null,\n completionPolicy?: string,\n isUserBound?: boolean\n) => Promise<SocketClientResult<ResultType>>;\n\n\n\n\n\nexport interface CBSocketMultipleMessageObject<MessageDataType = any> {\n \n key: string;\n message: CBSocketMessage<MessageDataType>;\n \n}\n\n\n// CBSocket communication messages\nexport interface CBSocketMessage<MessageDataType = any> {\n \n identifier: string;\n inResponseToIdentifier?: string;\n keepWaitingForResponses?: boolean;\n \n messageData: MessageDataType;\n \n // This is sent from client to server with requests\n storedResponseHash?: string;\n \n // This is always present on messages sent from the server side\n messageDataHash?: string;\n \n // This tells the client to store this message for future use\n canBeStoredAsResponse?: boolean;\n \n // This tells the client to use the previously stored response\n useStoredResponse?: boolean;\n \n // This tells the client that the response is valid for at least this long in ms\n responseValidityDuration?: number;\n \n}\n\n\nexport interface CBSocketMultipleMessage extends CBSocketMessage<CBSocketMultipleMessageObject[]> {\n \n shouldGroupResponses: boolean;\n \n}\n\n\nexport type CBSocketMessageSendResponseFunctionBase<ResponseMessageType> = (\n responseMessage: ResponseMessageType,\n completion?: CBSocketMessageCompletionFunction\n) => Promise<string>;\n\nexport type CBSocketMessageCompletionFunction = (\n responseMessage: any,\n respondWithMessage: CBSocketMessageSendResponseFunction\n) => void;\nexport type CBSocketMessageHandlerFunction<ResponseMessageType = any> = (\n message: any,\n respondWithMessage: CBSocketMessageSendResponseFunction<ResponseMessageType>\n) => void;\n\nexport type CBSocketMultipleMessagecompletionFunction = (\n responseMessages: any[],\n callcompletionFunctions: () => void\n) => void;\n\n\nexport interface CBSocketMessageSendResponseFunction<ResponseMessageType = any> extends CBSocketMessageSendResponseFunctionBase<ResponseMessageType> {\n respondingToMainResponse: boolean;\n \n excludeMessageFromAutomaticConnectionEvents: () => void;\n \n setResponseValidityDuration(duration: number): void;\n \n useStoredResponseWithErrorResponse(): void;\n \n sendErrorResponse(message?: any, completion?: CBSocketMessageCompletionFunction): void;\n \n sendIntermediateResponse(updateMessage: any, completion?: CBSocketMessageCompletionFunction): void;\n \n // This tells the client to use the stored response if responseHash matches and also enables storing of responses\n // in the client in the first place. Returns true if the hash matched.\n confirmStoredResponseHash(responseHash: string, completion?: CBSocketMessageCompletionFunction): boolean;\n \n}\n\n\n\n// Socket handshake messages\nexport interface CBSocketHandshakeInitMessage {\n \n accessToken?: string;\n userID: CBReferenceID;\n \n loginKey?: string;\n inquiryAccessKey?: string;\n \n instanceIdentifier: string;\n \n}\n\n\nexport interface CBSocketHandshakeResponseMessage {\n \n accepted: boolean;\n \n userProfile?: CBUserProfile;\n \n}\n\n\n\n\n\nexport type TypeWithoutKey<Type, Key> = Pick<Type, Exclude<keyof Type, Key>>;\n\nexport type TypeWithoutID<Type> = TypeWithoutKey<Type, \"_id\">;\n\nexport type Diff<T extends keyof any, U extends keyof any> =\n ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T];\n\nexport type Overwrite<T, U> = Pick<T, Diff<keyof T, keyof U>> & U;\n\nexport type RecursivePartial<T> = {\n [P in keyof T]?:\n T[P] extends (infer U)[] ? RecursivePartial<U>[] :\n T[P] extends object ? RecursivePartial<T[P]> :\n T[P];\n};\n\n\n\n\n\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6FO,IAAK,yBAAL,kBAAKA,4BAAL;AAEH,EAAAA,gDAAA,YAAS,MAAT;AACA,EAAAA,gDAAA,cAAW,MAAX;AACA,EAAAA,gDAAA,qBAAkB,OAAlB;AACA,EAAAA,gDAAA,cAAW,OAAX;AACA,EAAAA,gDAAA,uBAAoB,OAApB;AANQ,SAAAA;AAAA,GAAA;",
|
|
6
6
|
"names": ["CBAuthenticationSource"]
|
|
7
7
|
}
|
|
@@ -26,10 +26,10 @@ export declare class CBLanguageService implements UILanguageService {
|
|
|
26
26
|
get currentLanguageKey(): string;
|
|
27
27
|
static stringForKey(key: string, languageKey: string, defaultString: string, parameters?: {
|
|
28
28
|
[x: string]: string | UILocalizedTextObject;
|
|
29
|
-
}):
|
|
29
|
+
}): string;
|
|
30
30
|
stringForKey(key: string, languageKey: string, defaultString: string, parameters?: {
|
|
31
31
|
[x: string]: string | UILocalizedTextObject;
|
|
32
|
-
}):
|
|
32
|
+
}): string;
|
|
33
33
|
static localizedTextObjectForKey(key: string, defaultString?: string, parameters?: {
|
|
34
34
|
[x: string]: string | UILocalizedTextObject;
|
|
35
35
|
}): {};
|
|
@@ -38,6 +38,6 @@ export declare class CBLanguageService implements UILanguageService {
|
|
|
38
38
|
}): {};
|
|
39
39
|
static localizedTextObjectForText(text: string): any;
|
|
40
40
|
localizedTextObjectForText(text: string): any;
|
|
41
|
-
static stringForCurrentLanguage(localizedTextObject: CBLocalizedTextObject | string):
|
|
42
|
-
stringForCurrentLanguage(localizedTextObject: CBLocalizedTextObject):
|
|
41
|
+
static stringForCurrentLanguage(localizedTextObject: CBLocalizedTextObject | string): string;
|
|
42
|
+
stringForCurrentLanguage(localizedTextObject: CBLocalizedTextObject): string;
|
|
43
43
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -34,7 +35,7 @@ const _CBLanguageService = class {
|
|
|
34
35
|
}
|
|
35
36
|
static broadcastLanguageChangeEvent(view) {
|
|
36
37
|
view = view || import_CBCore.CBCore.sharedInstance.viewCores.everyElement.rootViewController.view.rootView;
|
|
37
|
-
view.broadcastEventInSubtree({
|
|
38
|
+
view == null ? void 0 : view.broadcastEventInSubtree({
|
|
38
39
|
name: import_uicore_ts.UIView.broadcastEventName.LanguageChanged,
|
|
39
40
|
parameters: {}
|
|
40
41
|
});
|
|
@@ -125,7 +126,7 @@ const _CBLanguageService = class {
|
|
|
125
126
|
return localizedTextObject;
|
|
126
127
|
}
|
|
127
128
|
localizedTextObject = (0, import_uicore_ts.FIRST_OR_NIL)(localizedTextObject);
|
|
128
|
-
|
|
129
|
+
let result = localizedTextObject[_CBLanguageService.currentLanguageKey];
|
|
129
130
|
if ((0, import_uicore_ts.IS_NOT)(result)) {
|
|
130
131
|
result = localizedTextObject[_CBLanguageService.defaultLanguageKey];
|
|
131
132
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/CBLanguageService.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n FIRST_OR_NIL,\n IS,\n IS_DEFINED,\n IS_NOT,\n nil,\n UICore,\n UILanguageService,\n UILocalizedTextObject,\n UIRoute,\n UIView\n} from \"uicore-ts\"\nimport { CBCore } from \"./CBCore\"\nimport { CBLocalizedTextObject } from \"./CBDataInterfaces\"\n\n\nexport interface ParticularLanguageValues {\n \n [x: string]: string\n \n topBarTitle: string;\n selectLanguageTitle: string;\n languageNameShort: string;\n leftBarTitle: string;\n languageName: string\n \n}\n\n\nexport interface LanguageValues {\n \n [x: string]: ParticularLanguageValues\n \n en: ParticularLanguageValues\n est: ParticularLanguageValues\n \n}\n\n\nexport class CBLanguageService implements UILanguageService {\n \n static _currentLanguageKey: string\n \n static languageValues: LanguageValues = {\n \n en: {\n \n languageName: \"English\",\n languageNameShort: \"ENG\",\n \n topBarTitle: \"UICore application\",\n \n selectLanguageTitle: \"Select language\",\n leftBarTitle: \"Title\"\n \n \n },\n est: {\n \n languageName: \"Eesti keel\",\n languageNameShort: \"EST\",\n \n topBarTitle: \"UICore rakendus\",\n \n selectLanguageTitle: \"Vali keel\",\n leftBarTitle: \"Pealkiri\"\n \n \n }\n \n \n \n \n }\n \n static languages = JSON.parse(JSON.stringify(CBLanguageService.languageValues))\n \n static useStoredLanguageValues(values = {}) {\n \n const result = JSON.parse(JSON.stringify(CBLanguageService.languageValues))\n .objectByCopyingValuesRecursivelyFromObject(\n values) as any\n \n if (JSON.stringify(result) != JSON.stringify(CBLanguageService.languages)) {\n \n CBLanguageService.languages = result\n \n CBLanguageService.broadcastLanguageChangeEvent()\n \n }\n \n }\n \n \n static broadcastLanguageChangeEvent(view?: UIView) {\n \n view = view as any || CBCore.sharedInstance.viewCores.everyElement.rootViewController.view.rootView as any\n \n view
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import {\n FIRST_OR_NIL,\n IS,\n IS_DEFINED,\n IS_NOT,\n nil,\n UICore,\n UILanguageService,\n UILocalizedTextObject,\n UIRoute,\n UIView\n} from \"uicore-ts\"\nimport { CBCore } from \"./CBCore\"\nimport { CBLocalizedTextObject } from \"./CBDataInterfaces\"\n\n\nexport interface ParticularLanguageValues {\n \n [x: string]: string\n \n topBarTitle: string;\n selectLanguageTitle: string;\n languageNameShort: string;\n leftBarTitle: string;\n languageName: string\n \n}\n\n\nexport interface LanguageValues {\n \n [x: string]: ParticularLanguageValues\n \n en: ParticularLanguageValues\n est: ParticularLanguageValues\n \n}\n\n\nexport class CBLanguageService implements UILanguageService {\n \n static _currentLanguageKey: string\n \n static languageValues: LanguageValues = {\n \n en: {\n \n languageName: \"English\",\n languageNameShort: \"ENG\",\n \n topBarTitle: \"UICore application\",\n \n selectLanguageTitle: \"Select language\",\n leftBarTitle: \"Title\"\n \n \n },\n est: {\n \n languageName: \"Eesti keel\",\n languageNameShort: \"EST\",\n \n topBarTitle: \"UICore rakendus\",\n \n selectLanguageTitle: \"Vali keel\",\n leftBarTitle: \"Pealkiri\"\n \n \n }\n \n \n \n \n }\n \n static languages = JSON.parse(JSON.stringify(CBLanguageService.languageValues))\n \n static useStoredLanguageValues(values = {}) {\n \n const result = JSON.parse(JSON.stringify(CBLanguageService.languageValues))\n .objectByCopyingValuesRecursivelyFromObject(\n values) as any\n \n if (JSON.stringify(result) != JSON.stringify(CBLanguageService.languages)) {\n \n CBLanguageService.languages = result\n \n CBLanguageService.broadcastLanguageChangeEvent()\n \n }\n \n }\n \n \n static broadcastLanguageChangeEvent(view?: UIView) {\n \n view = view as any || CBCore.sharedInstance.viewCores.everyElement.rootViewController.view.rootView as any\n \n view?.broadcastEventInSubtree({\n name: UIView.broadcastEventName.LanguageChanged,\n parameters: {}\n })\n \n }\n \n static get defaultLanguageKey() {\n \n // @ts-ignore\n return (CBCoreInitializerObject.defaultLanguageKey || \"en\")\n \n }\n \n static get currentLanguageKey() {\n \n if (!CBLanguageService._currentLanguageKey) {\n \n CBLanguageService.updateCurrentLanguageKey()\n \n }\n \n return CBLanguageService._currentLanguageKey\n \n }\n \n updateCurrentLanguageKey() {\n \n CBLanguageService.updateCurrentLanguageKey()\n \n }\n \n static updateCurrentLanguageKey(route = UIRoute.currentRoute) {\n \n let result = route.componentWithName(\"settings\").parameters.language\n \n if (IS_NOT(result)) {\n \n result = CBLanguageService.defaultLanguageKey\n \n }\n \n const isChanged = (result != CBLanguageService._currentLanguageKey)\n \n CBLanguageService._currentLanguageKey = result\n \n if (isChanged) {\n \n CBCore.sharedInstance.languageKey = result\n \n CBLanguageService.broadcastLanguageChangeEvent()\n \n }\n \n }\n \n get currentLanguageKey() {\n \n const result = CBLanguageService.currentLanguageKey\n \n return result\n \n }\n \n \n \n static stringForKey(\n key: string,\n languageKey: string,\n defaultString: string,\n parameters?: { [x: string]: string | UILocalizedTextObject; }\n ) {\n \n var result: string\n \n if (IS(key) && CBLanguageService.languages[languageKey] &&\n IS_DEFINED(CBLanguageService.languages[languageKey][key])) {\n \n result = CBLanguageService.languages[languageKey][key]\n \n }\n else {\n \n result = defaultString\n \n }\n \n if (IS(parameters)) {\n \n const parameterKeys = Object.keys(parameters)\n \n parameterKeys.forEach(function (key, index, array) {\n \n const keyString = \"%\" + key + \"%\"\n \n const parameter = parameters[key]\n \n var parameterString\n \n if (parameter instanceof Object) {\n \n parameterString = UICore.languageService.stringForCurrentLanguage(parameter as UILocalizedTextObject)\n \n }\n else {\n \n parameterString = parameter\n \n }\n \n \n result = result.replace(new RegExp(keyString, \"g\"), parameterString)\n \n })\n \n }\n \n return result\n \n }\n \n stringForKey(\n key: string,\n languageKey: string,\n defaultString: string,\n parameters?: { [x: string]: string | UILocalizedTextObject; }\n ) {\n \n \n return CBLanguageService.stringForKey(key, languageKey, defaultString, parameters)\n \n \n }\n \n \n static localizedTextObjectForKey(\n key: string,\n defaultString = key,\n parameters?: { [x: string]: string | UILocalizedTextObject; }\n ) {\n \n const result = {}\n \n CBLanguageService.languages.forEach(function (languageObject: any, languageKey: string) {\n \n // @ts-ignore\n result[languageKey] = CBLanguageService.stringForKey(key, languageKey, defaultString, parameters)\n \n })\n \n return result\n \n }\n \n localizedTextObjectForKey(\n key: string,\n defaultString?: string,\n parameters?: { [x: string]: string | UILocalizedTextObject; }\n ) {\n \n const result = CBLanguageService.localizedTextObjectForKey(key, defaultString, parameters)\n \n return result\n \n }\n \n \n static localizedTextObjectForText(text: string) {\n \n if (IS_NOT(text)) {\n \n return nil\n \n }\n \n const result = {\n \n [CBLanguageService.defaultLanguageKey]: text\n \n }\n \n return result\n \n }\n \n localizedTextObjectForText(text: string) {\n \n const result = CBLanguageService.localizedTextObjectForText(text)\n \n return result\n \n }\n \n \n static stringForCurrentLanguage(localizedTextObject: CBLocalizedTextObject | string) {\n \n if (!CBLanguageService || !localizedTextObject) {\n \n const asd = 1\n \n }\n \n if (localizedTextObject === \"\" + localizedTextObject) {\n \n return localizedTextObject\n \n }\n \n localizedTextObject = FIRST_OR_NIL(localizedTextObject)\n \n // @ts-ignore\n let result: string = localizedTextObject[CBLanguageService.currentLanguageKey]\n \n if (IS_NOT(result)) {\n \n // @ts-ignore\n result = localizedTextObject[CBLanguageService.defaultLanguageKey]\n \n }\n \n if (IS_NOT(result)) {\n \n // @ts-ignore\n result = localizedTextObject[\"en\"]\n \n }\n \n if (IS_NOT(result)) {\n \n result = \"\"\n \n }\n \n return result\n \n }\n \n stringForCurrentLanguage(localizedTextObject: CBLocalizedTextObject) {\n \n return CBLanguageService.stringForCurrentLanguage(localizedTextObject)\n \n }\n \n \n \n \n}\n\n\nUICore.languageService = CBLanguageService\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAWO;AACP,oBAAuB;AA2BhB,MAAM,qBAAN,MAAqD;AAAA,EAsCxD,OAAO,wBAAwB,SAAS,CAAC,GAAG;AAExC,UAAM,SAAS,KAAK,MAAM,KAAK,UAAU,mBAAkB,cAAc,CAAC,EACrE;AAAA,MACG;AAAA,IAAM;AAEd,QAAI,KAAK,UAAU,MAAM,KAAK,KAAK,UAAU,mBAAkB,SAAS,GAAG;AAEvE,yBAAkB,YAAY;AAE9B,yBAAkB,6BAA6B;AAAA,IAEnD;AAAA,EAEJ;AAAA,EAGA,OAAO,6BAA6B,MAAe;AAE/C,WAAO,QAAe,qBAAO,eAAe,UAAU,aAAa,mBAAmB,KAAK;AAE3F,iCAAM,wBAAwB;AAAA,MAC1B,MAAM,wBAAO,mBAAmB;AAAA,MAChC,YAAY,CAAC;AAAA,IACjB;AAAA,EAEJ;AAAA,EAEA,WAAW,qBAAqB;AAG5B,WAAQ,wBAAwB,sBAAsB;AAAA,EAE1D;AAAA,EAEA,WAAW,qBAAqB;AAE5B,QAAI,CAAC,mBAAkB,qBAAqB;AAExC,yBAAkB,yBAAyB;AAAA,IAE/C;AAEA,WAAO,mBAAkB;AAAA,EAE7B;AAAA,EAEA,2BAA2B;AAEvB,uBAAkB,yBAAyB;AAAA,EAE/C;AAAA,EAEA,OAAO,yBAAyB,QAAQ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AAc;AAAA,IACd,mBAAmB;AAAA,IAEnB,aAAa;AAAA,IAEb,qBAAqB;AAAA,IACrB,cAAc;AAAA,EAGlB;AAKJ;AAlCS,kBAoCF,YAAY,KAAK,MAAM,KAAK,UAAU,mBAAkB,cAAc,CAAC;AAgRlF,wBAAO,kBAAkB;",
|
|
6
6
|
"names": ["key"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/CBServerClient.ts"],
|
|
4
|
-
"sourcesContent": ["import { IS, nil, UIObject, YES } from \"../../uicore-ts\"\nimport { CBCore } from \"./CBCore\"\n\n\nexport class CBServerClient extends UIObject {\n \n _core: CBCore\n \n constructor(core: CBCore) {\n \n super()\n \n this._core = core\n \n }\n \n \n sendJSONObject(URL: string, objectToSend: any, completion: (response: any) => void) {\n \n this.sendRequest(\"POST\", URL, objectToSend, function (this: CBServerClient, status, response) {\n if (status != 200) {\n \n console.log(\"GET \" + URL + \" \" + status)\n \n if (IS(completion)) {\n completion(nil)\n }\n return\n }\n const result = JSON.parse(response)\n \n if (IS(completion)) {\n completion(result)\n }\n }.bind(this))\n \n }\n \n retrieveJSONObject(URL: string, completion: (response: any) => void) {\n \n this.retrieveJSONObjectWithCaching(URL, nil, nil, YES, completion)\n \n }\n \n retrieveJSONObjectWithCaching(\n URL: string,\n cacheObject: any,\n cacheKey: string,\n forceUpdate: boolean,\n completion: (response: any) => void\n ) {\n if (IS(cacheObject[cacheKey]) && !forceUpdate) {\n if (IS(completion)) {\n completion(cacheObject[cacheKey])\n }\n return\n }\n this.sendRequest(\"GET\", URL, null, function (this: CBServerClient, status, response) {\n if (status != 200) {\n \n console.log(\"GET \" + URL + \" \" + status)\n \n if (IS(completion)) {\n completion(nil)\n }\n return\n }\n const result = JSON.parse(response)\n cacheObject[cacheKey] = result\n if (IS(completion)) {\n completion(result)\n }\n }.bind(this))\n }\n \n sendRequest(method: string, URL: string, data: any, completion: (status: number, response: string) => void) {\n \n const xhr = new XMLHttpRequest()\n xhr.open(method, URL, true)\n xhr.setRequestHeader(\"Content-Type\", \"application/json;charset=UTF-8\")\n xhr.onreadystatechange = processRequest\n \n function processRequest(event: Event) {\n \n if (xhr.readyState == 4) {\n if (IS(completion)) {\n completion(xhr.status, xhr.responseText)\n }\n }\n \n }\n \n xhr.send(JSON.stringify(data))\n \n }\n \n \n \n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { IS, nil, UIObject, YES } from \"../../uicore-ts\"\nimport { CBCore } from \"./CBCore\"\n\n\nexport class CBServerClient extends UIObject {\n \n _core: CBCore\n \n constructor(core: CBCore) {\n \n super()\n \n this._core = core\n \n }\n \n \n sendJSONObject(URL: string, objectToSend: any, completion: (response: any) => void) {\n \n this.sendRequest(\"POST\", URL, objectToSend, function (this: CBServerClient, status: string | number, response: string) {\n if (status != 200) {\n \n console.log(\"GET \" + URL + \" \" + status)\n \n if (IS(completion)) {\n completion(nil)\n }\n return\n }\n const result = JSON.parse(response)\n \n if (IS(completion)) {\n completion(result)\n }\n }.bind(this))\n \n }\n \n retrieveJSONObject(URL: string, completion: (response: any) => void) {\n \n this.retrieveJSONObjectWithCaching(URL, nil, nil, YES, completion)\n \n }\n \n retrieveJSONObjectWithCaching(\n URL: string,\n cacheObject: any,\n cacheKey: string,\n forceUpdate: boolean,\n completion: (response: any) => void\n ) {\n if (IS(cacheObject[cacheKey]) && !forceUpdate) {\n if (IS(completion)) {\n completion(cacheObject[cacheKey])\n }\n return\n }\n this.sendRequest(\"GET\", URL, null, function (this: CBServerClient, status: string | number, response: string) {\n if (status != 200) {\n \n console.log(\"GET \" + URL + \" \" + status)\n \n if (IS(completion)) {\n completion(nil)\n }\n return\n }\n const result = JSON.parse(response)\n cacheObject[cacheKey] = result\n if (IS(completion)) {\n completion(result)\n }\n }.bind(this))\n }\n \n sendRequest(method: string, URL: string, data: any, completion: (status: number, response: string) => void) {\n \n const xhr = new XMLHttpRequest()\n xhr.open(method, URL, true)\n xhr.setRequestHeader(\"Content-Type\", \"application/json;charset=UTF-8\")\n xhr.onreadystatechange = processRequest\n \n function processRequest(event: Event) {\n \n if (xhr.readyState == 4) {\n if (IS(completion)) {\n completion(xhr.status, xhr.responseText)\n }\n }\n \n }\n \n xhr.send(JSON.stringify(data))\n \n }\n \n \n \n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAuC;AAIhC,MAAM,uBAAuB,0BAAS;AAAA,EAIzC,YAAY,MAAc;AAEtB,UAAM;AAEN,SAAK,QAAQ;AAAA,EAEjB;AAAA,EAGA,eAAe,KAAa,cAAmB,YAAqC;AAEhF,SAAK,YAAY,QAAQ,KAAK,cAAc,SAAgC,QAAyB,UAAkB;AACnH,UAAI,UAAU,KAAK;AAEf,gBAAQ,IAAI,SAAS,MAAM,MAAM,MAAM;AAEvC,gBAAI,qBAAG,UAAU,GAAG;AAChB,qBAAW,oBAAG;AAAA,QAClB;AACA;AAAA,MACJ;AACA,YAAM,SAAS,KAAK,MAAM,QAAQ;AAElC,cAAI,qBAAG,UAAU,GAAG;AAChB,mBAAW,MAAM;AAAA,MACrB;AAAA,IACJ,EAAE,KAAK,IAAI,CAAC;AAAA,EAEhB;AAAA,EAEA,mBAAmB,KAAa,YAAqC;AAEjE,SAAK,8BAA8B,KAAK,sBAAK,sBAAK,sBAAK,UAAU;AAAA,EAErE;AAAA,EAEA,8BACI,KACA,aACA,UACA,aACA,YACF;AACE,YAAI,qBAAG,YAAY,SAAS,KAAK,CAAC,aAAa;AAC3C,cAAI,qBAAG,UAAU,GAAG;AAChB,mBAAW,YAAY,SAAS;AAAA,MACpC;AACA;AAAA,IACJ;AACA,SAAK,YAAY,OAAO,KAAK,MAAM,SAAgC,QAAyB,UAAkB;AAC1G,UAAI,UAAU,KAAK;AAEf,gBAAQ,IAAI,SAAS,MAAM,MAAM,MAAM;AAEvC,gBAAI,qBAAG,UAAU,GAAG;AAChB,qBAAW,oBAAG;AAAA,QAClB;AACA;AAAA,MACJ;AACA,YAAM,SAAS,KAAK,MAAM,QAAQ;AAClC,kBAAY,YAAY;AACxB,cAAI,qBAAG,UAAU,GAAG;AAChB,mBAAW,MAAM;AAAA,MACrB;AAAA,IACJ,EAAE,KAAK,IAAI,CAAC;AAAA,EAChB;AAAA,EAEA,YAAY,QAAgB,KAAa,MAAW,YAAwD;AAExG,UAAM,MAAM,IAAI,eAAe;AAC/B,QAAI,KAAK,QAAQ,KAAK,IAAI;AAC1B,QAAI,iBAAiB,gBAAgB,gCAAgC;AACrE,QAAI,qBAAqB;AAEzB,aAAS,eAAe,OAAc;AAElC,UAAI,IAAI,cAAc,GAAG;AACrB,gBAAI,qBAAG,UAAU,GAAG;AAChB,qBAAW,IAAI,QAAQ,IAAI,YAAY;AAAA,QAC3C;AAAA,MACJ;AAAA,IAEJ;AAEA,QAAI,KAAK,KAAK,UAAU,IAAI,CAAC;AAAA,EAEjC;AAMJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -37,6 +38,8 @@ class CBSocketCallbackHolder extends import_uicore_ts.UIObject {
|
|
|
37
38
|
this.onetimeHandlers = {};
|
|
38
39
|
this.keysForIdentifiers = {};
|
|
39
40
|
this.isValid = import_uicore_ts.YES;
|
|
41
|
+
this._storeableResponseKeys = [];
|
|
42
|
+
this._storedResponseHashesDictionary = {};
|
|
40
43
|
this._verifiedResponseHashesDictionary = {};
|
|
41
44
|
this._socketClient = socketClient;
|
|
42
45
|
if ((0, import_uicore_ts.IS)(previousCallbackHolder)) {
|
|
@@ -231,7 +234,7 @@ class CBSocketCallbackHolder extends import_uicore_ts.UIObject {
|
|
|
231
234
|
}.bind(this));
|
|
232
235
|
}
|
|
233
236
|
if (this.onetimeHandlers[key]) {
|
|
234
|
-
this.onetimeHandlers[key].forEach(function(handler
|
|
237
|
+
this.onetimeHandlers[key].forEach(function(handler) {
|
|
235
238
|
handler(message.messageData, sendResponseFunction);
|
|
236
239
|
}.bind(this));
|
|
237
240
|
delete this.onetimeHandlers[key];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/CBSocketCallbackHolder.ts"],
|
|
4
|
-
"sourcesContent": ["import objectHash from \"object-hash\"\nimport { FIRST, IS, IS_NOT, nil, NO, UIObject, YES } from \"../../uicore-ts\"\nimport {\n CBSocketMessage,\n CBSocketMessageCompletionFunction,\n CBSocketMessageHandlerFunction, CBSocketMessageSendResponseFunction, CBSocketMultipleMessage,\n CBSocketMultipleMessagecompletionFunction, CBSocketMultipleMessageObject\n} from \"./CBDataInterfaces\"\nimport { CBSocketClient } from \"./CBSocketClient\"\n\n\n\n\n\ninterface CBSocketCallbackHolderMessageDescriptor {\n \n key: string;\n message: {\n identifier: string;\n inResponseToIdentifier?: string;\n keepWaitingForResponses?: boolean;\n }\n \n \n sentAtTime: number;\n \n //completionTriggered: boolean;\n \n messageDataHash: string;\n \n responseDataHash?: string;\n \n mainResponseReceived: boolean;\n \n anyMainResponseReceived: boolean;\n \n completionPolicy: string;\n completionFunction: CBSocketMessageCompletionFunction;\n \n}\n\n\ninterface CBSocketCallbackHolderStoredResponseObject {\n \n messageKey: string;\n messageData: any;\n messageDataHash: string;\n \n}\n\n\n\n\nexport class CBSocketCallbackHolder extends UIObject {\n \n messageDescriptors: {\n \n [x: string]: CBSocketCallbackHolderMessageDescriptor[]\n \n } = {}\n \n handlers: {\n [x: string]: CBSocketMessageHandlerFunction[]\n } = {}\n \n onetimeHandlers: {\n [x: string]: CBSocketMessageHandlerFunction[]\n } = {}\n \n keysForIdentifiers: {\n \n [x: string]: string\n \n } = {}\n \n \n isValid = YES\n _storeableResponseKeys: string[]\n _storedResponseHashesDictionary: {\n \n [x: string]: {\n \n hash: string,\n validityDate: number\n \n }\n \n }\n _verifiedResponseHashesDictionary: {\n \n [x: string]: boolean\n \n } = {}\n \n _socketClient: CBSocketClient\n \n \n \n \n \n constructor(socketClient: CBSocketClient, previousCallbackHolder?: CBSocketCallbackHolder) {\n \n super()\n \n \n this._socketClient = socketClient\n \n if (IS(previousCallbackHolder)) {\n \n this.handlers = previousCallbackHolder.handlers\n this._verifiedResponseHashesDictionary = previousCallbackHolder._verifiedResponseHashesDictionary\n \n }\n \n \n \n \n \n }\n \n \n \n \n \n triggerDisconnectHandlers() {\n \n this.messageDescriptors.forEach(function (descriptor: CBSocketCallbackHolderMessageDescriptor, key: string) {\n \n if (descriptor.mainResponseReceived) {\n \n descriptor.completionFunction(CBSocketClient.disconnectionMessage, nil)\n \n }\n \n })\n \n }\n \n \n \n \n \n registerHandler(key: string, handlerFunction: CBSocketMessageHandlerFunction) {\n \n \n if (!this.handlers[key]) {\n \n this.handlers[key] = []\n \n }\n \n this.handlers[key].push(handlerFunction)\n \n \n \n }\n \n registerOnetimeHandler(key: string, handlerFunction: CBSocketMessageHandlerFunction) {\n \n \n if (!this.onetimeHandlers[key]) {\n \n this.onetimeHandlers[key] = []\n \n }\n \n this.onetimeHandlers[key].push(handlerFunction)\n \n \n \n }\n \n \n \n \n \n get storedResponseHashesDictionary() {\n \n if (IS_NOT(this._storedResponseHashesDictionary)) {\n \n this._storedResponseHashesDictionary = JSON.parse(localStorage[\"CBSocketResponseHashesDictionary\"] || \"{}\")\n \n }\n \n return this._storedResponseHashesDictionary\n \n }\n \n storedResponseHashObjectForKey(requestKey: string, requestDataHash: string) {\n \n const localStorageKey = this.keyForRequestKeyAndRequestDataHash(requestKey, requestDataHash)\n \n const hashObject = this.storedResponseHashesDictionary[localStorageKey]\n \n const result = FIRST(hashObject, {} as any)\n \n \n \n return result\n \n }\n \n storedResponseForKey(requestKey: string, requestDataHash: string) {\n \n const localStorageKey = this.keyForRequestKeyAndRequestDataHash(requestKey, requestDataHash)\n \n const storedObject = JSON.parse(localStorage[localStorageKey] || \"{}\")\n \n return storedObject.responseMessageData\n \n }\n \n keyForRequestKeyAndRequestDataHash(requestKey: string, requestDataHash: string) {\n \n const result = \"_CBSCH_LS_key_\" + requestKey + \"_\" + requestDataHash\n \n return result\n \n }\n \n storeResponse(\n requestKey: string,\n requestDataHash: string,\n responseMessage: CBSocketMessage<any>,\n responseDataHash: string\n ) {\n \n \n if (!responseMessage.canBeStoredAsResponse ||\n (IS_NOT(responseMessage.messageData) && IS_NOT(responseMessage.messageDataHash))) {\n \n return\n \n }\n \n \n const localStorageKey = this.keyForRequestKeyAndRequestDataHash(requestKey, requestDataHash)\n \n \n var validityDate: number\n \n if (responseMessage.responseValidityDuration) {\n \n validityDate = Date.now() + responseMessage.responseValidityDuration\n \n }\n \n const storedResponseHashesDictionary = this.storedResponseHashesDictionary\n storedResponseHashesDictionary[localStorageKey] = {\n \n hash: responseDataHash,\n validityDate: validityDate\n \n }\n \n this.saveInLocalStorage(localStorageKey, {\n \n responseMessageData: responseMessage.messageData,\n responseHash: responseDataHash\n \n })\n \n \n this.saveStoredResponseHashesDictionary(storedResponseHashesDictionary)\n \n }\n \n \n \n \n \n private saveStoredResponseHashesDictionary(storedResponseHashesDictionary: { [x: string]: { hash: string; validityDate: number; }; }) {\n \n this.saveInLocalStorage(\"CBSocketResponseHashesDictionary\", storedResponseHashesDictionary)\n \n }\n \n saveInLocalStorage(key: string, object: any) {\n \n \n const stringToSave = JSON.stringify(object)\n \n if (stringToSave != localStorage[key]) {\n \n localStorage[key] = stringToSave\n \n }\n \n \n }\n \n \n \n \n \n socketShouldSendMessage(\n key: string,\n message: CBSocketMessage<any>,\n completionPolicy: string,\n completionFunction: CBSocketMessageCompletionFunction\n ) {\n \n \n \n var result = YES\n \n var triggerStoredResponseImmediately = NO\n \n \n const messageDataHash = objectHash(message.messageData || nil)\n \n const descriptorKey = \"socketMessageDescriptor_\" + key + messageDataHash\n \n this.messageDescriptors[descriptorKey] = (this.messageDescriptors[descriptorKey] || [])\n \n \n const hashObject = this.storedResponseHashObjectForKey(key, messageDataHash)\n message.storedResponseHash = hashObject.hash\n \n \n \n if (completionPolicy == CBSocketClient.completionPolicy.first) {\n \n const descriptorsForKey = (this.messageDescriptors[descriptorKey] || [])\n \n const matchingDescriptor = descriptorsForKey.find(function (descriptor, index, array) {\n return (descriptor.messageDataHash == messageDataHash)\n })\n \n if (matchingDescriptor) {\n \n result = NO\n \n }\n \n }\n \n if (completionPolicy == CBSocketClient.completionPolicy.storedOrFirst) {\n \n const descriptorsForKey = (this.messageDescriptors[descriptorKey] || [])\n \n const matchingDescriptor = descriptorsForKey.find(function (descriptor, index, array) {\n return (descriptor.messageDataHash == messageDataHash)\n })\n \n const storedResponse = IS(message.storedResponseHash)\n \n if (matchingDescriptor ||\n (storedResponse && this._verifiedResponseHashesDictionary[message.storedResponseHash])) {\n \n result = NO\n \n triggerStoredResponseImmediately = YES\n \n }\n \n }\n \n if (completionPolicy == CBSocketClient.completionPolicy.firstOnly) {\n \n const descriptorsForKey = (this.messageDescriptors[descriptorKey] || [])\n \n const matchingDescriptor = descriptorsForKey.find(function (descriptor, index, array) {\n return (descriptor.messageDataHash == messageDataHash)\n })\n \n if (matchingDescriptor) {\n \n return NO\n \n }\n \n }\n \n \n if (hashObject && hashObject.hash && hashObject.validityDate && message.storedResponseHash &&\n this._verifiedResponseHashesDictionary[message.storedResponseHash] && hashObject.validityDate >\n Date.now()) {\n \n result = NO\n \n triggerStoredResponseImmediately = YES\n \n }\n \n \n if (IS(completionFunction)) {\n \n this.messageDescriptors[descriptorKey].push({\n \n key: key,\n message: {\n \n identifier: message.identifier,\n inResponseToIdentifier: message.inResponseToIdentifier,\n keepWaitingForResponses: message.keepWaitingForResponses\n \n },\n \n sentAtTime: Date.now(),\n \n //completionTriggered: NO,\n \n \n messageDataHash: messageDataHash,\n \n mainResponseReceived: NO,\n anyMainResponseReceived: NO,\n \n \n completionPolicy: completionPolicy,\n completionFunction: completionFunction\n \n })\n \n this.keysForIdentifiers[message.identifier] = descriptorKey\n \n }\n \n \n if (triggerStoredResponseImmediately) {\n \n this.socketDidReceiveMessageForKey(\n CBSocketClient.responseMessageKey,\n {\n \n identifier: nil,\n messageData: nil,\n \n inResponseToIdentifier: message.identifier,\n \n useStoredResponse: YES\n \n },\n nil\n )\n \n }\n \n \n return result\n \n \n }\n \n \n \n \n \n static defaultMultipleMessagecompletionFunction(responseMessages: any[], callcompletionFunctions: () => void) {\n callcompletionFunctions()\n }\n \n \n socketWillSendMultipleMessage(\n messageToSend: CBSocketMultipleMessage,\n completionFunction: CBSocketMultipleMessagecompletionFunction = CBSocketCallbackHolder.defaultMultipleMessagecompletionFunction\n ) {\n \n \n \n const key = CBSocketClient.multipleMessageKey\n \n \n const messageDataHash = objectHash(messageToSend.messageData || nil)\n \n const descriptorKey = \"socketMessageDescriptor_\" + key + messageDataHash\n \n this.messageDescriptors[descriptorKey] = (this.messageDescriptors[descriptorKey] || [])\n \n \n messageToSend.storedResponseHash = this.storedResponseHashObjectForKey(key, messageDataHash).hash\n \n \n \n \n \n this.messageDescriptors[descriptorKey].push({\n \n key: key,\n message: {\n \n identifier: messageToSend.identifier,\n inResponseToIdentifier: messageToSend.inResponseToIdentifier,\n keepWaitingForResponses: messageToSend.keepWaitingForResponses\n \n },\n \n sentAtTime: Date.now(),\n \n //completionTriggered: NO,\n \n \n messageDataHash: messageDataHash,\n \n mainResponseReceived: NO,\n anyMainResponseReceived: NO,\n \n \n completionPolicy: CBSocketClient.completionPolicy.directOnly,\n completionFunction: function (\n this: CBSocketCallbackHolder,\n responseMessage: CBSocketMultipleMessageObject[],\n respondWithMessage\n ) {\n \n completionFunction(\n responseMessage.map(function (messageObject, index, array) {\n \n return messageObject.message.messageData\n \n }),\n function (this: CBSocketCallbackHolder) {\n \n //console.log(\"Received multiple message response with length of \" + responseMessage.length + \".\");\n \n // Call all completion functions\n responseMessage.forEach(function (\n this: CBSocketCallbackHolder,\n messageObject: CBSocketMultipleMessageObject,\n index: number,\n array: CBSocketMultipleMessageObject[]\n ) {\n \n this._socketClient.didReceiveMessageForKey(messageObject.key, messageObject.message)\n \n }.bind(this))\n \n }.bind(this)\n )\n \n }.bind(this)\n \n })\n \n this.keysForIdentifiers[messageToSend.identifier] = descriptorKey\n \n \n }\n \n \n \n \n \n socketDidReceiveMessageForKey(\n key: string,\n message: CBSocketMessage<any>,\n sendResponseFunction: CBSocketMessageSendResponseFunction\n ) {\n \n \n if (!this.isValid) {\n \n return\n \n }\n \n \n // Call static handlers\n if (this.handlers[key]) {\n \n this.handlers[key].forEach(function (\n this: CBSocketCallbackHolder,\n handler: CBSocketMessageHandlerFunction,\n index,\n array\n ) {\n \n handler(message.messageData, sendResponseFunction)\n \n }.bind(this))\n \n }\n \n if (this.onetimeHandlers[key]) {\n \n this.onetimeHandlers[key].forEach(function (\n this: CBSocketCallbackHolder,\n handler: CBSocketMessageHandlerFunction,\n index,\n array\n ) {\n \n handler(message.messageData, sendResponseFunction)\n \n }.bind(this))\n \n delete this.onetimeHandlers[key]\n \n }\n \n \n \n // Temporary response handlers are evaluated here\n if (message.inResponseToIdentifier &&\n (CBSocketClient.responseMessageKey == key || CBSocketClient.multipleMessageKey == key)) {\n \n // Find descriptors for the key of the message that is being responded to\n const descriptorKey = this.keysForIdentifiers[message.inResponseToIdentifier]\n const descriptorsForKey = (this.messageDescriptors[descriptorKey] || [])\n \n // Find response data hash to check for differences\n const responseDataHash = message.messageDataHash\n \n // Remove identifier from dictionary\n if (!message.keepWaitingForResponses) {\n \n delete this.keysForIdentifiers[message.inResponseToIdentifier]\n \n delete this.messageDescriptors[descriptorKey]\n \n }\n \n \n // Function to call completion function\n const callCompletionFunction = (descriptor, storedResponseCondition = NO) => {\n \n var messageData = message.messageData\n \n if (message.useStoredResponse && storedResponseCondition) {\n \n messageData = this.storedResponseForKey(descriptor.key, descriptor.messageDataHash)\n \n const responseHash = this.storedResponseHashObjectForKey(\n descriptor.key,\n descriptor.messageDataHash\n ).hash\n \n const localStorageKey = this.keyForRequestKeyAndRequestDataHash(\n descriptor.key,\n descriptor.messageDataHash\n )\n \n if (message.responseValidityDuration && this.storedResponseHashesDictionary[localStorageKey]) {\n \n this.storedResponseHashesDictionary[localStorageKey].validityDate = Date.now() +\n message.responseValidityDuration\n \n this.saveStoredResponseHashesDictionary(this.storedResponseHashesDictionary)\n \n }\n \n this._verifiedResponseHashesDictionary[responseHash] = YES\n \n console.log(\"Using stored response.\")\n \n }\n \n // Call completionFunction and set response data hash\n descriptor.completionFunction(messageData, sendResponseFunction)\n descriptor.responseDataHash = responseDataHash\n \n }\n \n \n descriptorsForKey.copy().forEach(function (\n this: CBSocketCallbackHolder,\n descriptor: CBSocketCallbackHolderMessageDescriptor,\n index: number,\n array: CBSocketCallbackHolderMessageDescriptor[]\n ) {\n \n \n if ((descriptor.completionPolicy == CBSocketClient.completionPolicy.directOnly &&\n descriptor.message.identifier == message.inResponseToIdentifier) || descriptor.completionPolicy ==\n CBSocketClient.completionPolicy.first || descriptor.completionPolicy ==\n CBSocketClient.completionPolicy.firstOnly || descriptor.completionPolicy ==\n CBSocketClient.completionPolicy.storedOrFirst) {\n \n // Calling completion function and removing descriptor\n \n if (!message.keepWaitingForResponses) {\n \n this.storeResponse(descriptor.key, descriptor.messageDataHash, message, responseDataHash)\n \n descriptorsForKey.removeElement(descriptor)\n \n sendResponseFunction.respondingToMainResponse = YES\n \n }\n \n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n }\n else if (descriptor.completionPolicy == CBSocketClient.completionPolicy.all) {\n \n // Calling completion function\n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n // Marking descriptor as having been responded to\n if (!message.keepWaitingForResponses) {\n \n if (message.inResponseToIdentifier == descriptor.message.identifier) {\n \n sendResponseFunction.respondingToMainResponse = YES\n descriptor.mainResponseReceived = YES\n descriptorsForKey.removeElement(descriptor)\n \n }\n \n descriptor.anyMainResponseReceived = YES\n \n }\n \n \n \n }\n else if (descriptor.completionPolicy == CBSocketClient.completionPolicy.allDifferent) {\n \n // Calling completionFunction if messageData is different from previous\n if (descriptor.responseDataHash != responseDataHash) {\n \n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n }\n \n // Marking descriptor as having been responded to\n if (!message.keepWaitingForResponses) {\n \n if (message.inResponseToIdentifier == descriptor.message.identifier) {\n \n sendResponseFunction.respondingToMainResponse = YES\n descriptor.mainResponseReceived = YES\n descriptorsForKey.removeElement(descriptor)\n \n }\n \n descriptor.anyMainResponseReceived = YES\n \n }\n \n }\n else if (descriptor.completionPolicy == CBSocketClient.completionPolicy.last &&\n descriptor.message.identifier == message.inResponseToIdentifier) {\n \n if (!message.keepWaitingForResponses) {\n \n // Marking descriptor as having been responded to\n descriptor.mainResponseReceived = YES\n descriptor.anyMainResponseReceived = YES\n \n sendResponseFunction.respondingToMainResponse = YES\n \n }\n else {\n \n descriptor.completionFunction(message.messageData, sendResponseFunction)\n \n }\n \n }\n else if (descriptor.completionPolicy == CBSocketClient.completionPolicy.firstAndLast ||\n descriptor.completionPolicy == CBSocketClient.completionPolicy.firstAndLastIfDifferent) {\n \n if (!message.keepWaitingForResponses) {\n \n // Only calling completionFunction once as a first response call\n if (!descriptor.anyMainResponseReceived) {\n \n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n }\n \n // Marking descriptor as having been responded to\n if (descriptor.message.identifier == message.inResponseToIdentifier) {\n \n descriptor.mainResponseReceived = YES\n sendResponseFunction.respondingToMainResponse = YES\n \n }\n \n descriptor.anyMainResponseReceived = YES\n \n }\n else if (descriptor.message.identifier == message.inResponseToIdentifier &&\n message.keepWaitingForResponses) {\n \n descriptor.completionFunction(message.messageData, sendResponseFunction)\n \n }\n \n }\n \n }.bind(this))\n \n \n \n \n \n // Last message completion policies\n \n const allResponsesReceived = descriptorsForKey.allMatch(function (descriptorObject, index, array) {\n return descriptorObject.mainResponseReceived\n })\n \n descriptorsForKey.copy().forEach(function (\n this: CBSocketCallbackHolder,\n descriptor: CBSocketCallbackHolderMessageDescriptor,\n index: number,\n array: CBSocketCallbackHolderMessageDescriptor[]\n ) {\n \n if ((descriptor.completionPolicy == CBSocketClient.completionPolicy.last ||\n descriptor.completionPolicy == CBSocketClient.completionPolicy.firstAndLast) &&\n allResponsesReceived && !message.keepWaitingForResponses) {\n \n // Calling completionFunction\n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n // Cleaning up\n descriptorsForKey.removeElement(descriptor)\n \n }\n else if (descriptor.completionPolicy == CBSocketClient.completionPolicy.firstAndLastIfDifferent &&\n allResponsesReceived && !message.keepWaitingForResponses) {\n \n // Calling completionFunction if needed\n if (descriptor.responseDataHash != responseDataHash) {\n \n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n }\n \n // Cleaning up\n descriptorsForKey.removeElement(descriptor)\n \n }\n \n }.bind(this))\n \n \n }\n \n \n \n \n \n }\n \n \n \n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import objectHash from \"object-hash\"\nimport { FIRST, IS, IS_NOT, nil, NO, UIObject, YES } from \"../../uicore-ts\"\nimport {\n CBSocketMessage,\n CBSocketMessageCompletionFunction,\n CBSocketMessageHandlerFunction, CBSocketMessageSendResponseFunction, CBSocketMultipleMessage,\n CBSocketMultipleMessagecompletionFunction, CBSocketMultipleMessageObject\n} from \"./CBDataInterfaces\"\nimport { CBSocketClient } from \"./CBSocketClient\"\n\n\n\n\n\ninterface CBSocketCallbackHolderMessageDescriptor {\n \n key: string;\n message: {\n identifier: string;\n inResponseToIdentifier?: string;\n keepWaitingForResponses?: boolean;\n }\n \n \n sentAtTime: number;\n \n //completionTriggered: boolean;\n \n messageDataHash: string;\n \n responseDataHash?: string;\n \n mainResponseReceived: boolean;\n \n anyMainResponseReceived: boolean;\n \n completionPolicy: string;\n completionFunction: CBSocketMessageCompletionFunction;\n \n}\n\n\ninterface CBSocketCallbackHolderStoredResponseObject {\n \n messageKey: string;\n messageData: any;\n messageDataHash: string;\n \n}\n\n\n\n\nexport class CBSocketCallbackHolder extends UIObject {\n \n messageDescriptors: {\n \n [x: string]: CBSocketCallbackHolderMessageDescriptor[]\n \n } = {}\n \n handlers: {\n [x: string]: CBSocketMessageHandlerFunction[]\n } = {}\n \n onetimeHandlers: {\n [x: string]: CBSocketMessageHandlerFunction[]\n } = {}\n \n keysForIdentifiers: {\n \n [x: string]: string\n \n } = {}\n \n \n isValid = YES\n _storeableResponseKeys: string[] = []\n _storedResponseHashesDictionary: {\n \n [x: string]: {\n \n hash: string,\n validityDate: number\n \n }\n \n } = {}\n _verifiedResponseHashesDictionary: {\n \n [x: string]: boolean\n \n } = {}\n \n _socketClient: CBSocketClient\n \n \n \n \n \n constructor(socketClient: CBSocketClient, previousCallbackHolder?: CBSocketCallbackHolder) {\n \n super()\n \n \n this._socketClient = socketClient\n \n if (IS(previousCallbackHolder)) {\n \n this.handlers = previousCallbackHolder.handlers\n this._verifiedResponseHashesDictionary = previousCallbackHolder._verifiedResponseHashesDictionary\n \n }\n \n \n \n \n \n }\n \n \n \n \n \n triggerDisconnectHandlers() {\n \n this.messageDescriptors.forEach(function (descriptor: CBSocketCallbackHolderMessageDescriptor, key: string) {\n \n if (descriptor.mainResponseReceived) {\n \n descriptor.completionFunction(CBSocketClient.disconnectionMessage, nil)\n \n }\n \n })\n \n }\n \n \n \n \n \n registerHandler(key: string, handlerFunction: CBSocketMessageHandlerFunction) {\n \n \n if (!this.handlers[key]) {\n \n this.handlers[key] = []\n \n }\n \n this.handlers[key].push(handlerFunction)\n \n \n \n }\n \n registerOnetimeHandler(key: string, handlerFunction: CBSocketMessageHandlerFunction) {\n \n \n if (!this.onetimeHandlers[key]) {\n \n this.onetimeHandlers[key] = []\n \n }\n \n this.onetimeHandlers[key].push(handlerFunction)\n \n \n \n }\n \n \n \n \n \n get storedResponseHashesDictionary() {\n \n if (IS_NOT(this._storedResponseHashesDictionary)) {\n \n this._storedResponseHashesDictionary = JSON.parse(localStorage[\"CBSocketResponseHashesDictionary\"] || \"{}\")\n \n }\n \n return this._storedResponseHashesDictionary\n \n }\n \n storedResponseHashObjectForKey(requestKey: string, requestDataHash: string) {\n \n const localStorageKey = this.keyForRequestKeyAndRequestDataHash(requestKey, requestDataHash)\n \n const hashObject = this.storedResponseHashesDictionary[localStorageKey]\n \n const result = FIRST(hashObject, {} as any)\n \n \n \n return result\n \n }\n \n storedResponseForKey(requestKey: string, requestDataHash: string) {\n \n const localStorageKey = this.keyForRequestKeyAndRequestDataHash(requestKey, requestDataHash)\n \n const storedObject = JSON.parse(localStorage[localStorageKey] || \"{}\")\n \n return storedObject.responseMessageData\n \n }\n \n keyForRequestKeyAndRequestDataHash(requestKey: string, requestDataHash: string) {\n \n const result = \"_CBSCH_LS_key_\" + requestKey + \"_\" + requestDataHash\n \n return result\n \n }\n \n storeResponse(\n requestKey: string,\n requestDataHash: string,\n responseMessage: CBSocketMessage<any>,\n responseDataHash: string\n ) {\n \n \n if (!responseMessage.canBeStoredAsResponse ||\n (IS_NOT(responseMessage.messageData) && IS_NOT(responseMessage.messageDataHash))) {\n \n return\n \n }\n \n \n const localStorageKey = this.keyForRequestKeyAndRequestDataHash(requestKey, requestDataHash)\n \n \n var validityDate: number\n \n if (responseMessage.responseValidityDuration) {\n \n validityDate = Date.now() + responseMessage.responseValidityDuration\n \n }\n \n const storedResponseHashesDictionary = this.storedResponseHashesDictionary\n storedResponseHashesDictionary[localStorageKey] = {\n \n hash: responseDataHash,\n validityDate: validityDate!\n \n }\n \n this.saveInLocalStorage(localStorageKey, {\n \n responseMessageData: responseMessage.messageData,\n responseHash: responseDataHash\n \n })\n \n \n this.saveStoredResponseHashesDictionary(storedResponseHashesDictionary)\n \n }\n \n \n \n \n \n private saveStoredResponseHashesDictionary(storedResponseHashesDictionary: { [x: string]: { hash: string; validityDate: number; }; }) {\n \n this.saveInLocalStorage(\"CBSocketResponseHashesDictionary\", storedResponseHashesDictionary)\n \n }\n \n saveInLocalStorage(key: string, object: any) {\n \n \n const stringToSave = JSON.stringify(object)\n \n if (stringToSave != localStorage[key]) {\n \n localStorage[key] = stringToSave\n \n }\n \n \n }\n \n \n \n \n \n socketShouldSendMessage(\n key: string,\n message: CBSocketMessage<any>,\n completionPolicy: string,\n completionFunction: CBSocketMessageCompletionFunction\n ) {\n \n \n \n var result = YES\n \n var triggerStoredResponseImmediately = NO\n \n \n const messageDataHash = objectHash(message.messageData || nil)\n \n const descriptorKey = \"socketMessageDescriptor_\" + key + messageDataHash\n \n this.messageDescriptors[descriptorKey] = (this.messageDescriptors[descriptorKey] || [])\n \n \n const hashObject = this.storedResponseHashObjectForKey(key, messageDataHash)\n message.storedResponseHash = hashObject.hash\n \n \n \n if (completionPolicy == CBSocketClient.completionPolicy.first) {\n \n const descriptorsForKey = (this.messageDescriptors[descriptorKey] || [])\n \n const matchingDescriptor = descriptorsForKey.find(function (descriptor, index, array) {\n return (descriptor.messageDataHash == messageDataHash)\n })\n \n if (matchingDescriptor) {\n \n result = NO\n \n }\n \n }\n \n if (completionPolicy == CBSocketClient.completionPolicy.storedOrFirst) {\n \n const descriptorsForKey = (this.messageDescriptors[descriptorKey] || [])\n \n const matchingDescriptor = descriptorsForKey.find(function (descriptor, index, array) {\n return (descriptor.messageDataHash == messageDataHash)\n })\n \n const storedResponse = IS(message.storedResponseHash)\n \n if (matchingDescriptor ||\n (storedResponse && this._verifiedResponseHashesDictionary[message.storedResponseHash!])) {\n \n result = NO\n \n triggerStoredResponseImmediately = YES\n \n }\n \n }\n \n if (completionPolicy == CBSocketClient.completionPolicy.firstOnly) {\n \n const descriptorsForKey = (this.messageDescriptors[descriptorKey] || [])\n \n const matchingDescriptor = descriptorsForKey.find(function (descriptor, index, array) {\n return (descriptor.messageDataHash == messageDataHash)\n })\n \n if (matchingDescriptor) {\n \n return NO\n \n }\n \n }\n \n \n if (hashObject && hashObject.hash && hashObject.validityDate && message.storedResponseHash &&\n this._verifiedResponseHashesDictionary[message.storedResponseHash] && hashObject.validityDate >\n Date.now()) {\n \n result = NO\n \n triggerStoredResponseImmediately = YES\n \n }\n \n \n if (IS(completionFunction)) {\n \n this.messageDescriptors[descriptorKey].push({\n \n key: key,\n message: {\n \n identifier: message.identifier,\n inResponseToIdentifier: message.inResponseToIdentifier,\n keepWaitingForResponses: message.keepWaitingForResponses\n \n },\n \n sentAtTime: Date.now(),\n \n //completionTriggered: NO,\n \n \n messageDataHash: messageDataHash,\n \n mainResponseReceived: NO,\n anyMainResponseReceived: NO,\n \n \n completionPolicy: completionPolicy,\n completionFunction: completionFunction\n \n })\n \n this.keysForIdentifiers[message.identifier] = descriptorKey\n \n }\n \n \n if (triggerStoredResponseImmediately) {\n \n this.socketDidReceiveMessageForKey(\n CBSocketClient.responseMessageKey,\n {\n \n identifier: nil,\n messageData: nil,\n \n inResponseToIdentifier: message.identifier,\n \n useStoredResponse: YES\n \n },\n nil\n )\n \n }\n \n \n return result\n \n \n }\n \n \n \n \n \n static defaultMultipleMessagecompletionFunction(responseMessages: any[], callcompletionFunctions: () => void) {\n callcompletionFunctions()\n }\n \n \n socketWillSendMultipleMessage(\n messageToSend: CBSocketMultipleMessage,\n completionFunction: CBSocketMultipleMessagecompletionFunction = CBSocketCallbackHolder.defaultMultipleMessagecompletionFunction\n ) {\n \n \n \n const key = CBSocketClient.multipleMessageKey\n \n \n const messageDataHash = objectHash(messageToSend.messageData || nil)\n \n const descriptorKey = \"socketMessageDescriptor_\" + key + messageDataHash\n \n this.messageDescriptors[descriptorKey] = (this.messageDescriptors[descriptorKey] || [])\n \n \n messageToSend.storedResponseHash = this.storedResponseHashObjectForKey(key, messageDataHash).hash\n \n \n \n \n \n this.messageDescriptors[descriptorKey].push({\n \n key: key,\n message: {\n \n identifier: messageToSend.identifier,\n inResponseToIdentifier: messageToSend.inResponseToIdentifier,\n keepWaitingForResponses: messageToSend.keepWaitingForResponses\n \n },\n \n sentAtTime: Date.now(),\n \n //completionTriggered: NO,\n \n \n messageDataHash: messageDataHash,\n \n mainResponseReceived: NO,\n anyMainResponseReceived: NO,\n \n \n completionPolicy: CBSocketClient.completionPolicy.directOnly,\n completionFunction: function (\n this: CBSocketCallbackHolder,\n responseMessage: CBSocketMultipleMessageObject[],\n respondWithMessage: any\n ) {\n \n completionFunction(\n responseMessage.map(function (messageObject, index, array) {\n \n return messageObject.message.messageData\n \n }),\n function (this: CBSocketCallbackHolder) {\n \n //console.log(\"Received multiple message response with length of \" + responseMessage.length + \".\");\n \n // Call all completion functions\n responseMessage.forEach(function (\n this: CBSocketCallbackHolder,\n messageObject: CBSocketMultipleMessageObject,\n index: number,\n array: CBSocketMultipleMessageObject[]\n ) {\n \n this._socketClient.didReceiveMessageForKey(messageObject.key, messageObject.message)\n \n }.bind(this))\n \n }.bind(this)\n )\n \n }.bind(this)\n \n })\n \n this.keysForIdentifiers[messageToSend.identifier] = descriptorKey\n \n \n }\n \n \n \n \n \n socketDidReceiveMessageForKey(\n key: string,\n message: CBSocketMessage<any>,\n sendResponseFunction: CBSocketMessageSendResponseFunction\n ) {\n \n \n if (!this.isValid) {\n \n return\n \n }\n \n \n // Call static handlers\n if (this.handlers[key]) {\n \n this.handlers[key].forEach(function (\n this: CBSocketCallbackHolder,\n handler: CBSocketMessageHandlerFunction,\n index: any,\n array: any\n ) {\n \n handler(message.messageData, sendResponseFunction)\n \n }.bind(this))\n \n }\n \n if (this.onetimeHandlers[key]) {\n \n this.onetimeHandlers[key].forEach(function (\n this: CBSocketCallbackHolder,\n handler: CBSocketMessageHandlerFunction\n ) {\n \n handler(message.messageData, sendResponseFunction)\n \n }.bind(this))\n \n delete this.onetimeHandlers[key]\n \n }\n \n \n \n // Temporary response handlers are evaluated here\n if (message.inResponseToIdentifier &&\n (CBSocketClient.responseMessageKey == key || CBSocketClient.multipleMessageKey == key)) {\n \n // Find descriptors for the key of the message that is being responded to\n const descriptorKey = this.keysForIdentifiers[message.inResponseToIdentifier]\n const descriptorsForKey = (this.messageDescriptors[descriptorKey] || [])\n \n // Find response data hash to check for differences\n const responseDataHash = message.messageDataHash\n \n // Remove identifier from dictionary\n if (!message.keepWaitingForResponses) {\n \n delete this.keysForIdentifiers[message.inResponseToIdentifier]\n \n delete this.messageDescriptors[descriptorKey]\n \n }\n \n \n // Function to call completion function\n const callCompletionFunction = (descriptor: CBSocketCallbackHolderMessageDescriptor, storedResponseCondition = NO) => {\n \n var messageData = message.messageData\n \n if (message.useStoredResponse && storedResponseCondition) {\n \n messageData = this.storedResponseForKey(descriptor.key, descriptor.messageDataHash)\n \n const responseHash = this.storedResponseHashObjectForKey(\n descriptor.key,\n descriptor.messageDataHash\n ).hash\n \n const localStorageKey = this.keyForRequestKeyAndRequestDataHash(\n descriptor.key,\n descriptor.messageDataHash\n )\n \n if (message.responseValidityDuration && this.storedResponseHashesDictionary[localStorageKey]) {\n \n this.storedResponseHashesDictionary[localStorageKey].validityDate = Date.now() +\n message.responseValidityDuration\n \n this.saveStoredResponseHashesDictionary(this.storedResponseHashesDictionary)\n \n }\n \n this._verifiedResponseHashesDictionary[responseHash] = YES\n \n console.log(\"Using stored response.\")\n \n }\n \n // Call completionFunction and set response data hash\n descriptor.completionFunction(messageData, sendResponseFunction)\n descriptor.responseDataHash = responseDataHash\n \n }\n \n \n descriptorsForKey.copy().forEach(function (\n this: CBSocketCallbackHolder,\n descriptor: CBSocketCallbackHolderMessageDescriptor,\n index: number,\n array: CBSocketCallbackHolderMessageDescriptor[]\n ) {\n \n \n if ((descriptor.completionPolicy == CBSocketClient.completionPolicy.directOnly &&\n descriptor.message.identifier == message.inResponseToIdentifier) || descriptor.completionPolicy ==\n CBSocketClient.completionPolicy.first || descriptor.completionPolicy ==\n CBSocketClient.completionPolicy.firstOnly || descriptor.completionPolicy ==\n CBSocketClient.completionPolicy.storedOrFirst) {\n \n // Calling completion function and removing descriptor\n \n if (!message.keepWaitingForResponses) {\n \n this.storeResponse(descriptor.key, descriptor.messageDataHash, message, responseDataHash!)\n \n descriptorsForKey.removeElement(descriptor)\n \n sendResponseFunction.respondingToMainResponse = YES\n \n }\n \n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n }\n else if (descriptor.completionPolicy == CBSocketClient.completionPolicy.all) {\n \n // Calling completion function\n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n // Marking descriptor as having been responded to\n if (!message.keepWaitingForResponses) {\n \n if (message.inResponseToIdentifier == descriptor.message.identifier) {\n \n sendResponseFunction.respondingToMainResponse = YES\n descriptor.mainResponseReceived = YES\n descriptorsForKey.removeElement(descriptor)\n \n }\n \n descriptor.anyMainResponseReceived = YES\n \n }\n \n \n \n }\n else if (descriptor.completionPolicy == CBSocketClient.completionPolicy.allDifferent) {\n \n // Calling completionFunction if messageData is different from previous\n if (descriptor.responseDataHash != responseDataHash) {\n \n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n }\n \n // Marking descriptor as having been responded to\n if (!message.keepWaitingForResponses) {\n \n if (message.inResponseToIdentifier == descriptor.message.identifier) {\n \n sendResponseFunction.respondingToMainResponse = YES\n descriptor.mainResponseReceived = YES\n descriptorsForKey.removeElement(descriptor)\n \n }\n \n descriptor.anyMainResponseReceived = YES\n \n }\n \n }\n else if (descriptor.completionPolicy == CBSocketClient.completionPolicy.last &&\n descriptor.message.identifier == message.inResponseToIdentifier) {\n \n if (!message.keepWaitingForResponses) {\n \n // Marking descriptor as having been responded to\n descriptor.mainResponseReceived = YES\n descriptor.anyMainResponseReceived = YES\n \n sendResponseFunction.respondingToMainResponse = YES\n \n }\n else {\n \n descriptor.completionFunction(message.messageData, sendResponseFunction)\n \n }\n \n }\n else if (descriptor.completionPolicy == CBSocketClient.completionPolicy.firstAndLast ||\n descriptor.completionPolicy == CBSocketClient.completionPolicy.firstAndLastIfDifferent) {\n \n if (!message.keepWaitingForResponses) {\n \n // Only calling completionFunction once as a first response call\n if (!descriptor.anyMainResponseReceived) {\n \n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n }\n \n // Marking descriptor as having been responded to\n if (descriptor.message.identifier == message.inResponseToIdentifier) {\n \n descriptor.mainResponseReceived = YES\n sendResponseFunction.respondingToMainResponse = YES\n \n }\n \n descriptor.anyMainResponseReceived = YES\n \n }\n else if (descriptor.message.identifier == message.inResponseToIdentifier &&\n message.keepWaitingForResponses) {\n \n descriptor.completionFunction(message.messageData, sendResponseFunction)\n \n }\n \n }\n \n }.bind(this))\n \n \n \n \n \n // Last message completion policies\n \n const allResponsesReceived = descriptorsForKey.allMatch(function (descriptorObject, index, array) {\n return descriptorObject.mainResponseReceived\n })\n \n descriptorsForKey.copy().forEach(function (\n this: CBSocketCallbackHolder,\n descriptor: CBSocketCallbackHolderMessageDescriptor,\n index: number,\n array: CBSocketCallbackHolderMessageDescriptor[]\n ) {\n \n if ((descriptor.completionPolicy == CBSocketClient.completionPolicy.last ||\n descriptor.completionPolicy == CBSocketClient.completionPolicy.firstAndLast) &&\n allResponsesReceived && !message.keepWaitingForResponses) {\n \n // Calling completionFunction\n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n // Cleaning up\n descriptorsForKey.removeElement(descriptor)\n \n }\n else if (descriptor.completionPolicy == CBSocketClient.completionPolicy.firstAndLastIfDifferent &&\n allResponsesReceived && !message.keepWaitingForResponses) {\n \n // Calling completionFunction if needed\n if (descriptor.responseDataHash != responseDataHash) {\n \n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n }\n \n // Cleaning up\n descriptorsForKey.removeElement(descriptor)\n \n }\n \n }.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AAmB,QAAQ,aAAa,oBAAoB;AAAA,UAE3E;AAAA,QAEJ;AAAA,MAEJ,EAAE,KAAK,IAAI,CAAC;AAQZ,YAAM,uBAAuB,kBAAkB,SAAS,SAAU,kBAAkB,OAAO,OAAO;AAC9F,eAAO,iBAAiB;AAAA,MAC5B,CAAC;AAED,wBAAkB,KAAK,EAAE,QAAQ,SAE7B,YACA,OACA,OACF;AAEE,aAAK,WAAW,oBAAoB,qCAAe,iBAAiB,QAC5D,WAAW,oBAAoB,qCAAe,iBAAiB,iBACnE,wBAAwB,CAAC,QAAQ,yBAAyB;AAG1D,iCAAuB,YAAY,CAAC,QAAQ,uBAAuB;AAGnE,4BAAkB,cAAc,UAAU;AAAA,QAE9C,WACS,WAAW,oBAAoB,qCAAe,iBAAiB,2BACpE,wBAAwB,CAAC,QAAQ,yBAAyB;AAG1D,cAAI,WAAW,oBAAoB,kBAAkB;AAEjD,mCAAuB,YAAY,CAAC,QAAQ,uBAAuB;AAAA,UAEvE;AAGA,4BAAkB,cAAc,UAAU;AAAA,QAE9C;AAAA,MAEJ,EAAE,KAAK,IAAI,CAAC;AAAA,IAGhB;AAAA,EAMJ;AAMJ;",
|
|
6
6
|
"names": ["objectHash"]
|
|
7
7
|
}
|
|
@@ -58,7 +58,7 @@ export declare class CBSocketClient extends UIObject {
|
|
|
58
58
|
errorResult: any;
|
|
59
59
|
respondWithMessage: CBSocketMessageSendResponseFunction;
|
|
60
60
|
}>;
|
|
61
|
-
_sendMessageForKey(key: string, message: any, inResponseToMessage?: CBSocketMessage<any>, keepMessageConnectionOpen?: boolean, completionPolicy?: string, isUserBound?: boolean, didSendFunction?: () => void, completion?: CBSocketMessageCompletionFunction): CBSocketClientMessageToBeSent;
|
|
61
|
+
_sendMessageForKey(key: string, message: any, inResponseToMessage?: CBSocketMessage<any>, keepMessageConnectionOpen?: boolean, completionPolicy?: string, isUserBound?: boolean, didSendFunction?: () => void, completion?: CBSocketMessageCompletionFunction): CBSocketClientMessageToBeSent | undefined;
|
|
62
62
|
sendMessagesAsGroup<FunctionReturnType extends object>(functionToCall: () => FunctionReturnType): FunctionReturnType;
|
|
63
63
|
sendAndReceiveMessagesAsGroup<FunctionReturnType extends object>(functionToCall: () => FunctionReturnType, completion?: CBSocketMultipleMessagecompletionFunction): FunctionReturnType;
|
|
64
64
|
didReceiveMessageForKey(key: string, message: CBSocketMessage<any>): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -52,9 +53,9 @@ const _CBSocketClient = class extends import_uicore_ts.UIObject {
|
|
|
52
53
|
localStorage.setItem("InstanceIdentifier", instanceIdentifier);
|
|
53
54
|
}
|
|
54
55
|
const handshakeMessage = {
|
|
55
|
-
accessToken:
|
|
56
|
+
accessToken: void 0,
|
|
56
57
|
userID: this._core.userProfile._id,
|
|
57
|
-
inquiryAccessKey:
|
|
58
|
+
inquiryAccessKey: void 0,
|
|
58
59
|
instanceIdentifier
|
|
59
60
|
};
|
|
60
61
|
this.socket.emit("CBSocketHandshakeInitMessage", {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/CBSocketClient.ts"],
|
|
4
|
-
"sourcesContent": ["import { io, Socket } from \"socket.io-client\"\nimport { FIRST_OR_NIL, IF, IS, IS_NIL, IS_NOT, MAKE_ID, nil, NO, RETURNER, UIObject, YES } from \"../../uicore-ts\"\nimport { CBCore } from \"./CBCore\"\nimport {\n CBSocketHandshakeInitMessage,\n CBSocketHandshakeResponseMessage,\n CBSocketMessage,\n CBSocketMessageCompletionFunction,\n CBSocketMessageHandlerFunction,\n CBSocketMessageSendResponseFunction,\n CBSocketMultipleMessage,\n CBSocketMultipleMessagecompletionFunction,\n CBSocketMultipleMessageObject,\n SocketClientInterface\n} from \"./CBDataInterfaces\"\nimport { CBSocketCallbackHolder } from \"./CBSocketCallbackHolder\"\n\n\ndeclare interface CBSocketClientMessageToBeSent {\n \n key: string;\n message: any;\n \n inResponseToMessage: CBSocketMessage<any>;\n keepWaitingForResponses: boolean;\n \n isBoundToUserWithID: string;\n \n completionPolicy: string;\n \n didSendFunction?: () => void;\n \n completion: CBSocketMessageCompletionFunction;\n \n}\n\n\ndeclare interface CBSocketClientErrorMessage {\n \n _isCBSocketErrorMessage: boolean;\n \n messageData: any;\n \n}\n\n\ntype FilterConditionally<Source, Condition> = Pick<Source, { [K in keyof Source]: Source[K] extends Condition ? K : never }[keyof Source]>;\n\n\nexport function IS_SOCKET_ERROR(object: any): object is CBSocketClientErrorMessage {\n \n const result = (IS(object) && object._isCBSocketErrorMessage)\n \n return result\n \n}\n\nexport function IS_NOT_SOCKET_ERROR(object: any) {\n \n return !IS_SOCKET_ERROR(object)\n \n}\n\n\nexport class CBSocketClient extends UIObject {\n \n _socket: Socket = io()\n _isConnectionEstablished = NO\n \n _collectMessagesToSendLater = NO\n \n _messagesToBeSent: CBSocketClientMessageToBeSent[] = []\n \n static _sharedInstance: CBSocketClient\n \n _core: CBCore\n \n _subscribedKeys: {\n [x: string]: boolean\n } = {}\n \n _callbackHolder = new CBSocketCallbackHolder(this)\n \n static responseMessageKey = \"CBSocketResponseMessage\"\n static multipleMessageKey = \"CBSocketMultipleMessage\"\n \n \n static disconnectionMessage: CBSocketClientErrorMessage = {\n \n _isCBSocketErrorMessage: YES,\n \n messageData: \"Server disconnected\"\n \n }\n \n \n constructor(core: CBCore) {\n \n super()\n \n this._core = core\n \n \n this.socket.on(\"connect\", () => {\n \n console.log(\"Socket.io connected to server. clientID = \" + this.socket + \", socketID = \" + this.socket)\n \n var instanceIdentifier = localStorage.getItem(\"InstanceIdentifier\")\n \n if (IS_NOT(instanceIdentifier)) {\n \n instanceIdentifier = MAKE_ID()\n localStorage.setItem(\"InstanceIdentifier\", instanceIdentifier)\n \n }\n \n const handshakeMessage: CBSocketHandshakeInitMessage = {\n \n accessToken: null,\n userID: this._core.userProfile._id,\n \n inquiryAccessKey: null,\n \n instanceIdentifier: instanceIdentifier\n \n }\n \n this.socket.emit(\"CBSocketHandshakeInitMessage\", {\n \n identifier: MAKE_ID(),\n messageData: handshakeMessage\n \n })\n \n \n })\n \n \n this.socket.on(\n \"CBSocketHandshakeResponseMessage\",\n (message: CBSocketMessage<CBSocketHandshakeResponseMessage>) => {\n \n \n this._isConnectionEstablished = message.messageData.accepted\n \n if (!message.messageData.accepted) {\n \n console.log(\"SocketIO connection failed.\")\n \n this._core.dialogViewShowerClass.alert(\n \"Failed to establish connection to server.\",\n () => {\n }\n )\n \n }\n else {\n \n console.log(\"SocketIO connection handshake completed.\")\n \n this._callbackHolder = new CBSocketCallbackHolder(this, this._callbackHolder)\n \n core.userProfile = message.messageData.userProfile\n \n this.sendUnsentMessages()\n \n }\n \n \n }\n )\n \n \n this.socket.on(\"disconnect\", () => {\n \n console.log(\"Socket.io disconnected from server. clientID = \" + this.socket + \".\")\n \n this._isConnectionEstablished = NO\n \n this._callbackHolder.isValid = NO\n \n this._callbackHolder.triggerDisconnectHandlers()\n \n \n })\n \n \n this.socket.on(\"CBPerformReconnect\", (message?: string) => {\n \n console.log(\"Performing socket reconnection.\")\n \n core.reloadSocketConnection()\n \n if (message) {\n \n this._core.dialogViewShowerClass.alert(message)\n \n }\n \n \n })\n \n \n this._socket.on(\n CBSocketClient.responseMessageKey,\n (message: CBSocketMessage<any>) => {\n \n this.didReceiveMessageForKey(CBSocketClient.responseMessageKey, message)\n \n }\n )\n \n this._socket.on(\n CBSocketClient.multipleMessageKey,\n (message: CBSocketMessage<CBSocketMultipleMessageObject[]>) => {\n \n console.log(\"Received \" + message.messageData.length + \" messages.\")\n this.didReceiveMessageForKey(CBSocketClient.multipleMessageKey, message)\n \n }\n )\n \n \n }\n \n \n get socket() {\n return this._socket\n }\n \n \n cancelUnsentMessages(messagesToCancel: CBSocketClientMessageToBeSent[]) {\n \n this._messagesToBeSent = this._messagesToBeSent.filter((\n messageObject: CBSocketClientMessageToBeSent,\n index: number,\n array: CBSocketClientMessageToBeSent[]\n ) => !messagesToCancel.contains(messageObject))\n \n }\n \n \n sendUnsentMessages(receiveResponsesTogether = NO, completion?: CBSocketMultipleMessagecompletionFunction) {\n \n if (!this._isConnectionEstablished || this._collectMessagesToSendLater) {\n \n return\n \n }\n \n const groupedMessages: CBSocketMultipleMessageObject<any>[] = []\n const didSendFunctions: (() => void)[] = []\n \n \n this._messagesToBeSent.copy().forEach((messageToBeSentObject: CBSocketClientMessageToBeSent) => {\n \n if (this._isConnectionEstablished) {\n \n var message = messageToBeSentObject.message\n if (IS_NOT(message)) {\n message = \"\"\n }\n \n const identifier = MAKE_ID()\n \n const completion = messageToBeSentObject.completion\n \n const messageObject: CBSocketMessage<any> = {\n \n messageData: message,\n identifier: identifier,\n keepWaitingForResponses: messageToBeSentObject.keepWaitingForResponses,\n inResponseToIdentifier: messageToBeSentObject.inResponseToMessage.identifier\n \n }\n \n const shouldSendMessage = this._callbackHolder.socketShouldSendMessage(\n messageToBeSentObject.key,\n messageObject,\n messageToBeSentObject.completionPolicy,\n completion\n )\n \n if (shouldSendMessage) {\n \n \n groupedMessages.push({\n \n key: messageToBeSentObject.key,\n message: messageObject\n \n })\n \n \n }\n \n didSendFunctions.push(messageToBeSentObject.didSendFunction)\n \n \n }\n \n })\n \n \n this._messagesToBeSent = []\n \n if (IS_NOT(groupedMessages.length)) {\n \n return\n \n }\n \n if (groupedMessages.length == 1) {\n \n console.log(\"sending 1 unsent message.\")\n \n }\n else {\n \n console.log(\"Sending \" + groupedMessages.length + \" unsent messages.\")\n \n }\n \n \n const messageObject: CBSocketMultipleMessage = {\n \n messageData: groupedMessages,\n identifier: MAKE_ID(),\n \n shouldGroupResponses: receiveResponsesTogether\n \n }\n \n //if (receiveResponsesTogether) {\n \n this._callbackHolder.socketWillSendMultipleMessage(messageObject, completion)\n \n //}\n \n this.socket.emit(CBSocketClient.multipleMessageKey, messageObject)\n \n \n didSendFunctions.forEach((didSendFunction, index, array) => {\n didSendFunction()\n })\n \n }\n \n \n static completionPolicy = {\n \n \"all\": \"all\",\n \"allDifferent\": \"allDifferent\",\n \"first\": \"first\",\n \"last\": \"last\",\n \"firstAndLast\": \"firstAndLast\",\n \"firstAndLastIfDifferent\": \"firstAndLastIfDifferent\",\n \"directOnly\": \"directOnly\",\n \"firstOnly\": \"firstOnly\",\n \"storedOrFirst\": \"storedOrFirst\"\n \n }\n \n \n sendUserBoundMessageForKeyWithPolicy(\n key: keyof SocketClientInterface,\n message: any,\n completionPolicy: keyof typeof CBSocketClient.completionPolicy,\n completion?: CBSocketMessageCompletionFunction\n ) {\n \n \n this._sendMessageForKey(key as string, message, undefined, NO, completionPolicy, YES, nil, completion)\n \n }\n \n sendUserBoundMessageForKey(\n key: keyof SocketClientInterface,\n message: any,\n completion?: CBSocketMessageCompletionFunction\n ) {\n \n this._sendMessageForKey(key as string, message, undefined, NO, undefined, YES, nil, completion)\n \n }\n \n sendMessageForKeyWithPolicy(\n key: keyof SocketClientInterface,\n message: any,\n completionPolicy: keyof typeof CBSocketClient.completionPolicy,\n completion?: CBSocketMessageCompletionFunction\n ) {\n \n \n this._sendMessageForKey(key as string, message, undefined, NO, completionPolicy, NO, nil, completion)\n \n }\n \n sendMessageForKey(key: keyof SocketClientInterface, message: any, completion?: CBSocketMessageCompletionFunction) {\n \n this._sendMessageForKey(key as string, message, undefined, NO, undefined, NO, nil, completion)\n \n }\n \n \n resultForMessageForKey(\n key: keyof SocketClientInterface,\n message: any,\n completionPolicy?: keyof typeof CBSocketClient.completionPolicy,\n isUserBound = NO\n ) {\n \n const result = new Promise<{\n \n responseMessage: any,\n result: any,\n errorResult: any,\n \n respondWithMessage: CBSocketMessageSendResponseFunction\n \n }>((resolve, reject) => {\n \n this._sendMessageForKey(\n key as string,\n message,\n undefined,\n NO,\n completionPolicy,\n isUserBound,\n nil,\n (responseMessage, respondWithMessage) => resolve({\n \n responseMessage: responseMessage,\n result: IF(IS_NOT_SOCKET_ERROR(responseMessage))(() => responseMessage).ELSE(RETURNER(undefined)),\n errorResult: IF(IS_SOCKET_ERROR(responseMessage))(() => responseMessage).ELSE(RETURNER(undefined)),\n \n respondWithMessage: respondWithMessage\n \n })\n )\n \n })\n \n return result\n \n }\n \n \n _sendMessageForKey(\n key: string,\n message: any,\n inResponseToMessage: CBSocketMessage<any> = {} as any,\n keepMessageConnectionOpen = NO,\n completionPolicy = CBSocketClient.completionPolicy.directOnly,\n isUserBound = NO,\n didSendFunction: () => void = nil,\n completion: CBSocketMessageCompletionFunction = nil\n ) {\n \n if (IS_NIL(message)) {\n \n message = \"\"\n \n }\n \n if (this._isConnectionEstablished && !this._collectMessagesToSendLater) {\n \n const identifier = MAKE_ID()\n \n const messageObject: CBSocketMessage<any> = {\n \n messageData: message,\n identifier: identifier,\n keepWaitingForResponses: keepMessageConnectionOpen,\n inResponseToIdentifier: inResponseToMessage.identifier\n \n }\n \n const shouldSendMessage = this._callbackHolder.socketShouldSendMessage(\n key,\n messageObject,\n completionPolicy,\n completion\n )\n \n if (shouldSendMessage) {\n \n this.socket.emit(key, messageObject)\n \n }\n \n didSendFunction()\n \n }\n else {\n \n this._messagesToBeSent.push({\n \n key: key,\n message: message,\n inResponseToMessage: inResponseToMessage,\n keepWaitingForResponses: keepMessageConnectionOpen,\n completionPolicy: completionPolicy,\n isBoundToUserWithID: IF(isUserBound)(RETURNER(FIRST_OR_NIL(CBCore.sharedInstance.userProfile._id)))(),\n didSendFunction: didSendFunction,\n completion: completion\n \n })\n \n return this._messagesToBeSent.lastElement\n \n }\n \n }\n \n \n sendMessagesAsGroup<FunctionReturnType extends object>(functionToCall: () => FunctionReturnType) {\n \n const collectMessagesToSendLater = this._collectMessagesToSendLater\n \n this._collectMessagesToSendLater = YES\n \n var result = functionToCall()\n \n this._collectMessagesToSendLater = collectMessagesToSendLater\n \n this.sendUnsentMessages()\n \n return result\n \n }\n \n sendAndReceiveMessagesAsGroup<FunctionReturnType extends object>(\n functionToCall: () => FunctionReturnType,\n completion?: CBSocketMultipleMessagecompletionFunction\n ) {\n \n const collectMessagesToSendLater = this._collectMessagesToSendLater\n \n this._collectMessagesToSendLater = YES\n \n var result = functionToCall()\n \n this._collectMessagesToSendLater = collectMessagesToSendLater\n \n this.sendUnsentMessages(YES, completion)\n \n return result\n \n }\n \n \n didReceiveMessageForKey(key: string, message: CBSocketMessage<any>) {\n \n \n const sendResponseFunction: CBSocketMessageSendResponseFunction = function (\n this: CBSocketClient,\n responseMessage: any,\n completion: CBSocketMessageCompletionFunction\n ) {\n \n this._sendMessageForKey(\n CBSocketClient.responseMessageKey,\n responseMessage,\n message,\n NO,\n undefined,\n NO,\n nil,\n completion\n )\n \n }.bind(this) as any\n \n sendResponseFunction.sendIntermediateResponse = function (\n this: CBSocketClient,\n updateMessage: any,\n completion: CBSocketMessageCompletionFunction\n ) {\n \n this._sendMessageForKey(\n CBSocketClient.responseMessageKey,\n updateMessage,\n message,\n YES,\n undefined,\n NO,\n nil,\n completion\n )\n \n }.bind(this)\n \n const sendUserBoundResponseFunction: CBSocketMessageSendResponseFunction = function (\n this: CBSocketClient,\n responseMessage: any,\n completion: CBSocketMessageCompletionFunction\n ) {\n \n this._sendMessageForKey(\n CBSocketClient.responseMessageKey,\n responseMessage,\n message,\n NO,\n undefined,\n YES,\n nil,\n completion\n )\n \n }.bind(this) as any\n \n sendUserBoundResponseFunction.sendIntermediateResponse = function (\n this: CBSocketClient,\n updateMessage: any,\n completion: CBSocketMessageCompletionFunction\n ) {\n \n this._sendMessageForKey(\n CBSocketClient.responseMessageKey,\n updateMessage,\n message,\n YES,\n undefined,\n YES,\n nil,\n completion\n )\n \n }.bind(this)\n \n if (IS_SOCKET_ERROR(message.messageData)) {\n \n console.log(\"CBSocketClient did receive error message.\")\n \n console.log(message.messageData)\n \n \n }\n \n \n this._callbackHolder.socketDidReceiveMessageForKey(key, message, sendResponseFunction)\n \n }\n \n \n addTargetForMessagesForKeys(keys: string[], handlerFunction: CBSocketMessageHandlerFunction) {\n keys.forEach(function (this: CBSocketClient, key: string, index: number, array: string[]) {\n this.addTargetForMessagesForKey(key, handlerFunction)\n }.bind(this))\n }\n \n \n addTargetForMessagesForKey(key: string, handlerFunction: CBSocketMessageHandlerFunction) {\n \n this._callbackHolder.registerHandler(key, handlerFunction)\n \n if (IS_NOT(this._subscribedKeys[key])) {\n \n this._socket.on(key, function (this: CBSocketClient, message: CBSocketMessage<any>) {\n \n this.didReceiveMessageForKey(key, message)\n \n }.bind(this))\n \n this._subscribedKeys[key] = true\n \n }\n \n \n }\n \n addTargetForOneMessageForKey(key: string, handlerFunction: CBSocketMessageHandlerFunction) {\n \n this._callbackHolder.registerOnetimeHandler(key, handlerFunction)\n \n if (IS_NOT(this._subscribedKeys[key])) {\n \n this._socket.on(key, function (this: CBSocketClient, message: CBSocketMessage<any>) {\n \n this.didReceiveMessageForKey(key, message)\n \n }.bind(this))\n \n this._subscribedKeys[key] = true\n \n }\n \n \n }\n \n \n}\n\n\nexport const SocketClient: SocketClientInterface = new Proxy({ \"name\": \"SocketClient\" }, {\n \n get(target, key) {\n \n const result = (\n messageData,\n completionPolicy,\n isUserBound\n ) => CBCore.sharedInstance.socketClient.resultForMessageForKey(\n key as string,\n messageData,\n completionPolicy,\n isUserBound\n )\n \n \n return result\n \n }\n \n}) as any\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { io, Socket } from \"socket.io-client\"\nimport { FIRST_OR_NIL, IF, IS, IS_NIL, IS_NOT, MAKE_ID, nil, NO, RETURNER, UIObject, YES } from \"../../uicore-ts\"\nimport { CBCore } from \"./CBCore\"\nimport {\n CBSocketHandshakeInitMessage,\n CBSocketHandshakeResponseMessage,\n CBSocketMessage,\n CBSocketMessageCompletionFunction,\n CBSocketMessageHandlerFunction,\n CBSocketMessageSendResponseFunction,\n CBSocketMultipleMessage,\n CBSocketMultipleMessagecompletionFunction,\n CBSocketMultipleMessageObject,\n SocketClientInterface\n} from \"./CBDataInterfaces\"\nimport { CBSocketCallbackHolder } from \"./CBSocketCallbackHolder\"\n\n\ndeclare interface CBSocketClientMessageToBeSent {\n \n key: string;\n message: any;\n \n inResponseToMessage: CBSocketMessage<any>;\n keepWaitingForResponses: boolean;\n \n isBoundToUserWithID: string;\n \n completionPolicy: string;\n \n didSendFunction?: () => void;\n \n completion: CBSocketMessageCompletionFunction;\n \n}\n\n\ndeclare interface CBSocketClientErrorMessage {\n \n _isCBSocketErrorMessage: boolean;\n \n messageData: any;\n \n}\n\n\ntype FilterConditionally<Source, Condition> = Pick<Source, { [K in keyof Source]: Source[K] extends Condition ? K : never }[keyof Source]>;\n\n\nexport function IS_SOCKET_ERROR(object: any): object is CBSocketClientErrorMessage {\n \n const result = (IS(object) && object._isCBSocketErrorMessage)\n \n return result\n \n}\n\nexport function IS_NOT_SOCKET_ERROR(object: any) {\n \n return !IS_SOCKET_ERROR(object)\n \n}\n\n\nexport class CBSocketClient extends UIObject {\n \n _socket: Socket = io()\n _isConnectionEstablished = NO\n \n _collectMessagesToSendLater = NO\n \n _messagesToBeSent: CBSocketClientMessageToBeSent[] = []\n \n static _sharedInstance: CBSocketClient\n \n _core: CBCore\n \n _subscribedKeys: {\n [x: string]: boolean\n } = {}\n \n _callbackHolder = new CBSocketCallbackHolder(this)\n \n static responseMessageKey = \"CBSocketResponseMessage\"\n static multipleMessageKey = \"CBSocketMultipleMessage\"\n \n \n static disconnectionMessage: CBSocketClientErrorMessage = {\n \n _isCBSocketErrorMessage: YES,\n \n messageData: \"Server disconnected\"\n \n }\n \n \n constructor(core: CBCore) {\n \n super()\n \n this._core = core\n \n \n this.socket.on(\"connect\", () => {\n \n console.log(\"Socket.io connected to server. clientID = \" + this.socket + \", socketID = \" + this.socket)\n \n var instanceIdentifier = localStorage.getItem(\"InstanceIdentifier\")\n \n if (IS_NOT(instanceIdentifier)) {\n \n instanceIdentifier = MAKE_ID()\n localStorage.setItem(\"InstanceIdentifier\", instanceIdentifier)\n \n }\n \n const handshakeMessage: CBSocketHandshakeInitMessage = {\n \n accessToken: undefined,\n userID: this._core.userProfile._id,\n \n inquiryAccessKey: undefined,\n \n instanceIdentifier: instanceIdentifier\n \n }\n \n this.socket.emit(\"CBSocketHandshakeInitMessage\", {\n \n identifier: MAKE_ID(),\n messageData: handshakeMessage\n \n })\n \n \n })\n \n \n this.socket.on(\n \"CBSocketHandshakeResponseMessage\",\n (message: CBSocketMessage<CBSocketHandshakeResponseMessage>) => {\n \n \n this._isConnectionEstablished = message.messageData.accepted\n \n if (!message.messageData.accepted) {\n \n console.log(\"SocketIO connection failed.\")\n \n this._core.dialogViewShowerClass.alert(\n \"Failed to establish connection to server.\",\n () => {\n }\n )\n \n }\n else {\n \n console.log(\"SocketIO connection handshake completed.\")\n \n this._callbackHolder = new CBSocketCallbackHolder(this, this._callbackHolder)\n \n core.userProfile = message.messageData.userProfile\n \n this.sendUnsentMessages()\n \n }\n \n \n }\n )\n \n \n this.socket.on(\"disconnect\", () => {\n \n console.log(\"Socket.io disconnected from server. clientID = \" + this.socket + \".\")\n \n this._isConnectionEstablished = NO\n \n this._callbackHolder.isValid = NO\n \n this._callbackHolder.triggerDisconnectHandlers()\n \n \n })\n \n \n this.socket.on(\"CBPerformReconnect\", (message?: string) => {\n \n console.log(\"Performing socket reconnection.\")\n \n core.reloadSocketConnection()\n \n if (message) {\n \n this._core.dialogViewShowerClass.alert(message)\n \n }\n \n \n })\n \n \n this._socket.on(\n CBSocketClient.responseMessageKey,\n (message: CBSocketMessage<any>) => {\n \n this.didReceiveMessageForKey(CBSocketClient.responseMessageKey, message)\n \n }\n )\n \n this._socket.on(\n CBSocketClient.multipleMessageKey,\n (message: CBSocketMessage<CBSocketMultipleMessageObject[]>) => {\n \n console.log(\"Received \" + message.messageData.length + \" messages.\")\n this.didReceiveMessageForKey(CBSocketClient.multipleMessageKey, message)\n \n }\n )\n \n \n }\n \n \n get socket() {\n return this._socket\n }\n \n \n cancelUnsentMessages(messagesToCancel: CBSocketClientMessageToBeSent[]) {\n \n this._messagesToBeSent = this._messagesToBeSent.filter((\n messageObject: CBSocketClientMessageToBeSent,\n index: number,\n array: CBSocketClientMessageToBeSent[]\n ) => !messagesToCancel.contains(messageObject))\n \n }\n \n \n sendUnsentMessages(receiveResponsesTogether = NO, completion?: CBSocketMultipleMessagecompletionFunction) {\n \n if (!this._isConnectionEstablished || this._collectMessagesToSendLater) {\n \n return\n \n }\n \n const groupedMessages: CBSocketMultipleMessageObject<any>[] = []\n const didSendFunctions: (() => void)[] = []\n \n \n this._messagesToBeSent.copy().forEach((messageToBeSentObject: CBSocketClientMessageToBeSent) => {\n \n if (this._isConnectionEstablished) {\n \n var message = messageToBeSentObject.message\n if (IS_NOT(message)) {\n message = \"\"\n }\n \n const identifier = MAKE_ID()\n \n const completion = messageToBeSentObject.completion\n \n const messageObject: CBSocketMessage<any> = {\n \n messageData: message,\n identifier: identifier,\n keepWaitingForResponses: messageToBeSentObject.keepWaitingForResponses,\n inResponseToIdentifier: messageToBeSentObject.inResponseToMessage.identifier\n \n }\n \n const shouldSendMessage = this._callbackHolder.socketShouldSendMessage(\n messageToBeSentObject.key,\n messageObject,\n messageToBeSentObject.completionPolicy,\n completion\n )\n \n if (shouldSendMessage) {\n \n \n groupedMessages.push({\n \n key: messageToBeSentObject.key,\n message: messageObject\n \n })\n \n \n }\n \n didSendFunctions.push(messageToBeSentObject.didSendFunction!)\n \n \n }\n \n })\n \n \n this._messagesToBeSent = []\n \n if (IS_NOT(groupedMessages.length)) {\n \n return\n \n }\n \n if (groupedMessages.length == 1) {\n \n console.log(\"sending 1 unsent message.\")\n \n }\n else {\n \n console.log(\"Sending \" + groupedMessages.length + \" unsent messages.\")\n \n }\n \n \n const messageObject: CBSocketMultipleMessage = {\n \n messageData: groupedMessages,\n identifier: MAKE_ID(),\n \n shouldGroupResponses: receiveResponsesTogether\n \n }\n \n //if (receiveResponsesTogether) {\n \n this._callbackHolder.socketWillSendMultipleMessage(messageObject, completion)\n \n //}\n \n this.socket.emit(CBSocketClient.multipleMessageKey, messageObject)\n \n \n didSendFunctions.forEach((didSendFunction, index, array) => {\n didSendFunction()\n })\n \n }\n \n \n static completionPolicy = {\n \n \"all\": \"all\",\n \"allDifferent\": \"allDifferent\",\n \"first\": \"first\",\n \"last\": \"last\",\n \"firstAndLast\": \"firstAndLast\",\n \"firstAndLastIfDifferent\": \"firstAndLastIfDifferent\",\n \"directOnly\": \"directOnly\",\n \"firstOnly\": \"firstOnly\",\n \"storedOrFirst\": \"storedOrFirst\"\n \n }\n \n \n sendUserBoundMessageForKeyWithPolicy(\n key: keyof SocketClientInterface,\n message: any,\n completionPolicy: keyof typeof CBSocketClient.completionPolicy,\n completion?: CBSocketMessageCompletionFunction\n ) {\n \n \n this._sendMessageForKey(key as string, message, undefined, NO, completionPolicy, YES, nil, completion)\n \n }\n \n sendUserBoundMessageForKey(\n key: keyof SocketClientInterface,\n message: any,\n completion?: CBSocketMessageCompletionFunction\n ) {\n \n this._sendMessageForKey(key as string, message, undefined, NO, undefined, YES, nil, completion)\n \n }\n \n sendMessageForKeyWithPolicy(\n key: keyof SocketClientInterface,\n message: any,\n completionPolicy: keyof typeof CBSocketClient.completionPolicy,\n completion?: CBSocketMessageCompletionFunction\n ) {\n \n \n this._sendMessageForKey(key as string, message, undefined, NO, completionPolicy, NO, nil, completion)\n \n }\n \n sendMessageForKey(key: keyof SocketClientInterface, message: any, completion?: CBSocketMessageCompletionFunction) {\n \n this._sendMessageForKey(key as string, message, undefined, NO, undefined, NO, nil, completion)\n \n }\n \n \n resultForMessageForKey(\n key: keyof SocketClientInterface,\n message: any,\n completionPolicy?: keyof typeof CBSocketClient.completionPolicy,\n isUserBound = NO\n ) {\n \n const result = new Promise<{\n \n responseMessage: any,\n result: any,\n errorResult: any,\n \n respondWithMessage: CBSocketMessageSendResponseFunction\n \n }>((resolve, reject) => {\n \n this._sendMessageForKey(\n key as string,\n message,\n undefined,\n NO,\n completionPolicy,\n isUserBound,\n nil,\n (responseMessage, respondWithMessage) => resolve({\n \n responseMessage: responseMessage,\n result: IF(IS_NOT_SOCKET_ERROR(responseMessage))(() => responseMessage).ELSE(RETURNER(undefined)),\n errorResult: IF(IS_SOCKET_ERROR(responseMessage))(() => responseMessage).ELSE(RETURNER(undefined)),\n \n respondWithMessage: respondWithMessage\n \n })\n )\n \n })\n \n return result\n \n }\n \n \n _sendMessageForKey(\n key: string,\n message: any,\n inResponseToMessage: CBSocketMessage<any> = {} as any,\n keepMessageConnectionOpen = NO,\n completionPolicy = CBSocketClient.completionPolicy.directOnly,\n isUserBound = NO,\n didSendFunction: () => void = nil,\n completion: CBSocketMessageCompletionFunction = nil\n ) {\n \n if (IS_NIL(message)) {\n \n message = \"\"\n \n }\n \n if (this._isConnectionEstablished && !this._collectMessagesToSendLater) {\n \n const identifier = MAKE_ID()\n \n const messageObject: CBSocketMessage<any> = {\n \n messageData: message,\n identifier: identifier,\n keepWaitingForResponses: keepMessageConnectionOpen,\n inResponseToIdentifier: inResponseToMessage.identifier\n \n }\n \n const shouldSendMessage = this._callbackHolder.socketShouldSendMessage(\n key,\n messageObject,\n completionPolicy,\n completion\n )\n \n if (shouldSendMessage) {\n \n this.socket.emit(key, messageObject)\n \n }\n \n didSendFunction()\n \n }\n else {\n \n this._messagesToBeSent.push({\n \n key: key,\n message: message,\n inResponseToMessage: inResponseToMessage,\n keepWaitingForResponses: keepMessageConnectionOpen,\n completionPolicy: completionPolicy,\n isBoundToUserWithID: IF(isUserBound)(RETURNER(FIRST_OR_NIL(CBCore.sharedInstance.userProfile._id)))(),\n didSendFunction: didSendFunction,\n completion: completion\n \n })\n \n return this._messagesToBeSent.lastElement\n \n }\n \n }\n \n \n sendMessagesAsGroup<FunctionReturnType extends object>(functionToCall: () => FunctionReturnType) {\n \n const collectMessagesToSendLater = this._collectMessagesToSendLater\n \n this._collectMessagesToSendLater = YES\n \n var result = functionToCall()\n \n this._collectMessagesToSendLater = collectMessagesToSendLater\n \n this.sendUnsentMessages()\n \n return result\n \n }\n \n sendAndReceiveMessagesAsGroup<FunctionReturnType extends object>(\n functionToCall: () => FunctionReturnType,\n completion?: CBSocketMultipleMessagecompletionFunction\n ) {\n \n const collectMessagesToSendLater = this._collectMessagesToSendLater\n \n this._collectMessagesToSendLater = YES\n \n var result = functionToCall()\n \n this._collectMessagesToSendLater = collectMessagesToSendLater\n \n this.sendUnsentMessages(YES, completion)\n \n return result\n \n }\n \n \n didReceiveMessageForKey(key: string, message: CBSocketMessage<any>) {\n \n \n const sendResponseFunction: CBSocketMessageSendResponseFunction = function (\n this: CBSocketClient,\n responseMessage: any,\n completion: CBSocketMessageCompletionFunction\n ) {\n \n this._sendMessageForKey(\n CBSocketClient.responseMessageKey,\n responseMessage,\n message,\n NO,\n undefined,\n NO,\n nil,\n completion\n )\n \n }.bind(this) as any\n \n sendResponseFunction.sendIntermediateResponse = function (\n this: CBSocketClient,\n updateMessage: any,\n completion: CBSocketMessageCompletionFunction\n ) {\n \n this._sendMessageForKey(\n CBSocketClient.responseMessageKey,\n updateMessage,\n message,\n YES,\n undefined,\n NO,\n nil,\n completion\n )\n \n }.bind(this)\n \n const sendUserBoundResponseFunction: CBSocketMessageSendResponseFunction = function (\n this: CBSocketClient,\n responseMessage: any,\n completion: CBSocketMessageCompletionFunction\n ) {\n \n this._sendMessageForKey(\n CBSocketClient.responseMessageKey,\n responseMessage,\n message,\n NO,\n undefined,\n YES,\n nil,\n completion\n )\n \n }.bind(this) as any\n \n sendUserBoundResponseFunction.sendIntermediateResponse = function (\n this: CBSocketClient,\n updateMessage: any,\n completion: CBSocketMessageCompletionFunction\n ) {\n \n this._sendMessageForKey(\n CBSocketClient.responseMessageKey,\n updateMessage,\n message,\n YES,\n undefined,\n YES,\n nil,\n completion\n )\n \n }.bind(this)\n \n if (IS_SOCKET_ERROR(message.messageData)) {\n \n console.log(\"CBSocketClient did receive error message.\")\n \n console.log(message.messageData)\n \n \n }\n \n \n this._callbackHolder.socketDidReceiveMessageForKey(key, message, sendResponseFunction)\n \n }\n \n \n addTargetForMessagesForKeys(keys: string[], handlerFunction: CBSocketMessageHandlerFunction) {\n keys.forEach(function (this: CBSocketClient, key: string, index: number, array: string[]) {\n this.addTargetForMessagesForKey(key, handlerFunction)\n }.bind(this))\n }\n \n \n addTargetForMessagesForKey(key: string, handlerFunction: CBSocketMessageHandlerFunction) {\n \n this._callbackHolder.registerHandler(key, handlerFunction)\n \n if (IS_NOT(this._subscribedKeys[key])) {\n \n this._socket.on(key, function (this: CBSocketClient, message: CBSocketMessage<any>) {\n \n this.didReceiveMessageForKey(key, message)\n \n }.bind(this))\n \n this._subscribedKeys[key] = true\n \n }\n \n \n }\n \n addTargetForOneMessageForKey(key: string, handlerFunction: CBSocketMessageHandlerFunction) {\n \n this._callbackHolder.registerOnetimeHandler(key, handlerFunction)\n \n if (IS_NOT(this._subscribedKeys[key])) {\n \n this._socket.on(key, function (this: CBSocketClient, message: CBSocketMessage<any>) {\n \n this.didReceiveMessageForKey(key, message)\n \n }.bind(this))\n \n this._subscribedKeys[key] = true\n \n }\n \n \n }\n \n \n}\n\n\nexport const SocketClient: SocketClientInterface = new Proxy({ \"name\": \"SocketClient\" }, {\n \n get(target, key) {\n \n const result = (\n messageData: any,\n completionPolicy: string | undefined,\n isUserBound: boolean | undefined\n ) => CBCore.sharedInstance.socketClient.resultForMessageForKey(\n key as string,\n messageData,\n completionPolicy as any,\n isUserBound\n )\n \n \n return result\n \n }\n \n}) as any\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAC3B,uBAAgG;AAChG,oBAA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AE7C,EAAE,KAAK,IAAI,CAAC;AAEZ,WAAK,gBAAgB,OAAO;AAAA,IAEhC;AAAA,EAGJ;AAGJ;AApnBO,IAAM,iBAAN;AAAM,eAmBF,qBAAqB;AAnBnB,eAoBF,qBAAqB;AApBnB,eAuBF,uBAAmD;AAAA,EAEtD,yBAAyB;AAAA,EAEzB,aAAa;AAEjB;AA7BS,eA6RF,mBAAmB;AAAA,EAEtB,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,2BAA2B;AAAA,EAC3B,cAAc;AAAA,EACd,aAAa;AAAA,EACb,iBAAiB;AAErB;AA8UG,MAAM,eAAsC,IAAI,MAAM,EAAE,QAAQ,eAAe,GAAG;AAAA,EAErF,IAAI,QAAQ,KAAK;AAEb,UAAM,SAAS,CACX,aACA,kBACA,gBACC,qBAAO,eAAe,aAAa;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ;AAGA,WAAO;AAAA,EAEX;AAEJ,CAAC;",
|
|
6
6
|
"names": ["completion", "messageObject"]
|
|
7
7
|
}
|
package/compiledScripts/index.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/index.ts"],
|
|
4
4
|
"sourcesContent": ["\nexport * from \"./CBCore\"\nexport * from \"./CBServerClient\"\nexport * from \"./CBSocketClient\"\nexport * from \"./CBSocketCallbackHolder\"\nexport * from \"./CBLanguageService\"\nexport * from \"./CBDataInterfaces\"\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AACA,4BAAc,qBADd;AAEA,4BAAc,6BAFd;AAGA,4BAAc,6BAHd;AAIA,4BAAc,qCAJd;AAKA,4BAAc,gCALd;AAMA,4BAAc,+BANd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cbcore-ts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "CBCore is a library to build web applications using pure Typescript.",
|
|
5
5
|
"main": "compiledScripts/index.js",
|
|
6
6
|
"types": "compiledScripts/index.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@types/object-hash": "^2.1.1",
|
|
35
35
|
"object-hash": "^2.1.1",
|
|
36
36
|
"socket.io-client": "^4.5.2",
|
|
37
|
-
"uicore-ts": "^1.0.
|
|
37
|
+
"uicore-ts": "^1.0.57"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@rollup/plugin-commonjs": "^23.0.0",
|
package/scripts/CBCore.ts
CHANGED
|
@@ -19,11 +19,11 @@ import { CBSocketClient } from "./CBSocketClient"
|
|
|
19
19
|
|
|
20
20
|
declare interface CBDialogViewShower {
|
|
21
21
|
|
|
22
|
-
alert(text: string, dismissCallback?: Function)
|
|
23
|
-
localizedAlert(textObject: CBLocalizedTextObject, dismissCallback?: Function)
|
|
22
|
+
alert(text: string, dismissCallback?: Function): void
|
|
23
|
+
localizedAlert(textObject: CBLocalizedTextObject, dismissCallback?: Function): void
|
|
24
24
|
|
|
25
|
-
showActionIndicatorDialog(message: string, dismissCallback?: Function)
|
|
26
|
-
hideActionIndicatorDialog()
|
|
25
|
+
showActionIndicatorDialog(message: string, dismissCallback?: Function): void
|
|
26
|
+
hideActionIndicatorDialog(): void
|
|
27
27
|
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -218,11 +218,12 @@ export class CBCore extends UIObject {
|
|
|
218
218
|
|
|
219
219
|
|
|
220
220
|
get userProfile() {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
|
|
222
|
+
let result = nil
|
|
223
|
+
|
|
224
|
+
|
|
225
225
|
try {
|
|
226
|
+
// @ts-ignore
|
|
226
227
|
result = JSON.parse(localStorage.getItem("CBUserProfile"))
|
|
227
228
|
} catch (error) {
|
|
228
229
|
|
|
@@ -305,6 +306,7 @@ export class CBCore extends UIObject {
|
|
|
305
306
|
|
|
306
307
|
get externalServiceIdentifier(): { accessKey: string; serviceID: string; organizationID: string } {
|
|
307
308
|
|
|
309
|
+
// @ts-ignore
|
|
308
310
|
const result = JSON.parse(localStorage.getItem("CBExternalServiceIdentifier"))
|
|
309
311
|
|
|
310
312
|
return result
|
|
@@ -271,13 +271,13 @@ export interface CBSocketMessageSendResponseFunction<ResponseMessageType = any>
|
|
|
271
271
|
|
|
272
272
|
excludeMessageFromAutomaticConnectionEvents: () => void;
|
|
273
273
|
|
|
274
|
-
setResponseValidityDuration(duration: number);
|
|
274
|
+
setResponseValidityDuration(duration: number): void;
|
|
275
275
|
|
|
276
|
-
useStoredResponseWithErrorResponse();
|
|
276
|
+
useStoredResponseWithErrorResponse(): void;
|
|
277
277
|
|
|
278
|
-
sendErrorResponse(message?: any, completion?: CBSocketMessageCompletionFunction);
|
|
278
|
+
sendErrorResponse(message?: any, completion?: CBSocketMessageCompletionFunction): void;
|
|
279
279
|
|
|
280
|
-
sendIntermediateResponse(updateMessage: any, completion?: CBSocketMessageCompletionFunction);
|
|
280
|
+
sendIntermediateResponse(updateMessage: any, completion?: CBSocketMessageCompletionFunction): void;
|
|
281
281
|
|
|
282
282
|
// This tells the client to use the stored response if responseHash matches and also enables storing of responses
|
|
283
283
|
// in the client in the first place. Returns true if the hash matched.
|
|
@@ -96,7 +96,7 @@ export class CBLanguageService implements UILanguageService {
|
|
|
96
96
|
|
|
97
97
|
view = view as any || CBCore.sharedInstance.viewCores.everyElement.rootViewController.view.rootView as any
|
|
98
98
|
|
|
99
|
-
view
|
|
99
|
+
view?.broadcastEventInSubtree({
|
|
100
100
|
name: UIView.broadcastEventName.LanguageChanged,
|
|
101
101
|
parameters: {}
|
|
102
102
|
})
|
|
@@ -169,7 +169,7 @@ export class CBLanguageService implements UILanguageService {
|
|
|
169
169
|
parameters?: { [x: string]: string | UILocalizedTextObject; }
|
|
170
170
|
) {
|
|
171
171
|
|
|
172
|
-
var result
|
|
172
|
+
var result: string
|
|
173
173
|
|
|
174
174
|
if (IS(key) && CBLanguageService.languages[languageKey] &&
|
|
175
175
|
IS_DEFINED(CBLanguageService.languages[languageKey][key])) {
|
|
@@ -239,8 +239,9 @@ export class CBLanguageService implements UILanguageService {
|
|
|
239
239
|
|
|
240
240
|
const result = {}
|
|
241
241
|
|
|
242
|
-
CBLanguageService.languages.forEach(function (languageObject, languageKey) {
|
|
242
|
+
CBLanguageService.languages.forEach(function (languageObject: any, languageKey: string) {
|
|
243
243
|
|
|
244
|
+
// @ts-ignore
|
|
244
245
|
result[languageKey] = CBLanguageService.stringForKey(key, languageKey, defaultString, parameters)
|
|
245
246
|
|
|
246
247
|
})
|
|
@@ -305,16 +306,19 @@ export class CBLanguageService implements UILanguageService {
|
|
|
305
306
|
|
|
306
307
|
localizedTextObject = FIRST_OR_NIL(localizedTextObject)
|
|
307
308
|
|
|
308
|
-
|
|
309
|
-
|
|
309
|
+
// @ts-ignore
|
|
310
|
+
let result: string = localizedTextObject[CBLanguageService.currentLanguageKey]
|
|
311
|
+
|
|
310
312
|
if (IS_NOT(result)) {
|
|
311
313
|
|
|
314
|
+
// @ts-ignore
|
|
312
315
|
result = localizedTextObject[CBLanguageService.defaultLanguageKey]
|
|
313
316
|
|
|
314
317
|
}
|
|
315
318
|
|
|
316
319
|
if (IS_NOT(result)) {
|
|
317
320
|
|
|
321
|
+
// @ts-ignore
|
|
318
322
|
result = localizedTextObject["en"]
|
|
319
323
|
|
|
320
324
|
}
|
|
@@ -17,7 +17,7 @@ export class CBServerClient extends UIObject {
|
|
|
17
17
|
|
|
18
18
|
sendJSONObject(URL: string, objectToSend: any, completion: (response: any) => void) {
|
|
19
19
|
|
|
20
|
-
this.sendRequest("POST", URL, objectToSend, function (this: CBServerClient, status, response) {
|
|
20
|
+
this.sendRequest("POST", URL, objectToSend, function (this: CBServerClient, status: string | number, response: string) {
|
|
21
21
|
if (status != 200) {
|
|
22
22
|
|
|
23
23
|
console.log("GET " + URL + " " + status)
|
|
@@ -55,7 +55,7 @@ export class CBServerClient extends UIObject {
|
|
|
55
55
|
}
|
|
56
56
|
return
|
|
57
57
|
}
|
|
58
|
-
this.sendRequest("GET", URL, null, function (this: CBServerClient, status, response) {
|
|
58
|
+
this.sendRequest("GET", URL, null, function (this: CBServerClient, status: string | number, response: string) {
|
|
59
59
|
if (status != 200) {
|
|
60
60
|
|
|
61
61
|
console.log("GET " + URL + " " + status)
|
|
@@ -75,7 +75,7 @@ export class CBSocketCallbackHolder extends UIObject {
|
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
isValid = YES
|
|
78
|
-
_storeableResponseKeys: string[]
|
|
78
|
+
_storeableResponseKeys: string[] = []
|
|
79
79
|
_storedResponseHashesDictionary: {
|
|
80
80
|
|
|
81
81
|
[x: string]: {
|
|
@@ -85,7 +85,7 @@ export class CBSocketCallbackHolder extends UIObject {
|
|
|
85
85
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
}
|
|
88
|
+
} = {}
|
|
89
89
|
_verifiedResponseHashesDictionary: {
|
|
90
90
|
|
|
91
91
|
[x: string]: boolean
|
|
@@ -249,7 +249,7 @@ export class CBSocketCallbackHolder extends UIObject {
|
|
|
249
249
|
storedResponseHashesDictionary[localStorageKey] = {
|
|
250
250
|
|
|
251
251
|
hash: responseDataHash,
|
|
252
|
-
validityDate: validityDate
|
|
252
|
+
validityDate: validityDate!
|
|
253
253
|
|
|
254
254
|
}
|
|
255
255
|
|
|
@@ -346,7 +346,7 @@ export class CBSocketCallbackHolder extends UIObject {
|
|
|
346
346
|
const storedResponse = IS(message.storedResponseHash)
|
|
347
347
|
|
|
348
348
|
if (matchingDescriptor ||
|
|
349
|
-
(storedResponse && this._verifiedResponseHashesDictionary[message.storedResponseHash])) {
|
|
349
|
+
(storedResponse && this._verifiedResponseHashesDictionary[message.storedResponseHash!])) {
|
|
350
350
|
|
|
351
351
|
result = NO
|
|
352
352
|
|
|
@@ -501,7 +501,7 @@ export class CBSocketCallbackHolder extends UIObject {
|
|
|
501
501
|
completionFunction: function (
|
|
502
502
|
this: CBSocketCallbackHolder,
|
|
503
503
|
responseMessage: CBSocketMultipleMessageObject[],
|
|
504
|
-
respondWithMessage
|
|
504
|
+
respondWithMessage: any
|
|
505
505
|
) {
|
|
506
506
|
|
|
507
507
|
completionFunction(
|
|
@@ -562,8 +562,8 @@ export class CBSocketCallbackHolder extends UIObject {
|
|
|
562
562
|
this.handlers[key].forEach(function (
|
|
563
563
|
this: CBSocketCallbackHolder,
|
|
564
564
|
handler: CBSocketMessageHandlerFunction,
|
|
565
|
-
index,
|
|
566
|
-
array
|
|
565
|
+
index: any,
|
|
566
|
+
array: any
|
|
567
567
|
) {
|
|
568
568
|
|
|
569
569
|
handler(message.messageData, sendResponseFunction)
|
|
@@ -576,9 +576,7 @@ export class CBSocketCallbackHolder extends UIObject {
|
|
|
576
576
|
|
|
577
577
|
this.onetimeHandlers[key].forEach(function (
|
|
578
578
|
this: CBSocketCallbackHolder,
|
|
579
|
-
handler: CBSocketMessageHandlerFunction
|
|
580
|
-
index,
|
|
581
|
-
array
|
|
579
|
+
handler: CBSocketMessageHandlerFunction
|
|
582
580
|
) {
|
|
583
581
|
|
|
584
582
|
handler(message.messageData, sendResponseFunction)
|
|
@@ -613,7 +611,7 @@ export class CBSocketCallbackHolder extends UIObject {
|
|
|
613
611
|
|
|
614
612
|
|
|
615
613
|
// Function to call completion function
|
|
616
|
-
const callCompletionFunction = (descriptor, storedResponseCondition = NO) => {
|
|
614
|
+
const callCompletionFunction = (descriptor: CBSocketCallbackHolderMessageDescriptor, storedResponseCondition = NO) => {
|
|
617
615
|
|
|
618
616
|
var messageData = message.messageData
|
|
619
617
|
|
|
@@ -671,7 +669,7 @@ export class CBSocketCallbackHolder extends UIObject {
|
|
|
671
669
|
|
|
672
670
|
if (!message.keepWaitingForResponses) {
|
|
673
671
|
|
|
674
|
-
this.storeResponse(descriptor.key, descriptor.messageDataHash, message, responseDataHash)
|
|
672
|
+
this.storeResponse(descriptor.key, descriptor.messageDataHash, message, responseDataHash!)
|
|
675
673
|
|
|
676
674
|
descriptorsForKey.removeElement(descriptor)
|
|
677
675
|
|
|
@@ -116,10 +116,10 @@ export class CBSocketClient extends UIObject {
|
|
|
116
116
|
|
|
117
117
|
const handshakeMessage: CBSocketHandshakeInitMessage = {
|
|
118
118
|
|
|
119
|
-
accessToken:
|
|
119
|
+
accessToken: undefined,
|
|
120
120
|
userID: this._core.userProfile._id,
|
|
121
121
|
|
|
122
|
-
inquiryAccessKey:
|
|
122
|
+
inquiryAccessKey: undefined,
|
|
123
123
|
|
|
124
124
|
instanceIdentifier: instanceIdentifier
|
|
125
125
|
|
|
@@ -294,7 +294,7 @@ export class CBSocketClient extends UIObject {
|
|
|
294
294
|
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
didSendFunctions.push(messageToBeSentObject.didSendFunction)
|
|
297
|
+
didSendFunctions.push(messageToBeSentObject.didSendFunction!)
|
|
298
298
|
|
|
299
299
|
|
|
300
300
|
}
|
|
@@ -698,13 +698,13 @@ export const SocketClient: SocketClientInterface = new Proxy({ "name": "SocketCl
|
|
|
698
698
|
get(target, key) {
|
|
699
699
|
|
|
700
700
|
const result = (
|
|
701
|
-
messageData,
|
|
702
|
-
completionPolicy,
|
|
703
|
-
isUserBound
|
|
701
|
+
messageData: any,
|
|
702
|
+
completionPolicy: string | undefined,
|
|
703
|
+
isUserBound: boolean | undefined
|
|
704
704
|
) => CBCore.sharedInstance.socketClient.resultForMessageForKey(
|
|
705
705
|
key as string,
|
|
706
706
|
messageData,
|
|
707
|
-
completionPolicy,
|
|
707
|
+
completionPolicy as any,
|
|
708
708
|
isUserBound
|
|
709
709
|
)
|
|
710
710
|
|
package/tsconfig.json
CHANGED
|
@@ -30,14 +30,15 @@
|
|
|
30
30
|
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
31
31
|
|
|
32
32
|
/* Strict Type-Checking Options */
|
|
33
|
-
|
|
33
|
+
"strict": true,
|
|
34
|
+
/* Enable all strict type-checking options. */
|
|
34
35
|
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
35
36
|
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
36
37
|
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
37
38
|
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
38
39
|
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
39
40
|
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
40
|
-
|
|
41
|
+
"noImplicitOverride": true,
|
|
41
42
|
"strictBindCallApply": true,
|
|
42
43
|
/* Additional Checks */
|
|
43
44
|
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
@@ -46,7 +47,8 @@
|
|
|
46
47
|
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
47
48
|
|
|
48
49
|
/* Module Resolution Options */
|
|
49
|
-
|
|
50
|
+
"moduleResolution": "node",
|
|
51
|
+
/* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
50
52
|
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
51
53
|
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
52
54
|
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|