cbcore-ts 1.1.15 → 1.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiledScripts/CBCore.d.ts +16 -16
- package/compiledScripts/CBCore.js +19 -19
- package/compiledScripts/CBCore.js.map +2 -2
- package/compiledScripts/CBSocketCallbackHolder.d.ts +5 -5
- package/compiledScripts/CBSocketCallbackHolder.js +12 -12
- package/compiledScripts/CBSocketCallbackHolder.js.map +2 -2
- package/compiledScripts/CBSocketClient.d.ts +11 -12
- package/compiledScripts/CBSocketClient.js +5 -5
- package/compiledScripts/CBSocketClient.js.map +2 -2
- package/package.json +2 -2
- package/scripts/CBCore.ts +23 -23
- package/scripts/CBSocketCallbackHolder.ts +15 -15
- package/scripts/CBSocketClient.ts +18 -19
|
@@ -26,17 +26,17 @@ declare interface CBDialogViewShower {
|
|
|
26
26
|
* // Additional session-level state goes here.
|
|
27
27
|
* mySessionData: MySessionData | undefined = undefined
|
|
28
28
|
*
|
|
29
|
-
* // Override
|
|
29
|
+
* // Override userProfileDidChange to fetch session data before the
|
|
30
30
|
* // userDidLogIn broadcast fires. Call super only after your data
|
|
31
31
|
* // is ready so that every listener receives a fully populated core.
|
|
32
|
-
* override async
|
|
32
|
+
* override async userProfileDidChange() {
|
|
33
33
|
* if (IS(this.userProfile)) {
|
|
34
34
|
* this.mySessionData = await fetchMySessionData()
|
|
35
35
|
* }
|
|
36
36
|
* else {
|
|
37
37
|
* this.mySessionData = undefined
|
|
38
38
|
* }
|
|
39
|
-
* super.
|
|
39
|
+
* super.userProfileDidChange()
|
|
40
40
|
* }
|
|
41
41
|
*
|
|
42
42
|
* // Expose a typed singleton so callers never need CBCore.sharedInstance.
|
|
@@ -50,7 +50,7 @@ declare interface CBDialogViewShower {
|
|
|
50
50
|
* 2. Register the subclass at app startup, before UICore is initialised:
|
|
51
51
|
*
|
|
52
52
|
* ```typescript
|
|
53
|
-
* CBCore.
|
|
53
|
+
* CBCore.registerSharedInstance(new MyAppCore())
|
|
54
54
|
* CBCore.initIfNeededWithViewCore(new UICore(...))
|
|
55
55
|
* ```
|
|
56
56
|
*
|
|
@@ -73,10 +73,10 @@ export declare class CBCore extends UIObject {
|
|
|
73
73
|
/**
|
|
74
74
|
* Returns the shared singleton instance.
|
|
75
75
|
*
|
|
76
|
-
* If `
|
|
76
|
+
* If `registerSharedInstance` was called before this getter was first accessed,
|
|
77
77
|
* that instance is returned. Otherwise a default `CBCore` is created.
|
|
78
78
|
* Library-internal code always goes through this getter, so registering a
|
|
79
|
-
* subclass via `
|
|
79
|
+
* subclass via `registerSharedInstance` is sufficient to replace the singleton
|
|
80
80
|
* for the entire session.
|
|
81
81
|
*/
|
|
82
82
|
static get sharedInstance(): CBCore;
|
|
@@ -90,11 +90,11 @@ export declare class CBCore extends UIObject {
|
|
|
90
90
|
*
|
|
91
91
|
* ```typescript
|
|
92
92
|
* // App entry point — must be the very first thing that runs.
|
|
93
|
-
* CBCore.
|
|
93
|
+
* CBCore.registerSharedInstance(new MyAppCore())
|
|
94
94
|
* CBCore.initIfNeededWithViewCore(new UICore("root", RootViewController))
|
|
95
95
|
* ```
|
|
96
96
|
*/
|
|
97
|
-
static
|
|
97
|
+
static registerSharedInstance(instance: CBCore): void;
|
|
98
98
|
static broadcastEventName: {
|
|
99
99
|
readonly userDidLogIn: "UserDidLogIn";
|
|
100
100
|
readonly userDidLogOut: "UserDidLogOut";
|
|
@@ -103,14 +103,14 @@ export declare class CBCore extends UIObject {
|
|
|
103
103
|
get socketClient(): CBSocketClient;
|
|
104
104
|
get serverClient(): CBServerClient;
|
|
105
105
|
set isUserLoggedIn(isUserLoggedIn: boolean);
|
|
106
|
-
|
|
106
|
+
userLoginStateDidChange(previousValue: boolean): void;
|
|
107
107
|
/**
|
|
108
108
|
* Called when the user transitions from logged-in to logged-out.
|
|
109
109
|
* The default implementation clears the route and broadcasts `userDidLogOut`.
|
|
110
110
|
* Subclasses may override this to suppress the route change when they intend
|
|
111
111
|
* to navigate somewhere specific immediately after logout.
|
|
112
112
|
*/
|
|
113
|
-
|
|
113
|
+
userDidLogOut(): void;
|
|
114
114
|
updateLinkTargets(): void;
|
|
115
115
|
get isUserLoggedIn(): boolean;
|
|
116
116
|
_userProfile: CBUserProfile;
|
|
@@ -120,29 +120,29 @@ export declare class CBCore extends UIObject {
|
|
|
120
120
|
* Called whenever `userProfile` is assigned.
|
|
121
121
|
*
|
|
122
122
|
* The default implementation derives `isUserLoggedIn` from the profile
|
|
123
|
-
* and triggers the login/logout broadcast via `
|
|
123
|
+
* and triggers the login/logout broadcast via `userLoginStateDidChange`.
|
|
124
124
|
*
|
|
125
125
|
* Subclasses may override this to fetch additional session data before
|
|
126
126
|
* the broadcast fires. The override must be `async` and must call
|
|
127
|
-
* `super.
|
|
127
|
+
* `super.userProfileDidChange()` after it has finished populating any
|
|
128
128
|
* extra state, so that all broadcast listeners receive a complete core:
|
|
129
129
|
*
|
|
130
130
|
* ```typescript
|
|
131
|
-
* override async
|
|
131
|
+
* override async userProfileDidChange() {
|
|
132
132
|
* if (IS(this.userProfile)) {
|
|
133
133
|
* this.companyStatus = (await SocketClient.CurrentUserStatusInCompany()).result
|
|
134
134
|
* }
|
|
135
135
|
* else {
|
|
136
136
|
* this.companyStatus = undefined
|
|
137
137
|
* }
|
|
138
|
-
* super.
|
|
138
|
+
* super.userProfileDidChange() // broadcast fires here
|
|
139
139
|
* }
|
|
140
140
|
* ```
|
|
141
141
|
*/
|
|
142
|
-
|
|
142
|
+
userProfileDidChange(): void;
|
|
143
143
|
set languageKey(languageKey: string);
|
|
144
144
|
get languageKey(): string;
|
|
145
|
-
|
|
145
|
+
languageKeyDidChange(): void;
|
|
146
146
|
reloadSocketConnection(): void;
|
|
147
147
|
callFunctionForEachSocketClient(functionToCall: () => void): void;
|
|
148
148
|
}
|
|
@@ -45,10 +45,10 @@ const _CBCore = class _CBCore extends import_uicore_ts2.UIObject {
|
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
if (event.key == "CBLanguageKey") {
|
|
48
|
-
this.
|
|
48
|
+
this.languageKeyDidChange();
|
|
49
49
|
}
|
|
50
50
|
}.bind(this));
|
|
51
|
-
this.
|
|
51
|
+
this.languageKeyDidChange();
|
|
52
52
|
}
|
|
53
53
|
static initIfNeededWithViewCore(viewCore) {
|
|
54
54
|
_CBCore.sharedInstance.viewCores.push(viewCore);
|
|
@@ -56,10 +56,10 @@ const _CBCore = class _CBCore extends import_uicore_ts2.UIObject {
|
|
|
56
56
|
/**
|
|
57
57
|
* Returns the shared singleton instance.
|
|
58
58
|
*
|
|
59
|
-
* If `
|
|
59
|
+
* If `registerSharedInstance` was called before this getter was first accessed,
|
|
60
60
|
* that instance is returned. Otherwise a default `CBCore` is created.
|
|
61
61
|
* Library-internal code always goes through this getter, so registering a
|
|
62
|
-
* subclass via `
|
|
62
|
+
* subclass via `registerSharedInstance` is sufficient to replace the singleton
|
|
63
63
|
* for the entire session.
|
|
64
64
|
*/
|
|
65
65
|
static get sharedInstance() {
|
|
@@ -78,14 +78,14 @@ const _CBCore = class _CBCore extends import_uicore_ts2.UIObject {
|
|
|
78
78
|
*
|
|
79
79
|
* ```typescript
|
|
80
80
|
* // App entry point — must be the very first thing that runs.
|
|
81
|
-
* CBCore.
|
|
81
|
+
* CBCore.registerSharedInstance(new MyAppCore())
|
|
82
82
|
* CBCore.initIfNeededWithViewCore(new UICore("root", RootViewController))
|
|
83
83
|
* ```
|
|
84
84
|
*/
|
|
85
|
-
static
|
|
85
|
+
static registerSharedInstance(instance) {
|
|
86
86
|
if (_CBCore._sharedInstance) {
|
|
87
87
|
throw new Error(
|
|
88
|
-
"CBCore.
|
|
88
|
+
"CBCore.registerSharedInstance must be called before sharedInstance is first accessed. Move the call to the very top of your app entry point."
|
|
89
89
|
);
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
@@ -103,9 +103,9 @@ const _CBCore = class _CBCore extends import_uicore_ts2.UIObject {
|
|
|
103
103
|
set isUserLoggedIn(isUserLoggedIn) {
|
|
104
104
|
const previousValue = this.isUserLoggedIn;
|
|
105
105
|
this._isUserLoggedIn = isUserLoggedIn;
|
|
106
|
-
this.
|
|
106
|
+
this.userLoginStateDidChange(previousValue);
|
|
107
107
|
}
|
|
108
|
-
|
|
108
|
+
userLoginStateDidChange(previousValue) {
|
|
109
109
|
const isUserLoggedIn = this.isUserLoggedIn;
|
|
110
110
|
if (isUserLoggedIn && previousValue != isUserLoggedIn) {
|
|
111
111
|
this.broadcastMessageInRootViewTree({
|
|
@@ -114,7 +114,7 @@ const _CBCore = class _CBCore extends import_uicore_ts2.UIObject {
|
|
|
114
114
|
});
|
|
115
115
|
this.updateLinkTargets();
|
|
116
116
|
} else if (previousValue != isUserLoggedIn) {
|
|
117
|
-
this.
|
|
117
|
+
this.userDidLogOut();
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
@@ -123,7 +123,7 @@ const _CBCore = class _CBCore extends import_uicore_ts2.UIObject {
|
|
|
123
123
|
* Subclasses may override this to suppress the route change when they intend
|
|
124
124
|
* to navigate somewhere specific immediately after logout.
|
|
125
125
|
*/
|
|
126
|
-
|
|
126
|
+
userDidLogOut() {
|
|
127
127
|
this.performFunctionWithDelay(0.01, function() {
|
|
128
128
|
import_uicore_ts2.UIRoute.currentRoute.routeByRemovingComponentsOtherThanOnesNamed([
|
|
129
129
|
"settings"
|
|
@@ -150,32 +150,32 @@ const _CBCore = class _CBCore extends import_uicore_ts2.UIObject {
|
|
|
150
150
|
}
|
|
151
151
|
set userProfile(userProfile) {
|
|
152
152
|
this._userProfile = userProfile;
|
|
153
|
-
this.
|
|
153
|
+
this.userProfileDidChange();
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
156
156
|
* Called whenever `userProfile` is assigned.
|
|
157
157
|
*
|
|
158
158
|
* The default implementation derives `isUserLoggedIn` from the profile
|
|
159
|
-
* and triggers the login/logout broadcast via `
|
|
159
|
+
* and triggers the login/logout broadcast via `userLoginStateDidChange`.
|
|
160
160
|
*
|
|
161
161
|
* Subclasses may override this to fetch additional session data before
|
|
162
162
|
* the broadcast fires. The override must be `async` and must call
|
|
163
|
-
* `super.
|
|
163
|
+
* `super.userProfileDidChange()` after it has finished populating any
|
|
164
164
|
* extra state, so that all broadcast listeners receive a complete core:
|
|
165
165
|
*
|
|
166
166
|
* ```typescript
|
|
167
|
-
* override async
|
|
167
|
+
* override async userProfileDidChange() {
|
|
168
168
|
* if (IS(this.userProfile)) {
|
|
169
169
|
* this.companyStatus = (await SocketClient.CurrentUserStatusInCompany()).result
|
|
170
170
|
* }
|
|
171
171
|
* else {
|
|
172
172
|
* this.companyStatus = undefined
|
|
173
173
|
* }
|
|
174
|
-
* super.
|
|
174
|
+
* super.userProfileDidChange() // broadcast fires here
|
|
175
175
|
* }
|
|
176
176
|
* ```
|
|
177
177
|
*/
|
|
178
|
-
|
|
178
|
+
userProfileDidChange() {
|
|
179
179
|
this.isUserLoggedIn = (0, import_uicore_ts2.IS)(this.userProfile);
|
|
180
180
|
}
|
|
181
181
|
set languageKey(languageKey) {
|
|
@@ -183,7 +183,7 @@ const _CBCore = class _CBCore extends import_uicore_ts2.UIObject {
|
|
|
183
183
|
localStorage.removeItem("CBLanguageKey");
|
|
184
184
|
}
|
|
185
185
|
localStorage.setItem("CBLanguageKey", JSON.stringify(languageKey));
|
|
186
|
-
this.
|
|
186
|
+
this.languageKeyDidChange();
|
|
187
187
|
}
|
|
188
188
|
get languageKey() {
|
|
189
189
|
return (0, import_uicore_ts2.FIRST)(localStorage.getItem("CBLanguageKey"), import_CBLanguageService.CBLanguageService.defaultLanguageKey).replace(
|
|
@@ -191,7 +191,7 @@ const _CBCore = class _CBCore extends import_uicore_ts2.UIObject {
|
|
|
191
191
|
""
|
|
192
192
|
).replace('"', "");
|
|
193
193
|
}
|
|
194
|
-
|
|
194
|
+
languageKeyDidChange() {
|
|
195
195
|
import_uicore_ts2.UIRoute.currentRoute.routeWithComponent(
|
|
196
196
|
"settings",
|
|
197
197
|
{ "language": this.languageKey },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/CBCore.ts"],
|
|
4
|
-
"sourcesContent": ["import { ManagerOptions, SocketOptions } from \"socket.io-client\"\nimport { NO } from \"uicore-ts\"\nimport { 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\n/**\n * CBCore \u2014 Application session model and library entry point.\n *\n * CBCore is a general-purpose library class. It must not contain any\n * project-specific business logic. To extend it for a specific project,\n * subclass CBCore and register the subclass as the singleton before any\n * other code accesses `CBCore.sharedInstance`.\n *\n * ## Extension pattern\n *\n * 1. Subclass CBCore in your project:\n *\n * ```typescript\n * class MyAppCore extends CBCore {\n *\n * // Additional session-level state goes here.\n * mySessionData: MySessionData | undefined = undefined\n *\n * // Override didSetUserProfile to fetch session data before the\n * // userDidLogIn broadcast fires. Call super only after your data\n * // is ready so that every listener receives a fully populated core.\n * override async didSetUserProfile() {\n * if (IS(this.userProfile)) {\n * this.mySessionData = await fetchMySessionData()\n * }\n * else {\n * this.mySessionData = undefined\n * }\n * super.didSetUserProfile()\n * }\n *\n * // Expose a typed singleton so callers never need CBCore.sharedInstance.\n * static override get sharedInstance(): MyAppCore {\n * return CBCore.sharedInstance as MyAppCore\n * }\n *\n * }\n * ```\n *\n * 2. Register the subclass at app startup, before UICore is initialised:\n *\n * ```typescript\n * CBCore.setSharedInstance(new MyAppCore())\n * CBCore.initIfNeededWithViewCore(new UICore(...))\n * ```\n *\n * 3. From that point on, every call to `CBCore.sharedInstance` \u2014 including\n * calls made internally by the library \u2014 returns the MyAppCore instance.\n * Project code should call `MyAppCore.sharedInstance` for the typed version.\n */\nexport class CBCore extends UIObject {\n \n private static _sharedInstance: CBCore\n \n viewCores: UICore[] = []\n \n _isUserLoggedIn = NO\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 if (event.key == \"CBLanguageKey\") {\n this.didSetLanguageKey()\n }\n \n }.bind(this))\n \n \n this.didSetLanguageKey()\n \n \n }\n \n \n static initIfNeededWithViewCore(\n viewCore: UICore\n ) {\n CBCore.sharedInstance.viewCores.push(viewCore)\n }\n \n \n /**\n * Returns the shared singleton instance.\n *\n * If `setSharedInstance` was called before this getter was first accessed,\n * that instance is returned. Otherwise a default `CBCore` is created.\n * Library-internal code always goes through this getter, so registering a\n * subclass via `setSharedInstance` is sufficient to replace the singleton\n * for the entire session.\n */\n static get sharedInstance() {\n if (!CBCore._sharedInstance) {\n CBCore._sharedInstance = new CBCore()\n }\n return CBCore._sharedInstance\n }\n \n \n /**\n * Registers a subclass instance as the application singleton.\n *\n * Call this once at app startup, before `CBCore.sharedInstance` or\n * `CBCore.initIfNeededWithViewCore` are first accessed. Calling it after\n * the singleton has already been created has no effect and will throw in\n * development to catch accidental misuse.\n *\n * ```typescript\n * // App entry point \u2014 must be the very first thing that runs.\n * CBCore.setSharedInstance(new MyAppCore())\n * CBCore.initIfNeededWithViewCore(new UICore(\"root\", RootViewController))\n * ```\n */\n static setSharedInstance(instance: CBCore) {\n \n if (CBCore._sharedInstance) {\n /// #if DEV\n throw new Error(\n \"CBCore.setSharedInstance must be called before sharedInstance is first accessed. \" +\n \"Move the call to the very top of your app entry point.\"\n )\n /// #endif\n return\n }\n \n CBCore._sharedInstance = instance\n \n }\n \n \n static broadcastEventName = {\n \n \"userDidLogIn\": \"UserDidLogIn\",\n \"userDidLogOut\": \"UserDidLogOut\"\n \n } as const\n \n broadcastMessageInRootViewTree(message: UIViewBroadcastEvent) {\n \n this.viewCores.everyElement.rootViewController.view.broadcastEventInSubtree(message)\n \n }\n \n \n 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 this._isUserLoggedIn = 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.didLogOut()\n \n }\n \n }\n \n /**\n * Called when the user transitions from logged-in to logged-out.\n * The default implementation clears the route and broadcasts `userDidLogOut`.\n * Subclasses may override this to suppress the route change when they intend\n * to navigate somewhere specific immediately after logout.\n */\n didLogOut() {\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 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 this._isUserLoggedIn\n }\n \n \n _userProfile: CBUserProfile\n \n get userProfile() {\n return this._userProfile\n }\n \n set userProfile(userProfile: CBUserProfile) {\n this._userProfile = userProfile\n this.didSetUserProfile()\n }\n \n /**\n * Called whenever `userProfile` is assigned.\n *\n * The default implementation derives `isUserLoggedIn` from the profile\n * and triggers the login/logout broadcast via `didSetIsUserLoggedIn`.\n *\n * Subclasses may override this to fetch additional session data before\n * the broadcast fires. The override must be `async` and must call\n * `super.didSetUserProfile()` after it has finished populating any\n * extra state, so that all broadcast listeners receive a complete core:\n *\n * ```typescript\n * override async didSetUserProfile() {\n * if (IS(this.userProfile)) {\n * this.companyStatus = (await SocketClient.CurrentUserStatusInCompany()).result\n * }\n * else {\n * this.companyStatus = undefined\n * }\n * super.didSetUserProfile() // broadcast fires here\n * }\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"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAAmB;AACnB,IAAAA,oBAAqG;AAErG,+BAAkC;AAClC,4BAA+B;AAC/B,4BAA+B;AAqExB,MAAM,UAAN,MAAM,gBAAe,2BAAS;AAAA,EAiBjC,cAAc;AAEV,UAAM;AAfV,qBAAsB,CAAC;AAEvB,2BAAkB;AAClB,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;AAEA,UAAI,MAAM,OAAO,iBAAiB;AAC9B,aAAK,
|
|
4
|
+
"sourcesContent": ["import { ManagerOptions, SocketOptions } from \"socket.io-client\"\nimport { NO } from \"uicore-ts\"\nimport { 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\n/**\n * CBCore \u2014 Application session model and library entry point.\n *\n * CBCore is a general-purpose library class. It must not contain any\n * project-specific business logic. To extend it for a specific project,\n * subclass CBCore and register the subclass as the singleton before any\n * other code accesses `CBCore.sharedInstance`.\n *\n * ## Extension pattern\n *\n * 1. Subclass CBCore in your project:\n *\n * ```typescript\n * class MyAppCore extends CBCore {\n *\n * // Additional session-level state goes here.\n * mySessionData: MySessionData | undefined = undefined\n *\n * // Override userProfileDidChange to fetch session data before the\n * // userDidLogIn broadcast fires. Call super only after your data\n * // is ready so that every listener receives a fully populated core.\n * override async userProfileDidChange() {\n * if (IS(this.userProfile)) {\n * this.mySessionData = await fetchMySessionData()\n * }\n * else {\n * this.mySessionData = undefined\n * }\n * super.userProfileDidChange()\n * }\n *\n * // Expose a typed singleton so callers never need CBCore.sharedInstance.\n * static override get sharedInstance(): MyAppCore {\n * return CBCore.sharedInstance as MyAppCore\n * }\n *\n * }\n * ```\n *\n * 2. Register the subclass at app startup, before UICore is initialised:\n *\n * ```typescript\n * CBCore.registerSharedInstance(new MyAppCore())\n * CBCore.initIfNeededWithViewCore(new UICore(...))\n * ```\n *\n * 3. From that point on, every call to `CBCore.sharedInstance` \u2014 including\n * calls made internally by the library \u2014 returns the MyAppCore instance.\n * Project code should call `MyAppCore.sharedInstance` for the typed version.\n */\nexport class CBCore extends UIObject {\n \n private static _sharedInstance: CBCore\n \n viewCores: UICore[] = []\n \n _isUserLoggedIn = NO\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 if (event.key == \"CBLanguageKey\") {\n this.languageKeyDidChange()\n }\n \n }.bind(this))\n \n \n this.languageKeyDidChange()\n \n \n }\n \n \n static initIfNeededWithViewCore(\n viewCore: UICore\n ) {\n CBCore.sharedInstance.viewCores.push(viewCore)\n }\n \n \n /**\n * Returns the shared singleton instance.\n *\n * If `registerSharedInstance` was called before this getter was first accessed,\n * that instance is returned. Otherwise a default `CBCore` is created.\n * Library-internal code always goes through this getter, so registering a\n * subclass via `registerSharedInstance` is sufficient to replace the singleton\n * for the entire session.\n */\n static get sharedInstance() {\n if (!CBCore._sharedInstance) {\n CBCore._sharedInstance = new CBCore()\n }\n return CBCore._sharedInstance\n }\n \n \n /**\n * Registers a subclass instance as the application singleton.\n *\n * Call this once at app startup, before `CBCore.sharedInstance` or\n * `CBCore.initIfNeededWithViewCore` are first accessed. Calling it after\n * the singleton has already been created has no effect and will throw in\n * development to catch accidental misuse.\n *\n * ```typescript\n * // App entry point \u2014 must be the very first thing that runs.\n * CBCore.registerSharedInstance(new MyAppCore())\n * CBCore.initIfNeededWithViewCore(new UICore(\"root\", RootViewController))\n * ```\n */\n static registerSharedInstance(instance: CBCore) {\n \n if (CBCore._sharedInstance) {\n /// #if DEV\n throw new Error(\n \"CBCore.registerSharedInstance must be called before sharedInstance is first accessed. \" +\n \"Move the call to the very top of your app entry point.\"\n )\n /// #endif\n return\n }\n \n CBCore._sharedInstance = instance\n \n }\n \n \n static broadcastEventName = {\n \n \"userDidLogIn\": \"UserDidLogIn\",\n \"userDidLogOut\": \"UserDidLogOut\"\n \n } as const\n \n broadcastMessageInRootViewTree(message: UIViewBroadcastEvent) {\n \n this.viewCores.everyElement.rootViewController.view.broadcastEventInSubtree(message)\n \n }\n \n \n 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 this._isUserLoggedIn = isUserLoggedIn\n this.userLoginStateDidChange(previousValue)\n }\n \n userLoginStateDidChange(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.userDidLogOut()\n \n }\n \n }\n \n /**\n * Called when the user transitions from logged-in to logged-out.\n * The default implementation clears the route and broadcasts `userDidLogOut`.\n * Subclasses may override this to suppress the route change when they intend\n * to navigate somewhere specific immediately after logout.\n */\n userDidLogOut() {\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 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 this._isUserLoggedIn\n }\n \n \n _userProfile: CBUserProfile\n \n get userProfile() {\n return this._userProfile\n }\n \n set userProfile(userProfile: CBUserProfile) {\n this._userProfile = userProfile\n this.userProfileDidChange()\n }\n \n /**\n * Called whenever `userProfile` is assigned.\n *\n * The default implementation derives `isUserLoggedIn` from the profile\n * and triggers the login/logout broadcast via `userLoginStateDidChange`.\n *\n * Subclasses may override this to fetch additional session data before\n * the broadcast fires. The override must be `async` and must call\n * `super.userProfileDidChange()` after it has finished populating any\n * extra state, so that all broadcast listeners receive a complete core:\n *\n * ```typescript\n * override async userProfileDidChange() {\n * if (IS(this.userProfile)) {\n * this.companyStatus = (await SocketClient.CurrentUserStatusInCompany()).result\n * }\n * else {\n * this.companyStatus = undefined\n * }\n * super.userProfileDidChange() // broadcast fires here\n * }\n * ```\n */\n userProfileDidChange() {\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.languageKeyDidChange()\n }\n \n get languageKey() {\n return FIRST(localStorage.getItem(\"CBLanguageKey\"), CBLanguageService.defaultLanguageKey).replace(\n \"\\\"\",\n \"\"\n ).replace(\"\\\"\", \"\")\n }\n \n languageKeyDidChange() {\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAAmB;A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C5D,mBAAe;AAAA,EACnB;AAGJ;AAtSa,QAsGF,qBAAqB;AAAA,EAExB,gBAAgB;AAAA,EAChB,iBAAiB;AAErB;AA3GG,IAAM,SAAN;",
|
|
6
6
|
"names": ["import_uicore_ts"]
|
|
7
7
|
}
|
|
@@ -18,14 +18,14 @@ interface CBSocketCallbackHolderMessageDescriptor {
|
|
|
18
18
|
_timeoutId?: ReturnType<typeof setTimeout>;
|
|
19
19
|
/**
|
|
20
20
|
* Called when a keepalive frame arrives for this descriptor's request.
|
|
21
|
-
* Registered via CBSocketRequestPromise.
|
|
21
|
+
* Registered via CBSocketRequestPromise.addKeepaliveHandler().
|
|
22
22
|
*/
|
|
23
23
|
keepaliveHandler?: (payload: CBSocketKeepalivePayload) => void;
|
|
24
24
|
/**
|
|
25
|
-
* When true the
|
|
25
|
+
* When true the default keepalive handler on CBSocketClient is NOT called
|
|
26
26
|
* for this descriptor — only keepaliveHandler fires.
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
skipsDefaultKeepaliveHandler: boolean;
|
|
29
29
|
}
|
|
30
30
|
export declare class CBSocketCallbackHolder extends UIObject {
|
|
31
31
|
messageDescriptors: {
|
|
@@ -34,7 +34,7 @@ export declare class CBSocketCallbackHolder extends UIObject {
|
|
|
34
34
|
handlers: {
|
|
35
35
|
[x: string]: CBSocketMessageHandlerFunction[];
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
oneTimeHandlers: {
|
|
38
38
|
[x: string]: CBSocketMessageHandlerFunction[];
|
|
39
39
|
};
|
|
40
40
|
keysForIdentifiers: {
|
|
@@ -55,7 +55,7 @@ export declare class CBSocketCallbackHolder extends UIObject {
|
|
|
55
55
|
constructor(socketClient: CBSocketClient, previousCallbackHolder?: CBSocketCallbackHolder);
|
|
56
56
|
triggerDisconnectHandlers(): void;
|
|
57
57
|
registerHandler(key: string, handlerFunction: CBSocketMessageHandlerFunction): void;
|
|
58
|
-
|
|
58
|
+
registerOneTimeHandler(key: string, handlerFunction: CBSocketMessageHandlerFunction): void;
|
|
59
59
|
_scheduleTimeoutForDescriptor(descriptor: CBSocketCallbackHolderMessageDescriptor): void;
|
|
60
60
|
_cancelTimeoutForDescriptor(descriptor: CBSocketCallbackHolderMessageDescriptor): void;
|
|
61
61
|
/**
|
|
@@ -39,7 +39,7 @@ class CBSocketCallbackHolder extends import_uicore_ts.UIObject {
|
|
|
39
39
|
super();
|
|
40
40
|
this.messageDescriptors = {};
|
|
41
41
|
this.handlers = {};
|
|
42
|
-
this.
|
|
42
|
+
this.oneTimeHandlers = {};
|
|
43
43
|
this.keysForIdentifiers = {};
|
|
44
44
|
this.isValid = import_uicore_ts.YES;
|
|
45
45
|
this._storeableResponseKeys = [];
|
|
@@ -71,11 +71,11 @@ class CBSocketCallbackHolder extends import_uicore_ts.UIObject {
|
|
|
71
71
|
}
|
|
72
72
|
this.handlers[key].push(handlerFunction);
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
if (!this.
|
|
76
|
-
this.
|
|
74
|
+
registerOneTimeHandler(key, handlerFunction) {
|
|
75
|
+
if (!this.oneTimeHandlers[key]) {
|
|
76
|
+
this.oneTimeHandlers[key] = [];
|
|
77
77
|
}
|
|
78
|
-
this.
|
|
78
|
+
this.oneTimeHandlers[key].push(handlerFunction);
|
|
79
79
|
}
|
|
80
80
|
_scheduleTimeoutForDescriptor(descriptor) {
|
|
81
81
|
const timeoutMs = this._socketClient.requestTimeoutMs;
|
|
@@ -246,7 +246,7 @@ class CBSocketCallbackHolder extends import_uicore_ts.UIObject {
|
|
|
246
246
|
completionPolicy,
|
|
247
247
|
completionFunction,
|
|
248
248
|
keepaliveHandler: void 0,
|
|
249
|
-
|
|
249
|
+
skipsDefaultKeepaliveHandler: import_uicore_ts.NO
|
|
250
250
|
});
|
|
251
251
|
const pushedDescriptor = this.messageDescriptors[descriptorKey].lastElement;
|
|
252
252
|
this.keysForIdentifiers[message.identifier] = descriptorKey;
|
|
@@ -306,7 +306,7 @@ class CBSocketCallbackHolder extends import_uicore_ts.UIObject {
|
|
|
306
306
|
);
|
|
307
307
|
}.bind(this),
|
|
308
308
|
keepaliveHandler: void 0,
|
|
309
|
-
|
|
309
|
+
skipsDefaultKeepaliveHandler: import_uicore_ts.NO
|
|
310
310
|
});
|
|
311
311
|
this.keysForIdentifiers[messageToSend.identifier] = descriptorKey;
|
|
312
312
|
}
|
|
@@ -320,11 +320,11 @@ class CBSocketCallbackHolder extends import_uicore_ts.UIObject {
|
|
|
320
320
|
handler(message.messageData, sendResponseFunction);
|
|
321
321
|
}.bind(this));
|
|
322
322
|
}
|
|
323
|
-
if (this.
|
|
324
|
-
this.
|
|
323
|
+
if (this.oneTimeHandlers[key]) {
|
|
324
|
+
this.oneTimeHandlers[key].forEach(function(handler) {
|
|
325
325
|
handler(message.messageData, sendResponseFunction);
|
|
326
326
|
}.bind(this));
|
|
327
|
-
delete this.
|
|
327
|
+
delete this.oneTimeHandlers[key];
|
|
328
328
|
}
|
|
329
329
|
if (message.inResponseToIdentifier && (import_CBSocketClient.CBSocketClient.responseMessageKey == key || import_CBSocketClient.CBSocketClient.multipleMessageKey == key)) {
|
|
330
330
|
const descriptorKey = this.keysForIdentifiers[message.inResponseToIdentifier];
|
|
@@ -337,8 +337,8 @@ class CBSocketCallbackHolder extends import_uicore_ts.UIObject {
|
|
|
337
337
|
return;
|
|
338
338
|
}
|
|
339
339
|
this._resetTimeoutForDescriptor(descriptor);
|
|
340
|
-
if (!descriptor.
|
|
341
|
-
(_b = (_a2 = this._socketClient).
|
|
340
|
+
if (!descriptor.skipsDefaultKeepaliveHandler) {
|
|
341
|
+
(_b = (_a2 = this._socketClient).keepaliveDidArrive) == null ? void 0 : _b.call(_a2, payload);
|
|
342
342
|
}
|
|
343
343
|
(_c = descriptor.keepaliveHandler) == null ? void 0 : _c.call(descriptor, payload);
|
|
344
344
|
});
|