cbcore-ts 1.0.37 → 1.0.38

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.
@@ -113,8 +113,9 @@ const _CBCore = class _CBCore extends import_uicore_ts.UIObject {
113
113
  set userProfile(userProfile) {
114
114
  if ((0, import_uicore_ts.IS_NOT)(userProfile)) {
115
115
  localStorage.removeItem("CBUserProfile");
116
+ } else {
117
+ localStorage.setItem("CBUserProfile", JSON.stringify(userProfile));
116
118
  }
117
- localStorage.setItem("CBUserProfile", JSON.stringify(userProfile));
118
119
  this.didSetUserProfile();
119
120
  }
120
121
  didSetUserProfile() {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../scripts/CBCore.ts"],
4
- "sourcesContent": ["import { FIRST, IS, IS_NOT, nil, UICore, UILink, UIObject, UIRoute, UIViewBroadcastEvent, YES } from \"../../uicore-ts\"\nimport { CBLocalizedTextObject, CBUserProfile } from \"./CBDataInterfaces\"\nimport { CBLanguageService } from \"./CBLanguageService\"\nimport { CBServerClient } from \"./CBServerClient\"\nimport { CBSocketClient } from \"./CBSocketClient\"\n\n\ndeclare interface CBDialogViewShower {\n \n alert(text: string, dismissCallback?: Function): void\n \n localizedAlert(textObject: CBLocalizedTextObject, dismissCallback?: Function): void\n \n showActionIndicatorDialog(message: string, dismissCallback?: Function): void\n \n hideActionIndicatorDialog(): void\n \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 return\n }\n \n //console.log(\"\" + event.key + \" changed to \" + event.newValue + \" from \" + event.oldValue);\n \n \n if (event.key == \"CBLanguageKey\") {\n this.didSetLanguageKey()\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 static get sharedInstance() {\n if (!CBCore._sharedInstance) {\n CBCore._sharedInstance = new CBCore()\n }\n return CBCore._sharedInstance\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 get socketClient() {\n return this._socketClient\n }\n \n get serverClient() {\n return this._serverClient\n }\n \n \n set isUserLoggedIn(isUserLoggedIn: boolean) {\n const previousValue = this.isUserLoggedIn\n localStorage.setItem(\"CBIsUserLoggedIn\", \"\" + isUserLoggedIn)\n this.didSetIsUserLoggedIn(previousValue)\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 this.broadcastMessageInRootViewTree({\n name: CBCore.broadcastEventName.userDidLogIn,\n parameters: nil\n })\n \n this.updateLinkTargets()\n \n }\n else if (previousValue != isUserLoggedIn) {\n \n this.performFunctionWithDelay(0.01, function (this: CBCore) {\n \n UIRoute.currentRoute.routeByRemovingComponentsOtherThanOnesNamed([\n \"settings\"\n ]).apply()\n \n this.broadcastMessageInRootViewTree({\n name: CBCore.broadcastEventName.userDidLogOut,\n parameters: nil\n })\n \n this.updateLinkTargets()\n \n }.bind(this))\n \n }\n \n }\n \n updateLinkTargets() {\n this.viewCores.everyElement.rootViewController.view.forEachViewInSubtree(function (view) {\n if (view instanceof UILink) {\n view.updateTarget()\n }\n })\n }\n \n get isUserLoggedIn() {\n return (localStorage.getItem(\"CBIsUserLoggedIn\") == \"true\")\n }\n \n \n get userProfile() {\n const text = localStorage.getItem(\"CBUserProfile\")\n if (text) {\n return JSON.parse(text) as CBUserProfile\n }\n return undefined\n }\n \n set userProfile(userProfile: CBUserProfile) {\n if (IS_NOT(userProfile)) {\n localStorage.removeItem(\"CBUserProfile\")\n }\n localStorage.setItem(\"CBUserProfile\", JSON.stringify(userProfile))\n this.didSetUserProfile()\n }\n \n didSetUserProfile() {\n this.isUserLoggedIn = IS(this.userProfile)\n }\n \n \n set languageKey(languageKey: string) {\n if (IS_NOT(languageKey)) {\n localStorage.removeItem(\"CBLanguageKey\")\n }\n localStorage.setItem(\"CBLanguageKey\", JSON.stringify(languageKey))\n this.didSetLanguageKey()\n }\n \n get languageKey() {\n return FIRST(localStorage.getItem(\"CBLanguageKey\"), CBLanguageService.defaultLanguageKey).replace(\n \"\\\"\",\n \"\"\n ).replace(\"\\\"\", \"\")\n }\n \n didSetLanguageKey() {\n UIRoute.currentRoute.routeWithComponent(\n \"settings\",\n { \"language\": this.languageKey },\n YES\n ).applyByReplacingCurrentRouteInHistory()\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 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,uBAAqG;AAErG,+BAAkC;AAClC,4BAA+B;AAC/B,4BAA+B;AAmBxB,MAAM,UAAN,MAAM,gBAAe,0BAAS;AAAA,EAiBjC,cAAc;AAEV,UAAM;AAfV,qBAAsB,CAAC;AAEvB,2BAA2B;AAC3B,0CAA2C;AAC3C,yBAAgC,IAAI,qCAAe,IAAI;AACvD,yBAAgC,IAAI,qCAAe,IAAI;AAEvD,+CAAsD,CAAC;AAEvD,mBAAiB,CAAC;AAElB,iCAA4C;AAMxC,QAAI,yBAAyB;AAEzB,iDAAkB,wBAAwB,wBAAwB,cAAc;AAAA,IAEpF;AAGA,WAAO,iBAAiB,WAAW,SAAwB,OAAqB;AAE5E,UAAI,MAAM,YAAY,MAAM,UAAU;AAClC;AAAA,MACJ;AAKA,UAAI,MAAM,OAAO,iBAAiB;AAC9B,aAAK,kBAAkB;AAAA,MAC3B;AAAA,IAEJ,EAAE,KAAK,IAAI,CAAC;AAKZ,SAAK,kBAAkB;AAAA,EAG3B;AAAA,EAGA,OAAO,yBAAyB,UAAkB;AAE9C,YAAO,eAAe,UAAU,KAAK,QAAQ;AAAA,EAEjD;AAAA,EAGA,WAAW,iBAAiB;AACxB,QAAI,CAAC,QAAO,iBAAiB;AACzB,cAAO,kBAAkB,IAAI,QAAO;AAAA,IACxC;AACA,WAAO,QAAO;AAAA,EAClB;AAAA,EAUA,+BAA+B,SAA+B;AAE1D,SAAK,UAAU,aAAa,mBAAmB,KAAK,wBAAwB,OAAO;AAAA,EAEvF;AAAA,EAGA,IAAI,eAAe;AACf,WAAO,KAAK;AAAA,E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B;AAAA,EAExB,gBAAgB;AAAA,EAChB,iBAAiB;AAErB;AAxEG,IAAM,SAAN;",
4
+ "sourcesContent": ["import { FIRST, IS, IS_NOT, nil, UICore, UILink, UIObject, UIRoute, UIViewBroadcastEvent, YES } from \"../../uicore-ts\"\nimport { CBLocalizedTextObject, CBUserProfile } from \"./CBDataInterfaces\"\nimport { CBLanguageService } from \"./CBLanguageService\"\nimport { CBServerClient } from \"./CBServerClient\"\nimport { CBSocketClient } from \"./CBSocketClient\"\n\n\ndeclare interface CBDialogViewShower {\n \n alert(text: string, dismissCallback?: Function): void\n \n localizedAlert(textObject: CBLocalizedTextObject, dismissCallback?: Function): void\n \n showActionIndicatorDialog(message: string, dismissCallback?: Function): void\n \n hideActionIndicatorDialog(): void\n \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 return\n }\n \n //console.log(\"\" + event.key + \" changed to \" + event.newValue + \" from \" + event.oldValue);\n \n \n if (event.key == \"CBLanguageKey\") {\n this.didSetLanguageKey()\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 static get sharedInstance() {\n if (!CBCore._sharedInstance) {\n CBCore._sharedInstance = new CBCore()\n }\n return CBCore._sharedInstance\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 get socketClient() {\n return this._socketClient\n }\n \n get serverClient() {\n return this._serverClient\n }\n \n \n set isUserLoggedIn(isUserLoggedIn: boolean) {\n const previousValue = this.isUserLoggedIn\n localStorage.setItem(\"CBIsUserLoggedIn\", \"\" + isUserLoggedIn)\n this.didSetIsUserLoggedIn(previousValue)\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 this.broadcastMessageInRootViewTree({\n name: CBCore.broadcastEventName.userDidLogIn,\n parameters: nil\n })\n \n this.updateLinkTargets()\n \n }\n else if (previousValue != isUserLoggedIn) {\n \n this.performFunctionWithDelay(0.01, function (this: CBCore) {\n \n UIRoute.currentRoute.routeByRemovingComponentsOtherThanOnesNamed([\n \"settings\"\n ]).apply()\n \n this.broadcastMessageInRootViewTree({\n name: CBCore.broadcastEventName.userDidLogOut,\n parameters: nil\n })\n \n this.updateLinkTargets()\n \n }.bind(this))\n \n }\n \n }\n \n updateLinkTargets() {\n this.viewCores.everyElement.rootViewController.view.forEachViewInSubtree(function (view) {\n if (view instanceof UILink) {\n view.updateTarget()\n }\n })\n }\n \n get isUserLoggedIn() {\n return (localStorage.getItem(\"CBIsUserLoggedIn\") == \"true\")\n }\n \n \n get userProfile() {\n const text = localStorage.getItem(\"CBUserProfile\")\n if (text) {\n return JSON.parse(text) as CBUserProfile\n }\n return undefined\n }\n \n set userProfile(userProfile: CBUserProfile) {\n if (IS_NOT(userProfile)) {\n localStorage.removeItem(\"CBUserProfile\")\n \n }\n else {\n localStorage.setItem(\"CBUserProfile\", JSON.stringify(userProfile))\n }\n this.didSetUserProfile()\n }\n \n didSetUserProfile() {\n this.isUserLoggedIn = IS(this.userProfile)\n }\n \n \n set languageKey(languageKey: string) {\n if (IS_NOT(languageKey)) {\n localStorage.removeItem(\"CBLanguageKey\")\n }\n localStorage.setItem(\"CBLanguageKey\", JSON.stringify(languageKey))\n this.didSetLanguageKey()\n }\n \n get languageKey() {\n return FIRST(localStorage.getItem(\"CBLanguageKey\"), CBLanguageService.defaultLanguageKey).replace(\n \"\\\"\",\n \"\"\n ).replace(\"\\\"\", \"\")\n }\n \n didSetLanguageKey() {\n UIRoute.currentRoute.routeWithComponent(\n \"settings\",\n { \"language\": this.languageKey },\n YES\n ).applyByReplacingCurrentRouteInHistory()\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 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,uBAAqG;AAErG,+BAAkC;AAClC,4BAA+B;AAC/B,4BAA+B;AAmBxB,MAAM,UAAN,MAAM,gBAAe,0BAAS;AAAA,EAiBjC,cAAc;AAEV,UAAM;AAfV,qBAAs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GAAG,2CAAkB,kBAAkB,EAAE;AAAA,MACtF;AAAA,MACA;AAAA,IACJ,EAAE,QAAQ,KAAM,EAAE;AAAA,EACtB;AAAA,EAEA,oBAAoB;AAChB,6BAAQ,aAAa;AAAA,MACjB;AAAA,MACA,EAAE,YAAY,KAAK,YAAY;AAAA,MAC/B;AAAA,IACJ,EAAE,sCAAsC;AAAA,EAC5C;AAAA,EAGA,yBAAyB;AAGrB,SAAK,aAAa,OAAO,WAAW;AAEpC,UAAM,mBAAmB,KAAK,aAAa,kBAAkB,OAAO,SAAU,aAAa,OAAO,OAAO;AAErG,aAAQ,CAAC,YAAY,uBAAuB,YAAY,uBACpD,QAAO,eAAe,YAAY;AAAA,IAE1C,CAAC;AAED,SAAK,gBAAgB,IAAI,qCAAe,IAAI;AAC5C,SAAK,cAAc,oBAAoB;AAEvC,UAAM,eAAe,KAAK;AAE1B,SAAK,QAAQ,QAAQ,SAAU,OAAO,OAAO,OAAO;AAEhD,YAAM,gBAAgB,YAAY;AAAA,IAEtC,CAAC;AAED,SAAK,oCAAoC,QAAQ,SAAU,gBAAgB,OAAO,OAAO;AAErF,qBAAe;AAAA,IAEnB,CAAC;AAAA,EAGL;AAAA,EAGA,gCAAgC,gBAA4B;AACxD,SAAK,oCAAoC,KAAK,cAAc;AAC5D,mBAAe;AAAA,EACnB;AAGJ;AAxOa,QAmEF,qBAAqB;AAAA,EAExB,gBAAgB;AAAA,EAChB,iBAAiB;AAErB;AAxEG,IAAM,SAAN;",
6
6
  "names": []
7
7
  }
@@ -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 const isInstanceIdentifierAllowed = localStorage.getItem(\"IsInstanceIdentifierAllowed\") == \"true\"\n \n let instanceIdentifier = IF(isInstanceIdentifierAllowed)(() => \n localStorage.getItem(\"InstanceIdentifier\")\n ).ELSE(() => \n \"\"\n )\n \n if (IS_NOT(instanceIdentifier) && isInstanceIdentifierAllowed) {\n \n instanceIdentifier = MAKE_ID()\n localStorage.setItem(\"InstanceIdentifier\", instanceIdentifier!)\n \n }\n \n const handshakeMessage: CBSocketHandshakeInitMessage = {\n \n accessToken: localStorage.getItem(\"CBUserAccessToken\") ?? 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 \n core.userProfile = message.messageData.userProfile\n \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,MAAM,wBAAuB,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;AAvGxC;AAyGY,cAAQ,IAAI,8CAA8C,KAAK,QAAQ,gBAAgB,KAAK,MAAM;AAElG,YAAM,8BAA8B,aAAa,QAAQ,6BAA6B,KAAK;AAE3F,UAAI,yBAAqB,qBAAG,2BAA2B;AAAA,QAAE,MACrD,aAAa,QAAQ,oBAAoB;AAAA,MAC7C,EAAE;AAAA,QAAK,MACH;AAAA,MACJ;AAEA,cAAI,yBAAO,kBAAkB,KAAK,6BAA6B;AAE3D,iCAAqB,0BAAQ;AAC7B,qBAAa,QAAQ,sBAAsB,kBAAmB;AAAA,MAElE;AAEA,YAAM,mBAAiD;AAAA,QAEnD,cAAa,kBAAa,QAAQ,mBAAmB,MAAxC,YAA6C;AAAA,QAC1D,SAAQ,UAAK,MAAM,gBAAX,mBAAwB;AAAA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J;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 const isInstanceIdentifierAllowed = localStorage.getItem(\"IsInstanceIdentifierAllowed\") == \"true\"\n \n let instanceIdentifier = IF(isInstanceIdentifierAllowed)(() => \n localStorage.getItem(\"InstanceIdentifier\")\n ).ELSE(() => \n \"\"\n )\n \n if (IS_NOT(instanceIdentifier) && isInstanceIdentifierAllowed) {\n \n instanceIdentifier = MAKE_ID()\n localStorage.setItem(\"InstanceIdentifier\", instanceIdentifier!)\n \n }\n \n const handshakeMessage: CBSocketHandshakeInitMessage = {\n \n accessToken: localStorage.getItem(\"CBUserAccessToken\") ?? 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 core.userProfile = message.messageData.userProfile\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 this._callbackHolder.isValid = NO\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 if (message) {\n this._core.dialogViewShowerClass.alert(message)\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,MAAM,wBAAuB,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;AAvGxC;AAyGY,cAAQ,IAAI,8CAA8C,KAAK,QAAQ,gBAAgB,KAAK,MAAM;AAElG,YAAM,8BAA8B,aAAa,QAAQ,6BAA6B,KAAK;AAE3F,UAAI,yBAAqB,qBAAG,2BAA2B;AAAA,QAAE,MACrD,aAAa,QAAQ,oBAAoB;AAAA,MAC7C,EAAE;AAAA,QAAK,MACH;AAAA,MACJ;AAEA,cAAI,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iB;AAErB;AA1SG,IAAM,iBAAN;AAynBA,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cbcore-ts",
3
- "version": "1.0.37",
3
+ "version": "1.0.38",
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",
package/scripts/CBCore.ts CHANGED
@@ -177,8 +177,11 @@ export class CBCore extends UIObject {
177
177
  set userProfile(userProfile: CBUserProfile) {
178
178
  if (IS_NOT(userProfile)) {
179
179
  localStorage.removeItem("CBUserProfile")
180
+
181
+ }
182
+ else {
183
+ localStorage.setItem("CBUserProfile", JSON.stringify(userProfile))
180
184
  }
181
- localStorage.setItem("CBUserProfile", JSON.stringify(userProfile))
182
185
  this.didSetUserProfile()
183
186
  }
184
187
 
@@ -165,11 +165,7 @@ export class CBSocketClient extends UIObject {
165
165
  console.log("SocketIO connection handshake completed.")
166
166
 
167
167
  this._callbackHolder = new CBSocketCallbackHolder(this, this._callbackHolder)
168
-
169
-
170
168
  core.userProfile = message.messageData.userProfile
171
-
172
-
173
169
  this.sendUnsentMessages()
174
170
 
175
171
  }
@@ -184,9 +180,7 @@ export class CBSocketClient extends UIObject {
184
180
  console.log("Socket.io disconnected from server. clientID = ", this.socket)
185
181
 
186
182
  this._isConnectionEstablished = NO
187
-
188
183
  this._callbackHolder.isValid = NO
189
-
190
184
  this._callbackHolder.triggerDisconnectHandlers()
191
185
 
192
186
 
@@ -198,11 +192,8 @@ export class CBSocketClient extends UIObject {
198
192
  console.log("Performing socket reconnection.")
199
193
 
200
194
  core.reloadSocketConnection()
201
-
202
195
  if (message) {
203
-
204
196
  this._core.dialogViewShowerClass.alert(message)
205
-
206
197
  }
207
198
 
208
199