@lukso/transaction-view-core 0.7.0-dev.717f495 → 0.7.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,3 @@
1
- export { safeCustomElement } from '@lukso/core/utils';
2
1
  import * as lit from 'lit';
3
2
  import { LitElement, ReactiveController, ReactiveControllerHost, TemplateResult } from 'lit';
4
3
  import { CoreLitElement } from '../styles/index.cjs';
@@ -560,6 +559,34 @@ declare global {
560
559
  }
561
560
  }
562
561
 
562
+ /**
563
+ * SSR-safe custom element decorator that prevents duplicate registration errors.
564
+ *
565
+ * ## Why this exists
566
+ *
567
+ * The standard `@customElement()` decorator from Lit will throw an error if
568
+ * a component is registered twice. This can happen in SSR environments where:
569
+ * - Components are dynamically imported via multiple paths
570
+ * - HMR causes modules to be re-executed during development
571
+ * - Server and client bundles both try to register components
572
+ *
573
+ * ## Usage
574
+ *
575
+ * Use this instead of `@customElement()`:
576
+ * ```ts
577
+ * import { safeCustomElement } from './safe-custom-element'
578
+ *
579
+ * @safeCustomElement('my-component')
580
+ * export class MyComponent extends LitElement {
581
+ * // ...
582
+ * }
583
+ * ```
584
+ *
585
+ * @param tagName - The custom element tag name (must contain a hyphen)
586
+ * @returns A class decorator that safely registers the element
587
+ */
588
+ declare function safeCustomElement(tagName: string): <T extends CustomElementConstructor>(classOrDescriptor: T) => T;
589
+
563
590
  /**
564
591
  * ScrollToBottomButton (core) - reusable scroll helper.
565
592
  * Emits `scroll-to-bottom` when clicked.
@@ -873,4 +900,4 @@ declare global {
873
900
  }
874
901
  }
875
902
 
876
- export { type AddressData$1 as AddressData, AddressDisplay, AddressView, CustomOption, CustomSelect, FunctionNameView, GasProviderView, IconView, type ImageLoadState, ImageLoaderController, MultiSignalController, NotificationView, type ProgressSegment, ProgressView, ScrollToBottomButton, type SelectOption, SignalController, TransactionSignalController, TransactionViewController, type TransactionViewState, UrlView, ValueView, useImageLoader, useSignal, useSignals, useTransactionSignal, useTransactionView };
903
+ export { type AddressData$1 as AddressData, AddressDisplay, AddressView, CustomOption, CustomSelect, FunctionNameView, GasProviderView, IconView, type ImageLoadState, ImageLoaderController, MultiSignalController, NotificationView, type ProgressSegment, ProgressView, ScrollToBottomButton, type SelectOption, SignalController, TransactionSignalController, TransactionViewController, type TransactionViewState, UrlView, ValueView, safeCustomElement, useImageLoader, useSignal, useSignals, useTransactionSignal, useTransactionView };
@@ -1,4 +1,3 @@
1
- export { safeCustomElement } from '@lukso/core/utils';
2
1
  import * as lit from 'lit';
3
2
  import { LitElement, ReactiveController, ReactiveControllerHost, TemplateResult } from 'lit';
4
3
  import { CoreLitElement } from '../styles/index.js';
@@ -560,6 +559,34 @@ declare global {
560
559
  }
561
560
  }
562
561
 
562
+ /**
563
+ * SSR-safe custom element decorator that prevents duplicate registration errors.
564
+ *
565
+ * ## Why this exists
566
+ *
567
+ * The standard `@customElement()` decorator from Lit will throw an error if
568
+ * a component is registered twice. This can happen in SSR environments where:
569
+ * - Components are dynamically imported via multiple paths
570
+ * - HMR causes modules to be re-executed during development
571
+ * - Server and client bundles both try to register components
572
+ *
573
+ * ## Usage
574
+ *
575
+ * Use this instead of `@customElement()`:
576
+ * ```ts
577
+ * import { safeCustomElement } from './safe-custom-element'
578
+ *
579
+ * @safeCustomElement('my-component')
580
+ * export class MyComponent extends LitElement {
581
+ * // ...
582
+ * }
583
+ * ```
584
+ *
585
+ * @param tagName - The custom element tag name (must contain a hyphen)
586
+ * @returns A class decorator that safely registers the element
587
+ */
588
+ declare function safeCustomElement(tagName: string): <T extends CustomElementConstructor>(classOrDescriptor: T) => T;
589
+
563
590
  /**
564
591
  * ScrollToBottomButton (core) - reusable scroll helper.
565
592
  * Emits `scroll-to-bottom` when clicked.
@@ -873,4 +900,4 @@ declare global {
873
900
  }
874
901
  }
875
902
 
876
- export { type AddressData$1 as AddressData, AddressDisplay, AddressView, CustomOption, CustomSelect, FunctionNameView, GasProviderView, IconView, type ImageLoadState, ImageLoaderController, MultiSignalController, NotificationView, type ProgressSegment, ProgressView, ScrollToBottomButton, type SelectOption, SignalController, TransactionSignalController, TransactionViewController, type TransactionViewState, UrlView, ValueView, useImageLoader, useSignal, useSignals, useTransactionSignal, useTransactionView };
903
+ export { type AddressData$1 as AddressData, AddressDisplay, AddressView, CustomOption, CustomSelect, FunctionNameView, GasProviderView, IconView, type ImageLoadState, ImageLoaderController, MultiSignalController, NotificationView, type ProgressSegment, ProgressView, ScrollToBottomButton, type SelectOption, SignalController, TransactionSignalController, TransactionViewController, type TransactionViewState, UrlView, ValueView, safeCustomElement, useImageLoader, useSignal, useSignals, useTransactionSignal, useTransactionView };
@@ -9,18 +9,26 @@ var __decorateClass = (decorators, target, key, kind) => {
9
9
  return result;
10
10
  };
11
11
 
12
- // src/shared/index.ts
13
- import { safeCustomElement as safeCustomElement12 } from "@lukso/core/utils";
14
-
15
12
  // src/shared/address-display.ts
16
13
  import { Task } from "@lit/task";
17
- import { safeCustomElement } from "@lukso/core/utils";
18
14
  import {
19
15
  useAddressResolver,
20
16
  useImageLoader
21
17
  } from "@lukso/transaction-view-headless";
22
18
  import { css, html, LitElement } from "lit";
23
19
  import { property } from "lit/decorators.js";
20
+
21
+ // src/shared/safe-custom-element.ts
22
+ function safeCustomElement(tagName) {
23
+ return (classOrDescriptor) => {
24
+ if (typeof customElements !== "undefined" && !customElements.get(tagName)) {
25
+ customElements.define(tagName, classOrDescriptor);
26
+ }
27
+ return classOrDescriptor;
28
+ };
29
+ }
30
+
31
+ // src/shared/address-display.ts
24
32
  var AddressDisplay = class extends LitElement {
25
33
  constructor() {
26
34
  super(...arguments);
@@ -295,7 +303,6 @@ AddressDisplay = __decorateClass([
295
303
 
296
304
  // src/shared/address-view.ts
297
305
  import { Task as Task2 } from "@lit/task";
298
- import { safeCustomElement as safeCustomElement2 } from "@lukso/core/utils";
299
306
  import { useAddressResolver as useAddressResolver2 } from "@lukso/transaction-view-headless";
300
307
  import makeBlockie from "ethereum-blockies-base64";
301
308
  import { html as html2 } from "lit";
@@ -636,11 +643,10 @@ __decorateClass([
636
643
  state()
637
644
  ], AddressView.prototype, "identicon", 2);
638
645
  AddressView = __decorateClass([
639
- safeCustomElement2("address-view")
646
+ safeCustomElement("address-view")
640
647
  ], AddressView);
641
648
 
642
649
  // src/shared/custom-select.ts
643
- import { safeCustomElement as safeCustomElement3 } from "@lukso/core/utils";
644
650
  import { html as html3 } from "lit";
645
651
  import { property as property3 } from "lit/decorators.js";
646
652
  import makeBlockie2 from "ethereum-blockies-base64";
@@ -669,7 +675,7 @@ __decorateClass([
669
675
  property3({ type: Boolean, reflect: true })
670
676
  ], CustomOption.prototype, "hoverable", 2);
671
677
  CustomOption = __decorateClass([
672
- safeCustomElement3("custom-option")
678
+ safeCustomElement("custom-option")
673
679
  ], CustomOption);
674
680
  var CustomSelect = class extends CoreLitElement {
675
681
  constructor() {
@@ -786,11 +792,10 @@ __decorateClass([
786
792
  property3({ type: String })
787
793
  ], CustomSelect.prototype, "size", 2);
788
794
  CustomSelect = __decorateClass([
789
- safeCustomElement3("custom-select")
795
+ safeCustomElement("custom-select")
790
796
  ], CustomSelect);
791
797
 
792
798
  // src/shared/function-name-view.ts
793
- import { safeCustomElement as safeCustomElement4 } from "@lukso/core/utils";
794
799
  import { html as html4 } from "lit";
795
800
  import { property as property4 } from "lit/decorators.js";
796
801
  var FunctionNameView = class extends CoreLitElement {
@@ -867,11 +872,10 @@ __decorateClass([
867
872
  property4({ attribute: "color" })
868
873
  ], FunctionNameView.prototype, "color", 2);
869
874
  FunctionNameView = __decorateClass([
870
- safeCustomElement4("function-name-view")
875
+ safeCustomElement("function-name-view")
871
876
  ], FunctionNameView);
872
877
 
873
878
  // src/shared/gas-provider-view.ts
874
- import { safeCustomElement as safeCustomElement5 } from "@lukso/core/utils";
875
879
  import { html as html5 } from "lit";
876
880
  import { property as property5 } from "lit/decorators.js";
877
881
  var GasProviderView = class extends CoreLitElement {
@@ -1045,12 +1049,11 @@ __decorateClass([
1045
1049
  property5({ attribute: "relayer-reset-date", reflect: true })
1046
1050
  ], GasProviderView.prototype, "relayerResetDate", 2);
1047
1051
  GasProviderView = __decorateClass([
1048
- safeCustomElement5("gas-provider-view")
1052
+ safeCustomElement("gas-provider-view")
1049
1053
  ], GasProviderView);
1050
1054
 
1051
1055
  // src/shared/icon-view.ts
1052
1056
  import { Task as Task3 } from "@lit/task";
1053
- import { safeCustomElement as safeCustomElement6 } from "@lukso/core/utils";
1054
1057
  import {
1055
1058
  useAddressResolver as useAddressResolver3,
1056
1059
  useImageLoader as useImageLoader2
@@ -1235,7 +1238,7 @@ __decorateClass([
1235
1238
  property6({ type: Number, attribute: "image-index" })
1236
1239
  ], IconView.prototype, "imageIndex", 2);
1237
1240
  IconView = __decorateClass([
1238
- safeCustomElement6("icon-view")
1241
+ safeCustomElement("icon-view")
1239
1242
  ], IconView);
1240
1243
 
1241
1244
  // src/shared/image-loader-controller.ts
@@ -1341,7 +1344,6 @@ function useImageLoader3(host) {
1341
1344
  }
1342
1345
 
1343
1346
  // src/shared/notification-view.ts
1344
- import { safeCustomElement as safeCustomElement7 } from "@lukso/core/utils";
1345
1347
  import { html as html7 } from "lit";
1346
1348
  import { property as property7, state as state2 } from "lit/decorators.js";
1347
1349
  var NotificationView = class extends CoreLitElement {
@@ -1459,11 +1461,10 @@ __decorateClass([
1459
1461
  property7({ type: Boolean, reflect: true })
1460
1462
  ], NotificationView.prototype, "checked", 2);
1461
1463
  NotificationView = __decorateClass([
1462
- safeCustomElement7("notification-view")
1464
+ safeCustomElement("notification-view")
1463
1465
  ], NotificationView);
1464
1466
 
1465
1467
  // src/shared/progress-view.ts
1466
- import { safeCustomElement as safeCustomElement8 } from "@lukso/core/utils";
1467
1468
  import { html as html8 } from "lit";
1468
1469
  import { property as property8 } from "lit/decorators.js";
1469
1470
  var ProgressView = class extends CoreLitElement {
@@ -1524,11 +1525,10 @@ __decorateClass([
1524
1525
  property8({ attribute: "label-position" })
1525
1526
  ], ProgressView.prototype, "labelPosition", 2);
1526
1527
  ProgressView = __decorateClass([
1527
- safeCustomElement8("progress-view")
1528
+ safeCustomElement("progress-view")
1528
1529
  ], ProgressView);
1529
1530
 
1530
1531
  // src/shared/scroll-to-bottom-button.ts
1531
- import { safeCustomElement as safeCustomElement9 } from "@lukso/core/utils";
1532
1532
  import { html as html9 } from "lit";
1533
1533
  import { property as property9 } from "lit/decorators.js";
1534
1534
  var ScrollToBottomButton = class extends CoreLitElement {
@@ -1569,7 +1569,7 @@ __decorateClass([
1569
1569
  property9({ attribute: "icon-name" })
1570
1570
  ], ScrollToBottomButton.prototype, "iconName", 2);
1571
1571
  ScrollToBottomButton = __decorateClass([
1572
- safeCustomElement9("scroll-to-bottom-button")
1572
+ safeCustomElement("scroll-to-bottom-button")
1573
1573
  ], ScrollToBottomButton);
1574
1574
 
1575
1575
  // src/shared/signal-controller.ts
@@ -1877,7 +1877,6 @@ function useTransactionSignal(host, signal) {
1877
1877
  }
1878
1878
 
1879
1879
  // src/shared/url-view.ts
1880
- import { safeCustomElement as safeCustomElement10 } from "@lukso/core/utils";
1881
1880
  import { html as html10 } from "lit";
1882
1881
  import { property as property10, state as state3 } from "lit/decorators.js";
1883
1882
  var UrlView = class extends CoreLitElement {
@@ -1987,12 +1986,11 @@ __decorateClass([
1987
1986
  state3()
1988
1987
  ], UrlView.prototype, "displayName", 2);
1989
1988
  UrlView = __decorateClass([
1990
- safeCustomElement10("url-view")
1989
+ safeCustomElement("url-view")
1991
1990
  ], UrlView);
1992
1991
 
1993
1992
  // src/shared/value-view.ts
1994
1993
  import { Task as Task4 } from "@lit/task";
1995
- import { safeCustomElement as safeCustomElement11 } from "@lukso/core/utils";
1996
1994
  import { useAddressResolver as useAddressResolver4 } from "@lukso/transaction-view-headless";
1997
1995
  import { html as html11 } from "lit";
1998
1996
  import { property as property11, state as state4 } from "lit/decorators.js";
@@ -2377,7 +2375,7 @@ __decorateClass([
2377
2375
  state4()
2378
2376
  ], ValueView.prototype, "_hasSlotContent", 2);
2379
2377
  ValueView = __decorateClass([
2380
- safeCustomElement11("value-view")
2378
+ safeCustomElement("value-view")
2381
2379
  ], ValueView);
2382
2380
  export {
2383
2381
  AddressDisplay,
@@ -2397,7 +2395,7 @@ export {
2397
2395
  TransactionViewController,
2398
2396
  UrlView,
2399
2397
  ValueView,
2400
- safeCustomElement12 as safeCustomElement,
2398
+ safeCustomElement,
2401
2399
  useImageLoader3 as useImageLoader,
2402
2400
  useSignal,
2403
2401
  useSignals,