@orbit-software/sdk 1.83.1 → 1.83.2

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/esm/sdk.mjs CHANGED
@@ -1867,7 +1867,7 @@ function promisify(e) {
1867
1867
  };
1868
1868
  }
1869
1869
  promisify.argumentNames = "__ES6-PROMISIFY--CUSTOM-ARGUMENTS__", promisify.Promise = void 0;
1870
- const version = "1.83.1";
1870
+ const version = "1.83.2";
1871
1871
  var jsxRuntime = { exports: {} }, reactJsxRuntime_development = {}, hasRequiredReactJsxRuntime_development;
1872
1872
  function requireReactJsxRuntime_development() {
1873
1873
  if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
@@ -21957,7 +21957,7 @@ var Rr, F0, Removable = (F0 = class {
21957
21957
  clearGcTimeout() {
21958
21958
  J(this, Rr) && (timeoutManager.clearTimeout(J(this, Rr)), Te(this, Rr, void 0));
21959
21959
  }
21960
- }, Rr = new WeakMap(), F0), define_process_env_default$3 = { NODE_ENV: '"production"', version: '"1.83.1"' }, Ir, Ur, Jt, Mr, Ft, $r, Or, Xt, or, B0, Query = (B0 = class extends Removable {
21960
+ }, Rr = new WeakMap(), F0), define_process_env_default$3 = { NODE_ENV: '"production"', version: '"1.83.2"' }, Ir, Ur, Jt, Mr, Ft, $r, Or, Xt, or, B0, Query = (B0 = class extends Removable {
21961
21961
  constructor(t) {
21962
21962
  super();
21963
21963
  Ke(this, Xt);
@@ -37576,7 +37576,7 @@ function delay(e, { signal: t } = {}) {
37576
37576
  t == null || t.addEventListener("abort", o, { once: !0 });
37577
37577
  });
37578
37578
  }
37579
- var define_process_env_default$2 = { NODE_ENV: '"production"', version: '"1.83.1"' }, win;
37579
+ var define_process_env_default$2 = { NODE_ENV: '"production"', version: '"1.83.2"' }, win;
37580
37580
  if (typeof window > "u") {
37581
37581
  var loc = {
37582
37582
  hostname: ""
@@ -52811,7 +52811,7 @@ const balance$4 = "Balance", topUp$4 = "Top Up", ads$4 = "Ads", adsOn$4 = "On",
52811
52811
  topUpModal,
52812
52812
  inventoryModal
52813
52813
  };
52814
- var define_process_env_default$1 = { NODE_ENV: '"production"', version: '"1.83.1"' };
52814
+ var define_process_env_default$1 = { NODE_ENV: '"production"', version: '"1.83.2"' };
52815
52815
  const resources = {
52816
52816
  en: {
52817
52817
  translation: en
@@ -53342,7 +53342,7 @@ function throttleLeading(e, t) {
53342
53342
  return a - i >= t ? (i = a, e.apply(this, s)) : (console.log(`Function is throttled. Next call available in ${t - (a - i)}ms`), Promise.resolve(!1));
53343
53343
  };
53344
53344
  }
53345
- var define_process_env_default = { NODE_ENV: '"production"', version: '"1.83.1"' };
53345
+ var define_process_env_default = { NODE_ENV: '"production"', version: '"1.83.2"' };
53346
53346
  init({
53347
53347
  dsn: "https://b52384170118e5a8b1f43ca653975198@o4509677809172480.ingest.de.sentry.io/4509677817364560",
53348
53348
  sendDefaultPii: !0
@@ -53353,28 +53353,56 @@ const CloudStorageGetItem = promisify(WebApp.CloudStorage.getItem), CloudStorage
53353
53353
  let timer;
53354
53354
  const pending = {};
53355
53355
  let state = {};
53356
+ const CLOUD_STORAGE_PREFIX = "sdk_pending_";
53356
53357
  function setValueSync(e, t) {
53357
- state[e] = pending[e] = t;
53358
+ state[e] = pending[e] = t, CloudStorageSetItem(`${CLOUD_STORAGE_PREFIX}${e}`, t).catch((i) => {
53359
+ console.error(`Failed to save ${e} to CloudStorage:`, i);
53360
+ });
53358
53361
  }
53359
53362
  function removeValueSync(e) {
53360
- delete state[e], delete pending[e], makeRequest(`storage/${e}`, "DELETE").catch(console.error);
53363
+ delete state[e], delete pending[e], CloudStorageRemoveItem(`${CLOUD_STORAGE_PREFIX}${e}`).catch(console.error), makeRequest(`storage/${e}`, "DELETE").catch(console.error);
53361
53364
  }
53362
53365
  function getValueSync(e) {
53363
53366
  return state[e];
53364
53367
  }
53365
53368
  async function loadAll() {
53366
- const e = [500, 500, 1e3];
53367
- let t = 0;
53369
+ const e = {};
53370
+ try {
53371
+ const a = await promisify(WebApp.CloudStorage.getKeys)();
53372
+ for (const o of a)
53373
+ if (o.startsWith(CLOUD_STORAGE_PREFIX))
53374
+ try {
53375
+ const l = await CloudStorageGetItem(o);
53376
+ if (l) {
53377
+ const c = o.replace(CLOUD_STORAGE_PREFIX, "");
53378
+ e[c] = l, console.log(`Loaded from CloudStorage: ${c}`);
53379
+ }
53380
+ } catch (l) {
53381
+ console.error(`Failed to load ${o} from CloudStorage:`, l);
53382
+ }
53383
+ } catch (s) {
53384
+ console.error("Failed to load keys from CloudStorage:", s);
53385
+ }
53386
+ const t = [500, 500, 1e3];
53387
+ let i = 0;
53368
53388
  for (; ; )
53369
53389
  try {
53370
- state = (await makeRequest("storage/", "GET")).data;
53390
+ const s = await makeRequest("storage/", "GET");
53391
+ state = { ...s.data, ...e };
53392
+ for (const a of Object.keys(e))
53393
+ pending[a] = e[a];
53394
+ console.log(
53395
+ `Loaded state from backend (${Object.keys(s.data).length} keys) and CloudStorage (${Object.keys(e).length} keys)`
53396
+ );
53371
53397
  return;
53372
- } catch (i) {
53373
- if (t >= e.length) {
53374
- console.error("Failed to load all storage values:", i), state = {};
53398
+ } catch (s) {
53399
+ if (i >= t.length) {
53400
+ console.error("Failed to load all storage values:", s), state = e;
53401
+ for (const a of Object.keys(e))
53402
+ pending[a] = e[a];
53375
53403
  return;
53376
53404
  }
53377
- await delay(e[t]), t += 1;
53405
+ await delay(t[i]), i += 1;
53378
53406
  }
53379
53407
  }
53380
53408
  function startSaveTick() {
@@ -53390,9 +53418,18 @@ async function savePendingChanges() {
53390
53418
  let a = 0, o = !1;
53391
53419
  for (; !o; )
53392
53420
  try {
53393
- await makeRequest(`storage/${t}`, "PUT", {
53421
+ if (await makeRequest(`storage/${t}`, "PUT", {
53394
53422
  value: i
53395
- }), delete pending[t], o = !0;
53423
+ }), pending[t] === i) {
53424
+ delete pending[t];
53425
+ try {
53426
+ await CloudStorageRemoveItem(`${CLOUD_STORAGE_PREFIX}${t}`), console.log(`Removed ${t} from CloudStorage after successful sync`);
53427
+ } catch (l) {
53428
+ console.error(`Failed to remove ${t} from CloudStorage:`, l);
53429
+ }
53430
+ } else
53431
+ console.log(`Value for ${t} changed during save, keeping in pending`);
53432
+ o = !0;
53396
53433
  } catch (l) {
53397
53434
  if (a >= s.length) {
53398
53435
  console.error(`Failed to save key ${t}:`, l);