cbcore-ts 1.0.32 → 1.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiledScripts/CBCore.d.ts +1 -1
- package/compiledScripts/CBCore.js +3 -3
- package/compiledScripts/CBCore.js.map +2 -2
- package/compiledScripts/CBLanguageService.js +5 -5
- package/compiledScripts/CBLanguageService.js.map +1 -1
- package/compiledScripts/CBServerClient.js.map +1 -1
- package/compiledScripts/CBSocketCallbackHolder.js +6 -0
- package/compiledScripts/CBSocketCallbackHolder.js.map +1 -1
- package/compiledScripts/CBSocketClient.js +13 -8
- package/compiledScripts/CBSocketClient.js.map +2 -2
- package/compiledScripts/index.js +17 -8
- package/compiledScripts/index.js.map +1 -1
- package/package.json +4 -4
- package/scripts/CBCore.ts +1 -1
- package/scripts/CBSocketClient.ts +8 -2
|
@@ -30,7 +30,7 @@ export declare class CBCore extends UIObject {
|
|
|
30
30
|
get serverClient(): CBServerClient;
|
|
31
31
|
set isUserLoggedIn(isUserLoggedIn: boolean);
|
|
32
32
|
didSetIsUserLoggedIn(previousValue: boolean): void;
|
|
33
|
-
|
|
33
|
+
updateLinkTargets(): void;
|
|
34
34
|
get isUserLoggedIn(): boolean;
|
|
35
35
|
get userProfile(): CBUserProfile;
|
|
36
36
|
set userProfile(userProfile: CBUserProfile);
|
|
@@ -25,7 +25,7 @@ var import_uicore_ts = require("../../uicore-ts");
|
|
|
25
25
|
var import_CBLanguageService = require("./CBLanguageService");
|
|
26
26
|
var import_CBServerClient = require("./CBServerClient");
|
|
27
27
|
var import_CBSocketClient = require("./CBSocketClient");
|
|
28
|
-
const _CBCore = class extends import_uicore_ts.UIObject {
|
|
28
|
+
const _CBCore = class _CBCore extends import_uicore_ts.UIObject {
|
|
29
29
|
constructor() {
|
|
30
30
|
super();
|
|
31
31
|
this.viewCores = [];
|
|
@@ -160,11 +160,11 @@ const _CBCore = class extends import_uicore_ts.UIObject {
|
|
|
160
160
|
functionToCall();
|
|
161
161
|
}
|
|
162
162
|
};
|
|
163
|
-
|
|
164
|
-
CBCore.broadcastEventName = {
|
|
163
|
+
_CBCore.broadcastEventName = {
|
|
165
164
|
"userDidLogIn": "UserDidLogIn",
|
|
166
165
|
"userDidLogOut": "UserDidLogOut"
|
|
167
166
|
};
|
|
167
|
+
let CBCore = _CBCore;
|
|
168
168
|
// Annotate the CommonJS export names for ESM import in node:
|
|
169
169
|
0 && (module.exports = {
|
|
170
170
|
CBCore
|
|
@@ -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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAqG;AAErG,+BAAkC;AAClC,4BAA+B;AAC/B,4BAA+B;AAmBxB,MAAM,UAAN,
|
|
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;AAmB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3B;AAAA,EAEA,IAAI,cAAc;AACd,eAAO,wBAAM,aAAa,QAAQ,eAAe,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;AArOa,QAmEF,qBAAqB;AAAA,EAExB,gBAAgB;AAAA,EAChB,iBAAiB;AAErB;AAxEG,IAAM,SAAN;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -23,7 +23,7 @@ __export(CBLanguageService_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(CBLanguageService_exports);
|
|
24
24
|
var import_uicore_ts = require("uicore-ts");
|
|
25
25
|
var import_CBCore = require("./CBCore");
|
|
26
|
-
const _CBLanguageService = class {
|
|
26
|
+
const _CBLanguageService = class _CBLanguageService {
|
|
27
27
|
static useStoredLanguageValues(values = {}) {
|
|
28
28
|
const result = JSON.parse(JSON.stringify(this.languageValues)).objectByCopyingValuesRecursivelyFromObject(
|
|
29
29
|
values
|
|
@@ -140,9 +140,8 @@ const _CBLanguageService = class {
|
|
|
140
140
|
return _CBLanguageService.currentClassObject.stringForCurrentLanguage(localizedTextObject);
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
CBLanguageService.languageValues = {
|
|
143
|
+
_CBLanguageService.currentClassObject = _CBLanguageService;
|
|
144
|
+
_CBLanguageService.languageValues = {
|
|
146
145
|
en: {
|
|
147
146
|
languageName: "English",
|
|
148
147
|
languageNameShort: "ENG",
|
|
@@ -158,7 +157,8 @@ CBLanguageService.languageValues = {
|
|
|
158
157
|
leftBarTitle: "Pealkiri"
|
|
159
158
|
}
|
|
160
159
|
};
|
|
161
|
-
|
|
160
|
+
_CBLanguageService.languages = JSON.parse(JSON.stringify(_CBLanguageService.languageValues));
|
|
161
|
+
let CBLanguageService = _CBLanguageService;
|
|
162
162
|
import_uicore_ts.UICore.languageService = CBLanguageService;
|
|
163
163
|
// Annotate the CommonJS export names for ESM import in node:
|
|
164
164
|
0 && (module.exports = {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/CBLanguageService.ts"],
|
|
4
4
|
"sourcesContent": ["import {\n FIRST_OR_NIL,\n IS,\n IS_DEFINED,\n IS_NOT,\n nil,\n UICore,\n UILanguageService,\n UILocalizedTextObject,\n UIRoute,\n UIView\n} from \"uicore-ts\"\nimport { CBCore } from \"./CBCore\"\nimport { CBLocalizedTextObject } from \"./CBDataInterfaces\"\n\n\nexport interface ParticularLanguageValues {\n \n [x: string]: string\n \n topBarTitle: string;\n selectLanguageTitle: string;\n languageNameShort: string;\n leftBarTitle: string;\n languageName: string\n \n}\n\n\nexport interface LanguageValues {\n \n [x: string]: ParticularLanguageValues\n \n en: ParticularLanguageValues\n est: ParticularLanguageValues\n \n}\n\n\nexport class CBLanguageService implements UILanguageService {\n \n static currentClassObject = CBLanguageService\n \n static _currentLanguageKey: string\n \n static languageValues: LanguageValues = {\n \n en: {\n \n languageName: \"English\",\n languageNameShort: \"ENG\",\n \n topBarTitle: \"UICore application\",\n \n selectLanguageTitle: \"Select language\",\n leftBarTitle: \"Title\"\n \n \n },\n est: {\n \n languageName: \"Eesti keel\",\n languageNameShort: \"EST\",\n \n topBarTitle: \"UICore rakendus\",\n \n selectLanguageTitle: \"Vali keel\",\n leftBarTitle: \"Pealkiri\"\n \n \n }\n \n \n }\n \n static languages = JSON.parse(JSON.stringify(this.languageValues))\n \n static useStoredLanguageValues(values = {}) {\n \n const result = JSON.parse(JSON.stringify(this.languageValues))\n .objectByCopyingValuesRecursivelyFromObject(\n values) as any\n \n if (JSON.stringify(result) != JSON.stringify(this.languages)) {\n \n this.languages = result\n \n this.broadcastLanguageChangeEvent()\n \n }\n \n }\n \n \n static broadcastLanguageChangeEvent(view?: UIView) {\n \n view = view as any || CBCore.sharedInstance.viewCores.everyElement.rootViewController.view.rootView as any\n \n view?.broadcastEventInSubtree({\n name: UIView.broadcastEventName.LanguageChanged,\n parameters: {}\n })\n \n }\n \n static get defaultLanguageKey() {\n \n // @ts-ignore\n return (CBCoreInitializerObject.defaultLanguageKey || \"en\")\n \n }\n \n static get currentLanguageKey() {\n \n if (!this._currentLanguageKey) {\n \n this.updateCurrentLanguageKey()\n \n }\n \n return this._currentLanguageKey\n \n }\n \n updateCurrentLanguageKey() {\n \n CBLanguageService.currentClassObject.updateCurrentLanguageKey()\n \n }\n \n static updateCurrentLanguageKey(route = UIRoute.currentRoute) {\n \n let result = route.componentWithName(\"settings\")?.parameters?.language\n \n if (IS_NOT(result)) {\n \n result = this.defaultLanguageKey\n \n }\n \n const isChanged = (result != this._currentLanguageKey)\n \n this._currentLanguageKey = result\n \n if (isChanged) {\n \n CBCore.sharedInstance.languageKey = result\n \n this.broadcastLanguageChangeEvent()\n \n }\n \n }\n \n get currentLanguageKey() {\n \n const result = CBLanguageService.currentClassObject.currentLanguageKey\n \n return result\n \n }\n \n \n static stringForKey(\n key: string,\n languageKey: string,\n defaultString: string,\n parameters?: { [x: string]: string | UILocalizedTextObject; }\n ) {\n \n var result: string\n \n if (IS(key) && this.languages[languageKey] &&\n IS_DEFINED(this.languages[languageKey][key])) {\n \n result = this.languages[languageKey][key]\n \n }\n else {\n \n result = defaultString\n \n }\n \n if (IS(parameters)) {\n \n const parameterKeys = Object.keys(parameters)\n \n parameterKeys.forEach(function (key, index, array) {\n \n const keyString = \"%\" + key + \"%\"\n \n const parameter = parameters[key]\n \n var parameterString\n \n if (parameter instanceof Object) {\n \n parameterString = UICore.languageService.stringForCurrentLanguage(parameter as UILocalizedTextObject)\n \n }\n else {\n \n parameterString = parameter\n \n }\n \n \n result = result.replace(new RegExp(keyString, \"g\"), parameterString)\n \n })\n \n }\n \n return result\n \n }\n \n stringForKey(\n key: string,\n languageKey: string,\n defaultString: string,\n parameters?: { [x: string]: string | UILocalizedTextObject; }\n ) {\n \n \n return CBLanguageService.currentClassObject.stringForKey(key, languageKey, defaultString, parameters)\n \n \n }\n \n \n static localizedTextObjectForKey(\n key: string,\n defaultString = key,\n parameters?: { [x: string]: string | UILocalizedTextObject; }\n ) {\n \n const result = {}\n \n this.languages.forEach((languageObject: any, languageKey: string) => {\n \n // @ts-ignore\n result[languageKey] = this.stringForKey(key, languageKey, defaultString, parameters)\n \n })\n \n return result\n \n }\n \n localizedTextObjectForKey(\n key: string,\n defaultString?: string,\n parameters?: { [x: string]: string | UILocalizedTextObject; }\n ) {\n \n const result = CBLanguageService.currentClassObject.localizedTextObjectForKey(key, defaultString, parameters)\n \n return result\n \n }\n \n \n static localizedTextObjectForText(text: string) {\n \n if (IS_NOT(text)) {\n \n return nil\n \n }\n \n const result = {\n \n [this.defaultLanguageKey]: text\n \n }\n \n return result\n \n }\n \n localizedTextObjectForText(text: string) {\n \n const result = CBLanguageService.currentClassObject.localizedTextObjectForText(text)\n \n return result\n \n }\n \n \n static stringForCurrentLanguage(localizedTextObject: CBLocalizedTextObject | string) {\n \n if (localizedTextObject === \"\" + localizedTextObject) {\n \n return localizedTextObject\n \n }\n \n localizedTextObject = FIRST_OR_NIL(localizedTextObject)\n \n // @ts-ignore\n let result: string = localizedTextObject[this.currentLanguageKey]\n \n if (IS_NOT(result)) {\n \n // @ts-ignore\n result = localizedTextObject[this.defaultLanguageKey]\n \n }\n \n if (IS_NOT(result)) {\n \n // @ts-ignore\n result = localizedTextObject[\"en\"]\n \n }\n \n if (IS_NOT(result)) {\n \n result = \"\"\n \n }\n \n return result\n \n }\n \n stringForCurrentLanguage(localizedTextObject: CBLocalizedTextObject) {\n \n return CBLanguageService.currentClassObject.stringForCurrentLanguage(localizedTextObject)\n \n }\n \n \n}\n\n\nUICore.languageService = CBLanguageService\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAWO;AACP,oBAAuB;AA2BhB,MAAM,qBAAN,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAWO;AACP,oBAAuB;AA2BhB,MAAM,qBAAN,MAAM,mBAA+C;AAAA,EAsCxD,OAAO,wBAAwB,SAAS,CAAC,GAAG;AAExC,UAAM,SAAS,KAAK,MAAM,KAAK,UAAU,KAAK,cAAc,CAAC,EACxD;AAAA,MACG;AAAA,IAAM;AAEd,QAAI,KAAK,UAAU,MAAM,KAAK,KAAK,UAAU,KAAK,SAAS,GAAG;AAE1D,WAAK,YAAY;AAEjB,WAAK,6BAA6B;AAAA,IAEtC;AAAA,EAEJ;AAAA,EAGA,OAAO,6BAA6B,MAAe;AAE/C,WAAO,QAAe,qBAAO,eAAe,UAAU,aAAa,mBAA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AEA,YAAI,yBAAO,MAAM,GAAG;AAGhB,eAAS,oBAAoB,IAAI;AAAA,IAErC;AAEA,YAAI,yBAAO,MAAM,GAAG;AAEhB,eAAS;AAAA,IAEb;AAEA,WAAO;AAAA,EAEX;AAAA,EAEA,yBAAyB,qBAA4C;AAEjE,WAAO,mBAAkB,mBAAmB,yBAAyB,mBAAmB;AAAA,EAE5F;AAGJ;AAxSa,mBAEF,qBAAqB;AAFnB,mBAMF,iBAAiC;AAAA,EAEpC,IAAI;AAAA,IAEA,cAAc;AAAA,IACd,mBAAmB;AAAA,IAEnB,aAAa;AAAA,IAEb,qBAAqB;AAAA,IACrB,cAAc;AAAA,EAGlB;AAAA,EACA,KAAK;AAAA,IAED,cAAc;AAAA,IACd,mBAAmB;AAAA,IAEnB,aAAa;AAAA,IAEb,qBAAqB;AAAA,IACrB,cAAc;AAAA,EAGlB;AAGJ;AAlCS,mBAoCF,YAAY,KAAK,MAAM,KAAK,UAAU,mBAAK,cAAc,CAAC;AApC9D,IAAM,oBAAN;AA2SP,wBAAO,kBAAkB;",
|
|
6
6
|
"names": ["key"]
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/CBServerClient.ts"],
|
|
4
4
|
"sourcesContent": ["import { IS, nil, UIObject, YES } from \"../../uicore-ts\"\nimport { CBCore } from \"./CBCore\"\n\n\nexport class CBServerClient extends UIObject {\n \n _core: CBCore\n \n constructor(core: CBCore) {\n \n super()\n \n this._core = core\n \n }\n \n \n sendJSONObject(URL: string, objectToSend: any, completion: (response: any) => void) {\n \n this.sendRequest(\"POST\", URL, objectToSend, function (this: CBServerClient, status: string | number, response: string) {\n if (status != 200) {\n \n console.log(\"GET \" + URL + \" \" + status)\n \n if (IS(completion)) {\n completion(nil)\n }\n return\n }\n const result = JSON.parse(response)\n \n if (IS(completion)) {\n completion(result)\n }\n }.bind(this))\n \n }\n \n retrieveJSONObject(URL: string, completion: (response: any) => void) {\n \n this.retrieveJSONObjectWithCaching(URL, nil, nil, YES, completion)\n \n }\n \n retrieveJSONObjectWithCaching(\n URL: string,\n cacheObject: any,\n cacheKey: string,\n forceUpdate: boolean,\n completion: (response: any) => void\n ) {\n if (IS(cacheObject[cacheKey]) && !forceUpdate) {\n if (IS(completion)) {\n completion(cacheObject[cacheKey])\n }\n return\n }\n this.sendRequest(\"GET\", URL, null, function (this: CBServerClient, status: string | number, response: string) {\n if (status != 200) {\n \n console.log(\"GET \" + URL + \" \" + status)\n \n if (IS(completion)) {\n completion(nil)\n }\n return\n }\n const result = JSON.parse(response)\n cacheObject[cacheKey] = result\n if (IS(completion)) {\n completion(result)\n }\n }.bind(this))\n }\n \n sendRequest(method: string, URL: string, data: any, completion: (status: number, response: string) => void) {\n \n const xhr = new XMLHttpRequest()\n xhr.open(method, URL, true)\n xhr.setRequestHeader(\"Content-Type\", \"application/json;charset=UTF-8\")\n xhr.onreadystatechange = processRequest\n \n function processRequest(event: Event) {\n \n if (xhr.readyState == 4) {\n if (IS(completion)) {\n completion(xhr.status, xhr.responseText)\n }\n }\n \n }\n \n xhr.send(JSON.stringify(data))\n \n }\n \n \n \n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAuC;AAIhC,MAAM,uBAAuB,0BAAS;AAAA,EAIzC,YAAY,MAAc;AAEtB,UAAM;AAEN,SAAK,QAAQ;AAAA,EAEjB;AAAA,EAGA,eAAe,KAAa,cAAmB,YAAqC;AAEhF,SAAK,YAAY,QAAQ,KAAK,cAAc,SAAgC,QAAyB,UAAkB;AACnH,UAAI,UAAU,KAAK;AAEf,gBAAQ,IAAI,SAAS,MAAM,MAAM,MAAM;AAEvC,gBAAI,qBAAG,UAAU,GA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;AAAA,IACJ;AACA,SAAK,YAAY,OAAO,KAAK,MAAM,SAAgC,QAAyB,UAAkB;AAC1G,UAAI,UAAU,KAAK;AAEf,gBAAQ,IAAI,SAAS,MAAM,MAAM,MAAM;AAEvC,gBAAI,qBAAG,UAAU,GAAG;AAChB,qBAAW,oBAAG;AAAA,QAClB;AACA;AAAA,MACJ;AACA,YAAM,SAAS,KAAK,MAAM,QAAQ;AAClC,kBAAY,QAAQ,IAAI;AACxB,cAAI,qBAAG,UAAU,GAAG;AAChB,mBAAW,MAAM;AAAA,MACrB;AAAA,IACJ,EAAE,KAAK,IAAI,CAAC;AAAA,EAChB;AAAA,EAEA,YAAY,QAAgB,KAAa,MAAW,YAAwD;AAExG,UAAM,MAAM,IAAI,eAAe;AAC/B,QAAI,KAAK,QAAQ,KAAK,IAAI;AAC1B,QAAI,iBAAiB,gBAAgB,gCAAgC;AACrE,QAAI,qBAAqB;AAEzB,aAAS,eAAe,OAAc;AAElC,UAAI,IAAI,cAAc,GAAG;AACrB,gBAAI,qBAAG,UAAU,GAAG;AAChB,qBAAW,IAAI,QAAQ,IAAI,YAAY;AAAA,QAC3C;AAAA,MACJ;AAAA,IAEJ;AAEA,QAAI,KAAK,KAAK,UAAU,IAAI,CAAC;AAAA,EAEjC;AAMJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -166,6 +170,7 @@ class CBSocketCallbackHolder extends import_uicore_ts.UIObject {
|
|
|
166
170
|
keepWaitingForResponses: message.keepWaitingForResponses
|
|
167
171
|
},
|
|
168
172
|
sentAtTime: Date.now(),
|
|
173
|
+
//completionTriggered: NO,
|
|
169
174
|
messageDataHash,
|
|
170
175
|
mainResponseReceived: import_uicore_ts.NO,
|
|
171
176
|
anyMainResponseReceived: import_uicore_ts.NO,
|
|
@@ -206,6 +211,7 @@ class CBSocketCallbackHolder extends import_uicore_ts.UIObject {
|
|
|
206
211
|
keepWaitingForResponses: messageToSend.keepWaitingForResponses
|
|
207
212
|
},
|
|
208
213
|
sentAtTime: Date.now(),
|
|
214
|
+
//completionTriggered: NO,
|
|
209
215
|
messageDataHash,
|
|
210
216
|
mainResponseReceived: import_uicore_ts.NO,
|
|
211
217
|
anyMainResponseReceived: import_uicore_ts.NO,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/CBSocketCallbackHolder.ts"],
|
|
4
4
|
"sourcesContent": ["import objectHash from \"object-hash\"\nimport { FIRST, IS, IS_NOT, nil, NO, UIObject, YES } from \"../../uicore-ts\"\nimport {\n CBSocketMessage,\n CBSocketMessageCompletionFunction,\n CBSocketMessageHandlerFunction, CBSocketMessageSendResponseFunction, CBSocketMultipleMessage,\n CBSocketMultipleMessagecompletionFunction, CBSocketMultipleMessageObject\n} from \"./CBDataInterfaces\"\nimport { CBSocketClient } from \"./CBSocketClient\"\n\n\n\n\n\ninterface CBSocketCallbackHolderMessageDescriptor {\n \n key: string;\n message: {\n identifier: string;\n inResponseToIdentifier?: string;\n keepWaitingForResponses?: boolean;\n }\n \n \n sentAtTime: number;\n \n //completionTriggered: boolean;\n \n messageDataHash: string;\n \n responseDataHash?: string;\n \n mainResponseReceived: boolean;\n \n anyMainResponseReceived: boolean;\n \n completionPolicy: string;\n completionFunction: CBSocketMessageCompletionFunction;\n \n}\n\n\ninterface CBSocketCallbackHolderStoredResponseObject {\n \n messageKey: string;\n messageData: any;\n messageDataHash: string;\n \n}\n\n\n\n\nexport class CBSocketCallbackHolder extends UIObject {\n \n messageDescriptors: {\n \n [x: string]: CBSocketCallbackHolderMessageDescriptor[]\n \n } = {}\n \n handlers: {\n [x: string]: CBSocketMessageHandlerFunction[]\n } = {}\n \n onetimeHandlers: {\n [x: string]: CBSocketMessageHandlerFunction[]\n } = {}\n \n keysForIdentifiers: {\n \n [x: string]: string\n \n } = {}\n \n \n isValid = YES\n _storeableResponseKeys: string[] = []\n _storedResponseHashesDictionary: {\n \n [x: string]: {\n \n hash: string,\n validityDate: number\n \n }\n \n } = {}\n _verifiedResponseHashesDictionary: {\n \n [x: string]: boolean\n \n } = {}\n \n _socketClient: CBSocketClient\n \n \n \n \n \n constructor(socketClient: CBSocketClient, previousCallbackHolder?: CBSocketCallbackHolder) {\n \n super()\n \n \n this._socketClient = socketClient\n \n if (IS(previousCallbackHolder)) {\n \n this.handlers = previousCallbackHolder.handlers\n this._verifiedResponseHashesDictionary = previousCallbackHolder._verifiedResponseHashesDictionary\n \n }\n \n \n \n \n \n }\n \n \n \n \n \n triggerDisconnectHandlers() {\n \n this.messageDescriptors.forEach(function (descriptor: CBSocketCallbackHolderMessageDescriptor, key: string) {\n \n if (descriptor.mainResponseReceived) {\n \n descriptor.completionFunction(CBSocketClient.disconnectionMessage, nil)\n \n }\n \n })\n \n }\n \n \n \n \n \n registerHandler(key: string, handlerFunction: CBSocketMessageHandlerFunction) {\n \n \n if (!this.handlers[key]) {\n \n this.handlers[key] = []\n \n }\n \n this.handlers[key].push(handlerFunction)\n \n \n \n }\n \n registerOnetimeHandler(key: string, handlerFunction: CBSocketMessageHandlerFunction) {\n \n \n if (!this.onetimeHandlers[key]) {\n \n this.onetimeHandlers[key] = []\n \n }\n \n this.onetimeHandlers[key].push(handlerFunction)\n \n \n \n }\n \n \n \n \n \n get storedResponseHashesDictionary() {\n \n if (IS_NOT(this._storedResponseHashesDictionary)) {\n \n this._storedResponseHashesDictionary = JSON.parse(localStorage[\"CBSocketResponseHashesDictionary\"] || \"{}\")\n \n }\n \n return this._storedResponseHashesDictionary\n \n }\n \n storedResponseHashObjectForKey(requestKey: string, requestDataHash: string) {\n \n const localStorageKey = this.keyForRequestKeyAndRequestDataHash(requestKey, requestDataHash)\n \n const hashObject = this.storedResponseHashesDictionary[localStorageKey]\n \n const result = FIRST(hashObject, {} as any)\n \n \n \n return result\n \n }\n \n storedResponseForKey(requestKey: string, requestDataHash: string) {\n \n const localStorageKey = this.keyForRequestKeyAndRequestDataHash(requestKey, requestDataHash)\n \n const storedObject = JSON.parse(localStorage[localStorageKey] || \"{}\")\n \n return storedObject.responseMessageData\n \n }\n \n keyForRequestKeyAndRequestDataHash(requestKey: string, requestDataHash: string) {\n \n const result = \"_CBSCH_LS_key_\" + requestKey + \"_\" + requestDataHash\n \n return result\n \n }\n \n storeResponse(\n requestKey: string,\n requestDataHash: string,\n responseMessage: CBSocketMessage<any>,\n responseDataHash: string\n ) {\n \n \n if (!responseMessage.canBeStoredAsResponse ||\n (IS_NOT(responseMessage.messageData) && IS_NOT(responseMessage.messageDataHash))) {\n \n return\n \n }\n \n \n const localStorageKey = this.keyForRequestKeyAndRequestDataHash(requestKey, requestDataHash)\n \n \n var validityDate: number\n \n if (responseMessage.responseValidityDuration) {\n \n validityDate = Date.now() + responseMessage.responseValidityDuration\n \n }\n \n const storedResponseHashesDictionary = this.storedResponseHashesDictionary\n storedResponseHashesDictionary[localStorageKey] = {\n \n hash: responseDataHash,\n validityDate: validityDate!\n \n }\n \n this.saveInLocalStorage(localStorageKey, {\n \n responseMessageData: responseMessage.messageData,\n responseHash: responseDataHash\n \n })\n \n \n this.saveStoredResponseHashesDictionary(storedResponseHashesDictionary)\n \n }\n \n \n \n \n \n private saveStoredResponseHashesDictionary(storedResponseHashesDictionary: { [x: string]: { hash: string; validityDate: number; }; }) {\n \n this.saveInLocalStorage(\"CBSocketResponseHashesDictionary\", storedResponseHashesDictionary)\n \n }\n \n saveInLocalStorage(key: string, object: any) {\n \n \n const stringToSave = JSON.stringify(object)\n \n if (stringToSave != localStorage[key]) {\n \n localStorage[key] = stringToSave\n \n }\n \n \n }\n \n \n \n \n \n socketShouldSendMessage(\n key: string,\n message: CBSocketMessage<any>,\n completionPolicy: string,\n completionFunction: CBSocketMessageCompletionFunction\n ) {\n \n \n \n var result = YES\n \n var triggerStoredResponseImmediately = NO\n \n \n const messageDataHash = objectHash(message.messageData || nil)\n \n const descriptorKey = \"socketMessageDescriptor_\" + key + messageDataHash\n \n this.messageDescriptors[descriptorKey] = (this.messageDescriptors[descriptorKey] || [])\n \n \n const hashObject = this.storedResponseHashObjectForKey(key, messageDataHash)\n message.storedResponseHash = hashObject.hash\n \n \n \n if (completionPolicy == CBSocketClient.completionPolicy.first) {\n \n const descriptorsForKey = (this.messageDescriptors[descriptorKey] || [])\n \n const matchingDescriptor = descriptorsForKey.find(function (descriptor, index, array) {\n return (descriptor.messageDataHash == messageDataHash)\n })\n \n if (matchingDescriptor) {\n \n result = NO\n \n }\n \n }\n \n if (completionPolicy == CBSocketClient.completionPolicy.storedOrFirst) {\n \n const descriptorsForKey = (this.messageDescriptors[descriptorKey] || [])\n \n const matchingDescriptor = descriptorsForKey.find(function (descriptor, index, array) {\n return (descriptor.messageDataHash == messageDataHash)\n })\n \n const storedResponse = IS(message.storedResponseHash)\n \n if (matchingDescriptor ||\n (storedResponse && this._verifiedResponseHashesDictionary[message.storedResponseHash!])) {\n \n result = NO\n \n triggerStoredResponseImmediately = YES\n \n }\n \n }\n \n if (completionPolicy == CBSocketClient.completionPolicy.firstOnly) {\n \n const descriptorsForKey = (this.messageDescriptors[descriptorKey] || [])\n \n const matchingDescriptor = descriptorsForKey.find(function (descriptor, index, array) {\n return (descriptor.messageDataHash == messageDataHash)\n })\n \n if (matchingDescriptor) {\n \n return NO\n \n }\n \n }\n \n \n if (hashObject && hashObject.hash && hashObject.validityDate && message.storedResponseHash &&\n this._verifiedResponseHashesDictionary[message.storedResponseHash] && hashObject.validityDate >\n Date.now()) {\n \n result = NO\n \n triggerStoredResponseImmediately = YES\n \n }\n \n \n if (IS(completionFunction)) {\n \n this.messageDescriptors[descriptorKey].push({\n \n key: key,\n message: {\n \n identifier: message.identifier,\n inResponseToIdentifier: message.inResponseToIdentifier,\n keepWaitingForResponses: message.keepWaitingForResponses\n \n },\n \n sentAtTime: Date.now(),\n \n //completionTriggered: NO,\n \n \n messageDataHash: messageDataHash,\n \n mainResponseReceived: NO,\n anyMainResponseReceived: NO,\n \n \n completionPolicy: completionPolicy,\n completionFunction: completionFunction\n \n })\n \n this.keysForIdentifiers[message.identifier] = descriptorKey\n \n }\n \n \n if (triggerStoredResponseImmediately) {\n \n this.socketDidReceiveMessageForKey(\n CBSocketClient.responseMessageKey,\n {\n \n identifier: nil,\n messageData: nil,\n completionPolicy: CBSocketClient.completionPolicy.directOnly,\n \n inResponseToIdentifier: message.identifier,\n \n useStoredResponse: YES\n \n },\n nil\n )\n \n }\n \n \n return result\n \n \n }\n \n \n \n \n \n static defaultMultipleMessagecompletionFunction(responseMessages: any[], callcompletionFunctions: () => void) {\n callcompletionFunctions()\n }\n \n \n socketWillSendMultipleMessage(\n messageToSend: CBSocketMultipleMessage,\n completionFunction: CBSocketMultipleMessagecompletionFunction = CBSocketCallbackHolder.defaultMultipleMessagecompletionFunction\n ) {\n \n \n \n const key = CBSocketClient.multipleMessageKey\n \n \n const messageDataHash = objectHash(messageToSend.messageData || nil)\n \n const descriptorKey = \"socketMessageDescriptor_\" + key + messageDataHash\n \n this.messageDescriptors[descriptorKey] = (this.messageDescriptors[descriptorKey] || [])\n \n \n messageToSend.storedResponseHash = this.storedResponseHashObjectForKey(key, messageDataHash).hash\n \n \n \n \n \n this.messageDescriptors[descriptorKey].push({\n \n key: key,\n message: {\n \n identifier: messageToSend.identifier,\n inResponseToIdentifier: messageToSend.inResponseToIdentifier,\n keepWaitingForResponses: messageToSend.keepWaitingForResponses\n \n },\n \n sentAtTime: Date.now(),\n \n //completionTriggered: NO,\n \n \n messageDataHash: messageDataHash,\n \n mainResponseReceived: NO,\n anyMainResponseReceived: NO,\n \n \n completionPolicy: CBSocketClient.completionPolicy.directOnly,\n completionFunction: function (\n this: CBSocketCallbackHolder,\n responseMessage: CBSocketMultipleMessageObject[],\n respondWithMessage: any\n ) {\n \n completionFunction(\n responseMessage.map(function (messageObject, index, array) {\n \n return messageObject.message.messageData\n \n }),\n function (this: CBSocketCallbackHolder) {\n \n //console.log(\"Received multiple message response with length of \" + responseMessage.length + \".\");\n \n // Call all completion functions\n responseMessage.forEach(function (\n this: CBSocketCallbackHolder,\n messageObject: CBSocketMultipleMessageObject,\n index: number,\n array: CBSocketMultipleMessageObject[]\n ) {\n \n this._socketClient.didReceiveMessageForKey(messageObject.key, messageObject.message)\n \n }.bind(this))\n \n }.bind(this)\n )\n \n }.bind(this)\n \n })\n \n this.keysForIdentifiers[messageToSend.identifier] = descriptorKey\n \n \n }\n \n \n \n \n \n socketDidReceiveMessageForKey(\n key: string,\n message: CBSocketMessage<any>,\n sendResponseFunction: CBSocketMessageSendResponseFunction\n ) {\n \n \n if (!this.isValid) {\n \n return\n \n }\n \n \n // Call static handlers\n if (this.handlers[key]) {\n \n this.handlers[key].forEach(function (\n this: CBSocketCallbackHolder,\n handler: CBSocketMessageHandlerFunction,\n index: any,\n array: any\n ) {\n \n handler(message.messageData, sendResponseFunction)\n \n }.bind(this))\n \n }\n \n if (this.onetimeHandlers[key]) {\n \n this.onetimeHandlers[key].forEach(function (\n this: CBSocketCallbackHolder,\n handler: CBSocketMessageHandlerFunction\n ) {\n \n handler(message.messageData, sendResponseFunction)\n \n }.bind(this))\n \n delete this.onetimeHandlers[key]\n \n }\n \n \n \n // Temporary response handlers are evaluated here\n if (message.inResponseToIdentifier &&\n (CBSocketClient.responseMessageKey == key || CBSocketClient.multipleMessageKey == key)) {\n \n // Find descriptors for the key of the message that is being responded to\n const descriptorKey = this.keysForIdentifiers[message.inResponseToIdentifier]\n const descriptorsForKey = (this.messageDescriptors[descriptorKey] || [])\n \n // Find response data hash to check for differences\n const responseDataHash = message.messageDataHash\n \n // Remove identifier from dictionary\n if (!message.keepWaitingForResponses) {\n \n delete this.keysForIdentifiers[message.inResponseToIdentifier]\n \n delete this.messageDescriptors[descriptorKey]\n \n }\n \n \n // Function to call completion function\n const callCompletionFunction = (descriptor: CBSocketCallbackHolderMessageDescriptor, storedResponseCondition = NO) => {\n \n var messageData = message.messageData\n \n if (message.useStoredResponse && storedResponseCondition) {\n \n messageData = this.storedResponseForKey(descriptor.key, descriptor.messageDataHash)\n \n const responseHash = this.storedResponseHashObjectForKey(\n descriptor.key,\n descriptor.messageDataHash\n ).hash\n \n const localStorageKey = this.keyForRequestKeyAndRequestDataHash(\n descriptor.key,\n descriptor.messageDataHash\n )\n \n if (message.responseValidityDuration && this.storedResponseHashesDictionary[localStorageKey]) {\n \n this.storedResponseHashesDictionary[localStorageKey].validityDate = Date.now() +\n message.responseValidityDuration\n \n this.saveStoredResponseHashesDictionary(this.storedResponseHashesDictionary)\n \n }\n \n this._verifiedResponseHashesDictionary[responseHash] = YES\n \n console.log(\"Using stored response.\")\n \n }\n \n // Call completionFunction and set response data hash\n descriptor.completionFunction(messageData, sendResponseFunction)\n descriptor.responseDataHash = responseDataHash\n \n }\n \n \n descriptorsForKey.copy().forEach(function (\n this: CBSocketCallbackHolder,\n descriptor: CBSocketCallbackHolderMessageDescriptor,\n index: number,\n array: CBSocketCallbackHolderMessageDescriptor[]\n ) {\n \n \n if ((descriptor.completionPolicy == CBSocketClient.completionPolicy.directOnly &&\n descriptor.message.identifier == message.inResponseToIdentifier) || descriptor.completionPolicy ==\n CBSocketClient.completionPolicy.first || descriptor.completionPolicy ==\n CBSocketClient.completionPolicy.firstOnly || descriptor.completionPolicy ==\n CBSocketClient.completionPolicy.storedOrFirst) {\n \n // Calling completion function and removing descriptor\n \n if (!message.keepWaitingForResponses) {\n \n this.storeResponse(descriptor.key, descriptor.messageDataHash, message, responseDataHash!)\n \n descriptorsForKey.removeElement(descriptor)\n \n sendResponseFunction.respondingToMainResponse = YES\n \n }\n \n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n }\n else if (descriptor.completionPolicy == CBSocketClient.completionPolicy.all) {\n \n // Calling completion function\n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n // Marking descriptor as having been responded to\n if (!message.keepWaitingForResponses) {\n \n if (message.inResponseToIdentifier == descriptor.message.identifier) {\n \n sendResponseFunction.respondingToMainResponse = YES\n descriptor.mainResponseReceived = YES\n descriptorsForKey.removeElement(descriptor)\n \n }\n \n descriptor.anyMainResponseReceived = YES\n \n }\n \n \n \n }\n else if (descriptor.completionPolicy == CBSocketClient.completionPolicy.allDifferent) {\n \n // Calling completionFunction if messageData is different from previous\n if (descriptor.responseDataHash != responseDataHash) {\n \n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n }\n \n // Marking descriptor as having been responded to\n if (!message.keepWaitingForResponses) {\n \n if (message.inResponseToIdentifier == descriptor.message.identifier) {\n \n sendResponseFunction.respondingToMainResponse = YES\n descriptor.mainResponseReceived = YES\n descriptorsForKey.removeElement(descriptor)\n \n }\n \n descriptor.anyMainResponseReceived = YES\n \n }\n \n }\n else if (descriptor.completionPolicy == CBSocketClient.completionPolicy.last &&\n descriptor.message.identifier == message.inResponseToIdentifier) {\n \n if (!message.keepWaitingForResponses) {\n \n // Marking descriptor as having been responded to\n descriptor.mainResponseReceived = YES\n descriptor.anyMainResponseReceived = YES\n \n sendResponseFunction.respondingToMainResponse = YES\n \n }\n else {\n \n descriptor.completionFunction(message.messageData, sendResponseFunction)\n \n }\n \n }\n else if (descriptor.completionPolicy == CBSocketClient.completionPolicy.firstAndLast ||\n descriptor.completionPolicy == CBSocketClient.completionPolicy.firstAndLastIfDifferent) {\n \n if (!message.keepWaitingForResponses) {\n \n // Only calling completionFunction once as a first response call\n if (!descriptor.anyMainResponseReceived) {\n \n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n }\n \n // Marking descriptor as having been responded to\n if (descriptor.message.identifier == message.inResponseToIdentifier) {\n \n descriptor.mainResponseReceived = YES\n sendResponseFunction.respondingToMainResponse = YES\n \n }\n \n descriptor.anyMainResponseReceived = YES\n \n }\n else if (descriptor.message.identifier == message.inResponseToIdentifier &&\n message.keepWaitingForResponses) {\n \n descriptor.completionFunction(message.messageData, sendResponseFunction)\n \n }\n \n }\n \n }.bind(this))\n \n \n \n \n \n // Last message completion policies\n \n const allResponsesReceived = descriptorsForKey.allMatch(function (descriptorObject, index, array) {\n return descriptorObject.mainResponseReceived\n })\n \n descriptorsForKey.copy().forEach(function (\n this: CBSocketCallbackHolder,\n descriptor: CBSocketCallbackHolderMessageDescriptor,\n index: number,\n array: CBSocketCallbackHolderMessageDescriptor[]\n ) {\n \n if ((descriptor.completionPolicy == CBSocketClient.completionPolicy.last ||\n descriptor.completionPolicy == CBSocketClient.completionPolicy.firstAndLast) &&\n allResponsesReceived && !message.keepWaitingForResponses) {\n \n // Calling completionFunction\n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n // Cleaning up\n descriptorsForKey.removeElement(descriptor)\n \n }\n else if (descriptor.completionPolicy == CBSocketClient.completionPolicy.firstAndLastIfDifferent &&\n allResponsesReceived && !message.keepWaitingForResponses) {\n \n // Calling completionFunction if needed\n if (descriptor.responseDataHash != responseDataHash) {\n \n callCompletionFunction(descriptor, !message.keepWaitingForResponses)\n \n }\n \n // Cleaning up\n descriptorsForKey.removeElement(descriptor)\n \n }\n \n }.bind(this))\n \n \n }\n \n \n \n \n \n }\n \n \n \n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAuB;AACvB,uBAA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AyB;AAEjC,uBAAW,mBAAmB,QAAQ,aAAa,oBAAoB;AAAA,UAE3E;AAAA,QAEJ;AAAA,MAEJ,EAAE,KAAK,IAAI,CAAC;AAQZ,YAAM,uBAAuB,kBAAkB,SAAS,SAAU,kBAAkB,OAAO,OAAO;AAC9F,eAAO,iBAAiB;AAAA,MAC5B,CAAC;AAED,wBAAkB,KAAK,EAAE,QAAQ,SAE7B,YACA,OACA,OACF;AAEE,aAAK,WAAW,oBAAoB,qCAAe,iBAAiB,QAC5D,WAAW,oBAAoB,qCAAe,iBAAiB,iBACnE,wBAAwB,CAAC,QAAQ,yBAAyB;AAG1D,iCAAuB,YAAY,CAAC,QAAQ,uBAAuB;AAGnE,4BAAkB,cAAc,UAAU;AAAA,QAE9C,WACS,WAAW,oBAAoB,qCAAe,iBAAiB,2BACpE,wBAAwB,CAAC,QAAQ,yBAAyB;AAG1D,cAAI,WAAW,oBAAoB,kBAAkB;AAEjD,mCAAuB,YAAY,CAAC,QAAQ,uBAAuB;AAAA,UAEvE;AAGA,4BAAkB,cAAc,UAAU;AAAA,QAE9C;AAAA,MAEJ,EAAE,KAAK,IAAI,CAAC;AAAA,IAGhB;AAAA,EAMJ;AAMJ;",
|
|
6
6
|
"names": ["objectHash"]
|
|
7
7
|
}
|
|
@@ -35,7 +35,7 @@ function IS_SOCKET_ERROR(object) {
|
|
|
35
35
|
function IS_NOT_SOCKET_ERROR(object) {
|
|
36
36
|
return !IS_SOCKET_ERROR(object);
|
|
37
37
|
}
|
|
38
|
-
const _CBSocketClient = class extends import_uicore_ts.UIObject {
|
|
38
|
+
const _CBSocketClient = class _CBSocketClient extends import_uicore_ts.UIObject {
|
|
39
39
|
constructor(core) {
|
|
40
40
|
super();
|
|
41
41
|
this._socket = (0, import_socket.io)();
|
|
@@ -48,8 +48,13 @@ const _CBSocketClient = class extends import_uicore_ts.UIObject {
|
|
|
48
48
|
this.socket.on("connect", () => {
|
|
49
49
|
var _a, _b;
|
|
50
50
|
console.log("Socket.io connected to server. clientID = ", this.socket, " socketID = ", this.socket);
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const isInstanceIdentifierAllowed = localStorage.getItem("IsInstanceIdentifierAllowed") == "true";
|
|
52
|
+
let instanceIdentifier = (0, import_uicore_ts.IF)(isInstanceIdentifierAllowed)(
|
|
53
|
+
() => localStorage.getItem("InstanceIdentifier")
|
|
54
|
+
).ELSE(
|
|
55
|
+
() => ""
|
|
56
|
+
);
|
|
57
|
+
if ((0, import_uicore_ts.IS_NOT)(instanceIdentifier) && isInstanceIdentifierAllowed) {
|
|
53
58
|
instanceIdentifier = (0, import_uicore_ts.MAKE_ID)();
|
|
54
59
|
localStorage.setItem("InstanceIdentifier", instanceIdentifier);
|
|
55
60
|
}
|
|
@@ -338,14 +343,13 @@ const _CBSocketClient = class extends import_uicore_ts.UIObject {
|
|
|
338
343
|
}
|
|
339
344
|
}
|
|
340
345
|
};
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
CBSocketClient.disconnectionMessage = {
|
|
346
|
+
_CBSocketClient.responseMessageKey = "CBSocketResponseMessage";
|
|
347
|
+
_CBSocketClient.multipleMessageKey = "CBSocketMultipleMessage";
|
|
348
|
+
_CBSocketClient.disconnectionMessage = {
|
|
345
349
|
_isCBSocketErrorMessage: import_uicore_ts.YES,
|
|
346
350
|
messageData: "Server disconnected"
|
|
347
351
|
};
|
|
348
|
-
|
|
352
|
+
_CBSocketClient.completionPolicy = {
|
|
349
353
|
"all": "all",
|
|
350
354
|
"allDifferent": "allDifferent",
|
|
351
355
|
"first": "first",
|
|
@@ -356,6 +360,7 @@ CBSocketClient.completionPolicy = {
|
|
|
356
360
|
"firstOnly": "firstOnly",
|
|
357
361
|
"storedOrFirst": "storedOrFirst"
|
|
358
362
|
};
|
|
363
|
+
let CBSocketClient = _CBSocketClient;
|
|
359
364
|
const SocketClient = new Proxy({ "name": "SocketClient" }, {
|
|
360
365
|
get(target, key) {
|
|
361
366
|
const result = (messageData, completionPolicy, isUserBound) => import_CBCore.CBCore.sharedInstance.socketClient.resultForMessageForKey(
|
|
@@ -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: 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,
|
|
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;AAA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AG,KAAK,SAAgC,SAA+B;AAEhF,aAAK,wBAAwB,KAAK,OAAO;AAAA,MAE7C,EAAE,KAAK,IAAI,CAAC;AAEZ,WAAK,gBAAgB,GAAG,IAAI;AAAA,IAEhC;AAAA,EAGJ;AAAA,EAEA,6BAA6B,KAAa,iBAAiD;AAEvF,SAAK,gBAAgB,uBAAuB,KAAK,eAAe;AAEhE,YAAI,yBAAO,KAAK,gBAAgB,GAAG,CAAC,GAAG;AAEnC,WAAK,QAAQ,GAAG,KAAK,SAAgC,SAA+B;AAEhF,aAAK,wBAAwB,KAAK,OAAO;AAAA,MAE7C,EAAE,KAAK,IAAI,CAAC;AAEZ,WAAK,gBAAgB,GAAG,IAAI;AAAA,IAEhC;AAAA,EAGJ;AAGJ;AA/nBa,gBAmBF,qBAAqB;AAnBnB,gBAoBF,qBAAqB;AApBnB,gBAuBF,uBAAmD;AAAA,EAEtD,yBAAyB;AAAA,EAEzB,aAAa;AAEjB;AA7BS,gBAuSF,mBAAmB;AAAA,EAEtB,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,2BAA2B;AAAA,EAC3B,cAAc;AAAA,EACd,aAAa;AAAA,EACb,iBAAiB;AAErB;AAnTG,IAAM,iBAAN;AAkoBA,MAAM,eAAsC,IAAI,MAAM,EAAE,QAAQ,eAAe,GAAG;AAAA,EAErF,IAAI,QAAQ,KAAK;AAEb,UAAM,SAAS,CACX,aACA,kBACA,gBACC,qBAAO,eAAe,aAAa;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ;AAGA,WAAO;AAAA,EAEX;AAEJ,CAAC;",
|
|
6
6
|
"names": ["completion", "messageObject"]
|
|
7
7
|
}
|
package/compiledScripts/index.js
CHANGED
|
@@ -13,12 +13,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
13
|
};
|
|
14
14
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var
|
|
17
|
-
module.exports = __toCommonJS(
|
|
18
|
-
__reExport(
|
|
19
|
-
__reExport(
|
|
20
|
-
__reExport(
|
|
21
|
-
__reExport(
|
|
22
|
-
__reExport(
|
|
23
|
-
__reExport(
|
|
16
|
+
var index_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(index_exports);
|
|
18
|
+
__reExport(index_exports, require("./CBCore"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./CBServerClient"), module.exports);
|
|
20
|
+
__reExport(index_exports, require("./CBSocketClient"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("./CBSocketCallbackHolder"), module.exports);
|
|
22
|
+
__reExport(index_exports, require("./CBLanguageService"), module.exports);
|
|
23
|
+
__reExport(index_exports, require("./CBDataInterfaces"), module.exports);
|
|
24
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
25
|
+
0 && (module.exports = {
|
|
26
|
+
...require("./CBCore"),
|
|
27
|
+
...require("./CBServerClient"),
|
|
28
|
+
...require("./CBSocketClient"),
|
|
29
|
+
...require("./CBSocketCallbackHolder"),
|
|
30
|
+
...require("./CBLanguageService"),
|
|
31
|
+
...require("./CBDataInterfaces")
|
|
32
|
+
});
|
|
24
33
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/index.ts"],
|
|
4
4
|
"sourcesContent": ["\nexport * from \"./CBCore\"\nexport * from \"./CBServerClient\"\nexport * from \"./CBSocketClient\"\nexport * from \"./CBSocketCallbackHolder\"\nexport * from \"./CBLanguageService\"\nexport * from \"./CBDataInterfaces\"\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AACA,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AACA,0BAAc,qBADd;AAEA,0BAAc,6BAFd;AAGA,0BAAc,6BAHd;AAIA,0BAAc,qCAJd;AAKA,0BAAc,gCALd;AAMA,0BAAc,+BANd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cbcore-ts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.36",
|
|
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",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"@types/object-hash": "^2.1.1",
|
|
36
36
|
"object-hash": "^2.1.1",
|
|
37
37
|
"socket.io-client": "^4.7.5",
|
|
38
|
-
"uicore-ts": "1.0.
|
|
38
|
+
"uicore-ts": "1.0.577"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@rollup/plugin-commonjs": "^23.0.0",
|
|
42
42
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
43
|
-
"esbuild": "^0.
|
|
44
|
-
"esbuild-node-tsc": "^
|
|
43
|
+
"esbuild": "^0.27.2",
|
|
44
|
+
"esbuild-node-tsc": "^2.0.5",
|
|
45
45
|
"esbuild-plugin-inline-worker": "^0.1.1",
|
|
46
46
|
"etsc": "^0.1.0",
|
|
47
47
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
package/scripts/CBCore.ts
CHANGED
|
@@ -153,7 +153,7 @@ export class CBCore extends UIObject {
|
|
|
153
153
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
updateLinkTargets() {
|
|
157
157
|
this.viewCores.everyElement.rootViewController.view.forEachViewInSubtree(function (view) {
|
|
158
158
|
if (view instanceof UILink) {
|
|
159
159
|
view.updateTarget()
|
|
@@ -105,9 +105,15 @@ export class CBSocketClient extends UIObject {
|
|
|
105
105
|
|
|
106
106
|
console.log("Socket.io connected to server. clientID = ", this.socket, " socketID = ", this.socket)
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
const isInstanceIdentifierAllowed = localStorage.getItem("IsInstanceIdentifierAllowed") == "true"
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
let instanceIdentifier = IF(isInstanceIdentifierAllowed)(() =>
|
|
111
|
+
localStorage.getItem("InstanceIdentifier")
|
|
112
|
+
).ELSE(() =>
|
|
113
|
+
""
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
if (IS_NOT(instanceIdentifier) && isInstanceIdentifierAllowed) {
|
|
111
117
|
|
|
112
118
|
instanceIdentifier = MAKE_ID()
|
|
113
119
|
localStorage.setItem("InstanceIdentifier", instanceIdentifier!)
|