@orbit-software/sdk 1.10.0 → 1.12.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.
@@ -1,4 +1,4 @@
1
- import { c as b, g as M } from "./sdk-4y_oRGP7.mjs";
1
+ import { c as b, g as M } from "./sdk-CbLf1YqO.mjs";
2
2
  function R(y, v) {
3
3
  for (var d = 0; d < v.length; d++) {
4
4
  const f = v[d];
@@ -0,0 +1,10 @@
1
+ export type AdStatus = "SHOWED" | "CLICKED" | "NOT_SHOWED";
2
+ export interface TMANetworkInterstitialResponse {
3
+ id: string;
4
+ reward: boolean;
5
+ }
6
+ export interface ShowAdOptions {
7
+ onStart?: () => void;
8
+ }
9
+ export declare function checkAdStatus(id: string): Promise<AdStatus>;
10
+ export declare function showAd(options?: ShowAdOptions): Promise<TMANetworkInterstitialResponse>;
@@ -1854,7 +1854,7 @@ function promisify(e) {
1854
1854
  };
1855
1855
  }
1856
1856
  promisify.argumentNames = "__ES6-PROMISIFY--CUSTOM-ARGUMENTS__", promisify.Promise = void 0;
1857
- const version = "1.10.0";
1857
+ const version = "1.11.0";
1858
1858
  var jsxRuntime = { exports: {} }, reactJsxRuntime_development = {}, hasRequiredReactJsxRuntime_development;
1859
1859
  function requireReactJsxRuntime_development() {
1860
1860
  if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
@@ -9788,7 +9788,7 @@ function resolveMotionValue(e) {
9788
9788
  const T = isMotionValue(e) ? e.get() : e;
9789
9789
  return isCustomValue(T) ? T.toValue() : T;
9790
9790
  }
9791
- function delay(e, T) {
9791
+ function delay$1(e, T) {
9792
9792
  const J = time.now(), $ = ({ timestamp: ee }) => {
9793
9793
  const te = ee - J;
9794
9794
  te >= T && (cancelFrame($), e(te - T));
@@ -9861,7 +9861,7 @@ function createProjectionNode$1({ attachResizeListener: e, defaultParent: T, mea
9861
9861
  let le;
9862
9862
  const de = () => this.root.updateBlockedByResize = !1;
9863
9863
  e(ie, () => {
9864
- this.root.updateBlockedByResize = !0, le && le(), le = delay(de, 250), globalProjectionState.hasAnimatedSinceResize && (globalProjectionState.hasAnimatedSinceResize = !1, this.nodes.forEach(finishAnimation));
9864
+ this.root.updateBlockedByResize = !0, le && le(), le = delay$1(de, 250), globalProjectionState.hasAnimatedSinceResize && (globalProjectionState.hasAnimatedSinceResize = !1, this.nodes.forEach(finishAnimation));
9865
9865
  });
9866
9866
  }
9867
9867
  ae && this.root.registerSharedNode(ae, this), this.options.animate !== !1 && oe && (ae || ne) && this.addEventListener("didUpdate", ({ delta: le, hasLayoutChanged: de, hasRelativeTargetChanged: pe, layout: me }) => {
@@ -23344,7 +23344,7 @@ const XpProgress = ({
23344
23344
  admin,
23345
23345
  inventory
23346
23346
  };
23347
- var define_process_env_default$2 = { NODE_ENV: '"production"', version: '"1.10.0"' };
23347
+ var define_process_env_default$2 = { NODE_ENV: '"production"', version: '"1.11.0"' };
23348
23348
  const resources = {
23349
23349
  en: {
23350
23350
  translation: en$2
@@ -24795,7 +24795,7 @@ function createThunkMiddleware(e) {
24795
24795
  }
24796
24796
  var thunk = createThunkMiddleware();
24797
24797
  thunk.withExtraArgument = createThunkMiddleware;
24798
- var define_process_env_default$1 = { NODE_ENV: '"production"', version: '"1.10.0"' }, __extends = /* @__PURE__ */ function() {
24798
+ var define_process_env_default$1 = { NODE_ENV: '"production"', version: '"1.11.0"' }, __extends = /* @__PURE__ */ function() {
24799
24799
  var e = function(T, J) {
24800
24800
  return e = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function($, ee) {
24801
24801
  $.__proto__ = ee;
@@ -57632,7 +57632,7 @@ function n3() {
57632
57632
  if (t3) return;
57633
57633
  if (cx) return cx;
57634
57634
  async function e() {
57635
- await import("./howler-Mh6LB0k5.mjs").then((T) => T.h), r3(window !== void 0 ? window : global), t3 = !0;
57635
+ await import("./howler-DXsASgUj.mjs").then((T) => T.h), r3(window !== void 0 ? window : global), t3 = !0;
57636
57636
  }
57637
57637
  return cx = e(), cx;
57638
57638
  }
@@ -75795,6 +75795,26 @@ const OverlayManager = ({ options: e }) => {
75795
75795
  /* @__PURE__ */ jsxRuntimeExports.jsx(BoxOpeningModal, {})
75796
75796
  ] }) }) }) }) }) });
75797
75797
  };
75798
+ class AbortError extends Error {
75799
+ constructor(T = "The operation was aborted") {
75800
+ super(T), this.name = "AbortError";
75801
+ }
75802
+ }
75803
+ function delay(e, { signal: T } = {}) {
75804
+ return new Promise((J, $) => {
75805
+ const ee = () => {
75806
+ $(new AbortError());
75807
+ }, te = () => {
75808
+ clearTimeout(ie), ee();
75809
+ };
75810
+ if (T != null && T.aborted)
75811
+ return ee();
75812
+ const ie = setTimeout(() => {
75813
+ T == null || T.removeEventListener("abort", te), J();
75814
+ }, e);
75815
+ T == null || T.addEventListener("abort", te, { once: !0 });
75816
+ });
75817
+ }
75798
75818
  var dist = {}, ga4 = {}, gtag = {}, hasRequiredGtag;
75799
75819
  function requireGtag() {
75800
75820
  return hasRequiredGtag || (hasRequiredGtag = 1, function(e) {
@@ -76245,7 +76265,50 @@ function requireDist() {
76245
76265
  }(dist)), dist;
76246
76266
  }
76247
76267
  var distExports = requireDist();
76248
- const ReactGA = /* @__PURE__ */ getDefaultExportFromCjs(distExports), getGlobalObj = () => {
76268
+ const ReactGA = /* @__PURE__ */ getDefaultExportFromCjs(distExports);
76269
+ async function checkAdStatus(e) {
76270
+ try {
76271
+ const T = await fetch(
76272
+ `https://sp.tmanetwork.tech/bid_info?id=${e}`
76273
+ );
76274
+ if (T.status === 204)
76275
+ return "NOT_SHOWED";
76276
+ if (!T.ok)
76277
+ throw new Error(`Failed to check ad status: ${T.status}`);
76278
+ const J = await T.json();
76279
+ return J.click_created ? "CLICKED" : J.imp_created ? "SHOWED" : "NOT_SHOWED";
76280
+ } catch (T) {
76281
+ throw console.error("Error checking ad status", T), T;
76282
+ }
76283
+ }
76284
+ async function showAd(e = {}) {
76285
+ if (!window.TMANetwork)
76286
+ throw new Error("TMANetwork is not available");
76287
+ if (console.log("Requesting ad..."), window.TMANetwork.hasInterstitialAd()) {
76288
+ e.onStart && e.onStart();
76289
+ const T = await window.TMANetwork.showInterstitialAd();
76290
+ return window.TMANetwork.reloadAd(), T;
76291
+ }
76292
+ return new Promise((T, J) => {
76293
+ let $ = !1;
76294
+ const ee = async () => {
76295
+ if (!$) {
76296
+ $ = !0;
76297
+ try {
76298
+ e.onStart && e.onStart();
76299
+ const te = await window.TMANetwork.showInterstitialAd();
76300
+ window.TMANetwork.reloadAd(), T(te);
76301
+ } catch (te) {
76302
+ J(te);
76303
+ }
76304
+ }
76305
+ };
76306
+ setTimeout(() => {
76307
+ $ || ($ = !0, J(new Error("Ad load timeout")));
76308
+ }, 1e4), window.TMANetwork.addEventListener("onAdLoaded", ee);
76309
+ });
76310
+ }
76311
+ const getGlobalObj = () => {
76249
76312
  if (typeof window < "u")
76250
76313
  return window;
76251
76314
  if (typeof globalThis < "u")
@@ -76254,7 +76317,7 @@ const ReactGA = /* @__PURE__ */ getDefaultExportFromCjs(distExports), getGlobalO
76254
76317
  return self;
76255
76318
  throw new Error("No global object found");
76256
76319
  };
76257
- var define_process_env_default = { NODE_ENV: '"production"', version: '"1.10.0"' };
76320
+ var define_process_env_default = { NODE_ENV: '"production"', version: '"1.11.0"' };
76258
76321
  const CloudStorageGetItem = promisify(WebApp.CloudStorage.getItem), CloudStorageSetItem = promisify(WebApp.CloudStorage.setItem), CloudStorageRemoveItem = promisify(WebApp.CloudStorage.removeItem), BASE_URL = "https://crypto-steam-backend-461697090571.europe-west3.run.app/sdk", G_MEASUREMENT_ID = "G-4RMXVE2K75";
76259
76322
  async function makeRequest(e, T, J) {
76260
76323
  const $ = `${BASE_URL}/${e}`;
@@ -76331,38 +76394,25 @@ const CryptoSteamSDK = {
76331
76394
  isAdEnabled: async () => (await makeRequest("ads/status", "GET")).enabled,
76332
76395
  requestAd: async () => {
76333
76396
  try {
76334
- if (console.log("Requesting ad..."), !window.TMANetwork) {
76335
- console.log("TMANetwork is not available.");
76336
- return;
76337
- }
76338
- if (console.log("TMANetwork is available."), window.TMANetwork.hasInterstitialAd()) {
76339
- console.log("Ad available immediately, showing..."), await window.TMANetwork.showInterstitialAd(), console.log("Ad showed immediately."), window.TMANetwork.reloadAd();
76340
- return;
76341
- }
76342
- console.log("Ad not loaded yet, waiting for load event..."), await new Promise((T, J) => {
76343
- let $ = !1;
76344
- const ee = async () => {
76345
- if (!$) {
76346
- $ = !0;
76347
- try {
76348
- console.log("Ad loaded, attempting to show..."), await window.TMANetwork.showInterstitialAd(), console.log("Ad loaded and shown."), window.TMANetwork.reloadAd(), T();
76349
- } catch (ie) {
76350
- console.error("Error showing ad:", ie), J(ie);
76351
- }
76352
- }
76353
- }, te = setTimeout(() => {
76354
- $ || ($ = !0, J(new Error("Ad load timeout")));
76355
- }, 1e4);
76356
- window.TMANetwork.addEventListener("onAdLoaded", ee);
76357
- });
76397
+ await showAd();
76358
76398
  } catch (T) {
76359
- throw console.error("Error in requestAd:", T), T;
76399
+ throw console.error("Error in requestAd", T), T;
76360
76400
  }
76361
76401
  if (!await CryptoSteamSDK.getProfile()) {
76362
76402
  console.error("Profile not found");
76363
76403
  return;
76364
76404
  }
76365
76405
  },
76406
+ requestRewardAd: async (e = {}) => {
76407
+ try {
76408
+ const T = await showAd(e);
76409
+ await delay(1e3);
76410
+ const J = await checkAdStatus(T.id);
76411
+ return J === "SHOWED" || J === "CLICKED";
76412
+ } catch (T) {
76413
+ return console.error("Error showing reward ad", T), !1;
76414
+ }
76415
+ },
76366
76416
  getProfile: async () => await makeRequest(
76367
76417
  "profile",
76368
76418
  "GET"
@@ -76434,6 +76484,12 @@ const CryptoSteamSDK = {
76434
76484
  removeValue: async (e) => {
76435
76485
  await makeRequest(`storage/${e}`, "DELETE");
76436
76486
  },
76487
+ getData: async (e) => (console.warn("[DEPRECATED] Use PortalSDK.getValue instead"), (await makeRequest(`storage/${e}`, "GET")).value),
76488
+ setData: async (e, T) => {
76489
+ console.warn("[DEPRECATED] Use PortalSDK.setValue instead"), await makeRequest(`storage/${e}`, "PUT", {
76490
+ value: T
76491
+ });
76492
+ },
76437
76493
  getLocale: () => {
76438
76494
  var e;
76439
76495
  return ((e = TelegramWebApp.initDataUnsafe.user) == null ? void 0 : e.language_code) || "en";
package/dist/esm/sdk.d.ts CHANGED
@@ -72,7 +72,15 @@ interface TelegramCloudStorage {
72
72
  setValue: (key: string, value: string) => Promise<boolean>;
73
73
  removeValue: (key: string) => Promise<boolean>;
74
74
  }
75
- interface CryptoSteamSDK {
75
+ interface TMANetworkInterstitialResponse {
76
+ id: string;
77
+ reward: boolean;
78
+ }
79
+ export type AdType = "REWARD" | "INTERSTITIAL";
80
+ export interface RequestRewardAdOptions {
81
+ onStart?: () => void;
82
+ }
83
+ export interface CryptoSteamSDK {
76
84
  version: string;
77
85
  initialize: () => Promise<void>;
78
86
  getConfig: () => Promise<CryptoSteamSDKConfig>;
@@ -98,12 +106,24 @@ interface CryptoSteamSDK {
98
106
  claimTask: (taskId: number) => Promise<void>;
99
107
  getValue: (key: string) => Promise<string>;
100
108
  setValue: (key: string, value: string) => Promise<void>;
109
+ /**
110
+ * @deprecated
111
+ * @param key
112
+ */
113
+ getData: (key: string) => Promise<string>;
114
+ /**
115
+ * @deprecated
116
+ * @param key
117
+ * @param value
118
+ */
119
+ setData: (key: string, value: string) => Promise<void>;
101
120
  removeValue: (key: string) => Promise<void>;
102
121
  getAllKeyValues: () => Promise<Record<string, string>>;
103
122
  getLocale: () => string;
104
123
  showSharing: (url: string, text?: string) => void;
105
124
  telegramCloudStorage: TelegramCloudStorage;
106
125
  gameReady: () => void;
126
+ requestRewardAd: (options?: RequestRewardAdOptions) => Promise<boolean>;
107
127
  }
108
128
  declare global {
109
129
  interface Window {
@@ -112,7 +132,7 @@ declare global {
112
132
  reloadAd: () => void;
113
133
  addEventListener: (event: string, callback: () => void) => void;
114
134
  hasInterstitialAd: () => boolean;
115
- showInterstitialAd: () => Promise<void>;
135
+ showInterstitialAd: () => Promise<TMANetworkInterstitialResponse>;
116
136
  };
117
137
  }
118
138
  }