@staffbase/plugins-client-sdk 3.0.3 → 3.1.0

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 3.0.0-alpha.2
5
+ * @version 3.0.0-alpha.4
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 2025
10
+ * @copyright 2026
11
11
  * @license Apache-2.0
12
12
  */
13
13
 
@@ -398,6 +398,7 @@
398
398
  version: 'app-version',
399
399
  mobile: 'app-mobile',
400
400
  native: 'app-native',
401
+ instanceUrl: 'instance-url',
401
402
  openLink: 'openExternalLink',
402
403
  nativeUpload: 'nativeFileUpload',
403
404
  nativeShare: 'nativeShareDialog',
@@ -1009,6 +1010,18 @@
1009
1010
  return locale;
1010
1011
  };
1011
1012
 
1013
+ /**
1014
+ * Get the Staffbase instance URL / frontend domain.
1015
+ *
1016
+ * Uses ancestorOrigins when available (chrome/safari in iframe),
1017
+ * falls back to document.referrer or empty string.
1018
+ *
1019
+ * @return {String} the instance URL
1020
+ */
1021
+ const getInstanceUrl$2 = () => {
1022
+ return window.location.ancestorOrigins && window.location.ancestorOrigins[0] || document.referrer || '';
1023
+ };
1024
+
1012
1025
  let connection$1 = null;
1013
1026
  const fallbackKickIn = 500;
1014
1027
 
@@ -1065,6 +1078,8 @@
1065
1078
  return getPreferredContentLocale$2.apply(null, payload);
1066
1079
  case commands.userContentLocale:
1067
1080
  return getUserContentLocale$2();
1081
+ case commands.instanceUrl:
1082
+ return getInstanceUrl$2();
1068
1083
  case commands.nativeUpload:
1069
1084
  case commands.nativeShare:
1070
1085
  return unSupported();
@@ -1201,7 +1216,8 @@
1201
1216
  const dataStore = _ref => {
1202
1217
  let {
1203
1218
  platform,
1204
- language
1219
+ language,
1220
+ instance
1205
1221
  } = _ref;
1206
1222
  return {
1207
1223
  mobile: platform.mobile,
@@ -1210,7 +1226,8 @@
1210
1226
  ios: platform.native === 'ios',
1211
1227
  android: platform.native === 'android',
1212
1228
  langInfos: language,
1213
- branchDefaultLanguage: language.branchDefaultLanguage
1229
+ branchDefaultLanguage: language.branchDefaultLanguage,
1230
+ instanceUrl: instance && instance.url || ''
1214
1231
  };
1215
1232
  };
1216
1233
  let connection = null;
@@ -1319,6 +1336,7 @@
1319
1336
  case commands.ios:
1320
1337
  case commands.android:
1321
1338
  case commands.branchDefaultLang:
1339
+ case commands.instanceUrl:
1322
1340
  return store[reversedCommands[cmd]];
1323
1341
  case commands.langInfos:
1324
1342
  case commands.openLink:
@@ -1531,6 +1549,15 @@
1531
1549
  return sendMessage(commands.langInfos).then(res => res.userContentLocale);
1532
1550
  };
1533
1551
 
1552
+ /**
1553
+ * Get the Staffbase instance URL / frontend domain.
1554
+ *
1555
+ * @return {Promise<string>}
1556
+ */
1557
+ const getInstanceUrl$1 = async () => {
1558
+ return sendMessage(commands.instanceUrl);
1559
+ };
1560
+
1534
1561
  /**
1535
1562
  * Compare [semver](https://semver.org/) version strings to find greater, equal or lesser.
1536
1563
  * 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`.
@@ -1744,6 +1771,13 @@
1744
1771
  */
1745
1772
  const getUserContentLocale = async () => getUserContentLocale$1();
1746
1773
 
1774
+ /**
1775
+ * Get the Staffbase instance URL / frontend domain.
1776
+ * @function
1777
+ * @return {Promise<string>}
1778
+ */
1779
+ const getInstanceUrl = async () => getInstanceUrl$1();
1780
+
1747
1781
  /**
1748
1782
  * Open a share dialog on native devices
1749
1783
  *
@@ -1767,6 +1801,7 @@
1767
1801
  exports.getBranchDefaultLanguage = getBranchDefaultLanguage;
1768
1802
  exports.getBranchLanguages = getBranchLanguages;
1769
1803
  exports.getContentLanguages = getContentLanguages;
1804
+ exports.getInstanceUrl = getInstanceUrl;
1770
1805
  exports.getPreferredContentLocale = getPreferredContentLocale;
1771
1806
  exports.getUserContentLocale = getUserContentLocale;
1772
1807
  exports.isAndroidDevice = isAndroidDevice;