@ghchinoy/lit-audio-ui 0.5.1 → 0.6.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.
Files changed (40) hide show
  1. package/custom-elements.json +134 -60
  2. package/dist/components/atoms/ui-audio-next-button.js +9 -13
  3. package/dist/components/atoms/ui-audio-play-button.js +10 -14
  4. package/dist/components/atoms/ui-audio-player-error.js +10 -14
  5. package/dist/components/atoms/ui-audio-prev-button.js +9 -13
  6. package/dist/components/atoms/ui-audio-progress-slider.js +16 -20
  7. package/dist/components/atoms/ui-audio-time-display.js +15 -19
  8. package/dist/components/atoms/ui-audio-volume-slider.js +17 -21
  9. package/dist/components/atoms/ui-speech-cancel-button.js +5 -5
  10. package/dist/components/atoms/ui-speech-record-button.js +5 -5
  11. package/dist/components/atoms/ui-timed-text.js +14 -18
  12. package/dist/components/atoms/ui-voice-waveform.js +15 -19
  13. package/dist/components/molecules/ui-live-waveform.js +33 -32
  14. package/dist/components/molecules/ui-mic-selector.js +14 -18
  15. package/dist/components/molecules/ui-playlist.js +15 -19
  16. package/dist/components/molecules/ui-scrolling-waveform.js +30 -29
  17. package/dist/components/molecules/ui-spectrum-visualizer.js +23 -25
  18. package/dist/components/molecules/ui-speech-preview.js +16 -20
  19. package/dist/components/molecules/ui-voice-button.js +25 -29
  20. package/dist/components/molecules/ui-voice-picker.js +21 -25
  21. package/dist/components/molecules/ui-voice-pill.js +5 -5
  22. package/dist/components/molecules/ui-waveform.js +46 -36
  23. package/dist/components/organisms/ui-audio-player.js +7 -11
  24. package/dist/components/providers/ui-audio-provider.js +17 -22
  25. package/dist/components/providers/ui-speech-provider.js +13 -17
  26. package/dist/index.js +36 -36
  27. package/dist/node_modules/@chenglou/pretext/dist/analysis.js +456 -0
  28. package/dist/node_modules/@chenglou/pretext/dist/bidi.js +62 -0
  29. package/dist/node_modules/@chenglou/pretext/dist/layout.js +190 -0
  30. package/dist/node_modules/@chenglou/pretext/dist/line-break.js +234 -0
  31. package/dist/node_modules/@chenglou/pretext/dist/measurement.js +106 -0
  32. package/dist/scream-audio-ui.umd.js +45 -42
  33. package/dist/src/components/molecules/ui-waveform.d.ts +7 -1
  34. package/dist/src/components/providers/ui-audio-provider.d.ts +2 -1
  35. package/dist/src/utils/audio-context.d.ts +0 -1
  36. package/dist/src/utils/audio-utils.d.ts +8 -0
  37. package/dist/standalone/scream-audio-ui.standalone.js +2626 -1655
  38. package/dist/tsconfig.tsbuildinfo +1 -1
  39. package/dist/utils/audio-utils.js +27 -16
  40. package/package.json +7 -4
@@ -1,15 +1,12 @@
1
1
  import { audioPlayerContext as e } from "../../utils/audio-context.js";
2
- import { LitElement as t, css as n, html as r } from "lit";
3
- import { customElement as i, property as a, query as o, state as s } from "lit/decorators.js";
4
- import { provide as c } from "@lit/context";
5
- var l = function(e, t, n, r) {
6
- var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
7
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
8
- else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
9
- return i > 3 && a && Object.defineProperty(t, n, a), a;
10
- }, u = class extends t {
11
- constructor() {
12
- super(...arguments), this.src = "", this.items = [], this.autoAdvance = !0, this.loop = !1, this._animationFrameId = 0, this.state = {
2
+ import { __decorate as t } from "../../_virtual/_@oxc-project_runtime@0.113.0/helpers/decorate.js";
3
+ import { clearCache as n } from "../../node_modules/@chenglou/pretext/dist/layout.js";
4
+ import { LitElement as r, css as i, html as a } from "lit";
5
+ import { customElement as o, property as s, query as c, state as l } from "lit/decorators.js";
6
+ import { provide as u } from "@lit/context";
7
+ var d = class extends r {
8
+ constructor(...e) {
9
+ super(...e), this.src = "", this.items = [], this.autoAdvance = !0, this._animationFrameId = 0, this.state = {
13
10
  src: "",
14
11
  isPlaying: !1,
15
12
  isBuffering: !1,
@@ -17,7 +14,6 @@ var l = function(e, t, n, r) {
17
14
  duration: 0,
18
15
  volume: 1,
19
16
  muted: !1,
20
- loop: !1,
21
17
  items: [],
22
18
  currentIndex: -1,
23
19
  autoAdvance: !0,
@@ -35,7 +31,7 @@ var l = function(e, t, n, r) {
35
31
  };
36
32
  }
37
33
  static {
38
- this.styles = n`
34
+ this.styles = i`
39
35
  :host {
40
36
  display: contents; /* We are completely invisible, just wrapping children */
41
37
  }
@@ -44,12 +40,14 @@ var l = function(e, t, n, r) {
44
40
  }
45
41
  `;
46
42
  }
43
+ clearTextCache() {
44
+ n();
45
+ }
47
46
  render() {
48
- return r`
47
+ return a`
49
48
  <audio
50
49
  crossorigin="anonymous"
51
50
  src="${this.src}"
52
- ?loop="${this.loop}"
53
51
  preload="metadata"
54
52
  @loadedmetadata="${this._handleLoadedMetadata}"
55
53
  @ended="${this._handleEnded}"
@@ -69,7 +67,7 @@ var l = function(e, t, n, r) {
69
67
  src: this.src,
70
68
  currentTime: 0,
71
69
  error: void 0
72
- }), e.has("items") && (this._updateState({ items: this.items }), this.items.length > 0 && !this.src && this.state.currentIndex === -1 && this.select(0)), e.has("autoAdvance") && this._updateState({ autoAdvance: this.autoAdvance }), e.has("loop") && this._updateState({ loop: this.loop });
70
+ }), e.has("items") && (this._updateState({ items: this.items }), this.items.length > 0 && !this.src && this.state.currentIndex === -1 && this.select(0)), e.has("autoAdvance") && this._updateState({ autoAdvance: this.autoAdvance });
73
71
  }
74
72
  updated(e) {
75
73
  e.has("src") && this._audioEl && (this._audioEl.load(), this.state.isPlaying && setTimeout(() => {
@@ -147,10 +145,7 @@ var l = function(e, t, n, r) {
147
145
  this._updateState({ duration: this._audioEl.duration });
148
146
  }
149
147
  _handleEnded() {
150
- this.dispatchEvent(new CustomEvent("ended", {
151
- bubbles: !0,
152
- composed: !0
153
- })), this.autoAdvance && this.items.length > 0 ? this.next() : (this._updateState({
148
+ this.autoAdvance && this.items.length > 0 ? this.next() : (this._updateState({
154
149
  isPlaying: !1,
155
150
  currentTime: 0
156
151
  }), this._audioEl.currentTime = 0);
@@ -183,5 +178,5 @@ var l = function(e, t, n, r) {
183
178
  this._animationFrameId = requestAnimationFrame(e);
184
179
  }
185
180
  };
186
- l([a({ type: String })], u.prototype, "src", void 0), l([a({ type: Array })], u.prototype, "items", void 0), l([a({ type: Boolean })], u.prototype, "autoAdvance", void 0), l([a({ type: Boolean })], u.prototype, "loop", void 0), l([o("audio")], u.prototype, "_audioEl", void 0), l([c({ context: e }), s()], u.prototype, "state", void 0), u = l([i("ui-audio-provider")], u);
187
- export { u as UiAudioProvider };
181
+ t([s({ type: String })], d.prototype, "src", void 0), t([s({ type: Array })], d.prototype, "items", void 0), t([s({ type: Boolean })], d.prototype, "autoAdvance", void 0), t([c("audio")], d.prototype, "_audioEl", void 0), t([u({ context: e }), l()], d.prototype, "state", void 0), d = t([o("ui-audio-provider")], d);
182
+ export { d as UiAudioProvider };
@@ -1,16 +1,12 @@
1
- import { createMockAnalyser as e } from "../../utils/audio-utils.js";
2
- import { speechContext as t } from "../../utils/speech-context.js";
3
- import { LitElement as n, css as r, html as i } from "lit";
4
- import { customElement as a, property as o, state as s } from "lit/decorators.js";
5
- import { provide as c } from "@lit/context";
6
- var l = function(e, t, n, r) {
7
- var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
8
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
9
- else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
10
- return i > 3 && a && Object.defineProperty(t, n, a), a;
11
- }, u = class extends n {
12
- constructor() {
13
- super(...arguments), this._context = {
1
+ import { __decorate as e } from "../../_virtual/_@oxc-project_runtime@0.113.0/helpers/decorate.js";
2
+ import { createMockAnalyser as t } from "../../utils/audio-utils.js";
3
+ import { speechContext as n } from "../../utils/speech-context.js";
4
+ import { LitElement as r, css as i, html as a } from "lit";
5
+ import { customElement as o, property as s, state as c } from "lit/decorators.js";
6
+ import { provide as l } from "@lit/context";
7
+ var u = class extends r {
8
+ constructor(...e) {
9
+ super(...e), this._context = {
14
10
  state: "idle",
15
11
  transcript: "",
16
12
  partialTranscript: "",
@@ -30,7 +26,7 @@ var l = function(e, t, n, r) {
30
26
  ];
31
27
  }
32
28
  static {
33
- this.styles = r`
29
+ this.styles = i`
34
30
  :host {
35
31
  display: contents;
36
32
  }
@@ -50,7 +46,7 @@ var l = function(e, t, n, r) {
50
46
  return;
51
47
  }
52
48
  try {
53
- if (this._updateContext({ state: "connecting" }), this.simulation) this._analyser = e();
49
+ if (this._updateContext({ state: "connecting" }), this.simulation) this._analyser = t();
54
50
  else {
55
51
  let e = { audio: !0 };
56
52
  this.deviceId && (e.audio = { deviceId: { exact: this.deviceId } }), this._stream = await navigator.mediaDevices.getUserMedia(e), this._audioCtx ||= new (window.AudioContext || window.webkitAudioContext)();
@@ -131,8 +127,8 @@ var l = function(e, t, n, r) {
131
127
  }));
132
128
  }
133
129
  render() {
134
- return i`<slot></slot>`;
130
+ return a`<slot></slot>`;
135
131
  }
136
132
  };
137
- l([c({ context: t }), s()], u.prototype, "_context", void 0), l([o({ type: String })], u.prototype, "state", void 0), l([o({ type: Boolean })], u.prototype, "simulation", void 0), l([o({ type: Boolean })], u.prototype, "manual", void 0), l([o({ type: String })], u.prototype, "transcript", void 0), l([o({ type: String })], u.prototype, "partialTranscript", void 0), l([o({ type: String })], u.prototype, "deviceId", void 0), u = l([a("ui-speech-provider")], u);
133
+ e([l({ context: n }), c()], u.prototype, "_context", void 0), e([s({ type: String })], u.prototype, "state", void 0), e([s({ type: Boolean })], u.prototype, "simulation", void 0), e([s({ type: Boolean })], u.prototype, "manual", void 0), e([s({ type: String })], u.prototype, "transcript", void 0), e([s({ type: String })], u.prototype, "partialTranscript", void 0), e([s({ type: String })], u.prototype, "deviceId", void 0), u = e([o("ui-speech-provider")], u);
138
134
  export { u as UiSpeechProvider };
package/dist/index.js CHANGED
@@ -2,40 +2,40 @@ import { audioPlayerContext as e } from "./utils/audio-context.js";
2
2
  import { UiAudioPlayButton as t } from "./components/atoms/ui-audio-play-button.js";
3
3
  import { UiAudioNextButton as n } from "./components/atoms/ui-audio-next-button.js";
4
4
  import { UiAudioPrevButton as r } from "./components/atoms/ui-audio-prev-button.js";
5
- import { applyCanvasEdgeFade as i, createAudioAnalyser as a, createMockAnalyser as o, formatAudioTime as s, generateRandomAudioData as c, getNormalizedFrequencyData as l } from "./utils/audio-utils.js";
6
- import { UiAudioProgressSlider as u } from "./components/atoms/ui-audio-progress-slider.js";
7
- import { UiAudioTimeDisplay as d } from "./components/atoms/ui-audio-time-display.js";
8
- import { UiAudioPlayerError as f } from "./components/atoms/ui-audio-player-error.js";
9
- import { UiTimedText as p } from "./components/atoms/ui-timed-text.js";
10
- import { UiAudioVolumeSlider as m } from "./components/atoms/ui-audio-volume-slider.js";
11
- import { speechContext as h } from "./utils/speech-context.js";
12
- import { UiSpeechRecordButton as g } from "./components/atoms/ui-speech-record-button.js";
13
- import { UiSpeechCancelButton as _ } from "./components/atoms/ui-speech-cancel-button.js";
14
- import { UiLiveWaveform as v } from "./components/molecules/ui-live-waveform.js";
15
- import { UiVoiceWaveform as y } from "./components/atoms/ui-voice-waveform.js";
16
- import { UiShimmeringText as b } from "./components/atoms/ui-shimmering-text.js";
17
- import { UiMessageBubble as x } from "./components/atoms/ui-message-bubble.js";
18
- import { UiTypingDot as S } from "./components/atoms/ui-typing-dot.js";
19
- import { UiWaveform as C } from "./components/molecules/ui-waveform.js";
20
- import { UiScrollingWaveform as w } from "./components/molecules/ui-scrolling-waveform.js";
21
- import { UiSpectrumVisualizer as T } from "./components/molecules/ui-spectrum-visualizer.js";
22
- import { UiMicSelector as E } from "./components/molecules/ui-mic-selector.js";
23
- import { UiVoicePicker as D } from "./components/molecules/ui-voice-picker.js";
24
- import { UiSpeechPreview as O } from "./components/molecules/ui-speech-preview.js";
25
- import { UiOrb as k } from "./components/molecules/ui-orb.js";
26
- import { UiMovingGradient as A } from "./components/molecules/ui-moving-gradient.js";
27
- import { Ui3dFlip as j } from "./components/molecules/ui-3d-flip.js";
28
- import { UiPlaylist as M } from "./components/molecules/ui-playlist.js";
29
- import { UiShowcaseCard as N } from "./components/molecules/ui-showcase-card.js";
30
- import { UiVoiceButton as P } from "./components/molecules/ui-voice-button.js";
31
- import { UiVoicePill as F } from "./components/molecules/ui-voice-pill.js";
32
- import { UiSpeechProvider as I } from "./components/providers/ui-speech-provider.js";
33
- import { UiConversationBar as L } from "./components/molecules/ui-conversation-bar.js";
34
- import { ScreamVoiceButton as R } from "./components/molecules/scream-voice-button.js";
35
- import { UiTypingIndicator as z } from "./components/molecules/ui-typing-indicator.js";
36
- import { UiChatItem as B } from "./components/molecules/ui-chat-item.js";
37
- import { UiChatList as V } from "./components/molecules/ui-chat-list.js";
38
- import { UiAudioProvider as H } from "./components/providers/ui-audio-provider.js";
39
- import { UiAudioPlayer as U } from "./components/organisms/ui-audio-player.js";
5
+ import { applyCanvasEdgeFade as i, computeAudioPeaks as a, createAudioAnalyser as o, createMockAnalyser as s, formatAudioTime as c, generateRandomAudioData as l, getNormalizedFrequencyData as u } from "./utils/audio-utils.js";
6
+ import { UiAudioProgressSlider as d } from "./components/atoms/ui-audio-progress-slider.js";
7
+ import { UiAudioTimeDisplay as f } from "./components/atoms/ui-audio-time-display.js";
8
+ import { UiAudioPlayerError as p } from "./components/atoms/ui-audio-player-error.js";
9
+ import { UiTimedText as m } from "./components/atoms/ui-timed-text.js";
10
+ import { UiAudioVolumeSlider as h } from "./components/atoms/ui-audio-volume-slider.js";
11
+ import { speechContext as g } from "./utils/speech-context.js";
12
+ import { UiSpeechRecordButton as _ } from "./components/atoms/ui-speech-record-button.js";
13
+ import { UiSpeechCancelButton as v } from "./components/atoms/ui-speech-cancel-button.js";
14
+ import { UiLiveWaveform as y } from "./components/molecules/ui-live-waveform.js";
15
+ import { UiVoiceWaveform as b } from "./components/atoms/ui-voice-waveform.js";
16
+ import { UiShimmeringText as x } from "./components/atoms/ui-shimmering-text.js";
17
+ import { UiMessageBubble as S } from "./components/atoms/ui-message-bubble.js";
18
+ import { UiTypingDot as C } from "./components/atoms/ui-typing-dot.js";
19
+ import { UiWaveform as w } from "./components/molecules/ui-waveform.js";
20
+ import { UiScrollingWaveform as T } from "./components/molecules/ui-scrolling-waveform.js";
21
+ import { UiSpectrumVisualizer as E } from "./components/molecules/ui-spectrum-visualizer.js";
22
+ import { UiMicSelector as D } from "./components/molecules/ui-mic-selector.js";
23
+ import { UiVoicePicker as O } from "./components/molecules/ui-voice-picker.js";
24
+ import { UiSpeechPreview as k } from "./components/molecules/ui-speech-preview.js";
25
+ import { UiOrb as A } from "./components/molecules/ui-orb.js";
26
+ import { UiMovingGradient as j } from "./components/molecules/ui-moving-gradient.js";
27
+ import { Ui3dFlip as M } from "./components/molecules/ui-3d-flip.js";
28
+ import { UiPlaylist as N } from "./components/molecules/ui-playlist.js";
29
+ import { UiShowcaseCard as P } from "./components/molecules/ui-showcase-card.js";
30
+ import { UiVoiceButton as F } from "./components/molecules/ui-voice-button.js";
31
+ import { UiVoicePill as I } from "./components/molecules/ui-voice-pill.js";
32
+ import { UiSpeechProvider as L } from "./components/providers/ui-speech-provider.js";
33
+ import { UiConversationBar as R } from "./components/molecules/ui-conversation-bar.js";
34
+ import { ScreamVoiceButton as z } from "./components/molecules/scream-voice-button.js";
35
+ import { UiTypingIndicator as B } from "./components/molecules/ui-typing-indicator.js";
36
+ import { UiChatItem as V } from "./components/molecules/ui-chat-item.js";
37
+ import { UiChatList as H } from "./components/molecules/ui-chat-list.js";
38
+ import { UiAudioProvider as U } from "./components/providers/ui-audio-provider.js";
39
+ import { UiAudioPlayer as W } from "./components/organisms/ui-audio-player.js";
40
40
  import "@material/web/icon/icon.js";
41
- export { R as ScreamVoiceButton, j as Ui3dFlip, n as UiAudioNextButton, t as UiAudioPlayButton, U as UiAudioPlayer, f as UiAudioPlayerError, r as UiAudioPrevButton, u as UiAudioProgressSlider, H as UiAudioProvider, d as UiAudioTimeDisplay, m as UiAudioVolumeSlider, B as UiChatItem, V as UiChatList, L as UiConversationBar, v as UiLiveWaveform, x as UiMessageBubble, E as UiMicSelector, A as UiMovingGradient, k as UiOrb, M as UiPlaylist, w as UiScrollingWaveform, b as UiShimmeringText, N as UiShowcaseCard, T as UiSpectrumVisualizer, _ as UiSpeechCancelButton, O as UiSpeechPreview, I as UiSpeechProvider, g as UiSpeechRecordButton, p as UiTimedText, S as UiTypingDot, z as UiTypingIndicator, P as UiVoiceButton, D as UiVoicePicker, F as UiVoicePill, y as UiVoiceWaveform, C as UiWaveform, i as applyCanvasEdgeFade, e as audioPlayerContext, a as createAudioAnalyser, o as createMockAnalyser, s as formatAudioTime, c as generateRandomAudioData, l as getNormalizedFrequencyData, h as speechContext };
41
+ export { z as ScreamVoiceButton, M as Ui3dFlip, n as UiAudioNextButton, t as UiAudioPlayButton, W as UiAudioPlayer, p as UiAudioPlayerError, r as UiAudioPrevButton, d as UiAudioProgressSlider, U as UiAudioProvider, f as UiAudioTimeDisplay, h as UiAudioVolumeSlider, V as UiChatItem, H as UiChatList, R as UiConversationBar, y as UiLiveWaveform, S as UiMessageBubble, D as UiMicSelector, j as UiMovingGradient, A as UiOrb, N as UiPlaylist, T as UiScrollingWaveform, x as UiShimmeringText, P as UiShowcaseCard, E as UiSpectrumVisualizer, v as UiSpeechCancelButton, k as UiSpeechPreview, L as UiSpeechProvider, _ as UiSpeechRecordButton, m as UiTimedText, C as UiTypingDot, B as UiTypingIndicator, F as UiVoiceButton, O as UiVoicePicker, I as UiVoicePill, b as UiVoiceWaveform, w as UiWaveform, i as applyCanvasEdgeFade, e as audioPlayerContext, a as computeAudioPeaks, o as createAudioAnalyser, s as createMockAnalyser, c as formatAudioTime, l as generateRandomAudioData, u as getNormalizedFrequencyData, g as speechContext };