@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
 
@@ -392,6 +392,7 @@ const commands = {
392
392
  version: 'app-version',
393
393
  mobile: 'app-mobile',
394
394
  native: 'app-native',
395
+ instanceUrl: 'instance-url',
395
396
  openLink: 'openExternalLink',
396
397
  nativeUpload: 'nativeFileUpload',
397
398
  nativeShare: 'nativeShareDialog',
@@ -1003,6 +1004,18 @@ const getUserContentLocale$2 = () => {
1003
1004
  return locale;
1004
1005
  };
1005
1006
 
1007
+ /**
1008
+ * Get the Staffbase instance URL / frontend domain.
1009
+ *
1010
+ * Uses ancestorOrigins when available (chrome/safari in iframe),
1011
+ * falls back to document.referrer or empty string.
1012
+ *
1013
+ * @return {String} the instance URL
1014
+ */
1015
+ const getInstanceUrl$2 = () => {
1016
+ return window.location.ancestorOrigins && window.location.ancestorOrigins[0] || document.referrer || '';
1017
+ };
1018
+
1006
1019
  let connection$1 = null;
1007
1020
  const fallbackKickIn = 500;
1008
1021
 
@@ -1059,6 +1072,8 @@ const sendMessage$2 = async function (cmd) {
1059
1072
  return getPreferredContentLocale$2.apply(null, payload);
1060
1073
  case commands.userContentLocale:
1061
1074
  return getUserContentLocale$2();
1075
+ case commands.instanceUrl:
1076
+ return getInstanceUrl$2();
1062
1077
  case commands.nativeUpload:
1063
1078
  case commands.nativeShare:
1064
1079
  return unSupported();
@@ -1195,7 +1210,8 @@ const get = id => {
1195
1210
  const dataStore = _ref => {
1196
1211
  let {
1197
1212
  platform,
1198
- language
1213
+ language,
1214
+ instance
1199
1215
  } = _ref;
1200
1216
  return {
1201
1217
  mobile: platform.mobile,
@@ -1204,7 +1220,8 @@ const dataStore = _ref => {
1204
1220
  ios: platform.native === 'ios',
1205
1221
  android: platform.native === 'android',
1206
1222
  langInfos: language,
1207
- branchDefaultLanguage: language.branchDefaultLanguage
1223
+ branchDefaultLanguage: language.branchDefaultLanguage,
1224
+ instanceUrl: instance && instance.url || ''
1208
1225
  };
1209
1226
  };
1210
1227
  let connection = null;
@@ -1313,6 +1330,7 @@ const sendMessage$1 = store => async function (cmd) {
1313
1330
  case commands.ios:
1314
1331
  case commands.android:
1315
1332
  case commands.branchDefaultLang:
1333
+ case commands.instanceUrl:
1316
1334
  return store[reversedCommands[cmd]];
1317
1335
  case commands.langInfos:
1318
1336
  case commands.openLink:
@@ -1525,6 +1543,15 @@ const getUserContentLocale$1 = async () => {
1525
1543
  return sendMessage(commands.langInfos).then(res => res.userContentLocale);
1526
1544
  };
1527
1545
 
1546
+ /**
1547
+ * Get the Staffbase instance URL / frontend domain.
1548
+ *
1549
+ * @return {Promise<string>}
1550
+ */
1551
+ const getInstanceUrl$1 = async () => {
1552
+ return sendMessage(commands.instanceUrl);
1553
+ };
1554
+
1528
1555
  /**
1529
1556
  * Compare [semver](https://semver.org/) version strings to find greater, equal or lesser.
1530
1557
  * 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`.
@@ -1738,6 +1765,13 @@ const getPreferredContentLocale = async content => getPreferredContentLocale$1(c
1738
1765
  */
1739
1766
  const getUserContentLocale = async () => getUserContentLocale$1();
1740
1767
 
1768
+ /**
1769
+ * Get the Staffbase instance URL / frontend domain.
1770
+ * @function
1771
+ * @return {Promise<string>}
1772
+ */
1773
+ const getInstanceUrl = async () => getInstanceUrl$1();
1774
+
1741
1775
  /**
1742
1776
  * Open a share dialog on native devices
1743
1777
  *
@@ -1756,5 +1790,5 @@ const getUserContentLocale = async () => getUserContentLocale$1();
1756
1790
  const openNativeShareDialog = async content => openNativeShareDialog$1(content);
1757
1791
  /* experimental */
1758
1792
 
1759
- export { deviceCanDownload, getAppVersion, getBranchDefaultLanguage, getBranchLanguages, getContentLanguages, getPreferredContentLocale, getUserContentLocale, isAndroidDevice, isIosDevice, isMobileApp, isNativeApp, openLink, openLinkExternal, openLinkInternal, openNativeFileDialog, openNativeShareDialog };
1793
+ export { deviceCanDownload, getAppVersion, getBranchDefaultLanguage, getBranchLanguages, getContentLanguages, getInstanceUrl, getPreferredContentLocale, getUserContentLocale, isAndroidDevice, isIosDevice, isMobileApp, isNativeApp, openLink, openLinkExternal, openLinkInternal, openNativeFileDialog, openNativeShareDialog };
1760
1794
  //# sourceMappingURL=plugins-client-sdk.esm.js.map