@staffbase/plugins-client-sdk 3.0.3 → 3.1.1

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
 
@@ -394,6 +394,7 @@ const commands = {
394
394
  version: 'app-version',
395
395
  mobile: 'app-mobile',
396
396
  native: 'app-native',
397
+ instanceUrl: 'instance-url',
397
398
  openLink: 'openExternalLink',
398
399
  nativeUpload: 'nativeFileUpload',
399
400
  nativeShare: 'nativeShareDialog',
@@ -1005,6 +1006,18 @@ const getUserContentLocale$2 = () => {
1005
1006
  return locale;
1006
1007
  };
1007
1008
 
1009
+ /**
1010
+ * Get the Staffbase instance URL / frontend domain.
1011
+ *
1012
+ * Uses ancestorOrigins when available (chrome/safari in iframe),
1013
+ * falls back to document.referrer or empty string.
1014
+ *
1015
+ * @return {String} the instance URL
1016
+ */
1017
+ const getInstanceUrl$2 = () => {
1018
+ return window.location.ancestorOrigins && window.location.ancestorOrigins[0] || document.referrer || '';
1019
+ };
1020
+
1008
1021
  let connection$1 = null;
1009
1022
  const fallbackKickIn = 500;
1010
1023
 
@@ -1061,6 +1074,8 @@ const sendMessage$2 = async function (cmd) {
1061
1074
  return getPreferredContentLocale$2.apply(null, payload);
1062
1075
  case commands.userContentLocale:
1063
1076
  return getUserContentLocale$2();
1077
+ case commands.instanceUrl:
1078
+ return getInstanceUrl$2();
1064
1079
  case commands.nativeUpload:
1065
1080
  case commands.nativeShare:
1066
1081
  return unSupported();
@@ -1197,7 +1212,8 @@ const get = id => {
1197
1212
  const dataStore = _ref => {
1198
1213
  let {
1199
1214
  platform,
1200
- language
1215
+ language,
1216
+ instance
1201
1217
  } = _ref;
1202
1218
  return {
1203
1219
  mobile: platform.mobile,
@@ -1206,7 +1222,8 @@ const dataStore = _ref => {
1206
1222
  ios: platform.native === 'ios',
1207
1223
  android: platform.native === 'android',
1208
1224
  langInfos: language,
1209
- branchDefaultLanguage: language.branchDefaultLanguage
1225
+ branchDefaultLanguage: language.branchDefaultLanguage,
1226
+ instanceUrl: instance && instance.url || ''
1210
1227
  };
1211
1228
  };
1212
1229
  let connection = null;
@@ -1315,6 +1332,7 @@ const sendMessage$1 = store => async function (cmd) {
1315
1332
  case commands.ios:
1316
1333
  case commands.android:
1317
1334
  case commands.branchDefaultLang:
1335
+ case commands.instanceUrl:
1318
1336
  return store[reversedCommands[cmd]];
1319
1337
  case commands.langInfos:
1320
1338
  case commands.openLink:
@@ -1527,6 +1545,15 @@ const getUserContentLocale$1 = async () => {
1527
1545
  return sendMessage(commands.langInfos).then(res => res.userContentLocale);
1528
1546
  };
1529
1547
 
1548
+ /**
1549
+ * Get the Staffbase instance URL / frontend domain.
1550
+ *
1551
+ * @return {Promise<string>}
1552
+ */
1553
+ const getInstanceUrl$1 = async () => {
1554
+ return sendMessage(commands.instanceUrl);
1555
+ };
1556
+
1530
1557
  /**
1531
1558
  * Compare [semver](https://semver.org/) version strings to find greater, equal or lesser.
1532
1559
  * 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`.
@@ -1740,6 +1767,13 @@ const getPreferredContentLocale = async content => getPreferredContentLocale$1(c
1740
1767
  */
1741
1768
  const getUserContentLocale = async () => getUserContentLocale$1();
1742
1769
 
1770
+ /**
1771
+ * Get the Staffbase instance URL / frontend domain.
1772
+ * @function
1773
+ * @return {Promise<string>}
1774
+ */
1775
+ const getInstanceUrl = async () => getInstanceUrl$1();
1776
+
1743
1777
  /**
1744
1778
  * Open a share dialog on native devices
1745
1779
  *
@@ -1763,6 +1797,7 @@ exports.getAppVersion = getAppVersion;
1763
1797
  exports.getBranchDefaultLanguage = getBranchDefaultLanguage;
1764
1798
  exports.getBranchLanguages = getBranchLanguages;
1765
1799
  exports.getContentLanguages = getContentLanguages;
1800
+ exports.getInstanceUrl = getInstanceUrl;
1766
1801
  exports.getPreferredContentLocale = getPreferredContentLocale;
1767
1802
  exports.getUserContentLocale = getUserContentLocale;
1768
1803
  exports.isAndroidDevice = isAndroidDevice;