@internetarchive/elements 0.4.0 → 0.4.1

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.
Files changed (90) hide show
  1. package/dist/src/elements/ia-audio-element/ia-audio-element.d.ts.map +1 -1
  2. package/dist/src/elements/ia-audio-element/ia-audio-element.js +2 -1
  3. package/dist/src/elements/ia-audio-element/ia-audio-element.js.map +1 -1
  4. package/dist/src/elements/ia-button/ia-button.d.ts.map +1 -1
  5. package/dist/src/elements/ia-button/ia-button.js +2 -1
  6. package/dist/src/elements/ia-button/ia-button.js.map +1 -1
  7. package/dist/src/elements/ia-combo-box/ia-combo-box.d.ts.map +1 -1
  8. package/dist/src/elements/ia-combo-box/ia-combo-box.js +2 -1
  9. package/dist/src/elements/ia-combo-box/ia-combo-box.js.map +1 -1
  10. package/dist/src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.d.ts.map +1 -1
  11. package/dist/src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.js +2 -1
  12. package/dist/src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.js.map +1 -1
  13. package/dist/src/elements/ia-expandable-search-bar/ia-expandable-search-bar.d.ts.map +1 -1
  14. package/dist/src/elements/ia-expandable-search-bar/ia-expandable-search-bar.js +2 -1
  15. package/dist/src/elements/ia-expandable-search-bar/ia-expandable-search-bar.js.map +1 -1
  16. package/dist/src/elements/ia-expandable-search-bar/ia-quick-search.d.ts.map +1 -1
  17. package/dist/src/elements/ia-expandable-search-bar/ia-quick-search.js +2 -1
  18. package/dist/src/elements/ia-expandable-search-bar/ia-quick-search.js.map +1 -1
  19. package/dist/src/elements/ia-image-viewer/ia-image-viewer.d.ts.map +1 -1
  20. package/dist/src/elements/ia-image-viewer/ia-image-viewer.js +2 -1
  21. package/dist/src/elements/ia-image-viewer/ia-image-viewer.js.map +1 -1
  22. package/dist/src/elements/ia-image-viewer/ia-imgview-controls.d.ts.map +1 -1
  23. package/dist/src/elements/ia-image-viewer/ia-imgview-controls.js +2 -1
  24. package/dist/src/elements/ia-image-viewer/ia-imgview-controls.js.map +1 -1
  25. package/dist/src/elements/ia-image-viewer/ia-imgview-slide.d.ts.map +1 -1
  26. package/dist/src/elements/ia-image-viewer/ia-imgview-slide.js +2 -1
  27. package/dist/src/elements/ia-image-viewer/ia-imgview-slide.js.map +1 -1
  28. package/dist/src/elements/ia-item-navigator/ia-item-navigator.d.ts.map +1 -1
  29. package/dist/src/elements/ia-item-navigator/ia-item-navigator.js +2 -1
  30. package/dist/src/elements/ia-item-navigator/ia-item-navigator.js.map +1 -1
  31. package/dist/src/elements/ia-item-navigator/ia-itemnav-menu-button.d.ts.map +1 -1
  32. package/dist/src/elements/ia-item-navigator/ia-itemnav-menu-button.js +2 -1
  33. package/dist/src/elements/ia-item-navigator/ia-itemnav-menu-button.js.map +1 -1
  34. package/dist/src/elements/ia-item-navigator/ia-itemnav-menu-slider.d.ts.map +1 -1
  35. package/dist/src/elements/ia-item-navigator/ia-itemnav-menu-slider.js +2 -1
  36. package/dist/src/elements/ia-item-navigator/ia-itemnav-menu-slider.js.map +1 -1
  37. package/dist/src/elements/ia-item-navigator/ia-itemnav-no-theater-available.d.ts.map +1 -1
  38. package/dist/src/elements/ia-item-navigator/ia-itemnav-no-theater-available.js +2 -1
  39. package/dist/src/elements/ia-item-navigator/ia-itemnav-no-theater-available.js.map +1 -1
  40. package/dist/src/elements/ia-item-navigator/menus/ia-itemnav-share-panel.d.ts.map +1 -1
  41. package/dist/src/elements/ia-item-navigator/menus/ia-itemnav-share-panel.js +2 -1
  42. package/dist/src/elements/ia-item-navigator/menus/ia-itemnav-share-panel.js.map +1 -1
  43. package/dist/src/elements/ia-item-navigator/menus/ia-itemnav-sort-files-button.d.ts.map +1 -1
  44. package/dist/src/elements/ia-item-navigator/menus/ia-itemnav-sort-files-button.js +2 -1
  45. package/dist/src/elements/ia-item-navigator/menus/ia-itemnav-sort-files-button.js.map +1 -1
  46. package/dist/src/elements/ia-item-navigator/menus/ia-itemnav-viewable-files-panel.d.ts.map +1 -1
  47. package/dist/src/elements/ia-item-navigator/menus/ia-itemnav-viewable-files-panel.js +2 -1
  48. package/dist/src/elements/ia-item-navigator/menus/ia-itemnav-viewable-files-panel.js.map +1 -1
  49. package/dist/src/elements/ia-otp-form/ia-otp-form.d.ts.map +1 -1
  50. package/dist/src/elements/ia-otp-form/ia-otp-form.js +2 -1
  51. package/dist/src/elements/ia-otp-form/ia-otp-form.js.map +1 -1
  52. package/dist/src/elements/ia-otp-input/ia-otp-input.d.ts.map +1 -1
  53. package/dist/src/elements/ia-otp-input/ia-otp-input.js +2 -1
  54. package/dist/src/elements/ia-otp-input/ia-otp-input.js.map +1 -1
  55. package/dist/src/elements/ia-playback-controls/ia-playback-controls.d.ts.map +1 -1
  56. package/dist/src/elements/ia-playback-controls/ia-playback-controls.js +2 -1
  57. package/dist/src/elements/ia-playback-controls/ia-playback-controls.js.map +1 -1
  58. package/dist/src/elements/ia-radio-player/ia-radio-player.d.ts.map +1 -1
  59. package/dist/src/elements/ia-radio-player/ia-radio-player.js +2 -1
  60. package/dist/src/elements/ia-radio-player/ia-radio-player.js.map +1 -1
  61. package/dist/src/elements/ia-radio-player/ia-search-results-switcher.d.ts.map +1 -1
  62. package/dist/src/elements/ia-radio-player/ia-search-results-switcher.js +2 -1
  63. package/dist/src/elements/ia-radio-player/ia-search-results-switcher.js.map +1 -1
  64. package/dist/src/elements/ia-scrubber-bar/ia-scrubber-bar.d.ts.map +1 -1
  65. package/dist/src/elements/ia-scrubber-bar/ia-scrubber-bar.js +2 -1
  66. package/dist/src/elements/ia-scrubber-bar/ia-scrubber-bar.js.map +1 -1
  67. package/dist/src/elements/ia-scrubber-bar/ia-section-marker.d.ts.map +1 -1
  68. package/dist/src/elements/ia-scrubber-bar/ia-section-marker.js +2 -1
  69. package/dist/src/elements/ia-scrubber-bar/ia-section-marker.js.map +1 -1
  70. package/dist/src/elements/ia-sr-only-text/ia-sr-only-text.js +1 -1
  71. package/dist/src/elements/ia-sr-only-text/ia-sr-only-text.js.map +1 -1
  72. package/dist/src/elements/ia-status-indicator/ia-status-indicator.d.ts.map +1 -1
  73. package/dist/src/elements/ia-status-indicator/ia-status-indicator.js +2 -1
  74. package/dist/src/elements/ia-status-indicator/ia-status-indicator.js.map +1 -1
  75. package/dist/src/elements/ia-transcript-view/ia-transcript-entry.d.ts.map +1 -1
  76. package/dist/src/elements/ia-transcript-view/ia-transcript-entry.js +2 -1
  77. package/dist/src/elements/ia-transcript-view/ia-transcript-entry.js.map +1 -1
  78. package/dist/src/elements/ia-transcript-view/ia-transcript-view.d.ts.map +1 -1
  79. package/dist/src/elements/ia-transcript-view/ia-transcript-view.js +2 -1
  80. package/dist/src/elements/ia-transcript-view/ia-transcript-view.js.map +1 -1
  81. package/dist/src/elements/ia-waveform-progress/ia-waveform-progress.d.ts.map +1 -1
  82. package/dist/src/elements/ia-waveform-progress/ia-waveform-progress.js +2 -1
  83. package/dist/src/elements/ia-waveform-progress/ia-waveform-progress.js.map +1 -1
  84. package/dist/src/labs/ia-snow/ia-snow.js +1 -1
  85. package/dist/src/labs/ia-snow/ia-snow.js.map +1 -1
  86. package/dist/src/util/custom-element.d.ts +39 -0
  87. package/dist/src/util/custom-element.d.ts.map +1 -0
  88. package/dist/src/util/custom-element.js +50 -0
  89. package/dist/src/util/custom-element.js.map +1 -0
  90. package/package.json +1 -1
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Allow for custom element classes with private constructors.
3
+ */
4
+ type CustomElementClass = Omit<typeof HTMLElement, 'new'>;
5
+ /**
6
+ * Class decorator factory that registers the decorated class as a custom
7
+ * element, unless something has already claimed the tag name.
8
+ *
9
+ * Each element subpath is served to non-bundler consumers as a self-contained
10
+ * bundle, so a component several elements share, such as
11
+ * `ia-status-indicator`, is built into every entry point that imports it. A
12
+ * page pulling in two of those subpaths therefore evaluates two copies of the
13
+ * shared component and registers the same tag twice. `customElements.define`
14
+ * throws on the second attempt, and because that happens while the module is
15
+ * still evaluating it takes down the rest of the bundle with it, so the
16
+ * element the page actually asked for never registers.
17
+ *
18
+ * Skipping a duplicate keeps the first copy registered and lets the rest of
19
+ * the module finish. The copies are interchangeable: they are built from the
20
+ * same source, and nothing narrows a shared element by class identity.
21
+ *
22
+ * A skip is also how a page ends up on an element it did not mean to use:
23
+ * load two versions of the package together, or let a host page claim one of
24
+ * these tag names, and whichever registered first is what the page gets,
25
+ * which looks like the expected element's behaviour going missing. Nothing
26
+ * here can tell that apart from a matched-version duplicate, since two builds
27
+ * of the same element differ in nothing observable at this point, so a skip
28
+ * warns and leaves the reader to tell the cases apart.
29
+ *
30
+ * ```ts
31
+ * @customElement('ia-example')
32
+ * class IAExample extends LitElement {}
33
+ * ```
34
+ *
35
+ * @param tagName The tag name to register the element under.
36
+ */
37
+ export declare function customElement(tagName: string): (classOrTarget: CustomElementClass, context?: ClassDecoratorContext<new () => HTMLElement>) => void;
38
+ export {};
39
+ //# sourceMappingURL=custom-element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-element.d.ts","sourceRoot":"","sources":["../../../src/util/custom-element.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,KAAK,kBAAkB,GAAG,IAAI,CAAC,OAAO,WAAW,EAAE,KAAK,CAAC,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,IAEzC,eAAe,kBAAkB,EACjC,UAAU,qBAAqB,CAAC,UAAU,WAAW,CAAC,KACrD,IAAI,CAgBR"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Class decorator factory that registers the decorated class as a custom
3
+ * element, unless something has already claimed the tag name.
4
+ *
5
+ * Each element subpath is served to non-bundler consumers as a self-contained
6
+ * bundle, so a component several elements share, such as
7
+ * `ia-status-indicator`, is built into every entry point that imports it. A
8
+ * page pulling in two of those subpaths therefore evaluates two copies of the
9
+ * shared component and registers the same tag twice. `customElements.define`
10
+ * throws on the second attempt, and because that happens while the module is
11
+ * still evaluating it takes down the rest of the bundle with it, so the
12
+ * element the page actually asked for never registers.
13
+ *
14
+ * Skipping a duplicate keeps the first copy registered and lets the rest of
15
+ * the module finish. The copies are interchangeable: they are built from the
16
+ * same source, and nothing narrows a shared element by class identity.
17
+ *
18
+ * A skip is also how a page ends up on an element it did not mean to use:
19
+ * load two versions of the package together, or let a host page claim one of
20
+ * these tag names, and whichever registered first is what the page gets,
21
+ * which looks like the expected element's behaviour going missing. Nothing
22
+ * here can tell that apart from a matched-version duplicate, since two builds
23
+ * of the same element differ in nothing observable at this point, so a skip
24
+ * warns and leaves the reader to tell the cases apart.
25
+ *
26
+ * ```ts
27
+ * @customElement('ia-example')
28
+ * class IAExample extends LitElement {}
29
+ * ```
30
+ *
31
+ * @param tagName The tag name to register the element under.
32
+ */
33
+ export function customElement(tagName) {
34
+ return (classOrTarget, context) => {
35
+ const define = () => {
36
+ if (customElements.get(tagName)) {
37
+ console.warn(`[elements] <${tagName}> is already registered, so this definition was skipped and whatever registered first stays in use. Harmless when a page loads two element subpaths that share a component. Otherwise look for a second copy of the package, or an unrelated element using the same name.`);
38
+ return;
39
+ }
40
+ customElements.define(tagName, classOrTarget);
41
+ };
42
+ // Standard decorators defer registration to an initializer; the legacy
43
+ // decorators this project compiles with hand over the class directly.
44
+ if (context)
45
+ context.addInitializer(define);
46
+ else
47
+ define();
48
+ };
49
+ }
50
+ //# sourceMappingURL=custom-element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-element.js","sourceRoot":"","sources":["../../../src/util/custom-element.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,OAAO,CACL,aAAiC,EACjC,OAAsD,EAChD,EAAE;QACR,MAAM,MAAM,GAAG,GAAS,EAAE;YACxB,IAAI,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBAChC,OAAO,CAAC,IAAI,CACV,eAAe,OAAO,2QAA2Q,CAClS,CAAC;gBACF,OAAO;YACT,CAAC;YACD,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,aAAyC,CAAC,CAAC;QAC5E,CAAC,CAAC;QAEF,uEAAuE;QACvE,sEAAsE;QACtE,IAAI,OAAO;YAAE,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;;YACvC,MAAM,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Allow for custom element classes with private constructors.\n */\ntype CustomElementClass = Omit<typeof HTMLElement, 'new'>;\n\n/**\n * Class decorator factory that registers the decorated class as a custom\n * element, unless something has already claimed the tag name.\n *\n * Each element subpath is served to non-bundler consumers as a self-contained\n * bundle, so a component several elements share, such as\n * `ia-status-indicator`, is built into every entry point that imports it. A\n * page pulling in two of those subpaths therefore evaluates two copies of the\n * shared component and registers the same tag twice. `customElements.define`\n * throws on the second attempt, and because that happens while the module is\n * still evaluating it takes down the rest of the bundle with it, so the\n * element the page actually asked for never registers.\n *\n * Skipping a duplicate keeps the first copy registered and lets the rest of\n * the module finish. The copies are interchangeable: they are built from the\n * same source, and nothing narrows a shared element by class identity.\n *\n * A skip is also how a page ends up on an element it did not mean to use:\n * load two versions of the package together, or let a host page claim one of\n * these tag names, and whichever registered first is what the page gets,\n * which looks like the expected element's behaviour going missing. Nothing\n * here can tell that apart from a matched-version duplicate, since two builds\n * of the same element differ in nothing observable at this point, so a skip\n * warns and leaves the reader to tell the cases apart.\n *\n * ```ts\n * @customElement('ia-example')\n * class IAExample extends LitElement {}\n * ```\n *\n * @param tagName The tag name to register the element under.\n */\nexport function customElement(tagName: string) {\n return (\n classOrTarget: CustomElementClass,\n context?: ClassDecoratorContext<new () => HTMLElement>,\n ): void => {\n const define = (): void => {\n if (customElements.get(tagName)) {\n console.warn(\n `[elements] <${tagName}> is already registered, so this definition was skipped and whatever registered first stays in use. Harmless when a page loads two element subpaths that share a component. Otherwise look for a second copy of the package, or an unrelated element using the same name.`,\n );\n return;\n }\n customElements.define(tagName, classOrTarget as CustomElementConstructor);\n };\n\n // Standard decorators defer registration to an initializer; the legacy\n // decorators this project compiles with hand over the class directly.\n if (context) context.addInitializer(define);\n else define();\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/elements",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "A web component library from the Internet Archive.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "types": "./dist/src/elements/index.d.ts",