cbcore-ts 1.0.11 → 1.0.18

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.
@@ -22,8 +22,8 @@ export declare class CBCore extends UIObject {
22
22
  static initIfNeededWithViewCore(viewCore: UICore): void;
23
23
  static get sharedInstance(): CBCore;
24
24
  static broadcastEventName: {
25
- userDidLogIn: string;
26
- userDidLogOut: string;
25
+ readonly userDidLogIn: "UserDidLogIn";
26
+ readonly userDidLogOut: "UserDidLogOut";
27
27
  };
28
28
  broadcastMessageInRootViewTree(message: UIViewBroadcastEvent): void;
29
29
  get socketClient(): CBSocketClient;
@@ -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): 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"],
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 } as const\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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CAAoC,QAAQ,SAAU,gBAAgB,OAAO,OAAO;AAErF,qBAAe;AAAA,IAEnB,CAAC;AAAA,EAIL;AAAA,EAGA,gCAAgC,gBAA4B;AACxD,SAAK,oCAAoC,KAAK,cAAc;AAC5D,mBAAe;AAAA,EACnB;AAGJ;AA1UO,IAAM,SAAN;AAAM,OA4EF,qBAAqB;AAAA,EAExB,gBAAgB;AAAA,EAChB,iBAAiB;AAErB;",
6
6
  "names": []
7
7
  }
@@ -38,15 +38,15 @@ export declare class CBSocketClient extends UIObject {
38
38
  cancelUnsentMessages(messagesToCancel: CBSocketClientMessageToBeSent[]): void;
39
39
  sendUnsentMessages(receiveResponsesTogether?: boolean, completion?: CBSocketMultipleMessagecompletionFunction): void;
40
40
  static completionPolicy: {
41
- all: string;
42
- allDifferent: string;
43
- first: string;
44
- last: string;
45
- firstAndLast: string;
46
- firstAndLastIfDifferent: string;
47
- directOnly: string;
48
- firstOnly: string;
49
- storedOrFirst: string;
41
+ readonly all: "all";
42
+ readonly allDifferent: "allDifferent";
43
+ readonly first: "first";
44
+ readonly last: "last";
45
+ readonly firstAndLast: "firstAndLast";
46
+ readonly firstAndLastIfDifferent: "firstAndLastIfDifferent";
47
+ readonly directOnly: "directOnly";
48
+ readonly firstOnly: "firstOnly";
49
+ readonly storedOrFirst: "storedOrFirst";
50
50
  };
51
51
  sendUserBoundMessageForKeyWithPolicy(key: keyof SocketClientInterface, message: any, completionPolicy: keyof typeof CBSocketClient.completionPolicy, completion?: CBSocketMessageCompletionFunction): void;
52
52
  sendUserBoundMessageForKey(key: keyof SocketClientInterface, message: any, completion?: CBSocketMessageCompletionFunction): void;
@@ -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 | undefined;
61
+ _sendMessageForKey(key: string, message: any, inResponseToMessage?: CBSocketMessage<any>, keepMessageConnectionOpen?: boolean, completionPolicy?: keyof typeof CBSocketClient.completionPolicy, 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,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: 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 completionPolicy: messageToBeSentObject.completionPolicy\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 completionPolicy: CBSocketClient.completionPolicy.all,\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 completionPolicy: completionPolicy\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,oBAAuB;AAavB,oCAAuC;AAkChC,SAAS,gBAAgB,QAAmD;AAE/E,QAAM,aAAU,qBAAG,MAAM,KAAK,OAAO;AAErC,SAAO;AAEX;AAEO,SAAS,oBAAoB,QAAa;AAE7C,SAAO,CAAC,gBAAgB,MAAM;AAElC;AAGO,MAAM,kBAAN,cAA6B,0BAAS;AAAA,EAgCzC,YAAY,MAAc;AAEtB,UAAM;AAhCV,uBAAkB,kBAAG;AACrB,oCAA2B;AAE3B,uCAA8B;AAE9B,6BAAqD,CAAC;AAMtD,2BAEI,CAAC;AAEL,2BAAkB,IAAI,qDAAuB,IAAI;AA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AAS;AAAA,EACT,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,2BAA2B;AAAA,EAC3B,cAAc;AAAA,EACd,aAAa;AAAA,EACb,iBAAiB;AAErB;AA+UG,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;",
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 completionPolicy: messageToBeSentObject.completionPolicy\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 completionPolicy: CBSocketClient.completionPolicy.all,\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 } as const\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: keyof typeof CBSocketClient.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 completionPolicy: completionPolicy\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,oBAAuB;AAavB,oCAAuC;AAkChC,SAAS,gBAAgB,QAAmD;AAE/E,QAAM,aAAU,qBAAG,MAAM,KAAK,OAAO;AAErC,SAAO;AAEX;AAEO,SAAS,oBAAoB,QAAa;AAE7C,SAAO,CAAC,gBAAgB,MAAM;AAElC;AAGO,MAAM,kBAAN,cAA6B,0BAAS;AAAA,EAgCzC,YAAY,MAAc;AAEtB,UAAM;AAhCV,uBAAkB,kBAAG;AACrB,oCAA2B;AAE3B,uCAA8B;AAE9B,6BAAqD,CAAC;AAMtD,2BAEI,CAAC;AAEL,2BAAkB,IAAI,qDAAuB,IAAI;AAmB7C,SAAK,QAAQ;AAGb,SAAK,OAAO,GAAG,WAAW,MAAM;AAE5B,cAAQ,IAAI,+CAA+C,KAAK,SAAS,kBAAkB,KAAK,MAAM;AAEtG,UAAI,qBAAqB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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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cbcore-ts",
3
- "version": "1.0.11",
3
+ "version": "1.0.18",
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.225"
37
+ "uicore-ts": "1.0.287"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@rollup/plugin-commonjs": "^23.0.0",
package/scripts/CBCore.ts CHANGED
@@ -111,7 +111,7 @@ export class CBCore extends UIObject {
111
111
  "userDidLogIn": "UserDidLogIn",
112
112
  "userDidLogOut": "UserDidLogOut"
113
113
 
114
- }
114
+ } as const
115
115
 
116
116
  broadcastMessageInRootViewTree(message: UIViewBroadcastEvent) {
117
117
 
@@ -361,7 +361,7 @@ export class CBSocketClient extends UIObject {
361
361
  "firstOnly": "firstOnly",
362
362
  "storedOrFirst": "storedOrFirst"
363
363
 
364
- }
364
+ } as const
365
365
 
366
366
 
367
367
  sendUserBoundMessageForKeyWithPolicy(
@@ -453,7 +453,7 @@ export class CBSocketClient extends UIObject {
453
453
  message: any,
454
454
  inResponseToMessage: CBSocketMessage<any> = {} as any,
455
455
  keepMessageConnectionOpen = NO,
456
- completionPolicy = CBSocketClient.completionPolicy.directOnly,
456
+ completionPolicy: keyof typeof CBSocketClient.completionPolicy = CBSocketClient.completionPolicy.directOnly,
457
457
  isUserBound = NO,
458
458
  didSendFunction: () => void = nil,
459
459
  completion: CBSocketMessageCompletionFunction = nil