@staffbase/plugins-client-sdk 2.0.1 → 3.0.0-alpha.2

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.
@@ -2,12 +2,12 @@
2
2
  * Bundle of @staffbase/plugins-client-sdk
3
3
  * @file Staffbase plugins client SDK for JavaScript
4
4
  * @see https://github.com/Staffbase/plugins-client-sdk#readme
5
- * @version 2.0.0
5
+ * @version 3.0.0-alpha.2
6
6
  *
7
7
  * @author Stefan Staude <stefan.staude@staffbase.com>
8
8
  * @author Daniel Große <daniel.grosse@staffbase.com>
9
9
  *
10
- * @copyright 2023
10
+ * @copyright 2026
11
11
  * @license Apache-2.0
12
12
  */
13
13
 
@@ -40,6 +40,8 @@ var loglevel = {
40
40
  var undefinedType = "undefined";
41
41
  var isIE = typeof window !== undefinedType && typeof window.navigator !== undefinedType && /Trident\/|MSIE /.test(window.navigator.userAgent);
42
42
  var logMethods = ["trace", "debug", "info", "warn", "error"];
43
+ var _loggersByName = {};
44
+ var defaultLogger = null;
43
45
 
44
46
  // Cross-browser bind equivalent that works at least back to IE6
45
47
  function bindMethod(obj, methodName) {
@@ -92,23 +94,31 @@ var loglevel = {
92
94
 
93
95
  // These private functions always need `this` to be set properly
94
96
 
95
- function replaceLoggingMethods(level, loggerName) {
97
+ function replaceLoggingMethods() {
96
98
  /*jshint validthis:true */
99
+ var level = this.getLevel();
100
+
101
+ // Replace the actual methods.
97
102
  for (var i = 0; i < logMethods.length; i++) {
98
103
  var methodName = logMethods[i];
99
- this[methodName] = i < level ? noop : this.methodFactory(methodName, level, loggerName);
104
+ this[methodName] = i < level ? noop : this.methodFactory(methodName, level, this.name);
100
105
  }
101
106
 
102
107
  // Define log.log as an alias for log.debug
103
108
  this.log = this.debug;
109
+
110
+ // Return any important warnings.
111
+ if (typeof console === undefinedType && level < this.levels.SILENT) {
112
+ return "No console available for logging";
113
+ }
104
114
  }
105
115
 
106
116
  // In old IE versions, the console isn't present until you first open it.
107
117
  // We build realMethod() replacements here that regenerate logging methods
108
- function enableLoggingWhenConsoleArrives(methodName, level, loggerName) {
118
+ function enableLoggingWhenConsoleArrives(methodName) {
109
119
  return function () {
110
120
  if (typeof console !== undefinedType) {
111
- replaceLoggingMethods.call(this, level, loggerName);
121
+ replaceLoggingMethods.call(this);
112
122
  this[methodName].apply(this, arguments);
113
123
  }
114
124
  };
@@ -116,14 +126,34 @@ var loglevel = {
116
126
 
117
127
  // By default, we use closely bound real methods wherever possible, and
118
128
  // otherwise we wait for a console to appear, and then try again.
119
- function defaultMethodFactory(methodName, level, loggerName) {
129
+ function defaultMethodFactory(methodName, _level, _loggerName) {
120
130
  /*jshint validthis:true */
121
131
  return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
122
132
  }
123
- function Logger(name, defaultLevel, factory) {
133
+ function Logger(name, factory) {
134
+ // Private instance variables.
124
135
  var self = this;
125
- var currentLevel;
126
- defaultLevel = defaultLevel == null ? "WARN" : defaultLevel;
136
+ /**
137
+ * The level inherited from a parent logger (or a global default). We
138
+ * cache this here rather than delegating to the parent so that it stays
139
+ * in sync with the actual logging methods that we have installed (the
140
+ * parent could change levels but we might not have rebuilt the loggers
141
+ * in this child yet).
142
+ * @type {number}
143
+ */
144
+ var inheritedLevel;
145
+ /**
146
+ * The default level for this logger, if any. If set, this overrides
147
+ * `inheritedLevel`.
148
+ * @type {number|null}
149
+ */
150
+ var defaultLevel;
151
+ /**
152
+ * A user-specific level for this logger. If set, this overrides
153
+ * `defaultLevel`.
154
+ * @type {number|null}
155
+ */
156
+ var userLevel;
127
157
  var storageKey = "loglevel";
128
158
  if (typeof name === "string") {
129
159
  storageKey += ":" + name;
@@ -156,9 +186,10 @@ var loglevel = {
156
186
  if (typeof storedLevel === undefinedType) {
157
187
  try {
158
188
  var cookie = window.document.cookie;
159
- var location = cookie.indexOf(encodeURIComponent(storageKey) + "=");
189
+ var cookieName = encodeURIComponent(storageKey);
190
+ var location = cookie.indexOf(cookieName + "=");
160
191
  if (location !== -1) {
161
- storedLevel = /^([^;]+)/.exec(cookie.slice(location))[1];
192
+ storedLevel = /^([^;]+)/.exec(cookie.slice(location + cookieName.length + 1))[1];
162
193
  }
163
194
  } catch (ignore) {}
164
195
  }
@@ -175,7 +206,6 @@ var loglevel = {
175
206
  // Use localStorage if available
176
207
  try {
177
208
  window.localStorage.removeItem(storageKey);
178
- return;
179
209
  } catch (ignore) {}
180
210
 
181
211
  // Use session cookie as fallback
@@ -183,6 +213,17 @@ var loglevel = {
183
213
  window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
184
214
  } catch (ignore) {}
185
215
  }
216
+ function normalizeLevel(input) {
217
+ var level = input;
218
+ if (typeof level === "string" && self.levels[level.toUpperCase()] !== undefined) {
219
+ level = self.levels[level.toUpperCase()];
220
+ }
221
+ if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) {
222
+ return level;
223
+ } else {
224
+ throw new TypeError("log.setLevel() called with invalid level: " + input);
225
+ }
226
+ }
186
227
 
187
228
  /*
188
229
  *
@@ -201,46 +242,60 @@ var loglevel = {
201
242
  };
202
243
  self.methodFactory = factory || defaultMethodFactory;
203
244
  self.getLevel = function () {
204
- return currentLevel;
245
+ if (userLevel != null) {
246
+ return userLevel;
247
+ } else if (defaultLevel != null) {
248
+ return defaultLevel;
249
+ } else {
250
+ return inheritedLevel;
251
+ }
205
252
  };
206
253
  self.setLevel = function (level, persist) {
207
- if (typeof level === "string" && self.levels[level.toUpperCase()] !== undefined) {
208
- level = self.levels[level.toUpperCase()];
209
- }
210
- if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) {
211
- currentLevel = level;
212
- if (persist !== false) {
213
- // defaults to true
214
- persistLevelIfPossible(level);
215
- }
216
- replaceLoggingMethods.call(self, level, name);
217
- if (typeof console === undefinedType && level < self.levels.SILENT) {
218
- return "No console available for logging";
219
- }
220
- } else {
221
- throw "log.setLevel() called with invalid level: " + level;
254
+ userLevel = normalizeLevel(level);
255
+ if (persist !== false) {
256
+ // defaults to true
257
+ persistLevelIfPossible(userLevel);
222
258
  }
259
+
260
+ // NOTE: in v2, this should call rebuild(), which updates children.
261
+ return replaceLoggingMethods.call(self);
223
262
  };
224
263
  self.setDefaultLevel = function (level) {
225
- defaultLevel = level;
264
+ defaultLevel = normalizeLevel(level);
226
265
  if (!getPersistedLevel()) {
227
266
  self.setLevel(level, false);
228
267
  }
229
268
  };
230
269
  self.resetLevel = function () {
231
- self.setLevel(defaultLevel, false);
270
+ userLevel = null;
232
271
  clearPersistedLevel();
272
+ replaceLoggingMethods.call(self);
273
+ };
274
+ self.enableAll = function (persist) {
275
+ self.setLevel(self.levels.TRACE, persist);
233
276
  };
234
277
  self.disableAll = function (persist) {
235
278
  self.setLevel(self.levels.SILENT, persist);
236
279
  };
280
+ self.rebuild = function () {
281
+ if (defaultLogger !== self) {
282
+ inheritedLevel = normalizeLevel(defaultLogger.getLevel());
283
+ }
284
+ replaceLoggingMethods.call(self);
285
+ if (defaultLogger === self) {
286
+ for (var childName in _loggersByName) {
287
+ _loggersByName[childName].rebuild();
288
+ }
289
+ }
290
+ };
237
291
 
238
- // Initialize with the right level
292
+ // Initialize all the internal levels.
293
+ inheritedLevel = normalizeLevel(defaultLogger ? defaultLogger.getLevel() : "WARN");
239
294
  var initialLevel = getPersistedLevel();
240
- if (initialLevel == null) {
241
- initialLevel = defaultLevel;
295
+ if (initialLevel != null) {
296
+ userLevel = normalizeLevel(initialLevel);
242
297
  }
243
- self.setLevel(initialLevel, false);
298
+ replaceLoggingMethods.call(self);
244
299
  }
245
300
 
246
301
  /*
@@ -249,15 +304,14 @@ var loglevel = {
249
304
  *
250
305
  */
251
306
 
252
- var defaultLogger = new Logger();
253
- var _loggersByName = {};
307
+ defaultLogger = new Logger();
254
308
  defaultLogger.getLogger = function getLogger(name) {
255
309
  if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
256
310
  throw new TypeError("You must supply a name when creating a logger.");
257
311
  }
258
312
  var logger = _loggersByName[name];
259
313
  if (!logger) {
260
- logger = _loggersByName[name] = new Logger(name, defaultLogger.getLevel(), defaultLogger.methodFactory);
314
+ logger = _loggersByName[name] = new Logger(name, defaultLogger.methodFactory);
261
315
  }
262
316
  return logger;
263
317
  };
@@ -343,7 +397,8 @@ const commands = {
343
397
  nativeShare: 'nativeShareDialog',
344
398
  langInfos: 'getLanguageInfos',
345
399
  branchDefaultLang: 'getBranchDefaultLanguage',
346
- prefContentLang: 'getPreferredContentLocale'
400
+ prefContentLang: 'getPreferredContentLocale',
401
+ userContentLocale: 'getUserContentLocale'
347
402
  };
348
403
 
349
404
  /**
@@ -441,6 +496,12 @@ var locales = {
441
496
  name: 'English',
442
497
  localizedName: 'English'
443
498
  },
499
+ enGB: {
500
+ key: 'enGB',
501
+ locale: 'en_GB',
502
+ name: 'English (United Kingdom)',
503
+ localizedName: 'English (United Kingdom)'
504
+ },
444
505
  es: {
445
506
  key: 'es',
446
507
  locale: 'es_ES',
@@ -932,7 +993,17 @@ const getPreferredContentLocale$2 = content => {
932
993
  }
933
994
  };
934
995
 
935
- let connection$2 = null;
996
+ /**
997
+ * Get the current user's content locale, fallback to branch default locale
998
+ *
999
+ * @return {String} the user's content locale
1000
+ */
1001
+ const getUserContentLocale$2 = () => {
1002
+ const locale = getBranchDefaultLanguage$2().locale;
1003
+ return locale;
1004
+ };
1005
+
1006
+ let connection$1 = null;
936
1007
  const fallbackKickIn = 500;
937
1008
 
938
1009
  /**
@@ -942,17 +1013,17 @@ const fallbackKickIn = 500;
942
1013
  * after the time specified in fallbackKickIn runs out.
943
1014
  * @return {Promise<function>} An appropriate send function
944
1015
  */
945
- var fallback = (() => {
946
- if (connection$2) {
947
- return connection$2;
1016
+ var fallback = () => {
1017
+ if (connection$1) {
1018
+ return connection$1;
948
1019
  }
949
- connection$2 = new Promise(resolve => {
1020
+ connection$1 = new Promise(resolve => {
950
1021
  setTimeout(function () {
951
- resolve(sendMessage$3);
1022
+ resolve(sendMessage$2);
952
1023
  }, fallbackKickIn);
953
1024
  });
954
- return connection$2;
955
- });
1025
+ return connection$1;
1026
+ };
956
1027
 
957
1028
  /**
958
1029
  * Send a SDK command to the Staffbase App.
@@ -963,7 +1034,7 @@ var fallback = (() => {
963
1034
  * @return {Promise<any>} which awaits the response of the Staffbase App
964
1035
  * @throws {Error} on commands not supported by protocol
965
1036
  */
966
- const sendMessage$3 = async function (cmd) {
1037
+ const sendMessage$2 = async function (cmd) {
967
1038
  for (var _len = arguments.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
968
1039
  payload[_key - 1] = arguments[_key];
969
1040
  }
@@ -986,6 +1057,8 @@ const sendMessage$3 = async function (cmd) {
986
1057
  return getBranchDefaultLanguage$2();
987
1058
  case commands.prefContentLang:
988
1059
  return getPreferredContentLocale$2.apply(null, payload);
1060
+ case commands.userContentLocale:
1061
+ return getUserContentLocale$2();
989
1062
  case commands.nativeUpload:
990
1063
  case commands.nativeShare:
991
1064
  return unSupported();
@@ -1008,7 +1081,6 @@ var protocol = {
1008
1081
  // send this to call a function in the frontend
1009
1082
  ERROR: 'ERROR' // receive this when something goes wrong
1010
1083
  };
1011
-
1012
1084
  const invocationMapping = {
1013
1085
  [commands.openLink]: 'openLink',
1014
1086
  [commands.nativeUpload]: 'nativeFileUpload',
@@ -1071,11 +1143,9 @@ const create = () => {
1071
1143
  *
1072
1144
  * @param {string} id of the promise
1073
1145
  * @param {any} msg the message which will will be passed to resolve
1074
- *
1075
- * @throws {Error} on unknown id
1076
1146
  */
1077
1147
  const resolve = (id, msg) => {
1078
- if (!(id in promiseMap)) throw new Error('Tried to resolve an unknown [' + id + '] promise.');
1148
+ if (!(id in promiseMap)) return;
1079
1149
  promiseMap[id].resolve(msg);
1080
1150
  delete promiseMap[id];
1081
1151
  };
@@ -1085,10 +1155,9 @@ const resolve = (id, msg) => {
1085
1155
  *
1086
1156
  * @param {string} id of the promise
1087
1157
  * @param {any} err the error which will will be passed to reject
1088
- * @throws {Error} on unknown id
1089
1158
  */
1090
1159
  const reject = (id, err) => {
1091
- if (!(id in promiseMap)) throw new Error('Tried to reject an unknown [' + id + '] promise.');
1160
+ if (!(id in promiseMap)) return;
1092
1161
  promiseMap[id].reject(err);
1093
1162
  delete promiseMap[id];
1094
1163
  };
@@ -1123,7 +1192,7 @@ const get = id => {
1123
1192
  * @static
1124
1193
  * @return {StaticValueStore}
1125
1194
  */
1126
- const dataStore$1 = _ref => {
1195
+ const dataStore = _ref => {
1127
1196
  let {
1128
1197
  platform,
1129
1198
  language
@@ -1138,26 +1207,53 @@ const dataStore$1 = _ref => {
1138
1207
  branchDefaultLanguage: language.branchDefaultLanguage
1139
1208
  };
1140
1209
  };
1141
- let connection$1 = null;
1210
+ let connection = null;
1142
1211
  const targetOrigin = '*';
1143
1212
 
1144
1213
  /**
1145
1214
  * Connect to the Staffbase App.
1146
1215
  *
1147
- * Create a connection to a Staffbase app 3.6
1148
- * @return {Promise<function>} An appropriate send function
1216
+ * Create a connection to a Staffbase app
1217
+ * Tries to reconnect until an answer is received
1218
+ *
1219
+ * @return {Promise<Function>} An appropriate send function
1149
1220
  */
1150
- const connect$2 = () => {
1151
- if (connection$1) {
1152
- return connection$1;
1221
+ const connect$1 = () => {
1222
+ if (connection) {
1223
+ return connection;
1153
1224
  }
1154
1225
  const connectId = create();
1155
- connection$1 = get(connectId).then(function (payload) {
1156
- return sendMessage$2(dataStore$1(payload));
1226
+ let timeout;
1227
+ const delayFactor = 1.2;
1228
+ connection = get(connectId).then(payload => {
1229
+ window.clearTimeout(timeout);
1230
+ return sendMessage$1(dataStore(payload));
1157
1231
  });
1158
1232
  window.addEventListener('message', receiveMessage);
1159
- window.parent.postMessage([protocol.HELLO, connectId, []], targetOrigin);
1160
- return connection$1;
1233
+ const recurringConnect = function () {
1234
+ let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 500;
1235
+ timeout = window.setTimeout(() => {
1236
+ if (delay < 1200) {
1237
+ recurringConnect(delay * delayFactor);
1238
+ } else {
1239
+ reject(connectId, 'No answer from Staffbase App');
1240
+ disconnect();
1241
+ }
1242
+ }, delay);
1243
+ window.parent.postMessage([protocol.HELLO, connectId, []], targetOrigin);
1244
+ };
1245
+ recurringConnect();
1246
+ return connection;
1247
+ };
1248
+
1249
+ /**
1250
+ * Disconnect from the Staffbase App
1251
+ *
1252
+ * Only useful for tests.
1253
+ */
1254
+ const disconnect = () => {
1255
+ window.removeEventListener('message', receiveMessage);
1256
+ connection = null;
1161
1257
  };
1162
1258
 
1163
1259
  /**
@@ -1209,7 +1305,7 @@ const receiveMessage = async evt => {
1209
1305
  * @return {Promise<any>} which awaits the response of the Staffbase App
1210
1306
  * @throws {Error} on commands not supported by protocol
1211
1307
  */
1212
- const sendMessage$2 = store => async function (cmd) {
1308
+ const sendMessage$1 = store => async function (cmd) {
1213
1309
  switch (cmd) {
1214
1310
  case commands.version:
1215
1311
  case commands.native:
@@ -1226,7 +1322,7 @@ const sendMessage$2 = store => async function (cmd) {
1226
1322
  for (var _len = arguments.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1227
1323
  payload[_key - 1] = arguments[_key];
1228
1324
  }
1229
- return sendInvocationCall$1(create())(invocationMapping[cmd], payload);
1325
+ return sendInvocationCall(create())(invocationMapping[cmd], payload);
1230
1326
  default:
1231
1327
  throw new Error('Command ' + cmd + ' not supported by driver');
1232
1328
  }
@@ -1241,164 +1337,16 @@ const sendMessage$2 = store => async function (cmd) {
1241
1337
  *
1242
1338
  * @return {Promise}
1243
1339
  */
1244
- const sendInvocationCall$1 = promiseID => (process, args) => {
1340
+ const sendInvocationCall = promiseID => (process, args) => {
1245
1341
  window.parent.postMessage([protocol.INVOCATION, promiseID, process, args], targetOrigin);
1246
1342
  return get(promiseID);
1247
1343
  };
1248
1344
 
1249
- let connection = null;
1250
- let outMsgQueue = [];
1251
-
1252
- /**
1253
- * Simple store solution to make the initial data available
1254
- * as static values
1255
- *
1256
- * @param {InitialValues} initial the initial data from the frontend
1257
- * @static
1258
- * @return {StaticValueStore}
1259
- */
1260
- const dataStore = _ref => {
1261
- let {
1262
- platform,
1263
- language
1264
- } = _ref;
1265
- return {
1266
- mobile: platform.mobile,
1267
- version: platform.version,
1268
- native: platform.native,
1269
- ios: platform.native === 'ios',
1270
- android: platform.native === 'android',
1271
- langInfos: language,
1272
- branchDefaultLang: language.branchDefaultLanguage
1273
- };
1274
- };
1275
- window.Staffbase = window.Staffbase || {};
1276
- window.Staffbase.plugins = {
1277
- getMessages: multiMessageProvider,
1278
- putMessage: singleMessageReceiver
1279
- };
1280
-
1281
- /**
1282
- * Connect to the Staffbase App.
1283
- *
1284
- * Create a connection to a Staffbase app 3.6 from a native tab
1285
- * @return {Promise<function>} An appropriate send function
1286
- */
1287
- const connect$1 = () => {
1288
- if (connection) {
1289
- return connection;
1290
- }
1291
- const connectId = create();
1292
- connection = get(connectId).then(function (payload) {
1293
- return sendMessage$1(dataStore(payload));
1294
- });
1295
- outMsgQueue.push([protocol.HELLO, connectId, []]);
1296
- return connection;
1297
- };
1298
-
1299
- /**
1300
- * A function which returns an array of messages
1301
- *
1302
- * The return value holds all messages in the order the were
1303
- * received over time by sendMessage
1304
- *
1305
- * @return {Array} ordered list of messages
1306
- */
1307
- function multiMessageProvider() {
1308
- const queueRef = outMsgQueue;
1309
- if (queueRef.length) ;
1310
- outMsgQueue = [];
1311
- return queueRef;
1312
- }
1313
-
1314
- /**
1315
- * A function which can receive a single message.
1316
- *
1317
- * Can be attached to window.onPostMessage
1318
- * @param {Array} msg Staffbase 3.6 message
1319
- */
1320
- function singleMessageReceiver(msg) {
1321
- let type;
1322
- let id;
1323
- let payload;
1324
-
1325
- // safe destructure
1326
- try {
1327
- [type, id, payload] = msg;
1328
- switch (type) {
1329
- case protocol.SUCCESS:
1330
- resolve(id, payload);
1331
- break;
1332
- case protocol.ERROR:
1333
- reject(id, payload);
1334
- break;
1335
- default:
1336
- // even thought catch-ignore is a bad style
1337
- // there may be other participants listening
1338
- // to messages in a different format so we
1339
- // silently ignore here
1340
- return;
1341
- }
1342
- } catch (e) {
1343
- // even thought catch-ignore is a bad style
1344
- // there may be other participants listening
1345
- // to messages in a different format so we
1346
- // silently ignore here
1347
- return;
1348
- }
1349
- }
1350
-
1351
- /**
1352
- * Send a SDK command to the Staffbase App.
1353
- *
1354
- * Translates SDK commands into protocol native commands.
1355
- * @param {StaticValueStore} store the store object
1356
- * @param {String} cmd an SDK command
1357
- * @param {array} payload for the command
1358
- * @return {Promise<any>} which awaits the response of the Staffbase App
1359
- * @throws {Error} on commands not supported by protocol
1360
- */
1361
- const sendMessage$1 = store => async function (cmd) {
1362
- switch (cmd) {
1363
- case commands.version:
1364
- case commands.native:
1365
- case commands.mobile:
1366
- case commands.ios:
1367
- case commands.android:
1368
- case commands.langInfos:
1369
- case commands.branchDefaultLang:
1370
- return store[reversedCommands[cmd]];
1371
- case commands.openLink:
1372
- case commands.prefContentLang:
1373
- for (var _len = arguments.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1374
- payload[_key - 1] = arguments[_key];
1375
- }
1376
- return sendInvocationCall(invocationMapping[cmd], payload);
1377
- default:
1378
- throw new Error('Command ' + cmd + ' not supported by driver');
1379
- }
1380
- };
1381
-
1382
- /**
1383
- * Create a promise and send an invocation call to the frontend
1384
- *
1385
- * @param {string} process the name of the process to call
1386
- * @param {array} args an array of arguments
1387
- *
1388
- * @return {Promise}
1389
- */
1390
- const sendInvocationCall = (process, args) => {
1391
- const promiseID = create();
1392
- outMsgQueue.push([protocol.INVOCATION, promiseID, process, args]);
1393
- return get(promiseID);
1394
- };
1395
-
1396
1345
  let connector;
1397
1346
  const connect = async () => {
1398
- const putMessageConnection = connect$1();
1399
- const postMessageConnection = connect$2();
1347
+ const postMessageConnection = connect$1();
1400
1348
  const fallbackConnection = fallback();
1401
- const realConnectionBucket = [putMessageConnection, postMessageConnection];
1349
+ const realConnectionBucket = [postMessageConnection];
1402
1350
  const fallbackConnectionBucket = realConnectionBucket.concat(fallbackConnection);
1403
1351
 
1404
1352
  // Wait on the real communication and replace the connector with
@@ -1568,6 +1516,15 @@ const getPreferredContentLocale$1 = async content => {
1568
1516
  return sendMessage(commands.prefContentLang, content);
1569
1517
  };
1570
1518
 
1519
+ /**
1520
+ * Get the default content language configured for the branch.
1521
+ *
1522
+ * @return {Promise<Object>}
1523
+ */
1524
+ const getUserContentLocale$1 = async () => {
1525
+ return sendMessage(commands.langInfos).then(res => res.userContentLocale);
1526
+ };
1527
+
1571
1528
  /**
1572
1529
  * Compare [semver](https://semver.org/) version strings to find greater, equal or lesser.
1573
1530
  * This library supports the full semver specification, including comparing versions with different number of digits like `1.0.0`, `1.0`, `1`, and pre-release versions like `1.0.0-alpha`.
@@ -1667,6 +1624,7 @@ const canDownload = async () => {
1667
1624
  * Interface exports
1668
1625
  */
1669
1626
 
1627
+
1670
1628
  /**
1671
1629
  * Check if device is able to perform a download.
1672
1630
  * @function
@@ -1773,6 +1731,13 @@ const getContentLanguages = async () => getContentLanguages$1();
1773
1731
  */
1774
1732
  const getPreferredContentLocale = async content => getPreferredContentLocale$1(content);
1775
1733
 
1734
+ /**
1735
+ * Get the current user's content locale, fallback to branch default locale
1736
+ * @function
1737
+ * @return {Promise<any>}
1738
+ */
1739
+ const getUserContentLocale = async () => getUserContentLocale$1();
1740
+
1776
1741
  /**
1777
1742
  * Open a share dialog on native devices
1778
1743
  *
@@ -1791,5 +1756,5 @@ const getPreferredContentLocale = async content => getPreferredContentLocale$1(c
1791
1756
  const openNativeShareDialog = async content => openNativeShareDialog$1(content);
1792
1757
  /* experimental */
1793
1758
 
1794
- export { deviceCanDownload, getAppVersion, getBranchDefaultLanguage, getBranchLanguages, getContentLanguages, getPreferredContentLocale, isAndroidDevice, isIosDevice, isMobileApp, isNativeApp, openLink, openLinkExternal, openLinkInternal, openNativeFileDialog, openNativeShareDialog };
1759
+ export { deviceCanDownload, getAppVersion, getBranchDefaultLanguage, getBranchLanguages, getContentLanguages, getPreferredContentLocale, getUserContentLocale, isAndroidDevice, isIosDevice, isMobileApp, isNativeApp, openLink, openLinkExternal, openLinkInternal, openNativeFileDialog, openNativeShareDialog };
1795
1760
  //# sourceMappingURL=plugins-client-sdk.esm.js.map