@lynx-js/web-elements 0.2.4

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 (204) hide show
  1. package/CHANGELOG.md +323 -0
  2. package/LICENSE.txt +202 -0
  3. package/Notice.txt +1 -0
  4. package/README.md +47 -0
  5. package/dist/LynxWrapper/LynxWrapper.d.ts +2 -0
  6. package/dist/LynxWrapper/LynxWrapper.js +27 -0
  7. package/dist/LynxWrapper/index.d.ts +1 -0
  8. package/dist/LynxWrapper/index.js +2 -0
  9. package/dist/ScrollView/FadeEdgeLengthAttribute.d.ts +10 -0
  10. package/dist/ScrollView/FadeEdgeLengthAttribute.js +43 -0
  11. package/dist/ScrollView/ScrollAttributes.d.ts +8 -0
  12. package/dist/ScrollView/ScrollAttributes.js +83 -0
  13. package/dist/ScrollView/ScrollIntoView.d.ts +9 -0
  14. package/dist/ScrollView/ScrollIntoView.js +71 -0
  15. package/dist/ScrollView/ScrollView.d.ts +31 -0
  16. package/dist/ScrollView/ScrollView.js +185 -0
  17. package/dist/ScrollView/ScrollViewEvents.d.ts +9 -0
  18. package/dist/ScrollView/ScrollViewEvents.js +146 -0
  19. package/dist/ScrollView/index.d.ts +1 -0
  20. package/dist/ScrollView/index.js +2 -0
  21. package/dist/XAudioTT/XAudioAttribute.d.ts +7 -0
  22. package/dist/XAudioTT/XAudioAttribute.js +93 -0
  23. package/dist/XAudioTT/XAudioEvents.d.ts +8 -0
  24. package/dist/XAudioTT/XAudioEvents.js +116 -0
  25. package/dist/XAudioTT/XAudioTT.d.ts +46 -0
  26. package/dist/XAudioTT/XAudioTT.js +183 -0
  27. package/dist/XAudioTT/index.d.ts +1 -0
  28. package/dist/XAudioTT/index.js +2 -0
  29. package/dist/XAudioTT/utils.d.ts +19 -0
  30. package/dist/XAudioTT/utils.js +66 -0
  31. package/dist/XCanvas/CanvasAttributes.d.ts +12 -0
  32. package/dist/XCanvas/CanvasAttributes.js +78 -0
  33. package/dist/XCanvas/XCanvas.d.ts +5 -0
  34. package/dist/XCanvas/XCanvas.js +32 -0
  35. package/dist/XCanvas/index.d.ts +1 -0
  36. package/dist/XCanvas/index.js +2 -0
  37. package/dist/XFoldViewNg/XFoldviewHeaderNg.d.ts +2 -0
  38. package/dist/XFoldViewNg/XFoldviewHeaderNg.js +32 -0
  39. package/dist/XFoldViewNg/XFoldviewHeaderNgFeatures.d.ts +9 -0
  40. package/dist/XFoldViewNg/XFoldviewHeaderNgFeatures.js +32 -0
  41. package/dist/XFoldViewNg/XFoldviewNg.d.ts +11 -0
  42. package/dist/XFoldViewNg/XFoldviewNg.js +52 -0
  43. package/dist/XFoldViewNg/XFoldviewNgEvents.d.ts +7 -0
  44. package/dist/XFoldViewNg/XFoldviewNgEvents.js +55 -0
  45. package/dist/XFoldViewNg/XFoldviewSlotDragNg.d.ts +2 -0
  46. package/dist/XFoldViewNg/XFoldviewSlotDragNg.js +30 -0
  47. package/dist/XFoldViewNg/XFoldviewSlotNg.d.ts +2 -0
  48. package/dist/XFoldViewNg/XFoldviewSlotNg.js +32 -0
  49. package/dist/XFoldViewNg/XFoldviewSlotNgTouchEventsHandler.d.ts +7 -0
  50. package/dist/XFoldViewNg/XFoldviewSlotNgTouchEventsHandler.js +105 -0
  51. package/dist/XFoldViewNg/XFoldviewToolbarNg.d.ts +2 -0
  52. package/dist/XFoldViewNg/XFoldviewToolbarNg.js +30 -0
  53. package/dist/XFoldViewNg/index.d.ts +5 -0
  54. package/dist/XFoldViewNg/index.js +6 -0
  55. package/dist/XImage/DropShadow.d.ts +6 -0
  56. package/dist/XImage/DropShadow.js +30 -0
  57. package/dist/XImage/FilterImage.d.ts +2 -0
  58. package/dist/XImage/FilterImage.js +31 -0
  59. package/dist/XImage/ImageEvents.d.ts +6 -0
  60. package/dist/XImage/ImageEvents.js +68 -0
  61. package/dist/XImage/ImageSrc.d.ts +7 -0
  62. package/dist/XImage/ImageSrc.js +61 -0
  63. package/dist/XImage/XImage.d.ts +2 -0
  64. package/dist/XImage/XImage.js +30 -0
  65. package/dist/XImage/index.d.ts +2 -0
  66. package/dist/XImage/index.js +3 -0
  67. package/dist/XInput/InputBaseAttributes.d.ts +9 -0
  68. package/dist/XInput/InputBaseAttributes.js +99 -0
  69. package/dist/XInput/Placeholder.d.ts +6 -0
  70. package/dist/XInput/Placeholder.js +60 -0
  71. package/dist/XInput/XInput.d.ts +28 -0
  72. package/dist/XInput/XInput.js +129 -0
  73. package/dist/XInput/XInputAttribute.d.ts +9 -0
  74. package/dist/XInput/XInputAttribute.js +52 -0
  75. package/dist/XInput/XInputEvents.d.ts +6 -0
  76. package/dist/XInput/XInputEvents.js +111 -0
  77. package/dist/XInput/index.d.ts +1 -0
  78. package/dist/XInput/index.js +2 -0
  79. package/dist/XList/ListItem.d.ts +2 -0
  80. package/dist/XList/ListItem.js +28 -0
  81. package/dist/XList/XList.d.ts +52 -0
  82. package/dist/XList/XList.js +257 -0
  83. package/dist/XList/XListAttributes.d.ts +8 -0
  84. package/dist/XList/XListAttributes.js +50 -0
  85. package/dist/XList/XListEvents.d.ts +7 -0
  86. package/dist/XList/XListEvents.js +356 -0
  87. package/dist/XList/index.d.ts +2 -0
  88. package/dist/XList/index.js +3 -0
  89. package/dist/XOverlayNg/XOverlayAttributes.d.ts +8 -0
  90. package/dist/XOverlayNg/XOverlayAttributes.js +80 -0
  91. package/dist/XOverlayNg/XOverlayNg.d.ts +2 -0
  92. package/dist/XOverlayNg/XOverlayNg.js +45 -0
  93. package/dist/XOverlayNg/index.d.ts +1 -0
  94. package/dist/XOverlayNg/index.js +2 -0
  95. package/dist/XRefreshView/XRefreshFooter.d.ts +3 -0
  96. package/dist/XRefreshView/XRefreshFooter.js +35 -0
  97. package/dist/XRefreshView/XRefreshHeader.d.ts +3 -0
  98. package/dist/XRefreshView/XRefreshHeader.js +35 -0
  99. package/dist/XRefreshView/XRefreshSubElementIntersectionObserver.d.ts +16 -0
  100. package/dist/XRefreshView/XRefreshSubElementIntersectionObserver.js +52 -0
  101. package/dist/XRefreshView/XRefreshView.d.ts +13 -0
  102. package/dist/XRefreshView/XRefreshView.js +125 -0
  103. package/dist/XRefreshView/XRefreshViewEventsEmitter.d.ts +8 -0
  104. package/dist/XRefreshView/XRefreshViewEventsEmitter.js +246 -0
  105. package/dist/XRefreshView/index.d.ts +3 -0
  106. package/dist/XRefreshView/index.js +4 -0
  107. package/dist/XSvg/XSvg.d.ts +8 -0
  108. package/dist/XSvg/XSvg.js +80 -0
  109. package/dist/XSvg/index.d.ts +1 -0
  110. package/dist/XSvg/index.js +2 -0
  111. package/dist/XSwiper/SwiperItem.d.ts +2 -0
  112. package/dist/XSwiper/SwiperItem.js +28 -0
  113. package/dist/XSwiper/XSwiper.d.ts +14 -0
  114. package/dist/XSwiper/XSwiper.js +231 -0
  115. package/dist/XSwiper/XSwiperAutoScroll.d.ts +8 -0
  116. package/dist/XSwiper/XSwiperAutoScroll.js +63 -0
  117. package/dist/XSwiper/XSwiperCircular.d.ts +8 -0
  118. package/dist/XSwiper/XSwiperCircular.js +191 -0
  119. package/dist/XSwiper/XSwiperEvents.d.ts +8 -0
  120. package/dist/XSwiper/XSwiperEvents.js +144 -0
  121. package/dist/XSwiper/XSwiperIndicator.d.ts +9 -0
  122. package/dist/XSwiper/XSwiperIndicator.js +118 -0
  123. package/dist/XSwiper/index.d.ts +2 -0
  124. package/dist/XSwiper/index.js +3 -0
  125. package/dist/XText/InlineImage.d.ts +11 -0
  126. package/dist/XText/InlineImage.js +56 -0
  127. package/dist/XText/InlineText.d.ts +5 -0
  128. package/dist/XText/InlineText.js +30 -0
  129. package/dist/XText/InlineTruncation.d.ts +5 -0
  130. package/dist/XText/InlineTruncation.js +42 -0
  131. package/dist/XText/RawText.d.ts +7 -0
  132. package/dist/XText/RawText.js +54 -0
  133. package/dist/XText/XText.d.ts +5 -0
  134. package/dist/XText/XText.js +49 -0
  135. package/dist/XText/XTextTruncation.d.ts +11 -0
  136. package/dist/XText/XTextTruncation.js +604 -0
  137. package/dist/XText/index.d.ts +5 -0
  138. package/dist/XText/index.js +6 -0
  139. package/dist/XTextarea/Placeholder.d.ts +7 -0
  140. package/dist/XTextarea/Placeholder.js +59 -0
  141. package/dist/XTextarea/TextareaBaseAttributes.d.ts +6 -0
  142. package/dist/XTextarea/TextareaBaseAttributes.js +70 -0
  143. package/dist/XTextarea/XTextarea.d.ts +21 -0
  144. package/dist/XTextarea/XTextarea.js +101 -0
  145. package/dist/XTextarea/XTextareaAttributes.d.ts +6 -0
  146. package/dist/XTextarea/XTextareaAttributes.js +81 -0
  147. package/dist/XTextarea/XTextareaEvents.d.ts +6 -0
  148. package/dist/XTextarea/XTextareaEvents.js +111 -0
  149. package/dist/XTextarea/index.d.ts +1 -0
  150. package/dist/XTextarea/index.js +2 -0
  151. package/dist/XView/BlurRadius.d.ts +7 -0
  152. package/dist/XView/BlurRadius.js +38 -0
  153. package/dist/XView/XBlurView.d.ts +2 -0
  154. package/dist/XView/XBlurView.js +29 -0
  155. package/dist/XView/XView.d.ts +4 -0
  156. package/dist/XView/XView.js +45 -0
  157. package/dist/XView/index.d.ts +2 -0
  158. package/dist/XView/index.js +3 -0
  159. package/dist/XViewpagerNg/XViewpagerItemNg.d.ts +2 -0
  160. package/dist/XViewpagerNg/XViewpagerItemNg.js +30 -0
  161. package/dist/XViewpagerNg/XViewpagerNg.d.ts +10 -0
  162. package/dist/XViewpagerNg/XViewpagerNg.js +98 -0
  163. package/dist/XViewpagerNg/XViewpagerNgEvents.d.ts +9 -0
  164. package/dist/XViewpagerNg/XViewpagerNgEvents.js +118 -0
  165. package/dist/XViewpagerNg/index.d.ts +2 -0
  166. package/dist/XViewpagerNg/index.js +3 -0
  167. package/dist/all.d.ts +16 -0
  168. package/dist/all.js +17 -0
  169. package/dist/common/Exposure.d.ts +28 -0
  170. package/dist/common/Exposure.js +193 -0
  171. package/dist/common/bindToIntersectionObserver.d.ts +1 -0
  172. package/dist/common/bindToIntersectionObserver.js +23 -0
  173. package/dist/common/commonEventInitConfiguration.d.ts +5 -0
  174. package/dist/common/commonEventInitConfiguration.js +9 -0
  175. package/dist/common/constants.d.ts +4 -0
  176. package/dist/common/constants.js +14 -0
  177. package/dist/common/convertLengthToPx.d.ts +1 -0
  178. package/dist/common/convertLengthToPx.js +25 -0
  179. package/dist/common/renameEvent.d.ts +1 -0
  180. package/dist/common/renameEvent.js +6 -0
  181. package/dist/common/throttle.d.ts +4 -0
  182. package/dist/common/throttle.js +40 -0
  183. package/dist/index.d.ts +4 -0
  184. package/dist/index.js +8 -0
  185. package/dist/lazy.d.ts +1 -0
  186. package/dist/lazy.js +106 -0
  187. package/index.css +19 -0
  188. package/package.json +110 -0
  189. package/src/LynxWrapper/lynx-wrapper.css +12 -0
  190. package/src/ScrollView/scroll-view.css +121 -0
  191. package/src/XAudioTT/x-audio-tt.css +3 -0
  192. package/src/XCanvas/x-canvas.css +16 -0
  193. package/src/XFoldViewNg/x-foldview-ng.css +80 -0
  194. package/src/XImage/x-image.css +82 -0
  195. package/src/XInput/x-input.css +48 -0
  196. package/src/XList/x-list.css +147 -0
  197. package/src/XOverlayNg/x-overlay-ng.css +56 -0
  198. package/src/XRefreshView/x-refresh-view.css +61 -0
  199. package/src/XSvg/x-svg.css +10 -0
  200. package/src/XSwiper/x-swiper.css +319 -0
  201. package/src/XText/x-text.css +272 -0
  202. package/src/XTextarea/x-textarea.css +49 -0
  203. package/src/XViewpagerNg/x-viewpager-ng.css +68 -0
  204. package/src/common-css/linear.css +386 -0
@@ -0,0 +1,8 @@
1
+ import { AttributeReactiveClass } from '@lynx-js/web-elements-reactive';
2
+ import type { XAudioTT } from './XAudioTT.js';
3
+ export declare class XAudioEvents implements InstanceType<AttributeReactiveClass<typeof HTMLElement>> {
4
+ #private;
5
+ static observedAttributes: never[];
6
+ constructor(dom: XAudioTT);
7
+ connectedCallback(): void;
8
+ }
@@ -0,0 +1,116 @@
1
+ /*
2
+ // Copyright 2024 The Lynx Authors. All rights reserved.
3
+ // Licensed under the Apache License Version 2.0 that can be found in the
4
+ // LICENSE file in the root directory of this source tree.
5
+ */
6
+ import { genDomGetter, } from '@lynx-js/web-elements-reactive';
7
+ import { audioLoadingStateMap, audioPlaybackStateMap, XAudioErrorCode, xAudioSrc, } from './utils.js';
8
+ import { commonComponentEventSetting } from '../common/commonEventInitConfiguration.js';
9
+ export class XAudioEvents {
10
+ static observedAttributes = [];
11
+ #dom;
12
+ #intervalPlay;
13
+ #getAudioElement = genDomGetter(() => this.#dom.shadowRoot, '#audio');
14
+ #playEvent = (event) => {
15
+ const attributeInterval = Number(this.#dom.getAttribute('interval'));
16
+ const delay = Number.isNaN(attributeInterval) ? 0 : attributeInterval;
17
+ this.#intervalPlay = setInterval(() => {
18
+ this.#dom.dispatchEvent(new CustomEvent('timeupdate', {
19
+ ...commonComponentEventSetting,
20
+ detail: {
21
+ currentTime: this.#getAudioElement().currentTime,
22
+ currentSrcID: this.#dom[xAudioSrc]?.id,
23
+ },
24
+ }));
25
+ }, delay);
26
+ const playbackState = audioPlaybackStateMap[event.type];
27
+ this.#dom.dispatchEvent(new CustomEvent('playbackstatechanged', {
28
+ ...commonComponentEventSetting,
29
+ detail: {
30
+ code: playbackState?.code,
31
+ type: playbackState?.type,
32
+ currentSrcID: this.#dom[xAudioSrc]?.id,
33
+ },
34
+ }));
35
+ };
36
+ #pauseEvent = (event) => {
37
+ clearInterval(this.#intervalPlay);
38
+ const playbackState = audioPlaybackStateMap[event.type];
39
+ this.#dom.dispatchEvent(new CustomEvent('playbackstatechanged', {
40
+ ...commonComponentEventSetting,
41
+ detail: {
42
+ code: playbackState?.code,
43
+ type: playbackState?.type,
44
+ currentSrcID: this.#dom[xAudioSrc]?.id,
45
+ },
46
+ }));
47
+ };
48
+ #loadingEvent = (event) => {
49
+ const loadingState = audioLoadingStateMap[event.type];
50
+ this.#dom.dispatchEvent(new CustomEvent('loadingstatechanged', {
51
+ ...commonComponentEventSetting,
52
+ detail: {
53
+ code: loadingState?.code,
54
+ type: loadingState?.type,
55
+ currentSrcID: this.#dom[xAudioSrc]?.id,
56
+ },
57
+ }));
58
+ };
59
+ #errorEvent = (event) => {
60
+ this.#loadingEvent(event);
61
+ const mediaCode = event.target?.error?.code;
62
+ let code = mediaCode === MediaError.MEDIA_ERR_DECODE
63
+ ? XAudioErrorCode.PlayerLoadingError
64
+ : XAudioErrorCode.PlayerPlaybackError;
65
+ if (mediaCode === MediaError.MEDIA_ERR_DECODE) {
66
+ code = XAudioErrorCode.PlayerLoadingError;
67
+ }
68
+ this.#dom.dispatchEvent(new CustomEvent('error', {
69
+ ...commonComponentEventSetting,
70
+ detail: {
71
+ code,
72
+ msg: '',
73
+ from: 'player',
74
+ currentSrcID: this.#dom[xAudioSrc]?.id,
75
+ },
76
+ }));
77
+ };
78
+ #endedEvent = () => {
79
+ const loop = this.#dom.getAttribute('loop') === null ? false : true;
80
+ this.#dom.dispatchEvent(new CustomEvent('finished', {
81
+ ...commonComponentEventSetting,
82
+ detail: {
83
+ loop,
84
+ currentSrcID: this.#dom[xAudioSrc]?.id,
85
+ },
86
+ }));
87
+ };
88
+ constructor(dom) {
89
+ this.#dom = dom;
90
+ }
91
+ connectedCallback() {
92
+ const audioElement = this.#getAudioElement();
93
+ audioElement.addEventListener('play', this.#playEvent, {
94
+ passive: true,
95
+ });
96
+ audioElement.addEventListener('pause', this.#pauseEvent, {
97
+ passive: true,
98
+ });
99
+ audioElement.addEventListener('ended', this.#endedEvent, {
100
+ passive: true,
101
+ });
102
+ audioElement.addEventListener('loadstart', this.#loadingEvent, {
103
+ passive: true,
104
+ });
105
+ audioElement.addEventListener('canplay', this.#loadingEvent, {
106
+ passive: true,
107
+ });
108
+ audioElement.addEventListener('stalled', this.#loadingEvent, {
109
+ passive: true,
110
+ });
111
+ audioElement.addEventListener('error', this.#errorEvent, {
112
+ passive: true,
113
+ });
114
+ }
115
+ }
116
+ //# sourceMappingURL=XAudioEvents.js.map
@@ -0,0 +1,46 @@
1
+ import { xAudioBlob, xAudioSrc } from './utils.js';
2
+ export declare class XAudioTT extends HTMLElement {
3
+ #private;
4
+ [xAudioSrc]?: {
5
+ id: string;
6
+ play_url: string;
7
+ };
8
+ [xAudioBlob]?: Promise<void>;
9
+ play(): {
10
+ currentSrcID: string | undefined;
11
+ loadingSrcID: string;
12
+ };
13
+ stop(): {
14
+ currentSrcID: string | undefined;
15
+ };
16
+ pause(): {
17
+ currentSrcID: string | undefined;
18
+ };
19
+ resume(): {
20
+ currentSrcID: string | undefined;
21
+ loadingSrcID: string;
22
+ };
23
+ seek(params: {
24
+ currentTime: number;
25
+ }): {
26
+ currentSrcID: string | undefined;
27
+ };
28
+ mute(params: {
29
+ mute: boolean;
30
+ }): {
31
+ currentSrcID: string | undefined;
32
+ };
33
+ playerInfo(): {
34
+ currentSrcID: string | undefined;
35
+ duration: number;
36
+ playbackState: number;
37
+ currentTime: number;
38
+ cacheTime: number;
39
+ };
40
+ prepare(): void;
41
+ setVolume(params: {
42
+ volume: number;
43
+ }): {
44
+ code: number;
45
+ };
46
+ }
@@ -0,0 +1,183 @@
1
+ import { __esDecorate, __runInitializers } from "tslib";
2
+ /*
3
+ // Copyright 2024 The Lynx Authors. All rights reserved.
4
+ // Licensed under the Apache License Version 2.0 that can be found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { Component, html, genDomGetter, bindToAttribute, } from '@lynx-js/web-elements-reactive';
8
+ import { XAudioAttribute } from './XAudioAttribute.js';
9
+ import { XAudioEvents } from './XAudioEvents.js';
10
+ import { LynxExposure } from '../common/Exposure.js';
11
+ import { commonComponentEventSetting } from '../common/commonEventInitConfiguration.js';
12
+ import { XAudioErrorCode, audioPlaybackStateMap, getAudioState, xAudioBlob, xAudioSrc, } from './utils.js';
13
+ let XAudioTT = (() => {
14
+ let _classDecorators = [Component('x-audio-tt', [LynxExposure, XAudioAttribute, XAudioEvents], html `<audio id="audio"></audio>`)];
15
+ let _classDescriptor;
16
+ let _classExtraInitializers = [];
17
+ let _classThis;
18
+ let _classSuper = HTMLElement;
19
+ var XAudioTT = class extends _classSuper {
20
+ static { _classThis = this; }
21
+ static {
22
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
23
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
24
+ XAudioTT = _classThis = _classDescriptor.value;
25
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
26
+ __runInitializers(_classThis, _classExtraInitializers);
27
+ }
28
+ #getAudio = genDomGetter(() => this.shadowRoot, '#audio');
29
+ #getAudioElement = genDomGetter(() => this.shadowRoot, '#audio');
30
+ #setAudioSrc = bindToAttribute(this.#getAudioElement, 'src');
31
+ [xAudioSrc];
32
+ [xAudioBlob];
33
+ #fetchAudio = () => {
34
+ const parsedSrc = this[xAudioSrc];
35
+ if (!parsedSrc || !parsedSrc.id || !parsedSrc.play_url) {
36
+ return;
37
+ }
38
+ let parsedHeaders;
39
+ try {
40
+ parsedHeaders = JSON.parse(this.getAttribute('headers') || '{}')
41
+ || {};
42
+ }
43
+ catch (error) {
44
+ console.error(`JSON.parse headers error: ${error}`);
45
+ parsedHeaders = {};
46
+ }
47
+ this[xAudioBlob] = new Promise(async (resolve, reject) => {
48
+ this.dispatchEvent(new CustomEvent('srcloadingstatechanged', {
49
+ ...commonComponentEventSetting,
50
+ detail: {
51
+ code: 0,
52
+ type: 'loading',
53
+ currentSrcID: parsedSrc.id,
54
+ },
55
+ }));
56
+ const response = await fetch(parsedSrc.play_url, {
57
+ headers: parsedHeaders,
58
+ });
59
+ if (!response.ok) {
60
+ this.dispatchEvent(new CustomEvent('error', {
61
+ ...commonComponentEventSetting,
62
+ detail: {
63
+ code: XAudioErrorCode.DownloadError,
64
+ msg: '',
65
+ from: 'res loader',
66
+ currentSrcID: parsedSrc.id,
67
+ },
68
+ }));
69
+ reject();
70
+ }
71
+ this.dispatchEvent(new CustomEvent('srcloadingstatechanged', {
72
+ ...commonComponentEventSetting,
73
+ detail: {
74
+ code: 1,
75
+ type: 'success',
76
+ currentSrcID: parsedSrc.id,
77
+ },
78
+ }));
79
+ const blob = await response.blob();
80
+ const blobUrl = URL.createObjectURL(blob);
81
+ this.#setAudioSrc(blobUrl);
82
+ resolve();
83
+ });
84
+ };
85
+ play() {
86
+ // If prepare method is not called, needs to fetch first
87
+ if (!this[xAudioBlob]) {
88
+ this.#fetchAudio();
89
+ }
90
+ this[xAudioBlob]?.then(() => {
91
+ const audio = this.#getAudio();
92
+ audio.currentTime = 0;
93
+ audio.play();
94
+ });
95
+ return {
96
+ currentSrcID: this[xAudioSrc]?.id,
97
+ loadingSrcID: '',
98
+ };
99
+ }
100
+ stop() {
101
+ const audio = this.#getAudio();
102
+ const playbackState = audioPlaybackStateMap['stop'];
103
+ this.dispatchEvent(new CustomEvent('playbackstatechanged', {
104
+ ...commonComponentEventSetting,
105
+ detail: {
106
+ code: playbackState?.code,
107
+ type: playbackState?.type,
108
+ currentSrcID: this[xAudioSrc]?.id,
109
+ },
110
+ }));
111
+ audio.currentTime = 0;
112
+ audio.pause();
113
+ return {
114
+ currentSrcID: this[xAudioSrc]?.id,
115
+ };
116
+ }
117
+ pause() {
118
+ const audio = this.#getAudio();
119
+ audio.pause();
120
+ return {
121
+ currentSrcID: this[xAudioSrc]?.id,
122
+ };
123
+ }
124
+ resume() {
125
+ const audio = this.#getAudio();
126
+ audio.play();
127
+ return {
128
+ currentSrcID: this[xAudioSrc]?.id,
129
+ loadingSrcID: '',
130
+ };
131
+ }
132
+ seek(params) {
133
+ const audio = this.#getAudio();
134
+ audio.currentTime = (params.currentTime || 0) / 1000;
135
+ this.dispatchEvent(new CustomEvent('seek', {
136
+ ...commonComponentEventSetting,
137
+ detail: {
138
+ seekresult: 1,
139
+ currentSrcID: this[xAudioSrc]?.id,
140
+ },
141
+ }));
142
+ return {
143
+ currentSrcID: this[xAudioSrc]?.id,
144
+ };
145
+ }
146
+ mute(params) {
147
+ const audio = this.#getAudio();
148
+ audio.muted = params.mute;
149
+ return {
150
+ currentSrcID: this[xAudioSrc]?.id,
151
+ };
152
+ }
153
+ playerInfo() {
154
+ const audioElement = this.#getAudio();
155
+ const buffered = audioElement.buffered;
156
+ const cacheTime = buffered.end(buffered.length - 1);
157
+ return {
158
+ currentSrcID: this[xAudioSrc]?.id,
159
+ duration: audioElement.duration * 1000,
160
+ playbackState: getAudioState(audioElement),
161
+ // playBitrate can not support now
162
+ currentTime: audioElement.currentTime,
163
+ cacheTime,
164
+ };
165
+ }
166
+ prepare() {
167
+ // if has fetched, no need to fetch again
168
+ if (!this[xAudioBlob]) {
169
+ this.#fetchAudio();
170
+ }
171
+ }
172
+ setVolume(params) {
173
+ const audio = this.#getAudio();
174
+ audio.volume = params.volume;
175
+ return {
176
+ code: 1,
177
+ };
178
+ }
179
+ };
180
+ return XAudioTT = _classThis;
181
+ })();
182
+ export { XAudioTT };
183
+ //# sourceMappingURL=XAudioTT.js.map
@@ -0,0 +1 @@
1
+ export { XAudioTT } from './XAudioTT.js';
@@ -0,0 +1,2 @@
1
+ export { XAudioTT } from './XAudioTT.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,19 @@
1
+ export declare const xAudioSrc: unique symbol;
2
+ export declare const xAudioBlob: unique symbol;
3
+ export declare const audioLoadingStateMap: Record<string, {
4
+ code: number;
5
+ type: string;
6
+ }>;
7
+ export declare const audioPlaybackStateMap: Record<string, {
8
+ code: number;
9
+ type: string;
10
+ }>;
11
+ export declare const getAudioState: (audioElement: HTMLAudioElement) => 0 | 2 | 1 | -1 | 3;
12
+ export declare const enum XAudioErrorCode {
13
+ SrcError = -1,
14
+ SrcJsonError = -2,
15
+ DownloadError = -3,
16
+ PlayerFinishedError = -4,
17
+ PlayerLoadingError = -5,
18
+ PlayerPlaybackError = -6
19
+ }
@@ -0,0 +1,66 @@
1
+ /*
2
+ // Copyright 2024 The Lynx Authors. All rights reserved.
3
+ // Licensed under the Apache License Version 2.0 that can be found in the
4
+ // LICENSE file in the root directory of this source tree.
5
+ */
6
+ export const xAudioSrc = Symbol('__src');
7
+ export const xAudioBlob = Symbol('__src');
8
+ export const audioLoadingStateMap = {
9
+ loadstart: {
10
+ code: 0,
11
+ type: 'init',
12
+ },
13
+ canplay: {
14
+ code: 1,
15
+ type: 'playable',
16
+ },
17
+ // Code 2 refers to the audio loading jam, which is a resource decoding problem
18
+ // cannot be implemented at present, use stalled replaced
19
+ stalled: {
20
+ code: 2,
21
+ type: 'stalled',
22
+ },
23
+ error: {
24
+ code: 3,
25
+ type: 'error',
26
+ },
27
+ };
28
+ export const audioPlaybackStateMap = {
29
+ stop: {
30
+ code: 0,
31
+ type: 'stopped',
32
+ },
33
+ play: {
34
+ code: 1,
35
+ type: 'playing',
36
+ },
37
+ pause: {
38
+ code: 2,
39
+ type: 'paused',
40
+ },
41
+ };
42
+ export const getAudioState = (audioElement) => {
43
+ if (!audioElement) {
44
+ return -1;
45
+ }
46
+ if (audioElement.paused) {
47
+ if (audioElement.ended) {
48
+ return 0;
49
+ }
50
+ return 2;
51
+ }
52
+ if (audioElement.currentTime > 0) {
53
+ return 1;
54
+ }
55
+ return 3;
56
+ };
57
+ export var XAudioErrorCode;
58
+ (function (XAudioErrorCode) {
59
+ XAudioErrorCode[XAudioErrorCode["SrcError"] = -1] = "SrcError";
60
+ XAudioErrorCode[XAudioErrorCode["SrcJsonError"] = -2] = "SrcJsonError";
61
+ XAudioErrorCode[XAudioErrorCode["DownloadError"] = -3] = "DownloadError";
62
+ XAudioErrorCode[XAudioErrorCode["PlayerFinishedError"] = -4] = "PlayerFinishedError";
63
+ XAudioErrorCode[XAudioErrorCode["PlayerLoadingError"] = -5] = "PlayerLoadingError";
64
+ XAudioErrorCode[XAudioErrorCode["PlayerPlaybackError"] = -6] = "PlayerPlaybackError";
65
+ })(XAudioErrorCode || (XAudioErrorCode = {}));
66
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,12 @@
1
+ import { AttributeReactiveClass } from '@lynx-js/web-elements-reactive';
2
+ import { XCanvas } from './XCanvas.js';
3
+ export declare class CanvasAttributes implements InstanceType<AttributeReactiveClass<typeof XCanvas>> {
4
+ #private;
5
+ static observedAttributes: string[];
6
+ constructor(dom: XCanvas);
7
+ handleName: (this: void, newVal: string | null) => void;
8
+ handleHeight: (this: void, newVal: string | null) => void;
9
+ handleWidth: (this: void, newVal: string | null) => void;
10
+ connectedCallback(): void;
11
+ dispose(): void;
12
+ }
@@ -0,0 +1,78 @@
1
+ import { __esDecorate, __runInitializers } from "tslib";
2
+ /*
3
+ // Copyright 2024 The Lynx Authors. All rights reserved.
4
+ // Licensed under the Apache License Version 2.0 that can be found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { bindToAttribute, genDomGetter, registerAttributeHandler, } from '@lynx-js/web-elements-reactive';
8
+ import { commonComponentEventSetting } from '../common/commonEventInitConfiguration.js';
9
+ let CanvasAttributes = (() => {
10
+ let _handleName_decorators;
11
+ let _handleName_initializers = [];
12
+ let _handleName_extraInitializers = [];
13
+ let _handleHeight_decorators;
14
+ let _handleHeight_initializers = [];
15
+ let _handleHeight_extraInitializers = [];
16
+ let _handleWidth_decorators;
17
+ let _handleWidth_initializers = [];
18
+ let _handleWidth_extraInitializers = [];
19
+ return class CanvasAttributes {
20
+ static {
21
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
22
+ _handleName_decorators = [registerAttributeHandler('name', true)];
23
+ _handleHeight_decorators = [registerAttributeHandler('height', true)];
24
+ _handleWidth_decorators = [registerAttributeHandler('height', true)];
25
+ __esDecorate(null, null, _handleName_decorators, { kind: "field", name: "handleName", static: false, private: false, access: { has: obj => "handleName" in obj, get: obj => obj.handleName, set: (obj, value) => { obj.handleName = value; } }, metadata: _metadata }, _handleName_initializers, _handleName_extraInitializers);
26
+ __esDecorate(null, null, _handleHeight_decorators, { kind: "field", name: "handleHeight", static: false, private: false, access: { has: obj => "handleHeight" in obj, get: obj => obj.handleHeight, set: (obj, value) => { obj.handleHeight = value; } }, metadata: _metadata }, _handleHeight_initializers, _handleHeight_extraInitializers);
27
+ __esDecorate(null, null, _handleWidth_decorators, { kind: "field", name: "handleWidth", static: false, private: false, access: { has: obj => "handleWidth" in obj, get: obj => obj.handleWidth, set: (obj, value) => { obj.handleWidth = value; } }, metadata: _metadata }, _handleWidth_initializers, _handleWidth_extraInitializers);
28
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
29
+ }
30
+ static observedAttributes = ['name', 'height', 'width'];
31
+ #dom;
32
+ #resizeObserver;
33
+ #getCanvas = genDomGetter(() => this.#dom.shadowRoot, '#canvas');
34
+ constructor(dom) {
35
+ this.#dom = dom;
36
+ }
37
+ handleName = __runInitializers(this, _handleName_initializers, bindToAttribute(this.#getCanvas, 'name'));
38
+ handleHeight = (__runInitializers(this, _handleName_extraInitializers), __runInitializers(this, _handleHeight_initializers, bindToAttribute(this.#getCanvas, 'height')));
39
+ handleWidth = (__runInitializers(this, _handleHeight_extraInitializers), __runInitializers(this, _handleWidth_initializers, bindToAttribute(this.#getCanvas, 'width')));
40
+ #resizeHandler = (__runInitializers(this, _handleWidth_extraInitializers), (entries) => {
41
+ const { contentRect } = entries[0];
42
+ const canvas = this.#dom.shadowRoot.firstElementChild;
43
+ if (canvas) {
44
+ let { height, width } = contentRect;
45
+ height = height * window.devicePixelRatio;
46
+ width = width * window.devicePixelRatio;
47
+ const resizeEvent = new CustomEvent('resize', {
48
+ ...commonComponentEventSetting,
49
+ detail: {
50
+ height,
51
+ width,
52
+ },
53
+ });
54
+ resizeEvent.height = height;
55
+ resizeEvent.width = width;
56
+ canvas.dispatchEvent(resizeEvent);
57
+ }
58
+ });
59
+ #startResizeObserver() {
60
+ if (!this.#resizeObserver) {
61
+ this.#resizeObserver = new ResizeObserver(this.#resizeHandler);
62
+ this.#resizeObserver.observe(this.#dom);
63
+ }
64
+ }
65
+ #stopResizeObserver() {
66
+ this.#resizeObserver?.disconnect();
67
+ this.#resizeObserver = undefined;
68
+ }
69
+ connectedCallback() {
70
+ this.#startResizeObserver();
71
+ }
72
+ dispose() {
73
+ this.#stopResizeObserver();
74
+ }
75
+ };
76
+ })();
77
+ export { CanvasAttributes };
78
+ //# sourceMappingURL=CanvasAttributes.js.map
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @deprecated this proposals cannot be implemented on other platforms
3
+ */
4
+ export declare class XCanvas extends HTMLElement {
5
+ }
@@ -0,0 +1,32 @@
1
+ import { __esDecorate, __runInitializers } from "tslib";
2
+ /*
3
+ // Copyright 2024 The Lynx Authors. All rights reserved.
4
+ // Licensed under the Apache License Version 2.0 that can be found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { Component, html } from '@lynx-js/web-elements-reactive';
8
+ import { LynxExposure } from '../common/Exposure.js';
9
+ import { CanvasAttributes } from './CanvasAttributes.js';
10
+ /**
11
+ * @deprecated this proposals cannot be implemented on other platforms
12
+ */
13
+ let XCanvas = (() => {
14
+ let _classDecorators = [Component('x-canvas', [LynxExposure, CanvasAttributes], html `<canvas id="canvas" part="canvas"></canvas>`)];
15
+ let _classDescriptor;
16
+ let _classExtraInitializers = [];
17
+ let _classThis;
18
+ let _classSuper = HTMLElement;
19
+ var XCanvas = class extends _classSuper {
20
+ static { _classThis = this; }
21
+ static {
22
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
23
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
24
+ XCanvas = _classThis = _classDescriptor.value;
25
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
26
+ __runInitializers(_classThis, _classExtraInitializers);
27
+ }
28
+ };
29
+ return XCanvas = _classThis;
30
+ })();
31
+ export { XCanvas };
32
+ //# sourceMappingURL=XCanvas.js.map
@@ -0,0 +1 @@
1
+ export { XCanvas } from './XCanvas.js';
@@ -0,0 +1,2 @@
1
+ export { XCanvas } from './XCanvas.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export declare class XFoldviewHeaderNg extends HTMLElement {
2
+ }
@@ -0,0 +1,32 @@
1
+ import { __esDecorate, __runInitializers } from "tslib";
2
+ /*
3
+ // Copyright 2024 The Lynx Authors. All rights reserved.
4
+ // Licensed under the Apache License Version 2.0 that can be found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { Component } from '@lynx-js/web-elements-reactive';
8
+ import { LynxExposure } from '../common/Exposure.js';
9
+ import { XFoldviewHeaderNgFeatures } from './XFoldviewHeaderNgFeatures.js';
10
+ let XFoldviewHeaderNg = (() => {
11
+ let _classDecorators = [Component('x-foldview-header-ng', [
12
+ LynxExposure,
13
+ XFoldviewHeaderNgFeatures,
14
+ ])];
15
+ let _classDescriptor;
16
+ let _classExtraInitializers = [];
17
+ let _classThis;
18
+ let _classSuper = HTMLElement;
19
+ var XFoldviewHeaderNg = class extends _classSuper {
20
+ static { _classThis = this; }
21
+ static {
22
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
23
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
24
+ XFoldviewHeaderNg = _classThis = _classDescriptor.value;
25
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
26
+ __runInitializers(_classThis, _classExtraInitializers);
27
+ }
28
+ };
29
+ return XFoldviewHeaderNg = _classThis;
30
+ })();
31
+ export { XFoldviewHeaderNg };
32
+ //# sourceMappingURL=XFoldviewHeaderNg.js.map
@@ -0,0 +1,9 @@
1
+ import type { AttributeReactiveClass } from '@lynx-js/web-elements-reactive';
2
+ import { XFoldviewHeaderNg } from './XFoldviewHeaderNg.js';
3
+ export declare class XFoldviewHeaderNgFeatures implements InstanceType<AttributeReactiveClass<typeof XFoldviewHeaderNg>> {
4
+ #private;
5
+ static observedAttributes: never[];
6
+ constructor(dom: XFoldviewHeaderNg);
7
+ connectedCallback(): void;
8
+ dispose(): void;
9
+ }
@@ -0,0 +1,32 @@
1
+ export class XFoldviewHeaderNgFeatures {
2
+ #dom;
3
+ #resizeObserver;
4
+ static observedAttributes = [];
5
+ constructor(dom) {
6
+ this.#dom = dom;
7
+ }
8
+ connectedCallback() {
9
+ this.#resizeObserver = new ResizeObserver(([resize]) => {
10
+ const parentElement = this.#dom.parentElement;
11
+ if (parentElement?.tagName === 'X-FOLDVIEW-NG') {
12
+ const slot = parentElement.querySelector('x-foldview-slot-ng');
13
+ if (slot) {
14
+ const offsetTop = slot.offsetTop;
15
+ const headerHeight = resize.contentRect.height;
16
+ if (offsetTop < headerHeight) {
17
+ slot.style.top = headerHeight - offsetTop + 'px';
18
+ parentElement.__scrollableLength = headerHeight - offsetTop;
19
+ }
20
+ }
21
+ }
22
+ });
23
+ this.#resizeObserver.observe(this.#dom);
24
+ }
25
+ dispose() {
26
+ if (this.#resizeObserver) {
27
+ this.#resizeObserver.disconnect();
28
+ this.#resizeObserver = undefined;
29
+ }
30
+ }
31
+ }
32
+ //# sourceMappingURL=XFoldviewHeaderNgFeatures.js.map