@elevenlabs/convai-widget-core 0.0.9 → 0.0.10

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.
@@ -1,6 +1,6 @@
1
1
  import { ReadonlySignal } from "@preact/signals";
2
2
  import { ComponentChildren } from "preact";
3
- export type Location = "us" | "global";
3
+ import { Location } from "../types/config";
4
4
  interface ServerLocationProviderProps {
5
5
  children: ComponentChildren;
6
6
  }
@@ -10,5 +10,4 @@ export declare function useServerLocation(): {
10
10
  serverUrl: ReadonlySignal<string>;
11
11
  webSocketUrl: ReadonlySignal<string>;
12
12
  };
13
- export declare function parseLocation(location?: string): Location;
14
13
  export {};
package/dist/index.js CHANGED
@@ -102,6 +102,18 @@ const lr = {
102
102
  }, na = Object.keys(
103
103
  cr
104
104
  );
105
+ function ra(e = "us") {
106
+ switch (e) {
107
+ case "eu-residency":
108
+ case "us":
109
+ case "global":
110
+ return e;
111
+ default:
112
+ return console.warn(
113
+ `[ConversationalAI] Invalid server-location: ${e}. Defaulting to "us"`
114
+ ), "us";
115
+ }
116
+ }
105
117
  function he(e) {
106
118
  const t = Xo(e);
107
119
  if (t == null)
@@ -111,7 +123,7 @@ function he(e) {
111
123
  return t;
112
124
  }
113
125
  const ur = pe(null);
114
- function ra({
126
+ function oa({
115
127
  value: e,
116
128
  children: t
117
129
  }) {
@@ -125,26 +137,30 @@ function ra({
125
137
  n[r].value = e[r];
126
138
  }), /* @__PURE__ */ h(ur.Provider, { value: n, children: t });
127
139
  }
128
- function oa() {
140
+ function aa() {
129
141
  return he(ur);
130
142
  }
131
143
  function H(e) {
132
- return oa()[e];
144
+ return aa()[e];
133
145
  }
134
146
  const dr = pe(null);
135
- function aa({
147
+ function ia({
136
148
  children: e
137
149
  }) {
138
150
  const t = H("server-location"), n = Re(() => {
139
- const r = xe(() => ia(t.value));
151
+ const r = xe(() => ra(t.value)), o = {
152
+ us: "https://api.us.elevenlabs.io",
153
+ "eu-residency": "https://api.eu.residency.elevenlabs.io",
154
+ global: "https://api.elevenlabs.io"
155
+ }, a = {
156
+ us: "wss://api.us.elevenlabs.io",
157
+ "eu-residency": "wss://api.eu.residency.elevenlabs.io",
158
+ global: "wss://api.elevenlabs.io"
159
+ };
140
160
  return {
141
161
  location: r,
142
- serverUrl: xe(
143
- () => r.value === "us" ? "https://api.us.elevenlabs.io" : "https://api.elevenlabs.io"
144
- ),
145
- webSocketUrl: xe(
146
- () => r.value === "us" ? "wss://api.us.elevenlabs.io" : "wss://api.elevenlabs.io"
147
- )
162
+ serverUrl: xe(() => o[r.value]),
163
+ webSocketUrl: xe(() => a[r.value])
148
164
  };
149
165
  }, []);
150
166
  return /* @__PURE__ */ h(dr.Provider, { value: n, children: e });
@@ -152,17 +168,6 @@ function aa({
152
168
  function fr() {
153
169
  return he(dr);
154
170
  }
155
- function ia(e = "us") {
156
- switch (e) {
157
- case "us":
158
- case "global":
159
- return e;
160
- default:
161
- return console.warn(
162
- `[ConversationalAI] Invalid server-location: ${e}. Defaulting to "us"`
163
- ), "us";
164
- }
165
- }
166
171
  const pt = {
167
172
  en: { name: "English", flagCode: "us", languageCode: "en" },
168
173
  zh: { name: "中文", flagCode: "cn", languageCode: "zh" },
@@ -5541,7 +5546,7 @@ const Ze = {
5541
5546
  ] });
5542
5547
  });
5543
5548
  function Ec(e) {
5544
- return /* @__PURE__ */ h(ra, { value: e, children: /* @__PURE__ */ h(aa, { children: /* @__PURE__ */ h(va, { children: /* @__PURE__ */ h(da, { children: /* @__PURE__ */ h(sa, { children: /* @__PURE__ */ h(la, { children: /* @__PURE__ */ h(ca, { children: /* @__PURE__ */ h(fa, { children: /* @__PURE__ */ h(xa, { children: /* @__PURE__ */ P(ya, { children: [
5549
+ return /* @__PURE__ */ h(oa, { value: e, children: /* @__PURE__ */ h(ia, { children: /* @__PURE__ */ h(va, { children: /* @__PURE__ */ h(da, { children: /* @__PURE__ */ h(sa, { children: /* @__PURE__ */ h(la, { children: /* @__PURE__ */ h(ca, { children: /* @__PURE__ */ h(fa, { children: /* @__PURE__ */ h(xa, { children: /* @__PURE__ */ P(ya, { children: [
5545
5550
  /* @__PURE__ */ h(ma, {}),
5546
5551
  /* @__PURE__ */ h(Sc, {})
5547
5552
  ] }) }) }) }) }) }) }) }) }) });
@@ -94,3 +94,5 @@ export declare const DefaultStyles: {
94
94
  };
95
95
  export declare const StyleKeys: (keyof typeof DefaultStyles)[];
96
96
  export type Styles = typeof DefaultStyles;
97
+ export declare function parseLocation(location?: string): Location;
98
+ export type Location = "us" | "global" | "eu-residency";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elevenlabs/convai-widget-core",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "The common library for the Conversational AI Widget.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "clsx": "^2.1.1",
32
32
  "preact": "^10.26.5",
33
33
  "preact-custom-element": "^4.3.0",
34
- "@elevenlabs/client": "0.1.6"
34
+ "@elevenlabs/client": "0.1.7"
35
35
  },
36
36
  "repository": {
37
37
  "type": "git",