@aippy/runtime 0.4.2-dev.4 → 0.4.2-dev.5

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,5 +1,5 @@
1
- import { D as o, d as r, e as i, c as n, U as A, a as C, b as g, j as I, g as f, h as t, i as _, l as E, n as T, p as U, r as p, f as D, s as l, v as L } from "../helper-BWszI06u.js";
2
- import "../bridge-D_-7nPNC.js";
1
+ import { D as o, d as r, e as i, c as n, U as A, a as C, b as g, j as I, g as f, h as t, i as _, l as E, n as T, p as U, r as p, f as D, s as l, v as L } from "../helper-CSe2sxu6.js";
2
+ import "../bridge-K3HqQwdj.js";
3
3
  export {
4
4
  o as DEFAULT_BASE_URL,
5
5
  r as DEFAULT_CHAT_MODEL,
@@ -156,17 +156,18 @@ class A {
156
156
  }
157
157
  }
158
158
  }
159
- const m = new A(), C = { iOS: "1.6.7", Android: "1.1.8" }, k = { iOS: "1.6.7", Android: "1.1.8" }, d = {
159
+ const m = new A(), C = { iOS: "1.6.7", Android: "1.1.8" }, k = { iOS: "1.6.7", Android: "1.1.8" }, P = { iOS: "1.21.0", Android: "1.3.7.0" }, d = {
160
160
  userCredentials: C,
161
- userInfo: k
161
+ userInfo: k,
162
+ ministore: P
162
163
  }, l = "https://cdn.aippy.ai/asset/fd292077086044ee9565bd36ac3a8b78.svg";
163
- function P() {
164
+ function V() {
164
165
  const t = m.parseAippyInfo();
165
166
  if (!t) return !1;
166
167
  const e = d.userCredentials[t.platform];
167
168
  return f(t.version, e) >= 0;
168
169
  }
169
- async function V(t, e = "update") {
170
+ async function _(t, e = "update") {
170
171
  const n = document.createElement("div");
171
172
  n.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";
172
173
  const r = document.createElement("div");
@@ -181,7 +182,7 @@ async function V(t, e = "update") {
181
182
  const a = document.createElement("img");
182
183
  a.src = l, a.style.cssText = "width:36px;height:36px;flex-shrink:0", r.appendChild(a);
183
184
  }
184
- const i = e === "signin" || e === "update" && P(), p = i ? t.replace(/\n/g, "") : t, s = document.createElement("span");
185
+ const i = e === "signin" || e === "update" && V(), p = i ? t.replace(/\n/g, "") : t, s = document.createElement("span");
185
186
  if (s.style.cssText = "font-size:14px;font-weight:600;color:#fff;line-height:1.4;white-space:pre-line", s.textContent = p, r.appendChild(s), i) {
186
187
  const a = e === "signin" ? "Sign in" : "Update", c = document.createElement("button");
187
188
  c.style.cssText = "background:#fff;color:#000;font-size:14px;font-weight:600;border:none;border-radius:32px;height:36px;min-width:80px;padding:0 16px;cursor:pointer;flex-shrink:0;white-space:nowrap", c.textContent = a, c.onclick = () => {
@@ -196,12 +197,12 @@ async function V(t, e = "update") {
196
197
  }
197
198
  n.appendChild(r), document.body.appendChild(n);
198
199
  }
199
- function _(t) {
200
+ function R(t) {
200
201
  const e = d[t];
201
202
  return e || (console.warn(`[AppVersionChecker] Unknown feature: ${t}`), { iOS: "999.0.0", Android: "999.0.0" });
202
203
  }
203
- function R(t) {
204
- const e = _(t), n = m.checkAppEnvironment(e), r = n.aippyInfo?.version, o = n.aippyInfo ? e[n.aippyInfo.platform] : void 0;
204
+ function I(t) {
205
+ const e = R(t), n = m.checkAppEnvironment(e), r = n.aippyInfo?.version, o = n.aippyInfo ? e[n.aippyInfo.platform] : void 0;
205
206
  switch (n.type) {
206
207
  case "new_app":
207
208
  return {
@@ -225,24 +226,24 @@ function R(t) {
225
226
  };
226
227
  }
227
228
  }
228
- function L(t) {
229
- const e = R(t);
229
+ function M(t) {
230
+ const e = I(t);
230
231
  if (!e.supported && (e.envCheck.type === "new_app" || e.envCheck.type === "old_ios_app" || e.envCheck.type === "old_android_app"))
231
- throw console.warn(`[AppVersionChecker] ${e.message}`), V(`This project needs a newer version.
232
+ throw console.warn(`[AppVersionChecker] ${e.message}`), _(`This project needs a newer version.
232
233
  Update to view it.`, "update"), v(`App version too old: ${e.message}`, x.NOT_SUPPORTED);
233
234
  return e;
234
235
  }
235
- function M() {
236
+ function N() {
236
237
  return Object.keys(d);
237
238
  }
238
239
  export {
239
240
  A as P,
240
- R as a,
241
- M as b,
241
+ I as a,
242
+ N as b,
242
243
  f as c,
243
- _ as g,
244
+ R as g,
244
245
  y as i,
245
246
  m as p,
246
- L as r,
247
- V as s
247
+ M as r,
248
+ _ as s
248
249
  };
@@ -1,5 +1,5 @@
1
1
  import { a as v } from "./runtime-CmoG3v2m.js";
2
- import { r as b, s as q, i as w } from "./app-version-checker-Bz7FrEZz.js";
2
+ import { r as b, s as q, i as w } from "./app-version-checker-YVIFbytA.js";
3
3
  import { c as A, a as _ } from "./errors-B3bDbQbD.js";
4
4
  const F = ".aippynow.com", k = "https://api.aippy.dev", S = "https://api.aippy.ai";
5
5
  function ee(e) {
@@ -1,5 +1,5 @@
1
- import { g as o, a as i } from "./bridge-D_-7nPNC.js";
2
- const r = "0.4.2-dev.4", c = {
1
+ import { g as o, a as i } from "./bridge-K3HqQwdj.js";
2
+ const r = "0.4.2-dev.5", c = {
3
3
  version: r
4
4
  }, a = c.version, p = "@aippy/runtime";
5
5
  function u() {
@@ -1,7 +1,7 @@
1
1
  import { D as r, g as s, m as o } from "../config-B0A7gHQM.js";
2
- import { _ as t, r as i } from "../bridge-D_-7nPNC.js";
2
+ import { _ as t, r as i } from "../bridge-K3HqQwdj.js";
3
3
  import { A as R, a as E, E as c, b as m, c as A } from "../errors-B3bDbQbD.js";
4
- import { S as f, V as g, c as l, a as y, g as _, s as d } from "../container-message-DmIChz4h.js";
4
+ import { S as f, V as g, c as l, a as y, g as _, s as d } from "../container-message-D4RX93q2.js";
5
5
  import { A as D, C as O, R as F, a as I, p as S } from "../runtime-CmoG3v2m.js";
6
6
  export {
7
7
  D as AippyRuntime,
@@ -2,9 +2,9 @@ import { createOpenAICompatible as C } from "@ai-sdk/openai-compatible";
2
2
  import { j as O } from "./url-c26cuIpu.js";
3
3
  import { AISDKError as p, DefaultChatTransport as E } from "ai";
4
4
  import { E as f, b as m, a as g } from "./errors-B3bDbQbD.js";
5
- import { r as l } from "./bridge-D_-7nPNC.js";
6
- import { s as b, a as _ } from "./container-message-DmIChz4h.js";
7
- import { s as v } from "./wallet-recharge-BqOljLWn.js";
5
+ import { r as l } from "./bridge-K3HqQwdj.js";
6
+ import { s as b, a as _ } from "./container-message-D4RX93q2.js";
7
+ import { s as v } from "./wallet-recharge-xSzcD6QS.js";
8
8
  const T = `${l()}/aisdk/v1/`, ne = `${l()}/aisdk/v1/ui/`, S = "gpt-5-nano", U = "";
9
9
  function M(t = {}) {
10
10
  return {
@@ -15,7 +15,7 @@ async function v() {
15
15
  console.log("🔍 [useUserInfo] fetchUserInfoFromBridge started");
16
16
  const n = A();
17
17
  try {
18
- const { getUserInfoAsync: o, getUserInfoFromParent: c, isInIframe: t } = await import("./bridge-D_-7nPNC.js").then((r) => r.d), { hasNativeBridge: f } = await import("./native-bridge-BnvipFJc.js"), i = f(), l = t();
18
+ const { getUserInfoAsync: o, getUserInfoFromParent: c, isInIframe: t } = await import("./bridge-K3HqQwdj.js").then((r) => r.d), { hasNativeBridge: f } = await import("./native-bridge-BnvipFJc.js"), i = f(), l = t();
19
19
  console.log("🔍 [useUserInfo] Environment check:", {
20
20
  hasNativeBridge: i,
21
21
  isInIframe: l,
@@ -1,18 +1,18 @@
1
1
  import { D as r, g as s, m as o } from "../config-B0A7gHQM.js";
2
- import { _ as i, g as n, r as p } from "../bridge-D_-7nPNC.js";
2
+ import { _ as i, g as n, r as p } from "../bridge-K3HqQwdj.js";
3
3
  import { A as m, a as f, E as c, b as C, c as g } from "../errors-B3bDbQbD.js";
4
- import { S as l, V as E, c as I, a as d, g as S, s as x } from "../container-message-DmIChz4h.js";
4
+ import { S as l, V as E, c as I, a as d, g as S, s as x } from "../container-message-D4RX93q2.js";
5
5
  import { A as U, C as _, R as D, a as T, p as M } from "../runtime-CmoG3v2m.js";
6
6
  import { CameraAPI as v, FileSystemAPI as y, GeolocationAPI as F, SensorsAPI as P, camera as O, fileSystem as b, geolocation as L, isMotionSupported as w, isOrientationSupported as H, requestMotionPermission as N, sensors as V, vibrate as B, watchMotion as k, watchOrientation as j } from "../device/index.js";
7
- import { P as G, a as z, c as K, b as W, g as X, i as Y, p as J, r as Q, s as Z } from "../app-version-checker-Bz7FrEZz.js";
7
+ import { P as G, a as z, c as K, b as W, g as X, i as Y, p as J, r as Q, s as Z } from "../app-version-checker-YVIFbytA.js";
8
8
  import { a as ee, P as ae, p as re, b as se } from "../pwa-C5nXU0DN.js";
9
9
  import { j as te } from "../url-c26cuIpu.js";
10
10
  import { a as ne, b as pe } from "../useTweaks-C7BEMpV3.js";
11
11
  import { c as me, b as fe, i as ce, p as Ce, u as ge, a as ue } from "../useSound-z_eIn0KH.js";
12
12
  import { reportScore as Ee, sendEvent as Ie, updateScore as de } from "../leaderboard/index.js";
13
- import { D as xe, d as Re, e as Ue, c as _e, U as De, a as Te, b as Me, j as he, g as ve, h as ye, i as Fe, l as Pe, n as Oe, p as be, r as Le, f as we, s as He, v as Ne } from "../helper-BWszI06u.js";
13
+ import { D as xe, d as Re, e as Ue, c as _e, U as De, a as Te, b as Me, j as he, g as ve, h as ye, i as Fe, l as Pe, n as Oe, p as be, r as Le, f as we, s as He, v as Ne } from "../helper-CSe2sxu6.js";
14
14
  import { MinistoreError as Be, ministore as ke } from "../ministore/index.js";
15
- import { c as qe, u as Ge } from "../hooks-Ct9qEjM6.js";
15
+ import { c as qe, u as Ge } from "../hooks-CMKwSLcQ.js";
16
16
  import { hasNativeBridge as Ke } from "../native-bridge-BnvipFJc.js";
17
17
  export {
18
18
  U as AippyRuntime,
@@ -1,6 +1,6 @@
1
1
  import { MinistoreAuthorization, MinistoreAuthorizationInput, MinistoreResult } from './types';
2
2
  export declare function usableAuthorization(data: MinistoreAuthorization, input: MinistoreAuthorizationInput): boolean;
3
- /** Shared runtime-auth version floor plus native bridge, not wallet capability. */
3
+ /** Native bridge plus the ministore app version floor. Silent: no upgrade banner. */
4
4
  export declare function isAuthorizationSupported(): boolean;
5
5
  /**
6
6
  * Native records authorization only. No App login token, project ID or HTTP
@@ -1,12 +1,12 @@
1
- var de = Object.defineProperty;
2
- var fe = (e, t, r) => t in e ? de(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var w = (e, t, r) => fe(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { a as le, i as he, r as me, b as be, c as pe } from "../bridge-D_-7nPNC.js";
5
- import { a as C, r as ye } from "../app-version-checker-Bz7FrEZz.js";
1
+ var fe = Object.defineProperty;
2
+ var le = (e, t, r) => t in e ? fe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var w = (e, t, r) => le(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { a as he, i as me, r as be, b as pe, c as ye } from "../bridge-K3HqQwdj.js";
5
+ import { a as B, r as j } from "../app-version-checker-YVIFbytA.js";
6
6
  import { E as x } from "../errors-B3bDbQbD.js";
7
- import { a as we, s as ze } from "../container-message-DmIChz4h.js";
7
+ import { a as we, s as ze } from "../container-message-D4RX93q2.js";
8
8
  import { j as ge } from "../url-c26cuIpu.js";
9
- import { W as M, s as Oe, w as Ae } from "../wallet-recharge-BqOljLWn.js";
9
+ import { W as M, s as Oe, w as Ae } from "../wallet-recharge-xSzcD6QS.js";
10
10
  class d extends Error {
11
11
  constructor(r, n, o = {}) {
12
12
  super(
@@ -56,7 +56,7 @@ function ve(e) {
56
56
  iconUrl: f(t.iconUrl)
57
57
  };
58
58
  }
59
- function B(e) {
59
+ function C(e) {
60
60
  const t = z(e);
61
61
  return "value" in t || y(), {
62
62
  benefitKey: f(t.benefitKey),
@@ -67,7 +67,7 @@ function B(e) {
67
67
  display: ve(t.display)
68
68
  };
69
69
  }
70
- function j(e) {
70
+ function D(e) {
71
71
  const t = z(e);
72
72
  "value" in t || y();
73
73
  const r = f(t.itemId);
@@ -86,10 +86,10 @@ function Ne(e) {
86
86
  if (e == null) return;
87
87
  const t = z(e);
88
88
  if (!(t.itemId === "" || Object.keys(t).length === 0))
89
- return j(t);
89
+ return D(t);
90
90
  }
91
91
  function T(e) {
92
- const t = z(e), r = B(t), n = r.quantity === 0 && r.used === 0 && (t.holdings === null || t.holdings === void 0) && (t.items === null || t.items === void 0), o = n || t.holdings === null || t.holdings === void 0 ? [] : E(t.holdings, (u) => {
92
+ const t = z(e), r = C(t), n = r.quantity === 0 && r.used === 0 && (t.holdings === null || t.holdings === void 0) && (t.items === null || t.items === void 0), o = n || t.holdings === null || t.holdings === void 0 ? [] : E(t.holdings, (u) => {
93
93
  const a = z(u), s = f(a.orderId), c = a.source === void 0 ? "" : f(a.source);
94
94
  return (!I(s) && !(s === "" && c === "FREE") || !("value" in a)) && y(), {
95
95
  orderId: s,
@@ -99,14 +99,14 @@ function T(e) {
99
99
  createdAt: f(a.createdAt),
100
100
  source: c
101
101
  };
102
- }), i = n || t.items === null || t.items === void 0 ? [] : E(t.items, j);
102
+ }), i = n || t.items === null || t.items === void 0 ? [] : E(t.items, D);
103
103
  return { ...r, holdings: o, items: i };
104
104
  }
105
105
  function v(e, t) {
106
106
  const r = z(e), n = f(r.reason), o = t(r);
107
107
  return n === "" ? { ok: !0, data: o } : { ok: !1, reason: n, data: o };
108
108
  }
109
- function D(e) {
109
+ function H(e) {
110
110
  return {
111
111
  benefitKey: f(e.benefitKey),
112
112
  authMode: f(e.authMode),
@@ -152,13 +152,13 @@ function I(e) {
152
152
  function R(e) {
153
153
  return I(e) && BigInt(e) > 0n;
154
154
  }
155
- const H = 3e4, K = /* @__PURE__ */ Symbol("authorization-pending"), Ue = "wallet.authorize-result", qe = "wallet.authorize-alive", Te = "wallet.authorize-alive-ack";
155
+ const V = 3e4, K = /* @__PURE__ */ Symbol("authorization-pending"), Ue = "wallet.authorize-result", qe = "wallet.authorize-alive", Te = "wallet.authorize-alive-ack";
156
156
  let Se = 0;
157
- function V() {
157
+ function $() {
158
158
  return typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : `ministore-${Date.now().toString(36)}-${++Se}-${Math.random().toString(36).slice(2)}`;
159
159
  }
160
160
  const U = /* @__PURE__ */ new WeakMap();
161
- function $(e) {
161
+ function F(e) {
162
162
  return z(typeof e == "string" ? JSON.parse(e) : e);
163
163
  }
164
164
  function Pe(e, t, r) {
@@ -170,7 +170,7 @@ function Pe(e, t, r) {
170
170
  const i = /* @__PURE__ */ new Map(), u = e.processAuthorizeResult, a = (s) => {
171
171
  let c;
172
172
  try {
173
- c = $(s);
173
+ c = F(s);
174
174
  } catch {
175
175
  u?.call(e, s);
176
176
  return;
@@ -194,7 +194,7 @@ function Pe(e, t, r) {
194
194
  o.pending.delete(t), o.pending.size === 0 && (e.processAuthorizeResult === o.dispatch && (o.hadPrevious ? e.processAuthorizeResult = o.previous : delete e.processAuthorizeResult), U.delete(e));
195
195
  };
196
196
  }
197
- function F(e, t) {
197
+ function G(e, t) {
198
198
  const r = typeof t.code == "number" || typeof t.code == "string" ? t.code : void 0, n = typeof t.reason == "string" ? t.reason : void 0, o = ["unsupported_type", "invalid_params", "busy"].includes(n ?? "") || n === "server_error" && [1001, 2e4, 1002, 1003, 1004, 401, 11001, 10001].includes(
199
199
  Number(r)
200
200
  );
@@ -206,7 +206,7 @@ function F(e, t) {
206
206
  authorizationUnknown: !o
207
207
  });
208
208
  }
209
- function G(e, t) {
209
+ function J(e, t) {
210
210
  return e.benefitKey !== t.benefitKey || !e.authorized ? !1 : e.authMode === "none" || e.authMode === "once" ? !0 : e.authMode === "every" && e.bizOrderNo === t.bizOrderNo && e.quantity >= t.quantity && e.quantity <= 99 && !e.used;
211
211
  }
212
212
  function Re(e, t) {
@@ -221,17 +221,17 @@ function Re(e, t) {
221
221
  });
222
222
  }
223
223
  function Ke(e, t) {
224
- const r = $(e), n = b(r.code), o = f(r.msg);
224
+ const r = F(e), n = b(r.code), o = f(r.msg);
225
225
  if (n !== 0)
226
- throw F(t, {
226
+ throw G(t, {
227
227
  reason: "server_error",
228
228
  code: n,
229
229
  message: o
230
230
  });
231
- const i = v(r.data, D);
232
- return i.ok ? G(i.data, t) ? i : { ok: !1, reason: "authorization_required", data: i.data } : i;
231
+ const i = v(r.data, H);
232
+ return i.ok ? J(i.data, t) ? i : { ok: !1, reason: "authorization_required", data: i.data } : i;
233
233
  }
234
- function J(e, t) {
234
+ function Q(e, t) {
235
235
  const r = z(e);
236
236
  switch (r.status) {
237
237
  case "closed":
@@ -241,7 +241,7 @@ function J(e, t) {
241
241
  type: "closed"
242
242
  });
243
243
  case "failed":
244
- throw r.reason === "rejected" ? Re(t, r) : F(t, r);
244
+ throw r.reason === "rejected" ? Re(t, r) : G(t, r);
245
245
  case "timeout":
246
246
  throw new d("authorization", "App authorization timed out", {
247
247
  bizOrderNo: t.bizOrderNo,
@@ -254,7 +254,7 @@ function J(e, t) {
254
254
  y();
255
255
  }
256
256
  }
257
- function Q(e, t) {
257
+ function W(e, t) {
258
258
  return {
259
259
  type: "authorize",
260
260
  title: e.title,
@@ -271,7 +271,7 @@ function Q(e, t) {
271
271
  function xe(e, t, r, n, o) {
272
272
  if (!r)
273
273
  try {
274
- const i = J(e, t);
274
+ const i = Q(e, t);
275
275
  if (i === K) return;
276
276
  n(), o(i);
277
277
  } catch (i) {
@@ -291,7 +291,7 @@ function _e(e, t, r) {
291
291
  bizOrderNo: e.bizOrderNo
292
292
  })
293
293
  );
294
- const n = V();
294
+ const n = $();
295
295
  return new Promise((o, i) => {
296
296
  let u = !1;
297
297
  const a = () => {
@@ -315,8 +315,8 @@ function _e(e, t, r) {
315
315
  }
316
316
  )
317
317
  );
318
- }, H), g = (p) => {
319
- if (he(p, r)) {
318
+ }, V), g = (p) => {
319
+ if (me(p, r)) {
320
320
  if (p.data.type === qe && p.data.requestId === n) {
321
321
  window.parent.postMessage(
322
322
  { type: Te, requestId: n },
@@ -340,7 +340,7 @@ function _e(e, t, r) {
340
340
  window.parent.postMessage(
341
341
  {
342
342
  type: "wallet.authorize",
343
- parameters: Q(e, n)
343
+ parameters: W(e, n)
344
344
  },
345
345
  r
346
346
  );
@@ -362,13 +362,13 @@ function _e(e, t, r) {
362
362
  function Le() {
363
363
  if (typeof window > "u" || typeof navigator > "u" || typeof window.webkit?.messageHandlers?.aippyListener?.postMessage != "function")
364
364
  return !1;
365
- const e = C("userCredentials");
365
+ const e = B("ministore");
366
366
  return e.envCheck.type === "new_app" && e.supported;
367
367
  }
368
- function Ce(e, t) {
368
+ function Be(e, t) {
369
369
  const r = typeof window > "u" ? void 0 : window.webkit?.messageHandlers?.aippyListener;
370
370
  if (typeof r?.postMessage != "function") {
371
- const i = le();
371
+ const i = he();
372
372
  return i ? _e(e, t, i) : Promise.reject(
373
373
  new d("unsupported", "App authorization is unavailable", {
374
374
  bizOrderNo: e.bizOrderNo
@@ -382,7 +382,7 @@ function Ce(e, t) {
382
382
  })
383
383
  );
384
384
  try {
385
- const i = ye("userCredentials");
385
+ const i = j("ministore");
386
386
  if (i.envCheck.type !== "new_app" || !i.supported)
387
387
  throw new Error("Native App authorization is unavailable");
388
388
  } catch (i) {
@@ -393,7 +393,7 @@ function Ce(e, t) {
393
393
  })
394
394
  );
395
395
  }
396
- const n = window, o = V();
396
+ const n = window, o = $();
397
397
  return new Promise((i, u) => {
398
398
  let a = !1, s = () => {
399
399
  };
@@ -418,12 +418,12 @@ function Ce(e, t) {
418
418
  }
419
419
  )
420
420
  );
421
- }, H);
421
+ }, V);
422
422
  try {
423
423
  s = Pe(n, o, (m) => {
424
424
  if (!a)
425
425
  try {
426
- const O = J(m, e);
426
+ const O = Q(m, e);
427
427
  if (O === K) return;
428
428
  a = !0, c(), i(O);
429
429
  } catch (O) {
@@ -457,7 +457,7 @@ function Ce(e, t) {
457
457
  try {
458
458
  r.postMessage({
459
459
  command: "wallet.authorize",
460
- parameters: Q(e, o)
460
+ parameters: W(e, o)
461
461
  });
462
462
  } catch (m) {
463
463
  h(
@@ -474,19 +474,19 @@ function Ce(e, t) {
474
474
  }
475
475
  });
476
476
  }
477
- const W = /* @__PURE__ */ Symbol("ministoreScopeCheck");
478
- function Z(e) {
477
+ const Z = /* @__PURE__ */ Symbol("ministoreScopeCheck");
478
+ function X(e) {
479
479
  let t;
480
480
  try {
481
- t = new URL(e ?? `${me()}/aisdk/v1/`);
481
+ t = new URL(e ?? `${be()}/aisdk/v1/`);
482
482
  } catch {
483
483
  l("baseUrl must be a valid official Aippy API URL");
484
484
  }
485
- return (!be(t.origin) || t.username || t.password || t.search || t.hash || t.pathname !== "/aisdk/v1" && t.pathname !== "/aisdk/v1/") && l(
485
+ return (!pe(t.origin) || t.username || t.password || t.search || t.hash || t.pathname !== "/aisdk/v1" && t.pathname !== "/aisdk/v1/") && l(
486
486
  "baseUrl must use an official HTTPS Aippy API origin and /aisdk/v1/"
487
487
  ), t.href;
488
488
  }
489
- function X(e) {
489
+ function Y(e) {
490
490
  if (e !== void 0)
491
491
  try {
492
492
  return JSON.stringify(e, (t, r) => {
@@ -498,8 +498,8 @@ function X(e) {
498
498
  l("Request body must contain finite, non-cyclic JSON values");
499
499
  }
500
500
  }
501
- function Y(e) {
502
- return JSON.parse(X(e));
501
+ function ee(e) {
502
+ return JSON.parse(Y(e));
503
503
  }
504
504
  function q(e) {
505
505
  if (e?.aborted)
@@ -508,16 +508,16 @@ function q(e) {
508
508
  function _(e) {
509
509
  return e !== null && typeof e == "object" && !Array.isArray(e) ? e : void 0;
510
510
  }
511
- function Be(e) {
511
+ function je(e) {
512
512
  if (!e) return;
513
513
  const t = Number(e), r = Number.isFinite(t) ? t * 1e3 : Date.parse(e) - Date.now();
514
514
  return Number.isFinite(r) && r >= 0 ? r : void 0;
515
515
  }
516
516
  async function N(e, t, r, n) {
517
517
  const o = ge(
518
- Z(t.baseUrl),
518
+ X(t.baseUrl),
519
519
  `ministore/${e}`
520
- ), i = X(r.body);
520
+ ), i = Y(r.body);
521
521
  let u = !1, a, s = "auth";
522
522
  const c = {
523
523
  bizOrderNo: r.bizOrderNo
@@ -525,7 +525,7 @@ async function N(e, t, r, n) {
525
525
  try {
526
526
  q(t.signal);
527
527
  const h = await we();
528
- q(t.signal), t[W]?.(), t.language && h.set("App-Language", t.language), r.body !== void 0 && h.set("Content-Type", "application/json"), s = "network", u = !0, a = await globalThis.fetch(o, {
528
+ q(t.signal), t[Z]?.(), t.language && h.set("App-Language", t.language), r.body !== void 0 && h.set("Content-Type", "application/json"), s = "network", u = !0, a = await globalThis.fetch(o, {
529
529
  method: r.method,
530
530
  headers: h,
531
531
  cache: "no-store",
@@ -533,13 +533,13 @@ async function N(e, t, r, n) {
533
533
  redirect: "error",
534
534
  signal: t.signal,
535
535
  body: i
536
- }), c.httpStatus = a.status, c.traceId = a.headers.get("X-Trace-Id") ?? void 0, c.retryAfterMs = Be(a.headers.get("Retry-After")), s = "protocol";
536
+ }), c.httpStatus = a.status, c.traceId = a.headers.get("X-Trace-Id") ?? void 0, c.retryAfterMs = je(a.headers.get("Retry-After")), s = "protocol";
537
537
  const g = await a.json().catch((p) => {
538
538
  if (a.ok) throw p;
539
539
  });
540
540
  if (q(t.signal), a.status !== 200) {
541
- const p = _(g), m = _(p?.error), ue = typeof m?.message == "string" && (typeof m.code == "number" || typeof m.code == "string") && [400, 401, 403, 429].includes(a.status);
542
- if (c.settlementUnknown = r.method === "POST" && !ue, c.code = typeof m?.code == "number" || typeof m?.code == "string" ? m.code : void 0, c.type = typeof m?.type == "string" ? m.type : void 0, c.appMessage = typeof p?.appMessage == "string" ? p.appMessage : void 0, c.appMessage)
541
+ const p = _(g), m = _(p?.error), de = typeof m?.message == "string" && (typeof m.code == "number" || typeof m.code == "string") && [400, 401, 403, 429].includes(a.status);
542
+ if (c.settlementUnknown = r.method === "POST" && !de, c.code = typeof m?.code == "number" || typeof m?.code == "string" ? m.code : void 0, c.type = typeof m?.type == "string" ? m.type : void 0, c.appMessage = typeof p?.appMessage == "string" ? p.appMessage : void 0, c.appMessage)
543
543
  try {
544
544
  ze(c.appMessage);
545
545
  } catch {
@@ -562,7 +562,7 @@ async function N(e, t, r, n) {
562
562
  );
563
563
  }
564
564
  }
565
- function ee(e = {}) {
565
+ function te(e = {}) {
566
566
  return N(
567
567
  "wallet/balance",
568
568
  e,
@@ -573,17 +573,17 @@ function ee(e = {}) {
573
573
  }
574
574
  );
575
575
  }
576
- async function te(e, t = {}) {
576
+ async function re(e, t = {}) {
577
577
  (!e || typeof e != "object") && l("An authorization query is required"), k(e.benefitKey, "benefitKey", 64), e.bizOrderNo !== void 0 && k(e.bizOrderNo, "bizOrderNo", 64);
578
578
  const r = new URLSearchParams({ benefitKey: e.benefitKey });
579
579
  return e.bizOrderNo && r.set("bizOrderNo", e.bizOrderNo), N(
580
580
  `benefits/authorization?${r}`,
581
581
  t,
582
582
  { method: "GET", bizOrderNo: e.bizOrderNo },
583
- (n) => v(n, D)
583
+ (n) => v(n, H)
584
584
  );
585
585
  }
586
- function je(e = {}) {
586
+ function Ce(e = {}) {
587
587
  return N(
588
588
  "catalog",
589
589
  e,
@@ -593,7 +593,7 @@ function je(e = {}) {
593
593
  items: E(r.items, (n) => {
594
594
  const o = z(n);
595
595
  return {
596
- ...B(o),
596
+ ...C(o),
597
597
  price: b(o.price),
598
598
  freeQuota: b(o.freeQuota),
599
599
  maxQuantity: b(o.maxQuantity),
@@ -650,7 +650,7 @@ async function He(e = {}, t = {}) {
650
650
  );
651
651
  }
652
652
  async function Ve(e, t = {}) {
653
- (!e || typeof e != "object") && l("An authorization input is required"), e.operation !== "purchase" && e.operation !== "consume" && l("Invalid authorization operation"), k(e.benefitKey, "benefitKey", 64), k(e.bizOrderNo, "bizOrderNo", 64), P(e.quantity), Z(t.baseUrl);
653
+ (!e || typeof e != "object") && l("An authorization input is required"), e.operation !== "purchase" && e.operation !== "consume" && l("Invalid authorization operation"), k(e.benefitKey, "benefitKey", 64), k(e.bizOrderNo, "bizOrderNo", 64), P(e.quantity), X(t.baseUrl);
654
654
  for (const i of ["title", "buttonText"])
655
655
  (typeof e[i] != "string" || e[i].trim() === "") && l(`${i} must be a nonempty string`);
656
656
  e.content !== void 0 && typeof e.content != "string" && l("content must be a string");
@@ -662,11 +662,11 @@ async function Ve(e, t = {}) {
662
662
  title: e.title,
663
663
  buttonText: e.buttonText,
664
664
  ...e.content !== void 0 ? { content: e.content } : {}
665
- }, n = await Ce(r, t.signal);
665
+ }, n = await Be(r, t.signal);
666
666
  if (!n.ok) return n;
667
667
  let o;
668
668
  try {
669
- o = await te(
669
+ o = await re(
670
670
  { benefitKey: r.benefitKey, bizOrderNo: r.bizOrderNo },
671
671
  t
672
672
  );
@@ -682,22 +682,22 @@ async function Ve(e, t = {}) {
682
682
  }
683
683
  );
684
684
  }
685
- return o.ok ? G(o.data, r) ? o : {
685
+ return o.ok ? J(o.data, r) ? o : {
686
686
  ok: !1,
687
687
  reason: "authorization_required",
688
688
  data: o.data
689
689
  } : o;
690
690
  }
691
- function re(e) {
691
+ function oe(e) {
692
692
  if (e !== void 0)
693
693
  return k(e, "bizOrderNo", 64), e;
694
694
  if (typeof globalThis.crypto?.randomUUID == "function")
695
695
  return globalThis.crypto.randomUUID();
696
696
  l("This environment cannot create a secure bizOrderNo");
697
697
  }
698
- const L = 6e4, oe = 1e3;
699
- function ne(e) {
700
- const t = typeof window > "u" ? void 0 : window, r = t?.location?.href, n = C("userCredentials"), o = n.supported && n.envCheck.type === "new_app";
698
+ const L = 6e4, ne = 1e3;
699
+ function ie(e) {
700
+ const t = typeof window > "u" ? void 0 : window, r = t?.location?.href, n = B("ministore"), o = n.supported && n.envCheck.type === "new_app";
701
701
  let i = null, u = !1;
702
702
  const a = () => {
703
703
  if (!o) return;
@@ -705,13 +705,13 @@ function ne(e) {
705
705
  throw new DOMException("Purchase page changed", "AbortError");
706
706
  if (u && typeof document < "u" && document.visibilityState === "hidden")
707
707
  throw new DOMException("Purchase page is not visible", "AbortError");
708
- const c = pe();
708
+ const c = ye();
709
709
  if (!i) i = c;
710
710
  else if (c !== i)
711
711
  throw new DOMException("Purchase account changed", "AbortError");
712
712
  };
713
713
  return {
714
- options: { ...e, [W]: a },
714
+ options: { ...e, [Z]: a },
715
715
  check: a,
716
716
  prepareContinuation: () => {
717
717
  u = !0, a();
@@ -719,7 +719,7 @@ function ne(e) {
719
719
  available: () => o && !!i && typeof t?.webkit?.messageHandlers?.aippyListener?.postMessage == "function" && !(typeof document < "u" && document.visibilityState === "hidden")
720
720
  };
721
721
  }
722
- function ie(e, t) {
722
+ function ae(e, t) {
723
723
  return new Promise((r, n) => {
724
724
  if (t.aborted) {
725
725
  n(t.reason);
@@ -733,7 +733,7 @@ function ie(e, t) {
733
733
  t.addEventListener("abort", o, { once: !0 });
734
734
  });
735
735
  }
736
- async function ae(e, t) {
736
+ async function se(e, t) {
737
737
  const r = new AbortController(), n = e.options.signal, o = () => r.abort(n?.reason);
738
738
  n?.addEventListener("abort", o, { once: !0 }), n?.aborted && o();
739
739
  const i = Date.now() + L;
@@ -761,47 +761,53 @@ async function ae(e, t) {
761
761
  clearTimeout(a), n?.removeEventListener("abort", o);
762
762
  }
763
763
  }
764
- async function se(e, t, r) {
764
+ async function ce(e, t, r) {
765
765
  for (; ; ) {
766
766
  e.check();
767
- let n = oe;
767
+ let n = ne;
768
768
  try {
769
- const o = await ee(t);
769
+ const o = await te(t);
770
770
  return e.check(), o;
771
771
  } catch (o) {
772
772
  if (!(o instanceof d && (o.kind === "network" || o.kind === "http" && (o.httpStatus === 429 || (o.httpStatus ?? 0) >= 500)))) throw o;
773
773
  n = Math.max(n, o.retryAfterMs ?? 0);
774
774
  }
775
- await ie(
775
+ await ae(
776
776
  Math.min(n, Math.max(0, r - Date.now())),
777
777
  t.signal
778
778
  );
779
779
  }
780
780
  }
781
781
  async function $e(e, t) {
782
- await ae(e, async (r, n) => {
782
+ await se(e, async (r, n) => {
783
783
  for (; ; ) {
784
- if (await se(e, r, n) > t) return;
785
- await ie(
786
- Math.min(oe, Math.max(0, n - Date.now())),
784
+ if (await ce(e, r, n) > t) return;
785
+ await ae(
786
+ Math.min(ne, Math.max(0, n - Date.now())),
787
787
  r.signal
788
788
  );
789
789
  }
790
790
  });
791
791
  }
792
- async function ce(e, t, r, n = !0) {
792
+ async function ue(e, t, r, n = !0) {
793
793
  const o = await e();
794
794
  if (o.ok || o.reason !== "insufficient_balance" || !n)
795
795
  return o;
796
796
  try {
797
797
  if (t.options.signal?.aborted)
798
798
  throw new M("cancelled", "Recharge action cancelled");
799
- if (!t.available())
799
+ if (!t.available()) {
800
+ try {
801
+ j("ministore");
802
+ } catch {
803
+ return o;
804
+ }
800
805
  return Oe(), o;
806
+ }
801
807
  t.check();
802
- const i = await ae(
808
+ const i = await se(
803
809
  t,
804
- (a, s) => se(t, a, s)
810
+ (a, s) => ce(t, a, s)
805
811
  );
806
812
  t.check();
807
813
  const u = await Ae(t.options.signal);
@@ -826,14 +832,14 @@ async function ce(e, t, r, n = !0) {
826
832
  }
827
833
  async function Fe(e, t = {}) {
828
834
  ke(e);
829
- const r = re(e.bizOrderNo), n = Y({
835
+ const r = oe(e.bizOrderNo), n = ee({
830
836
  benefitKey: e.benefitKey,
831
837
  bizOrderNo: r,
832
838
  autoPurchase: e.autoPurchase === !0,
833
839
  ...e.quantity === void 0 ? {} : { quantity: e.quantity },
834
840
  ...e.itemIds === void 0 ? {} : { itemIds: e.itemIds }
835
- }), o = ne(t);
836
- return ce(
841
+ }), o = ie(t);
842
+ return ue(
837
843
  () => N(
838
844
  "benefits/consume",
839
845
  o.options,
@@ -856,13 +862,13 @@ function Ge() {
856
862
  }
857
863
  async function Je(e, t = {}) {
858
864
  Ee(e);
859
- const r = e.itemValues, n = e.quantity ?? r?.length ?? 1, o = re(e.bizOrderNo), i = Y({
865
+ const r = e.itemValues, n = e.quantity ?? r?.length ?? 1, o = oe(e.bizOrderNo), i = ee({
860
866
  benefitKey: e.benefitKey,
861
867
  quantity: n,
862
868
  bizOrderNo: o,
863
869
  ...r === void 0 ? {} : { itemValues: r }
864
- }), u = ne(t);
865
- return ce(() => N(
870
+ }), u = ie(t);
871
+ return ue(() => N(
866
872
  "benefits/purchase",
867
873
  u.options,
868
874
  {
@@ -898,10 +904,10 @@ async function Qe(e, t = {}) {
898
904
  );
899
905
  }
900
906
  const ot = {
901
- getGemBalance: ee,
902
- getAuthorization: te,
907
+ getGemBalance: te,
908
+ getAuthorization: re,
903
909
  requestAuthorization: Ve,
904
- listCatalog: je,
910
+ listCatalog: Ce,
905
911
  listBenefits: De,
906
912
  isPurchaseSupported: Ge,
907
913
  purchase: Je,
@@ -1,5 +1,5 @@
1
1
  import { MinistorePurchaseInput, MinistoreRequestOptions, MinistoreResult, MinistoreSettlement } from './types';
2
- /** Native bridge and shared auth version floor; not wallet capability or API readiness. */
2
+ /** Native bridge and ministore app version floor; not backend readiness. */
3
3
  export declare function isPurchaseSupported(): boolean;
4
4
  /** Settle an explicit purchase; mall enforces its server-recorded authorization. */
5
5
  export declare function purchase(input: MinistorePurchaseInput, options?: MinistoreRequestOptions): Promise<MinistoreResult<MinistoreSettlement>>;
@@ -1,6 +1,6 @@
1
- import { c as o, u as s } from "../hooks-Ct9qEjM6.js";
2
- import { g as f } from "../bridge-D_-7nPNC.js";
3
- import { i as t } from "../app-version-checker-Bz7FrEZz.js";
1
+ import { c as o, u as s } from "../hooks-CMKwSLcQ.js";
2
+ import { g as f } from "../bridge-K3HqQwdj.js";
3
+ import { i as t } from "../app-version-checker-YVIFbytA.js";
4
4
  export {
5
5
  o as clearUserInfoCache,
6
6
  f as getAuthTokenAsync,
@@ -6,6 +6,10 @@ declare const _default: {
6
6
  "userInfo": {
7
7
  "iOS": "1.6.7",
8
8
  "Android": "1.1.8"
9
+ },
10
+ "ministore": {
11
+ "iOS": "1.21.0",
12
+ "Android": "1.3.7.0"
9
13
  }
10
14
  }
11
15
  ;
@@ -1,4 +1,4 @@
1
- import { P as a, a as s, c as o, b as t, g as p, i, p as m, r as n, s as f } from "../app-version-checker-Bz7FrEZz.js";
1
+ import { P as a, a as s, c as o, b as t, g as p, i, p as m, r as n, s as f } from "../app-version-checker-YVIFbytA.js";
2
2
  import { a as c, P as l, p as P, b as F } from "../pwa-C5nXU0DN.js";
3
3
  import { j as g } from "../url-c26cuIpu.js";
4
4
  export {
@@ -1,4 +1,4 @@
1
- import { a as v } from "./bridge-D_-7nPNC.js";
1
+ import { a as v } from "./bridge-K3HqQwdj.js";
2
2
  const l = "wallet.showRecharge", R = 3e5;
3
3
  class s extends Error {
4
4
  constructor(t, r) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aippy/runtime",
3
- "version": "0.4.2-dev.4",
3
+ "version": "0.4.2-dev.5",
4
4
  "description": "Aippy Runtime SDK - Runtime SDK for Aippy projects",
5
5
  "private": false,
6
6
  "type": "module",