@zean-chat/js 0.1.2 → 0.1.3

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.
package/dist/index.js CHANGED
@@ -1,6 +1,14 @@
1
1
  // ../shared/src/constants/app.ts
2
2
  var APP_NAME = "Zean";
3
3
  var PRODUCTION_LOADER_URL = "https://widget.zean.chat/loader.js";
4
+ var STAGING_APP_KEY_PREFIX = "app_stg_";
5
+ var STAGING_LOADER_URL = "https://widget-stg.zean.chat/loader.js";
6
+
7
+ // ../shared/src/utils/app-keys.ts
8
+ var isStagingKey = (appKey) => appKey.startsWith(STAGING_APP_KEY_PREFIX);
9
+ function loaderUrlFor(appKey) {
10
+ return isStagingKey(appKey) ? STAGING_LOADER_URL : PRODUCTION_LOADER_URL;
11
+ }
4
12
 
5
13
  // src/load.ts
6
14
  var SCRIPT_ATTRIBUTE = "data-zean-sdk";
@@ -48,7 +56,7 @@ var zean = {
48
56
  signOut: () => withApi((api) => api.signOut()),
49
57
  setAttributes: (attributes) => withApi((api) => api.setAttributes(attributes))
50
58
  };
51
- function loadZean({ appKey, user, locale, loaderUrl = PRODUCTION_LOADER_URL }) {
59
+ function loadZean({ appKey, user, locale, loaderUrl = loaderUrlFor(appKey) }) {
52
60
  if (typeof window === "undefined" || typeof document === "undefined") return zean;
53
61
  if (loadedKey !== null) {
54
62
  if (loadedKey !== appKey) console.warn(`${APP_NAME}: the chat is already loaded with the App key ${loadedKey}.`);
@@ -39,6 +39,10 @@ export interface ZeanApi {
39
39
  setAttributes: (attributes: ZeanAttributes) => void;
40
40
  }
41
41
  export interface ZeanOptions extends ZeanSettings {
42
- /** Where the chat loads from. Leave it out: the default is Zean's own. */
42
+ /**
43
+ * Where the chat loads from. Leave it out: the App key says which of Zean's own. For local development only, so
44
+ * left out of the documentation.
45
+ * @internal
46
+ */
43
47
  loaderUrl?: string;
44
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zean-chat/js",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Live chat widget for any website: add a free customer support chat in one line. Vanilla JS, TypeScript, no framework needed. Intercom and Crisp alternative.",
5
5
  "keywords": [
6
6
  "javascript",