@staffbase/plugins-client-sdk 3.0.2 → 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
 
@@ -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',
@@ -498,6 +499,12 @@ var locales = {
498
499
  name: 'English',
499
500
  localizedName: 'English'
500
501
  },
502
+ enGB: {
503
+ key: 'enGB',
504
+ locale: 'en_GB',
505
+ name: 'English (United Kingdom)',
506
+ localizedName: 'English (United Kingdom)'
507
+ },
501
508
  es: {
502
509
  key: 'es',
503
510
  locale: 'es_ES',
@@ -999,6 +1006,18 @@ const getUserContentLocale$2 = () => {
999
1006
  return locale;
1000
1007
  };
1001
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
+
1002
1021
  let connection$1 = null;
1003
1022
  const fallbackKickIn = 500;
1004
1023
 
@@ -1055,6 +1074,8 @@ const sendMessage$2 = async function (cmd) {
1055
1074
  return getPreferredContentLocale$2.apply(null, payload);
1056
1075
  case commands.userContentLocale:
1057
1076
  return getUserContentLocale$2();
1077
+ case commands.instanceUrl:
1078
+ return getInstanceUrl$2();
1058
1079
  case commands.nativeUpload:
1059
1080
  case commands.nativeShare:
1060
1081
  return unSupported();
@@ -1191,7 +1212,8 @@ const get = id => {
1191
1212
  const dataStore = _ref => {
1192
1213
  let {
1193
1214
  platform,
1194
- language
1215
+ language,
1216
+ instance
1195
1217
  } = _ref;
1196
1218
  return {
1197
1219
  mobile: platform.mobile,
@@ -1200,7 +1222,8 @@ const dataStore = _ref => {
1200
1222
  ios: platform.native === 'ios',
1201
1223
  android: platform.native === 'android',
1202
1224
  langInfos: language,
1203
- branchDefaultLanguage: language.branchDefaultLanguage
1225
+ branchDefaultLanguage: language.branchDefaultLanguage,
1226
+ instanceUrl: instance && instance.url || ''
1204
1227
  };
1205
1228
  };
1206
1229
  let connection = null;
@@ -1309,6 +1332,7 @@ const sendMessage$1 = store => async function (cmd) {
1309
1332
  case commands.ios:
1310
1333
  case commands.android:
1311
1334
  case commands.branchDefaultLang:
1335
+ case commands.instanceUrl:
1312
1336
  return store[reversedCommands[cmd]];
1313
1337
  case commands.langInfos:
1314
1338
  case commands.openLink:
@@ -1521,6 +1545,15 @@ const getUserContentLocale$1 = async () => {
1521
1545
  return sendMessage(commands.langInfos).then(res => res.userContentLocale);
1522
1546
  };
1523
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
+
1524
1557
  /**
1525
1558
  * Compare [semver](https://semver.org/) version strings to find greater, equal or lesser.
1526
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`.
@@ -1734,6 +1767,13 @@ const getPreferredContentLocale = async content => getPreferredContentLocale$1(c
1734
1767
  */
1735
1768
  const getUserContentLocale = async () => getUserContentLocale$1();
1736
1769
 
1770
+ /**
1771
+ * Get the Staffbase instance URL / frontend domain.
1772
+ * @function
1773
+ * @return {Promise<string>}
1774
+ */
1775
+ const getInstanceUrl = async () => getInstanceUrl$1();
1776
+
1737
1777
  /**
1738
1778
  * Open a share dialog on native devices
1739
1779
  *
@@ -1757,6 +1797,7 @@ exports.getAppVersion = getAppVersion;
1757
1797
  exports.getBranchDefaultLanguage = getBranchDefaultLanguage;
1758
1798
  exports.getBranchLanguages = getBranchLanguages;
1759
1799
  exports.getContentLanguages = getContentLanguages;
1800
+ exports.getInstanceUrl = getInstanceUrl;
1760
1801
  exports.getPreferredContentLocale = getPreferredContentLocale;
1761
1802
  exports.getUserContentLocale = getUserContentLocale;
1762
1803
  exports.isAndroidDevice = isAndroidDevice;