@velora-dex/widget 0.3.6 → 0.3.7-dev.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.
@@ -1,3 +1,3 @@
1
1
  import { WidgetProps } from './types';
2
- export declare const Widget: ({ config, provider, events, input }: WidgetProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const Widget: ({ config, apiConfig, provider, events, input, }: WidgetProps) => import("react/jsx-runtime").JSX.Element;
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.tsx"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAiB7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAqU3C,eAAO,MAAM,MAAM,GAAI,qCAAqC,WAAW,4CAatE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.tsx"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAiB7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAiV3C,eAAO,MAAM,MAAM,GAAI,iDAMpB,WAAW,4CAcb,CAAC"}
@@ -69,6 +69,7 @@ import { isBridgePrice } from '../hooks/swap/prices/delta/queries/useDeltaPriceQ
69
69
  import { BridgeSelectorExpandable } from '../components/widget/BridgeSelectorExpandable/BridgeSelectorExpandable.js';
70
70
  import { ErrorBoundary } from 'react-error-boundary';
71
71
  import { useInitialValue } from './screen/hooks/useInitialValue.js';
72
+ import { apiConfigAtom } from './state/apiConfigAtom.js';
72
73
 
73
74
  runSubscriptions();
74
75
  const SwapScreen = () => {
@@ -277,9 +278,10 @@ const App = () => {
277
278
  return t2;
278
279
  };
279
280
  const WidgetBase = (t0) => {
280
- const $ = distExports.c(70);
281
+ const $ = distExports.c(83);
281
282
  const {
282
283
  config: _config,
284
+ apiConfig,
283
285
  provider,
284
286
  events,
285
287
  input: formInputProps
@@ -287,6 +289,7 @@ const WidgetBase = (t0) => {
287
289
  const queryClient = useQueryClient();
288
290
  const setWidgetConfig = useSetAtom(setWidgetConfigAtom);
289
291
  const setSubConfig = useSetAtom(setSubConfigAtom);
292
+ const setApiConfig = useSetAtom(apiConfigAtom);
290
293
  let t1;
291
294
  if ($[0] !== _config) {
292
295
  t1 = _config || {};
@@ -361,75 +364,92 @@ const WidgetBase = (t0) => {
361
364
  } else {
362
365
  t3 = $[18];
363
366
  }
364
- const t4 = provider || null;
365
- let t5;
366
- if ($[19] !== t4) {
367
- t5 = [externalProviderAtom, t4];
368
- $[19] = t4;
369
- $[20] = t5;
367
+ let t4;
368
+ if ($[19] !== apiConfig) {
369
+ t4 = apiConfig || {};
370
+ $[19] = apiConfig;
371
+ $[20] = t4;
370
372
  } else {
371
- t5 = $[20];
373
+ t4 = $[20];
372
374
  }
373
- let t6;
374
- if ($[21] !== events) {
375
- t6 = events || {};
376
- $[21] = events;
377
- $[22] = t6;
375
+ let t5;
376
+ if ($[21] !== t4) {
377
+ t5 = [apiConfigAtom, t4];
378
+ $[21] = t4;
379
+ $[22] = t5;
378
380
  } else {
379
- t6 = $[22];
381
+ t5 = $[22];
380
382
  }
383
+ const t6 = provider || null;
381
384
  let t7;
382
385
  if ($[23] !== t6) {
383
- t7 = [widgetEventsAtom, t6];
386
+ t7 = [externalProviderAtom, t6];
384
387
  $[23] = t6;
385
388
  $[24] = t7;
386
389
  } else {
387
390
  t7 = $[24];
388
391
  }
389
392
  let t8;
390
- if ($[25] !== formInputProps) {
391
- t8 = formInputProps || {};
392
- $[25] = formInputProps;
393
+ if ($[25] !== events) {
394
+ t8 = events || {};
395
+ $[25] = events;
393
396
  $[26] = t8;
394
397
  } else {
395
398
  t8 = $[26];
396
399
  }
397
400
  let t9;
398
401
  if ($[27] !== t8) {
399
- t9 = [formInputPropsAtom, t8];
402
+ t9 = [widgetEventsAtom, t8];
400
403
  $[27] = t8;
401
404
  $[28] = t9;
402
405
  } else {
403
406
  t9 = $[28];
404
407
  }
405
408
  let t10;
406
- if ($[29] !== queryClient) {
407
- t10 = [queryClientAtom, queryClient];
408
- $[29] = queryClient;
409
+ if ($[29] !== formInputProps) {
410
+ t10 = formInputProps || {};
411
+ $[29] = formInputProps;
409
412
  $[30] = t10;
410
413
  } else {
411
414
  t10 = $[30];
412
415
  }
413
416
  let t11;
414
- if ($[31] !== t10 || $[32] !== t2 || $[33] !== t3 || $[34] !== t5 || $[35] !== t7 || $[36] !== t9) {
415
- t11 = [t2, t3, t5, t7, t9, t10];
417
+ if ($[31] !== t10) {
418
+ t11 = [formInputPropsAtom, t10];
416
419
  $[31] = t10;
417
- $[32] = t2;
418
- $[33] = t3;
419
- $[34] = t5;
420
- $[35] = t7;
421
- $[36] = t9;
422
- $[37] = t11;
420
+ $[32] = t11;
423
421
  } else {
424
- t11 = $[37];
422
+ t11 = $[32];
425
423
  }
426
- useHydrateAtoms(t11);
427
- useWidgetEventsSetter(events);
428
- useSetFormInputFromProps(formInputProps);
429
424
  let t12;
425
+ if ($[33] !== queryClient) {
426
+ t12 = [queryClientAtom, queryClient];
427
+ $[33] = queryClient;
428
+ $[34] = t12;
429
+ } else {
430
+ t12 = $[34];
431
+ }
430
432
  let t13;
431
- if ($[38] !== config.debug || $[39] !== config.enableCrossChain || $[40] !== config.enableDelta || $[41] !== config.ignoreBadUsdPrice || $[42] !== config.partner || $[43] !== config.privyAppId || $[44] !== config.privyClientId || $[45] !== config.theme || $[46] !== config.widgetMode || $[47] !== setWidgetConfig) {
432
- t12 = () => {
433
+ if ($[35] !== t11 || $[36] !== t12 || $[37] !== t2 || $[38] !== t3 || $[39] !== t5 || $[40] !== t7 || $[41] !== t9) {
434
+ t13 = [t2, t3, t5, t7, t9, t11, t12];
435
+ $[35] = t11;
436
+ $[36] = t12;
437
+ $[37] = t2;
438
+ $[38] = t3;
439
+ $[39] = t5;
440
+ $[40] = t7;
441
+ $[41] = t9;
442
+ $[42] = t13;
443
+ } else {
444
+ t13 = $[42];
445
+ }
446
+ useHydrateAtoms(t13);
447
+ useWidgetEventsSetter(events);
448
+ useSetFormInputFromProps(formInputProps);
449
+ let t14;
450
+ let t15;
451
+ if ($[43] !== config.debug || $[44] !== config.enableCrossChain || $[45] !== config.enableDelta || $[46] !== config.ignoreBadUsdPrice || $[47] !== config.partner || $[48] !== config.privyAppId || $[49] !== config.privyClientId || $[50] !== config.theme || $[51] !== config.widgetMode || $[52] !== setWidgetConfig) {
452
+ t14 = () => {
433
453
  setWidgetConfig({
434
454
  theme: config.theme,
435
455
  enableDelta: config.enableDelta,
@@ -442,28 +462,28 @@ const WidgetBase = (t0) => {
442
462
  ignoreBadUsdPrice: config.ignoreBadUsdPrice
443
463
  });
444
464
  };
445
- t13 = [config.theme, config.enableDelta, config.enableCrossChain, config.partner, config.privyAppId, config.privyClientId, config.debug, config.widgetMode, config.ignoreBadUsdPrice, setWidgetConfig];
446
- $[38] = config.debug;
447
- $[39] = config.enableCrossChain;
448
- $[40] = config.enableDelta;
449
- $[41] = config.ignoreBadUsdPrice;
450
- $[42] = config.partner;
451
- $[43] = config.privyAppId;
452
- $[44] = config.privyClientId;
453
- $[45] = config.theme;
454
- $[46] = config.widgetMode;
455
- $[47] = setWidgetConfig;
456
- $[48] = t12;
457
- $[49] = t13;
458
- } else {
459
- t12 = $[48];
460
- t13 = $[49];
461
- }
462
- useLayoutEffect(t12, t13);
463
- let t14;
464
- let t15;
465
- if ($[50] !== destChains || $[51] !== devURLs || $[52] !== excludeUI || $[53] !== setSubConfig || $[54] !== srcChains || $[55] !== tokenLists || $[56] !== tradeModes) {
466
- t14 = () => {
465
+ t15 = [config.theme, config.enableDelta, config.enableCrossChain, config.partner, config.privyAppId, config.privyClientId, config.debug, config.widgetMode, config.ignoreBadUsdPrice, setWidgetConfig];
466
+ $[43] = config.debug;
467
+ $[44] = config.enableCrossChain;
468
+ $[45] = config.enableDelta;
469
+ $[46] = config.ignoreBadUsdPrice;
470
+ $[47] = config.partner;
471
+ $[48] = config.privyAppId;
472
+ $[49] = config.privyClientId;
473
+ $[50] = config.theme;
474
+ $[51] = config.widgetMode;
475
+ $[52] = setWidgetConfig;
476
+ $[53] = t14;
477
+ $[54] = t15;
478
+ } else {
479
+ t14 = $[53];
480
+ t15 = $[54];
481
+ }
482
+ useLayoutEffect(t14, t15);
483
+ let t16;
484
+ let t17;
485
+ if ($[55] !== destChains || $[56] !== devURLs || $[57] !== excludeUI || $[58] !== setSubConfig || $[59] !== srcChains || $[60] !== tokenLists || $[61] !== tradeModes) {
486
+ t16 = () => {
467
487
  setSubConfig({
468
488
  srcChains,
469
489
  destChains,
@@ -473,97 +493,127 @@ const WidgetBase = (t0) => {
473
493
  devURLs
474
494
  });
475
495
  };
476
- t15 = [srcChains, destChains, tokenLists, setSubConfig, tradeModes, excludeUI, devURLs];
477
- $[50] = destChains;
478
- $[51] = devURLs;
479
- $[52] = excludeUI;
480
- $[53] = setSubConfig;
481
- $[54] = srcChains;
482
- $[55] = tokenLists;
483
- $[56] = tradeModes;
484
- $[57] = t14;
485
- $[58] = t15;
486
- } else {
487
- t14 = $[57];
488
- t15 = $[58];
496
+ t17 = [srcChains, destChains, tokenLists, setSubConfig, tradeModes, excludeUI, devURLs];
497
+ $[55] = destChains;
498
+ $[56] = devURLs;
499
+ $[57] = excludeUI;
500
+ $[58] = setSubConfig;
501
+ $[59] = srcChains;
502
+ $[60] = tokenLists;
503
+ $[61] = tradeModes;
504
+ $[62] = t16;
505
+ $[63] = t17;
506
+ } else {
507
+ t16 = $[62];
508
+ t17 = $[63];
489
509
  }
490
- useLayoutEffect(t14, t15);
510
+ useLayoutEffect(t16, t17);
511
+ let t18;
512
+ if ($[64] !== apiConfig?.apiKey || $[65] !== apiConfig?.headers || $[66] !== setApiConfig) {
513
+ t18 = () => {
514
+ setApiConfig({
515
+ apiKey: apiConfig?.apiKey,
516
+ headers: apiConfig?.headers
517
+ });
518
+ };
519
+ $[64] = apiConfig?.apiKey;
520
+ $[65] = apiConfig?.headers;
521
+ $[66] = setApiConfig;
522
+ $[67] = t18;
523
+ } else {
524
+ t18 = $[67];
525
+ }
526
+ const t19 = apiConfig?.apiKey;
527
+ const t20 = apiConfig?.headers;
528
+ let t21;
529
+ if ($[68] !== setApiConfig || $[69] !== t19 || $[70] !== t20) {
530
+ t21 = [t19, t20, setApiConfig];
531
+ $[68] = setApiConfig;
532
+ $[69] = t19;
533
+ $[70] = t20;
534
+ $[71] = t21;
535
+ } else {
536
+ t21 = $[71];
537
+ }
538
+ useLayoutEffect(t18, t21);
491
539
  const setExternalProvider = useSetAtom(externalProviderAtom);
492
- let t16;
493
- let t17;
494
- if ($[59] !== provider || $[60] !== setExternalProvider) {
495
- t16 = () => {
540
+ let t22;
541
+ let t23;
542
+ if ($[72] !== provider || $[73] !== setExternalProvider) {
543
+ t22 = () => {
496
544
  setExternalProvider(provider || null);
497
545
  };
498
- t17 = [provider, setExternalProvider];
499
- $[59] = provider;
500
- $[60] = setExternalProvider;
501
- $[61] = t16;
502
- $[62] = t17;
546
+ t23 = [provider, setExternalProvider];
547
+ $[72] = provider;
548
+ $[73] = setExternalProvider;
549
+ $[74] = t22;
550
+ $[75] = t23;
503
551
  } else {
504
- t16 = $[61];
505
- t17 = $[62];
552
+ t22 = $[74];
553
+ t23 = $[75];
506
554
  }
507
- useLayoutEffect(t16, t17);
555
+ useLayoutEffect(t22, t23);
508
556
  const isDappMode = config?.widgetMode === "dapp";
509
557
  const reconnectOnMountInit = useInitialValue(!isDappMode);
510
- let t18;
511
- let t19;
512
- let t20;
513
- let t21;
514
- let t22;
515
- if ($[63] === Symbol.for("react.memo_cache_sentinel")) {
516
- t18 = /* @__PURE__ */ jsx(AutoconnectExternalProvider, {});
517
- t19 = /* @__PURE__ */ jsx(PrivyIframeDependency, {});
518
- t20 = /* @__PURE__ */ jsx(Updaters, {});
519
- t21 = /* @__PURE__ */ jsx(App, {});
520
- t22 = false;
521
- $[63] = t18;
522
- $[64] = t19;
523
- $[65] = t20;
524
- $[66] = t21;
525
- $[67] = t22;
526
- } else {
527
- t18 = $[63];
528
- t19 = $[64];
529
- t20 = $[65];
530
- t21 = $[66];
531
- t22 = $[67];
532
- }
533
- let t23;
534
- if ($[68] !== reconnectOnMountInit) {
535
- t23 = /* @__PURE__ */ jsxs(Web3Providers, { reconnectOnMount: reconnectOnMountInit, children: [
536
- t18,
537
- t19,
538
- t20,
539
- t21,
540
- t22
558
+ let t24;
559
+ let t25;
560
+ let t26;
561
+ let t27;
562
+ let t28;
563
+ if ($[76] === Symbol.for("react.memo_cache_sentinel")) {
564
+ t24 = /* @__PURE__ */ jsx(AutoconnectExternalProvider, {});
565
+ t25 = /* @__PURE__ */ jsx(PrivyIframeDependency, {});
566
+ t26 = /* @__PURE__ */ jsx(Updaters, {});
567
+ t27 = /* @__PURE__ */ jsx(App, {});
568
+ t28 = false;
569
+ $[76] = t24;
570
+ $[77] = t25;
571
+ $[78] = t26;
572
+ $[79] = t27;
573
+ $[80] = t28;
574
+ } else {
575
+ t24 = $[76];
576
+ t25 = $[77];
577
+ t26 = $[78];
578
+ t27 = $[79];
579
+ t28 = $[80];
580
+ }
581
+ let t29;
582
+ if ($[81] !== reconnectOnMountInit) {
583
+ t29 = /* @__PURE__ */ jsxs(Web3Providers, { reconnectOnMount: reconnectOnMountInit, children: [
584
+ t24,
585
+ t25,
586
+ t26,
587
+ t27,
588
+ t28
541
589
  ] });
542
- $[68] = reconnectOnMountInit;
543
- $[69] = t23;
590
+ $[81] = reconnectOnMountInit;
591
+ $[82] = t29;
544
592
  } else {
545
- t23 = $[69];
593
+ t29 = $[82];
546
594
  }
547
- return t23;
595
+ return t29;
548
596
  };
549
597
  const Widget = (t0) => {
550
- const $ = distExports.c(5);
598
+ const $ = distExports.c(6);
551
599
  const {
552
600
  config,
601
+ apiConfig,
553
602
  provider,
554
603
  events,
555
604
  input
556
605
  } = t0;
557
606
  let t1;
558
- if ($[0] !== config || $[1] !== events || $[2] !== input || $[3] !== provider) {
559
- t1 = /* @__PURE__ */ jsx(JotaiProvider, { children: /* @__PURE__ */ jsx(QueryClientProvider, { children: /* @__PURE__ */ jsx(WidgetBase, { config, provider, events, input }) }) });
560
- $[0] = config;
561
- $[1] = events;
562
- $[2] = input;
563
- $[3] = provider;
564
- $[4] = t1;
565
- } else {
566
- t1 = $[4];
607
+ if ($[0] !== apiConfig || $[1] !== config || $[2] !== events || $[3] !== input || $[4] !== provider) {
608
+ t1 = /* @__PURE__ */ jsx(JotaiProvider, { children: /* @__PURE__ */ jsx(QueryClientProvider, { children: /* @__PURE__ */ jsx(WidgetBase, { config, apiConfig, provider, events, input }) }) });
609
+ $[0] = apiConfig;
610
+ $[1] = config;
611
+ $[2] = events;
612
+ $[3] = input;
613
+ $[4] = provider;
614
+ $[5] = t1;
615
+ } else {
616
+ t1 = $[5];
567
617
  }
568
618
  return t1;
569
619
  };