@aippy/runtime 0.2.7-dev.5 → 0.2.7-dev.6

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/ai/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { A, D as r, d as n, e as C, c as e, U as E, a as I, b as _, f, g, l as T, n as p, p as t, s as U, v as D } from "../helper-BENVYOU-.js";
1
+ import { A, D as r, d as n, e as C, c as e, U as E, a as I, b as _, f, g, l as T, n as p, p as t, s as U, v as D } from "../helper-yKJ_6uB-.js";
2
2
  import "react";
3
- import "../bridge-Ca3H2iN1.js";
3
+ import "../bridge-BKcAlLAd.js";
4
4
  export {
5
5
  A as AIConfigValidationError,
6
6
  r as DEFAULT_BASE_URL,
@@ -2,10 +2,6 @@
2
2
  * Shared fetch utilities for Aippy AI SDK.
3
3
  * Used by both OpenAI-compatible (Core) and Data Stream Protocol (UI) paths.
4
4
  */
5
- /**
6
- * Joins a base URL with a path segment.
7
- */
8
- export declare function joinUrl(baseUrl: string, path: string): string;
9
5
  /**
10
6
  * Creates a fetch wrapper that injects Authorization header and handles error responses.
11
7
  * Error responses are intercepted and normalized errors are thrown immediately.
@@ -3,4 +3,4 @@
3
3
  * Re-exports config and fetch utilities used by both protocol paths.
4
4
  */
5
5
  export { DEFAULT_BASE_URL, DEFAULT_UI_BASE_URL, DEFAULT_CHAT_MODEL, DEFAULT_CHAT_SYSTEM, resolveOpenAIConfig, resolveUIConfig, type AippyOpenAIConfig, type AippyUIConfig, type AippyChatConfig, } from './config';
6
- export { joinUrl, createAuthFetch } from './fetch';
6
+ export { createAuthFetch } from './fetch';
@@ -1,40 +1,40 @@
1
- var d = Object.defineProperty;
2
- var l = (o, e, n) => e in o ? d(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
3
- var c = (o, e, n) => l(o, typeof e != "symbol" ? e + "" : e, n);
4
- import { UAParser as u } from "ua-parser-js";
5
- import { hasNativeBridge as p } from "./native-bridge-BnvipFJc.js";
6
- function m() {
1
+ var u = Object.defineProperty;
2
+ var l = (t, e, n) => e in t ? u(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var c = (t, e, n) => l(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { UAParser as m } from "ua-parser-js";
5
+ import { hasNativeBridge as f } from "./native-bridge-BnvipFJc.js";
6
+ function w() {
7
7
  try {
8
8
  return typeof window < "u" && window.parent !== window;
9
9
  } catch {
10
10
  return !0;
11
11
  }
12
12
  }
13
- function f(o, e) {
14
- const n = o.split(".").map(Number), r = e.split(".").map(Number), t = Math.max(n.length, r.length);
15
- for (let i = 0; i < t; i++) {
13
+ function h(t, e) {
14
+ const n = t.split(".").map(Number), r = e.split(".").map(Number), o = Math.max(n.length, r.length);
15
+ for (let i = 0; i < o; i++) {
16
16
  const s = n[i] || 0, a = r[i] || 0;
17
17
  if (s < a) return -1;
18
18
  if (s > a) return 1;
19
19
  }
20
20
  return 0;
21
21
  }
22
- class w {
22
+ class g {
23
23
  constructor() {
24
24
  c(this, "parser");
25
- this.parser = new u();
25
+ this.parser = new m();
26
26
  }
27
27
  /**
28
28
  * Get platform information
29
29
  */
30
30
  getPlatformInfo() {
31
- const e = this.parser.getResult(), n = this.normalizePlatformName(e.os.name), r = this.normalizeBrowserName(e.browser.name), t = this.isMobileDevice(), i = !t;
31
+ const e = this.parser.getResult(), n = this.normalizePlatformName(e.os.name), r = this.normalizeBrowserName(e.browser.name), o = this.isMobileDevice(), i = !o;
32
32
  return {
33
33
  name: n,
34
34
  version: e.os.version,
35
35
  browser: r,
36
36
  browserVersion: e.browser.version,
37
- isMobile: t,
37
+ isMobile: o,
38
38
  isDesktop: i
39
39
  };
40
40
  }
@@ -104,15 +104,15 @@ class w {
104
104
  checkAppEnvironment(e) {
105
105
  const n = this.parseAippyInfo();
106
106
  if (n) {
107
- const r = e[n.platform], t = f(n.version, r) >= 0;
107
+ const r = e[n.platform], o = h(n.version, r) >= 0;
108
108
  return {
109
109
  type: "new_app",
110
- isValid: t,
110
+ isValid: o,
111
111
  aippyInfo: n,
112
- message: t ? void 0 : `App version ${n.version} < ${r}`
112
+ message: o ? void 0 : `App version ${n.version} < ${r}`
113
113
  };
114
114
  }
115
- return p() ? {
115
+ return f() ? {
116
116
  type: "old_ios_app",
117
117
  isValid: !1,
118
118
  message: "Native bridge exists but no Aippy info (old iOS version)"
@@ -120,7 +120,7 @@ class w {
120
120
  type: "old_android_app",
121
121
  isValid: !1,
122
122
  message: "Android WebView detected but no Aippy info (old Android version)"
123
- } : m() ? { type: "iframe", isValid: !0 } : { type: "web", isValid: !0 };
123
+ } : w() ? { type: "iframe", isValid: !0 } : { type: "web", isValid: !0 };
124
124
  }
125
125
  /**
126
126
  * Parse Aippy App info from User-Agent
@@ -128,10 +128,10 @@ class w {
128
128
  parseAippyInfo() {
129
129
  const e = navigator.userAgent, n = /Aippy\/([^/]+)\/[^/]+\/(iOS|Android)/i, r = e.match(n);
130
130
  if (r) {
131
- const t = r[1];
131
+ const o = r[1];
132
132
  return {
133
133
  platform: r[2],
134
- version: t
134
+ version: o
135
135
  };
136
136
  }
137
137
  return null;
@@ -155,21 +155,76 @@ class w {
155
155
  }
156
156
  }
157
157
  }
158
- const x = new w();
159
- function v(o) {
158
+ const b = new g(), p = "https://cdn.aippy.ai/asset/fd292077086044ee9565bd36ac3a8b78.svg";
159
+ async function v(t) {
160
160
  const e = document.createElement("div");
161
- e.style.cssText = "position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);display:flex;align-items:center;justify-content:center;z-index:999999";
161
+ e.style.cssText = "position:fixed;top:0;left:0;right:0;bottom:12px;display:flex;align-items:flex-end;justify-content:center;z-index:999999;pointer-events:none";
162
162
  const n = document.createElement("div");
163
- n.style.cssText = "background:#fff;border-radius:12px;padding:24px 32px;max-width:80%;text-align:center;box-shadow:0 4px 20px rgba(0,0,0,0.15)";
164
- const r = document.createElement("p");
165
- r.style.cssText = "margin:0 0 20px;font-size:16px;color:#333;line-height:1.5", r.textContent = o;
166
- const t = document.createElement("button");
167
- t.style.cssText = "background:#007AFF;color:#fff;border:none;border-radius:8px;padding:10px 32px;font-size:15px;cursor:pointer", t.textContent = "OK", t.onclick = () => e.remove(), n.appendChild(r), n.appendChild(t), e.appendChild(n), document.body.appendChild(e);
163
+ n.style.cssText = "background:#323232;border-radius:32px;padding:12px 30px 12px 24px;max-width:85%;display:flex;align-items:center;gap:12px;pointer-events:auto";
164
+ let r = !1;
165
+ try {
166
+ r = (await fetch(p, { method: "HEAD" })).ok;
167
+ } catch {
168
+ r = !1;
169
+ }
170
+ if (r) {
171
+ const i = document.createElement("img");
172
+ i.src = p, i.style.cssText = "width:36px;height:36px;flex-shrink:0", n.appendChild(i);
173
+ }
174
+ const o = document.createElement("span");
175
+ o.style.cssText = "font-size:16px;color:#fff;line-height:1.4;white-space:pre-line", o.textContent = t, n.appendChild(o), e.appendChild(n), document.body.appendChild(e);
176
+ }
177
+ const x = { iOS: "1.6.7", Android: "1.1.8" }, y = { iOS: "1.6.7", Android: "1.1.8" }, d = {
178
+ userCredentials: x,
179
+ userInfo: y
180
+ };
181
+ function A(t) {
182
+ const e = d[t];
183
+ return e || (console.warn(`[AppVersionChecker] Unknown feature: ${t}`), { iOS: "999.0.0", Android: "999.0.0" });
184
+ }
185
+ function C(t) {
186
+ const e = A(t), n = b.checkAppEnvironment(e), r = n.aippyInfo?.version, o = n.aippyInfo ? e[n.aippyInfo.platform] : void 0;
187
+ switch (n.type) {
188
+ case "new_app":
189
+ return {
190
+ supported: n.isValid,
191
+ envCheck: n,
192
+ currentVersion: r,
193
+ requiredVersion: o,
194
+ message: n.isValid ? void 0 : `App version ${r} does not support ${t}. Minimum required: ${o}`
195
+ };
196
+ case "old_ios_app":
197
+ case "old_android_app":
198
+ return {
199
+ supported: !1,
200
+ envCheck: n,
201
+ message: `Old app version detected. Please upgrade to use ${t}.`
202
+ };
203
+ default:
204
+ return {
205
+ supported: !0,
206
+ envCheck: n
207
+ };
208
+ }
209
+ }
210
+ function _(t) {
211
+ const e = C(t);
212
+ if (!e.supported && (e.envCheck.type === "new_app" || e.envCheck.type === "old_ios_app" || e.envCheck.type === "old_android_app"))
213
+ throw console.warn(`[AppVersionChecker] ${e.message}`), v(`This project needs a newer version.
214
+ Update to view it.`), new Error(`App version too old: ${e.message}`);
215
+ return e;
216
+ }
217
+ function I() {
218
+ return Object.keys(d);
168
219
  }
169
220
  export {
170
- w as P,
171
- f as c,
172
- m as i,
173
- x as p,
221
+ g as P,
222
+ C as a,
223
+ I as b,
224
+ h as c,
225
+ A as g,
226
+ w as i,
227
+ b as p,
228
+ _ as r,
174
229
  v as s
175
230
  };
@@ -0,0 +1,237 @@
1
+ import { a as y } from "./runtime-CmoG3v2m.js";
2
+ import { r as h, s as b, i as p } from "./app-version-checker-GLONqMxq.js";
3
+ const f = {
4
+ apiBaseUrl: "https://api.aippy.dev/api",
5
+ authToken: "",
6
+ currentUserId: null
7
+ };
8
+ function L(n) {
9
+ Object.assign(f, n);
10
+ }
11
+ function C(n) {
12
+ f.authToken = n;
13
+ }
14
+ function q(n) {
15
+ f.currentUserId = n;
16
+ }
17
+ const U = 3e3, v = 50, g = 500, c = { uid: "", token: "" };
18
+ let a = null, u = !1, l = null, t = null;
19
+ function w(n) {
20
+ if (!n || typeof n != "object") return null;
21
+ let e = n;
22
+ if (e.credentials && typeof e.credentials == "object" && (e = e.credentials), e.user && typeof e.user == "object" && e.token) {
23
+ const d = e.user;
24
+ e = { uid: d.uid || d.userId || d.id, token: e.token, apiBaseUrl: e.apiBaseUrl };
25
+ }
26
+ const r = e.uid || e.userId || e.id || "", o = e.token || e.authToken || "", s = e.apiBaseUrl;
27
+ if (!r || !o) return null;
28
+ const i = { uid: String(r), token: o, apiBaseUrl: s };
29
+ return q(i.uid), C(o), s && L({ apiBaseUrl: s }), i;
30
+ }
31
+ function m(n) {
32
+ if (console.log("🔄 [Bridge] processUserInfoData called with:", n), !n || typeof n != "object")
33
+ return console.warn("⚠️ [Bridge] Invalid data (null or not object):", n), null;
34
+ let e = n;
35
+ console.log("🔄 [Bridge] Initial obj keys:", Object.keys(e)), e.userInfo && typeof e.userInfo == "object" && (console.log("🔄 [Bridge] Unwrapping nested userInfo"), e = e.userInfo), e.user && typeof e.user == "object" && (console.log("🔄 [Bridge] Unwrapping nested user"), e = e.user), console.log("🔄 [Bridge] After unwrapping, obj:", e);
36
+ const r = e.uid || e.userId || e.id || "";
37
+ if (!r)
38
+ return console.warn("⚠️ [Bridge] No uid found in data"), null;
39
+ const o = { uid: String(r), ...e };
40
+ return console.log("✅ [Bridge] Created userInfo:", o), a = o, u = !0, console.log("✅ [Bridge] Cached userInfo, userInfoReceived = true"), o;
41
+ }
42
+ function A(n = g) {
43
+ return console.log("📱 [Bridge] requestCredentialsFromiOS called, timeout:", n), l ? (console.log("⏳ [Bridge] Pending credentials request exists, waiting..."), new Promise((e) => {
44
+ const r = l.resolve;
45
+ l.resolve = (o) => {
46
+ r(o), e(o);
47
+ };
48
+ })) : new Promise((e) => {
49
+ (async () => {
50
+ let r = window.webkit?.messageHandlers?.aippyListener;
51
+ if (console.log("📱 [Bridge] Checking aippyListener for credentials:", {
52
+ hasWebkit: !!window.webkit,
53
+ hasMessageHandlers: !!window.webkit?.messageHandlers,
54
+ hasAippyListener: !!r
55
+ }), r || (console.log("⏳ [Bridge] aippyListener not found, waiting for injection..."), r = await k(1500)), !r) {
56
+ console.warn("⚠️ [Bridge] No aippyListener found after waiting, returning empty credentials"), e(c);
57
+ return;
58
+ }
59
+ const o = setTimeout(() => {
60
+ console.warn("⏰ [Bridge] Credentials request TIMEOUT after", n, "ms"), l = null, e(c);
61
+ }, n);
62
+ l = {
63
+ resolve: (s) => {
64
+ console.log("✅ [Bridge] pendingCredentialsRequest.resolve called with:", s), clearTimeout(o), l = null, e(s);
65
+ }
66
+ }, console.log("📱 [Bridge] pendingCredentialsRequest set"), y.receiveChannel.once("user.credentials", (s) => {
67
+ console.log("📩 [Bridge] Received user.credentials via receiveChannel:", s), clearTimeout(o);
68
+ const i = w(s) || c;
69
+ l && l.resolve(i);
70
+ });
71
+ try {
72
+ const s = {
73
+ command: "user.getCredentials",
74
+ parameters: JSON.stringify({ timestamp: Date.now(), endpoint: "user.credentials" })
75
+ };
76
+ console.log("📤 [Bridge] Sending credentials request:", s), r.postMessage(s), console.log("📤 [Bridge] Credentials postMessage sent successfully");
77
+ } catch (s) {
78
+ console.error("❌ [Bridge] Failed to send credentials postMessage:", s), clearTimeout(o), l = null, e(c);
79
+ }
80
+ })();
81
+ });
82
+ }
83
+ function E(n = g) {
84
+ return new Promise((e) => {
85
+ if (!p()) {
86
+ e(c);
87
+ return;
88
+ }
89
+ const r = setTimeout(() => {
90
+ window.removeEventListener("message", o), e(c);
91
+ }, n), o = (s) => {
92
+ s.data?.type === "user-credentials-response" && (clearTimeout(r), window.removeEventListener("message", o), e(w(s.data) || c));
93
+ };
94
+ window.addEventListener("message", o);
95
+ try {
96
+ window.parent.postMessage({ type: "user-credentials-request", timestamp: Date.now() }, "*");
97
+ } catch {
98
+ clearTimeout(r), window.removeEventListener("message", o), e(c);
99
+ }
100
+ });
101
+ }
102
+ const R = () => /Aippy\/[\d.]+\/\d+\/Android/i.test(navigator.userAgent);
103
+ async function k(n = 1500) {
104
+ if (!R())
105
+ return console.log("📱 [Bridge] Not Android, skipping waitForAippyListener"), window.webkit?.messageHandlers?.aippyListener || null;
106
+ const e = Date.now(), r = 50;
107
+ for (console.log("🤖 [Bridge] Android: Waiting for aippyListener (max", n, "ms)..."); Date.now() - e < n; ) {
108
+ const o = window.webkit?.messageHandlers?.aippyListener;
109
+ if (o)
110
+ return console.log("✅ [Bridge] aippyListener became available after", Date.now() - e, "ms"), o;
111
+ await new Promise((s) => setTimeout(s, r));
112
+ }
113
+ return console.warn("⏰ [Bridge] aippyListener not available after", n, "ms"), null;
114
+ }
115
+ function S(n = !1, e = g) {
116
+ return console.log("📱 [Bridge] requestUserInfoFromiOS called:", { forceRefresh: n, timeoutMs: e }), console.log("📱 [Bridge] Cache state:", { userInfoReceived: u, cachedUserInfo: a ? "(cached)" : null }), u && a && !n ? (console.log("✅ [Bridge] Returning cached userInfo from requestUserInfoFromiOS"), Promise.resolve(a)) : t ? (console.log("⏳ [Bridge] Pending userInfo request exists, waiting..."), new Promise((r) => {
117
+ const o = t.resolve;
118
+ t.resolve = (s) => {
119
+ console.log("⏳ [Bridge] Pending request resolved:", s), o(s), r(s);
120
+ };
121
+ })) : new Promise((r) => {
122
+ (async () => {
123
+ let o = window.webkit?.messageHandlers?.aippyListener;
124
+ if (console.log("📱 [Bridge] Checking aippyListener:", {
125
+ hasWebkit: !!window.webkit,
126
+ hasMessageHandlers: !!window.webkit?.messageHandlers,
127
+ hasAippyListener: !!o
128
+ }), o || (console.log("⏳ [Bridge] aippyListener not found, waiting for injection..."), o = await k(1500)), !o) {
129
+ console.warn("⚠️ [Bridge] No aippyListener found after waiting, returning null"), r(null);
130
+ return;
131
+ }
132
+ console.log("📱 [Bridge] Setting up timeout:", e, "ms");
133
+ const s = setTimeout(() => {
134
+ console.warn("⏰ [Bridge] UserInfo request TIMEOUT after", e, "ms"), t = null, r(null);
135
+ }, e);
136
+ t = { resolve: (i) => {
137
+ console.log("✅ [Bridge] pendingUserInfoRequest.resolve called with:", i), clearTimeout(s), t = null, r(i);
138
+ } }, console.log("📱 [Bridge] pendingUserInfoRequest set"), y.receiveChannel.once("user.info", (i) => {
139
+ console.log("📩 [Bridge] Received user.info via receiveChannel:", i), clearTimeout(s);
140
+ const d = m(i);
141
+ console.log("📩 [Bridge] Processed userInfo:", d), t ? t.resolve(d) : console.warn("⚠️ [Bridge] No pendingUserInfoRequest when receiveChannel fired");
142
+ }), console.log("📱 [Bridge] receiveChannel.once registered for user.info");
143
+ try {
144
+ const i = {
145
+ command: "user.getUserInfo",
146
+ parameters: JSON.stringify({ timestamp: Date.now(), endpoint: "user.info" })
147
+ };
148
+ console.log("📤 [Bridge] Sending to aippyListener:", i), o.postMessage(i), console.log("📤 [Bridge] postMessage sent successfully");
149
+ } catch (i) {
150
+ console.error("❌ [Bridge] Failed to send postMessage:", i), clearTimeout(s), t = null, r(null);
151
+ }
152
+ })();
153
+ });
154
+ }
155
+ function T(n = g) {
156
+ return new Promise((e) => {
157
+ if (!p()) {
158
+ e(null);
159
+ return;
160
+ }
161
+ const r = setTimeout(() => {
162
+ window.removeEventListener("message", o), e(null);
163
+ }, n), o = (s) => {
164
+ s.data?.type === "user-info-response" && (clearTimeout(r), window.removeEventListener("message", o), e(m(s.data)));
165
+ };
166
+ window.addEventListener("message", o);
167
+ try {
168
+ window.parent.postMessage({ type: "user-info-request", timestamp: Date.now() }, "*");
169
+ } catch {
170
+ clearTimeout(r), window.removeEventListener("message", o), e(null);
171
+ }
172
+ });
173
+ }
174
+ async function P() {
175
+ const { envCheck: n } = h("userCredentials");
176
+ switch (n.type) {
177
+ case "new_app": {
178
+ const e = await A(U);
179
+ if (!e?.token) throw new Error("Token unavailable in app");
180
+ return e.token;
181
+ }
182
+ case "iframe": {
183
+ const e = await E(v);
184
+ if (e?.token) return e.token;
185
+ throw b(`Sign in to continue.
186
+ Open this project in the app.`), new Error("Token unavailable: User needs to login");
187
+ }
188
+ default:
189
+ return "";
190
+ }
191
+ }
192
+ async function F(n = !1) {
193
+ if (console.log("🔍 [Bridge] getUserInfoAsync called, forceRefresh:", n), console.log("🔍 [Bridge] Current cache state:", { userInfoReceived: u, cachedUserInfo: a }), u && a && !n)
194
+ return console.log("✅ [Bridge] Returning cached userInfo"), a;
195
+ const { envCheck: e } = h("userInfo");
196
+ switch (console.log("🔍 [Bridge] Environment check result:", e), e.type) {
197
+ case "new_app":
198
+ return console.log("📱 [Bridge] Detected new_app environment"), await S(n, U);
199
+ case "iframe":
200
+ return console.log("🖼️ [Bridge] Detected iframe environment"), await T(v);
201
+ default:
202
+ return console.log("🌐 [Bridge] Detected web environment, returning cached:", a), a;
203
+ }
204
+ }
205
+ async function M(n = g) {
206
+ return p() ? await T(n) : null;
207
+ }
208
+ function B(n) {
209
+ const e = w(n);
210
+ e && l && (l.resolve(e), l = null);
211
+ }
212
+ function I(n) {
213
+ console.log("📩 [Bridge] window.processUserInfo called with:", n), console.log("📩 [Bridge] pendingUserInfoRequest exists:", !!t);
214
+ const e = m(n);
215
+ t ? (console.log("✅ [Bridge] Resolving pendingUserInfoRequest with:", e), t.resolve(e), t = null) : (console.warn("⚠️ [Bridge] No pendingUserInfoRequest when processUserInfo called!"), console.warn("⚠️ [Bridge] UserInfo was processed but no one is waiting for it"));
216
+ }
217
+ function j() {
218
+ if (typeof window > "u") {
219
+ console.log("🔧 [Bridge] initUserBridge: window is undefined, skipping");
220
+ return;
221
+ }
222
+ console.log("🔧 [Bridge] initUserBridge: Initializing..."), console.log("🔧 [Bridge] UserAgent:", navigator.userAgent), window.processUserCredentials = B, window.processUserInfo = I, console.log("🔧 [Bridge] Exposed window.processUserCredentials and window.processUserInfo"), window.addEventListener("message", (n) => {
223
+ n.data?.type === "user-credentials" && (console.log("📩 [Bridge] Received postMessage user-credentials:", n.data), B(n.data)), n.data?.type === "user-info" && (console.log("📩 [Bridge] Received postMessage user-info:", n.data), I(n.data));
224
+ }), console.log("🔧 [Bridge] Added message event listener"), console.log("✅ [Bridge] initUserBridge complete");
225
+ }
226
+ j();
227
+ P().catch((n) => {
228
+ console.warn("[UserSDK] Auth check on load:", n.message);
229
+ });
230
+ export {
231
+ P as getAuthTokenAsync,
232
+ F as getUserInfoAsync,
233
+ M as getUserInfoFromParent,
234
+ p as isInIframe,
235
+ B as processUserCredentials,
236
+ I as processUserInfo
237
+ };
@@ -0,0 +1,28 @@
1
+ const n = {
2
+ mode: "development",
3
+ debug: !1,
4
+ apiBaseUrl: void 0,
5
+ headers: {}
6
+ };
7
+ function o() {
8
+ const e = {};
9
+ return typeof process < "u" && process.env && (process.env.NODE_ENV && (e.mode = process.env.NODE_ENV), process.env.AIPPY_DEBUG && (e.debug = process.env.AIPPY_DEBUG === "true"), process.env.AIPPY_API_BASE_URL && (e.apiBaseUrl = process.env.AIPPY_API_BASE_URL)), e;
10
+ }
11
+ function r(e) {
12
+ const s = o();
13
+ return {
14
+ ...n,
15
+ ...s,
16
+ ...e,
17
+ headers: {
18
+ ...n.headers,
19
+ ...s.headers,
20
+ ...e?.headers
21
+ }
22
+ };
23
+ }
24
+ export {
25
+ n as D,
26
+ o as g,
27
+ r as m
28
+ };
@@ -0,0 +1,56 @@
1
+ import "react";
2
+ import { getAuthTokenAsync as a } from "./bridge-BKcAlLAd.js";
3
+ const r = "0.2.7-dev.6", i = {
4
+ version: r
5
+ }, o = i.version, c = "@aippy/runtime";
6
+ function w() {
7
+ return {
8
+ name: c,
9
+ version: o,
10
+ buildTime: (/* @__PURE__ */ new Date()).toISOString()
11
+ };
12
+ }
13
+ function p(n) {
14
+ const { token: t, existingHeaders: e } = n, s = new Headers(e);
15
+ return s.set("Aippy-Runtime-Authorization", `Bearer ${t}`), s.set("Aippy-Runtime-SDK-Version", o), typeof navigator < "u" && navigator.userAgent && s.set("Aippy-Runtime-UA", navigator.userAgent), s;
16
+ }
17
+ async function m(n) {
18
+ const t = await a();
19
+ return p({ token: t, existingHeaders: n });
20
+ }
21
+ function u(n) {
22
+ if (!(typeof window > "u"))
23
+ try {
24
+ const t = window.webkit?.messageHandlers?.aippyListener;
25
+ if (t)
26
+ try {
27
+ const e = {
28
+ command: "container.message",
29
+ parameters: n
30
+ };
31
+ t.postMessage(e), console.log("📤 [Container Message] Sent message to iOS app container:", n);
32
+ } catch (e) {
33
+ console.warn("❌ [Container Message] Failed to send message to iOS app:", e);
34
+ }
35
+ if (window.parent && window.parent !== window)
36
+ try {
37
+ const e = {
38
+ type: "container.message",
39
+ data: n
40
+ };
41
+ window.parent.postMessage(e, "*"), console.log("📤 [Container Message] Sent message to parent window:", n);
42
+ } catch (e) {
43
+ console.warn("❌ [Container Message] Failed to send message to parent window:", e);
44
+ }
45
+ } catch (t) {
46
+ console.warn("⚠️ [Container Message] Failed to send message:", t);
47
+ }
48
+ }
49
+ export {
50
+ c as S,
51
+ o as V,
52
+ m as a,
53
+ p as c,
54
+ w as g,
55
+ u as s
56
+ };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Aippy Runtime Headers utilities.
3
+ * Shared header generation for all SDK modules.
4
+ */
5
+ export interface CreateAippyHeadersOptions {
6
+ /** Auth token for Authorization header */
7
+ token: string;
8
+ /** Optional existing headers to extend */
9
+ existingHeaders?: HeadersInit;
10
+ }
11
+ /**
12
+ * Creates Aippy runtime headers with authentication and metadata.
13
+ * Can be used by any module to create consistent headers.
14
+ *
15
+ * Headers set:
16
+ * - Aippy-Runtime-Authorization: Bearer token for authentication
17
+ * - Aippy-Runtime-SDK-Version: SDK version number
18
+ * - Aippy-Runtime-UA: User agent from the shell app
19
+ *
20
+ * @param options - Options for creating headers
21
+ * @returns Headers object with Aippy runtime headers
22
+ */
23
+ export declare function createAippyHeaders(options: CreateAippyHeadersOptions): Headers;
24
+ /**
25
+ * Async version that automatically gets the auth token.
26
+ * Convenient for most use cases.
27
+ *
28
+ * @param existingHeaders - Optional existing headers to extend
29
+ * @returns Promise resolving to Headers object with Aippy runtime headers
30
+ */
31
+ export declare function createAippyHeadersAsync(existingHeaders?: HeadersInit): Promise<Headers>;
@@ -2,5 +2,6 @@ export * from './types';
2
2
  export * from './config';
3
3
  export * from './errors';
4
4
  export * from './version';
5
+ export * from './headers';
5
6
  export * from './container-message';
6
7
  export * from './runtime';
@@ -1,53 +1,23 @@
1
- import { A as d, E as v, c as m } from "../errors-CDEBaBxB.js";
2
- import { s as A } from "../container-message-DGrno17o.js";
3
- import { A as g, C as R, R as I, a as P, p as l } from "../runtime-CmoG3v2m.js";
4
- const s = {
5
- mode: "development",
6
- debug: !1,
7
- apiBaseUrl: void 0,
8
- headers: {}
9
- };
10
- function o() {
11
- const e = {};
12
- return typeof process < "u" && process.env && (process.env.NODE_ENV && (e.mode = process.env.NODE_ENV), process.env.AIPPY_DEBUG && (e.debug = process.env.AIPPY_DEBUG === "true"), process.env.AIPPY_API_BASE_URL && (e.apiBaseUrl = process.env.AIPPY_API_BASE_URL)), e;
13
- }
14
- function p(e) {
15
- const n = o();
16
- return {
17
- ...s,
18
- ...n,
19
- ...e,
20
- headers: {
21
- ...s.headers,
22
- ...n.headers,
23
- ...e?.headers
24
- }
25
- };
26
- }
27
- const r = "0.2.7-dev.5", a = {
28
- version: r
29
- }, t = a.version, i = "@aippy/runtime";
30
- function c() {
31
- return {
32
- name: i,
33
- version: t,
34
- buildTime: (/* @__PURE__ */ new Date()).toISOString()
35
- };
36
- }
1
+ import { D as s, g as r, m as o } from "../config-B0A7gHQM.js";
2
+ import { A as p, E as t, c as i } from "../errors-CDEBaBxB.js";
3
+ import { S as c, V as A, c as E, a as R, g, s as C } from "../container-message-WJolNXso.js";
4
+ import { A as y, C as D, R as l, a as x, p as O } from "../runtime-CmoG3v2m.js";
37
5
  export {
38
- g as AippyRuntime,
39
- d as AippyRuntimeError,
40
- R as Cancellable,
6
+ y as AippyRuntime,
7
+ p as AippyRuntimeError,
8
+ D as Cancellable,
41
9
  s as DEFAULT_CONFIG,
42
- v as ERROR_CODES,
43
- I as ReceiveChannel,
44
- i as SDK_NAME,
45
- t as VERSION,
46
- P as aippyRuntime,
47
- m as createError,
48
- o as getConfigFromEnv,
49
- c as getVersionInfo,
50
- p as mergeConfig,
51
- l as processMotionData,
52
- A as sendMessageToContainer
10
+ t as ERROR_CODES,
11
+ l as ReceiveChannel,
12
+ c as SDK_NAME,
13
+ A as VERSION,
14
+ x as aippyRuntime,
15
+ E as createAippyHeaders,
16
+ R as createAippyHeadersAsync,
17
+ i as createError,
18
+ r as getConfigFromEnv,
19
+ g as getVersionInfo,
20
+ o as mergeConfig,
21
+ O as processMotionData,
22
+ C as sendMessageToContainer
53
23
  };